home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / HELLO6 / AHELLOW6.HPP < prev    next >
C/C++ Source or Header  |  1995-04-07  |  23KB  |  297 lines

  1. #ifndef _AHELLOW6_
  2. #define _AHELLOW6_
  3. /*****************************************************************************
  4. * HELLO WORLD SAMPLE PROGRAM - Version 6: Class Header (ahellow6.hpp)        *
  5. *                                                                            *
  6. * COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1995. *
  7. *                                                                            *
  8. * DISCLAIMER OF WARRANTIES:                                                  *
  9. *   The following [enclosed] code is sample code created by IBM              *
  10. *   Corporation.  This sample code is not part of any standard IBM product   *
  11. *   and is provided to you solely for the purpose of assisting you in the    *
  12. *   development of your applications.  The code is provided "AS IS",         *
  13. *   without warranty of any kind.  IBM shall not be liable for any damages   *
  14. *   arising out of your use of the sample code, even if they have been       *
  15. *   advised of the possibility of such damages.                              *
  16. *****************************************************************************/
  17. //NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
  18.  
  19. #ifndef _IFRAME_                                                            //V2
  20.   #include <iframe.hpp>         //Include IFrameWindow class header           V2
  21. #endif                                                                      //V2
  22. #ifndef _ISTATTXT_                                                          //V2
  23.   #include <istattxt.hpp>       //Include IStaticText class header            V2
  24. #endif                                                                      //V2
  25. #ifndef _IINFOA_                                                            //V2
  26.   #include <iinfoa.hpp>         //Include IInfoArea class header              V2
  27. #endif                                                                      //V2
  28. #ifndef _IMENUBAR_                                                          //V3
  29.   #include <imenubar.hpp>       //Include IMenuBar class header               V3
  30. #endif                                                                      //V3
  31. #ifndef _ICMDHDR_                                                           //V3
  32.   #include <icmdhdr.hpp>        //Include ICommandHandler class header        V3
  33. #endif                                                                      //V3
  34. #ifndef _ISETCV_                                                            //V4
  35.   #include <isetcv.hpp>         //Include ISetCanvas class header             V4
  36. #endif                                                                      //V4
  37. #ifndef _IPUSHBUT_                                                          //V4
  38.   #include <ipushbut.hpp>       //Include IPushButton class header            V4
  39. #endif                                                                      //V4
  40. #ifndef _ISPLITCV_                                                          //V5
  41.   #include <isplitcv.hpp>       //Include ISplitCanvas class header           V5
  42. #endif                                                                      //V5
  43. #ifndef _ILISTBOX_                                                          //V5
  44.   #include <ilistbox.hpp>       //Include IListBox class header               V5
  45. #endif                                                                      //V5
  46. #ifndef _ISELHDR_                                                           //V5
  47.   #include <iselhdr.hpp>        //Include ISelectHandler class header         V5
  48. #endif                                                                      //V5
  49. #ifndef _IHELPHDR_                                                          //V5
  50.   #include <ihelphdr.hpp>       //Include IHelpHandler class header           V5
  51. #endif                                                                      //V5
  52. #ifndef _IHELP_                                                             //V5
  53.   #include <ihelp.hpp>          //Include IHelp class header                  V5
  54. #endif                                                                      //V5
  55. #ifndef _IPOPMENU_                                                          //V6
  56.   #include <ipopmenu.hpp>       //Include IPopUpMenu class header             V6
  57. #endif                                                                      //V6
  58. #ifndef _IMENUHDR_                                                          //V6
  59.   #include <imenuhdr.hpp>       //Include IMenuHandler class header           V6
  60. #endif                                                                      //V6
  61. #ifndef _AEARTHW6_                                                          //v6
  62.   #include "aearthw6.hpp"       //Include AEarthWindow class header           v6
  63. #endif                                                                      //V5
  64. #ifndef _ATIMEHDR_                                                          //V6
  65.   #include "atimehdr.hpp"       //Include ATimeHandler class header           V6
  66. #endif                                                                      //V6
  67. #ifndef _ANOTEBW6_                                                          //V6
  68.   #include "anotebw6.hpp"       //Include ANotebookWindow class header        V6
  69. #endif                                                                      //V6
  70.  
  71. //Forward declarations for other classes:
  72. class AHelloWindow;                                                         //V3
  73. class ANotebookWindow;                                                      //V6
  74.  
  75. /**************************************************************************   V3
  76. * Class:   ACommandHandler                                                *   V3
  77. *                                                                         *   V3
  78. * Purpose: New Command Handler class that handles commands                *   V3
  79. *          specifically for AHelloWindow class windows.                   *   V3
  80. *                                                                         *   V3
  81. **************************************************************************/ //V3
  82. class ACommandHandler : public ICommandHandler {                            //V3
  83. public:                                                                     //V3
  84.   ACommandHandler(AHelloWindow *helloFrame);                                //V3
  85. virtual ~ACommandHandler() { }                                              //V3
  86.  
  87. protected:                                                                  //V3
  88. /*------------------------ Override Command Function ---------------------|   V3
  89. | The command function is called to handle application command events.    |   V3
  90. |------------------------------------------------------------------------*/ //V3
  91. virtual Boolean                                                             //V3
  92.   command(ICommandEvent& cmdEvent);                                         //V3
  93.  
  94. private:                                                                    //V3
  95.   AHelloWindow *frame;                                                      //V3
  96. };                                                                          //V3
  97.  
  98. /**************************************************************************   V5
  99. * Class:   ASelectHandler                                                 *   V5
  100. *                                                                         *   V5
  101. * Purpose: New Select Handler class that handles list box selections      *   V5
  102. *          specifically for AHelloWindow class windows.                   *   V5
  103. *                                                                         *   V5
  104. **************************************************************************/ //V5
  105. class ASelectHandler : public ISelectHandler {                              //V5
  106.  
  107. public:                                                                     //V5
  108.   ASelectHandler(AHelloWindow *helloFrame);                                 //V5
  109. virtual ~ASelectHandler() { }                                               //V5
  110.  
  111. protected:                                                                  //V5
  112. /*------------------------ Override Selected Function --------------------|   V5
  113. | The selected() function is called to handle list box selection events.  |   V5
  114. |------------------------------------------------------------------------*/ //V5
  115. virtual Boolean                                                             //V5
  116.   selected(IControlEvent& ctlEvent);                                        //V5
  117.  
  118. private:                                                                    //V5
  119.   AHelloWindow *frame;                                                      //V5
  120. };
  121.  
  122. /**************************************************************************   V5
  123. * Class:   AHelpHandler                                                   *   V5
  124. *                                                                         *   V5
  125. * Purpose: New Help Handler class that only overrides one                 *   V5
  126. *          IHelpHandler function, keysHelpId().  If keysHelpId()          *   V5
  127. *          is not overridden, then the default action sets the event      *   V5
  128. *          result to zero, which indicates that no action is required,    *   V5
  129. *          that is, no help information for keys is displayed.            *   V5
  130. **************************************************************************/ //V5
  131. class AHelpHandler : public IHelpHandler {                                  //V5
  132. public:                                                                     //V5
  133. virtual ~AHelpHandler() { }                                                 //V5
  134. protected:                                                                  //V5
  135. /*----------------------- Override keysHelpId Function -------------------|   V5
  136. | The keysHelpId() function is called to set the event result to the      |   V5
  137. |   ID within the Hello World help libraries for Keys Help.               |   V5
  138. |------------------------------------------------------------------------*/ //V5
  139. virtual Boolean                                                             //V5
  140.      keysHelpId(IEvent& evt);                                               //V5
  141. };
  142.  
  143. /**************************************************************************   V6
  144. * Class:   APopUpHandler                                                  *   V6
  145. *                                                                         *   V6
  146. * Purpose: New Menu Handler class that handles makePopUpMenu requests     *   V6
  147. *          specifically for AHelloWindow class windows.                   *   V6
  148. *                                                                         *   V6
  149. **************************************************************************/ //V6
  150. class APopUpHandler : public IMenuHandler {                                 //V6
  151. protected:                                                                  //V6
  152. /*------------------- Override MakePopUpMenu Function --------------------|   V6
  153. | The makePopUpMenu function is called to process requests for showing    |   V6
  154. |   pop-up menus for windows attached to this handler.                    |   V6
  155. |------------------------------------------------------------------------*/ //V6
  156. virtual Boolean                                                             //V6
  157.   makePopUpMenu(IMenuEvent& menuEvent);                                     //V6
  158. };                                                                          //V6
  159.  
  160. /**************************************************************************   V6
  161. * Class:   AHelloTimeHandler                                              *   V6
  162. *                                                                         *   V6
  163. * Purpose: New Time Handler class that processes timer ticks specifically *   V6
  164. *          for AHelloWindow class windows.  It is derived from the        *   V6
  165. *          ATimeHandler class, which is derived from IHandler class.      *   V6
  166. *                                                                         *   V6
  167. **************************************************************************/ //V6
  168. class AHelloTimeHandler : public ATimeHandler {                             //V6
  169. protected:                                                                  //V6
  170. /*------------------------ Override Tick Function ------------------------|   V6
  171. | The tick function is called each time a timer event occurs.             |   V6
  172. |------------------------------------------------------------------------*/ //V6
  173. virtual IBase::Boolean                                                      //V6
  174.   tick(IEvent& evt);                                                        //V6
  175. };                                                                          //V6
  176.  
  177. /**************************************************************************   V2
  178. * Class:   AHelloWindow                                                   *   V2
  179. *                                                                         *   V2
  180. * Purpose: Main Window class for C++ Hello World sample application.      *   V2
  181. *          It is derived from IFrameWindow class.                         *   V2
  182. *                                                                         *   V2
  183. **************************************************************************/ //V2
  184. class AHelloWindow : public IFrameWindow                                    //V2
  185. {                                                                           //V2
  186. public:                                                                     //V2
  187.     AHelloWindow(unsigned long windowId);                                   //V2
  188. virtual ~AHelloWindow();                    //Destructor for this class       v3
  189.  
  190. /*------------------------ Hello Text Alignment --------------------------|   V3
  191. | The following enumeration type is used to specify the alignment of      |   V3
  192. | text in the hello static text window.                                   |   V3
  193. |------------------------------------------------------------------------*/ //V3
  194.     enum Alignment                                                          //V3
  195.       {                                                                     //V3
  196.       left, center, right                                                   //V3
  197.       };                                                                    //V3
  198. /*---------------------- Hello Static Text Functions ---------------------|   V3
  199. | These functions are used to change the hello static text window.        |   V3
  200. |   setAlignment - Align the static text horizontally.  The text is       |   V3
  201. |           always centered vertically by design.                         |   V3
  202. |   editText - Use a modal dialog window to edit the text in the static   |   V4
  203. |           text window.                                                  |   V4
  204. |   setTextFromListBox -  Set the text to the first selected item in the  |   V5
  205. |           list box.                                                     |   V5
  206. │   setHelloFont - Use a modal font dialog window to change the font of   |   V6
  207. |           static text.                                                  |   V6
  208. |------------------------------------------------------------------------*/ //V3
  209. virtual AHelloWindow                                                        //V3
  210.    &setAlignment(Alignment alignment),                                      //V3
  211.    &editText(),                                                             //V4
  212.    &setTextFromListBox(),                                                   //V5
  213.    &setHelloFont();                                                         //V6
  214. /*----------------------- Hello Settings Functions -----------------------|   V6
  215. | These functions are used to manage attributes of the hello and          |   V6
  216. | earthWindow static text windows.                                        |   V6
  217. |   readHelloSettings - Read saved settings from an IProfile file.  A     |   V6
  218. |           message box displays the success or failure of the read       |   V6
  219. |           operation.                                                    |   V6
  220. |   openHelloSettings - Open a non-modal frame window containing a        |   V6
  221. |           notebook window with multiple controls for changing           |   V6
  222. |           settings in AHelloWindow.                                     |   V6
  223. |   saveHelloSettings - Save current AHelloWindow settings in an IProfile |   V6
  224. |           file.  A message box displays the success or failure of the   |   V6
  225. |           save operation.                                               |   V6
  226. |   earth - Provide non-AHelloWindow functions with access to the         |   V6
  227. |           AEarthWindow settings functions by returning a pointer to     |   V6
  228. |           the earthWindow object contained in AHelloWindow.             |   V6
  229. |------------------------------------------------------------------------*/ //V6
  230. virtual AHelloWindow                                                        //V6
  231.    &readHelloSettings(),                                                    //V6
  232.    &openHelloSettings(),                                                    //V6
  233.    &saveHelloSettings();                                                    //V6
  234. AEarthWindow                                                                //V6
  235.    *earth();                                                                //V6
  236. /*-------------------- Hello Date and Time Functions ---------------------|   V6
  237. | These functions are used to manage the date and time static text        |   V6
  238. | windows in AHelloWindow.                                                |   V6
  239. |   tickTime - Update date and time windows if the current values are     |   V6
  240. |           different than what is displayed.  This is the function that  |   V6
  241. |           the AHelloTimeHandler::tick calls each time a timer event isu |   V6
  242. |           processed.                                                    |   V6
  243. |   enableDateLong - Change the format of the date to long,               |   V6
  244. |           for example, August 10, 1994.                                 |   V6
  245. |   disableDateLong - Change the format of the date to short,             |   V6
  246. |           for example, 08/10/94 (depending on locale).                  |   V6
  247. |   enableTimeLong - Change the format of the time to long,               |   V6
  248. |           for example, 01:57:59.                                        |   V6
  249. |   disableTimeLong - Change the format of the time to short,             |   V6
  250. |           for example, 13:57.                                           |   V6
  251. |   isDateLong - Return true is date format is long.                      |   V6
  252. |   isTimeLong - Return true is time format is long.                      |   V6
  253. |------------------------------------------------------------------------*/ //V6
  254. virtual AHelloWindow                                                        //V6
  255.    &tickTime(),                                                             //V6
  256.    &enableDateLong(IBase::Boolean makingLong=true),                         //V6
  257.    &disableDateLong(),                                                      //V6
  258.    &enableTimeLong(IBase::Boolean makingLong=true),                         //V6
  259.    &disableTimeLong();                                                      //V6
  260. const Boolean                                                               //V6
  261.    isDateLong(),                                                            //V6
  262.    isTimeLong();                                                            //V6
  263.  
  264.   private:                                                                  //V2
  265.     IMenuBar      menuBar;                                                  //V3
  266.     ISplitCanvas  statusCanvas;                                             //V3
  267.     IStaticText   statusLine;                                               //V3
  268.     IStaticText   statusDate;                                               //V3
  269.     IStaticText   statusTime;                                               //V3
  270.     ISplitCanvas  clientWindow;                                             //V5
  271.     ISplitCanvas  helloCanvas;                                              //V5
  272.     IStaticText   hello;                                                    //V2
  273.     AEarthWindow  earthWindow;                                              //V5
  274.     IListBox      listBox;                                                  //V5
  275.     ISetCanvas    buttons;                                                  //V4
  276.     IPushButton   leftButton;                                               //V4
  277.     IPushButton   centerButton;                                             //V4
  278.     IPushButton   rightButton;                                              //V4
  279.     IPushButton   helpButton;                                               //V5
  280.     IInfoArea     infoArea;                                                 //V2
  281.     ACommandHandler commandHandler;                                         //V3
  282.     ASelectHandler selectHandler;                                           //V5
  283.     AHelpHandler  helpHandler;                                              //V5
  284.     IHelpWindow   helpWindow;                                               //V5
  285.     AHelloTimeHandler timeHandler;                                          //V6
  286.     APopUpHandler popUpHandler;                                             //V6
  287.     ANotebookWindow *settingsNotebook;                                      //V6
  288.     Boolean       dateLong;                                                 //V6
  289.     Boolean       timeLong;                                                 //V6
  290.     IPopUpMenu    helloPopUpMenu;                                           //V6
  291.  
  292.     AHelloWindow(const AHelloWindow&);  //Default copy constructor            V2
  293. AHelloWindow                                                                //V2
  294.     &operator=(const AHelloWindow&);    //Default assignment operator         V2
  295. };                                                                          //V2
  296. #endif                                                                      //V2
  297.