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

  1. //*********************************************************
  2. // Canvas - IMultiCellCanvas with Smarter Group Boxes
  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 <icheckbx.hpp>
  10. #include <ientryfd.hpp>
  11. #include <iframe.hpp>
  12. #include <imcelcv.hpp>
  13. #include <iradiobt.hpp>
  14. #include <istattxt.hpp>
  15. #include <icconst.h>
  16.  
  17. #include "mcgroup.hpp"       // For GroupBoxForMultiCell.
  18. #include "pushbtns.hpp"      // For MyStandardPushButtons.
  19. #include "mcgroup.h"
  20.  
  21. void main ( )
  22. {
  23.   IFrameWindow
  24.     frame( "Lunch",
  25.            ID_LUNCH_DIALOG,
  26.            IFrameWindow::classDefaultStyle
  27.              & ~IFrameWindow::maximizeButton
  28.              & ~IFrameWindow::minimizeButton
  29.              | IFrameWindow::dialogBackground );
  30.  
  31.   // Create the client window.
  32.   IMultiCellCanvas
  33.     client( IC_FRAME_CLIENT_ID, &frame, &frame );
  34.  
  35.   // Create the heading text.
  36.   IStaticText
  37.     headingText( ID_LUNCH_TEXT, &client, &client );
  38.   headingText
  39.    .setText( "Select your lunch preferences:" );
  40.  
  41.   // Create the "Food" group box and its choices.
  42.   GroupBoxForMultiCell
  43.     food( ID_FOOD, &client );
  44.   food
  45.    .setText( "Food" );
  46.   IRadioButton
  47.     hamburger   ( ID_HAMBURGER,    &client, &client ),
  48.     cheeseburger( ID_CHEESEBURGER, &client, &client ),
  49.     hotdog      ( ID_HOTDOG,       &client, &client ),
  50.     pizza       ( ID_PIZZA,        &client, &client );
  51.   hamburger
  52. #ifdef IC_PM
  53.    .setText      ( "~Hamburger" )
  54. #else
  55.    .setText      ( "&Hamburger" )
  56. #endif
  57.    .enableTabStop()
  58.    .enableGroup  ();
  59. #ifdef IC_PM
  60.   cheeseburger.setText( "~Cheeseburger" );
  61.   hotdog.setText( "Hot ~dog" );
  62.   pizza.setText( "~Pizza" );
  63. #else
  64.   cheeseburger.setText( "&Cheeseburger" );
  65.   hotdog.setText( "Hot &dog" );
  66.   pizza.setText( "&Pizza" );
  67. #endif
  68.  
  69.   // Create the "Beverage" group box and its radio buttons.
  70.   GroupBoxForMultiCell
  71.     beverage( ID_BEVERAGE, &client );
  72.   beverage
  73.    .setText( "Beverage" );
  74.   IRadioButton
  75.     milk     ( ID_MILK,      &client, &client ),
  76.     softDrink( ID_SOFTDRINK, &client, &client ),
  77.     juice    ( ID_JUICE,     &client, &client ),
  78.     water    ( ID_WATER,     &client, &client );
  79.   milk
  80. #ifdef IC_PM
  81.    .setText      ( "~Milk" )
  82. #else
  83.    .setText      ( "&Milk" )
  84. #endif
  85.    .enableTabStop()
  86.    .enableGroup  ();
  87. #ifdef IC_PM
  88.   softDrink
  89.    .setText( "~Soft drink" );
  90.   juice
  91.    .setText( "~Juice" );
  92.   water
  93.    .setText( "~Water" );
  94. #else
  95.   softDrink
  96.    .setText( "&Soft drink" );
  97.   juice
  98.    .setText( "&Juice" );
  99.   water
  100.    .setText( "&Water" );
  101. #endif
  102.  
  103.   // Create the "Side orders" group box and its choices.
  104.   GroupBoxForMultiCell
  105.     sideOrders( ID_SIDEORDERS, &client );
  106.   sideOrders
  107.    .setText( "Side orders" );
  108.   IMultiCellCanvas
  109.     checkBoxes ( 1, &client, &client ),
  110.     requestPair( 2, &client, &client );
  111.   ICheckBox
  112.     salad( ID_SALAD, &checkBoxes, &checkBoxes ),
  113.     fries( ID_FRIES, &checkBoxes, &checkBoxes );
  114.   salad
  115. #ifdef IC_PM
  116.    .setText      ( "Sa~lad" )
  117. #else
  118.    .setText      ( "Sa&lad" )
  119. #endif
  120.    .enableTabStop()
  121.    .enableGroup  ();
  122.   fries
  123. #ifdef IC_PM
  124.    .setText      ( "~French fries" )
  125. #else
  126.    .setText      ( "&French fries" )
  127. #endif
  128.    .enableTabStop()
  129.    .enableGroup  ();
  130.   IStaticText
  131.     requestPrompt( ID_REQUESTPROMPT,
  132.                    &requestPair, &requestPair );
  133.   requestPrompt
  134.    .setAlignment( IStaticText::centerLeft )
  135.    .setText( "Other" );
  136.   IEntryField
  137.     request(ID_REQUEST, &requestPair, &requestPair );
  138.   request
  139.    .enableTabStop()
  140.    .enableGroup();
  141.  
  142.   // Create the push buttons.
  143.   MyStandardPushButtons
  144.     pushButtons( 4, &client );
  145.  
  146.   // Position and size child windows of the multicell canvases
  147.   // by assigning them to cells.
  148.   ISize
  149.     defaultCell = IMultiCellCanvas::defaultCell();
  150.   client
  151.    .addToCell( &headingText,   2,  2,  14 )
  152.    .addToCell( &food,          3,  5,  5,  10 )
  153.    .addToCell( &hamburger,     5,  7 )
  154.    .addToCell( &cheeseburger,  5,  9 )
  155.    .addToCell( &hotdog,        5,  11 )
  156.    .addToCell( &pizza,         5,  13 )
  157.    .addToCell( &beverage,      9,  5,  6,  10 )
  158.    .addToCell( &milk,          11, 7 )
  159.    .addToCell( &softDrink,     11, 9 )
  160.    .addToCell( &juice,         11, 11 )
  161.    .addToCell( &water,         11, 13 )
  162.    .addToCell( &sideOrders,    3,  17, 12, 6 )
  163.    .addToCell( &checkBoxes,    5,  19, 8 )
  164.    .addToCell( &requestPair,   5,  21, 8 )
  165.    .addToCell( &pushButtons,   2,  25, 14 );
  166.   client
  167.    .setColumnWidth( 6,  defaultCell.width(), true )
  168.    .setColumnWidth( 12, defaultCell.width(), true )
  169.    .setColumnWidth( 16, defaultCell.width() )
  170.    .setRowHeight  ( 1,  defaultCell.height(), true )
  171.    .setRowHeight  ( 3,  defaultCell.height(), true )
  172.    .setRowHeight  ( 16, defaultCell.height(), true )
  173.    .setRowHeight  ( 23, defaultCell.height(), true )
  174.    .setRowHeight  ( 26, defaultCell.height(), true );
  175.  
  176.   // Tell GroupBoxForMultiCell objects where they are positioned
  177.   // in the multicell canvas.
  178.   food
  179.    .setMultiCellRow( 5 );
  180.   beverage
  181.    .setMultiCellRow( 5 );
  182.   sideOrders
  183.    .setMultiCellRow( 17 );
  184.  
  185.   checkBoxes
  186.    .addToCell( &salad,         1,  1 )
  187.    .addToCell( &fries,         3,  1 );
  188.   checkBoxes
  189.    .setColumnWidth( 2, defaultCell.width(), true )
  190.    .setColumnWidth( 4, defaultCell.width(), true );
  191.  
  192.   requestPair
  193.    .addToCell( &requestPrompt, 1,  1 )
  194.    .addToCell( &request,       3,  1 );
  195.   requestPair
  196.    .setColumnWidth( 3, 0, true );
  197.  
  198.   // Select the default choices.
  199.   hamburger
  200.    .select();
  201.   milk
  202.    .select();
  203.  
  204.   // Size and position the frame window.
  205.   IRectangle
  206.     clientRect( IPoint( 50, 50 ),
  207.                 client.minimumSize() );
  208.   frame
  209.    .setClient( &client )
  210.    .moveSizeToClient( clientRect );
  211.  
  212.   // Show the dialog now.
  213.   frame
  214.    .setFocus()
  215.    .show();
  216.  
  217.   IApplication::current().run();
  218. }
  219.