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

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