home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / canvas / cvsimple / cvsimple.cpp next >
Text File  |  1996-10-29  |  3KB  |  84 lines

  1. //*********************************************************
  2. // Canvas - Simple ICanvas 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 <icanvas.hpp>
  10. #include <icolor.hpp>
  11. #include <icoordsy.hpp>
  12. #include <iframe.hpp>
  13. #include <ipushbut.hpp>
  14. #include <isysmenu.hpp>
  15. #include <icconst.h>
  16.  
  17. #define MARGIN         15
  18. #define COLOR_SIZE     100
  19. #define COLOR_OVERLAP  25
  20. #define BUTTON_PAD     20
  21. #define BUTTON_HEIGHT  35
  22.  
  23. void main ( )
  24. {
  25.   // Position windows relative to the upper left as the
  26.   // Windows operating system does.
  27.   ICoordinateSystem::setApplicationOrientation
  28.     ( ICoordinateSystem::originUpperLeft );
  29.  
  30.   IFrameWindow
  31.     frame( "Base Canvas Example" );
  32.   ICanvas
  33.     client( IC_FRAME_CLIENT_ID, &frame, &frame );
  34.  
  35.   // Create three color squares using ICanvas objects,
  36.   // specifying their position and size.
  37.   ISize
  38.     colorSize( COLOR_SIZE, COLOR_SIZE );
  39.   ICanvas
  40.     red  ( 1, &client, &client,
  41.            IRectangle( IPoint( MARGIN, MARGIN ), colorSize ) ),
  42.     green( 2, &client, &client,
  43.            IRectangle( IPoint( MARGIN + COLOR_SIZE - COLOR_OVERLAP,
  44.                                MARGIN + COLOR_SIZE - COLOR_OVERLAP ),
  45.                        colorSize ) ),
  46.     blue ( 3, &client, &client,
  47.            IRectangle( IPoint( MARGIN + 2 * COLOR_SIZE
  48.                                       - 2 * COLOR_OVERLAP,
  49.                                MARGIN ),
  50.                        colorSize ) );
  51.   red
  52.    .setBackgroundColor( IColor::red );
  53.   green
  54.    .setBackgroundColor( IColor::green );
  55.   blue
  56.    .setBackgroundColor( IColor::blue );
  57.  
  58.   // Create a push button, specifying its postion and size.
  59.   IPushButton
  60.     ok( ISystemMenu::idClose, &client, &client,
  61.         IRectangle( IPoint( MARGIN,
  62.                             MARGIN + 2 * COLOR_SIZE
  63.                                    - COLOR_OVERLAP + BUTTON_PAD ),
  64.                     ISize( 3 * COLOR_SIZE - 2 * COLOR_OVERLAP,
  65.                            BUTTON_HEIGHT ) ) );
  66.   ok
  67.    .enableDefault()
  68.    .enableSystemCommand()  // For ISystemMenu::idClose.
  69.    .setText( "OK" )
  70.    .enableTabStop()
  71.    .enableGroup();
  72.  
  73.   // Size and show the window now.
  74.   ISize
  75.     clientSize( client.minimumSize() + ISize( MARGIN, MARGIN ) );
  76.   frame
  77.    .setClient( &client )
  78.    .moveSizeToClient( IRectangle( IPoint( 100, 100 ), clientSize ) )
  79.    .setFocus()
  80.    .show();
  81.  
  82.   IApplication::current().run();
  83. }
  84.