home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2058 / schedule.c < prev   
Encoding:
C/C++ Source or Header  |  1990-12-28  |  2.6 KB  |  103 lines

  1. /*
  2.  *    schedule.c : The schedule editor window
  3.  *
  4.  *    $Id: schedule.c,v 1.1 90/11/07 11:23:13 ferguson Exp $
  5.  */
  6. #include <X11/Intrinsic.h>
  7. #include <X11/Shell.h>
  8. #include <X11/StringDefs.h>
  9. #include <X11/Xaw/Form.h>
  10. #include <X11/Xaw/Command.h>
  11. #include <X11/Xaw/Cardinals.h>
  12. #include "widgets.h"
  13. #include "month.h"
  14. #include "day.h"
  15. #include "db.h"
  16. #include "date-strings.h"
  17.  
  18. extern int appointsChanged;
  19.  
  20. /*
  21.  * Functions defined in this file
  22.  */
  23. void createPopupSchedule();
  24. static void dismissSchedProc(), applySchedProc();
  25.  
  26. /*
  27.  * Data defined in this file
  28.  */
  29. static Widget schedulePopupShell;
  30. static DayFormData *scheduleDayFormDatas[7];
  31. static void dismissSchedProc(),applySchedProc();
  32.  
  33. /*    -    -    -    -    -    -    -    -    */
  34.  
  35. void
  36. createPopupSchedule()
  37. {
  38.     Widget form,dismiss,apply,w;
  39.     Arg args[1];
  40.     int dow,i;
  41.     char *s;
  42.  
  43.     schedulePopupShell = XtCreatePopupShell("schedulePopupShell",
  44.                 topLevelShellWidgetClass,toplevel,NULL,ZERO);
  45.     form = XtCreateManagedWidget("popupForm",formWidgetClass,schedulePopupShell,
  46.                                 NULL,ZERO);
  47.     dismiss = XtCreateManagedWidget("dismissSchedButton",commandWidgetClass,
  48.                             form,NULL,ZERO);
  49.     apply = XtCreateManagedWidget("applySchedButton",commandWidgetClass,form,
  50.                                 NULL,ZERO);
  51.     XtAddCallback(dismiss,"callback",dismissSchedProc,NULL);
  52.     XtAddCallback(apply,"callback",applySchedProc,NULL);
  53.     w = NULL;
  54.     for (dow=0; dow < 7; dow++) {
  55.     scheduleDayFormDatas[dow] = createDayFormData(form);
  56.     XtSetArg(args[0],XtNfromHoriz,w);
  57.     XtSetValues(scheduleDayFormDatas[dow]->form,args,ONE);
  58.     XtSetArg(args[0],XtNlabel,longDayStr[dow]);
  59.     XtSetValues(scheduleDayFormDatas[dow]->date,args,ONE);
  60.     w = scheduleDayFormDatas[dow]->form;
  61.     for (i=0; i < 22; i++)
  62.         if ((s=lookupScheduleDow(i,dow)) != NULL) {
  63.         XtSetArg(args[0],XtNstring,s);
  64.         XtSetValues(scheduleDayFormDatas[dow]->items[i]->text,args,ONE);
  65.         }
  66.     }
  67.     XtPopup(schedulePopupShell,XtGrabNone);
  68. }
  69.  
  70. static void
  71. dismissSchedProc(w,client_data,call_data)
  72. Widget w;
  73. caddr_t client_data,call_data;
  74. {
  75.     XtPopdown(schedulePopupShell);
  76.     XtDestroyWidget(schedulePopupShell);
  77. }
  78.  
  79. static void
  80. applySchedProc(w,client_data,call_data)
  81. Widget w;
  82. caddr_t client_data,call_data;
  83. {
  84.     Arg args[1];
  85.     char *new,*old;
  86.     int dow,i;
  87.  
  88.     XtSetArg(args[0],XtNstring,&new);
  89.     for (dow=0; dow < 7; dow++)
  90.     for (i=0; i < 22; i++) {
  91.         XtGetValues(scheduleDayFormDatas[dow]->items[i]->text,args,ONE);
  92.         old = lookupScheduleDow(i,dow);
  93.         if (new != old) {
  94.         if (*new == '\0')
  95.             deleteScheduleDow(i,dow,new);
  96.         else
  97.             addScheduleDow(i,dow,new);
  98.         appointsChanged = True;
  99.         }
  100.     }
  101.     /* refresh display */
  102. }
  103.