home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / help / helptbl / helptbl.cpp next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  3.9 KB  |  148 lines

  1. //***********************************************************
  2. // Using Help - Help Tables                                  
  3. //                                                           
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.                                      
  7. //***********************************************************
  8. #include <iapp.hpp>
  9. #include <icoordsy.hpp>
  10. #include <iframe.hpp>
  11. #include <ihelp.hpp>
  12. #include <ilistbox.hpp>
  13. #include <imcelcv.hpp>
  14. #include <imenubar.hpp>
  15. #include <istattxt.hpp>
  16.  
  17. #include "helptbl.hpp"
  18. #include "helptbl.h"
  19.  
  20. #ifdef IC_PM
  21.   #ifdef IPF_COMPATIBLE
  22.     #undef IPF_COMPATIBLE
  23.   #endif
  24. #endif
  25.  
  26. void main ( )
  27. {
  28.   ICoordinateSystem::setApplicationOrientation
  29.           ( ICoordinateSystem::originUpperLeft );
  30.  
  31.   // Create a primary window with a list box.
  32.   IFrameWindow
  33.     primary( "Help Table Example", ID_PRIMARY );
  34.   IMenuBar
  35.     menubar( &primary );
  36.   menubar
  37.    .setMenu( ID_MENUBAR );
  38.  
  39.   IMultiCellCanvas
  40.     client( ID_CLIENT, &primary, &primary );
  41.   IStaticText
  42.     heading( ID_DUMMY, &client, &client );
  43.   heading
  44.    .setText( "Select a type of window to create." );
  45.   IListBox
  46.     list( ID_LISTBOX, &client, &client );
  47.   list
  48.    .addAsLast( "Primary" );
  49.   list
  50.    .addAsLast( "Secondary (modeless)" );
  51.   list
  52.    .addAsLast( "Secondary (modal)" );
  53.   list
  54.    .select( 0 )
  55.    .enableTabStop()
  56.    .enableGroup();
  57.  
  58.   // Create handler that processes an "open" event.
  59.   ListBoxSelectHandler
  60.     selHandler;
  61.   selHandler
  62.    .handleEventsFor( &client );
  63.  
  64.   client
  65.    .addToCell( &heading, 2, 2 )
  66.    .addToCell( &list,    2, 4 );
  67.   client
  68.    .setColumnWidth( 2, 1, true )
  69.    .setColumnWidth( 3, IMultiCellCanvas::defaultCell().width() )
  70.    .setRowHeight( 4, 1, true )
  71.    .setRowHeight( 5, IMultiCellCanvas::defaultCell().height() );
  72.  
  73.   // Create the help window and associate it with the primary window.
  74.   IHelpWindow::Settings
  75.     settings;
  76.   settings
  77.    .setTitle( "Help Table Example - Help" )
  78.    .setLibraries( "HELPTBL.HLP" )
  79.    .setHelpTable( ID_HELPTABLE );
  80. #ifdef IPF_COMPATIBLE
  81.   IHelpWindow
  82.     help( settings, &primary,
  83.           IHelpWindow::classDefaultStyle
  84.            | IHelpWindow::ipfCompatible );
  85. #else
  86.   IHelpWindow
  87.     help( settings, &primary );
  88. #endif
  89.  
  90.   primary
  91.    .setClient( &client )
  92.    .setFocus()
  93.    .show();
  94.  
  95.   IApplication::current().run();
  96. }
  97.  
  98. IBase::Boolean
  99.   ListBoxSelectHandler::enter ( IControlEvent& event )
  100. {
  101.   Boolean
  102.     dontPassOn = false;
  103.   if ( event.controlId() == ID_LISTBOX )
  104.   {
  105.      long
  106.        selection = ((IListBox*)event.controlWindow())->selection();
  107.      switch ( selection )
  108.      {
  109.        case 0:     // Display another primary window.
  110.        {
  111.          PrimaryWindow
  112.           *frame = new PrimaryWindow;
  113.          frame->setAutoDeleteObject();
  114.          IHelpWindow
  115.           *help = IHelpWindow::helpWindow( event.dispatchingWindow() );
  116.          help->setAssociatedWindow( frame );
  117.          frame->show();
  118.          break;
  119.        }
  120.        case 1:     // Display a modeless secondary window.
  121.        {
  122.          SecondaryWindow
  123.           *frame = new SecondaryWindow( ID_SECONDARY_MODELESS,
  124.                                         event.dispatchingWindow() );
  125.          frame->setAutoDeleteObject();
  126.          IHelpWindow
  127.           *help = IHelpWindow::helpWindow( frame );
  128.          help->setAssociatedWindow( frame );
  129.          frame->show();
  130.          break;
  131.        }
  132.        case 2:     // Display a modal secondary window.
  133.        {
  134.          SecondaryWindow
  135.            frame( ID_SECONDARY_MODAL, event.dispatchingWindow() );
  136.          IHelpWindow
  137.           *help = IHelpWindow::helpWindow( &frame );
  138.          help->setAssociatedWindow( &frame );
  139.          frame.showModally();
  140.          break;
  141.        }
  142.      }
  143.      dontPassOn = true;
  144.   }
  145.  
  146.   return dontPassOn;
  147. }
  148.