home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / static / textclr / textclr.cpp < prev   
Text File  |  1996-10-29  |  2KB  |  68 lines

  1. //************************************************************
  2. // Static Controls - Static Text Color 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 <icolor.hpp>
  9. #include <iframe.hpp>
  10. #include <iapp.hpp>
  11. #include <istattxt.hpp>
  12. #include <icconst.h>
  13. #include <icoordsy.hpp>
  14.  
  15. void main ( )
  16. {
  17.   // Set the coordinate system to upper-left on all platforms.
  18.   ICoordinateSystem::setApplicationOrientation(
  19.        ICoordinateSystem::originUpperLeft);
  20.  
  21.   // Create the frame with a static text client.  
  22.   IFrameWindow frame( "Static Text Color Example" );
  23.   IStaticText client( IC_FRAME_CLIENT_ID, &frame, &frame );
  24.   frame.setClient( &client );
  25.   client.setFillColor( IColor::green );
  26.  
  27.   // Cyan block on the left.
  28.   IStaticText left( 1, &frame, &frame );
  29.   frame.addExtension( &left,
  30.                       IFrameWindow::leftOfClient, 100 );
  31.   left.setBackgroundColor( IColor::cyan );
  32.  
  33.   // Text on top.
  34.   IStaticText top( 2, &frame, &frame );
  35.   frame.addExtension( &top,
  36.                       IFrameWindow::aboveClient, 30 );
  37.   top.setFillColor( IColor::yellow )
  38.      .setForegroundColor( IColor::blue )
  39.      .setBackgroundColor( IColor::white );
  40.   top.setText( "This is blue on white text." )
  41.      .setAlignment( IStaticText::centerCenter );
  42.  
  43.   // Red horizontal separators.
  44.   ISize screen( IWindow::desktopWindow()->size() ),
  45.         separatorSize( screen.width(), 4 );
  46.   IStaticText thinSeparator( 3, &client, &client );
  47.   thinSeparator.setFillColor( IColor::red )
  48.                .moveSizeTo( IRectangle( IPoint( 0, 10 ),
  49.                                         separatorSize ));
  50.  
  51.   IStaticText medSeparator( 4, &client, &client );
  52.   separatorSize.scaleBy( 1, 2 );  // Double the thickness.
  53.   medSeparator.setFillColor( IColor::red )
  54.               .moveSizeTo( IRectangle( IPoint( 0, 50 ),
  55.                                        separatorSize ));
  56.  
  57.   IStaticText thickSeparator( 5, &client, &client );
  58.   separatorSize.scaleBy( 1, 3 );  // Now triple the thickness.
  59.   thickSeparator.setFillColor( IColor::red )
  60.                 .moveSizeTo( IRectangle( IPoint( 0, 110 ),
  61.                                          separatorSize ));
  62.  
  63.   // Size and show the window now.
  64.   frame.setFocus()
  65.        .show();
  66.   IApplication::current().run();
  67. }
  68.