home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume13 / xcal / part04 / xcal.h < prev   
C/C++ Source or Header  |  1991-05-12  |  6KB  |  199 lines

  1. /*
  2.  *    xcal.h    3.14    1/16/91
  3.  *
  4.  *    Header file for the xcal program
  5.  */
  6.  
  7. /*
  8.  *    On 32 bit machines we can pack the date into one word
  9.  *    if not we have to use two callbacks
  10.  *    so undef if not true
  11.  *    and fiddle with the definitions below
  12.  */
  13. /* #define    LONG_IS_32_BITS */
  14.  
  15. /* pack year and month into Cardinals */
  16. #ifdef LONG_IS_32_BITS
  17. #define    DatePack(w, d, m, y)    ((((w)&0x7)<<21) | (((d)&0x1f)<<16) | (((m)&0xf)<<12) | ((y)&0xfff))
  18. #define YrUnpack(v)    ((v)&0xfff)
  19. #define MoUnpack(v)    (((v)>>12)&0xf)
  20. #define DyUnpack(v)    (((v)>>16)&0x1f)
  21. #define WdUnpack(v)    (((v)>>21)&0x7)
  22. #else /*  LONG_IS_32_BITS */
  23. #define    DatePack(m, y)    ((((m)&0xf)<<12) | ((y)&0xfff))
  24. #define DayPack(w, d)    ((((w)&0x7)<<5) | ((d)&0x1f))
  25. #define YrUnpack(v)    ((v)&0xfff)
  26. #define MoUnpack(v)    (((v)>>12)&0xf)
  27. #define DyUnpack(v)    ((v)&0x1f)
  28. #define WdUnpack(v)    (((v)>>5)&0xf)
  29. #endif /* LONG_IS_32_BITS */
  30.  
  31. /*
  32.  *    Foreground/Background colours
  33.  */
  34. typedef struct
  35. {    Pixel    bg;
  36.     Pixel    fg;
  37. } Colour;
  38.  
  39. /*
  40.  *    resources used by xcal.c
  41.  */
  42. struct resources
  43. {    Boolean    debug;        /* Debug switch - currently used to fast fwd */
  44.                 /* the date */
  45.     Boolean    alarmScan;    /* Debug switch for alarm system */
  46.     Boolean    reverseVideo;    /* Display in Reverse video */
  47.     Boolean    useWmTitle;    /* When displaying strips do not include a */
  48.                 /* month - year value */
  49.     Boolean    markToday;    /* Mark today with today's colours */
  50.     Boolean    calCompat;    /* True if handle files like xcalendar */
  51.     Boolean giveHelp;    /* True if help is needed (default) */
  52.     Boolean initialCalendar;/* Pop up Calendar on startup if True */
  53.     Boolean initialEdit;    /* Pop up today's Edit on startup if True */
  54.     Boolean    initialMemo;    /* Pop up memo box on start */
  55.     Boolean    dateYearIs2;    /* Display year as two digits in date strip  */
  56.     Boolean    editYearIs2;    /* Display year as two digits in edit strip  */
  57.     Boolean    memoYearIs2;    /* Display year as two digits in memo strip  */
  58.     String    mon[12];    /* Long month names */
  59.     String    smon[12];    /* Short month names */
  60.     String    day[7];        /* Day names - full */
  61.     String    sday[7];    /* Short day names */
  62.     String    weekly;        /* Title of weekly edit strip */
  63.     String    opfmt;        /* format for main box */
  64.     String    order;        /* Orders are dmy/ymd/mdy/ydm */
  65.     int    val_order;    /* The selected order */
  66.     Colour    marked;        /* Marked entry colour */
  67.     Colour    today;        /* What to mark today with */
  68.     XFontStruct *fontToday; /* We can also do Today in a different font */
  69.     String    directory;    /* Directory under home where Calendar files */
  70.                 /* can be found */
  71.     int    textbufsz;    /* Text buffer size for editing */
  72.     Dimension minstripwidth; /* Minimum strip width */
  73.     Boolean    alarms;        /* false - no alarms, true - alarms */
  74.     XtIntervalId interval_id;/* store XtAddTimeOut value */
  75.     int    update;        /* interval between peeks (60 secs) */
  76.     int    volume;        /* how loud to beep the alarm 0-100 */
  77.     int    nbeeps;        /* how many beeps for an alarm ? */
  78.     int    autoquit;    /* Automatically delete message boxes */
  79.     String    countdown;    /* Comma separated countdown string for alarms */
  80.     String    cmd;        /* command to execute for every alarm */
  81.     String    alarmleft;    /* string containing a message - %d mins left */
  82.     String    alarmnow;    /* string containing a message - Now! */
  83.     Boolean    useMemo;    /* true use top-level memo button, false - don't */
  84.     Boolean memoLeft;    /* True if on left of date, false otherwise */
  85.     String    memoFile;    /* name of the file where the memo data is stored */
  86.     int    maxDisplayLines;/* maximum number of lines that we want to */
  87.                 /* allow the top half of a memo window to */
  88.                 /* stretch to */
  89. };
  90.  
  91. extern    struct resources    appResources;
  92.  
  93. /*
  94.  *    Order coding inserted into val_order
  95.  */
  96. #define    O_DMY        0    /* default */
  97. #define O_YMD        1    /* Year/Month/Day */
  98. #define O_MDY        2    /* Month/Day/Year */
  99. #define O_YDM        3    /* Year/Day/Month */
  100. #define    O_WEEKLEFT    4    /* Place day of the week on the left */
  101. #define O_WEEKRIGHT    8    /* Place day of the week on the right */
  102. #define    O_WEEKMASK    O_WEEKLEFT|O_WEEKRIGHT
  103.  
  104. /*
  105.  *    Date structure
  106.  */
  107. typedef struct
  108. {    Cardinal    day;
  109.     Cardinal    month;
  110.     Cardinal    year;
  111.     Cardinal    wday;
  112. } Date;
  113.  
  114. /*
  115.  *    A month entry
  116.  */
  117. typedef struct me
  118. {
  119.     Cardinal    me_year;    /* map year */
  120.     Cardinal    me_month;    /* which month */
  121.     String        me_have[32];    /* if a file present for the day */
  122.                     /* then will have a non-zero entry */
  123.     int        me_type;    /* type of displayed strip */
  124. } MonthEntry;
  125.  
  126. #define ME_MONTHLY    1        /* `Normal' monthly strip */
  127. #define ME_WEEKLY    2        /* Weekly strip */
  128.  
  129. /*
  130.  *    An instance of the strip
  131.  */
  132. typedef    struct    instance
  133. {    struct    instance *i_next;    /* next object */
  134.     Widget    i_w;            /* the widget top level */
  135.     Widget    i_day_label[32];    /* the handle to the label on each day */
  136.                     /* so we can change dates at night */
  137.     Widget    i_day_info[32];        /* The info field for this date - so */
  138.                     /* we can sensitise/desensitise on editing */
  139.     Colour    i_col;            /* what the fg/bg colours used to be */
  140.     XFontStruct    *i_font;    /* what the font was */
  141. } Instance;
  142.  
  143. Instance *RegisterMonth();
  144. Instance *FindInstanceList();
  145.  
  146. /*
  147.  *    Alarm structure
  148.  *    one of these exists for each event in the timeout queue
  149.  *    the list is sorted in event order
  150.  */
  151. typedef struct _alarm
  152. {    struct _alarm *next;    /* pointer to next alarm */
  153.     String    alarm;        /* alarm string */
  154.     String    what;        /* what is message */
  155.     int    alarm_mm;    /* hour*60 + min */
  156.     int    alarm_state;    /* what time left to `real' timeout */
  157.     Boolean isAction;    /* more than alarm */
  158. } Alarm;
  159.  
  160. /*
  161.  *    We occasionally need these
  162.  */
  163. extern    Widget    toplevel;
  164. extern    Date    today;
  165.  
  166. /*
  167.  *    Global routines
  168.  */
  169. void    InitAlarms();
  170. void    MouseShow();
  171. void    Leave();
  172. void    Fatal();
  173. void    SetDate();
  174. void    AskLeave();
  175. void    DialogPopup();
  176. void    SetDate();
  177. void    TextCal();
  178. void    DoCalendar();
  179. void    DoMemo();
  180. void    DoWeekly();
  181. void    MemoPoll();
  182. void    NewMonthStrip();
  183. void    InitMonthEntries();
  184. void    ChangeHighlight();
  185. void    NoEditIsPossible();
  186. void    NoDayEditIsPossible();
  187. void    StartEditing();
  188. MonthEntry *GetMonthEntry();
  189. MonthEntry *GetWeeklyEntry();
  190. void    AlarmFilePoll();
  191. String    ReadCalendarFile();
  192. void    UpdateMemo();
  193. void    PlaceStr();
  194. String    MakeWeeklyName();
  195. String    GetWeeklyFile();
  196. Boolean    NeedTop();
  197.  
  198. time_t    time();
  199.