home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / gik2 / ewyio2eu.d2x / EWYHA.C < prev    next >
Encoding:
Text File  |  1993-08-04  |  34.2 KB  |  756 lines

  1. /*
  2. GIK/2 1.0.1 EWYHA.C 5621-432 (C) COPYRIGHT IBM CORP 1991, 1993.  ALL RIGHTS RESERVED.  LICENSED MATERIALS - PROPERTY OF IBM.
  3. */
  4. /**********************************************************************/
  5. /*                                                                    */
  6. /*                         MODULE PROLOGUE                            */
  7. /*                                                                    */
  8. /* COMPONENT NAME:   CLOCK EXAMPLE                                    */
  9. /*                                                                    */
  10. /* MODULE NAME:      EWYHA.C                                          */
  11. /*                                                                    */
  12. /* DESCRIPTIVE NAME: Graphics Interface Kit/2 - Clock Example         */
  13. /*                                                                    */
  14. /* PURPOSE:                                                           */
  15. /*                                                                    */
  16. /*   This module contains functions of the customizing code of        */
  17. /*   the clock example.                                               */
  18. /*                                                                    */
  19. /* DESCRIPTION:                                                       */
  20. /*                                                                    */
  21. /*   The actual drawing routines for the three clock styles are       */
  22. /*   coded here.                                                      */
  23. /*                                                                    */
  24. /*                                                                    */
  25. /* COPYRIGHT:        (C) 1991, 1993 IBM Corporation                   */
  26. /*                                                                    */
  27. /* DISCLAIMER OF WARRANTIES.  The following [enclosed] code is        */
  28. /* sample code created by IBM Corporation. This sample code is not    */
  29. /* part of any standard or IBM product and is provided to you solely  */
  30. /* for the purpose of assisting you in the development of your        */
  31. /* applications.  The code is provided "AS IS", without               */
  32. /* warranty of any kind.  IBM shall not be liable for any damages     */
  33. /* arising out of your use of the sample code, even if they have been */
  34. /* advised of the possibility of such damages.                        */
  35. /*                                                                    */
  36. /**********************************************************************/
  37.  
  38. ;
  39.  
  40. /*--------------------------------------------------------------------*/
  41. /* INCLUDE RELATED DEFINES                                            */
  42. /*--------------------------------------------------------------------*/
  43.  
  44. #define  INCL_DOS                      /* OS/2 definitions            */
  45. #define  INCL_PM                       /* PM definitions              */
  46.  
  47. /*--------------------------------------------------------------------*/
  48. /* HEADER FILES                                                       */
  49. /*--------------------------------------------------------------------*/
  50.  
  51. #include <os2.h>                       /* OS/2 header file            */
  52. #include <math.h>
  53. #include <stdlib.h>
  54. #include <stdio.h>
  55. #include <ewyga.h>                     /* GIK/2 header file           */
  56. #include "EWYHADF.H"                   /* Generated header file       */
  57. #include "EWYHA.H"                     /* Header file                 */
  58.  
  59. /*--------------------------------------------------------------------*/
  60. /* Local constants                                                    */
  61. /*--------------------------------------------------------------------*/
  62.  
  63. ;
  64.  
  65.   /*------------------------------------------------------------------*/
  66.   /* Radius for the different mercurian circles                       */
  67.   /*------------------------------------------------------------------*/
  68.  
  69. #define  Q_DOT_RADIUS            400
  70. #define  Q_SEC_RADIUS            550
  71. #define  Q_MIN_RADIUS            250
  72. ;
  73.  
  74.   /*------------------------------------------------------------------*/
  75.   /* Radius for the different martian circles                         */
  76.   /*------------------------------------------------------------------*/
  77.  
  78. #define  M_HOUR_RADIUS           550
  79. #define  M_MIN_RADIUS            300
  80. #define  M_SEC_RADIUS            150
  81.  
  82. /*--------------------------------------------------------------------*/
  83. /* Module variables                                                   */
  84. /*--------------------------------------------------------------------*/
  85.  
  86. ;
  87.  
  88.   /*------------------------------------------------------------------*/
  89.   /* All the symbol handles for the mercurian clock                   */
  90.   /*------------------------------------------------------------------*/
  91.  
  92. static SHND      Q_top_shnd;
  93. static SHND      Q_sec_shnd;
  94. static SHND      Q_min_shnd;
  95. static SHND      Q_hour_shnd;
  96. static SHND      Q_min_c1_shnd;
  97. static SHND      Q_min_c2_shnd;
  98. static SHND      Q_secline_shnd;
  99. ;
  100.  
  101.   /*------------------------------------------------------------------*/
  102.   /* All the symbol handles for the martian clock                     */
  103.   /*------------------------------------------------------------------*/
  104.  
  105. static SHND      M_ssec_shnd;
  106. static SHND      M_sec_shnd;
  107. static SHND      M_secline_shnd;
  108. static SHND      M_min_shnd;
  109. static SHND      M_minline_shnd;
  110. static SHND      M_hour_shnd;
  111. static SHND      M_hourline_shnd;
  112.  
  113.   /*------------------------------------------------------------------*/
  114.   /* All the symbol handles for the venusian clock                    */
  115.   /*------------------------------------------------------------------*/
  116.  
  117. static SHND      V_base_shnd;
  118. static SHND      V_hour_shnd;
  119. static SHND      V_hour_text_shnd;
  120. static SHND      V_min_shnd;
  121. static SHND      V_min_text_shnd;
  122. static SHND      V_sec_shnd;
  123. static SHND      V_sec_text_shnd;
  124. static POINTL    V_text_off;
  125.  
  126. /*--------------------------------------------------------------------*/
  127. /* Local function prototypes                                          */
  128. /*--------------------------------------------------------------------*/
  129.  
  130. ;
  131.  
  132. /*--------------------------------------------------------------------*/
  133. /* Functions                                                          */
  134. /*--------------------------------------------------------------------*/
  135.  
  136. ;
  137.  
  138. /**********************************************************************/
  139. /* Q_Build                                                            */
  140. /*                                                                    */
  141. /* Parameters:                                                        */
  142. /*    DHND     dhnd   (I):  diagram handle                            */
  143. /*                                                                    */
  144. /* Returns:                                                           */
  145. /*    GS_OK                                                           */
  146. /*                                                                    */
  147. /* Description:                                                       */
  148. /*   Initially builds the mercurian clock.                            */
  149. /**********************************************************************/
  150.  
  151. SHORT Q_Build(DHND dhnd)
  152. {
  153.   SHND             shnd;
  154.   double           ang;
  155.   POINTL           pos;
  156.   SHORT            n;
  157.  
  158.   /*------------------------------------------------------------------*/
  159.   /* Add the 60 dots                                                  */
  160.   /*------------------------------------------------------------------*/
  161.  
  162.   n = 0;
  163.   ang = 0.0;
  164.   for (; n < 60; n++)
  165.   {
  166.     pos.x = (LONG)(Q_DOT_RADIUS *sin(ang));
  167.     pos.y = (LONG)(Q_DOT_RADIUS *cos(ang));
  168.     GsAddSym(dhnd, &shnd, Q_dot, Q_dot_f0);
  169.     GsPutSymPosition(dhnd, shnd, &pos);
  170.     ang += (360/60)/(180/PI);
  171.   }
  172.   Q_top_shnd = shnd-59;                /* remember the 'shnd' of the
  173.                                           top dot. This is the 12
  174.                                           o'clock dot.                */
  175.  
  176.   /*------------------------------------------------------------------*/
  177.   /* Add hour symbol                                                  */
  178.   /*------------------------------------------------------------------*/
  179.  
  180.   GsAddSym(dhnd, &Q_hour_shnd, Q_hour, Q_hour_f0);
  181.  
  182.   /*------------------------------------------------------------------*/
  183.   /* Add symbols for minute display                                   */
  184.   /*------------------------------------------------------------------*/
  185.  
  186.   GsAddSym(dhnd, &Q_min_shnd, Q_min, Q_min_f0);
  187.   GsAddSym(dhnd, &Q_min_c1_shnd, Q_line, Q_line_f0);/* link from
  188.                                           'hour' to 'minute' symbol.  */
  189.   GsPutSymTerminal(dhnd, Q_min_c1_shnd, GS_SOURCE, Q_hour_shnd);
  190.   GsPutSymTerminal(dhnd, Q_min_c1_shnd, GS_TARGET, Q_min_shnd);
  191.   GsAddSym(dhnd, &Q_min_c2_shnd, Q_minline, Q_minline_f0);/* link from
  192.                                           'minute' symbol to dots.    */
  193.   GsPutSymTerminal(dhnd, Q_min_c2_shnd, GS_SOURCE, Q_min_shnd);
  194.  
  195.   /*------------------------------------------------------------------*/
  196.   /* Add the time-second and time-line symbol and attach them         */
  197.   /*------------------------------------------------------------------*/
  198.  
  199.   GsAddSym(dhnd, &Q_sec_shnd, Q_sec, Q_sec_f0);/* 'second' symbol     */
  200.   GsAddSym(dhnd, &Q_secline_shnd, Q_secline, Q_secline_f0);/* link
  201.                                           from 'second' symbol to
  202.                                           dots.                       */
  203.   GsPutSymTerminal(dhnd, Q_secline_shnd, GS_TARGET, Q_sec_shnd);
  204.  
  205.   /*------------------------------------------------------------------*/
  206.   /* Bye                                                              */
  207.   /*------------------------------------------------------------------*/
  208.  
  209.   return (GS_OK);
  210. }
  211.  
  212. /**********************************************************************/
  213. /* Q_Tick                                                             */
  214. /*                                                                    */
  215. /* Parameters:                                                        */
  216. /*   DHND     dhnd       (I):  diagram handle                         */
  217. /*   DATETIME *pNew_time (I):  pointer to structure with new time     */
  218. /*   DATETIME *pOld_time (I):  pointer to structure with old time     */
  219. /*                                                                    */
  220. /* Returns:                                                           */
  221. /*   GS_OK                                                            */
  222. /*                                                                    */
  223. /* Description:                                                       */
  224. /*   This is the function to display the time for the mercurian clock.*/
  225. /*                                                                    */
  226. /*   Based upon the difference in time of the 'old' and the 'new'     */
  227. /*   time, the clock face, or parts of it are updated.                */
  228. /**********************************************************************/
  229.  
  230. SHORT Q_Tick(DHND dhnd,DATETIME *pNew_time,DATETIME *pOld_time)
  231. {
  232.   double           ang;
  233.   POINTL           pos;
  234.   CHAR             text[4];
  235.  
  236.   /*------------------------------------------------------------------*/
  237.   /* See if anything is to do                                         */
  238.   /*------------------------------------------------------------------*/
  239.  
  240.   if (pNew_time->seconds == pOld_time->seconds/*                      */
  241.      && pNew_time->minutes == pOld_time->minutes/*                    */
  242.      && pNew_time->hours == pOld_time->hours)
  243.     return (GS_OK);
  244.  
  245.   /*------------------------------------------------------------------*/
  246.   /* The time changed                                                 */
  247.   /*------------------------------------------------------------------*/
  248.  
  249.   SecondTick(DO_TICK);
  250.  
  251.   /*------------------------------------------------------------------*/
  252.   /* Adjust the second dependent stuff                                */
  253.   /*------------------------------------------------------------------*/
  254.  
  255.   if (pNew_time->seconds != pOld_time->seconds)
  256.   {
  257.  
  258.     /*----------------------------------------------------------------*/
  259.     /* Put new position                                               */
  260.     /*----------------------------------------------------------------*/
  261.  
  262.     ang = ((360/60)/(180/PI))*pNew_time->seconds;
  263.     pos.x = (LONG)(Q_SEC_RADIUS *sin(ang));
  264.     pos.y = (LONG)(Q_SEC_RADIUS *cos(ang));
  265.     GsPutSymPosition(dhnd, Q_sec_shnd, &pos);
  266.  
  267.     /*----------------------------------------------------------------*/
  268.     /* Put second text                                                */
  269.     /*----------------------------------------------------------------*/
  270.  
  271.     sprintf(text, "%2d", pNew_time->seconds);
  272.     GsPutPartText(dhnd, Q_sec_shnd, Q_sec_ptext, text);
  273.  
  274.     /*----------------------------------------------------------------*/
  275.     /* Adjust the second pointer                                      */
  276.     /*----------------------------------------------------------------*/
  277.  
  278.     GsPutSymTerminal(dhnd, Q_secline_shnd, GS_SOURCE, Q_top_shnd+
  279.        pNew_time->seconds);
  280.   }
  281.  
  282.   /*------------------------------------------------------------------*/
  283.   /* Adjust the minute dependent stuff                                */
  284.   /*------------------------------------------------------------------*/
  285.  
  286.   if (pNew_time->minutes != pOld_time->minutes)
  287.   {
  288.  
  289.     /*----------------------------------------------------------------*/
  290.     /* Put new position                                               */
  291.     /*----------------------------------------------------------------*/
  292.  
  293.     ang = ((360/60)/(180/PI))*pNew_time->minutes;
  294.     pos.x = (LONG)(Q_MIN_RADIUS *sin(ang));
  295.     pos.y = (LONG)(Q_MIN_RADIUS *cos(ang));
  296.     GsPutSymPosition(dhnd, Q_min_shnd, &pos);
  297.  
  298.     /*----------------------------------------------------------------*/
  299.     /* Put minute text                                                */
  300.     /*----------------------------------------------------------------*/
  301.  
  302.     sprintf(text, "%2d", pNew_time->minutes);
  303.     GsPutPartText(dhnd, Q_min_shnd, Q_min_ptext, text);
  304.  
  305.     /*----------------------------------------------------------------*/
  306.     /* Adjust the minute pointer                                      */
  307.     /*----------------------------------------------------------------*/
  308.  
  309.     GsPutSymTerminal(dhnd, Q_min_c2_shnd, GS_TARGET, Q_top_shnd+
  310.        pNew_time->minutes);
  311.   }
  312.  
  313.   /*------------------------------------------------------------------*/
  314.   /* Adjust the hour dependent stuff                                  */
  315.   /*------------------------------------------------------------------*/
  316.  
  317.   if (pNew_time->hours != pOld_time->hours)
  318.   {
  319.  
  320.     /*----------------------------------------------------------------*/
  321.     /* Put hour text                                                  */
  322.     /*----------------------------------------------------------------*/
  323.  
  324.     sprintf(text, "%2d", pNew_time->hours);
  325.     GsPutPartText(dhnd, Q_hour_shnd, Q_hour_ptext, text);
  326.   }
  327.  
  328.   /*------------------------------------------------------------------*/
  329.   /* Bye                                                              */
  330.   /*------------------------------------------------------------------*/
  331.  
  332.   return (GS_OK);
  333. }
  334.  
  335. ;
  336.  
  337. /**********************************************************************/
  338. /* M_Build                                                            */
  339. /*                                                                    */
  340. /* Parameters:                                                        */
  341. /*    DHND     dhnd   (I):  diagram handle                            */
  342. /*                                                                    */
  343. /* Returns:                                                           */
  344. /*    GS_OK                                                           */
  345. /*                                                                    */
  346. /* Description:                                                       */
  347. /*   Initially build the mars clock.                                  */
  348. /**********************************************************************/
  349.  
  350. SHORT M_Build(DHND dhnd)
  351. {
  352.  
  353.   /*------------------------------------------------------------------*/
  354.   /* Add the three pointers first, so they are at the grapihcal bottom*/
  355.   /*------------------------------------------------------------------*/
  356.  
  357.   GsAddSym(dhnd, &M_secline_shnd, M_secline, M_secline_f0);
  358.   GsAddSym(dhnd, &M_minline_shnd, M_minline, M_minline_f0);
  359.   GsAddSym(dhnd, &M_hourline_shnd, M_hourline, M_hourline_f0);
  360.  
  361.   /*------------------------------------------------------------------*/
  362.   /* Add the four bubbles                                             */
  363.   /*------------------------------------------------------------------*/
  364.  
  365.   GsAddSym(dhnd, &M_ssec_shnd, M_ssec, M_ssec_f0);
  366.   GsAddSym(dhnd, &M_sec_shnd, M_sec, M_sec_f0);
  367.   GsAddSym(dhnd, &M_min_shnd, M_min, M_min_f0);
  368.   GsAddSym(dhnd, &M_hour_shnd, M_hour, M_hour_f0);
  369.  
  370.   /*------------------------------------------------------------------*/
  371.   /* Connect the three pointers                                       */
  372.   /*------------------------------------------------------------------*/
  373.  
  374.   GsPutSymTerminal(dhnd, M_hourline_shnd, GS_SOURCE, M_hour_shnd);
  375.   GsPutSymTerminal(dhnd, M_hourline_shnd, GS_TARGET, M_min_shnd);
  376.   GsPutSymTerminal(dhnd, M_minline_shnd, GS_SOURCE, M_min_shnd);
  377.   GsPutSymTerminal(dhnd, M_minline_shnd, GS_TARGET, M_sec_shnd);
  378.   GsPutSymTerminal(dhnd, M_secline_shnd, GS_SOURCE, M_sec_shnd);
  379.   GsPutSymTerminal(dhnd, M_secline_shnd, GS_TARGET, M_ssec_shnd);
  380.  
  381.   /*------------------------------------------------------------------*/
  382.   /* Bye                                                              */
  383.   /*------------------------------------------------------------------*/
  384.  
  385.   return (GS_OK);
  386. }
  387.  
  388. /**********************************************************************/
  389. /* M_Tick                                                             */
  390. /*                                                                    */
  391. /* Parameters:                                                        */
  392. /*   DHND     dhnd       (I):  diagram handle                         */
  393. /*   DATETIME *pNew_time (I):  pointer to structure with new time     */
  394. /*   DATETIME *pOld_time (I):  pointer to structure with old time     */
  395. /*                                                                    */
  396. /* Returns:                                                           */
  397. /*   GS_OK                                                            */
  398. /*                                                                    */
  399. /* Description:                                                       */
  400. /*   This is the function to dispaly the time for the martian clock.  */
  401. /*                                                                    */
  402. /*   Based upon the difference in time of the 'old' and the 'new'     */
  403. /*   time, the clock face, or parts of it are updated.                */
  404. /**********************************************************************/
  405.  
  406. SHORT M_Tick(DHND dhnd,DATETIME *pNew_time,DATETIME *pOld_time)
  407. {
  408.   double           ang;
  409.   CHAR             text[4];
  410.   POINTL           pos;
  411.  
  412.   /*------------------------------------------------------------------*/
  413.   /* See if anything is to do                                         */
  414.   /*------------------------------------------------------------------*/
  415.  
  416.   if (pNew_time->seconds == pOld_time->seconds/*                      */
  417.      && pNew_time->minutes == pOld_time->minutes/*                    */
  418.      && pNew_time->hours == pOld_time->hours)
  419.     return (GS_OK);
  420.  
  421.   /*------------------------------------------------------------------*/
  422.   /* The time changed                                                 */
  423.   /*------------------------------------------------------------------*/
  424.  
  425.   SecondTick(DO_TICK);
  426.  
  427.   /*------------------------------------------------------------------*/
  428.   /* Adjust the hour dependent stuff                                  */
  429.   /*------------------------------------------------------------------*/
  430.  
  431.   if (pNew_time->hours != pOld_time->hours)
  432.   {
  433.  
  434.     /*----------------------------------------------------------------*/
  435.     /* Calc the new position                                          */
  436.     /*----------------------------------------------------------------*/
  437.  
  438.     ang = ((360/12)/(180/PI))*pNew_time->hours;
  439.     pos.x = (LONG)(-M_HOUR_RADIUS *sin(ang));
  440.     pos.y = (LONG)(-M_HOUR_RADIUS *cos(ang));
  441.     GsPutSymPosition(dhnd, M_hour_shnd, &pos);
  442.  
  443.     /*----------------------------------------------------------------*/
  444.     /* Put hour text                                                  */
  445.     /*----------------------------------------------------------------*/
  446.  
  447.     sprintf(text, "%2d", pNew_time->hours);
  448.     GsPutPartText(dhnd, M_hour_shnd, M_hour_ptext, text);
  449.   }
  450.  
  451.   /*------------------------------------------------------------------*/
  452.   /* Adjust the minute dependent stuff                                */
  453.   /*------------------------------------------------------------------*/
  454.  
  455.   if (pNew_time->minutes != pOld_time->minutes)
  456.   {
  457.  
  458.     /*----------------------------------------------------------------*/
  459.     /* Calc the new position                                          */
  460.     /*----------------------------------------------------------------*/
  461.  
  462.     ang = ((360/60)/(180/PI))*pNew_time->minutes;
  463.     pos.x = (LONG)(M_MIN_RADIUS *sin(ang));
  464.     pos.y = (LONG)(M_MIN_RADIUS *cos(ang));
  465.     GsPutSymPosition(dhnd, M_sec_shnd, &pos);
  466.  
  467.     /*----------------------------------------------------------------*/
  468.     /* Put minute text                                                */
  469.     /*----------------------------------------------------------------*/
  470.  
  471.     sprintf(text, "%2d", pNew_time->minutes);
  472.     GsPutPartText(dhnd, M_min_shnd, M_min_ptext, text);
  473.  
  474.     /*----------------------------------------------------------------*/
  475.     /* Force decendants for update                                    */
  476.     /*----------------------------------------------------------------*/
  477.  
  478.     pOld_time->seconds = 0xff;
  479.   }
  480.  
  481.   /*------------------------------------------------------------------*/
  482.   /* Adjust the second dependent stuff                                */
  483.   /*------------------------------------------------------------------*/
  484.  
  485.   if (pNew_time->seconds != pOld_time->seconds)
  486.   {
  487.  
  488.     /*----------------------------------------------------------------*/
  489.     /* Get offset                                                     */
  490.     /*----------------------------------------------------------------*/
  491.  
  492.     GsGetSymPosition(dhnd, M_sec_shnd, &pos);
  493.  
  494.     /*----------------------------------------------------------------*/
  495.     /* Calc the new position                                          */
  496.     /*----------------------------------------------------------------*/
  497.  
  498.     ang = ((360/60)/(180/PI))*pNew_time->seconds;
  499.     pos.x += (LONG)(M_SEC_RADIUS *sin(ang));
  500.     pos.y += (LONG)(M_SEC_RADIUS *cos(ang));
  501.     GsPutSymPosition(dhnd, M_ssec_shnd, &pos);
  502.  
  503.     /*----------------------------------------------------------------*/
  504.     /* Put second text                                                */
  505.     /*----------------------------------------------------------------*/
  506.  
  507.     sprintf(text, "%2d", pNew_time->seconds);
  508.     GsPutPartText(dhnd, M_sec_shnd, M_sec_ptext, text);
  509.   }
  510.  
  511.   /*------------------------------------------------------------------*/
  512.   /* Bye                                                              */
  513.   /*------------------------------------------------------------------*/
  514.  
  515.   return (GS_OK);
  516. }
  517.  
  518. ;
  519. ;
  520.  
  521. /**********************************************************************/
  522. /* V_Build                                                            */
  523. /*                                                                    */
  524. /* Parameters:                                                        */
  525. /*    DHND     dhnd   (I):  diagram handle                            */
  526. /*                                                                    */
  527. /* Returns:                                                           */
  528. /*    GS_OK                                                           */
  529. /*                                                                    */
  530. /* Description:                                                       */
  531. /*   Initially build the venusian clock.                              */
  532. /**********************************************************************/
  533.  
  534. SHORT V_Build(DHND dhnd)
  535. {
  536.   RECTL            br;
  537.  
  538.   /*------------------------------------------------------------------*/
  539.   /* Add the four needed symbol first, so they are at the grapihcal   */
  540.   /* bottom                                                           */
  541.   /*------------------------------------------------------------------*/
  542.  
  543.   GsAddSym(dhnd, &V_base_shnd, V_base, V_base_f0);
  544.   GsAddSym(dhnd, &V_hour_shnd, V_hour, V_hour_f0);
  545.   GsAddSym(dhnd, &V_hour_text_shnd, V_text, V_text_f0);
  546.   GsAddSym(dhnd, &V_min_shnd, V_min, V_min_f0);
  547.   GsAddSym(dhnd, &V_min_text_shnd, V_text, V_text_f0);
  548.   GsAddSym(dhnd, &V_sec_shnd, V_sec, V_sec_f0);
  549.   GsAddSym(dhnd, &V_sec_text_shnd, V_text, V_text_f0);
  550.  
  551.   /*------------------------------------------------------------------*/
  552.   /* Get offset of text fieled                                        */
  553.   /*------------------------------------------------------------------*/
  554.  
  555.   GsGetSymBoundingRect(dhnd, V_sec_text_shnd, GS_BR_VISIBLE_SYM, GS_YES,
  556.      0, &br);
  557.   V_text_off.x = (br.xRight+br.xLeft)/2;
  558.   V_text_off.y = (br.yTop+br.yBottom)/2;
  559.  
  560.   /*------------------------------------------------------------------*/
  561.   /* Bye                                                              */
  562.   /*------------------------------------------------------------------*/
  563.  
  564.   return (GS_OK);
  565. }
  566.  
  567. /**********************************************************************/
  568. /* V_Tick                                                             */
  569. /*                                                                    */
  570. /* Parameters:                                                        */
  571. /*   DHND     dhnd       (I):  diagram handle                         */
  572. /*   DATETIME *pNew_time (I):  pointer to structure with new time     */
  573. /*   DATETIME *pOld_time (I):  pointer to structure with old time     */
  574. /*                                                                    */
  575. /* Returns:                                                           */
  576. /*   GS_OK                                                            */
  577. /*                                                                    */
  578. /* Description:                                                       */
  579. /*   This is the function to dispaly the time for the venusian clock. */
  580. /*                                                                    */
  581. /*   Based upon the difference in time of the 'old' and the 'new'     */
  582. /*   time, the clock face, or parts of it are updated.                */
  583. /**********************************************************************/
  584.  
  585. SHORT V_Tick(DHND dhnd,DATETIME *pNew_time,DATETIME *pOld_time)
  586. {
  587.   double           ang;
  588.   double           s05,c05;
  589.   CHAR             text[4];
  590.   POINTL           pos;
  591.   RECTL            br;
  592.   POINTL           dim_base;
  593.   POINTL           dim_hour;
  594.   POINTL           dim_min;
  595.   POINTL           dim_sec;
  596.  
  597.   /*------------------------------------------------------------------*/
  598.   /* See if anything is to do                                         */
  599.   /*------------------------------------------------------------------*/
  600.  
  601.   if (pNew_time->seconds == pOld_time->seconds/*                      */
  602.      && pNew_time->minutes == pOld_time->minutes/*                    */
  603.      && pNew_time->hours == pOld_time->hours)
  604.     return (GS_OK);
  605.  
  606.   /*------------------------------------------------------------------*/
  607.   /* The time changed                                                 */
  608.   /*------------------------------------------------------------------*/
  609.  
  610.   SecondTick(DO_TICK);
  611.  
  612.   /*------------------------------------------------------------------*/
  613.   /* Get all the clock metrics                                        */
  614.   /*------------------------------------------------------------------*/
  615.  
  616.   GsGetSymBoundingRect(dhnd, V_base_shnd, GS_BR_VISIBLE_SYM, GS_YES, 0,
  617.      &br);
  618.   dim_base.x = br.xRight-br.xLeft;
  619.   dim_base.y = br.yTop-br.yBottom;
  620.   GsGetSymBoundingRect(dhnd, V_hour_shnd, GS_BR_VISIBLE_SYM, GS_YES, 0,
  621.      &br);
  622.   dim_hour.x = br.xRight-br.xLeft;
  623.   dim_hour.y = br.yTop-br.yBottom;
  624.   GsGetSymBoundingRect(dhnd, V_min_shnd, GS_BR_VISIBLE_SYM, GS_YES, 0,
  625.      &br);
  626.   dim_min.x = br.xRight-br.xLeft;
  627.   dim_min.y = br.yTop-br.yBottom;
  628.   GsGetSymBoundingRect(dhnd, V_sec_shnd, GS_BR_VISIBLE_SYM, GS_YES, 0,
  629.      &br);
  630.   dim_sec.x = br.xRight-br.xLeft;
  631.   dim_sec.y = br.yTop-br.yBottom;
  632.  
  633.   /*------------------------------------------------------------------*/
  634.   /* Adjust the hour dependent stuff                                  */
  635.   /*------------------------------------------------------------------*/
  636.  
  637.   if (pNew_time->hours != pOld_time->hours)
  638.   {
  639.  
  640.     /*----------------------------------------------------------------*/
  641.     /* Calc the new hour position                                     */
  642.     /*----------------------------------------------------------------*/
  643.  
  644.     ang = ((360/12)/(180/PI))*pNew_time->hours;
  645.     GsGetSymPosition(dhnd, V_base_shnd, &pos);
  646.     pos.x += (LONG)((dim_base.x-dim_hour.x)*sin(ang)*0.5);
  647.     pos.y += (LONG)((dim_base.y-dim_hour.y)*cos(ang)*0.5);
  648.     GsPutSymPosition(dhnd, V_hour_shnd, &pos);
  649.  
  650.     /*----------------------------------------------------------------*/
  651.     /* Put hour text                                                  */
  652.     /*----------------------------------------------------------------*/
  653.  
  654.     sprintf(text, "%2d", pNew_time->hours);
  655.     GsPutPartText(dhnd, V_hour_text_shnd, V_text_p0, text);
  656.  
  657.     /*----------------------------------------------------------------*/
  658.     /* Force decendants for update                                    */
  659.     /*----------------------------------------------------------------*/
  660.  
  661.     pOld_time->minutes = 0xff;
  662.   }
  663.  
  664.   /*------------------------------------------------------------------*/
  665.   /* Adjust the minute dependent stuff                                */
  666.   /*------------------------------------------------------------------*/
  667.  
  668.   if (pNew_time->minutes != pOld_time->minutes)
  669.   {
  670.  
  671.     /*----------------------------------------------------------------*/
  672.     /* Get minute hand angle                                          */
  673.     /*----------------------------------------------------------------*/
  674.  
  675.     ang = ((360/60)/(180/PI))*pNew_time->minutes;
  676.     s05 = sin(ang)*0.5;
  677.     c05 = cos(ang)*0.5;
  678.     GsGetSymPosition(dhnd, V_hour_shnd, &pos);
  679.     pos.x += (LONG)((dim_hour.x-dim_min.x)*s05);
  680.     pos.y += (LONG)((dim_hour.y-dim_min.y)*c05);
  681.     GsPutSymPosition(dhnd, V_min_shnd, &pos);
  682.  
  683.     /*----------------------------------------------------------------*/
  684.     /* Put minute text                                                */
  685.     /*----------------------------------------------------------------*/
  686.  
  687.     sprintf(text, "%2d", pNew_time->minutes);
  688.     GsPutPartText(dhnd, V_min_text_shnd, V_text_p0, text);
  689.  
  690.     /*----------------------------------------------------------------*/
  691.     /* Position 'hour' text field                                     */
  692.     /*----------------------------------------------------------------*/
  693.  
  694.     pos.x -= (LONG)((dim_hour.x)*s05)+V_text_off.x;
  695.     pos.y -= (LONG)((dim_hour.y)*c05)+V_text_off.y;
  696.     GsPutSymPosition(dhnd, V_hour_text_shnd, &pos);
  697.  
  698.     /*----------------------------------------------------------------*/
  699.     /* Force decendants for update                                    */
  700.     /*----------------------------------------------------------------*/
  701.  
  702.     pOld_time->seconds = 0xff;
  703.   }
  704.  
  705.   /*------------------------------------------------------------------*/
  706.   /* Adjust the second dependent stuff                                */
  707.   /*------------------------------------------------------------------*/
  708.  
  709.   if (pNew_time->seconds != pOld_time->seconds)
  710.   {
  711.  
  712.     /*----------------------------------------------------------------*/
  713.     /* Get second hand angle                                          */
  714.     /*----------------------------------------------------------------*/
  715.  
  716.     ang = ((360/60)/(180/PI))*pNew_time->seconds;
  717.     s05 = sin(ang)*0.5;
  718.     c05 = cos(ang)*0.5;
  719.     GsGetSymPosition(dhnd, V_min_shnd, &pos);
  720.     pos.x += (LONG)((dim_min.x-dim_sec.x)*s05);
  721.     pos.y += (LONG)((dim_min.y-dim_sec.y)*c05);
  722.     GsPutSymPosition(dhnd, V_sec_shnd, &pos);
  723.  
  724.     /*----------------------------------------------------------------*/
  725.     /* Position 'seconds' text field                                  */
  726.     /*----------------------------------------------------------------*/
  727.  
  728.     pos.x -= V_text_off.x;
  729.     pos.y -= V_text_off.y;
  730.     GsPutSymPosition(dhnd, V_sec_text_shnd, &pos);
  731.  
  732.     /*----------------------------------------------------------------*/
  733.     /* Put 'second' text                                              */
  734.     /*----------------------------------------------------------------*/
  735.  
  736.     sprintf(text, "%2d", pNew_time->seconds);
  737.     GsPutPartText(dhnd, V_sec_text_shnd, V_text_p0, text);
  738.  
  739.     /*----------------------------------------------------------------*/
  740.     /* Position 'minute' text field                                   */
  741.     /*----------------------------------------------------------------*/
  742.  
  743.     pos.x -= (LONG)((dim_min.x)*s05);
  744.     pos.y -= (LONG)((dim_min.y)*c05);
  745.     GsPutSymPosition(dhnd, V_min_text_shnd, &pos);
  746.   }
  747.  
  748.   /*------------------------------------------------------------------*/
  749.   /* Bye                                                              */
  750.   /*------------------------------------------------------------------*/
  751.  
  752.   return (GS_OK);
  753. }
  754.  
  755. ;
  756.