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

  1. //*********************************************************
  2. // Canvas - Lunch Dialog Using IMultiCellCanvas
  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 <igroupbx.hpp>
  13. #include <imcelcv.hpp>
  14. #include <iradiobt.hpp>
  15. #include <istattxt.hpp>
  16. #include <icconst.h>
  17.  
  18. #include "pushbtns.hpp"      // For MyStandardPushButtons.
  19. #include "mclunch.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( ID_LUNCH_TEXT );
  40.  
  41.   // Create the "Food" group box and its choices.
  42.   IGroupBox
  43.     food( ID_FOOD, &client, &client );
  44.   food
  45.    .setText( ID_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.    .setText      ( ID_HAMBURGER )
  53.    .enableTabStop()
  54.    .enableGroup  ();
  55.   cheeseburger
  56.    .setText( ID_CHEESEBURGER );
  57.   hotdog
  58.    .setText( ID_HOTDOG );
  59.   pizza
  60.    .setText( ID_PIZZA );
  61.  
  62.   // Create the "Beverage" group box and its radio buttons.
  63.   IGroupBox
  64.     beverage( ID_BEVERAGE, &client, &client );
  65.   beverage
  66.    .setText( ID_BEVERAGE );
  67.   IRadioButton
  68.     milk     ( ID_MILK,      &client, &client ),
  69.     softDrink( ID_SOFTDRINK, &client, &client ),
  70.     juice    ( ID_JUICE,     &client, &client ),
  71.     water    ( ID_WATER,     &client, &client );
  72.   milk
  73.    .setText      ( ID_MILK )
  74.    .enableTabStop()
  75.    .enableGroup  ();
  76.   softDrink
  77.    .setText( ID_SOFTDRINK );
  78.   juice
  79.    .setText( ID_JUICE );
  80.   water
  81.    .setText( ID_WATER );
  82.  
  83.   // Create the "Side orders" group box and its choices.
  84.   IGroupBox
  85.     sideOrders( ID_SIDEORDERS, &client, &client );
  86.   sideOrders
  87.    .setText( ID_SIDEORDERS );
  88.   IMultiCellCanvas
  89.     checkBoxes ( 1, &client, &client ),
  90.     requestPair( 2, &client, &client );
  91.   ICheckBox
  92.     salad( ID_SALAD, &checkBoxes, &checkBoxes ),
  93.     fries( ID_FRIES, &checkBoxes, &checkBoxes );
  94.   salad
  95.    .setText      ( ID_SALAD )
  96.    .enableTabStop()
  97.    .enableGroup  ();
  98.   fries
  99.    .setText      ( ID_FRIES )
  100.    .enableTabStop()
  101.    .enableGroup  ();
  102.   IStaticText
  103.     requestPrompt( ID_REQUESTPROMPT, &requestPair, &requestPair );
  104.   requestPrompt
  105.    .setAlignment( IStaticText::centerLeft )
  106.    .setText     ( ID_REQUESTPROMPT );
  107.   IEntryField
  108.     request(ID_REQUEST, &requestPair, &requestPair );
  109.   request
  110.    .enableTabStop()
  111.    .enableGroup();
  112.  
  113.   // Create the push buttons.
  114.   MyStandardPushButtons
  115.     pushButtons( 4, &client );
  116.  
  117.   // Position and size child windows of the multicell canvases
  118.   // by assigning them to cells.
  119.   ISize
  120.     defaultCellSize = IMultiCellCanvas::defaultCell();
  121.   client
  122.    .addToCell( &headingText,   2,  2,  14 )
  123.    .addToCell( &food,          3,  5,  5,  11 )
  124.    .addToCell( &hamburger,     5,  8 )
  125.    .addToCell( &cheeseburger,  5,  10 )
  126.    .addToCell( &hotdog,        5,  12 )
  127.    .addToCell( &pizza,         5,  14 )
  128.    .addToCell( &beverage,      9,  5,  6,  11 )
  129.    .addToCell( &milk,          11, 8 )
  130.    .addToCell( &softDrink,     11, 10 )
  131.    .addToCell( &juice,         11, 12 )
  132.    .addToCell( &water,         11, 14 )
  133.    .addToCell( &sideOrders,    3,  18, 12, 7 )
  134.    .addToCell( &checkBoxes,    5,  21, 8 )
  135.    .addToCell( &requestPair,   5,  23, 8 )
  136.    .addToCell( &pushButtons,   2,  27, 14 );
  137.   client
  138.    .setColumnWidth( 6,  defaultCellSize.width(), true )
  139.    .setColumnWidth( 12, defaultCellSize.width(), true )
  140.    .setColumnWidth( 16, defaultCellSize.width() )
  141.    .setRowHeight  ( 1,  defaultCellSize.height(), true )
  142.    .setRowHeight  ( 3,  defaultCellSize.height(), true )
  143.    .setRowHeight  ( 17, defaultCellSize.height(), true )
  144.    .setRowHeight  ( 25, defaultCellSize.height(), true )
  145.    .setRowHeight  ( 28, defaultCellSize.height(), true );
  146.  
  147.   checkBoxes
  148.    .addToCell( &salad,         1,  1 )
  149.    .addToCell( &fries,         3,  1 );
  150.   checkBoxes
  151.    .setColumnWidth( 2, defaultCellSize.width(), true )
  152.    .setColumnWidth( 4, defaultCellSize.width(), true );
  153.  
  154.   requestPair
  155.    .addToCell( &requestPrompt, 1,  1 )
  156.    .addToCell( &request,       3,  1 );
  157.   requestPair
  158.    .setColumnWidth( 3, 0, true );
  159.  
  160.   // Select the default choices.
  161.   hamburger
  162.    .select();
  163.   milk
  164.    .select();
  165.  
  166.   // Size and position the frame window.
  167.   IRectangle
  168.     clientRect( IPoint( 50, 50 ), client.minimumSize() );
  169.   frame
  170.    .setClient( &client )
  171.    .moveSizeToClient( clientRect );
  172.  
  173.   // Show the dialog now.
  174.   frame
  175.    .setFocus()
  176.    .show();
  177.  
  178.   IApplication::current().run();
  179. }
  180.