home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pwrgu2.zip / POWERGU2.EXE / CANVAS / MCLUNCH / MCLUNCH.CPP < prev    next >
Text File  |  1995-07-25  |  5KB  |  161 lines

  1. //************************************************************
  2. // Canvas  - IMultiCellCanvas Implementation of Lunch Dialog
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // All Rights Reserved.
  6. //************************************************************
  7. #include <icheckbx.hpp>
  8. #include <ientryfd.hpp>
  9. #include <iframe.hpp>
  10. #include <iapp.hpp>
  11. #include <igroupbx.hpp>
  12. #include <imcelcv.hpp>
  13. #include <iradiobt.hpp>
  14. #include <istattxt.hpp>
  15. #include <icconst.h>
  16.  
  17. #include "pushbtns.hpp"      // For MyStandardPushButtons.
  18. #include "lunch.h"
  19.  
  20. void main ( )
  21. {
  22.   IFrameWindow frame( "Lunch",
  23.                       ID_LUNCH_DIALOG,
  24.                       IFrameWindow::classDefaultStyle
  25.                         & ~IFrameWindow::maximizeButton
  26.                         & ~IFrameWindow::minimizeButton
  27. #if IC_MAJOR_VERSION >= 201
  28.                         | IFrameWindow::dialogBackground );
  29. #else
  30.                       );
  31. #endif
  32.  
  33.   // Create the client window.
  34.   IMultiCellCanvas client( IC_FRAME_CLIENT_ID, &frame, &frame );
  35.  
  36.   // Heading text.
  37.   IStaticText headingText( ID_LUNCH_TEXT, &client, &client );
  38.   headingText.setText( "Select your lunch preferences:" );
  39.  
  40.   // Food group box and radio buttons.
  41.   IGroupBox food( ID_FOOD, &client, &client );
  42.   food.setText( "Food" );
  43.   IRadioButton
  44.     hamburger   ( ID_HAMBURGER,    &client, &client ),
  45.     cheeseburger( ID_CHEESEBURGER, &client, &client ),
  46.     hotdog      ( ID_HOTDOG,       &client, &client ),
  47.     pizza       ( ID_PIZZA,        &client, &client );
  48.   hamburger
  49.    .setText      ( "Hamburger" )
  50.    .enableTabStop()
  51.    .enableGroup  ();
  52.   cheeseburger.setText( "Cheeseburger" );
  53.   hotdog.setText( "Hot dog" );
  54.   pizza.setText( "Pizza" );
  55.  
  56.   // Beverage group box and radio buttons.
  57.   IGroupBox beverage( ID_BEVERAGE, &client, &client );
  58.   beverage.setText( "Beverage" );
  59.   IRadioButton
  60.     milk     ( ID_MILK,      &client, &client ),
  61.     softDrink( ID_SOFTDRINK, &client, &client ),
  62.     juice    ( ID_JUICE,     &client, &client ),
  63.     water    ( ID_WATER,     &client, &client );
  64.   milk
  65.    .setText      ( "Milk" )
  66.    .enableTabStop()
  67.    .enableGroup  ();
  68.   softDrink.setText( "Soft drink" );
  69.   juice.setText( "Juice" );
  70.   water.setText( "Water" );
  71.  
  72.   // Side orders group box and choices.
  73.   IGroupBox sideOrders( ID_SIDEORDERS, &client, &client );
  74.   sideOrders.setText( "Side orders" );
  75.   IMultiCellCanvas
  76.     checkBoxes ( 1, &client, &client ),
  77.     requestPair( 2, &client, &client );
  78.   ICheckBox
  79.     salad( ID_SALAD, &checkBoxes, &checkBoxes ),
  80.     fries( ID_FRIES, &checkBoxes, &checkBoxes );
  81.   salad
  82.    .setText      ( "Salad" )
  83.    .enableTabStop()
  84.    .enableGroup  ();
  85.   fries
  86.    .setText      ( "Fries" )
  87.    .enableTabStop()
  88.    .enableGroup  ();
  89.   IStaticText
  90.     requestPrompt( ID_REQUESTPROMPT,
  91.                    &requestPair, &requestPair );
  92.   requestPrompt
  93.    .setAlignment( IStaticText::centerLeft )
  94.    .setText( "Other" );
  95.   IEntryField request(ID_REQUEST, &requestPair, &requestPair );
  96.   request
  97.    .setLimit(15)
  98.    .enableTabStop()
  99.    .enableGroup();
  100.  
  101.   // Push buttons.
  102.   MyStandardPushButtons pushButtons( 4, &client );
  103.  
  104.   // Assign child windows to cells.
  105.   ISize defaultCell = IMultiCellCanvas::defaultCell();
  106.   client
  107.    .addToCell( &headingText,   2,  2,  14 )
  108.    .addToCell( &food,          3,  5,  5,  11 )
  109.    .addToCell( &hamburger,     5,  7 )
  110.    .addToCell( &cheeseburger,  5,  9 )
  111.    .addToCell( &hotdog,        5,  11 )
  112.    .addToCell( &pizza,         5,  13 )
  113.    .addToCell( &beverage,      9,  5,  6,  11 )
  114.    .addToCell( &milk,          11, 7 )
  115.    .addToCell( &softDrink,     11, 9 )
  116.    .addToCell( &juice,         11, 11 )
  117.    .addToCell( &water,         11, 13 )
  118.    .addToCell( &sideOrders,    3,  17, 12, 7 )
  119.    .addToCell( &checkBoxes,    5,  19, 8 )
  120.    .addToCell( &requestPair,   5,  21, 8 )
  121.    .addToCell( &pushButtons,   2,  25, 14 );
  122.   client
  123.    .setColumnWidth( 6,  defaultCell.width(), true )
  124.    .setColumnWidth( 12, defaultCell.width(), true )
  125.    .setColumnWidth( 16, defaultCell.width() )
  126.    .setRowHeight  ( 1,  defaultCell.height(), true )
  127.    .setRowHeight  ( 3,  defaultCell.height(), true )
  128.    .setRowHeight  ( 16, defaultCell.height(), true )
  129.    .setRowHeight  ( 24, defaultCell.height(), true )
  130.    .setRowHeight  ( 26, defaultCell.height(), true );
  131.  
  132.   checkBoxes
  133.    .addToCell( &salad,         1,  1 )
  134.    .addToCell( &fries,         3,  1 );
  135.   checkBoxes
  136.    .setColumnWidth( 2, defaultCell.width(), true )
  137.    .setColumnWidth( 4, defaultCell.width(), true );
  138.  
  139.   requestPair
  140.    .addToCell( &requestPrompt, 1,  1 )
  141.    .addToCell( &request,       3,  1 );
  142.   requestPair
  143.    .setColumnWidth( 3, 0, true );
  144.  
  145.   // Select the default choices.
  146.   hamburger.select();
  147.   milk.select();
  148.  
  149.   // Size and position the frame window.
  150.   frame.setClient( &client );
  151.   IRectangle clientRect( IPoint( 30, 20 ),
  152.                          client.minimumSize() );
  153.   frame.moveSizeToClient( clientRect );
  154.  
  155.   // Show the dialog now.
  156.   frame
  157.    .setFocus()
  158.    .show();
  159.   IApplication::current().run();
  160. }
  161.