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

  1. //*********************************************************
  2. // Canvas - Lunch Dialog Using ISetCanvas
  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 <iradiobt.hpp>
  13. #include <isetcv.hpp>
  14. #include <istattxt.hpp>
  15. #include <icconst.h>
  16.  
  17. #include "pushbtns.hpp"      // For MyStandardPushButtons.
  18. #include "setlunch.h"
  19.  
  20. void main ( )
  21. {
  22.   IFrameWindow
  23.     frame( "Lunch",
  24.            ID_LUNCH_DIALOG,
  25.            IFrameWindow::classDefaultStyle
  26.              & ~IFrameWindow::maximizeButton
  27.              & ~IFrameWindow::minimizeButton
  28.              | IFrameWindow::dialogBackground );
  29.  
  30.   // Create the client window.
  31.   ISetCanvas
  32.     client( IC_FRAME_CLIENT_ID, &frame, &frame );
  33.   client
  34.    .setDeckOrientation( ISetCanvas::vertical );
  35.  
  36.   // Create the heading text.
  37.   IStaticText
  38.     headingText( ID_LUNCH_TEXT, &client, &client );
  39.   headingText
  40.    .setText( ID_LUNCH_TEXT );
  41.  
  42.   // Create canvases for additional formatting and the
  43.   // "Food" group box and its choices.
  44.   ISetCanvas
  45.     choices( 1, &client, &client ),
  46.     columns( 2, &choices, &choices ),
  47.     food   ( ID_FOOD, &columns, &columns );
  48.   choices
  49.    .setDeckOrientation( ISetCanvas::vertical )
  50.    .setPackType       ( ISetCanvas::even );
  51.   columns
  52.    .setMargin  ( ISize() )
  53.    .setPackType( ISetCanvas::expanded );
  54.   food
  55.    .setDeckOrientation( ISetCanvas::vertical )
  56.    .setText           ( ID_FOOD );
  57.  
  58.   // Create the "Food" radio buttons.
  59.   IRadioButton
  60.     hamburger   ( ID_HAMBURGER,    &food, &food ),
  61.     cheeseburger( ID_CHEESEBURGER, &food, &food ),
  62.     hotdog      ( ID_HOTDOG,       &food, &food ),
  63.     pizza       ( ID_PIZZA,        &food, &food );
  64.   hamburger
  65.    .setText      ( ID_HAMBURGER )
  66.    .enableTabStop()
  67.    .enableGroup  ();
  68.   cheeseburger
  69.    .setText( ID_CHEESEBURGER );
  70.   hotdog
  71.    .setText( ID_HOTDOG );
  72.   pizza
  73.    .setText( ID_PIZZA );
  74.  
  75.   // Create the "Beverage" group box and its radio buttons.
  76.   ISetCanvas
  77.     beverage( ID_BEVERAGE, &columns, &columns );
  78.   beverage
  79.    .setDeckOrientation( ISetCanvas::vertical )
  80.    .setText           ( ID_BEVERAGE );
  81.   IRadioButton
  82.     milk     ( ID_MILK,      &beverage, &beverage ),
  83.     softDrink( ID_SOFTDRINK, &beverage, &beverage ),
  84.     juice    ( ID_JUICE,     &beverage, &beverage ),
  85.     water    ( ID_WATER,     &beverage, &beverage );
  86.   milk
  87.    .setText      ( ID_MILK )
  88.    .enableTabStop()
  89.    .enableGroup  ();
  90.   softDrink
  91.    .setText( ID_SOFTDRINK );
  92.   juice
  93.    .setText( ID_JUICE );
  94.   water
  95.    .setText( ID_WATER );
  96.  
  97.   // Create the "Side orders" group box and its choices.
  98.   ISetCanvas
  99.     sideOrders( ID_SIDEORDERS, &choices, &choices );
  100.   sideOrders
  101.    .setDeckCount( 2 )
  102.    .setAlignment( ISetCanvas::centerCenter )
  103.    .setText     ( ID_SIDEORDERS );
  104.   ICheckBox
  105.     salad( ID_SALAD, &sideOrders, &sideOrders ),
  106.     fries( ID_FRIES, &sideOrders, &sideOrders );
  107.   salad
  108.    .setText      ( ID_SALAD )
  109.    .enableTabStop()
  110.    .enableGroup  ();
  111.   fries
  112.    .setText      ( ID_FRIES )
  113.    .enableTabStop()
  114.    .enableGroup  ();
  115.   IStaticText
  116.     requestPrompt( ID_REQUESTPROMPT, &sideOrders, &sideOrders );
  117.   requestPrompt
  118.    .setText( ID_REQUESTPROMPT );
  119.   IEntryField
  120.     request(ID_REQUEST, &sideOrders, &sideOrders );
  121.   request
  122.    .enableTabStop()
  123.    .enableGroup();
  124.  
  125.   // Create the push buttons.
  126.   MyStandardPushButtons
  127.     pushButtons( 4, &client );
  128.  
  129.   // Select the default choices.
  130.   hamburger
  131.    .select();
  132.   milk
  133.    .select();
  134.  
  135.   // Size and position the frame window.
  136.   IRectangle
  137.     clientRect( IPoint( 50, 50 ),
  138.                 client.minimumSize() );
  139.   frame
  140.    .setClient( &client )
  141.    .moveSizeToClient( clientRect );
  142.  
  143.   // Show the dialog now.
  144.   frame
  145.    .setFocus()
  146.    .show();
  147.  
  148.   IApplication::current().run();
  149. }
  150.