home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / iwindow.hp_ / IWINDOW.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  14.0 KB  |  305 lines

  1. #ifndef _IWINDOW_
  2. #define _IWINDOW_
  3. /*******************************************************************************
  4. * FILE NAME: iwindow.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IWindow -  Abstract base class for all GUI window classes.               *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *$Log:   R:/IBMCLASS/IBASEAPP/VCS/IWINDOW.HPV  $
  18. // 
  19. //    Rev 1.9   26 Oct 1992 10:48:26   nunn
  20. // Kevin's changes for 10/26
  21.    
  22.    Miscellaneous improvements.
  23. *******************************************************************************/
  24. #ifndef _IVBASE_
  25.   #include <ivbase.hpp>
  26. #endif
  27.  
  28. // Forward declarations for other classes:
  29. class IWindow;
  30. class IHandler;
  31. class IPoint;
  32. class ISize;
  33. class IRectangle;
  34. class IString;
  35. class IColor;
  36. class IEvent;
  37. class ILHandlerSet;
  38. class IBITFLAG;
  39. #if !defined( _IBITFLAG_ ) 
  40.   #include <ibitflag.hpp>
  41. #endif
  42. class IHandle;
  43. #if !defined( _IHANDLE_ ) 
  44.   #include <ihandle.hpp>
  45. #endif
  46.  
  47. class IWindow : public IVBase {
  48. /*******************************************************************************
  49. * The IWindow class is an abstract base class and has common functions to      *
  50. * operate on a window and to define event handlers.                            *
  51. *******************************************************************************/
  52. typedef IVBase Inherited;
  53. public:
  54. /*-------------------------------- STYLES --------------------------------------
  55. | These style objects provide means of setting the window style of instance    |
  56. | of this class:                                                               |
  57. |   IWindow::noStyle      - all styles set off                                 |
  58. |   IWindow::visible      - window is visible                                  |
  59. |   IWindow::disabled     - window is disabled                                 |
  60. |   IWindow::clipChildren - area occupied by the children of the window is     |
  61. |                           to be excluded when drawing in the window          |
  62. |   IWindow::clipSiblings - area occupied by the siblings of the window is     |
  63. |                           to be excluded when drawing in the window          |
  64. |   IWindow::parentClip   - control how the window is clipped when a drawing   |
  65. |                           action taken place in the window                   |
  66. |   IWindow::saveBits     - screen image of the area under the window be saved |
  67. |                           when the window is made visible                    |
  68. |   IWindow::synchPaint   - window is synchorously repainted                   |
  69. ------------------------------------------------------------------------------*/
  70. INESTEDBITFLAGCLASSDEF0(Style, IWindow);
  71. static const Style
  72.   noStyle,
  73.   visible,
  74.   disabled,
  75.   clipChildren,
  76.   clipSiblings,
  77.   parentClip,
  78.   saveBits,
  79.   synchPaint;
  80.  
  81. /*-------------------------------- ACCESSORS -----------------------------------
  82. | These functions provide means of getting and setting the accessible          |
  83. | attributes of instances of this class:                                       |
  84. |   color            - Returns the window's attribute color                    |
  85. |   disable          - disables the window                                     |       
  86. |   enable           - enables the window                                      |       
  87. |   grabPresSpace    - gets the window presentation space handle               |
  88. |   handle           - returns the window handle                               |       
  89. |   hide             - hides the window                                        |       
  90. |   id               - returns the window ID.                                  |       
  91. |   moveSizeTo       - moves and sizes the window                              |
  92. |   moveTo           - moves the window                                        |
  93. |   position         - returns the window position or location                 |
  94. |   rect             - returns the window rectangle value                      |
  95. |   releasePresSpace - releases the window presentation space handle           |
  96. |   setColor         - sets the window's attribute color                       |
  97. |   setFocus         - gives the window input focus                            |       
  98. |   show             - shows the window                                        |       
  99. |   size             - returns the window size                                 |
  100. |   sizeTo           - sizes the window                                        |
  101. ------------------------------------------------------------------------------*/
  102. virtual void 
  103.   disable(),
  104.   enable(Boolean enableWindow=true);
  105.  
  106. virtual const IWindowHandle
  107.   &handle() const;
  108.  
  109. unsigned long
  110.   id() const;
  111.  
  112. ISize 
  113.   size() const;
  114.  
  115. IPoint 
  116.   position() const;
  117.  
  118. IRectangle 
  119.   rect() const;
  120.  
  121. IPresSpaceHandle
  122.   grabPresSpace() const;
  123.  
  124. IWindow
  125.   &hide(),
  126.   &moveSizeTo(const IRectangle& newRect),
  127.   &moveTo(const IPoint& newPosition),
  128.   &releasePresSpace(const IPresSpaceHandle& hps) const,
  129.   &setFocus(),
  130.   &show(Boolean showWindow=true),
  131.   &sizeTo(const ISize& newSize);
  132.  
  133. enum Attribute
  134.   {foreground, background, hiliteFgnd, hiliteBgnd, disableFgnd, diableBgnd,
  135.    border, active, inactive, shadow, activeTextFgnd, activeTextBgnd,
  136.    inactiveTextFgnd, inactiveTextBgnd };
  137.  
  138. IWindow
  139.   &setColor(Attribute value, const IColor& color);
  140.  
  141. IColor 
  142.   color(Attribute value) const;
  143.  
  144. /*-------------------------------- TESTING   -----------------------------------
  145. | These functions provide means of testing the attributes of instances of      |
  146. | this class:                                                                  |
  147. |   isDisable - Queries if the window is disabled                              |
  148. |   isFocus   - Queries if the window has the focus                            |
  149. |   isShowing - Queries if the window is showing                               |
  150. |   isValid   - Queries if the window handle is valid                          |
  151. |   isVisible - Queries if the window is visible                               |
  152. ------------------------------------------------------------------------------*/
  153. Boolean 
  154.   isDisabled() const,
  155.   isFocus() const,
  156.   isShowing() const,
  157.   isValid() const,
  158.   isVisible() const;
  159.  
  160. /*----------------------------- WINDOW PAINTING -------------------------------
  161. | These functions provide means of update the window:                          |
  162.     repaint - 1. Invalidates and redraws the entire window
  163.               2. Invalidates and redraws a given window rectangle
  164.     update  - Forces the update of the window and its children
  165. ------------------------------------------------------------------------------*/
  166. IWindow
  167.   &repaint(),
  168.   &repaint(const IRectangle& invalidRect),
  169.   &update();
  170.  
  171. /*----------------------------- PARENT/OWNER -----------------------------------
  172. | These function provide means of update the window:                           |
  173. |   setParent - Changes the window parent                                      |
  174. |   setOwner  - Changes the window owner                                       |
  175. |   parent    - Returns the window's parent                                    |
  176. |   owner     - Returns the window's owner                                     |
  177. ------------------------------------------------------------------------------*/
  178. IWindow
  179.   &setParent(const IWindow* newParent),
  180.   &setOwner(const IWindow* newOwner);
  181.  
  182. const IWindow
  183.   *parent() const,
  184.   *owner() const;
  185.  
  186. /*-------------------------- STATIC OBJECT -------------------------------------
  187. | These functions provide means of getting instances of window object:         |
  188. |   desktopWindow - Returns the instance of object representing the            |
  189. |                   system desktop window                                      |
  190. |   objectWindow  - Returns the instance of object representing the            |
  191. |                   system object                                              |
  192. ------------------------------------------------------------------------------*/
  193. static const IWindow
  194.   *desktopWindow(),
  195.   *objectWindow();
  196.  
  197. /*------------------------- OBJECT DELETION ------------------------------------
  198. | These functions provide means of managing the window object:                 |
  199. |   setAutoDelete   - Causes the instance of this class to destruct when the   |
  200. |                     window handle is destroyed                               |
  201. |   setNoAutoDelete - Sets the state to prevent setAutoDelete function         |
  202. ------------------------------------------------------------------------------*/
  203. IWindow
  204.   &setAutoDelete(),
  205.   &setNoAutoDelete();
  206.  
  207. /*------------------------- EVENT HANDLER   ------------------------------------
  208. | These functions provide means of managing handlers of instances of this      |
  209. | class:                                                                       |
  210. |   addHandler       - Adds an instance of handler class to the window         |
  211. |   removeHandler    - Removes a previously added handler                      |
  212. |   dispatch         - Event dispatching functions                             |
  213. |   defaultProcedure - Invokes the subclassed default window procedure         |
  214. ------------------------------------------------------------------------------*/
  215. IWindow
  216.   &addHandler(IHandler* newHandler),
  217.   &removeHandler(IHandler* oldHandler);
  218.  
  219. Boolean 
  220.   dispatch(IEvent& event);
  221.  
  222. IWindow
  223.   &defaultProcedure(IEvent& evt);
  224.  
  225. /*------------------------- POP-UP VISUAL CUE ----------------------------------
  226. | These functions provide means for derived window subclasses to implement     |
  227. | the following:                                                               |
  228. |   drawPopUpMenuEmphasis  - Draws pop-up menu's owner visual cue when menu    |
  229. |                            is shown                                          |
  230. |   erasePopUpMenuEmphasis - Erases the pop-up menu's owner visual cue         |
  231. ------------------------------------------------------------------------------*/
  232. virtual void 
  233.   drawPopUpMenuEmphasis() {;} 
  234.  
  235. virtual void 
  236.   erasePopUpMenuEmphasis() {;}       
  237.  
  238. /*--------------------------- OBSELETE FUNCTION --------------------------------
  239. | These functions are obselete:                                                |
  240. |   ungrabPresSpace - see releasePresSpace                                     |
  241. |   startHandlingEvent - see similar function with one argument                |
  242. ------------------------------------------------------------------------------*/
  243. IWindow& ungrabPresSpace(IPresSpaceHandle hps) const
  244.            { releasePresSpace(hps);
  245.              return (IWindow&)this; }
  246. IWindow& startHandlingEvent(IWindowHandle windowHandle, void* windowPtr)
  247.          { return startHandlingEvent(windowHandle); }
  248.  
  249. protected:
  250. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  251. | There are one way to construct instances of this class:                      |
  252. |   1. default                                                                 |
  253. |     this initialize the object                                               |
  254. ------------------------------------------------------------------------------*/
  255.   IWindow();
  256.  
  257. virtual 
  258.   ~IWindow();
  259.  
  260. /*------------------------ STYLE IMPLEMENTATION --------------------------------
  261. | These functions are used to implement window style operations.               |
  262. |   style    - Returns an unsigned long masking bits representing the window's |
  263. |              style as defined by OS/2 Presentation Manager toolkit.          |
  264. |   setStyle - Sets the window style using the masking bits defined by         |
  265. |               OS/2 Presentation Manager toolkit.                             |
  266. ------------------------------------------------------------------------------*/
  267. unsigned long 
  268.   style() const;
  269.     virtual void setStyle(unsigned long style);
  270.  
  271. /*----------------------- EVENT HANDLING IMPLEMENTATION ------------------------
  272. | There functions provide means to handle events of instances of this class:   |
  273. |   startHandlingEvent - Starts processing events for the window. Typically,   |
  274. |                        an application does not need to invoke this function. |
  275. |   handleEvent        - Processes default window destroy event. Typically,    |
  276. |                        derived classes override this function to dispatch    |
  277. |                        event handling functions specific to this window      |
  278. |                        class. Note that events are only dispatched to this   |
  279. |                        virtual function, if no action is taken by handler    |
  280. |                        associated to the window.                             |
  281. ------------------------------------------------------------------------------*/
  282. IWindow
  283.   &startHandlingEvent(IWindowHandle windowHandle);
  284.  
  285. virtual Boolean 
  286.   handleWindowEvent(IEvent& evevt);
  287.  
  288. private:
  289. /*--------------------------------- PRIVATE ----------------------------------*/
  290. static unsigned long 
  291.   convertRGBAttribute(Attribute value);
  292.   IWindow(const IWindow&);
  293. IWindow& 
  294.   operator= (const IWindow&);
  295. IWINCALLBACK* 
  296.   pClDefWinProc;
  297. IWindowHandle 
  298.   wndhCl;
  299. unsigned long 
  300.   ulClFlag;
  301. ILHandlerSet* 
  302.   pcolLHandler;
  303. };
  304. #endif /* _IWINDOW_ */
  305.