home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / os2 / timeserv / clkdata.c < prev    next >
C/C++ Source or Header  |  1999-05-11  |  6KB  |  175 lines

  1. /*static char *SCCSID = "@(#)clkdata.c    6.5 92/02/18";*/
  2. /*=========================================================================\
  3.  *                                                                         *
  4.  *       FILE:clkdata.c                                                    *
  5.  *                                                                         *
  6.  *       DESCRIPTION:    Presentation Manager Alarm Clock Application      *
  7.  *                                                                         *
  8.  *                                                                         *
  9.  *                                                                         *
  10.  *      Copyright 1989, 1990, 1992 IBM Corp.                               *
  11.  *                                                                         *
  12.  *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is        *
  13.  *      sample code created by IBM Corporation. This sample code is not    *
  14.  *      part of any standard or IBM product and is provided to you solely  *
  15.  *      for  the purpose of assisting you in the development of your       *
  16.  *      applications.  The code is provided "AS IS", without               *
  17.  *      warranty of any kind.  IBM shall not be liable for any damages     *
  18.  *      arising out of your use of the sample code, even if they have been *
  19.  *      advised of the possibility of   such damages.                      *
  20.  *                                                                         *
  21.  *-------------------------------------------------------------------------*
  22.  *
  23.  *
  24.  *
  25.  *
  26.  *
  27.  *
  28.  *
  29.  *
  30.  *
  31.  *
  32.  *
  33.  *--------------------------------------------------------------
  34.  *
  35.  *  This source file contains no functional code, but is used
  36.  *  to include global data variable for various modules of the
  37.  *  sample clock program
  38.  *
  39.  *
  40.  *
  41. \*==============================================================*/
  42.  
  43. /*--------------------------------------------------------------*\
  44.  *  Include files, macros, defined constants, and externs
  45. \*--------------------------------------------------------------*/
  46. #define INCL_PM
  47. #define INCL_DOSSEMAPHORES
  48. #define INCL_DOSDATETIME
  49.  
  50.  
  51. #include <os2.h>
  52. #include <string.h>
  53. #include "clock.h"
  54. #include "res.h"
  55.  
  56.  
  57.  
  58.  
  59. /*--------------------------------------------------------------*\
  60.  *  Global variables
  61. \*--------------------------------------------------------------*/
  62. HWND hwndFrame;
  63. HWND hwndTitleBar;
  64. HWND hwndSysMenu;
  65. HWND hwndMinMax;
  66. HWND hwndMenu;
  67. HAB  hab;
  68. HMQ  hmq;
  69. HSWITCH hsw;
  70. BOOL fStartAsIcon = FALSE;
  71. BOOL fHelpEnabled = FALSE;
  72.  
  73. CLOCKPREF cp;
  74. HWND hwndHelpInstance;
  75.  
  76. PFNWP pfnwpFrameWndProc;
  77.  
  78.  
  79. SHORT      Selected = NOSELECT;     /* currently hilited and selected field */
  80. SHORT      PreviousSelected;        /* previously hilited and selected field */
  81.  
  82. UCHAR      lastSecondDrawn = -1;
  83.  
  84.  
  85. BOOL bLeadingZero;                  /* pad date/time with zero */
  86. BOOL bIsIconic = FALSE;
  87.  
  88.  
  89. WRECT rDateTime[6];                /* placement of time and date matters */
  90. WRECT rAlarmTime[3];               /* placement of time and date matters */
  91. WRECT rRepaintTime;                /* repaint time region */
  92. WRECT rDateAssign[3];              /* holds date locs, so can quickly
  93.                                       reassign rDateTime[MONTH-YEAR]
  94.                                       to diff date formats */
  95. SHORT sFirstTime;                  /* first field in time */
  96. SHORT sFirstDate;                  /* first field in date */
  97. SHORT asLeftOf[6];                 /* for inc/dec inclds wrapping */
  98. SHORT asRightOf[6];                /* for inc/dec inclds wrapping */
  99. SHORT wDateTime[6];                /* values for first 6 date/time items */
  100. SHORT wModulos[3] =                /* highest value for each; actually mod n+ 1 */
  101.       { 23,59,59 };
  102. SHORT wPrevDateTime[6];            /* only repaint fields if nec */
  103.  
  104. HWND  hDate, hTime;                /* handle to group boxes (for focus) */
  105. HWND  hDateScroll;
  106. HWND  hTimeScroll;
  107. HWND  hCurrentFocus;               /* control with current focus */
  108. HWND  hDateTime;
  109. HWND  hAlarmTime;
  110.  
  111. BOOL bTwelveHourFormat;            /* 12 hr. versus military */
  112. WRECT rTimeSep[3];                 /* posn of time separator strings and AM/PM */
  113. CHAR  szTimeSep[TIME_SEP_LEN+1];     /* time separator string */
  114. CHAR  szAnteMeridian[STRING_AM_LEN+1]; /* AM/PM */
  115. CHAR  szPostMeridian[STRING_PM_LEN+1];
  116. CHAR  szTitle [81];
  117. CHAR  szErrClocks[PATHMAX+1];
  118.  
  119. WRECT rDateSep[2];                 /* posn of date separator strings */
  120. CHAR  szDateSep[DATE_SEP_LEN+1];   /* date separator string */
  121. BOOL fTimeFreez = FALSE;
  122. BOOL fDateFreez = FALSE;
  123. USHORT vusDateFormat;
  124. MATRIXLF vmatlfDateTrans = {
  125.      MAKEFIXED ( 1 , 0 ) ,       MAKEFIXED ( 0 , 0 ) ,       0L ,
  126.      MAKEFIXED ( 0 , 0 ) ,       MAKEFIXED ( 1 , 0 ) ,       0L ,
  127.      0L ,                      0L ,                      1L } ;
  128. MATRIXLF vmatlfDateScale  = {
  129.      MAKEFIXED ( 1 , 0 ) ,       MAKEFIXED ( 0 , 0 ) ,       0L ,
  130.      MAKEFIXED ( 0 , 0 ) ,       MAKEFIXED ( 1 , 0 ) ,       0L ,
  131.      0L ,                      0L ,                      1L } ;
  132.  
  133. SWP swp;
  134. HPS hps;
  135. HDC hdc;
  136. RECTL rclPage;
  137. DATETIME dt;
  138. BOOL f;
  139. BOOL fIconic, fShowSecondHand;
  140. SIZEL sizl = { 200 , 200 };
  141. ULONG cxRes , cyRes;
  142. char achOldTime[9];
  143. char achAmPm[3];
  144. char achOldAmPm[3];
  145. char achOldDate[9];
  146. HPS hpsWnd;
  147. LONG cxScreen , cyScreen;          /* screen dimensions */
  148. LONG vclrBG[3];
  149. LONG vclrFace[3];
  150. LONG vclrRing[3];
  151. LONG vclrHands[3];
  152. LONG vclrMajorTicks[3];
  153. LONG vclrMinorTicks[3];
  154. LONG vclrDate[4];
  155. USHORT vusDatePos;
  156. BOOL vbInAlarm;
  157. PFNWP pfnwpEntryField;
  158. HWND hwndEntryField;
  159.  
  160. HWND hwndClient;
  161. HPS hpsBuffer;
  162. HDC hdcBuffer;
  163. BOOL fBufferDirty = FALSE;
  164.  
  165. ULONG cColorPlanes, cColorBitcount;
  166. BOOL fEndThread = FALSE;
  167. TIMER_RESOURCES TimerResources;
  168.  
  169. /*--------------------------------------------------------------*\
  170.  *  Entry point declarations
  171. \*--------------------------------------------------------------*/
  172.  
  173.  
  174.  
  175.