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

  1. extern "C" {
  2.   #define INCL_WINDIALOGS
  3.   #define INCL_WINFRAMEMGR
  4.   #include <os2.h>
  5. }
  6.  
  7. #include <iframe.hpp>
  8. #include <icombobx.hpp>
  9. #include <ilistbox.hpp>
  10. #include <ipushbut.hpp>
  11. #include <istattxt.hpp>
  12. #include <ispinnum.hpp>
  13. #include <ientryfd.hpp>
  14. #include <islider.hpp>
  15. #include <icslider.hpp>
  16. #include <imle.hpp>
  17.  
  18. #include "driver.hpp"
  19. #include "driver.h"
  20.  
  21. /*------------------------------------------------------------------------------
  22. | main                                                                         |
  23. ------------------------------------------------------------------------------*/
  24. main()
  25. {
  26.   MyFrame myFrame;
  27.   IApplication::current().run();
  28. }
  29.  
  30.  
  31. /*------------------------------------------------------------------------------
  32. | MyFrame::MyFrame                                                             |
  33. ------------------------------------------------------------------------------*/
  34. MyFrame::MyFrame( )
  35.   : IFrameWindow( "Manipulating Dialogues in C++",
  36.                   ID_MYFRAME,
  37.                   IFrameWindow::defaultStyle() | IFrameWindow::shellPosition ),
  38.     clientCanvas( FID_CLIENT, this, this ),
  39.     createButton ( ID_CREATEBUTTON, &clientCanvas, &clientCanvas ),
  40.     quitButton ( DID_CANCEL, &clientCanvas, &clientCanvas ),
  41.     pSampleDlg( 0 ),
  42.     commandHandler( *this )
  43.  
  44. {
  45.   createButton
  46.     .setText( "Create Dialogue" )
  47.     .enableTabStop();
  48.  
  49.   quitButton
  50.     .setText( "Quit" )
  51.     .enableTabStop();
  52.  
  53.   commandHandler.handleEventsFor( this );
  54.  
  55.   setClient( &clientCanvas );
  56.   sizeTo( ISize( 100, 100) + clientCanvas.minimumSize( ) );
  57.   show();
  58.   setFocus();
  59. }
  60.  
  61.  
  62. /*------------------------------------------------------------------------------
  63. | MyFrame::~MyFrame                                                            |
  64. ------------------------------------------------------------------------------*/
  65. MyFrame:: ~MyFrame( )
  66. {
  67.   delete this->pSampleDlg;
  68. }
  69.  
  70.  
  71. /*------------------------------------------------------------------------------
  72. | MyFrame::dialog                                                              |
  73. ------------------------------------------------------------------------------*/
  74. SampleDialog* MyFrame:: dialog() const
  75. {
  76.   return( this->pSampleDlg );
  77. }
  78.  
  79. /*------------------------------------------------------------------------------
  80. | MyFrame::setDialog                                                           |
  81. ------------------------------------------------------------------------------*/
  82. MyFrame& MyFrame:: setDialog( SampleDialog* sampleDialog )
  83. {
  84.   this->pSampleDlg = sampleDialog;
  85.   return( *this );
  86. }
  87.  
  88.  
  89. /*------------------------------------------------------------------------------
  90. | SampleDialog::SampleDialog                                                   |
  91. ------------------------------------------------------------------------------*/
  92. SampleDialog :: SampleDialog( unsigned long ulWindowId, IWindow* pOwner )
  93.     : Dialog( ulWindowId, pOwner ),
  94.       commandHandler( *this ),
  95.       selectHandler( *this ),
  96.       sampleObserver( *this )
  97. {
  98.   createControlsFromTemplate( );
  99.  
  100.   commandHandler.handleEventsFor( this );
  101.   selectHandler.handleEventsFor( this );
  102. }
  103.  
  104.  
  105. /*------------------------------------------------------------------------------
  106. | SampleDialog::~SampleDialog                                                  |
  107. ------------------------------------------------------------------------------*/
  108. SampleDialog :: ~SampleDialog( )
  109. {
  110. }
  111.  
  112.  
  113. /*------------------------------------------------------------------------------
  114. | SampleDialog::comboBox                                                       |
  115. ------------------------------------------------------------------------------*/
  116. SampleDialog& SampleDialog :: comboBox( IComboBox* pComboBox )
  117. {
  118.   unsigned long i;
  119.  
  120.   for (i = 1; i < 11; i++)
  121.     pComboBox->addAsLast( "CB Item" + IString( i ) );
  122.  
  123.   pComboBox->select( 0 );
  124.   return( *this );
  125. }
  126.  
  127. /*------------------------------------------------------------------------------
  128. | SampleDialog::listBox                                                        |
  129. ------------------------------------------------------------------------------*/
  130. SampleDialog& SampleDialog :: listBox( IListBox* pListBox )
  131. {
  132.   unsigned long i;
  133.  
  134.   for (i = 1; i < 11; i++)
  135.     pListBox->addAsLast( "LB Item" + IString( i ) );
  136.  
  137.   pListBox->select( 0 );
  138.   return( *this );
  139. }
  140.  
  141. /*------------------------------------------------------------------------------
  142. | SampleDialog::pushButton                                                     |
  143. ------------------------------------------------------------------------------*/
  144. SampleDialog& SampleDialog :: pushButton( IPushButton* pPushButton )
  145. {
  146.   return( *this );
  147. }
  148.  
  149. /*------------------------------------------------------------------------------
  150. | SampleDialog::staticText                                                     |
  151. ------------------------------------------------------------------------------*/
  152. SampleDialog& SampleDialog :: staticText( IStaticText* pStaticText )
  153. {
  154.   return( *this );
  155. }
  156.  
  157. /*------------------------------------------------------------------------------
  158. | SampleDialog::numericSpinButton                                              |
  159. ------------------------------------------------------------------------------*/
  160. SampleDialog& SampleDialog ::
  161.               numericSpinButton( INumericSpinButton* pSpinButton )
  162. {
  163.   pSpinButton->setRange( IRange( 0, 50 ) );
  164.   return( *this );
  165. }
  166.  
  167. /*------------------------------------------------------------------------------
  168. | SampleDialog::entryField                                                     |
  169. ------------------------------------------------------------------------------*/
  170. SampleDialog& SampleDialog :: entryField( IEntryField* pEntryField )
  171. {
  172.   pEntryField->setText( IString( 25 ) );
  173.   return( *this );
  174. }
  175.  
  176. /*------------------------------------------------------------------------------
  177. | SampleDialog::progressIndicator                                              |
  178. ------------------------------------------------------------------------------*/
  179. SampleDialog& SampleDialog ::
  180.               progressIndicator( IProgressIndicator* pProgressIndicator )
  181. {
  182.   pProgressIndicator->moveArmToTick( 25 );
  183.   return( *this );
  184. }
  185.  
  186. /*------------------------------------------------------------------------------
  187. | SampleDialog::circularSlider                                                 |
  188. ------------------------------------------------------------------------------*/
  189. SampleDialog& SampleDialog :: circularSlider( ICircularSlider* pCircularSlider )
  190. {
  191.   pCircularSlider->setArmRange( IRange( 0, 50 ) )
  192.                   .setRotationIncrement( 5 )
  193.                   .setTickSpacing( 5 )
  194.                   .setValue( 25 )
  195.                   .enableNotification();
  196.  
  197.   sampleObserver.handleNotificationsFor( *pCircularSlider );
  198.  
  199.   return( *this );
  200. }
  201.  
  202. /*------------------------------------------------------------------------------
  203. | SampleDialog::mle                                                            |
  204. ------------------------------------------------------------------------------*/
  205. SampleDialog& SampleDialog :: mle( IMultiLineEdit* pMLE )
  206. {
  207.   return( *this );
  208. }
  209.  
  210.