home *** CD-ROM | disk | FTP | other *** search
-
- /*
- Name: monthtool
-
- Purpose: visual appointment calendar
-
- Author: Sarah Metcalfe apres Mike Essex & Rich Burridge
-
- Date: June 24, 1987
-
- Discussion: Displays a calendar to the screen for a given month.
- User may move the mouse to any day of the
- month and view or enter appointments for that date.
- */
-
-
-
-
- #include "monthtool.h"
-
- void dateEvent();
-
- void monthEvent();
- void todayBtnHit();
- void upBtnHit();
- void downBtnHit();
- void monthBackgroundHit();
-
- void notesBackgroundHit();
- void notesPanelEvent();
- void notesRadioHit();
-
- Canvas datesDsply;
- Textsw notesDsply;
- Panel monthPanel,
- notesPanel;
- Frame frame;
- Menu mainMenu,
- fileMenu;
- Panel_item monthItem,
- notesTypeItem;
- Pixwin *datesCrayon;
- struct pixfont *font,
- *notesFont;
-
-
- short dayIcon[] = {
- 0xFFFF,0xFFFF,0xFF00,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0x8000,0x0000,0x0100,0x0000,
- 0x8000,0x0000,0x0100,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
- mpr_static(dayPr, 64, 64, 1, dayIcon);
-
- short bigDayIcon[] = {
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xE000,0x0000,0x0700,0x0000,
- 0xE000,0x0000,0x0700,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
- mpr_static(bigDayPr, 64, 64, 1, bigDayIcon);
-
- short daySelIcon[] = {
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xA222,0x2222,0x2300,0x0000,
- 0xC444,0x4444,0x4500,0x0000,0x9111,0x1111,0x1100,0x0000,
- 0x8888,0x8888,0x8900,0x0000,0xA222,0x2222,0x2300,0x0000,
- 0xC444,0x4444,0x4500,0x0000,0x9111,0x1111,0x1100,0x0000,
- 0x8888,0x8888,0x8900,0x0000,0xA222,0x2222,0x2300,0x0000,
- 0xC444,0x4444,0x4500,0x0000,0x9111,0x1111,0x1100,0x0000,
- 0x8888,0x8888,0x8900,0x0000,0xA222,0x2222,0x2300,0x0000,
- 0xC444,0x4444,0x4500,0x0000,0x9111,0x1111,0x1100,0x0000,
- 0x8888,0x8888,0x8900,0x0000,0xA222,0x2222,0x2300,0x0000,
- 0xC444,0x4444,0x4500,0x0000,0x9111,0x1111,0x1100,0x0000,
- 0x8888,0x8888,0x8900,0x0000,0xA222,0x2222,0x2300,0x0000,
- 0xC444,0x4444,0x4500,0x0000,0x9111,0x1111,0x1100,0x0000,
- 0x8888,0x8888,0x8900,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
- mpr_static(daySelPr, 64, 64, 1, daySelIcon);
-
- short bigDaySelIcon[] = {
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xF111,0x1111,0x1700,0x0000,
- 0xE888,0x8888,0x8F00,0x0000,0xE222,0x2222,0x2700,0x0000,
- 0xE444,0x4444,0x4700,0x0000,0xF111,0x1111,0x1700,0x0000,
- 0xE888,0x8888,0x8F00,0x0000,0xE222,0x2222,0x2700,0x0000,
- 0xE444,0x4444,0x4700,0x0000,0xF111,0x1111,0x1700,0x0000,
- 0xE888,0x8888,0x8F00,0x0000,0xE222,0x2222,0x2700,0x0000,
- 0xE444,0x4444,0x4700,0x0000,0xF111,0x1111,0x1700,0x0000,
- 0xE888,0x8888,0x8F00,0x0000,0xE222,0x2222,0x2700,0x0000,
- 0xE444,0x4444,0x4700,0x0000,0xF111,0x1111,0x1700,0x0000,
- 0xE888,0x8888,0x8F00,0x0000,0xE222,0x2222,0x2700,0x0000,
- 0xE444,0x4444,0x4700,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0xFFFF,0xFFFF,0xFF00,0x0000,0xFFFF,0xFFFF,0xFF00,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
- mpr_static(bigDaySelPr, 64, 64, 1, bigDaySelIcon);
-
-
- short upBtnIcon[] = {
- 0x3FFF,0xE000,0x7FFF,0xF000,
- 0xE000,0x3800,0xC000,0x1800,
- 0xC020,0x1800,0xC070,0x1800,
- 0xC0F8,0x1800,0xC1FC,0x1800,
- 0xC3FE,0x1800,0xC7FF,0x1800,
- 0xCFFF,0x9800,0xC0F8,0x1800,
- 0xC0F8,0x1800,0xC0F8,0x1800,
- 0xC0F8,0x1800,0xC000,0x1800,
- 0xE000,0x3800,0x7FFF,0xF000,
- 0x3FFF,0xE000,0x0000,0x0000
- };
- mpr_static(upBtnPr, BTN_WIDTH, BTN_HEIGHT, 1, upBtnIcon);
-
- short downBtnIcon[] = {
- 0x3FFF,0xE000,0x7FFF,0xF000,
- 0xE000,0x3800,0xC000,0x1800,
- 0xC0F8,0x1800,0xC0F8,0x1800,
- 0xC0F8,0x1800,0xC0F8,0x1800,
- 0xCFFF,0x9800,0xC7FF,0x1800,
- 0xC3FE,0x1800,0xC1FC,0x1800,
- 0xC0F8,0x1800,0xC070,0x1800,
- 0xC020,0x1800,0xC000,0x1800,
- 0xE000,0x3800,0x7FFF,0xF000,
- 0x3FFF,0xE000,0x0000,0x0000
- };
- mpr_static(downBtnPr, BTN_WIDTH, BTN_HEIGHT, 1, downBtnIcon);
-
-
- short toolIcon[] = {
- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8C08,0x87C2,0x21F0,0xF031,
- 0x920D,0x8102,0x2040,0x8049,0x880A,0x8102,0xA040,0xE021,
- 0x840A,0x8102,0xA040,0x8011,0x9208,0x8103,0x6040,0x8049,
- 0x8C08,0x8102,0x2040,0x8031,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2814,0x0A05,0x0281,0x8040,0x2814,0x0A05,0x0281,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2013,0xA804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2016,0x8804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- 0x8040,0x2010,0x0804,0x0201,0xA050,0x2814,0x0B05,0x82C1,
- 0xA050,0x2814,0x0B05,0x82C1,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0805,0xD201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8040,0x2010,0x0804,0x0201,
- 0xB058,0x2C16,0x0B05,0x82C1,0xB058,0x2C16,0x0B05,0x82C1,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2F50,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2D50,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0xFFFF,0xFFFF,0xFFFF,0xFFFF,
- 0x8040,0x2010,0x0804,0x0201,0xB058,0x2C16,0x0B05,0x82C1,
- 0xB058,0x2C16,0x0B05,0x82C1,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0BE4,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0BA4,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8040,0x2010,0x0804,0x0201,
- 0xB058,0x2C16,0x0B04,0x0201,0xB058,0x2C16,0x0B04,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0xBA40,0x2017,0xC804,0x0201,0x8040,0x2010,0x0804,0x0201,
- 0x8040,0x2013,0xC804,0x0201,0x9240,0x2010,0x0804,0x0201,
- 0x8040,0x2010,0x0804,0x0201,0xFFFF,0xFFFF,0xFFFF,0xFFFF
- };
- DEFINE_ICON_FROM_IMAGE(monthIcon, toolIcon);
-
-
-
- struct dateBox monthBoxes[DATE_ROWS][DATE_COLS];
-
-
- struct apptsData *firstApptRecord[NUM_NOTES_TYPE + 1 /*for NOTES_ERROR*/];
- struct apptsData *lastApptRecord[NUM_NOTES_TYPE + 1 /*for NOTES_ERROR*/];
-
-
- int tmonth, tday, tyear;
-
- int yearToShow, monthToShow;
- int dayToShow = 0;
- int dateNumToShow[NUM_NOTES_TYPE];
-
- int editCount = 0;
- int notesModified = 0;
-
- char typeChar[NUM_NOTES_TYPE] = { 0x90, 0x91, 0x92, 0x93 };
- char typeMark[3] = " ";
-
- char *smon[] = { "January", "February", "March",
- "April", "May", "June",
- "July", "August", "September",
- "October", "November", "December"
- };
- int mon[] = { 0, 31, 29, 31,
- 30, 31, 30,
- 31, 31, 30,
- 31, 30, 31,
- };
-
- main(argc, argv)
-
- int argc;
- char *argv[];
-
- {
- char fontString[80];
- char choiceString[2];
- int type;
-
-
- /* Set up menus */
-
- fileMenu = menu_create(MENU_ITEM,
- MENU_STRING, "Save",
- MENU_VALUE, MENU_SAVE,
- 0,
- MENU_ITEM,
- MENU_STRING, "Reload",
- MENU_VALUE, MENU_RELOAD,
- 0,
- 0);
-
- mainMenu = menu_create(MENU_ITEM,
- MENU_STRING, "Close (with Save)",
- MENU_VALUE, MENU_CLOSE,
- 0,
- MENU_ITEM,
- MENU_STRING, "Update Appts.",
- MENU_PULLRIGHT, fileMenu,
- 0,
- MENU_ITEM,
- MENU_STRING, "Quit (with Save)",
- MENU_VALUE, MENU_QUIT,
- 0,
- 0);
-
-
- /* Set up windows */
-
- font = pf_open(LARGEFONT); /* Open large sized font. */
- strcpy(fontString, FONTDIR);
- strcat(fontString, NORMALFONT);
- notesFont = pf_open(fontString); /* Open regular sized font. */
-
- frame = window_create(0, FRAME,
- FRAME_ICON, &monthIcon,
- FRAME_SHOW_LABEL, FALSE,
- FRAME_SUBWINDOWS_ADJUSTABLE, FALSE,
- FRAME_NO_CONFIRM, FALSE,
- WIN_HEIGHT, DATES_HEIGHT + MONTH_HEIGHT +
- NOTES_PANEL_HEIGHT + NOTES_HEIGHT + 25,
- WIN_WIDTH, WINDOW_WIDTH + 10,
- FRAME_ARGS, argc, argv,
- 0);
-
- monthPanel = window_create(frame, PANEL,
- WIN_X, 0,
- WIN_Y, 0,
- WIN_HEIGHT, MONTH_HEIGHT,
- WIN_WIDTH, WINDOW_WIDTH,
- WIN_FONT, font,
- PANEL_BACKGROUND_PROC, monthBackgroundHit,
- PANEL_EVENT_PROC, monthEvent,
- 0);
-
- datesDsply = window_create(frame, CANVAS,
- WIN_X, 0,
- WIN_BELOW, monthPanel,
- WIN_HEIGHT, DATES_HEIGHT,
- WIN_WIDTH, WINDOW_WIDTH,
- WIN_FONT, font,
- WIN_EVENT_PROC, dateEvent,
- 0);
- datesCrayon = canvas_pixwin(datesDsply);
-
- notesPanel = window_create(frame, PANEL,
- WIN_X, 0,
- WIN_BELOW, datesDsply,
- WIN_HEIGHT, NOTES_PANEL_HEIGHT,
- WIN_WIDTH, WINDOW_WIDTH,
- WIN_FONT, notesFont,
- PANEL_BACKGROUND_PROC, notesBackgroundHit,
- PANEL_EVENT_PROC, notesPanelEvent,
- 0);
-
- notesDsply = window_create(frame, TEXTSW,
- WIN_X, 0,
- WIN_BELOW, notesPanel,
- WIN_HEIGHT, WIN_EXTEND_TO_EDGE,
- WIN_WIDTH, 10000 /* very large number, cuts to actual width */,
- WIN_FONT, notesFont,
- TEXTSW_IGNORE_LIMIT, TEXTSW_INFINITY,
- 0);
-
- /* Set up panels */
-
-
- monthItem = panel_create_item(monthPanel, PANEL_MESSAGE,
- PANEL_LABEL_X, 5,
- PANEL_LABEL_Y, 10,
- 0);
-
-
- panel_create_item( monthPanel, PANEL_BUTTON,
- PANEL_ITEM_X, WINDOW_WIDTH - 2 * (BTN_WIDTH + GAP) - 55,
- PANEL_ITEM_Y, 10,
- PANEL_NOTIFY_PROC, todayBtnHit,
- PANEL_LABEL_IMAGE,
- panel_button_image(monthPanel,"Today",0,notesFont),
- 0);
-
- panel_create_item( monthPanel, PANEL_BUTTON,
- PANEL_ITEM_X, WINDOW_WIDTH - 2 * (BTN_WIDTH + GAP),
- PANEL_ITEM_Y, 10,
- PANEL_NOTIFY_PROC, upBtnHit,
- PANEL_LABEL_IMAGE, &upBtnPr,
- 0);
-
- panel_create_item( monthPanel, PANEL_BUTTON,
- PANEL_ITEM_X, WINDOW_WIDTH - (BTN_WIDTH + GAP),
- PANEL_ITEM_Y, 10,
- PANEL_NOTIFY_PROC, downBtnHit,
- PANEL_LABEL_IMAGE, &downBtnPr,
- 0);
-
-
- notesTypeItem = panel_create_item( notesPanel, PANEL_CHOICE,
- PANEL_LABEL_STRING, "Reminder Types:",
- PANEL_FEEDBACK, PANEL_NONE,
- PANEL_NOTIFY_PROC, notesRadioHit,
- 0);
- choiceString[1] = '\0';
- for (type = 0; type < NUM_NOTES_TYPE; type++) {
- choiceString[0] = typeChar[type];
- panel_set( notesTypeItem, PANEL_CHOICE_STRING, type, choiceString, 0);
- panel_set( notesTypeItem, PANEL_CHOICE_X, type, 100 + 40*(type+1), 0);
- panel_set( notesTypeItem, PANEL_CHOICE_Y, type, 4, 0);
- }
- panel_set( notesTypeItem, PANEL_LABEL_X, 4, 0);
- panel_set( notesTypeItem, PANEL_LABEL_Y, 4, 0);
-
- /* Get today's date */
-
- todaySet();
- yearToShow = tyear;
- monthToShow = tmonth;
-
- /* Load the appointments file and show this month's calendar */
-
- loadData();
- dayHit(tday);
-
- /* Wait for events */
-
- window_main_loop(frame);
-
- /* When done, leave */
-
- freeData();
- exit(0);
-
- }
-
- static void monthEvent(item, event)
-
- Panel_item item;
- Event *event;
-
- {
- switch (event_id(event)) {
- case MS_RIGHT:
- if (event_is_down(event)) {
- rootMenuDisplay(monthPanel,event);
- }
- break;
- case MS_LEFT:
- panel_default_handle_event(item,event);
- break;
- default:
- return;
- }
-
- }
-
- static void todayBtnHit(item, event)
-
- Panel_item item;
- Event *event;
-
- {
- todaySet();
- if ( (monthToShow != tmonth) || (yearToShow != tyear) ) {
- notesSave();
- monthToShow = tmonth;
- yearToShow = tyear;
- monthDisplay();
- dayHit(tday);
- }else{
- if (dayToShow != tday) {
- notesSave();
- dayHit(tday);
- }
- }
- }
-
- static void upBtnHit(item, event)
-
- Panel_item item;
- Event *event;
-
- {
- notesSave();
- if (--monthToShow < 1) {
- monthToShow = 12;
- yearToShow--;
- }
- monthDisplay();
- dayHit(1);
-
- }
-
- static void downBtnHit(item, event)
-
- Panel_item item;
- Event *event;
-
- {
- notesSave();
- if (++monthToShow == 13) {
- monthToShow = 1;
- yearToShow++;
- }
- monthDisplay();
- dayHit(1);
-
- }
-
- static void monthBackgroundHit(panel, event)
-
- Panel panel;
- Event *event;
-
- {
- switch (event_id(event)) {
- case MS_RIGHT:
- if (event_is_down(event)) {
- rootMenuDisplay(monthPanel,event);
- }
- break;
- default:
- return;
- }
-
- }
-
- static void dateEvent(win, event, arg)
-
- Canvas win;
- Event *event;
- caddr_t arg;
-
- {
- int column,
- row;
-
- if (event_is_up(event)) {
- return;
- }
-
- switch (event_id(event)) {
- case MS_LEFT:
- notesSave();
- column = event_x(event) / (DATE_BOX_WIDTH + GAP);
- row = (event_y(event)) / (DATE_BOX_HEIGHT + GAP);
- dayHit(monthBoxes[row][column].date);
- break;
- case MS_RIGHT:
- rootMenuDisplay(win,event);
- break;
- case WIN_REPAINT:
- notesSave();
- monthDisplay();
- dayHit(dayToShow);
- break;
- default:
- return;
- }
-
- }
-
- dayHit(date)
-
- int date;
-
- {
- int row,
- column;
-
- if (date != 0) {
- if (dayToShow != 0) {
- for (row = 0; row < DATE_ROWS; row++) {
- for (column = 0; column < DATE_COLS; column++) {
- if (dayToShow == monthBoxes[row][column].date) {
- dateBoxDisplay(row, column, NOHIGHLIGHT);
- }
- }
- }
- }
- for (row = 0; row < DATE_ROWS; row++) {
- for (column = 0; column < DATE_COLS; column++) {
- if (date == monthBoxes[row][column].date) {
- dateBoxDisplay(row, column, HIGHLIGHT);
- }
- }
- }
-
- dayToShow = date;
-
- dateNumToShow[NOTES_ALL_ALL_ALL] = 0;
- dateNumToShow[NOTES_D_ALL_ALL] = dayToShow;
- dateNumToShow[NOTES_D_M_ALL] = dayToShow + 100 * monthToShow;
- dateNumToShow[NOTES_D_M_Y] = dayToShow + 100 * monthToShow + 10000 * yearToShow;
-
- notesDisplay();
-
- }
-
- }
-
- static void notesPanelEvent(item, event)
-
- Panel_item item;
- Event *event;
-
- {
-
- switch (event_id(event)) {
- case MS_RIGHT:
- if (event_is_down(event)) {
- rootMenuDisplay(notesPanel,event);
- }
- break;
- case MS_LEFT:
- panel_default_handle_event(item,event);
- break;
- default:
- return;
- }
-
- }
-
- static void notesRadioHit(item, value, event)
-
- Panel_item item;
- int value;
- Event *event;
-
- {
- int caretIndex,
- endIndex,
- lineStartIndex,
- nextLineStartIndex,
- ptrnStartIndex,
- ptrnEndIndex,
- ptrnLen,
- type,
- result,
- lineNo;
-
- typeMark[0] = typeChar[value];
- ptrnLen = strlen(typeMark);
-
- caretIndex = (int)window_get( notesDsply, TEXTSW_INSERTION_POINT );
-
- lineNo = 0;
- lineStartIndex = 0;
- while (1) {
- nextLineStartIndex = (int)textsw_index_for_file_line(notesDsply, lineNo+1);
- if ( (nextLineStartIndex < 0) || (nextLineStartIndex > caretIndex) ) {
- break;
- }
- lineNo++;
- lineStartIndex = nextLineStartIndex;
- }
-
- window_set( notesDsply, TEXTSW_INSERTION_POINT, lineStartIndex, 0 );
- textsw_insert( notesDsply, typeMark, ptrnLen );
- caretIndex += ptrnLen;
-
- endIndex = (int)window_get( notesDsply, TEXTSW_LENGTH );
- if ( (nextLineStartIndex < 0) || (nextLineStartIndex > endIndex) ) {
- nextLineStartIndex = endIndex + 1;
- }
-
- lineStartIndex += strlen(typeMark);
- for (type = 0; type < NUM_NOTES_TYPE; type++) {
-
- typeMark[0] = typeChar[type];
- ptrnLen = strlen(typeMark);
- while ( ptrnLen ) {
- do {
- ptrnStartIndex = lineStartIndex;
- result = textsw_find_bytes(notesDsply, &ptrnStartIndex, &ptrnEndIndex,
- typeMark, ptrnLen, 0);
- if (result != -1) {
- if ((ptrnEndIndex < nextLineStartIndex) && (ptrnStartIndex >= lineStartIndex)) {
- textsw_erase(notesDsply, ptrnStartIndex, ptrnEndIndex);
- caretIndex -= ptrnLen;
- }else{
- result = -1;
- }
- }
- } while (result != -1);
- ptrnLen--;
- }
-
- }
-
- window_set( notesDsply, TEXTSW_INSERTION_POINT, caretIndex, 0);
-
- }
-
- static void notesBackgroundHit(panel, event)
-
- Panel panel;
- Event *event;
-
- {
- switch (event_id(event)) {
- case MS_RIGHT:
- if (event_is_down(event)) {
- rootMenuDisplay(notesPanel,event);
- }
- break;
- default:
- return;
- }
-
- }
-
- rootMenuDisplay(window, event)
-
- Window window;
- Event *event;
-
- {
-
- switch( (int)menu_show(mainMenu, window, event, 0) ) {
- case MENU_SAVE:
- saveData();
- break;
- case MENU_RELOAD:
- loadData();
- monthDisplay();
- dayHit(dayToShow);
- break;
- case MENU_CLOSE:
- saveData();
- window_set(frame, FRAME_CLOSED, TRUE, 0);
- break;
- case MENU_QUIT:
- saveData();
- window_destroy(frame);
- break;
- }
-
- }
-
- monthDisplay()
-
-
- {
- int column,
- row;
- int i, day, dow;
- char monthString[20];
- struct apptsData *cur ;
-
- sprintf(monthString, "%s %4u", smon[monthToShow-1], yearToShow);
- panel_set(monthItem, PANEL_LABEL_STRING, monthString, 0);
-
- dow = jan1Set(yearToShow);
- mon[2] = 29;
- mon[9] = 30;
- switch ((jan1Set(yearToShow + 1) + 7 - dow) % 7) {
- case 1: /* non-leap year */
- mon[2] = 28;
- break;
- case 2: /* leap year */
- break;
- default: /* 1752 */
- mon[9] = 19;
- break;
- }
- for (i = 1; i < monthToShow; i++) {
- dow += mon[i];
- }
- dow %= 7;
-
- row = 0;
- for (column = 0; column < dow; column++) {
- monthBoxes[row][column].date = 0;
- monthBoxes[row][column].hasNotes = 0;
- }
-
- for ( day = 1; day <= mon[monthToShow]; day++) {
- monthBoxes[row][column].date = day;
- monthBoxes[row][column].hasNotes = 0;
- if (column >= (DATE_COLS-1)) {
- row++;
- column = 0;
- }else{
- column++;
- }
- }
-
- for (; row < DATE_ROWS; row++) {
- for (; column < DATE_COLS; column++) {
- monthBoxes[row][column].date = 0;
- monthBoxes[row][column].hasNotes = 0;
- }
- column = 0;
- }
-
- for (i = 0; i < NUM_NOTES_TYPE; i++) {
- if ( i != NOTES_ALL_ALL_ALL ) {
- for (cur = firstApptRecord[i]; cur != NULL; cur = cur->next) {
- if ( i==NOTES_D_ALL_ALL ||
- ( cur->month==monthToShow &&
- ( i==NOTES_D_M_ALL ||
- ( cur->year==yearToShow
- )))) {
- monthBoxes[(cur->day + dow-1) / DATE_COLS]
- [(cur->day + dow-1) % DATE_COLS].hasNotes = 1;
- }
- }
- }
- }
-
- pw_writebackground(datesCrayon, 0, 0, WINDOW_WIDTH, DATES_HEIGHT, PIX_CLR);
-
- for (row = 0; row < DATE_ROWS; row++) {
- for (column = 0; column < DATE_COLS; column++) {
- dateBoxDisplay(row, column, NOHIGHLIGHT);
- }
- }
-
- }
-
- jan1Set(year)
-
- int year;
-
- {
-
- register y, dow;
-
- /* normal gregorian calendar one extra day per four years */
-
- y = year;
- dow = 4 + y + (y + 3) / 4;
-
- /* julian calendar regular gregorian less three days per 400 */
-
- if (y > 1800) {
- dow -= (y - 1701) / 100;
- dow += (y - 1601) / 400;
- }
-
- /* great calendar changeover instant */
-
- if (y > 1752)
- dow += 3;
-
- return (dow % 7);
-
- }
-
- todaySet()
-
-
- {
- struct tm *tp; /* time structure */
- long tloc; /* number of seconds since 1970 */
-
- time(&tloc);
- tp = localtime(&tloc);
- tyear = tp->tm_year;
- tmonth = tp->tm_mon + 1;
- tday = tp->tm_mday;
- tyear += 1900;
-
- }
-
- dateBoxDisplay(row, column, hilite)
-
- int row;
- int column;
- int hilite;
-
- {
- char dateString[4];
-
- if (monthBoxes[row][column].date == 0) {
- pw_write(datesCrayon,
- column * DATE_BOX_WIDTH + DATE_BORDER + (column * GAP),
- row * DATE_BOX_HEIGHT + DATE_BORDER + (row * GAP),
- DATE_BOX_WIDTH, DATE_BOX_HEIGHT, PIX_SRC, &dayPr, 0, 0);
- pw_text(datesCrayon,
- column * DATE_BOX_WIDTH + DATE_BORDER + (column * GAP) + 8,
- row * DATE_BOX_HEIGHT + DATE_BORDER + (row * GAP) + 20,
- PIX_SRC | PIX_DST, font, " ");
- }else{
- if (monthBoxes[row][column].hasNotes) {
- pw_write(datesCrayon,
- column * DATE_BOX_WIDTH + DATE_BORDER + (column * GAP),
- row * DATE_BOX_HEIGHT + DATE_BORDER + (row * GAP),
- DATE_BOX_WIDTH, DATE_BOX_HEIGHT, PIX_SRC,
- hilite ? &bigDaySelPr : &bigDayPr,
- 0, 0);
- }else{
- pw_write(datesCrayon,
- column * DATE_BOX_WIDTH + DATE_BORDER + (column * GAP),
- row * DATE_BOX_HEIGHT + DATE_BORDER + (row * GAP),
- DATE_BOX_WIDTH, DATE_BOX_HEIGHT, PIX_SRC,
- hilite ? &daySelPr : &dayPr,
- 0, 0);
- }
- sprintf(dateString, "%2u", monthBoxes[row][column].date);
- pw_text(datesCrayon,
- column * DATE_BOX_WIDTH + DATE_BORDER + (column * GAP) + 8,
- row * DATE_BOX_HEIGHT + DATE_BORDER + (row * GAP) + 20,
- PIX_SRC | PIX_DST, font, dateString);
- }
-
- }
-
- notesDisplay()
-
-
- {
- int type,
- i;
- char timeString[7];
- struct apptsData *cur;
-
-
- i = (int)window_get(notesDsply, TEXTSW_LENGTH);
- if ( i > 0 ) {
- textsw_erase( notesDsply, 0, i + 1 );
- }
-
- for (type = 0; type < NUM_NOTES_TYPE; type++) {
-
- typeMark[0] = typeChar[type];
-
- cur = firstApptRecord[type];
- while ( (cur != NULL) && (cur->dateNum < dateNumToShow[type]) ) {
- cur = cur->next;
- }
-
- while ( (cur != NULL) && (cur->dateNum == dateNumToShow[type]) ) {
-
- textsw_insert( notesDsply, typeMark, 2 );
- if (cur->time != 0) {
- sprintf(timeString, "%d:%02d ",
- (int)(cur->time / 100), (cur->time % 100));
- textsw_insert( notesDsply, timeString, strlen(timeString) );
- }
- textsw_insert( notesDsply, cur->apptMsg, strlen(cur->apptMsg) );
- textsw_insert( notesDsply, "\n", 1 );
- cur = cur->next;
- }
-
- }
-
- editCount = (int)window_get(notesDsply, TEXTSW_EDIT_COUNT);
- window_set(notesDsply, TEXTSW_FIRST_LINE, 0, 0);
- window_set(notesDsply, TEXTSW_UPDATE_SCROLLBAR, 0);
-
- }
-
- notesSave()
-
-
- {
- int bufLen,
- row, column,
- numNotes,
- type,
- newEditCount,
- thisTime, thisYear, thisMonth, thisDay;
- char *thisMsg,
- *untypedMsg,
- *notesBuffer;
- struct apptsData *cur,
- *new,
- *old,
- *nextAppt[NUM_NOTES_TYPE];
-
- newEditCount = (int)window_get(notesDsply, TEXTSW_EDIT_COUNT);
- if (newEditCount <= editCount) {
- return;
- }
- editCount = newEditCount;
-
- for (type = 0; type < NUM_NOTES_TYPE; type++) {
-
- cur = firstApptRecord[type];
- while ( (cur != NULL) && (cur->dateNum < dateNumToShow[type]) ) {
- cur = cur->next;
- }
-
- while ( (cur != NULL) && (cur->dateNum == dateNumToShow[type]) ) {
- if (cur->prev != NULL) {
- cur->prev->next = cur->next;
- }else{
- firstApptRecord[type] = cur->next;
- }
- if (cur->next != NULL) {
- cur->next->prev = cur->prev;
- }else{
- lastApptRecord[type] = cur->prev;
- }
- old = cur;
- cur = cur->next;
- free(old->apptMsg);
- free(old);
- }
- nextAppt[type] = cur;
-
- }
-
- numNotes = 0;
- bufLen = (int)window_get(notesDsply, TEXTSW_LENGTH);
-
- if (bufLen > 0) {
-
- notesBuffer = (char *)malloc( bufLen + 1 );
- window_get( notesDsply, TEXTSW_CONTENTS, 0, notesBuffer, bufLen + 1 );
-
- thisMsg = strtok( notesBuffer, "\n" );
-
- while ( thisMsg != NULL ) {
-
- stripType(thisMsg, &untypedMsg, &type);
- findTime(&untypedMsg, &thisTime);
-
- if (strlen (untypedMsg) != 0) {
-
- thisYear = thisMonth = thisDay = 0;
- switch (type) {
- case NOTES_D_M_Y:
- thisYear = yearToShow;
- case NOTES_D_M_ALL:
- thisMonth = monthToShow;
- case NOTES_D_ALL_ALL:
- thisDay = dayToShow;
- }
-
- new = (struct apptsData *)malloc( sizeof( struct apptsData ) );
- new->year = thisYear;
- new->month = thisMonth;
- new->day = thisDay;
- new->dateNum = dateNumToShow[type];
- new->time = thisTime;
- new->apptMsg = (char *)malloc( strlen(untypedMsg) + 1 );
- strcpy( new->apptMsg, untypedMsg );
-
- if (nextAppt[type] != NULL) {
- new->prev = nextAppt[type]->prev;
- if (new->prev != NULL) {
- new->prev->next = new;
- }else{
- firstApptRecord[type] = new;
- }
- new->next = nextAppt[type];
- if (new->next != NULL) {
- new->next->prev = new;
- }else{
- lastApptRecord[type] = new;
- }
- }else{
- if ( lastApptRecord[type] != NULL ) {
- new->next = NULL;
- new->prev = lastApptRecord[type];
- lastApptRecord[type]->next = new;
- lastApptRecord[type] = new;
- }else{
- firstApptRecord[type] = lastApptRecord[type] = new;
- new->prev = new->next = NULL;
- }
- }
-
- if (type != NOTES_ALL_ALL_ALL) {
- numNotes++;
- }
-
- }
- free(untypedMsg);
- thisMsg = strtok( NULL, "\n" );
-
- }
-
- free(notesBuffer);
-
- }
-
- for (row = 0; row < DATE_ROWS; row++) {
- for (column = 0; column < DATE_COLS; column++) {
- if (dayToShow == monthBoxes[row][column].date) {
- if (numNotes > 0) {
- monthBoxes[row][column].hasNotes = 1;
- }else{
- monthBoxes[row][column].hasNotes = 0;
- }
- dateBoxDisplay(row, column, HIGHLIGHT);
- }
- }
- }
-
-
- notesModified = 1;
-
- }
-
- int stripType( oldMsg, newMsg, type )
-
- char *oldMsg;
- char **newMsg;
- int *type;
-
- {
- int i,j,
- typeFound, thisIsTypeChar;
-
- *newMsg = (char *)malloc( strlen(oldMsg) + 1 );
-
- i = 0;
- typeFound = 0;
-
- while ( *oldMsg != '\0' ) {
- thisIsTypeChar = 0;
- for (j = 0; j < NUM_NOTES_TYPE; j++) {
- if ( *oldMsg == typeChar[j] ) {
- *type = j;
- thisIsTypeChar = 1;
- typeFound = 1;
- }
- }
- if (thisIsTypeChar) {
- oldMsg++;
- while (*oldMsg == ' ') {
- oldMsg++;
- }
- }else{
- (*newMsg)[i] = *oldMsg;
- oldMsg++;
- i++;
- }
- }
- (*newMsg)[i] = '\0';
-
- if ( !typeFound ) {
- *type = NOTES_D_M_Y;
- }
-
- }
-
- findTime(msg, time)
-
- char **msg;
- int *time;
-
- {
- char timeString[5];
- char *curChar;
- int timeFound;
-
- curChar = *msg;
- while (*curChar == ' ') {
- curChar++;
- }
-
- if (strlen(curChar) >= 4) {
-
- timeFound = 1;
- if (*(curChar+1) == ':') {
- timeString[0] = '0';
- }else if (*(curChar+2) == ':') {
- if (isdigit(*curChar)) {
- timeString[0] = *curChar;
- curChar++;
- }else{
- timeFound = 0;
- }
- }else{
- timeFound = 0;
- }
-
- if (timeFound) {
- if ( isdigit(*curChar) && isdigit(*(curChar+2)) && isdigit(*(curChar+3)) &&
- ( (*(curChar+4) == ' ') || (*(curChar+4) == '\0') ) ) {
- timeString[1] = *curChar;
- timeString[2] = *(curChar+2);
- timeString[3] = *(curChar+3);
- timeString[4] = '\0';
- }else{
- timeFound = 0;
- }
- }
- }else{
- timeFound = 0;
- }
-
- if (timeFound) {
- *time = atoi( timeString );
- if ( ( (int)(*time / 100) >= 24 ) || ( (*time % 100 ) >= 60 ) ) {
- *time = 0;
- }else{
- curChar += 4;
- while (*curChar == ' ') {
- curChar++;
- }
- *msg = curChar;
- }
- }else{
- *time = 0;
- }
-
- }
-
- loadData()
-
-
- {
- char home[80];
- FILE *fptr;
-
- char basedata[80];
- char *timestr;
- char *apptstring;
-
- int i;
- struct apptsData *new;
-
- strcpy(home, getenv("HOME"));
- strcat(home, "/.monthtool");
-
- if ((fptr = fopen(home, "r")) != NULL) {
-
- for ( i = 0; i < (NUM_NOTES_TYPE + 1 /*for NOTES_ERROR*/); i++ ){
- firstApptRecord[i] = lastApptRecord[i] = NULL;
- }
-
- while ((fgets(basedata, 80, fptr) != NULL)) {
-
- basedata[strlen(basedata) - 1] = NULL;
-
- new = (struct apptsData *)malloc( sizeof( struct apptsData ) );
-
- new->month = atoi( strtok(basedata, ",") );
- new->day = atoi( strtok(NULL, ",") );
- new->year = atoi( strtok(NULL, ",") );
- new->dateNum = 10000 * new->year + 100 * new->month + new->day;
-
- timestr = strtok(NULL,",");
- if (strcmp(timestr, " ") == 0) {
- new->time = 0;
- }else{
- new->time = atoi(timestr);
- }
-
- apptstring = strtok(NULL, "\n" );
- new->apptMsg = malloc(strlen(apptstring) + 1);
- strcpy(new->apptMsg, apptstring);
-
- if ( new->year != 0 ) {
- if ( new->month != 0 ) {
- if ( new->day != 0 ) {
- i = NOTES_D_M_Y;
- }else{
- i = NOTES_ERROR; /* *mmyyyy */
- }
- }else{
- i = NOTES_ERROR; /* dd*yyyy or **yyyy */
- }
- }else{
- if ( new->month != 0 ) {
- if ( new->day != 0 ) {
- i = NOTES_D_M_ALL;
- }else{
- i = NOTES_ERROR; /* *mm* */
- }
- }else{
- if ( new->day != 0 ) {
- i = NOTES_D_ALL_ALL;
- }else{
- i = NOTES_ALL_ALL_ALL;
- }
- }
- }
-
- if ( i == NOTES_ERROR ) {
- fprintf(stderr, "Monthtool warning! Invalid record: %u,%u,%4u,",
- new->month, new->day, new->year );
- if (new->time != 0) {
- fprintf(stderr, "%04u", new->time);
- }else{
- fprintf(stderr, " ");
- }
- fprintf(stderr, ",%s\n", new->apptMsg );
- }
-
- insertApptRecord(new, i);
-
- }
-
- fclose(fptr);
- }
-
- }
-
- insertApptRecord(new, type)
-
- struct apptsData *new;
- int type;
-
- {
- struct apptsData *cur;
- int inserted;
-
- if (lastApptRecord[type] == NULL) {
- firstApptRecord[type] = lastApptRecord[type] = new;
- new->prev = NULL;
- new->next = NULL;
- }else{
- inserted = 0;
- cur = lastApptRecord[type];
- do {
- if (new->dateNum >= cur->dateNum) {
- if (cur->next != NULL) {
- cur->next->prev = new;
- }else{
- lastApptRecord[type] = new;
- }
- new->next = cur->next;
- new->prev = cur;
- cur->next = new;
- inserted = 1;
- }else{
- cur = cur->prev;
- }
- } while ( !inserted && cur != NULL );
- if (!inserted) {
- new->next = firstApptRecord[type];
- new->prev = NULL;
- firstApptRecord[type]->prev = new;
- firstApptRecord[type] = new;
- }
- }
-
- }
-
- saveData()
-
-
- {
- FILE *fptr;
- char home[80];
-
- int i;
- struct apptsData *cur ;
-
- notesSave();
-
- if (notesModified) {
-
- strcpy(home, getenv("HOME"));
- strcat(home, "/.monthtool");
-
- if ((fptr = fopen(home, "w")) == NULL) {
- fprintf(stderr, "Monthtool error: Cannot open %s file", home);
- return;
- }
-
- for ( i = 0; i < (NUM_NOTES_TYPE + 1 /*for NOTES_ERROR*/); i++ ) {
- for (cur = firstApptRecord[i]; cur != NULL; cur = cur->next) {
- fprintf(fptr, "%u,%u,%u,", cur->month, cur->day, cur->year );
- if (cur->time != 0) {
- fprintf(fptr, "%04u", cur->time);
- }else{
- fprintf(fptr, " ");
- }
- fprintf(fptr, ",%s\n", cur->apptMsg );
- }
- }
-
- fclose(fptr);
-
- notesModified = 0;
-
- }
-
- }
-
- freeData()
-
-
- {
-
- int i;
- struct apptsData *cur ;
-
- for ( i = 0; i < (NUM_NOTES_TYPE + 1 /*for NOTES_ERROR*/); i++ ) {
- while( firstApptRecord[i] != NULL) {
- cur = firstApptRecord[i];
- firstApptRecord[i] = firstApptRecord[i]->next;
- free(cur->apptMsg);
- free( cur );
- }
- }
-
- }
-
-