home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / help / helpid / helpid.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  4.2 KB  |  159 lines

  1. #ifndef _HELPID_
  2. #define _HELPID_
  3. //************************************************************
  4. // Using Help - Runtime Setting of Help Panels               
  5. //                                                           
  6. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  7. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  8. // All Rights Reserved.                                      
  9. //************************************************************
  10. #include <ientryfd.hpp>
  11. #include <iframe.hpp>
  12. #include <imcelcv.hpp>
  13. #include <ipushbut.hpp>
  14. #include <iselhdr.hpp>
  15. #include <istattxt.hpp>
  16. #include <isysmenu.hpp>
  17. #include <ititle.hpp>
  18.  
  19. #include "helpid.h"
  20.  
  21. class ListBoxSelectHandler : public ISelectHandler {
  22. protected:
  23. virtual Boolean
  24.   enter ( IControlEvent& event );
  25. }; // ListBoxSelectHandler
  26.  
  27. class TestWindow : public IFrameWindow {
  28. public:
  29.   TestWindow ( unsigned long id,
  30.                IWindow*      parent = 0,
  31.                IWindow*      owner = 0 )
  32.     : IFrameWindow ( id, parent, owner ),
  33.       canvasClient( ID_CLIENT, this, this ),
  34.       prompt1 ( ID_DUMMY, &canvasClient, &canvasClient ),
  35.       prompt2 ( ID_DUMMY, &canvasClient, &canvasClient ),
  36.       entry1 ( ID_ENTRY1, &canvasClient, &canvasClient ),
  37.       entry2 ( ID_ENTRY2, &canvasClient, &canvasClient ),
  38.       helpButton ( ID_HELP_BUTTON, &canvasClient, &canvasClient )
  39.   {
  40.     prompt1
  41.      .setText( "Has contextual help" );
  42.     prompt2
  43.      .setText( "No contextual help" );
  44.     entry1
  45.      .enableTabStop()
  46.      .enableGroup();
  47.     entry2
  48.      .enableTabStop()
  49.      .enableGroup();
  50.     helpButton
  51.      .enableHelp()
  52.      .disableMouseClickFocus()
  53.      .setText( "Help" )
  54.      .enableTabStop()
  55.      .enableGroup();
  56.  
  57.     canvasClient
  58.      .addToCell( &prompt1,    2, 2 )
  59.      .addToCell( &prompt2,    2, 4 )
  60.      .addToCell( &entry1,     4, 2 )
  61.      .addToCell( &entry2,     4, 4 )
  62.      .addToCell( &helpButton, 2, 6, 3 );
  63.     canvasClient
  64.      .setColumnWidth( 5, 10 )
  65.      .setRowHeight( 7, 10 );
  66.  
  67.     (*this)
  68.      .moveSizeToClient( IRectangle( this->rect().minXMinY(),
  69.                                     ISize( canvasClient.minimumSize() ) ) )
  70.      .setFocus();
  71.   }
  72. protected:
  73. IMultiCellCanvas
  74.   canvasClient;
  75. IStaticText
  76.   prompt1,
  77.   prompt2;
  78. IEntryField
  79.   entry1,
  80.   entry2;
  81. IPushButton
  82.   helpButton;
  83. private:
  84.   TestWindow ( const TestWindow& );
  85. TestWindow
  86.  &operator=  ( const TestWindow& );
  87. }; // TestWindow
  88.  
  89. class PrimaryWindow : public TestWindow {
  90. public:
  91.   PrimaryWindow ( )
  92.     : TestWindow ( ID_PRIMARY2 ),
  93.       systemMenu ( this )
  94.   {
  95.     ITitle( this, "Another Primary Window" );
  96.  
  97.     // Assign contextual and general help.
  98.     ( *this )
  99.      .setHelpId( PANEL_PRIMARY2 );
  100.     entry1
  101.      .setHelpId( PANEL_ENTRY1_PRIMARY2 );
  102.     helpButton
  103.      .setHelpId( PANEL_HELP_BUTTON_PRIMARY2 );
  104.     systemMenu
  105.      .setItemHelpId( ID_CLOSE, PANEL_CLOSE );
  106.   }
  107. private:
  108.   PrimaryWindow ( const PrimaryWindow& );
  109. PrimaryWindow
  110.  &operator=     ( const PrimaryWindow& );
  111. ISystemMenu
  112.   systemMenu;
  113. }; // PrimaryWindow
  114.  
  115. class SecondaryWindow : public TestWindow {
  116. public:
  117.   SecondaryWindow ( unsigned long id,
  118.                     IWindow*      owner )
  119.     : TestWindow ( id, 0, owner ),
  120.       systemMenu ( this )
  121.   {
  122.     ITitle( this,
  123.             id == ID_SECONDARY_MODELESS ?
  124.                "Modeless Secondary Window" :
  125.                "Modal Secondary Window" );
  126.  
  127.     // Assign contextual and general help depending on the
  128.     // window type.
  129.     if ( id == ID_SECONDARY_MODELESS )
  130.     {
  131.        ( *this )
  132.         .setHelpId( PANEL_SEC_MODELESS );
  133.        entry1
  134.         .setHelpId( PANEL_ENTRY1_SEC_MODELESS );
  135.        helpButton
  136.         .setHelpId( PANEL_HELP_BUTTON_SEC_MODELESS );
  137.     }
  138.     else
  139.     {
  140.        ( *this )
  141.         .setHelpId( PANEL_SEC_MODAL );
  142.        entry1
  143.         .setHelpId( PANEL_ENTRY1_SEC_MODAL );
  144.        helpButton
  145.         .setHelpId( PANEL_HELP_BUTTON_SEC_MODAL );
  146.     }
  147.     systemMenu
  148.      .setItemHelpId( ID_CLOSE, PANEL_CLOSE );
  149.   }
  150. private:
  151.   SecondaryWindow ( const SecondaryWindow& );
  152. SecondaryWindow
  153.  &operator=       ( const SecondaryWindow& );
  154. ISystemMenu
  155.   systemMenu;
  156. }; // SecondaryWindow
  157.  
  158. #endif // _HELPID_
  159.