home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pwrgu2.zip / POWERGU2.EXE / CANVAS / MCSIMPLE / MCSIMPLE.CPP < prev    next >
Text File  |  1995-07-25  |  2KB  |  75 lines

  1. //************************************************************
  2. // Canvas Simple IMultiCellCanvas example.                    
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // All Rights Reserved.
  6. //************************************************************
  7. #include <icolor.hpp>
  8. #include <iframe.hpp>
  9. #include <iapp.hpp>
  10. #include <imcelcv.hpp>
  11. #include <ipushbut.hpp>
  12. #include <isysmenu.hpp>
  13. #include <icconst.h>
  14.  
  15. #define MARGIN         10
  16. #define BUTTON_PAD     15
  17. #define COLOR_OVERLAP  25
  18.  
  19. void main ( )
  20. {
  21.   IFrameWindow frame( "Multi-cell Canvas Example" );
  22.   IMultiCellCanvas client( IC_FRAME_CLIENT_ID, &frame, &frame );
  23.   frame.setClient( &client );
  24.  
  25.   // Create three color squares.
  26.   ICanvas
  27.     red  ( 1, &client, &client ),
  28.     green( 2, &client, &client ),
  29.     blue ( 3, &client, &client );
  30.   red.setColor  ( ICanvas::background, IColor::red );
  31.   green.setColor( ICanvas::background, IColor::green );
  32.   blue.setColor ( ICanvas::background, IColor::blue );
  33.  
  34.   // Create a push button.
  35.   IPushButton ok( ISystemMenu::idClose, &client, &client );
  36.   ok
  37.    .enableSystemCommand()    // For ISystemMenu::idClose.
  38.    .enableDefault()
  39.    .setText( "OK" )
  40.    .enableTabStop()
  41.    .enableGroup();
  42.  
  43.   // Position child windows in the canvas.
  44.   ISize defaultCell = IMultiCellCanvas::defaultCell();
  45.   client
  46.   .addToCell( &red,   2, 2, 3, 2 )
  47.   .addToCell( &green, 4, 3, 3, 2 )
  48.   .addToCell( &blue,  6, 2, 3, 2 )
  49.   .addToCell( &ok,    2, 6, 7 );
  50.  client
  51.   .setColumnWidth( 1, MARGIN )
  52.   .setColumnWidth( 2, COLOR_OVERLAP )
  53.   .setColumnWidth( 3, defaultCell.width(), true )
  54.   .setColumnWidth( 4, COLOR_OVERLAP )
  55.   .setColumnWidth( 5, defaultCell.width(), true )
  56.   .setColumnWidth( 6, COLOR_OVERLAP )
  57.   .setColumnWidth( 7, defaultCell.width(), true )
  58.   .setColumnWidth( 8, COLOR_OVERLAP )
  59.   .setColumnWidth( 9, MARGIN )
  60.   .setRowHeight( 1, MARGIN )
  61.   .setRowHeight( 2, defaultCell.height(), true )
  62.   .setRowHeight( 3, COLOR_OVERLAP )
  63.   .setRowHeight( 4, defaultCell.height(), true )
  64.   .setRowHeight( 5, BUTTON_PAD )
  65.   .setRowHeight( 7, MARGIN );
  66.  
  67.   // Size and show the window now.
  68.   frame
  69.    .moveSizeToClient( IRectangle( IPoint( 100, 100 ),
  70.                                   client.minimumSize() ))
  71.    .setFocus()
  72.    .show();
  73.   IApplication::current().run();
  74. }
  75.