home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / canvas / setpack / packcv.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  5.9 KB  |  208 lines

  1. //*********************************************************
  2. // Canvas - ISetCanvas Pack Options
  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 "packcv.hpp"
  9. #include <icconst.h>
  10. #include "packcv.h"
  11.  
  12. PackCanvas::PackCanvas ( unsigned long id,
  13.                          IWindow* parentAndOwner,
  14.                          ISetCanvas::PackType pack )
  15.   : ISetCanvas( id, parentAndOwner, parentAndOwner ),
  16.     first(  1, this, this),
  17.     second( 2, this, this),
  18.     third(  3, this, this),
  19.     fourth( 4, this, this),
  20.     fifth(  5, this, this),
  21.     sixth(  6, this, this)
  22. {
  23.   (*this)
  24.    .setPackType( pack )
  25.    .setDeckCount( 2 );
  26.   switch ( pack )
  27.   {
  28.     case ISetCanvas::tight:
  29.        this->setText( "Pack tight" );
  30.        break;
  31.     case ISetCanvas::even:
  32.        this->setText( "Pack even" );
  33.        break;
  34.     case ISetCanvas::expanded:
  35.     default:
  36.        this->setText( "Pack expanded" );
  37.        break;
  38.   }
  39.   first
  40.    .setMinimumSize( ISize( 30, 25 ) );
  41.   second
  42.    .setMinimumSize( ISize( 15, 40 ) );
  43.   third
  44.    .setMinimumSize( ISize( 35, 65 ) );
  45.   fourth
  46.    .setMinimumSize( ISize( 40, 35 ) );
  47.   fifth
  48.    .setMinimumSize( ISize( 30, 20 ) );
  49.   sixth
  50.    .setMinimumSize( ISize( 20, 60 ) );
  51. }
  52.  
  53. PackAlignTest::PackAlignTest ( )
  54.   : IFrameWindow( "ISetCanvas Pack Options" ),
  55.     packClient( IC_FRAME_CLIENT_ID, this, this ),
  56.     tight( 1, &packClient, ISetCanvas::tight ),
  57.     even( 2, &packClient, ISetCanvas::even ),
  58.     expanded( 3, &packClient, ISetCanvas::expanded ),
  59.     cmdHdr( this ),
  60.     toolBar( 0, this ),
  61.     topLeft( ID_TOP_LEFT, &toolBar, &toolBar,
  62.              IRectangle(),
  63.              IToolBarButton::classDefaultStyle
  64.               | IToolBarButton::autoLatch ),
  65.     topCenter( ID_TOP_CENTER, &toolBar, &toolBar,
  66.                IRectangle(),
  67.                IToolBarButton::classDefaultStyle
  68.                 | IToolBarButton::autoLatch ),
  69.     topRight( ID_TOP_RIGHT, &toolBar, &toolBar,
  70.               IRectangle(),
  71.               IToolBarButton::classDefaultStyle
  72.                | IToolBarButton::autoLatch ),
  73.     centerLeft( ID_CENTER_LEFT, &toolBar, &toolBar,
  74.                 IRectangle(),
  75.                 IToolBarButton::classDefaultStyle
  76.                  | IToolBarButton::autoLatch ),
  77.     centerCenter( ID_CENTER_CENTER, &toolBar, &toolBar,
  78.                   IRectangle(),
  79.                   IToolBarButton::classDefaultStyle
  80.                    | IToolBarButton::autoLatch ),
  81.     centerRight( ID_CENTER_RIGHT, &toolBar, &toolBar,
  82.                  IRectangle(),
  83.                  IToolBarButton::classDefaultStyle
  84.                   | IToolBarButton::autoLatch ),
  85.     bottomLeft( ID_BOTTOM_LEFT, &toolBar, &toolBar,
  86.                 IRectangle(),
  87.                 IToolBarButton::classDefaultStyle
  88.                  | IToolBarButton::autoLatch ),
  89.     bottomCenter( ID_BOTTOM_CENTER, &toolBar, &toolBar,
  90.                   IRectangle(),
  91.                   IToolBarButton::classDefaultStyle
  92.                    | IToolBarButton::autoLatch ),
  93.     bottomRight( ID_BOTTOM_RIGHT, &toolBar, &toolBar,
  94.                  IRectangle(),
  95.                  IToolBarButton::classDefaultStyle
  96.                   | IToolBarButton::autoLatch )
  97. {
  98.   packClient
  99.    .setDeckOrientation( ISetCanvas::horizontal );
  100.   cmdHdr
  101.    .handleEventsFor( this );
  102.  
  103.   // Set up the tool bar.
  104.   toolBar
  105.    .addAsFirst( &topLeft, true )
  106.    .addAsLast( &topCenter )
  107.    .addAsLast( &topRight )
  108.    .addAsLast( ¢erLeft )
  109.    .addAsLast( ¢erCenter )
  110.    .addAsLast( ¢erRight )
  111.    .addAsLast( &bottomLeft )
  112.    .addAsLast( &bottomCenter )
  113.    .addAsLast( &bottomRight );
  114.  
  115.   // Set up the tool bar buttons.
  116.   topLeft
  117.    .setBitmap( ID_TOP_LEFT );
  118.   topCenter
  119.    .setBitmap( ID_TOP_CENTER );
  120.   topRight
  121.    .setBitmap( ID_TOP_RIGHT );
  122.   centerLeft
  123.    .setBitmap( ID_CENTER_LEFT );
  124.   centerCenter
  125.    .setBitmap( ID_CENTER_CENTER );
  126.   centerRight
  127.    .setBitmap( ID_CENTER_RIGHT );
  128.   bottomLeft
  129.    .setBitmap( ID_BOTTOM_LEFT );
  130.   bottomCenter
  131.    .setBitmap( ID_BOTTOM_CENTER );
  132.   bottomRight
  133.    .setBitmap( ID_BOTTOM_RIGHT );
  134.  
  135.   // Size and position the window now.
  136.   (*this)
  137.    .setClient( &packClient )
  138.    .moveSizeToClient( IRectangle( IPoint( 50, 50 ),
  139.                                   packClient.minimumSize() ) );
  140. }
  141.  
  142. PackAlignTest& PackAlignTest::alignGrandChildren
  143.                                 ( ISetCanvas::Alignment align )
  144. {
  145.   tight
  146.    .setAlignment( align );
  147.   even
  148.    .setAlignment( align );
  149.   expanded
  150.    .setAlignment( align );
  151.   return *this;
  152. }
  153.  
  154. IBase::Boolean PackAlignTest::CmdHandler::command
  155.                                      ( ICommandEvent& event )
  156. {
  157.   Boolean
  158.     dontPassOn = false;
  159.   ISetCanvas::Alignment
  160.     align = ISetCanvas::bottomRight;
  161.  
  162.   switch ( event.commandId() )
  163.   {
  164.      case ID_TOP_LEFT:
  165.        align = ISetCanvas::topLeft;
  166.        dontPassOn = true;
  167.        break;
  168.      case ID_TOP_CENTER:
  169.        align = ISetCanvas::topCenter;
  170.        dontPassOn = true;
  171.        break;
  172.      case ID_TOP_RIGHT:
  173.        align = ISetCanvas::topRight;
  174.        dontPassOn = true;
  175.        break;
  176.      case ID_CENTER_LEFT:
  177.        align = ISetCanvas::centerLeft;
  178.        dontPassOn = true;
  179.        break;
  180.      case ID_CENTER_CENTER:
  181.        align = ISetCanvas::centerCenter;
  182.        dontPassOn = true;
  183.        break;
  184.      case ID_CENTER_RIGHT:
  185.        align = ISetCanvas::centerRight;
  186.        dontPassOn = true;
  187.        break;
  188.      case ID_BOTTOM_LEFT:
  189.        align = ISetCanvas::bottomLeft;
  190.        dontPassOn = true;
  191.        break;
  192.      case ID_BOTTOM_CENTER:
  193.        align = ISetCanvas::bottomCenter;
  194.        dontPassOn = true;
  195.        break;
  196.      case ID_BOTTOM_RIGHT:
  197.      default:
  198.        dontPassOn = true;
  199.        break;
  200.   }
  201.  
  202.   if ( dontPassOn )
  203.   {
  204.      clWindow->alignGrandChildren( align );
  205.   }
  206.   return dontPassOn;
  207. }
  208.