home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / hello6 / ahellow6.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  14.8 KB  |  320 lines

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