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

  1. //*********************************************************
  2. // Canvas - Nested Canvas Tabbing Example
  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 <icolor.hpp>
  10. #include <icoordsy.hpp>
  11. #include <ientryfd.hpp>
  12. #include <iframe.hpp>
  13. #include <imcelcv.hpp>
  14. #include <ipushbut.hpp>
  15. #include <isysmenu.hpp>
  16. #include <icconst.h>
  17.  
  18. void main ( )
  19. {
  20.   // Position windows relative to the bottom-left, like the
  21.   // OS/2 operating system does.
  22.   ICoordinateSystem::setApplicationOrientation
  23.     ( ICoordinateSystem::originLowerLeft );
  24.  
  25.   IFrameWindow
  26.     frame( "Canvas Tabbing" );
  27.   IMultiCellCanvas
  28.     client( IC_FRAME_CLIENT_ID, &frame, &frame );
  29.  
  30.   // Create child windows of the client canvas.
  31.   IEntryField
  32.     ef1( 1, &client, &client );
  33.   ef1
  34.    .setLimit( 24 )
  35.    .setText( "Has tab stop" )
  36.    .enableTabStop()
  37.    .enableGroup();
  38.  
  39.   IMultiCellCanvas
  40.     childCanvas( 0, &client, &client );
  41.   childCanvas
  42.    .setBackgroundColor( IColor::cyan );
  43.  
  44.   // Create child windows of the child canvas.
  45.   IEntryField
  46.     ef2( 2, &childCanvas, &childCanvas ),
  47.     ef3( 3, &childCanvas, &childCanvas );
  48.   ef2
  49.    .setLimit( 24 )
  50.    .setText( "Has tab stop" )
  51.    .enableTabStop()
  52.    .enableGroup();
  53.   ef3
  54.    .setLimit( 24 )
  55.    .setText( "Has tab stop" )
  56.    .enableTabStop()
  57.    .enableGroup();
  58.  
  59.   // Position the child windows of the child canvas.
  60.   ISize
  61.     cell( IMultiCellCanvas::defaultCell() );
  62.   unsigned long
  63.     defaultHeight = cell.height(),
  64.     defaultWidth = cell.width();
  65.   childCanvas
  66.    .addToCell( &ef2, 2, 2 )
  67.    .addToCell( &ef3, 2, 4 )
  68.    .setRowHeight( 3, defaultHeight * 2 )
  69.    .setRowHeight( 5, defaultHeight )
  70.    .setColumnWidth( 1, defaultWidth * 2 )
  71.    .setColumnWidth( 2, defaultWidth, true )
  72.    .setColumnWidth( 3, defaultWidth * 2 );
  73.  
  74.   // Create another child window of the client canvas.
  75.   IEntryField
  76.     ef4( 4, &client, &client );
  77.   ef4
  78.    .setLimit( 24 )
  79.    .setText( "Has tab stop" )
  80.    .enableTabStop()
  81.    .enableGroup();
  82.  
  83.   // Create a push button.
  84.   IPushButton
  85.     ok( ISystemMenu::idClose, &client, &client );
  86.   ok
  87.    .enableSystemCommand()  // For ISystemMenu::idClose.
  88.    .enableDefault()
  89.    .setText( "OK" )
  90.    .enableTabStop()
  91.    .enableGroup();
  92.  
  93.   // Position the child windows of the client canvas.
  94.   client
  95.    .addToCell( &ef1,         3, 2, 2 )
  96.    .addToCell( &childCanvas, 2, 4, 4 )
  97.    .addToCell( &ef4,         3, 6, 2 )
  98.    .addToCell( &ok,          3, 8 )
  99.    .setRowHeight( 1, defaultHeight * 3 / 2 )
  100.    .setRowHeight( 3, defaultHeight )
  101.    .setRowHeight( 5, defaultHeight )
  102.    .setRowHeight( 7, defaultHeight * 2 )
  103.    .setRowHeight( 9, defaultHeight * 3 / 2 )
  104.    .setColumnWidth( 2, defaultWidth * 2 )
  105.    .setColumnWidth( 3, 2 )
  106.    .setColumnWidth( 4, 5, true )
  107.    .setColumnWidth( 5, defaultWidth * 2 )
  108.    .setColumnWidth( 6, defaultWidth );
  109.  
  110.   // Size and show the window now.
  111.   frame
  112.    .setClient( &client )
  113.    .moveSizeToClient( IRectangle( IPoint( 100, 100 ),
  114.                                   client.minimumSize() ) )
  115.    .setFocus()
  116.    .show();
  117.  
  118.   IApplication::current().run();
  119. }
  120.