home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / spinbu.cpp < prev    next >
Text File  |  1994-12-18  |  3KB  |  108 lines

  1. #: 119416 S5/IBM C++Class
  2.     23-Nov-94  15:17:46
  3. Sb: Spin Button Docu
  4. Fm: HIROSHI TSUJI [IBM] 73232,2467
  5. To: Bob Meizlik 72074,3272
  6.  
  7. Bob:
  8.  
  9. Below is a simple example of a text and numeric spin button.
  10.  
  11. Hiroshi Tsuji  IBM User Interface Library development - - - - - - - - - - - -
  12. - - - - - - - - - - - - - - - - - - - - - -
  13.  // spinbt.cpp
  14.  #include <iapp.hpp>
  15.  #include <iframe.hpp>
  16.  #include <imcelcv.hpp>
  17.  #include <ispinbt.hpp>
  18.  #include <istattxt.hpp>
  19.  
  20.  void main ( )
  21.  {
  22.    // Create the frame and client windows.
  23.    IFrameWindow frame( "Simple Read-Only Spin Buttons" );
  24.    IMultiCellCanvas client( 0x8008, &frame, &frame );
  25.    frame.setClient( &client );
  26.  
  27.    // Create some prompt text.
  28.    IStaticText
  29.      prompt1( 1, &client, &client ),
  30.      prompt2( 2, &client, &client );
  31.    prompt1.setText( "Text spin button (hex 00 - 1F)" );
  32.    prompt2.setText( "Numeric spin button (0 - 31)" );
  33.  
  34.    // Create the spin buttons.
  35.    ISpinButton
  36.      textSpin   ( 3, &client, &client ),
  37.      numericSpin( 4, &client, &client );
  38.    textSpin
  39.     .setReadOnly()
  40.     .enableTabStop()
  41.     .enableGroup();
  42.    numericSpin
  43.     .setInputType( ISpinButton::numeric )
  44.     .setReadOnly()
  45.     .enableTabStop()
  46.     .enableGroup();
  47.  
  48.    // Fill the text spin button with 00-1F.
  49.    ISpinButton::Cursor cursor( textSpin );
  50.    cursor.setToFirst();
  51.    for( int i = 0; i <= 31; i++ )
  52.    {
  53.       textSpin.addAsLast( IString( i ).d2x(), cursor );
  54.       cursor.setToNext();
  55.    }
  56.    textSpin
  57.     .refreshText()
  58.     .setLimit( 2 );
  59.  
  60.    // Fill the numeric spin button with 0-31.
  61.    numericSpin
  62.     .setRange( IRange( 0, 31 ))
  63.     .setLimit( 2 );
  64.  
  65.    // Position the text and spin buttons in the canvas.
  66.    client
  67.     .addToCell( &prompt1,     2, 2 )
  68.     .addToCell( &textSpin,    2, 4 )
  69.     .addToCell( &prompt2,     4, 2 )
  70.     .addToCell( &numericSpin, 4, 4 );
  71.  
  72.    // Add margins and specify where to add white space.
  73.    unsigned long defaultHeight =
  74.      IMultiCellCanvas::defaultCell().height();
  75.    client
  76.     .setColumnWidth( 2, 1, true )
  77.     .setColumnWidth( 4, 1, true )
  78.     .setColumnWidth( 5, IMultiCellCanvas::defaultCell().width() )
  79.     .setRowHeight( 1, defaultHeight * 2, true )
  80.     .setRowHeight( 3, defaultHeight, true )
  81.     .setRowHeight( 5, defaultHeight * 2, true );
  82.  
  83.    // Show the window now.
  84.    frame
  85.     .moveSizeToClient( IRectangle( IPoint( 50, 50 ),
  86.                                    client.minimumSize() ))
  87.     .setFocus()
  88.     .show();
  89.    IApplication::current().run();
  90.  }
  91.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  92.  ## Make file for spin button example.
  93.  
  94.  CFLAGS = /Tdp /Gd+ /Ge+ /Gm+ /Wall+ext-gnr-got-por-ppt-uni-vft-
  95.  LFLAGS = /PM:PM /NOI
  96.  LIBS = dde4muii.lib dde4cci.lib
  97.  
  98.  ALL : spinbt.exe
  99.  
  100.  spinbt.exe : spinbt.obj
  101.     icc $(CFLAGS) /B"$(LFLAGS)" /Fe.\$*.exe $(LIBS) spinbt.obj
  102.  
  103.  {.}.cpp.obj:
  104.     icc $(CFLAGS) /C+ .\$*.cpp
  105.  
  106.  
  107.  
  108.