home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume1 / calentool / part08 / tool.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-27  |  29.9 KB  |  1,073 lines

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