home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / lancelot / lprdinfo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  5.7 KB  |  125 lines

  1. /******************************************************************************
  2. * .FILE:         lprdinfo.cpp                                                 *
  3. *                                                                             *
  4. * .DESCRIPTION:  Lancelot Sample Program:              Class Implementation   *
  5. *                                                                             *
  6. * .CLASSES:      LProdInfoDialog                                              *
  7. *                                                                             *
  8. * .COPYRIGHT:                                                                 *
  9. *    Licensed Material - Program-Property of IBM                              *
  10. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  11. *                                                                             *
  12. * .DISCLAIMER:                                                                *
  13. *   The following [enclosed] code is sample code created by IBM               *
  14. *   Corporation.  This sample code is not part of any standard IBM product    *
  15. *   and is provided to you solely for the purpose of assisting you in the     *
  16. *   development of your applications.  The code is provided 'AS IS',          *
  17. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  18. *   arising out of your use of the sample code, even if they have been        *
  19. *   advised of the possibility of such damages.                               *
  20. *                                                                             *
  21. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  22. *                                                                             *
  23. ******************************************************************************/
  24.  
  25. #ifndef _IBASE_                         //Make sure ibase.hpp is included
  26.   #include <ibase.hpp>                  //  since that is where IC_<environ>
  27. #endif                                  //  is defined.
  28. #include "lprdinfo.hpp"
  29. #include "lancelot.h"
  30.  
  31.  
  32. /***********************************************************/
  33. /* Constructor for the product information dialog class.   */
  34. /***********************************************************/
  35. LProdInfoDialog::LProdInfoDialog( IWindow *owner )
  36.   :IFrameWindow( ID_PRODINFO, IWindow::desktopWindow(), owner,
  37.                  IRectangle(),
  38.                  IFrameWindow::systemMenu
  39.                  | IFrameWindow::dialogBackground
  40.                  | IFrameWindow::dialogBorder )
  41.   ,canvas( ID_PRODINFO_CANVAS, this, this )
  42.   ,iconCtl( ID_PRODINFO_ICON, &canvas, &canvas )
  43.   ,text1( ID_PRODINFO_TEXT1, &canvas, &canvas )
  44.   ,text2( ID_PRODINFO_TEXT2, &canvas, &canvas )
  45.   ,text3( ID_PRODINFO_TEXT3, &canvas, &canvas )
  46.   ,text4( ID_PRODINFO_TEXT4, &canvas, &canvas )
  47.   ,text5( ID_PRODINFO_TEXT5, &canvas, &canvas )
  48.   ,button( ID_PRODINFO_OK, &canvas, &canvas )
  49. {
  50.    // Set self as command event handler
  51.    handleEventsFor(this);
  52.  
  53.    // Set text for the controls
  54.    iconCtl.setIcon( ID_MAIN );
  55.    text1.setText( IResourceId( STR_MAIN_TITLE ) );
  56.    text1.setForegroundColor( IColor::red );
  57.    text2.setText( IResourceId( STR_PRODINFO_TEXT2 ) );
  58.    text3.setText( IResourceId( STR_PRODINFO_TEXT3 ) );
  59.    text4.setText( IResourceId( STR_PRODINFO_TEXT4 ) );
  60.    text5.setText( IResourceId( STR_PRODINFO_TEXT5 ) );
  61.    button.setText( IResourceId( STR_OK ) );
  62.  
  63.    // Set the canvas orientation to veritical
  64.    // Set the canvas alignment to center all the controls
  65.    canvas.setDeckOrientation( ISetCanvas::vertical );
  66.    canvas.setAlignment( ISetCanvas::centerCenter );
  67.  
  68.    // Set the client as the canvas
  69.    setClient( &canvas );
  70.  
  71. /*-----------------------------------------------------------------------------
  72. | Resize the window based on the minimum size of the canvas                   |
  73. -----------------------------------------------------------------------------*/
  74. #ifndef IC_MOTIF
  75.    moveSizeToClient( IRectangle( IPoint(
  76.                      IWindow::desktopWindow()->size().width()/2,
  77.                      IWindow::desktopWindow()->size().height()/2 ),
  78.                      canvas.minimumSize() ) );
  79. #else
  80.    moveSizeTo( IRectangle( IPoint(
  81.                IWindow::desktopWindow()->size().width()/2,
  82.                IWindow::desktopWindow()->size().height()/2 ),
  83.                canvas.minimumSize() ) );
  84. #endif
  85.  
  86. /*-----------------------------------------------------------------------------
  87. | Center the frame window                                                     |
  88. -----------------------------------------------------------------------------*/
  89.    moveSizeTo( rect().centerAt( IWindow::desktopWindow()->rect().center() ) );
  90.  
  91. /*-----------------------------------------------------------------------------
  92. | Show the dialog window                                                      |
  93. -----------------------------------------------------------------------------*/
  94.    setFocus();
  95.    show();
  96.  
  97. }
  98.  
  99.  
  100. /***********************************************************/
  101. /* Destructor for the product information dialog class.    */
  102. /***********************************************************/
  103. LProdInfoDialog :: ~LProdInfoDialog()
  104. {
  105.    stopHandlingEventsFor(this);
  106. }
  107.  
  108.  
  109.  
  110. /***********************************************************/
  111. /* Command handler function for the product information    */
  112. /* dialog. There is only one control to handle.            */
  113. /***********************************************************/
  114. Boolean LProdInfoDialog :: command( ICommandEvent& cmdevt)
  115. {
  116.   switch ( cmdevt.commandId() )
  117.   {
  118.      case ID_PRODINFO_OK:
  119.         dismiss(ID_PRODINFO_OK);
  120.         return true;
  121.   }
  122.  
  123.   return false;
  124. }
  125.