home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume17 / calentool / part11 / tool.c < prev   
Encoding:
C/C++ Source or Header  |  1991-04-06  |  32.7 KB  |  1,166 lines

  1. /*
  2.  * $Header: tool.c,v 2.5 91/03/27 16:46:32 billr Exp $
  3.  */
  4. /*
  5.  * tool.c
  6.  *
  7.  * Author: Philip Heller, Sun Microsystems. Inc. <terrapin!heller@sun.com>
  8.  *
  9.  * Original source Copyright (C) 1987, Sun Microsystems, Inc.
  10.  *    All Rights Reserved
  11.  * Permission is hereby granted to use and modify this program in source
  12.  * or binary form as long as it is not sold for profit and this copyright
  13.  * notice remains intact.
  14.  *
  15.  *
  16.  * Changes/additions by: Bill Randle, Tektronix, Inc. <billr@saab.CNA.TEK.COM>
  17.  *
  18.  * Changes and additions Copyright (C) 1988, 1989, 1991 Tektronix, Inc.
  19.  *    All Rights Reserved
  20.  * Permission is hereby granted to use and modify the modifications in source
  21.  * or binary form as long as they are not sold for profit and this copyright
  22.  * notice remains intact.
  23.  */
  24. #include <stdio.h>    /* for NULL */
  25. #include <suntool/sunview.h>
  26. #include <suntool/canvas.h>
  27. #include <suntool/panel.h>
  28. #include <sunwindow/defaults.h>
  29. #include <sys/file.h>
  30. #include "ct.h"
  31.  
  32. /*
  33.  * define standard B/W monochrome colors as defaults in case we're running
  34.  * on a color system with the monochrome colors set differently
  35.  */
  36. #define FG_DEFAULT  { 0, 0, 0 }     /* black */
  37. #define BG_DEFAULT  { 255, 255, 255 }   /* white */
  38.  
  39. extern int monday_first;
  40. extern struct tm current;
  41. extern Frame frame;
  42. extern int working_msg;
  43. extern int n_slots;
  44. extern int user_font;
  45. Canvas canvas;
  46. Panel panel;
  47. Panel_item todaybutton_pi, working_pi;
  48. Panel_item monthmenu_pi, yearmenu_pi, weekbutton_pi, daybutton_pi;
  49. Panel_item previous_pi, next_pi, current_pi, filebutton_pi;
  50. Panel_item clock_pi;
  51. Panel_item runl_pi;
  52. Panel_item donebutton_pi;
  53. #ifndef NO_PRINTER
  54. Panel_item printbutton_pi;
  55. #endif
  56. #ifndef NO_SUN_MOON
  57. Panel_item moonbutton_pi, sunbutton_pi;
  58. #endif
  59. Menu next_menu, previous_menu;
  60. Menu day_menu, week_menu, month_menu, year_menu;
  61. Menu day_sel_menu, current_menu;
  62. Menu done_menu;
  63. #ifndef NO_PRINTER
  64. Menu print_menu;
  65. #endif
  66. Pixfont *font, *bigfont, *sfont;
  67. Frame fframe = 0;
  68. Panel fpanel, fcpanel;
  69. Frame attr_frame;
  70. Panel attr_panel;
  71. Panel_item repeat_pi, remind_pi, everyx_pi, whichwk_pi, marked_pi;
  72. Panel_item advw_pi;
  73. Frame del_frame;
  74. Panel del_panel;
  75. Panel_item del_choice_pi;
  76. Frame wmore_frame;
  77. Panel wmore_panel;
  78. #ifndef NO_SUN_MOON
  79. Frame sframe = 0, mframe = 0;
  80. #endif
  81. Frame fileframe;
  82. Panel filepanel;
  83. Panel_item filename_pi, file_ro_pi;
  84. #ifndef NO_PRINTER
  85. Panel_item prcmd_pi;
  86. Panel_item prfile_pi;
  87. int print_to_file = 0;
  88. Frame prframe;
  89. #endif
  90. #ifndef NO_SUN_MOON
  91. Canvas scanvas, mcanvas;
  92. Panel_item sdate_pi, mdate_pi;
  93. static struct singlecolor       fg_default = FG_DEFAULT;
  94. static struct singlecolor       bg_default = BG_DEFAULT;
  95. #endif
  96. Frame prompt_frame = 0;
  97. Pixrect *morebutton;
  98. static Cursor panel_cursor, canvas_cursor;
  99. Frame date_frame;
  100. Panel_item setdate_pi;
  101. Frame cut_frame;
  102. Panel cut_panel;
  103. void monthmenu_notify(), yearmenu_notify(), weekbutton_notify();
  104. void month_menu_event(), year_menu_event(), week_menu_event();
  105. void todaybutton_notify(), currentbutton_notify(), daybutton_notify();
  106. void filebutton_notify(), current_menu_event();
  107. void cut_done(), cut_abort();
  108. void donebutton_notify(), done_menu_event();
  109. #ifndef NO_SUN_MOON
  110. void moonbutton_notify(), sunbutton_notify();
  111. #endif
  112. #ifndef NO_PRINTER
  113. void printbutton_notify(), print_menu_event();
  114. #endif
  115. void day_menu_event();
  116. void mainsw_selected();
  117. void next_menu_event(), nextbutton_notify();
  118. void previous_menu_event(), previous_menu_notify();
  119. void mainsw_inputevent();
  120. void fdone_proc(), fkeep_proc(), fappt_notify();
  121. void attr_accept(), attr_abort();
  122. void del_done();
  123. #ifndef NO_SUN_MOON
  124. void sdone_proc(), mdone_proc();
  125. void sframe_done(), mframe_done();
  126. #endif
  127. void fileframe_done(), file_accept(), file_reset(), file_done();
  128. void file_save();
  129. void prompt_no_notify(), prompt_yes_notify();
  130. void error_event(), file_orig();
  131. void dtframe_done(), dtdone_proc();
  132. #ifndef NO_PRINTER
  133. void prframe_done(), prdone_proc();
  134. #endif
  135. Notify_value check_close();
  136. int monthlength();
  137. char year_str[NR_YEARS][5]; /* holds strings for year menu */
  138. extern Pixwin *main_pixwin;
  139. extern Cursor day_cursor, wait_cursor;
  140. extern int day_is_open, mainsw_state;
  141. extern char clockstr[];
  142. extern struct appt_entry future[];
  143. extern int findex;
  144. extern struct dayslot *slots;
  145. #ifndef NO_SUN_MOON
  146. extern Pixrect moon_icon_pr, sun_icon_pr;
  147. #endif
  148. extern char printer[];
  149. extern int day_first;
  150. extern int locked;
  151.  
  152. /* Create and init control panel */
  153. create_panel()
  154. {
  155.     int    width;
  156.  
  157.     /* Create the control panel. */
  158.     panel = window_create(frame, PANEL,
  159.               WIN_HEIGHT, 72, WIN_FONT, font,
  160.               WIN_CONSUME_KBD_EVENTS,
  161.               WIN_UP_EVENTS, KEY_LEFT(7), 0,
  162.               WIN_ERROR_MSG, "Can't create main panel.",
  163.               0);
  164.  
  165.     /* Create the panel items and their menus */
  166.     done_menu = menu_create(MENU_STRINGS,
  167.             "Close to Icon", "Quit Tool", 0,
  168.             0);
  169.  
  170.     donebutton_pi = panel_create_item(panel, PANEL_BUTTON,
  171.                         PANEL_LABEL_IMAGE, 
  172.                           panel_button_image(panel, "Done", 4, font),
  173.             PANEL_EVENT_PROC, done_menu_event,
  174.                         PANEL_NOTIFY_PROC, donebutton_notify,
  175.             PANEL_ITEM_X, ATTR_COL(0),
  176.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  177.                         0);
  178.     
  179.     if( monday_first ) 
  180.         day_menu = menu_create(MENU_STRINGS, 
  181.                     "Monday", "Tuesday", "Wednesday",
  182.             "Thursday", "Friday", "Saturday", "Sunday", 0,
  183.             0);
  184.     else
  185.         day_menu = menu_create(MENU_STRINGS, 
  186.                     "Sunday", "Monday", "Tuesday", "Wednesday",
  187.             "Thursday", "Friday", "Saturday", 0,
  188.             0);
  189.  
  190.     daybutton_pi = panel_create_item(panel, PANEL_BUTTON,
  191.                         PANEL_LABEL_IMAGE, 
  192.                           panel_button_image(panel, "Day", 3, font),
  193.             PANEL_EVENT_PROC, day_menu_event,
  194.                         PANEL_NOTIFY_PROC, daybutton_notify,
  195.             PANEL_ITEM_X, ATTR_COL(7),
  196.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  197.                         0);
  198.     
  199.     week_menu = menu_create(MENU_STRINGS, "1st", "2nd",
  200.             "3rd", "4th", "5th", "Last", 0,
  201.             0);
  202.  
  203.     weekbutton_pi = panel_create_item(panel, PANEL_BUTTON,
  204.                         PANEL_LABEL_IMAGE, 
  205.                           panel_button_image(panel, "Week", 4, font),
  206.             PANEL_EVENT_PROC, week_menu_event,
  207.                         PANEL_NOTIFY_PROC, weekbutton_notify,
  208.             PANEL_ITEM_X, ATTR_COL(12),
  209.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  210.                         0);
  211.  
  212.     month_menu = menu_create(MENU_STRINGS,
  213.             "January", "February","March",
  214.             "April", "May", "June", "July", "August",
  215.             "September", "October", "November", "December", 0,
  216.             0);
  217.  
  218.     monthmenu_pi = panel_create_item(panel, PANEL_BUTTON,  
  219.                         PANEL_LABEL_IMAGE,
  220.               panel_button_image(panel, "Month", 5, font),
  221.             PANEL_EVENT_PROC, month_menu_event,
  222.                         PANEL_NOTIFY_PROC, monthmenu_notify,  
  223.             PANEL_ITEM_X, ATTR_COL(18),
  224.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  225.                         0);
  226.  
  227.     year_menu = menu_create(0);    /* years filled in later */
  228.     add_years_to_menu();
  229.  
  230.     yearmenu_pi = panel_create_item(panel, PANEL_BUTTON,
  231.                         PANEL_LABEL_IMAGE,
  232.               panel_button_image(panel, "Year", 4, font),
  233.             PANEL_EVENT_PROC, year_menu_event,
  234.                         PANEL_NOTIFY_PROC, yearmenu_notify,
  235.             PANEL_ITEM_X, ATTR_COL(25),
  236.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  237.                         0);
  238.  
  239.     todaybutton_pi = panel_create_item(panel, PANEL_BUTTON,
  240.                         PANEL_LABEL_IMAGE, 
  241.                           panel_button_image(panel, "Today", 5, font),
  242.                         PANEL_NOTIFY_PROC, todaybutton_notify,
  243.             PANEL_ITEM_X, ATTR_COL(34),
  244.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  245.                         0);
  246.  
  247.     filebutton_pi = panel_create_item(panel, PANEL_BUTTON,
  248.                         PANEL_LABEL_IMAGE, 
  249.                           panel_button_image(panel, "File", 4, font),
  250.                         PANEL_NOTIFY_PROC, filebutton_notify,
  251.             PANEL_ITEM_X, ATTR_COL(45),
  252.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  253.                         0);
  254.  
  255. #ifndef NO_PRINTER
  256.     printbutton_pi = panel_create_item(panel, PANEL_BUTTON,
  257.                         PANEL_LABEL_IMAGE, 
  258.                           panel_button_image(panel, "Print", 5, font),
  259.                         PANEL_EVENT_PROC, print_menu_event,
  260.                         PANEL_NOTIFY_PROC, printbutton_notify,
  261.             PANEL_ITEM_X, ATTR_COL(53),
  262.             PANEL_ITEM_Y, ATTR_ROW(0)+2,
  263.             PANEL_SHOW_ITEM, FALSE,
  264.                         0);
  265.     
  266.     print_menu = menu_create(MENU_STRINGS, "Print Postscript", "Print Raster",
  267.             "Change Printer", 0,
  268.             0);
  269. #endif
  270.  
  271.     working_pi = panel_create_item(panel, PANEL_MESSAGE,
  272.             PANEL_LABEL_STRING, "Working!",
  273.             PANEL_LABEL_FONT, font,
  274.             PANEL_LABEL_BOLD, TRUE,
  275.             PANEL_SHOW_ITEM, FALSE,
  276.             PANEL_ITEM_X, ATTR_COL(37),
  277.             PANEL_ITEM_Y, ATTR_ROW(1)+5,
  278.             0);
  279.  
  280.     previous_menu = menu_create(MENU_STRINGS,
  281.             "Yesterday", "Last Week", "Last Month", "Last Year", 0,
  282.             0);
  283.     
  284.     previous_pi = panel_create_item(panel, PANEL_BUTTON,
  285.                         PANEL_LABEL_IMAGE, 
  286.                           panel_button_image(panel, "Previous", 8, font),
  287.             PANEL_EVENT_PROC, previous_menu_event,
  288.                         PANEL_NOTIFY_PROC, previous_menu_notify, 
  289.             PANEL_ITEM_X, ATTR_COL(2),
  290.             PANEL_ITEM_Y, ATTR_ROW(2)-2,
  291.             0);
  292.  
  293.     current_menu = menu_create(MENU_STRINGS, "Current Day",
  294.             "Current Week", "Current Month", "Current Year",
  295.             "Change Date", 0,
  296.             0);
  297.  
  298.     current_pi = panel_create_item(panel, PANEL_BUTTON,
  299.                         PANEL_LABEL_IMAGE, 
  300.                           panel_button_image(panel, "Current", 7, font),
  301.             PANEL_EVENT_PROC, current_menu_event,
  302.                         PANEL_NOTIFY_PROC, currentbutton_notify,
  303.             PANEL_ITEM_X, ATTR_COL(13),
  304.             PANEL_ITEM_Y, ATTR_ROW(2)-2,
  305.                         0);
  306.  
  307.     next_menu = menu_create(MENU_STRINGS, "Tomorrow",
  308.             "Next Week", "Next Month", "Next Year", 0,
  309.             0);
  310.     
  311.     next_pi = panel_create_item(panel, PANEL_BUTTON,
  312.                         PANEL_LABEL_IMAGE, 
  313.                           panel_button_image(panel, "Next", 4, font),
  314.             PANEL_EVENT_PROC, next_menu_event,
  315.                         PANEL_NOTIFY_PROC, nextbutton_notify, 
  316.             PANEL_ITEM_X, ATTR_COL(23),
  317.             PANEL_ITEM_Y, ATTR_ROW(2)-2,
  318.             0);
  319.  
  320.     width = (int)window_get(panel, WIN_WIDTH);
  321.  
  322.     get_today();    /* get current date and time */
  323.     clock_pi = panel_create_item(panel, PANEL_MESSAGE,
  324.             PANEL_ITEM_X, width-150-(strlen(clockstr)*font->pf_defaultsize.x),
  325.             PANEL_ITEM_Y, ATTR_ROW(2)+3,
  326.             PANEL_LABEL_STRING, clockstr,
  327.             PANEL_LABEL_FONT, font,
  328.             0);
  329.  
  330. #ifndef NO_SUN_MOON
  331.     sunbutton_pi = panel_create_item(panel, PANEL_BUTTON,
  332.                         PANEL_LABEL_IMAGE, &sun_icon_pr,
  333.                         PANEL_NOTIFY_PROC, sunbutton_notify,
  334.             PANEL_ITEM_X, width-140,
  335.             PANEL_ITEM_Y, ATTR_ROW(0),
  336.             PANEL_SHOW_ITEM, FALSE,
  337.                         0);
  338.  
  339.     moonbutton_pi = panel_create_item(panel, PANEL_BUTTON,
  340.                         PANEL_LABEL_IMAGE, &moon_icon_pr,
  341.                         PANEL_NOTIFY_PROC, moonbutton_notify,
  342.             PANEL_ITEM_X, width-70,
  343.             PANEL_ITEM_Y, ATTR_ROW(0),
  344.             PANEL_SHOW_ITEM, FALSE,
  345.                         0);
  346. #endif
  347.  
  348.     /*
  349.      * menu strings for right MB menu in the canvas
  350.      * (day display). NB: if the order of this menu is
  351.      * changed, also change the #defines in ct.h
  352.      * (MMODIFY, MCUT, etc.).
  353.      */
  354.     day_sel_menu = menu_create(MENU_STRINGS,
  355.             "Modify", "Cut", "Paste", "Copy", "Delete",
  356.             "Undelete", 0,
  357.             0);
  358.  
  359.     /*
  360.      * this button is displayed in the canvas, but needs a panel
  361.      * for the function call to work properly
  362.      */
  363.     morebutton = panel_button_image(panel, "More", 4, font);
  364.  
  365.     /*
  366.      * interpose on panel events to check for L7 (open/close)
  367.      */
  368.     notify_interpose_event_func(panel, check_close, NOTIFY_SAFE);
  369. }
  370.  
  371. /*
  372.  * Add year strings to year panel menu
  373.  */
  374. add_years_to_menu()
  375. {
  376.     int n, year;
  377.  
  378.     n = 1;
  379.     for (year=START_YEAR; year<START_YEAR+NR_YEARS; year++,n++) {
  380.         sprintf(year_str[n-1], "%4d", year+1900);
  381.         menu_set(year_menu, MENU_STRING_ITEM, year_str[n-1], n, 0);
  382.     }
  383. }
  384.  
  385. /* turn sun and moon buttons on or off */
  386. sun_moon_buttons(state)
  387. int state;
  388. {
  389. #ifndef NO_SUN_MOON
  390.     if (state) {
  391.         if (!mframe)
  392.             panel_set(moonbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
  393.         if (!sframe)
  394.             panel_set(sunbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
  395.     } else {
  396.         panel_set(moonbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
  397.         panel_set(sunbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
  398.         /* remove moon window, if it exists */
  399.         if (mframe) {
  400.             window_destroy(mframe);
  401.             mframe = 0;
  402.         }
  403.         /* remove sun window, if it exists */
  404.         if (sframe) {
  405.             window_destroy(sframe);
  406.             sframe = 0;
  407.         }
  408.     }
  409. #endif
  410. }
  411.  
  412. /* turn print button on or off */
  413. print_button(state)
  414. int state;
  415. {
  416. #ifndef NO_PRINTER
  417. /* if no printer specified then never show Print button */
  418.     if (state)
  419.         panel_set(printbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
  420.     else
  421.         panel_set(printbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
  422. #endif    /* NO_PRINTER */
  423. }
  424.  
  425. working(state)
  426. int state;
  427. {
  428.     /* turn "Working!" message on or off */
  429.     if (working_msg) {
  430.         if (state)
  431.             panel_set(working_pi, PANEL_SHOW_ITEM, TRUE, 0);
  432.         else
  433.             panel_set(working_pi, PANEL_SHOW_ITEM, FALSE, 0);
  434.     }
  435. }
  436.  
  437. /* Create and init main subwindow. */
  438. create_main_window()
  439. {
  440.     canvas = window_create(frame, CANVAS,
  441.             CANVAS_FIXED_IMAGE, TRUE,
  442.             WIN_CONSUME_KBD_EVENTS, WIN_ASCII_EVENTS,
  443.             WIN_UP_EVENTS, KEY_LEFT(5), KEY_LEFT(6),
  444.             KEY_LEFT(7), KEY_LEFT(8), 0,
  445.             WIN_CONSUME_PICK_EVENTS, WIN_NO_EVENTS,
  446.             WIN_MOUSE_BUTTONS, LOC_STILL, LOC_DRAG,
  447.             WIN_IN_TRANSIT_EVENTS, 0,
  448.             WIN_EVENT_PROC, mainsw_inputevent,
  449.             CANVAS_RETAINED, TRUE,
  450.             WIN_BELOW, panel,
  451.             WIN_ERROR_MSG, "Can't create main window.",
  452.             0);
  453.     main_pixwin = (Pixwin *) canvas_pixwin(canvas);
  454.     
  455.     window_set(canvas, WIN_CURSOR, day_cursor, 0);
  456.     mainsw_state = DISPLAYING_DAY;
  457.     day_is_open = FALSE;
  458.     draw_day1();  /* like draw_day(), only no future popup */
  459. }
  460.  
  461. get_fonts()
  462. {
  463.     char *default_ptr, fontstr[128];
  464.  
  465.     /* Open normal and big font files. */
  466.     if (user_font)
  467.         /* use command line override */
  468.         font = pw_pfsysopen();
  469.     else if ((default_ptr = defaults_get_string("/CalenTool/Font", NULL, 0)) != NULL) {
  470.         if (*default_ptr != '/') {
  471.             strcpy(fontstr, "/usr/lib/fonts/fixedwidthfonts/");
  472.             strcat(fontstr, default_ptr);
  473.             if ((font = pf_open(fontstr)) == NULL)
  474.                 font = pw_pfsysopen();
  475.         } else {
  476.             if ((font = pf_open(default_ptr)) == NULL)
  477.                 font = pw_pfsysopen();
  478.         }
  479.     } else
  480.         font = pw_pfsysopen();
  481.     if ((default_ptr = defaults_get_string("/CalenTool/BigFont", NULL, 0)) != NULL) {
  482.         if (*default_ptr != '/') {
  483.             strcpy(fontstr, "/usr/lib/fonts/fixedwidthfonts/");
  484.             strcat(fontstr, default_ptr);
  485.             if ((bigfont = pf_open(fontstr)) == NULL)
  486.                 bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.10");
  487.         } else {
  488.             if ((bigfont = pf_open(default_ptr)) == NULL)
  489.                 bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.10");
  490.         }
  491.     } else
  492.         bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.10");
  493.     /* double check */
  494.     if (bigfont == NULL) {
  495.         err_rpt("unable to open large size font", NON_FATAL);
  496.         bigfont = pw_pfsysopen();
  497.     }
  498.  
  499.     /* font for displaying time under the icon and days under moon */
  500.     sfont = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.7");
  501. }
  502.  
  503. /*
  504.  * create popup window for future appts display
  505.  * called when we draw a day display.
  506.  */
  507. create_future_popup()
  508. {
  509.     int i, p_width;
  510.     Panel_item item;
  511.     char *fappt_str, *format_appt();
  512.     static Panel_item fdone_pi, fkeep_pi;
  513.     static int cp_width, cp_x;
  514.  
  515.     if (!fframe) {
  516.         /* create new frame and control panel */
  517.         fframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  518.                 WIN_X, ATTR_COL(12),
  519.                 WIN_Y, slots[n_slots-4].slot_pos.top,
  520.                 FRAME_LABEL, "Future Appointments",
  521.                 FRAME_SHOW_LABEL, TRUE,
  522.                 WIN_ERROR_MSG, "Can't create future frame.",
  523.                 0);
  524.  
  525.         fcpanel = window_create(fframe, PANEL, 0);
  526.     
  527.         fkeep_pi = panel_create_item(fcpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  528.                 fkeep_proc, PANEL_LABEL_IMAGE,
  529.                 panel_button_image(fcpanel, "Keep", 4, font),
  530.                 PANEL_SHOW_ITEM, TRUE,
  531.                 PANEL_ITEM_X, ATTR_COL(20),
  532.                 PANEL_ITEM_Y, ATTR_ROW(0),
  533.                 0);
  534.     
  535.         fdone_pi = panel_create_item(fcpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  536.                 fdone_proc, PANEL_LABEL_IMAGE,
  537.                 panel_button_image(fcpanel, "Done", 4, font),
  538.                 PANEL_SHOW_ITEM, TRUE,
  539.                 PANEL_ITEM_X, ATTR_COL(30),
  540.                 PANEL_ITEM_Y, ATTR_ROW(0),
  541.                 0);
  542.     
  543.         window_fit(fcpanel);
  544.         cp_width = (int) window_get(fcpanel, WIN_WIDTH);
  545.         cp_x = (int) window_get(fcpanel, WIN_X);
  546.  
  547.     } else {
  548.         /* existing frame, so just delete and recreate the
  549.          * message panel and its items
  550.          */
  551.         window_destroy(fpanel);
  552.     }
  553.     fpanel = window_create(fframe, PANEL, WIN_BELOW, fcpanel,
  554.             WIN_FONT, font, WIN_X, cp_x, 0);
  555.     /* create a panel message item for each future appt */
  556.     for (i=0; i<findex; i++) {
  557.         fappt_str = format_appt(&future[i]);
  558.         (void) panel_create_item(fpanel, PANEL_MESSAGE,
  559.                 PANEL_NOTIFY_PROC, fappt_notify,
  560.                 PANEL_SHOW_ITEM, TRUE,
  561.                 PANEL_CLIENT_DATA, (caddr_t)i,
  562.                 PANEL_LABEL_X, ATTR_COL(1),
  563.                 PANEL_LABEL_Y, ATTR_ROW(i),
  564.                 PANEL_LABEL_FONT, font,
  565.                 PANEL_LABEL_STRING, fappt_str,
  566.                 0);
  567.     }
  568.     window_fit(fpanel);
  569.     /* find out which panel is wider and use it for frame width */
  570.     p_width = (int) window_get(fpanel, WIN_WIDTH);
  571.     if (p_width > cp_width) {
  572.         /* reset control panel size */
  573.         window_set(fcpanel, WIN_WIDTH, p_width, 0);
  574.         /* move buttons */
  575.         panel_set(fdone_pi, PANEL_ITEM_X, ATTR_COL(-7)+p_width,
  576.                 PANEL_SHOW_ITEM, TRUE,
  577.                 0);
  578.         panel_set(fkeep_pi, PANEL_ITEM_X, ATTR_COL(-17)+p_width,
  579.                 PANEL_SHOW_ITEM, TRUE,
  580.                 0);
  581.     } else {
  582.         window_set(fpanel, WIN_WIDTH, cp_width, 0);
  583.         /* move buttons */
  584.         panel_set(fdone_pi, PANEL_ITEM_X, ATTR_COL(-7)+cp_width,
  585.                 PANEL_SHOW_ITEM, TRUE,
  586.                 0);
  587.         panel_set(fkeep_pi, PANEL_ITEM_X, ATTR_COL(-17)+cp_width,
  588.                 PANEL_SHOW_ITEM, TRUE,
  589.                 0);
  590.     }
  591.     window_fit(fframe);
  592.     window_set(fframe, WIN_SHOW, TRUE, 0);
  593. }
  594.  
  595. /*
  596.  * create a popup to modify or set attributes for a given
  597.  * appointment.
  598.  */
  599. create_attr_frame()
  600. {
  601.     void everyx_notify();
  602.  
  603.     /* create new frame and control panel */
  604.     attr_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  605.             FRAME_SHOW_LABEL, FALSE,
  606.             WIN_ERROR_MSG, "Can't create attributes frame.",
  607.             0);
  608.  
  609.     attr_panel = window_create(attr_frame, PANEL,
  610.             WIN_FONT, font,
  611.             PANEL_BLINK_CARET, TRUE,
  612.             0);
  613.     
  614.     (void) panel_create_item(attr_panel, PANEL_MESSAGE,
  615.             PANEL_SHOW_ITEM, TRUE,
  616.             PANEL_LABEL_STRING, "Appointment Options",
  617.             PANEL_LABEL_X, ATTR_COL(4),
  618.             PANEL_LABEL_Y, ATTR_ROW(0)+4,
  619.             PANEL_LABEL_BOLD, TRUE,
  620.             0);
  621.  
  622.     (void) panel_create_item(attr_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  623.             attr_accept, PANEL_LABEL_IMAGE,
  624.             panel_button_image(attr_panel, "Accept", 6, font),
  625.             PANEL_SHOW_ITEM, TRUE,
  626.             PANEL_ITEM_X, ATTR_COL(35),
  627.             PANEL_ITEM_Y, ATTR_ROW(0),
  628.             0);
  629.  
  630.     (void) panel_create_item(attr_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  631.             attr_abort, PANEL_LABEL_IMAGE,
  632.             panel_button_image(attr_panel, "Abort", 5, font),
  633.             PANEL_SHOW_ITEM, TRUE,
  634.             PANEL_ITEM_X, ATTR_COL(45),
  635.             PANEL_ITEM_Y, ATTR_ROW(0),
  636.             0);
  637.  
  638.     everyx_pi = panel_create_item(attr_panel, PANEL_TOGGLE,
  639.             PANEL_SHOW_ITEM, TRUE,
  640.             PANEL_DISPLAY_LEVEL, PANEL_ALL,
  641.             PANEL_NOTIFY_PROC, everyx_notify,
  642.             PANEL_LABEL_STRING, "Repeat appointment:",
  643.             PANEL_CHOICE_STRINGS, "Mon-Fri", "Every Day",
  644.             "Selected Week", "Every Month", "Every Year", 0,
  645.             PANEL_ITEM_X, ATTR_COL(1),
  646.             PANEL_ITEM_Y, ATTR_ROW(2)-5,
  647.             0);
  648.  
  649.     whichwk_pi = panel_create_item(attr_panel, PANEL_TOGGLE,
  650.             PANEL_SHOW_ITEM, TRUE,
  651.             PANEL_DISPLAY_LEVEL, PANEL_ALL,
  652.             PANEL_LABEL_STRING,
  653.             "Indicate which week(s) in the month:",
  654.             PANEL_CHOICE_STRINGS, "1st", "2nd",
  655.             "3rd", "4th", "5th", "Last", "All", 0,
  656.             PANEL_ITEM_X, ATTR_COL(1),
  657.             PANEL_ITEM_Y, ATTR_ROW(3)-5,
  658.             0);
  659.  
  660.     repeat_pi = panel_create_item(attr_panel, PANEL_TEXT,
  661.             PANEL_SHOW_ITEM, FALSE,
  662.             PANEL_LABEL_STRING,
  663.             "Repeat at specified interval of days:",
  664.             PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
  665.             PANEL_VALUE_DISPLAY_LENGTH, 4,
  666.             PANEL_ITEM_X, ATTR_COL(1),
  667.             PANEL_ITEM_Y, ATTR_ROW(3),
  668.             PANEL_BLINK_CARET, TRUE,
  669.             0);
  670.     
  671.     runl_pi = panel_create_item(attr_panel, PANEL_TEXT,
  672.             PANEL_SHOW_ITEM, TRUE,
  673.             PANEL_LABEL_STRING,
  674.             "Repeat specified number of times (default forever):",
  675.             PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
  676.             PANEL_VALUE_DISPLAY_LENGTH, 4,
  677.             PANEL_ITEM_X, ATTR_COL(1),
  678.             PANEL_ITEM_Y, ATTR_ROW(4),
  679.             PANEL_BLINK_CARET, TRUE,
  680.             0);
  681.  
  682.     remind_pi = panel_create_item(attr_panel, PANEL_TEXT,
  683.             PANEL_SHOW_ITEM, TRUE,
  684.             PANEL_LABEL_STRING,
  685.             "Warn in advance by specified number of days:",
  686.             PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
  687.             PANEL_VALUE_DISPLAY_LENGTH, 4,
  688.             PANEL_ITEM_X, ATTR_COL(1),
  689.             PANEL_ITEM_Y, ATTR_ROW(5),
  690.             PANEL_BLINK_CARET, TRUE,
  691.             0);
  692.  
  693.     advw_pi = panel_create_item(attr_panel, PANEL_TEXT,
  694.             PANEL_SHOW_ITEM, TRUE,
  695.             PANEL_LABEL_STRING,
  696.             "Remind a specified number of minutes before:",
  697.             PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
  698.             PANEL_VALUE_DISPLAY_LENGTH, 4,
  699.             PANEL_ITEM_X, ATTR_COL(1),
  700.             PANEL_ITEM_Y, ATTR_ROW(6),
  701.             PANEL_BLINK_CARET, TRUE,
  702.             0);
  703.  
  704.     /* This panel item is currently only supported
  705.      * for note appointment entries.
  706.      */
  707.     marked_pi = panel_create_item(attr_panel, PANEL_CYCLE,
  708.             PANEL_SHOW_ITEM, FALSE,
  709.             PANEL_LABEL_STRING,
  710.             "Mark in month/year display:",
  711.             PANEL_CHOICE_STRINGS, "Yes", "No", 0,
  712.             PANEL_ITEM_X, ATTR_COL(1),
  713.             PANEL_ITEM_Y, ATTR_ROW(7),
  714.             0);
  715.  
  716.     window_fit(attr_panel);
  717.     window_fit(attr_frame);
  718. }
  719.  
  720. /*
  721.  * create a popup to choose delete mode
  722.  */
  723. create_del_frame()
  724. {
  725.     /* create new frame and control panel */
  726.     del_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  727.             FRAME_SHOW_LABEL, FALSE,
  728.             WIN_ERROR_MSG, "Can't create delete frame.",
  729.             0);
  730.  
  731.     del_panel = window_create(del_frame, PANEL,
  732.             WIN_FONT, font,
  733.             0);
  734.     
  735.     (void) panel_create_item(del_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  736.             del_done, PANEL_LABEL_IMAGE,
  737.             panel_button_image(del_panel, "Accept", 6, font),
  738.             PANEL_SHOW_ITEM, TRUE,
  739.             PANEL_ITEM_X, ATTR_COL(30),
  740.             PANEL_ITEM_Y, ATTR_ROW(0),
  741.             0);
  742.  
  743.     (void) panel_create_item(del_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  744.             attr_abort, PANEL_LABEL_IMAGE,
  745.             panel_button_image(del_panel, "Abort", 5, font),
  746.             PANEL_SHOW_ITEM, TRUE,
  747.             PANEL_ITEM_X, ATTR_COL(40),
  748.             PANEL_ITEM_Y, ATTR_ROW(0),
  749.             0);
  750.  
  751.     (void) panel_create_item(del_panel, PANEL_MESSAGE,
  752.             PANEL_SHOW_ITEM, TRUE,
  753.             PANEL_LABEL_STRING, "This is a recurring appointment.",
  754.             PANEL_LABEL_X, ATTR_COL(1),
  755.             PANEL_LABEL_Y, ATTR_ROW(1)+5,
  756.             PANEL_LABEL_BOLD, TRUE,
  757.             0);
  758.  
  759.     del_choice_pi = panel_create_item(del_panel, PANEL_CYCLE,
  760.             PANEL_SHOW_ITEM, TRUE,
  761.             PANEL_LABEL_STRING, "Do you wish to:",
  762.             PANEL_CHOICE_STRINGS, "Delete this occurrance only", "Delete all occurrances", 0,
  763.             PANEL_ITEM_X, ATTR_COL(1),
  764.             PANEL_ITEM_Y, ATTR_ROW(2)+5,
  765.             0);
  766.  
  767.     window_fit(del_panel);
  768.     window_fit(del_frame);
  769. }
  770.  
  771. #ifndef NO_SUN_MOON
  772. /*
  773.  * create popup for sun data frame
  774.  */
  775. sun_data_frame()
  776. {
  777.     Panel spanel;
  778.  
  779.     /* create new frame and canvas */
  780.     if (!sframe) {
  781.         sframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  782.                 WIN_X, ATTR_COL(12),
  783.                 FRAME_LABEL, "Solar Data",
  784.                 FRAME_SHOW_LABEL, TRUE,
  785.                 FRAME_DONE_PROC, sframe_done,
  786.                 WIN_ERROR_MSG, "Can't create sun data frame.",
  787.                 0);
  788.  
  789.         spanel = window_create(sframe, PANEL, WIN_FONT, font,
  790.                 WIN_WIDTH, 55*font->pf_defaultsize.x,
  791.                 WIN_ERROR_MSG, "Can't create sun data panel.",
  792.                 0);
  793.     
  794.         (void) panel_create_item(spanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  795.                 sdone_proc, PANEL_LABEL_IMAGE,
  796.                 panel_button_image(spanel, "Done", 4, font),
  797.                 PANEL_SHOW_ITEM, TRUE,
  798.                 PANEL_ITEM_X, ATTR_COL(45),
  799.                 PANEL_ITEM_Y, ATTR_ROW(0),
  800.                 0);
  801.  
  802.         sdate_pi = panel_create_item(spanel, PANEL_MESSAGE,
  803.                 PANEL_ITEM_X, ATTR_COL(8),
  804.                 PANEL_ITEM_Y, ATTR_ROW(0),
  805.                 /* string filled in later */
  806.                 PANEL_LABEL_STRING, "",
  807.                 PANEL_LABEL_FONT, font,
  808.                 0);
  809.     
  810.         window_fit_height(spanel);
  811.         scanvas = window_create(sframe, CANVAS, WIN_BELOW, spanel,
  812.                 WIN_X, 0,
  813.                 WIN_HEIGHT, 17*font->pf_defaultsize.y,
  814.                 WIN_CONSUME_PICK_EVENT, WIN_NO_EVENTS,
  815.                 WIN_CONSUME_KBD_EVENT, WIN_NO_EVENTS,
  816.                 WIN_ERROR_MSG, "Can't create sun data canvas.",
  817.                 0);
  818.     
  819.         write_sun_data();
  820.         window_fit(sframe);
  821.         window_set(sframe, WIN_SHOW, TRUE, 0);
  822.     } else
  823.         write_sun_data();
  824. }
  825.  
  826. /*
  827.  * create popup for moon data frame
  828.  */
  829. moon_data_frame()
  830. {
  831.     Panel mpanel;
  832.  
  833.     /* create new frame and canvas */
  834.     if (!mframe) {
  835.         mframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  836.                 WIN_X, ATTR_COL(12),
  837.                 FRAME_LABEL, "Lunar Data",
  838.                 FRAME_SHOW_LABEL, TRUE,
  839.                 FRAME_FOREGROUND_COLOR, &fg_default,
  840.                 FRAME_BACKGROUND_COLOR, &bg_default,
  841.                 FRAME_DONE_PROC, mframe_done,
  842.                 WIN_ERROR_MSG, "Can't create moon data frame.",
  843.                 0);
  844.  
  845.         mpanel = window_create(mframe, PANEL, WIN_FONT, font,
  846.                 WIN_WIDTH, 70*font->pf_defaultsize.x,
  847.                 WIN_ERROR_MSG, "Can't create moon data panel.",
  848.                 0);
  849.     
  850.         (void) panel_create_item(mpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  851.                 mdone_proc, PANEL_LABEL_IMAGE,
  852.                 panel_button_image(mpanel, "Done", 4, font),
  853.                 PANEL_SHOW_ITEM, TRUE,
  854.                 PANEL_ITEM_X, ATTR_COL(60),
  855.                 PANEL_ITEM_Y, ATTR_ROW(0),
  856.                 0);
  857.  
  858.         mdate_pi = panel_create_item(mpanel, PANEL_MESSAGE,
  859.                 PANEL_ITEM_X, ATTR_COL(8),
  860.                 PANEL_ITEM_Y, ATTR_ROW(0),
  861.                 /* string filled in later */
  862.                 PANEL_LABEL_STRING, "",
  863.                 PANEL_LABEL_FONT, font,
  864.                 0);
  865.     
  866.         window_fit_height(mpanel);
  867.         mcanvas = window_create(mframe, CANVAS, WIN_BELOW, mpanel,
  868.                 WIN_X, 0,
  869.                 WIN_HEIGHT, 17*font->pf_defaultsize.y,
  870.                 CANVAS_RETAINED, TRUE,
  871.                 WIN_CONSUME_PICK_EVENT, WIN_NO_EVENTS,
  872.                 WIN_CONSUME_KBD_EVENT, WIN_NO_EVENTS,
  873.                 WIN_ERROR_MSG, "Can't create moon data canvas.",
  874.                 0);
  875.     
  876.         write_moon_data();
  877.         window_fit(mframe);
  878.         window_set(mframe, WIN_SHOW, TRUE, 0);
  879.     } else
  880.         write_moon_data();
  881. }
  882. #endif    /* NO_SUN_MOON */
  883.  
  884. /*
  885.  * create a popup to allow selecting a different appointment file
  886.  */
  887. create_file_frame()
  888. {
  889.  
  890.     /* create new frame and control panel */
  891.     fileframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  892.             FRAME_LABEL, "File Selection",
  893.             FRAME_SHOW_LABEL, TRUE,
  894.             FRAME_DONE_PROC, fileframe_done,
  895.             WIN_ERROR_MSG, "Can't create file frame.",
  896.             0);
  897.  
  898.     filepanel = window_create(fileframe, PANEL, WIN_FONT, font,
  899.             PANEL_BLINK_CARET, TRUE,
  900.             0);
  901.     
  902.     file_ro_pi = panel_create_item(filepanel, PANEL_CYCLE, PANEL_CHOICE_STRINGS,
  903.             "Read Only", "Read/Write", 0,
  904.             PANEL_SHOW_ITEM, TRUE,
  905.             PANEL_ITEM_X, ATTR_COL(1),
  906.             PANEL_ITEM_Y, ATTR_ROW(0),
  907.             0);
  908.  
  909.     (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  910.             file_orig, PANEL_LABEL_IMAGE,
  911.             panel_button_image(filepanel, "Original", 7, font),
  912.             PANEL_SHOW_ITEM, TRUE,
  913.             PANEL_ITEM_X, ATTR_COL(17),
  914.             PANEL_ITEM_Y, ATTR_ROW(0),
  915.             0);
  916.  
  917.     (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  918.             file_accept, PANEL_LABEL_IMAGE,
  919.             panel_button_image(filepanel, "Accept", 6, font),
  920.             PANEL_SHOW_ITEM, TRUE,
  921.             PANEL_ITEM_X, ATTR_COL(27),
  922.             PANEL_ITEM_Y, ATTR_ROW(0),
  923.             0);
  924.  
  925.     (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  926.             file_reset, PANEL_LABEL_IMAGE,
  927.             panel_button_image(filepanel, "Reset", 5, font),
  928.             PANEL_SHOW_ITEM, TRUE,
  929.             PANEL_ITEM_X, ATTR_COL(35),
  930.             PANEL_ITEM_Y, ATTR_ROW(0),
  931.             0);
  932.  
  933.     (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  934.             file_save, PANEL_LABEL_IMAGE,
  935.             panel_button_image(filepanel, "Update", 6, font),
  936.             PANEL_SHOW_ITEM, TRUE,
  937.             PANEL_ITEM_X, ATTR_COL(42),
  938.             PANEL_ITEM_Y, ATTR_ROW(0),
  939.             0);
  940.  
  941.     (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  942.             file_done, PANEL_LABEL_IMAGE,
  943.             panel_button_image(filepanel, "Done", 4, font),
  944.             PANEL_SHOW_ITEM, TRUE,
  945.             PANEL_ITEM_X, ATTR_COL(50),
  946.             PANEL_ITEM_Y, ATTR_ROW(0),
  947.             0);
  948.  
  949.     (void) panel_create_item(filepanel, PANEL_MESSAGE,
  950.             PANEL_SHOW_ITEM, TRUE,
  951.             PANEL_LABEL_STRING, "Enter the desired appointment file",
  952.             PANEL_LABEL_X, ATTR_COL(6),
  953.             PANEL_LABEL_Y, ATTR_ROW(2),
  954.             PANEL_LABEL_BOLD, TRUE,
  955.             0);
  956.  
  957.     filename_pi = panel_create_item(filepanel, PANEL_TEXT,
  958.             PANEL_SHOW_ITEM, TRUE,
  959.             PANEL_LABEL_STRING, "Filename:",
  960.             PANEL_LABEL_BOLD, TRUE,
  961.             PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 128,
  962.             PANEL_VALUE_DISPLAY_LENGTH, 30,
  963.             PANEL_ITEM_X, ATTR_COL(1),
  964.             PANEL_ITEM_Y, ATTR_ROW(3),
  965.             PANEL_BLINK_CARET, TRUE,
  966.             0);
  967.  
  968.     window_fit(filepanel);
  969.     window_fit(fileframe);
  970. }
  971.  
  972. /*
  973.  * create a popup to display an error message
  974.  */
  975. create_prompt_frame(str1, buttonflag)
  976. char *str1;
  977. {
  978.     static Panel_item prompt_panel;
  979.     static Panel_item msg_pi, yes_pi, no_pi = 0;
  980.  
  981.     if (!prompt_frame) {
  982.         /* create new frame and control panel */
  983.         prompt_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  984.                 FRAME_SHOW_LABEL, FALSE,
  985.                 WIN_SHOW, TRUE,
  986.                 WIN_X, ATTR_COL(15), WIN_Y, ATTR_ROW(15),
  987.                 WIN_ERROR_MSG, "Can't create error frame.",
  988.                 0);
  989.  
  990.         prompt_panel = window_create(prompt_frame, PANEL,
  991.                 PANEL_ACCEPT_KEYSTROKE, FALSE,
  992.                 WIN_FONT, font,
  993.                 0);
  994.     } else {
  995.         /* existing frame, delete the items */
  996.         panel_destroy_item(msg_pi);
  997.         panel_destroy_item(yes_pi);
  998.         if (no_pi) {
  999.             panel_destroy_item(no_pi);
  1000.             no_pi = 0;
  1001.         }
  1002.     }
  1003.     
  1004.     /* create new message and button panel items */
  1005.     msg_pi = panel_create_item(prompt_panel, PANEL_MESSAGE,
  1006.             PANEL_SHOW_ITEM, TRUE,
  1007.             PANEL_ITEM_X, ATTR_COL(1),
  1008.             PANEL_ITEM_Y, ATTR_ROW(0),
  1009.             PANEL_LABEL_STRING, str1,
  1010.             PANEL_LABEL_BOLD, TRUE,
  1011.             0);
  1012.  
  1013.     if (buttonflag) {
  1014.         yes_pi = panel_create_item(prompt_panel, PANEL_BUTTON,
  1015.                 PANEL_SHOW_ITEM, TRUE,
  1016.                 PANEL_ITEM_X, ATTR_COL(4),
  1017.                 PANEL_ITEM_Y, ATTR_ROW(2),
  1018.                 PANEL_NOTIFY_PROC, prompt_yes_notify,
  1019.                 PANEL_LABEL_IMAGE,
  1020.                 panel_button_image(prompt_panel, "Yes", 3, font),
  1021.                 0);
  1022.  
  1023.         no_pi = panel_create_item(prompt_panel, PANEL_MESSAGE,
  1024.                 PANEL_SHOW_ITEM, TRUE,
  1025.                 PANEL_ITEM_X, ATTR_COL(12),
  1026.                 PANEL_ITEM_Y, ATTR_ROW(2),
  1027.                 PANEL_NOTIFY_PROC, prompt_no_notify,
  1028.                 PANEL_LABEL_IMAGE,
  1029.                 panel_button_image(prompt_panel, "No", 2, font),
  1030.                 0);
  1031.     } else {
  1032.         yes_pi = panel_create_item(prompt_panel, PANEL_MESSAGE,
  1033.                 PANEL_SHOW_ITEM, TRUE,
  1034.                 PANEL_ITEM_X, ATTR_COL(12),
  1035.                 PANEL_ITEM_Y, ATTR_ROW(2),
  1036.                 PANEL_NOTIFY_PROC, prompt_yes_notify,
  1037.                 PANEL_LABEL_IMAGE,
  1038.                 panel_button_image(prompt_panel, "Ok", 2, font),
  1039.                 0);
  1040.     }
  1041.  
  1042.     window_fit(prompt_panel);
  1043.     window_fit(prompt_frame);
  1044. }
  1045.  
  1046. #ifndef NO_PRINTER
  1047. /* create popup to change the printer */
  1048. create_print_frame()
  1049. {
  1050.     Panel prpanel;
  1051.  
  1052.     prframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  1053.             WIN_SHOW, FALSE, WIN_X, ATTR_COL(12),
  1054.             FRAME_LABEL, "Change Printer",
  1055.             FRAME_SHOW_LABEL, TRUE,
  1056.             FRAME_DONE_PROC, prframe_done,
  1057.             WIN_ERROR_MSG, "Can't create printer frame.",
  1058.             0);
  1059.  
  1060.     prpanel = window_create(prframe, PANEL, WIN_FONT, font,
  1061.             WIN_ERROR_MSG, "Can't create printer panel.",
  1062.             0);
  1063.     
  1064.     (void) panel_create_item(prpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  1065.             prdone_proc, PANEL_LABEL_IMAGE,
  1066.             panel_button_image(prpanel, "Done", 4, font),
  1067.             PANEL_SHOW_ITEM, TRUE,
  1068.             PANEL_ITEM_X, ATTR_COL(34),
  1069.             PANEL_ITEM_Y, ATTR_ROW(0),
  1070.             0);
  1071.  
  1072.     prfile_pi = panel_create_item(prpanel, PANEL_CYCLE,
  1073.             PANEL_SHOW_ITEM, TRUE,
  1074.             PANEL_ITEM_X, ATTR_COL(1),
  1075.             PANEL_ITEM_Y, ATTR_ROW(1)+5,
  1076.             PANEL_LABEL_STRING, "Destination:",
  1077.             PANEL_LABEL_BOLD, TRUE,
  1078.             PANEL_CHOICE_STRINGS, "Printer", "File Only", 0,
  1079.             0);
  1080.     
  1081.     prcmd_pi = panel_create_item(prpanel, PANEL_TEXT,
  1082.             PANEL_SHOW_ITEM, TRUE,
  1083.             PANEL_ITEM_X, ATTR_COL(1),
  1084.             PANEL_ITEM_Y, ATTR_ROW(2)+5,
  1085.             PANEL_LABEL_STRING, "Print command:",
  1086.             PANEL_LABEL_FONT, font,
  1087.             PANEL_LABEL_BOLD, TRUE,
  1088.             PANEL_VALUE_STORED_LENGTH, 128,
  1089.             PANEL_VALUE_DISPLAY_LENGTH, 30,
  1090.             PANEL_BLINK_CARET, TRUE,
  1091.             0);
  1092.     
  1093.     panel_set_value(prcmd_pi, printer);
  1094.     panel_set_value(prfile_pi, 0);
  1095.     window_fit(prpanel);
  1096.     window_fit(prframe);
  1097. }
  1098. #endif    /* NO_PRINTER */
  1099.  
  1100. /* create popup to change the date */
  1101. create_date_frame()
  1102. {
  1103.     Panel dtpanel;
  1104.     char date[9];
  1105.  
  1106.     date_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
  1107.             WIN_SHOW, FALSE, WIN_X, ATTR_COL(12),
  1108.             FRAME_LABEL, "Change Current Date",
  1109.             FRAME_SHOW_LABEL, TRUE,
  1110.             FRAME_DONE_PROC, dtframe_done,
  1111.             WIN_ERROR_MSG, "Can't create date frame.",
  1112.             0);
  1113.  
  1114.     dtpanel = window_create(date_frame, PANEL, WIN_FONT, font,
  1115.             WIN_ERROR_MSG, "Can't create date panel.",
  1116.             0);
  1117.     
  1118.     (void) panel_create_item(dtpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
  1119.             dtdone_proc, PANEL_LABEL_IMAGE,
  1120.             panel_button_image(dtpanel, "Done", 4, font),
  1121.             PANEL_SHOW_ITEM, TRUE,
  1122.             PANEL_ITEM_X, ATTR_COL(34),
  1123.             PANEL_ITEM_Y, ATTR_ROW(0),
  1124.             0);
  1125.  
  1126.     setdate_pi = panel_create_item(dtpanel, PANEL_TEXT,
  1127.             PANEL_SHOW_ITEM, TRUE,
  1128.             PANEL_ITEM_X, ATTR_COL(1),
  1129.             PANEL_ITEM_Y, ATTR_ROW(1)+5,
  1130.             PANEL_LABEL_STRING, (day_first ? "Enter date (D, D/M, or D/M/Y):" : "Enter date (D, M/D, or M/D/Y):"),
  1131.             PANEL_LABEL_FONT, font,
  1132.             PANEL_LABEL_BOLD, TRUE,
  1133.             PANEL_VALUE_STORED_LENGTH, 10,
  1134.             PANEL_VALUE_DISPLAY_LENGTH, 10,
  1135.             PANEL_BLINK_CARET, TRUE,
  1136.             0);
  1137.     
  1138.     if (day_first)
  1139.         sprintf(date, "%d/%d/%02d", current.tm_mday, current.tm_mon+1, current.tm_year);
  1140.     else
  1141.         sprintf(date, "%d/%d/%02d", current.tm_mon+1, current.tm_mday, current.tm_year);
  1142.     panel_set_value(setdate_pi, date);
  1143.     window_fit(dtpanel);
  1144.     window_fit(date_frame);
  1145. }
  1146.  
  1147. /* replace cursors with hourglass symbol to show we're waiting */
  1148. lock_cursors()
  1149. {
  1150.     panel_cursor = cursor_copy((Cursor) window_get(panel, WIN_CURSOR));
  1151.     canvas_cursor = cursor_copy((Cursor) window_get(canvas, WIN_CURSOR));
  1152.     window_set(panel, WIN_CURSOR, wait_cursor, 0);
  1153.     window_set(canvas, WIN_CURSOR, wait_cursor, 0);
  1154.     locked = 1;
  1155. }
  1156.  
  1157. /* restore cursors */
  1158. unlock_cursors()
  1159. {
  1160.     window_set(panel, WIN_CURSOR, panel_cursor, 0);
  1161.     window_set(canvas, WIN_CURSOR, canvas_cursor, 0);
  1162.     cursor_destroy(panel_cursor);
  1163.     cursor_destroy(canvas_cursor);
  1164.     locked = 0;
  1165. }
  1166.