home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / canvas / mccombo / mccombo.cpp < prev   
Text File  |  1996-10-29  |  4KB  |  137 lines

  1. //*********************************************************
  2. // Canvas - IMultiCellCanvas with Combination Boxes
  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 <icombobx.hpp>
  10. #include <iframe.hpp>
  11. #include <imcelcv.hpp>
  12. #include <iradiobt.hpp>
  13. #include <istring.hpp>
  14. #include <icconst.h>
  15.  
  16. void main ( )
  17. {
  18.   IFrameWindow
  19.     frame( "Multicell Canvas with Combination Boxes" );
  20.   IMultiCellCanvas
  21.     client( IC_FRAME_CLIENT_ID, &frame, &frame );
  22.  
  23.   // Create a combination box without a drop-down list box that
  24.   // does not overlap any sibling windows.  Also create one with
  25.   // a drop-down list box that overlaps some radio buttons.
  26.   IComboBox
  27.     simpleCombo( 1, &client, &client ),
  28.     dropDownCombo( 2, &client, &client, IRectangle(),
  29.                    IComboBox::classDefaultStyle
  30.                     & ~IBaseComboBox::simpleType
  31.                     | IBaseComboBox::dropDownType );
  32.   simpleCombo
  33.    .enableTabStop();
  34.   dropDownCombo
  35.    .setMinimumRows( 8 )
  36.    .enableTabStop();
  37.  
  38.   // Fill the combination boxes with some items.
  39.   simpleCombo
  40.    .addAsFirst( "Simple-type combination box" );
  41.   simpleCombo
  42.    .addAsLast( "Second item" );
  43.   simpleCombo
  44.    .addAsLast( "Third item" );
  45.   simpleCombo
  46.    .setText( simpleCombo.itemText( 0 ) );
  47.   dropDownCombo
  48.    .addAsFirst( "Drop-down type combination box" );
  49.   dropDownCombo
  50.    .addAsLast( "Second item" );
  51.   dropDownCombo
  52.    .addAsLast( "Third item" );
  53.   dropDownCombo
  54.    .addAsLast( "Fourth item" );
  55.   dropDownCombo
  56.    .addAsLast( "Fifth item" );
  57.   dropDownCombo
  58.    .addAsLast( "Sixth item" );
  59.   dropDownCombo
  60.    .addAsLast( "Seventh item" );
  61.   dropDownCombo
  62.    .addAsLast( "Eighth item" );
  63.   dropDownCombo
  64.    .setText( dropDownCombo.itemText( 0 ) );
  65.  
  66.   // Create radio buttons below the drop-down combination box.
  67.   IRadioButton
  68.     left1( 3, &client, &client ),
  69.     left2( 4, &client, &client );
  70.   left1
  71.    .setText( "Button 1" )
  72.    .enableTabStop()
  73.    .enableGroup();
  74.   left2
  75.    .setText( "Button 2" );
  76.  
  77.   // Create radio buttons to the right of the combination boxes.
  78.   IRadioButton
  79.     right1( 5,  &client, &client ),
  80.     right2( 6,  &client, &client ),
  81.     right3( 7,  &client, &client ),
  82.     right4( 8,  &client, &client ),
  83.     right5( 9,  &client, &client ),
  84.     right6( 10, &client, &client );
  85.   right1
  86.    .setText( "Button A" )
  87.    .enableTabStop()
  88.    .enableGroup();
  89.   right2
  90.    .setText( "Button B" );
  91.   right3
  92.    .setText( "Button C" );
  93.   right4
  94.    .setText( "Button D" );
  95.   right5
  96.    .setText( "Button E" );
  97.   right6
  98.    .setText( "Button F" );
  99.  
  100.   // Position the child windows in the canvas.  Note that we place
  101.   // the drop-down combination box in a single row.  We control the
  102.   // height of its list box using its setMinimumRows function.
  103.   client
  104.    .addToCell( &simpleCombo,   2, 2, 1, 5 )
  105.    .addToCell( &dropDownCombo, 2, 8 )
  106.    .addToCell( &left1,         2, 10 )
  107.    .addToCell( &left2,         2, 12 )
  108.    .addToCell( &right1,        4, 2 )
  109.    .addToCell( &right2,        4, 4 )
  110.    .addToCell( &right3,        4, 6 )
  111.    .addToCell( &right4,        4, 8 )
  112.    .addToCell( &right5,        4, 10 )
  113.    .addToCell( &right6,        4, 12 );
  114.  
  115.   // Grow the canvas vertically between the radio buttons;
  116.   // grow the combination boxes horizontally.
  117.   client
  118.    .setRowHeight( 1,  10, true )
  119.    .setRowHeight( 3,  10, true )
  120.    .setRowHeight( 5,  10, true )
  121.    .setRowHeight( 7,  10, true )
  122.    .setRowHeight( 9,  10, true )
  123.    .setRowHeight( 11, 10, true )
  124.    .setRowHeight( 13, 10, true )
  125.    .setColumnWidth( 2, 10, true );
  126.  
  127.   // Size and show the window now.
  128.   frame
  129.    .setClient( &client )
  130.    .moveSizeToClient( IRectangle( IPoint( 100, 200 ),
  131.                                   client.minimumSize() ) )
  132.    .setFocus()
  133.    .show();
  134.  
  135.   IApplication::current().run();
  136. }
  137.