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

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