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

  1. /******************************************************************************
  2. * .FILE:         tbar1.hpp                                                    *
  3. *                                                                             *
  4. * .DESCRIPTION:  Tool Bar Example 1:  Class Header                            *
  5. *                                                                             *
  6. * .CLASSES:      FontSelectHandler                                            *
  7. *                ACommandHandler                                              *
  8. *                Editor                                                       *
  9. *                                                                             *
  10. * .COPYRIGHT:                                                                 *
  11. *    Licensed Material - Program-Property of IBM                              *
  12. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  13. *                                                                             *
  14. * .DISCLAIMER:                                                                *
  15. *   The following [enclosed] code is sample code created by IBM               *
  16. *   Corporation.  This sample code is not part of any standard IBM product    *
  17. *   and is provided to you solely for the purpose of assisting you in the     *
  18. *   development of your applications.  The code is provided 'AS IS',          *
  19. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  20. *   arising out of your use of the sample code, even if they have been        *
  21. *   advised of the possibility of such damages.                               *
  22. *                                                                             *
  23. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  24. *                                                                             *
  25. ******************************************************************************/
  26. #ifndef _TBAR1_
  27. #define _TBAR1_
  28. #include <ifont.hpp>
  29. #include <iframe.hpp>
  30. #include <itbar.hpp>
  31. #include <itbarbut.hpp>
  32. #include <imle.hpp>
  33. #include <icmdhdr.hpp>
  34. #include <imenubar.hpp>
  35. #include <iflytext.hpp>
  36. #include <istattxt.hpp>
  37. #include <iflyhhdr.hpp>
  38. #include <icombobx.hpp>
  39. #include <iselhdr.hpp>
  40. #include <ititle.hpp>
  41.  
  42. class Editor;
  43.  
  44. /******************************************************************************
  45. * Class  FontSelectHandler - Handles the selection of a font from the font    *
  46. *   font combo box on the tool bar.                                           *
  47. ******************************************************************************/
  48. class FontSelectHandler : public ISelectHandler
  49. {
  50. public:
  51. /*------------------------------- Constructor --------------------------------|
  52. | Constructs the object with:                                                 |
  53. | 1) A reference to the Editor (main window)                                  |
  54. -----------------------------------------------------------------------------*/
  55.   FontSelectHandler ( Editor& editor ) : editorFrame(editor) {}
  56.  
  57. protected:
  58. /*-----------------------------------------------------------------------------
  59. | enter - an overloaded function that process selections                      |
  60. -----------------------------------------------------------------------------*/
  61. virtual Boolean
  62.   enter ( IControlEvent& event );
  63.  
  64. private:
  65.   Editor
  66.    &editorFrame;
  67. };
  68.  
  69.  
  70. /******************************************************************************
  71. * Class ACommandHandler - Processes command events                            *
  72. ******************************************************************************/
  73. class ACommandHandler: public ICommandHandler {
  74. public:
  75. /*------------------------------- Constructor --------------------------------|
  76. | Constructs the object with:                                                 |
  77. | 1) Pointers to the mle, toolbar, and edit font.                             |
  78. -----------------------------------------------------------------------------*/
  79.   ACommandHandler ( IFont * f,IToolBar *t,IMultiLineEdit *m)
  80.      : editWindow(m)
  81.      , toolBar(t)
  82.      , editFont(f)
  83.      , under(0)
  84.      , bold(0)
  85.      , italic(0)
  86.      {}
  87. /*-----------------------------------------------------------------------------
  88. | command - an overloaded function that processes command events              |
  89. -----------------------------------------------------------------------------*/
  90.   Boolean
  91.     command ( ICommandEvent& event );
  92.  
  93. private:
  94.   IFont
  95.    *editFont;
  96.   IToolBar
  97.    *toolBar;
  98.   IMultiLineEdit
  99.    *editWindow;
  100.   int
  101.     bold,
  102.     italic,
  103.     under;
  104.  
  105. };
  106.  
  107. /******************************************************************************
  108. * Class Editor - Main window                                                  *
  109. ******************************************************************************/
  110. class Editor : public IFrameWindow
  111. {
  112. public:
  113. /*------------------------------- Constructor --------------------------------|
  114. | Constructs the object with:                                                 |
  115. | 1) No parameters                                                            |
  116. -----------------------------------------------------------------------------*/
  117.     Editor();
  118.  
  119. /*-----------------------------------------------------------------------------
  120. | editorWindow - returns a reference to the mle                               |
  121. | editorFont   - returns the current font of the editor                       |
  122. -----------------------------------------------------------------------------*/
  123.   IMultiLineEdit
  124.    &editorWindow ( ) { return editWindow; }
  125.  
  126.   IFont
  127.    &editorFont ( ) { return editFont; }
  128.  
  129. private:
  130.   ITitle
  131.     title;
  132.   IToolBar
  133.     toolBar;
  134.   IFlyText
  135.     flyText;
  136.   IStaticText
  137.     infoText;
  138.   IFlyOverHelpHandler
  139.     flyHelpHandler;
  140.   IMultiLineEdit
  141.     editWindow;
  142.   FontSelectHandler
  143.     fontSelectHandler;
  144.   IToolBarButton
  145.     cutButton,
  146.     copyButton,
  147.     pasteButton,
  148.     boldButton,
  149.     italicButton,
  150.     underscoreButton;
  151.   IComboBox
  152.     fontCombo;
  153.   IMenuBar
  154.     menu;
  155.   IFont
  156.     editFont;
  157.   ACommandHandler
  158.     commandhandler;
  159. };
  160.  
  161. #endif /* _TBAR1_ */
  162.