home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Header: tool.c,v 2.5 91/03/27 16:46:32 billr Exp $
- */
- /*
- * tool.c
- *
- * Author: Philip Heller, Sun Microsystems. Inc. <terrapin!heller@sun.com>
- *
- * Original source Copyright (C) 1987, Sun Microsystems, Inc.
- * All Rights Reserved
- * Permission is hereby granted to use and modify this program in source
- * or binary form as long as it is not sold for profit and this copyright
- * notice remains intact.
- *
- *
- * Changes/additions by: Bill Randle, Tektronix, Inc. <billr@saab.CNA.TEK.COM>
- *
- * Changes and additions Copyright (C) 1988, 1989, 1991 Tektronix, Inc.
- * All Rights Reserved
- * Permission is hereby granted to use and modify the modifications in source
- * or binary form as long as they are not sold for profit and this copyright
- * notice remains intact.
- */
- #include <stdio.h> /* for NULL */
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- #include <suntool/panel.h>
- #include <sunwindow/defaults.h>
- #include <sys/file.h>
- #include "ct.h"
-
- /*
- * define standard B/W monochrome colors as defaults in case we're running
- * on a color system with the monochrome colors set differently
- */
- #define FG_DEFAULT { 0, 0, 0 } /* black */
- #define BG_DEFAULT { 255, 255, 255 } /* white */
-
- extern int monday_first;
- extern struct tm current;
- extern Frame frame;
- extern int working_msg;
- extern int n_slots;
- extern int user_font;
- Canvas canvas;
- Panel panel;
- Panel_item todaybutton_pi, working_pi;
- Panel_item monthmenu_pi, yearmenu_pi, weekbutton_pi, daybutton_pi;
- Panel_item previous_pi, next_pi, current_pi, filebutton_pi;
- Panel_item clock_pi;
- Panel_item runl_pi;
- Panel_item donebutton_pi;
- #ifndef NO_PRINTER
- Panel_item printbutton_pi;
- #endif
- #ifndef NO_SUN_MOON
- Panel_item moonbutton_pi, sunbutton_pi;
- #endif
- Menu next_menu, previous_menu;
- Menu day_menu, week_menu, month_menu, year_menu;
- Menu day_sel_menu, current_menu;
- Menu done_menu;
- #ifndef NO_PRINTER
- Menu print_menu;
- #endif
- Pixfont *font, *bigfont, *sfont;
- Frame fframe = 0;
- Panel fpanel, fcpanel;
- Frame attr_frame;
- Panel attr_panel;
- Panel_item repeat_pi, remind_pi, everyx_pi, whichwk_pi, marked_pi;
- Panel_item advw_pi;
- Frame del_frame;
- Panel del_panel;
- Panel_item del_choice_pi;
- Frame wmore_frame;
- Panel wmore_panel;
- #ifndef NO_SUN_MOON
- Frame sframe = 0, mframe = 0;
- #endif
- Frame fileframe;
- Panel filepanel;
- Panel_item filename_pi, file_ro_pi;
- #ifndef NO_PRINTER
- Panel_item prcmd_pi;
- Panel_item prfile_pi;
- int print_to_file = 0;
- Frame prframe;
- #endif
- #ifndef NO_SUN_MOON
- Canvas scanvas, mcanvas;
- Panel_item sdate_pi, mdate_pi;
- static struct singlecolor fg_default = FG_DEFAULT;
- static struct singlecolor bg_default = BG_DEFAULT;
- #endif
- Frame prompt_frame = 0;
- Pixrect *morebutton;
- static Cursor panel_cursor, canvas_cursor;
- Frame date_frame;
- Panel_item setdate_pi;
- Frame cut_frame;
- Panel cut_panel;
- void monthmenu_notify(), yearmenu_notify(), weekbutton_notify();
- void month_menu_event(), year_menu_event(), week_menu_event();
- void todaybutton_notify(), currentbutton_notify(), daybutton_notify();
- void filebutton_notify(), current_menu_event();
- void cut_done(), cut_abort();
- void donebutton_notify(), done_menu_event();
- #ifndef NO_SUN_MOON
- void moonbutton_notify(), sunbutton_notify();
- #endif
- #ifndef NO_PRINTER
- void printbutton_notify(), print_menu_event();
- #endif
- void day_menu_event();
- void mainsw_selected();
- void next_menu_event(), nextbutton_notify();
- void previous_menu_event(), previous_menu_notify();
- void mainsw_inputevent();
- void fdone_proc(), fkeep_proc(), fappt_notify();
- void attr_accept(), attr_abort();
- void del_done();
- #ifndef NO_SUN_MOON
- void sdone_proc(), mdone_proc();
- void sframe_done(), mframe_done();
- #endif
- void fileframe_done(), file_accept(), file_reset(), file_done();
- void file_save();
- void prompt_no_notify(), prompt_yes_notify();
- void error_event(), file_orig();
- void dtframe_done(), dtdone_proc();
- #ifndef NO_PRINTER
- void prframe_done(), prdone_proc();
- #endif
- Notify_value check_close();
- int monthlength();
- char year_str[NR_YEARS][5]; /* holds strings for year menu */
- extern Pixwin *main_pixwin;
- extern Cursor day_cursor, wait_cursor;
- extern int day_is_open, mainsw_state;
- extern char clockstr[];
- extern struct appt_entry future[];
- extern int findex;
- extern struct dayslot *slots;
- #ifndef NO_SUN_MOON
- extern Pixrect moon_icon_pr, sun_icon_pr;
- #endif
- extern char printer[];
- extern int day_first;
- extern int locked;
-
- /* Create and init control panel */
- create_panel()
- {
- int width;
-
- /* Create the control panel. */
- panel = window_create(frame, PANEL,
- WIN_HEIGHT, 72, WIN_FONT, font,
- WIN_CONSUME_KBD_EVENTS,
- WIN_UP_EVENTS, KEY_LEFT(7), 0,
- WIN_ERROR_MSG, "Can't create main panel.",
- 0);
-
- /* Create the panel items and their menus */
- done_menu = menu_create(MENU_STRINGS,
- "Close to Icon", "Quit Tool", 0,
- 0);
-
- donebutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Done", 4, font),
- PANEL_EVENT_PROC, done_menu_event,
- PANEL_NOTIFY_PROC, donebutton_notify,
- PANEL_ITEM_X, ATTR_COL(0),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- if( monday_first )
- day_menu = menu_create(MENU_STRINGS,
- "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday", "Sunday", 0,
- 0);
- else
- day_menu = menu_create(MENU_STRINGS,
- "Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday", 0,
- 0);
-
- daybutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Day", 3, font),
- PANEL_EVENT_PROC, day_menu_event,
- PANEL_NOTIFY_PROC, daybutton_notify,
- PANEL_ITEM_X, ATTR_COL(7),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- week_menu = menu_create(MENU_STRINGS, "1st", "2nd",
- "3rd", "4th", "5th", "Last", 0,
- 0);
-
- weekbutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Week", 4, font),
- PANEL_EVENT_PROC, week_menu_event,
- PANEL_NOTIFY_PROC, weekbutton_notify,
- PANEL_ITEM_X, ATTR_COL(12),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- month_menu = menu_create(MENU_STRINGS,
- "January", "February","March",
- "April", "May", "June", "July", "August",
- "September", "October", "November", "December", 0,
- 0);
-
- monthmenu_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Month", 5, font),
- PANEL_EVENT_PROC, month_menu_event,
- PANEL_NOTIFY_PROC, monthmenu_notify,
- PANEL_ITEM_X, ATTR_COL(18),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- year_menu = menu_create(0); /* years filled in later */
- add_years_to_menu();
-
- yearmenu_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Year", 4, font),
- PANEL_EVENT_PROC, year_menu_event,
- PANEL_NOTIFY_PROC, yearmenu_notify,
- PANEL_ITEM_X, ATTR_COL(25),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- todaybutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Today", 5, font),
- PANEL_NOTIFY_PROC, todaybutton_notify,
- PANEL_ITEM_X, ATTR_COL(34),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- filebutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "File", 4, font),
- PANEL_NOTIFY_PROC, filebutton_notify,
- PANEL_ITEM_X, ATTR_COL(45),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- 0);
-
- #ifndef NO_PRINTER
- printbutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Print", 5, font),
- PANEL_EVENT_PROC, print_menu_event,
- PANEL_NOTIFY_PROC, printbutton_notify,
- PANEL_ITEM_X, ATTR_COL(53),
- PANEL_ITEM_Y, ATTR_ROW(0)+2,
- PANEL_SHOW_ITEM, FALSE,
- 0);
-
- print_menu = menu_create(MENU_STRINGS, "Print Postscript", "Print Raster",
- "Change Printer", 0,
- 0);
- #endif
-
- working_pi = panel_create_item(panel, PANEL_MESSAGE,
- PANEL_LABEL_STRING, "Working!",
- PANEL_LABEL_FONT, font,
- PANEL_LABEL_BOLD, TRUE,
- PANEL_SHOW_ITEM, FALSE,
- PANEL_ITEM_X, ATTR_COL(37),
- PANEL_ITEM_Y, ATTR_ROW(1)+5,
- 0);
-
- previous_menu = menu_create(MENU_STRINGS,
- "Yesterday", "Last Week", "Last Month", "Last Year", 0,
- 0);
-
- previous_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Previous", 8, font),
- PANEL_EVENT_PROC, previous_menu_event,
- PANEL_NOTIFY_PROC, previous_menu_notify,
- PANEL_ITEM_X, ATTR_COL(2),
- PANEL_ITEM_Y, ATTR_ROW(2)-2,
- 0);
-
- current_menu = menu_create(MENU_STRINGS, "Current Day",
- "Current Week", "Current Month", "Current Year",
- "Change Date", 0,
- 0);
-
- current_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Current", 7, font),
- PANEL_EVENT_PROC, current_menu_event,
- PANEL_NOTIFY_PROC, currentbutton_notify,
- PANEL_ITEM_X, ATTR_COL(13),
- PANEL_ITEM_Y, ATTR_ROW(2)-2,
- 0);
-
- next_menu = menu_create(MENU_STRINGS, "Tomorrow",
- "Next Week", "Next Month", "Next Year", 0,
- 0);
-
- next_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE,
- panel_button_image(panel, "Next", 4, font),
- PANEL_EVENT_PROC, next_menu_event,
- PANEL_NOTIFY_PROC, nextbutton_notify,
- PANEL_ITEM_X, ATTR_COL(23),
- PANEL_ITEM_Y, ATTR_ROW(2)-2,
- 0);
-
- width = (int)window_get(panel, WIN_WIDTH);
-
- get_today(); /* get current date and time */
- clock_pi = panel_create_item(panel, PANEL_MESSAGE,
- PANEL_ITEM_X, width-150-(strlen(clockstr)*font->pf_defaultsize.x),
- PANEL_ITEM_Y, ATTR_ROW(2)+3,
- PANEL_LABEL_STRING, clockstr,
- PANEL_LABEL_FONT, font,
- 0);
-
- #ifndef NO_SUN_MOON
- sunbutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE, &sun_icon_pr,
- PANEL_NOTIFY_PROC, sunbutton_notify,
- PANEL_ITEM_X, width-140,
- PANEL_ITEM_Y, ATTR_ROW(0),
- PANEL_SHOW_ITEM, FALSE,
- 0);
-
- moonbutton_pi = panel_create_item(panel, PANEL_BUTTON,
- PANEL_LABEL_IMAGE, &moon_icon_pr,
- PANEL_NOTIFY_PROC, moonbutton_notify,
- PANEL_ITEM_X, width-70,
- PANEL_ITEM_Y, ATTR_ROW(0),
- PANEL_SHOW_ITEM, FALSE,
- 0);
- #endif
-
- /*
- * menu strings for right MB menu in the canvas
- * (day display). NB: if the order of this menu is
- * changed, also change the #defines in ct.h
- * (MMODIFY, MCUT, etc.).
- */
- day_sel_menu = menu_create(MENU_STRINGS,
- "Modify", "Cut", "Paste", "Copy", "Delete",
- "Undelete", 0,
- 0);
-
- /*
- * this button is displayed in the canvas, but needs a panel
- * for the function call to work properly
- */
- morebutton = panel_button_image(panel, "More", 4, font);
-
- /*
- * interpose on panel events to check for L7 (open/close)
- */
- notify_interpose_event_func(panel, check_close, NOTIFY_SAFE);
- }
-
- /*
- * Add year strings to year panel menu
- */
- add_years_to_menu()
- {
- int n, year;
-
- n = 1;
- for (year=START_YEAR; year<START_YEAR+NR_YEARS; year++,n++) {
- sprintf(year_str[n-1], "%4d", year+1900);
- menu_set(year_menu, MENU_STRING_ITEM, year_str[n-1], n, 0);
- }
- }
-
- /* turn sun and moon buttons on or off */
- sun_moon_buttons(state)
- int state;
- {
- #ifndef NO_SUN_MOON
- if (state) {
- if (!mframe)
- panel_set(moonbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
- if (!sframe)
- panel_set(sunbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
- } else {
- panel_set(moonbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
- panel_set(sunbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
- /* remove moon window, if it exists */
- if (mframe) {
- window_destroy(mframe);
- mframe = 0;
- }
- /* remove sun window, if it exists */
- if (sframe) {
- window_destroy(sframe);
- sframe = 0;
- }
- }
- #endif
- }
-
- /* turn print button on or off */
- print_button(state)
- int state;
- {
- #ifndef NO_PRINTER
- /* if no printer specified then never show Print button */
- if (state)
- panel_set(printbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
- else
- panel_set(printbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
- #endif /* NO_PRINTER */
- }
-
- working(state)
- int state;
- {
- /* turn "Working!" message on or off */
- if (working_msg) {
- if (state)
- panel_set(working_pi, PANEL_SHOW_ITEM, TRUE, 0);
- else
- panel_set(working_pi, PANEL_SHOW_ITEM, FALSE, 0);
- }
- }
-
- /* Create and init main subwindow. */
- create_main_window()
- {
- canvas = window_create(frame, CANVAS,
- CANVAS_FIXED_IMAGE, TRUE,
- WIN_CONSUME_KBD_EVENTS, WIN_ASCII_EVENTS,
- WIN_UP_EVENTS, KEY_LEFT(5), KEY_LEFT(6),
- KEY_LEFT(7), KEY_LEFT(8), 0,
- WIN_CONSUME_PICK_EVENTS, WIN_NO_EVENTS,
- WIN_MOUSE_BUTTONS, LOC_STILL, LOC_DRAG,
- WIN_IN_TRANSIT_EVENTS, 0,
- WIN_EVENT_PROC, mainsw_inputevent,
- CANVAS_RETAINED, TRUE,
- WIN_BELOW, panel,
- WIN_ERROR_MSG, "Can't create main window.",
- 0);
- main_pixwin = (Pixwin *) canvas_pixwin(canvas);
-
- window_set(canvas, WIN_CURSOR, day_cursor, 0);
- mainsw_state = DISPLAYING_DAY;
- day_is_open = FALSE;
- draw_day1(); /* like draw_day(), only no future popup */
- }
-
- get_fonts()
- {
- char *default_ptr, fontstr[128];
-
- /* Open normal and big font files. */
- if (user_font)
- /* use command line override */
- font = pw_pfsysopen();
- else if ((default_ptr = defaults_get_string("/CalenTool/Font", NULL, 0)) != NULL) {
- if (*default_ptr != '/') {
- strcpy(fontstr, "/usr/lib/fonts/fixedwidthfonts/");
- strcat(fontstr, default_ptr);
- if ((font = pf_open(fontstr)) == NULL)
- font = pw_pfsysopen();
- } else {
- if ((font = pf_open(default_ptr)) == NULL)
- font = pw_pfsysopen();
- }
- } else
- font = pw_pfsysopen();
- if ((default_ptr = defaults_get_string("/CalenTool/BigFont", NULL, 0)) != NULL) {
- if (*default_ptr != '/') {
- strcpy(fontstr, "/usr/lib/fonts/fixedwidthfonts/");
- strcat(fontstr, default_ptr);
- if ((bigfont = pf_open(fontstr)) == NULL)
- bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.10");
- } else {
- if ((bigfont = pf_open(default_ptr)) == NULL)
- bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.10");
- }
- } else
- bigfont = pf_open("/usr/lib/fonts/fixedwidthfonts/gallant.r.10");
- /* double check */
- if (bigfont == NULL) {
- err_rpt("unable to open large size font", NON_FATAL);
- bigfont = pw_pfsysopen();
- }
-
- /* font for displaying time under the icon and days under moon */
- sfont = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.7");
- }
-
- /*
- * create popup window for future appts display
- * called when we draw a day display.
- */
- create_future_popup()
- {
- int i, p_width;
- Panel_item item;
- char *fappt_str, *format_appt();
- static Panel_item fdone_pi, fkeep_pi;
- static int cp_width, cp_x;
-
- if (!fframe) {
- /* create new frame and control panel */
- fframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- WIN_X, ATTR_COL(12),
- WIN_Y, slots[n_slots-4].slot_pos.top,
- FRAME_LABEL, "Future Appointments",
- FRAME_SHOW_LABEL, TRUE,
- WIN_ERROR_MSG, "Can't create future frame.",
- 0);
-
- fcpanel = window_create(fframe, PANEL, 0);
-
- fkeep_pi = panel_create_item(fcpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- fkeep_proc, PANEL_LABEL_IMAGE,
- panel_button_image(fcpanel, "Keep", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(20),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- fdone_pi = panel_create_item(fcpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- fdone_proc, PANEL_LABEL_IMAGE,
- panel_button_image(fcpanel, "Done", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(30),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- window_fit(fcpanel);
- cp_width = (int) window_get(fcpanel, WIN_WIDTH);
- cp_x = (int) window_get(fcpanel, WIN_X);
-
- } else {
- /* existing frame, so just delete and recreate the
- * message panel and its items
- */
- window_destroy(fpanel);
- }
- fpanel = window_create(fframe, PANEL, WIN_BELOW, fcpanel,
- WIN_FONT, font, WIN_X, cp_x, 0);
- /* create a panel message item for each future appt */
- for (i=0; i<findex; i++) {
- fappt_str = format_appt(&future[i]);
- (void) panel_create_item(fpanel, PANEL_MESSAGE,
- PANEL_NOTIFY_PROC, fappt_notify,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_CLIENT_DATA, (caddr_t)i,
- PANEL_LABEL_X, ATTR_COL(1),
- PANEL_LABEL_Y, ATTR_ROW(i),
- PANEL_LABEL_FONT, font,
- PANEL_LABEL_STRING, fappt_str,
- 0);
- }
- window_fit(fpanel);
- /* find out which panel is wider and use it for frame width */
- p_width = (int) window_get(fpanel, WIN_WIDTH);
- if (p_width > cp_width) {
- /* reset control panel size */
- window_set(fcpanel, WIN_WIDTH, p_width, 0);
- /* move buttons */
- panel_set(fdone_pi, PANEL_ITEM_X, ATTR_COL(-7)+p_width,
- PANEL_SHOW_ITEM, TRUE,
- 0);
- panel_set(fkeep_pi, PANEL_ITEM_X, ATTR_COL(-17)+p_width,
- PANEL_SHOW_ITEM, TRUE,
- 0);
- } else {
- window_set(fpanel, WIN_WIDTH, cp_width, 0);
- /* move buttons */
- panel_set(fdone_pi, PANEL_ITEM_X, ATTR_COL(-7)+cp_width,
- PANEL_SHOW_ITEM, TRUE,
- 0);
- panel_set(fkeep_pi, PANEL_ITEM_X, ATTR_COL(-17)+cp_width,
- PANEL_SHOW_ITEM, TRUE,
- 0);
- }
- window_fit(fframe);
- window_set(fframe, WIN_SHOW, TRUE, 0);
- }
-
- /*
- * create a popup to modify or set attributes for a given
- * appointment.
- */
- create_attr_frame()
- {
- void everyx_notify();
-
- /* create new frame and control panel */
- attr_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- FRAME_SHOW_LABEL, FALSE,
- WIN_ERROR_MSG, "Can't create attributes frame.",
- 0);
-
- attr_panel = window_create(attr_frame, PANEL,
- WIN_FONT, font,
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- (void) panel_create_item(attr_panel, PANEL_MESSAGE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING, "Appointment Options",
- PANEL_LABEL_X, ATTR_COL(4),
- PANEL_LABEL_Y, ATTR_ROW(0)+4,
- PANEL_LABEL_BOLD, TRUE,
- 0);
-
- (void) panel_create_item(attr_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- attr_accept, PANEL_LABEL_IMAGE,
- panel_button_image(attr_panel, "Accept", 6, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(35),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(attr_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- attr_abort, PANEL_LABEL_IMAGE,
- panel_button_image(attr_panel, "Abort", 5, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(45),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- everyx_pi = panel_create_item(attr_panel, PANEL_TOGGLE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_DISPLAY_LEVEL, PANEL_ALL,
- PANEL_NOTIFY_PROC, everyx_notify,
- PANEL_LABEL_STRING, "Repeat appointment:",
- PANEL_CHOICE_STRINGS, "Mon-Fri", "Every Day",
- "Selected Week", "Every Month", "Every Year", 0,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(2)-5,
- 0);
-
- whichwk_pi = panel_create_item(attr_panel, PANEL_TOGGLE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_DISPLAY_LEVEL, PANEL_ALL,
- PANEL_LABEL_STRING,
- "Indicate which week(s) in the month:",
- PANEL_CHOICE_STRINGS, "1st", "2nd",
- "3rd", "4th", "5th", "Last", "All", 0,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(3)-5,
- 0);
-
- repeat_pi = panel_create_item(attr_panel, PANEL_TEXT,
- PANEL_SHOW_ITEM, FALSE,
- PANEL_LABEL_STRING,
- "Repeat at specified interval of days:",
- PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
- PANEL_VALUE_DISPLAY_LENGTH, 4,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(3),
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- runl_pi = panel_create_item(attr_panel, PANEL_TEXT,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING,
- "Repeat specified number of times (default forever):",
- PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
- PANEL_VALUE_DISPLAY_LENGTH, 4,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(4),
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- remind_pi = panel_create_item(attr_panel, PANEL_TEXT,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING,
- "Warn in advance by specified number of days:",
- PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
- PANEL_VALUE_DISPLAY_LENGTH, 4,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(5),
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- advw_pi = panel_create_item(attr_panel, PANEL_TEXT,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING,
- "Remind a specified number of minutes before:",
- PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 4,
- PANEL_VALUE_DISPLAY_LENGTH, 4,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(6),
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- /* This panel item is currently only supported
- * for note appointment entries.
- */
- marked_pi = panel_create_item(attr_panel, PANEL_CYCLE,
- PANEL_SHOW_ITEM, FALSE,
- PANEL_LABEL_STRING,
- "Mark in month/year display:",
- PANEL_CHOICE_STRINGS, "Yes", "No", 0,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(7),
- 0);
-
- window_fit(attr_panel);
- window_fit(attr_frame);
- }
-
- /*
- * create a popup to choose delete mode
- */
- create_del_frame()
- {
- /* create new frame and control panel */
- del_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- FRAME_SHOW_LABEL, FALSE,
- WIN_ERROR_MSG, "Can't create delete frame.",
- 0);
-
- del_panel = window_create(del_frame, PANEL,
- WIN_FONT, font,
- 0);
-
- (void) panel_create_item(del_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- del_done, PANEL_LABEL_IMAGE,
- panel_button_image(del_panel, "Accept", 6, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(30),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(del_panel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- attr_abort, PANEL_LABEL_IMAGE,
- panel_button_image(del_panel, "Abort", 5, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(40),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(del_panel, PANEL_MESSAGE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING, "This is a recurring appointment.",
- PANEL_LABEL_X, ATTR_COL(1),
- PANEL_LABEL_Y, ATTR_ROW(1)+5,
- PANEL_LABEL_BOLD, TRUE,
- 0);
-
- del_choice_pi = panel_create_item(del_panel, PANEL_CYCLE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING, "Do you wish to:",
- PANEL_CHOICE_STRINGS, "Delete this occurrance only", "Delete all occurrances", 0,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(2)+5,
- 0);
-
- window_fit(del_panel);
- window_fit(del_frame);
- }
-
- #ifndef NO_SUN_MOON
- /*
- * create popup for sun data frame
- */
- sun_data_frame()
- {
- Panel spanel;
-
- /* create new frame and canvas */
- if (!sframe) {
- sframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- WIN_X, ATTR_COL(12),
- FRAME_LABEL, "Solar Data",
- FRAME_SHOW_LABEL, TRUE,
- FRAME_DONE_PROC, sframe_done,
- WIN_ERROR_MSG, "Can't create sun data frame.",
- 0);
-
- spanel = window_create(sframe, PANEL, WIN_FONT, font,
- WIN_WIDTH, 55*font->pf_defaultsize.x,
- WIN_ERROR_MSG, "Can't create sun data panel.",
- 0);
-
- (void) panel_create_item(spanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- sdone_proc, PANEL_LABEL_IMAGE,
- panel_button_image(spanel, "Done", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(45),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- sdate_pi = panel_create_item(spanel, PANEL_MESSAGE,
- PANEL_ITEM_X, ATTR_COL(8),
- PANEL_ITEM_Y, ATTR_ROW(0),
- /* string filled in later */
- PANEL_LABEL_STRING, "",
- PANEL_LABEL_FONT, font,
- 0);
-
- window_fit_height(spanel);
- scanvas = window_create(sframe, CANVAS, WIN_BELOW, spanel,
- WIN_X, 0,
- WIN_HEIGHT, 17*font->pf_defaultsize.y,
- WIN_CONSUME_PICK_EVENT, WIN_NO_EVENTS,
- WIN_CONSUME_KBD_EVENT, WIN_NO_EVENTS,
- WIN_ERROR_MSG, "Can't create sun data canvas.",
- 0);
-
- write_sun_data();
- window_fit(sframe);
- window_set(sframe, WIN_SHOW, TRUE, 0);
- } else
- write_sun_data();
- }
-
- /*
- * create popup for moon data frame
- */
- moon_data_frame()
- {
- Panel mpanel;
-
- /* create new frame and canvas */
- if (!mframe) {
- mframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- WIN_X, ATTR_COL(12),
- FRAME_LABEL, "Lunar Data",
- FRAME_SHOW_LABEL, TRUE,
- FRAME_FOREGROUND_COLOR, &fg_default,
- FRAME_BACKGROUND_COLOR, &bg_default,
- FRAME_DONE_PROC, mframe_done,
- WIN_ERROR_MSG, "Can't create moon data frame.",
- 0);
-
- mpanel = window_create(mframe, PANEL, WIN_FONT, font,
- WIN_WIDTH, 70*font->pf_defaultsize.x,
- WIN_ERROR_MSG, "Can't create moon data panel.",
- 0);
-
- (void) panel_create_item(mpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- mdone_proc, PANEL_LABEL_IMAGE,
- panel_button_image(mpanel, "Done", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(60),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- mdate_pi = panel_create_item(mpanel, PANEL_MESSAGE,
- PANEL_ITEM_X, ATTR_COL(8),
- PANEL_ITEM_Y, ATTR_ROW(0),
- /* string filled in later */
- PANEL_LABEL_STRING, "",
- PANEL_LABEL_FONT, font,
- 0);
-
- window_fit_height(mpanel);
- mcanvas = window_create(mframe, CANVAS, WIN_BELOW, mpanel,
- WIN_X, 0,
- WIN_HEIGHT, 17*font->pf_defaultsize.y,
- CANVAS_RETAINED, TRUE,
- WIN_CONSUME_PICK_EVENT, WIN_NO_EVENTS,
- WIN_CONSUME_KBD_EVENT, WIN_NO_EVENTS,
- WIN_ERROR_MSG, "Can't create moon data canvas.",
- 0);
-
- write_moon_data();
- window_fit(mframe);
- window_set(mframe, WIN_SHOW, TRUE, 0);
- } else
- write_moon_data();
- }
- #endif /* NO_SUN_MOON */
-
- /*
- * create a popup to allow selecting a different appointment file
- */
- create_file_frame()
- {
-
- /* create new frame and control panel */
- fileframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- FRAME_LABEL, "File Selection",
- FRAME_SHOW_LABEL, TRUE,
- FRAME_DONE_PROC, fileframe_done,
- WIN_ERROR_MSG, "Can't create file frame.",
- 0);
-
- filepanel = window_create(fileframe, PANEL, WIN_FONT, font,
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- file_ro_pi = panel_create_item(filepanel, PANEL_CYCLE, PANEL_CHOICE_STRINGS,
- "Read Only", "Read/Write", 0,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- file_orig, PANEL_LABEL_IMAGE,
- panel_button_image(filepanel, "Original", 7, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(17),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- file_accept, PANEL_LABEL_IMAGE,
- panel_button_image(filepanel, "Accept", 6, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(27),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- file_reset, PANEL_LABEL_IMAGE,
- panel_button_image(filepanel, "Reset", 5, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(35),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- file_save, PANEL_LABEL_IMAGE,
- panel_button_image(filepanel, "Update", 6, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(42),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(filepanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- file_done, PANEL_LABEL_IMAGE,
- panel_button_image(filepanel, "Done", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(50),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- (void) panel_create_item(filepanel, PANEL_MESSAGE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING, "Enter the desired appointment file",
- PANEL_LABEL_X, ATTR_COL(6),
- PANEL_LABEL_Y, ATTR_ROW(2),
- PANEL_LABEL_BOLD, TRUE,
- 0);
-
- filename_pi = panel_create_item(filepanel, PANEL_TEXT,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_LABEL_STRING, "Filename:",
- PANEL_LABEL_BOLD, TRUE,
- PANEL_VALUE, 0, PANEL_VALUE_STORED_LENGTH, 128,
- PANEL_VALUE_DISPLAY_LENGTH, 30,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(3),
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- window_fit(filepanel);
- window_fit(fileframe);
- }
-
- /*
- * create a popup to display an error message
- */
- create_prompt_frame(str1, buttonflag)
- char *str1;
- {
- static Panel_item prompt_panel;
- static Panel_item msg_pi, yes_pi, no_pi = 0;
-
- if (!prompt_frame) {
- /* create new frame and control panel */
- prompt_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- FRAME_SHOW_LABEL, FALSE,
- WIN_SHOW, TRUE,
- WIN_X, ATTR_COL(15), WIN_Y, ATTR_ROW(15),
- WIN_ERROR_MSG, "Can't create error frame.",
- 0);
-
- prompt_panel = window_create(prompt_frame, PANEL,
- PANEL_ACCEPT_KEYSTROKE, FALSE,
- WIN_FONT, font,
- 0);
- } else {
- /* existing frame, delete the items */
- panel_destroy_item(msg_pi);
- panel_destroy_item(yes_pi);
- if (no_pi) {
- panel_destroy_item(no_pi);
- no_pi = 0;
- }
- }
-
- /* create new message and button panel items */
- msg_pi = panel_create_item(prompt_panel, PANEL_MESSAGE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(0),
- PANEL_LABEL_STRING, str1,
- PANEL_LABEL_BOLD, TRUE,
- 0);
-
- if (buttonflag) {
- yes_pi = panel_create_item(prompt_panel, PANEL_BUTTON,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(4),
- PANEL_ITEM_Y, ATTR_ROW(2),
- PANEL_NOTIFY_PROC, prompt_yes_notify,
- PANEL_LABEL_IMAGE,
- panel_button_image(prompt_panel, "Yes", 3, font),
- 0);
-
- no_pi = panel_create_item(prompt_panel, PANEL_MESSAGE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(12),
- PANEL_ITEM_Y, ATTR_ROW(2),
- PANEL_NOTIFY_PROC, prompt_no_notify,
- PANEL_LABEL_IMAGE,
- panel_button_image(prompt_panel, "No", 2, font),
- 0);
- } else {
- yes_pi = panel_create_item(prompt_panel, PANEL_MESSAGE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(12),
- PANEL_ITEM_Y, ATTR_ROW(2),
- PANEL_NOTIFY_PROC, prompt_yes_notify,
- PANEL_LABEL_IMAGE,
- panel_button_image(prompt_panel, "Ok", 2, font),
- 0);
- }
-
- window_fit(prompt_panel);
- window_fit(prompt_frame);
- }
-
- #ifndef NO_PRINTER
- /* create popup to change the printer */
- create_print_frame()
- {
- Panel prpanel;
-
- prframe = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- WIN_SHOW, FALSE, WIN_X, ATTR_COL(12),
- FRAME_LABEL, "Change Printer",
- FRAME_SHOW_LABEL, TRUE,
- FRAME_DONE_PROC, prframe_done,
- WIN_ERROR_MSG, "Can't create printer frame.",
- 0);
-
- prpanel = window_create(prframe, PANEL, WIN_FONT, font,
- WIN_ERROR_MSG, "Can't create printer panel.",
- 0);
-
- (void) panel_create_item(prpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- prdone_proc, PANEL_LABEL_IMAGE,
- panel_button_image(prpanel, "Done", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(34),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- prfile_pi = panel_create_item(prpanel, PANEL_CYCLE,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(1)+5,
- PANEL_LABEL_STRING, "Destination:",
- PANEL_LABEL_BOLD, TRUE,
- PANEL_CHOICE_STRINGS, "Printer", "File Only", 0,
- 0);
-
- prcmd_pi = panel_create_item(prpanel, PANEL_TEXT,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(2)+5,
- PANEL_LABEL_STRING, "Print command:",
- PANEL_LABEL_FONT, font,
- PANEL_LABEL_BOLD, TRUE,
- PANEL_VALUE_STORED_LENGTH, 128,
- PANEL_VALUE_DISPLAY_LENGTH, 30,
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- panel_set_value(prcmd_pi, printer);
- panel_set_value(prfile_pi, 0);
- window_fit(prpanel);
- window_fit(prframe);
- }
- #endif /* NO_PRINTER */
-
- /* create popup to change the date */
- create_date_frame()
- {
- Panel dtpanel;
- char date[9];
-
- date_frame = window_create(frame, FRAME, FRAME_NO_CONFIRM, TRUE,
- WIN_SHOW, FALSE, WIN_X, ATTR_COL(12),
- FRAME_LABEL, "Change Current Date",
- FRAME_SHOW_LABEL, TRUE,
- FRAME_DONE_PROC, dtframe_done,
- WIN_ERROR_MSG, "Can't create date frame.",
- 0);
-
- dtpanel = window_create(date_frame, PANEL, WIN_FONT, font,
- WIN_ERROR_MSG, "Can't create date panel.",
- 0);
-
- (void) panel_create_item(dtpanel, PANEL_BUTTON, PANEL_NOTIFY_PROC,
- dtdone_proc, PANEL_LABEL_IMAGE,
- panel_button_image(dtpanel, "Done", 4, font),
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(34),
- PANEL_ITEM_Y, ATTR_ROW(0),
- 0);
-
- setdate_pi = panel_create_item(dtpanel, PANEL_TEXT,
- PANEL_SHOW_ITEM, TRUE,
- PANEL_ITEM_X, ATTR_COL(1),
- PANEL_ITEM_Y, ATTR_ROW(1)+5,
- PANEL_LABEL_STRING, (day_first ? "Enter date (D, D/M, or D/M/Y):" : "Enter date (D, M/D, or M/D/Y):"),
- PANEL_LABEL_FONT, font,
- PANEL_LABEL_BOLD, TRUE,
- PANEL_VALUE_STORED_LENGTH, 10,
- PANEL_VALUE_DISPLAY_LENGTH, 10,
- PANEL_BLINK_CARET, TRUE,
- 0);
-
- if (day_first)
- sprintf(date, "%d/%d/%02d", current.tm_mday, current.tm_mon+1, current.tm_year);
- else
- sprintf(date, "%d/%d/%02d", current.tm_mon+1, current.tm_mday, current.tm_year);
- panel_set_value(setdate_pi, date);
- window_fit(dtpanel);
- window_fit(date_frame);
- }
-
- /* replace cursors with hourglass symbol to show we're waiting */
- lock_cursors()
- {
- panel_cursor = cursor_copy((Cursor) window_get(panel, WIN_CURSOR));
- canvas_cursor = cursor_copy((Cursor) window_get(canvas, WIN_CURSOR));
- window_set(panel, WIN_CURSOR, wait_cursor, 0);
- window_set(canvas, WIN_CURSOR, wait_cursor, 0);
- locked = 1;
- }
-
- /* restore cursors */
- unlock_cursors()
- {
- window_set(panel, WIN_CURSOR, panel_cursor, 0);
- window_set(canvas, WIN_CURSOR, canvas_cursor, 0);
- cursor_destroy(panel_cursor);
- cursor_destroy(canvas_cursor);
- locked = 0;
- }
-