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

  1. //************************************************************
  2. // Button Controls  - Push Button Example
  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 <iframe.hpp>
  9. #include <ipushbut.hpp>
  10. #include <igraphbt.hpp>
  11. #include <imcelcv.hpp>
  12. #include <isetcv.hpp>
  13. #include <iapp.hpp>
  14. #include <icconst.h>
  15. #include <isysmenu.hpp>
  16. #include "pushbut.h"
  17.  
  18.  
  19. void main()
  20. {
  21. // Create a frame window with a multi-cell canvas
  22. // in the client area.
  23. IFrameWindow
  24.   frame ("Push Button Example");
  25. IMultiCellCanvas
  26.   client(IC_FRAME_CLIENT_ID, &frame, &frame);
  27.  
  28. // Create a set canvas to hold the push buttons.
  29. ISetCanvas
  30.   buttons(ID_BUTTONS, &client, &client);
  31.  
  32. // Create the push buttons in the set canvas.
  33. IPushButton
  34.   ok(ID_OK, &buttons, &buttons),
  35.   cancel(ISystemMenu::idClose, &buttons, &buttons);
  36.  
  37. IGraphicPushButton
  38.   bitmap(ID_BITMAPBUTTON, &buttons, &buttons,
  39.          ISystemBitmapHandle(ISystemBitmapHandle::program)),
  40.   icon(ID_ICONBUTTON, &buttons, &buttons,
  41.          ISystemPointerHandle(ISystemPointerHandle::folder));
  42. IPushButton
  43.   help(ID_HELP, &buttons, &buttons, IRectangle(),
  44.        IPushButton::defaultStyle() | IPushButton::noPointerFocus);
  45.  
  46. // Indicate that the bitmap button should base its size on
  47. // the size of the bitmap.
  48. bitmap.enableSizeToGraphic();
  49.  
  50. // Set default button to "OK" and make this
  51. // button the first of the group.
  52. ok
  53.   .enableDefault()
  54.   .setText("OK")
  55.   .enableTabStop()
  56.   .enableGroup();
  57.  
  58. // Make the Cancel button a "Close" system command so
  59. // the application closes when it is pressed.  Note
  60. // that we created the button with the id
  61. // ISystemMenu::idClose.
  62. cancel
  63.   .enableSystemCommand()
  64.   .setText("Cancel");
  65.  
  66.  
  67. // Make the Help button show help when pressed (in
  68. // this application, we haven't defined any help
  69. // to display).
  70. help
  71.   .enableHelp()
  72.   .setText("Help");
  73.  
  74. // Add the controls to the multicell canvas.
  75. client
  76.  .addToCell(&buttons, 2, 6, 3, 1);
  77.  
  78. // Allow for some growth in the canvas.
  79. client
  80.  .setRowHeight   (1, 20, true);
  81.  
  82. // Put the canvas in the client and show the window.
  83. frame
  84.   .setClient(&client)
  85.   .setFocus()
  86.   .show();
  87. IApplication::current().run();
  88.  
  89. }
  90.