home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / 2dbmap / 2dbmap.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  7.1 KB  |  164 lines

  1. /******************************************************************************
  2. * .FILE:         2d-bmap.hpp                                                  *
  3. *                                                                             *
  4. * .DESCRIPTION:  2D Bitmap Graphic Sample Program:  Class Definitions         *
  5. *                                                                             *
  6. * .CLASSES:      DrawingAreaPaintHandler                                      *
  7. *                MainCommandHandler                                           *
  8. *                DrawingArea                                                  *
  9. *                MainWindow                                                   *
  10. *                                                                             *
  11. * .COPYRIGHT:                                                                 *
  12. *    Licensed Material - Program-Property of IBM                              *
  13. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  14. *                                                                             *
  15. * .DISCLAIMER:                                                                *
  16. *   The following [enclosed] code is sample code created by IBM               *
  17. *   Corporation.  This sample code is not part of any standard IBM product    *
  18. *   and is provided to you solely for the purpose of assisting you in the     *
  19. *   development of your applications.  The code is provided 'AS IS',          *
  20. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  21. *   arising out of your use of the sample code, even if they have been        *
  22. *   advised of the possibility of such damages.                               *
  23. *                                                                             *
  24. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  25. *                                                                             *
  26. ******************************************************************************/
  27. #ifndef BITMAP_HPP
  28. #define BITMAP_HPP
  29.  
  30. #include <iframe.hpp>
  31. #include <icmdhdr.hpp>
  32. #include <idrawcv.hpp>
  33. #include <ivport.hpp>
  34. #include <ipainhdr.hpp>
  35. #include <igbitmap.hpp>
  36. #include "2dbmap.h"
  37.  
  38. /***************************************************************************
  39. * Class DrawingAreaPaintHandler - Handles repainting                       *
  40. ***************************************************************************/
  41. class DrawingAreaPaintHandler : public IPaintHandler
  42. {
  43. typedef IPaintHandler
  44.   Inherited;
  45.  
  46. protected:
  47. /*------------------------------------------------------------------------|
  48. | paintWindow is an overloaded function that repaints the window.         |
  49. -------------------------------------------------------------------------*/
  50.   virtual Boolean
  51.     paintWindow( IPaintEvent& event );
  52. };
  53.  
  54. /***************************************************************************
  55. * Class MainCommandHandler - Handle command events for the main window.    *
  56. ***************************************************************************/
  57. class MainCommandHandler : public ICommandHandler
  58. {
  59. typedef ICommandHandler
  60.   Inherited;
  61.  
  62. protected:
  63. /*------------------------------------------------------------------------|
  64. | command is an overloaded function that handles command events.          |
  65. -------------------------------------------------------------------------*/
  66. virtual Boolean
  67.   command( ICommandEvent& event );
  68. };
  69.  
  70. /******************************************************************************
  71. * Class DrawingArea - A drawing canvas to draw and modify bitmaps             *
  72. ******************************************************************************/
  73. class DrawingArea : public IDrawingCanvas
  74. {
  75. typedef IDrawingCanvas
  76.   Inherited;
  77.  
  78. public:
  79. /*------------------------------- Constructor --------------------------------|
  80. | Constructs the object with:                                                 |
  81. | 1) the windowid and pointers to the parent window and owner window          |
  82. -----------------------------------------------------------------------------*/
  83.   DrawingArea( unsigned long id, IWindow* parent, IWindow* owner );
  84.  
  85. /*-------------------------------- Destructor --------------------------------|
  86. | Destructs the object with:                                                  |
  87. | 1) no parameters                                                            |
  88. -----------------------------------------------------------------------------*/
  89.   virtual
  90.    ~DrawingArea();
  91.  
  92. /*----------------------------------------------------------------------------|
  93. | loadBitmap   - loads a bitmap file form disk.                               |
  94. | bitmap       - returns a pointer to its bitmap.                             |
  95. | setClipStyle - set the clip style for the drawing area.                     |
  96. -----------------------------------------------------------------------------*/
  97.   DrawingArea
  98.    &loadBitmap( const IString& imageFile );
  99.   IGBitmap
  100.    *bitmap() const;
  101.   DrawingArea
  102.    &setClipStyle ( unsigned long style ) { fStyle = style; return *this; }
  103.   unsigned long
  104.     clipStyle( ) const { return fStyle; }
  105.  
  106. protected:
  107.   virtual ISize
  108.     calcMinimumSize     ( ) const;
  109.  
  110. private:
  111.  
  112.   DrawingAreaPaintHandler
  113.     drawingAreaPaintHandler;
  114.   IGBitmap
  115.    *fBitmap;
  116.   unsigned long
  117.     fStyle;
  118. };
  119.  
  120. /******************************************************************************
  121. * Class:   MainWindow - Main window for C++ 2D Bitmap sample application      *
  122. ******************************************************************************/
  123. class MainWindow : public IFrameWindow
  124. {
  125. typedef IFrameWindow
  126.   Inherited;
  127.  
  128. public:
  129. /*------------------------------- Constructor --------------------------------|
  130. | Constructs the object with:                                                 |
  131. | 1)                                                                          |
  132. -----------------------------------------------------------------------------*/
  133.     MainWindow(unsigned long windowId);
  134.  
  135. /*-------------------------------- Destructor --------------------------------|
  136. | Destructs the object with:                                                  |
  137. | 1)                                                                          |
  138. -----------------------------------------------------------------------------*/
  139. virtual
  140.   ~MainWindow();
  141.  
  142. /*----------------------------------------------------------------------------|
  143. | loadImageFile - loads an image from a file.                                 |
  144. | modifyBitmap  - Modifies the bitmap based upon the event id.                |
  145. | draingArea    - Returns a reference to the drawing area.                    |
  146. -----------------------------------------------------------------------------*/
  147.   virtual MainWindow
  148.    &loadImageFile( const IString& imageFile );
  149.   virtual MainWindow
  150.    &modifyBitmap( unsigned long eventId );
  151.   DrawingArea
  152.    &drawingArea( ) { return fDrawingArea; }
  153.  
  154. private:
  155.   IViewPort
  156.     fViewPort;
  157.   DrawingArea
  158.     fDrawingArea;
  159.   MainCommandHandler
  160.     fMainCommandHandler;
  161. };
  162.  
  163. #endif
  164.