home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dlgcpp.zip / drivhdr.cpp < prev    next >
Text File  |  1995-08-30  |  7KB  |  210 lines

  1. extern "C" {
  2.   #define INCL_WINDIALOGS
  3.   #include <os2.h>
  4. }
  5.  
  6. #include <iframe.hpp>
  7. #include <icombobx.hpp>
  8. #include <ilistbox.hpp>
  9. #include <ipushbut.hpp>
  10. #include <istattxt.hpp>
  11. #include <ispinnum.hpp>
  12. #include <ientryfd.hpp>
  13. #include <islider.hpp>
  14. #include <icslider.hpp>
  15. #include <imle.hpp>
  16.  
  17. #include "driver.hpp"
  18. #include "driver.h"
  19.  
  20.  
  21. /*------------------------------------------------------------------------------
  22. | SampleCommandHandler::SampleCommandHandler                                   |
  23. ------------------------------------------------------------------------------*/
  24. SampleCommandHandler :: SampleCommandHandler( SampleDialog& dialogue )
  25.     : ICommandHandler( ),
  26.       sampleDialog( dialogue )
  27. {
  28. }
  29.  
  30. /*------------------------------------------------------------------------------
  31. | SampleCommandHandler::~SampleCommandHandler                                  |
  32. ------------------------------------------------------------------------------*/
  33. SampleCommandHandler :: ~SampleCommandHandler( )
  34. {
  35. }
  36.  
  37. /*------------------------------------------------------------------------------
  38. | SampleCommandHandler::command                                                |
  39. ------------------------------------------------------------------------------*/
  40. Boolean SampleCommandHandler :: command( ICommandEvent& cmdevt )
  41. {
  42.  
  43.   switch ( cmdevt.commandId( ) )
  44.   {
  45.     case DID_CANCEL:
  46.       sampleDialog.dismiss( DID_CANCEL );
  47.       break;
  48.  
  49.     case PB_QUERY:
  50.       {
  51.         IMultiLineEdit
  52.           *pMLE = sampleDialog.mleWithId( MLE_TEST );
  53.  
  54.         pMLE->addLineAsLast( "*************** Query Results ***************" );
  55.  
  56.         // Simple combobox, so just grab entryfield text ...
  57.         pMLE->addLineAsLast( IString( "Combo box selected item = " +
  58.                              sampleDialog.comboBoxWithId( CB_TEST )->text() ) );
  59.  
  60.         // Display list box selected item
  61.         IListBox
  62.           *pListBox = sampleDialog.listBoxWithId( LB_TEST );
  63.         pMLE->addLineAsLast( IString( "List box selected item = " +
  64.                              pListBox->itemText( pListBox->selection() ) ) );
  65.  
  66.         // Display numeric spin button value
  67.         IString
  68.           strValue( sampleDialog.numericSpinButtonWithId( SPB_TEST )->value() );
  69.         pMLE->addLineAsLast( IString( "Numeric spin button value = " +
  70.                              strValue ) );
  71.  
  72.       }
  73.       return( true );      // Finished processing event
  74.  
  75.   }
  76.                            // Allow other handlers or default window procedure
  77.   return( false );         // to process the event
  78. }
  79.  
  80.  
  81. /*------------------------------------------------------------------------------
  82. | SampleSelectHandler::SampleSelectHandler                                     |
  83. ------------------------------------------------------------------------------*/
  84. SampleSelectHandler :: SampleSelectHandler( SampleDialog& dialogue )
  85.     : ISelectHandler( ),
  86.       sampleDialog( dialogue )
  87. {
  88. }
  89.  
  90. /*------------------------------------------------------------------------------
  91. | SampleSelectHandler::~SampleSelectHandler                                    |
  92. ------------------------------------------------------------------------------*/
  93. SampleSelectHandler :: ~SampleSelectHandler( )
  94. {
  95. }
  96.  
  97. /*------------------------------------------------------------------------------
  98. | SampleSelectHandler::selected                                                |
  99. ------------------------------------------------------------------------------*/
  100. Boolean SampleSelectHandler :: selected( IControlEvent& ctlevt )
  101. {
  102.   if ( ctlevt.controlId() == LB_TEST )
  103.   {
  104.     IStaticText
  105.       *pStaticText = sampleDialog.staticTextWithId( ST_TEXT );
  106.  
  107.     IListBox
  108.       *pListBox = sampleDialog.listBoxWithId( LB_TEST );
  109.         pStaticText->setText( pListBox->itemText( pListBox->selection() ) );
  110.  
  111.     return( true );        // Finished processing event
  112.   }
  113.                            // Allow other handlers or default window procedure
  114.   return( false );         // to process the event
  115. }
  116.  
  117.  
  118. /*------------------------------------------------------------------------------
  119. | SampleObserver::SampleObserver                                               |
  120. ------------------------------------------------------------------------------*/
  121. SampleObserver :: SampleObserver( SampleDialog& dialogue )
  122.     : IObserver( ),
  123.       sampleDialog( dialogue )
  124. {
  125.   IObserver *x = this;
  126. }
  127.  
  128. /*------------------------------------------------------------------------------
  129. | SampleObserver::~SampleObserver                                              |
  130. ------------------------------------------------------------------------------*/
  131. SampleObserver :: ~SampleObserver( )
  132. {
  133. }
  134.  
  135. /*------------------------------------------------------------------------------
  136. | SampleObserver::dispatchNotificationEvent                                    |
  137. ------------------------------------------------------------------------------*/
  138. SampleObserver& SampleObserver ::
  139.                 dispatchNotificationEvent  ( const INotificationEvent& event )
  140. {
  141.   if ( event.notificationId() == ICircularSlider::valueId )
  142.   {
  143.     IEntryField
  144.       *pEntryField = sampleDialog.entryFieldWithId( EF_TEST );
  145.  
  146.     IProgressIndicator
  147.       *pProgressIndicator = sampleDialog.progressIndicatorWithId( SLD_TEST );
  148.  
  149.     unsigned long
  150.       ulValue = event.eventData().asUnsignedLong();
  151.     pEntryField->setText( IString( ulValue ) );
  152.     pProgressIndicator->moveArmToTick( ulValue );
  153.   }
  154.  
  155.   return( *this );
  156. }
  157.  
  158.  
  159. /*------------------------------------------------------------------------------
  160. | MyFrameCommandHandler::MyFrameCommandHandler                                 |
  161. ------------------------------------------------------------------------------*/
  162. MyFrameCommandHandler :: MyFrameCommandHandler( MyFrame& aFrame )
  163.     : ICommandHandler( ),
  164.       myFrame( aFrame )
  165. {
  166. }
  167.  
  168. /*------------------------------------------------------------------------------
  169. | MyFrameCommandHandler::~MyFrameCommandHandler                                |
  170. ------------------------------------------------------------------------------*/
  171. MyFrameCommandHandler :: ~MyFrameCommandHandler( )
  172. {
  173. }
  174.  
  175. /*------------------------------------------------------------------------------
  176. | MyFrameCommandHandler::command                                               |
  177. ------------------------------------------------------------------------------*/
  178. Boolean MyFrameCommandHandler :: command( ICommandEvent& cmdevt )
  179. {
  180.  
  181.   switch ( cmdevt.commandId( ) )
  182.   {
  183.     case DID_CANCEL:
  184.       myFrame.close();
  185.       break;
  186.  
  187.     case ID_CREATEBUTTON:
  188.       {
  189.         SampleDialog
  190.          *pSampleDialog = myFrame.dialog();
  191.  
  192.         if ( pSampleDialog )
  193.         {
  194.           pSampleDialog->show();
  195.           pSampleDialog->setFocus();
  196.         }
  197.         else
  198.         {
  199.           pSampleDialog = new SampleDialog( DLG_SAMPLEDIALOGUE, &myFrame );
  200.           myFrame.setDialog( pSampleDialog );
  201.         }
  202.       }
  203.       return( true );      // Finished processing event
  204.  
  205.   }
  206.                            // Allow other handlers or default window procedure
  207.   return( false );         // to process the event
  208. }
  209.  
  210.