home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / uicldd.zip / IWINDOW.HPP < prev    next >
Text File  |  1993-08-23  |  43KB  |  806 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:   I:/IBMCLASS/IBASEAPP/VCS/IWINDOW.HPV  $
  18. // 
  19. //    Rev 1.47   23 Aug 1993 14:30:28   FWBROWN
  20. // Updated descriptions of clipChildren and clipSiblibs styles.
  21. // 
  22. //    Rev 1.46   18 Aug 1993 12:41:56   law
  23. // Added functions required for direct manipulation.
  24. // 
  25. //    Rev 1.45   16 Aug 1993 17:39:26   FWBROWN
  26. // Updated the comments for IWindow, IWindow::ChildCursor, and 
  27. // IWindow::ExceptionFn to match the Reference book.
  28. // 
  29. //    Rev 1.44   12 Jul 1993 13:22:08   unknown
  30. // No change.
  31. // 
  32. //    Rev 1.43   13 May 1993 03:13:38   tsuji
  33. // Rename childFontChanged to fontPropogated.
  34. //
  35. //    Rev 1.42   09 May 1993 19:18:16   tsuji
  36. // Remove old versions of setLayoutDistorted, isLayoutDistorted.  Also
  37. // update the Layout flags.
  38. //
  39. //    Rev 1.41   27 Apr 1993 14:29:28   HARPERSP
  40. // Made IFileDialog and IFontDialog friends of IWindow.
  41. // This was lost when setDefaultProcedure() had to be re-put.
  42. //
  43. //    Rev 1.40   27 Apr 1993 01:55:42   BOBLOVE
  44. // Added new setLayoutDistorted support
  45. //
  46. //    Rev 1.39   27 Apr 1993 00:41:36   BOBLOVE
  47. // Added ExceptionFn dtor
  48. //
  49. //    Rev 1.38   26 Apr 1993 15:25:32   HARPERSP
  50. // Put setDefaultProcedure() on top of most recent revisions.
  51. // defaultPushbutton() and matchForMnemonic() updates had been lost.
  52. //
  53. //    Rev 1.37   26 Apr 1993 02:08:46   tsuji
  54. // P515, P535: Add defaultPushbutton() and matchForMnemonic()
  55. // functions for use primarily by ICanvas and ICanvasHandler.
  56. //
  57. //    Rev 1.36   23 Apr 1993 10:27:58   law
  58. // Added code to ensure destroyed handlers get detached from windows.
  59. //
  60. //    Rev 1.35   18 Apr 1993 22:12:42   BOBLOVE
  61. // Added new private "states"
  62. //
  63. //    Rev 1.34   18 Apr 1993 12:18:22   tsuji
  64. // P597: Add more words to color(), setColor().
  65. //
  66. //    Rev 1.33   15 Apr 1993 03:23:48   tsuji
  67. // P568: Add isTabStop function, change layoutDistorted functions to virtual.
  68. //
  69. //    Rev 1.32   12 Apr 1993 03:07:10   tsuji
  70. // P487: Move addHandler/removeHandler from public to protected.  Also
  71. // remove "ul" from send/post default values.
  72. //
  73. //    Rev 1.31   05 Apr 1993 17:24:50   BOBLOVE
  74. // Added optional color function that takes a defaultColor
  75. //
  76. //    Rev 1.30   08 Mar 1993 03:19:30   BOBLOVE
  77. // Doc change
  78. //
  79. //    Rev 1.29   05 Mar 1993 02:56:40   BOBLOVE
  80. // Added canvas sizing functions
  81. // Added send/postEvent(EventType)
  82. //
  83. *******************************************************************************/
  84. #ifndef _IVBASE_
  85.   #include <ivbase.hpp>
  86. #endif
  87.  
  88. // Forward declarations for other classes:
  89. class IColor;
  90. class IException;
  91. class IHandler;
  92. class IHandlerList;
  93. class IRectangle;
  94. class IString;
  95. class IDMItemProvider;
  96.  
  97. #ifndef  _IBITFLAG_
  98.   #include <ibitflag.hpp>
  99. #endif
  100.  
  101. #ifndef _IEVENT_
  102.   #include <ievent.hpp>
  103. #endif
  104.  
  105. #ifndef  _IHANDLE_
  106.   #include <ihandle.hpp>
  107. #endif
  108.  
  109. #ifndef _IPOINT_
  110.   #include <ipoint.hpp>
  111. #endif
  112.  
  113.  
  114. class IWindow : public IVBase {
  115. typedef IVBase
  116.   Inherited;
  117. /*******************************************************************************
  118. * The IWindow class is the base window class and provides behavior common to   *
  119. * all windows.  While this class contains behavior that requires the           *
  120. * existence of a presentation window, the presentation window itself must be   *
  121. * constructed by the subclass.                                                 *
  122. *                                                                              *
  123. * NOTE: You cannot construct members of this class directly.                   *
  124. *                                                                              *
  125. * Example:                                                                     *
  126. *                                                                              *
  127. *  The following example demonstrates the required behavior of the constructor *
  128. *  of an IWindow subclass, by actually using an IControl subclass.             *
  129. *                                                                              *
  130. *  //                                                                          *
  131. *  // Constructor to create a super control                                    *
  132. *  //                                                                          *
  133. *  SuperControl::SuperControl(unsigned long ulId,                              *
  134. *                             IWindow* pwndParent,                             *
  135. *                             IWindow* pwndOwner,                              *
  136. *                             const IRectangle& rectInit,                      *
  137. *                             Style efsStyle)                                  *
  138. *  {                                                                           *
  139. *  // Create the control using a call to Presentation Manager                  *
  140. *    IWindowHandle whSuperControl =                                            *
  141. *       WinCreateWindow(pwndParent->handle(),                                  *
  142. *                       WC_SUPERCONTROL, 0,                                    *
  143. *                       efsStyle.asUnsignedLong(),                             *
  144. *                       rectInit.left(), rectInit.bottom(),                    *
  145. *                       rectInit.width(), rectInit.height(),                   *
  146. *                       (pwndOwner==0)?0:pwndOwner->handle(),                  *
  147. *                       HWND_TOP, ulId, 0, 0);                                 *
  148. *                                                                              *
  149. *    if (whSuperControl == 0)                                                  *
  150. *    {                                                                         *
  151. *       // indicates an error so throw an exception                            *
  152. *    }                                                                         *
  153. *    // tell IWindow to start processing events for the window                 *
  154. *    startHandlingEvent(whSuperControl);                                       *
  155. *  }                                                                           *
  156. *                                                                              *
  157. *******************************************************************************/
  158. public:
  159.  
  160. /*-------------------------------- Destructor ----------------------------------
  161. | You cannot construct IWindow objects publicly. However, you can destroy an   |
  162. | IWindow subclass using the following virtual destructor.                     |
  163. ------------------------------------------------------------------------------*/
  164. virtual
  165.   ~IWindow     ( );
  166.  
  167. /*---------------------------------- Style -------------------------------------
  168. |  The following functions provide a means to set and query window styles:     |
  169. |                                                                              |
  170. |    Style - Nested class that provides static members that define the set of  |
  171. |            valid window styles.  For example, you could define an instance   |
  172. |            of the IWindow::Style class and initialize it like:               |
  173. |              IWindow::Style                                                  |
  174. |                style = visible | clipChildren | saveBits;                    |
  175. |            An object of this type is provided when the window is created. A  |
  176. |            customizable default is used if no styles are specified.  Once    |
  177. |            the object is constructed, you can use IWindow member functions   |
  178. |            to set or query the object's style.                               |
  179. |                                                                              |
  180. |            The declaration of the IWindow::Style nested class is generated   |
  181. |            by the INESTEDBITFLAGCLASSDEF0 macro.                             |
  182. |                                                                              |
  183. |  The valid window styles are:                                                |
  184. |    noStyle      - Sets all styles off.                                       |
  185. |    visible      - Causes the window to be visible.  In general, controls     |
  186. |                   are constructed as visible and frame windows as invisible. |
  187. |    disabled     - Specifies that keyboard and mouse input are no longer      |
  188. |                   dispatched to the window, preventing the window from       |
  189. |                   being used.                                                |
  190. |    clipChildren - Excludes the area occupied by the children of the window   |
  191. |                   when drawing in the window.  Child windows are always      |
  192. |                   "clipped" to their parent window.  When a parent window    |
  193. |                   is painted, the clipChildren style controls whether the    |
  194. |                   invalidated region of the parent window includes the area  |
  195. |                   occupied by its children, thus preventing a window from    |
  196. |                   painting over its child windows.                           |
  197. |    clipSiblings - Controls which sibling window is displayed on top when     |
  198. |                   multiple siblings are displayed.  Sibling windows are      |
  199. |                   windows that share the same parent window.  Assign the     |
  200. |                   clipSiblings style to the sibling window that should be    |
  201. |                   displayed on top of the other siblings, in Z-order.        |
  202. |    clipToParent - Restricts a window from painting over its parent window.   |
  203. |    saveBits     - Optimizes the painting of a window by saving the screen    |
  204. |                   image of the area under the window as a bit map, and then  |
  205. |                   using the bit map to redraw the window when necessary.     |
  206. |    synchPaint   - Synchronously repaints the window.  Without this style,    |
  207. |                   painting only occurs if there are no other events waiting  |
  208. |                   to be processed.                                           |
  209. ------------------------------------------------------------------------------*/
  210. INESTEDBITFLAGCLASSDEF0(Style, IWindow);
  211. static const Style
  212.   noStyle,
  213.   visible,
  214.   disabled,
  215.   clipChildren,
  216.   clipSiblings,
  217.   clipToParent,
  218.   saveBits,
  219.   synchPaint;
  220.  
  221. /*------------------------------ Related Types ---------------------------------
  222. | The following enumeration is defined:                                        |
  223. |   EventType - Enumeration that specifies windowing system message            |
  224. |               identifiers.  Valid values are:                                |
  225. |                 command       - The event type is user command.              |
  226. |                 systemCommand - The event type is system command.            |
  227. |                 help          - The event type is help.                      |
  228. |                 character     - The event type is key character.             |
  229. ------------------------------------------------------------------------------*/
  230. enum EventType { command=1, systemCommand, help, character };
  231.  
  232. /*---------------------------- Window Positioning ------------------------------
  233. | These functions are used to set and query the size and position of windows:  |
  234. |   moveTo     - Changes the position of the window.                           |
  235. |   sizeTo     - Changes the size of the window.                               |
  236. |   moveSizeTo - Changes the position and size of the window.                  |
  237. |   position   - Returns the window position.                                  |
  238. |   size       - Returns the size of the window in window coordinates.                               |
  239. |                NOTE: This function will return ISize(0,0) for a frame        |
  240. |                      window if it is constructed using the shell position    |
  241. |                      and the window has not been shown.                      |
  242. |   rect       - Returns a rectangle that represents the position and size of  |
  243. |                the window.                                                   |
  244. |                NOTE: This function will return IRectangle(0,0,0,0) for a     |
  245. |                      frame window if it is constructed using the shell       |
  246. |                      position and the window has not been shown.             |
  247. ------------------------------------------------------------------------------*/
  248. virtual IWindow
  249.  &moveTo         ( const IPoint& aPoint ),
  250.  &sizeTo         ( const ISize& newSize ),
  251.  &moveSizeTo     ( const IRectangle& aRectangle );
  252.  
  253. IPoint
  254.   position       ( ) const;
  255.  
  256. ISize
  257.   size           ( ) const;
  258.  
  259. IRectangle
  260.   rect           ( ) const;
  261.  
  262. /*-------------------------------- Accessors -----------------------------------
  263. | These functions provide a means of getting and setting the accessible        |
  264. | attributes of instances of this class:                                       |
  265. |   enable           - Enables the window to accept keyboard and mouse input.  |
  266. |   disable          - Prevents keyboard and mouse input from being sent to    |
  267. |                      the window.                                             |
  268. |   isDisabled       - Returns true if the window is not sent mouse and        |
  269. |                      keyboard input.                                         |
  270. |   setFocus         - Sets the input focus to the window.                     |
  271. |   hasFocus         - Returns true if the window has the input focus.         |
  272. |   setParent        - Changes the window parent.                              |
  273. |   parent           - Returns the window's parent.                            |
  274. |   setOwner         - Changes the window owner.                               |
  275. |   owner            - Returns the window's owner.                             |
  276. |   isValid          - Returns true if this object represents a valid          |
  277. |                      Presentation Manager window.  It returns false if the   |
  278. |                      window has yet to be created or has already been        |
  279. |                      destroyed.                                              |
  280. |   isFrameWindow    - Returns true if this object represents a frame window.  |
  281. |   desktopWindow    - Returns the instance of the object that represents the  |
  282. |                      system desktop window.                                  |
  283. |   objectWindow     - Returns the instance of the object that represents the  |
  284. |                      system object.                                          |
  285. |   handle           - Returns the window handle.                              |
  286. |   windowWithHandle - Static function to return the IWindow instance in the   |
  287. |                      current thread for the passed window handle.            |
  288. |   windowWithId     - Static function to return the IWindow instance in the   |
  289. |                      current thread for the ID and owner.                    |
  290. |   id               - Returns the window ID.                                  |
  291. |   messageQueue     - Returns the handle for the window's message queue.      |
  292. ------------------------------------------------------------------------------*/
  293. virtual IWindow
  294.  &enable             ( Boolean        enableWindow=true ),
  295.  &disable            ( ),
  296.  &setFocus           ( ),
  297.  &setParent          ( const IWindow* newParent ),
  298.  &setOwner           ( const IWindow*  newOwner );
  299.  
  300. IWindow
  301.  *parent             ( ) const,
  302.  *owner              ( ) const;
  303.  
  304. Boolean
  305.   isDisabled         ( ) const,
  306.   hasFocus           ( ) const,
  307.   isValid            ( ) const,
  308.   isFrameWindow      ( ) const;
  309.  
  310. static IWindow
  311.  *desktopWindow      ( ),
  312.  *objectWindow       ( );
  313.  
  314. virtual IWindowHandle
  315.   handle             ( ) const;
  316.  
  317. static IWindow
  318.  *windowWithHandle   ( const IWindowHandle& windowHandle ),
  319.  *windowWithId       ( unsigned long        id,
  320.                        const IWindow*       owner );
  321.  
  322. unsigned long
  323.   id                 ( ) const;
  324.  
  325. IMessageQueueHandle
  326.   messageQueue       ( ) const;
  327.  
  328. /*----------------------------- Event Send/Post --------------------------------
  329. | These functions provide a simplified means of sending or posting an IEvent   |
  330. | to a window:                                                                 |
  331. |   postEvent - Posts an event constructed from the arguments to the window.   |
  332. |               If an EventType is used, an event will be constructed with     |
  333. |               the appropriate message identifier.                            |
  334. |   sendEvent - Sends an event constructed from the arguments to the window.   |
  335. |               If an EventType is used, an event will be constructed with     |
  336. |               the appropriate message identifier.                            |
  337. ------------------------------------------------------------------------------*/
  338. void
  339.   postEvent ( unsigned long           eventId,
  340.               const IEventParameter1 &parm1 = 0,
  341.               const IEventParameter2 &parm2 = 0 ) const;
  342.  
  343. IEventResult
  344.   sendEvent ( unsigned long           eventId,
  345.               const IEventParameter1 &parm1 = 0,
  346.               const IEventParameter2 &parm2 = 0 ) const;
  347.  
  348. void
  349.   postEvent ( EventType               eventType,
  350.               const IEventParameter1 &parm1 = 0,
  351.               const IEventParameter2 &parm2 = 0 ) const;
  352.  
  353. IEventResult
  354.   sendEvent ( EventType               eventType,
  355.               const IEventParameter1 &parm1 = 0,
  356.               const IEventParameter2 &parm2 = 0 ) const;
  357.  
  358. /*----------------------------- Window Painting --------------------------------
  359. | These functions are used in displaying a window and determining the          |
  360. | visibility of a window.                                                      |
  361. |   show               - Makes the window visible.                             |
  362. |   hide               - Hides the window.                                     |
  363. |   refresh            - Has the following implementations:                    |
  364. |                          - Invalidates and redraws the entire window.  If    |
  365. |                            the refreshChildren argument is true, the         |
  366. |                            children are updated as well.                     |
  367. |                          - Invalidates and redraws a given window rectangle. |
  368. |   showSourceEmphasis - Called by a pop-up menu handler to notify the window  |
  369. |                        to draw pop-up menu emphasis.  The default behavior   |
  370. |                        of IWindow is to do nothing.                          |
  371. |   hideSourceEmphasis - Called by a pop-up menu handler to notify the window  |
  372. |                        to remove pop-up menu emphasis.  The default          |
  373. |                        behavior of IWindow is to do nothing.                 |
  374. |   isVisible          - Returns true if the windows style is visible.         |
  375. |                        NOTE: A window can have a style of visible and yet    |
  376. |                              not be showing if it is covered by another      |
  377. |                              window.                                         |
  378. |   isShowing          - Returns true if any part of the window is showing.    |
  379. |                        NOTE: A window can be visible and yet not be showing  |
  380. |                              if it is covered by another window.             |
  381. |   presSpace          - Acquires and returns the presentation space handle    |
  382. |                        for the window.                                       |
  383. |   releasePresSpace   - Releases the window's presentation space handle.      |
  384. |   setLayoutDistorted - Indicates that changes have occurred in the window    |
  385. |                        that will cause the layout of the window in a canvas  |
  386. |                        to be updated.                                        |
  387. |   isLayoutDistorted  - Determines whether changes have been made in a        |
  388. |                        window that will require updating the layout of the   |
  389. |                        window in a canvas.                                   |
  390. |   setMinimumSize     - Sets the minimum allowable size of the window.  In    |
  391. |                        the library, this applies to windows on a canvas      |
  392. |                        only.                                                 |
  393. |   minimumSize        - Returns the minimum allowable size set by the user's  |
  394. |                        class.                                                |
  395. ------------------------------------------------------------------------------*/
  396. virtual IWindow
  397.  &show                     ( Boolean           showWindow=true ),
  398.  &hide                     ( ),
  399.  &refresh                  ( Boolean           refreshChildren=false ),
  400.  &refresh                  ( const IRectangle& invalidRectangle ),
  401.  &showSourceEmphasis       ( Boolean           show=true ),
  402.  &hideSourceEmphasis       ( );
  403.  
  404. Boolean
  405.   isVisible                ( ) const,
  406.   isShowing                ( ) const;
  407.  
  408. IPresSpaceHandle
  409.   presSpace                ( ) const;
  410.  
  411. void
  412.   releasePresSpace         ( const IPresSpaceHandle& aPresentationSpaceHandle ) const;
  413.  
  414. enum Layout { windowCreated=1, colorChanged=2, sizeChanged=4,
  415.               minimumSizeChanged=8, childMinimumSizeChanged=16,
  416.               fontChanged=32, fontPropogated=64, layoutChanged=128,
  417.               immediateUpdate=256 };
  418. virtual IWindow
  419.  &setLayoutDistorted       ( unsigned long layoutAttributeOn,
  420.                              unsigned long layoutAttributeOff );
  421.  
  422. virtual Boolean
  423.   isLayoutDistorted        ( unsigned long layoutAttribute ) const;
  424.  
  425. IWindow
  426.  &setMinimumSize           ( const ISize& sizMin );
  427. ISize
  428.   minimumSize              ( ) const;
  429.  
  430. /*------------------------- Object Deletion ------------------------------------
  431. | These functions provide a means of managing the window object:               |
  432. |   setAutoDeleteObject  - Determines whether the IWindow instance should be   |
  433. |                          deleted when the presentation window is destroyed.  |
  434. |                          The deletion will occur when the Presentation       |
  435. |                          Manager dispatches a destroy event to the window.   |
  436. |                          By default, the instance is not deleted.            |
  437. |   setAutoDestroyWindow - Determines whether the presentation window should   |
  438. |                          be destroyed when the IWindow instance is deleted.  |
  439. |                          This is used in cases where an IWindow is a         |
  440. |                          wrapper for a presentation window whose creation    |
  441. |                          and destruction are handled outside the C++ object. |
  442. |   isAutoDeleteObject   - Returns true if the window instance will be         |
  443. |                          deleted when a destroy event is dispatched to the   |
  444. |                          window.                                             |
  445. |   isAutoDestroyWindow  - Returns true if the presentation window will be     |
  446. |                          destroyed when the window instance is deleted.      |
  447. ------------------------------------------------------------------------------*/
  448. IWindow
  449.  &setAutoDeleteObject      ( Boolean autoDelete=true ),
  450.  &setAutoDestroyWindow     ( Boolean autoDestroy=false );
  451.  
  452. Boolean
  453.   isAutoDeleteObject       ( ) const,
  454.   isAutoDestroyWindow      ( ) const;
  455.  
  456. /*------------------------------ Drag/Drop Support -----------------------------
  457. | These functions provide means of getting and setting the accessible          |
  458. | attributes of instances of this class:                                       |
  459. |   itemProvider    - Returns pointer to drag item provider for this window    |
  460. |   setItemProvider - Sets pointer to drag item provider for this window.      |
  461. ------------------------------------------------------------------------------*/
  462. IDMItemProvider
  463.  *itemProvider ( ) const;
  464.  
  465. IWindow
  466.  &setItemProvider ( IDMItemProvider *dragProvider );
  467.  
  468. class ChildCursor : public IVBase {
  469. /*******************************************************************************
  470. * The IWindow::ChildCursor class is a nested cursor class used to iterate      *
  471. * over the children of any window.  The children are accessed in Z-order,      *
  472. * from top to bottom.                                                          *
  473. *                                                                              *
  474. * Example:                                                                     *
  475. *   // Iterate over children of frame...                                       *
  476. *   IFrameWindow                                                               *
  477. *     frame;                                                                   *
  478. *   IFrameWindow::ChildCursor                                                  *
  479. *     cursor ( frame );                                                        *
  480. *   for ( cursor.setToFirst(); cursor.isValid(); cursor.setToNext() )          *
  481. *     { // Do something with each child...                                     *
  482. *     IWindowHandle                                                            *
  483. *       child = frame.childAt( cursor );                                       *
  484. *     ...                                                                      *
  485. *     }                                                                        *
  486. *******************************************************************************/
  487. public:
  488. /*-------------------------- Constructor/Destructor ----------------------------
  489. | You can construct objects of this class from a reference to the window       |
  490. | whose child windows will be iterated over.                                   |
  491. ------------------------------------------------------------------------------*/
  492.   ChildCursor ( IWindow &parent );
  493.  
  494.  ~ChildCursor ( );
  495.  
  496. /*-------------------------------- Overrides -----------------------------------
  497. | The nested ChildCursor class overrides the following functions to            |
  498. | provide the appropriate cursor behavior:                                     |
  499. |   setToFirst - Resets the cursor position to the first child window (in      |
  500. |                Z-order).                                                     |
  501. |   setToNext  - Advances the cursor position to the next child window (in     |
  502. |                Z-order).                                                     |
  503. |   isValid    - Returns true if the cursor is in a valid area.                |
  504. |   invalidate - Marks the cursor as invalid.                                  |
  505. ------------------------------------------------------------------------------*/
  506. virtual Boolean
  507.   setToFirst ( ),
  508.   setToNext  ( ),
  509.   isValid    ( ) const;
  510.  
  511. virtual void
  512.   invalidate ( );
  513.  
  514. private:
  515. /*--------------------------------- Private ----------------------------------*/
  516. friend class IWindow;
  517. IEnumHandle
  518.   enumHandle;
  519. IWindowHandle
  520.   windowHandle,
  521.   parentHandle;
  522. ChildCursor
  523.  &operator =  ( const ChildCursor & );
  524.   ChildCursor ( const ChildCursor & );
  525. }; // IWindow::ChildCursor
  526.  
  527. /*------------------------------ ChildCursor Support ---------------------------
  528. |   childAt - Returns the window handle of the child window at the current     |
  529. |             position of the argument cursor.                                 |
  530. ------------------------------------------------------------------------------*/
  531. IWindowHandle
  532.   childAt ( const ChildCursor &aCursor ) const;
  533.  
  534. /*------------------------------ Canvas Support --------------------------------
  535. | These functions are used by the canvas classes to provide dialog-like        |
  536. | behavior (minimal implementations are provided here):                        |
  537. |   isTabStop         - Returns true if the user can tab to the window.        |
  538. |   defaultPushbutton - Returns the first child window that is a default push  |
  539. |                       button, if one exists.                                 |
  540. |   matchForMnemonic  - Returns the first child window that uses the           |
  541. |                       specified character as a mnemonic.                     |
  542. ------------------------------------------------------------------------------*/
  543. virtual Boolean
  544.   isTabStop          ( ) const;
  545.  
  546. virtual IWindowHandle
  547.   defaultPushbutton  ( ) const,
  548.   matchForMnemonic   ( unsigned short character ) const;
  549.  
  550. /*------------------------------ Miscellaneous ---------------------------------
  551. | This function is used to map coordinates from one window to another:         |
  552. |   mapPoint - Static function to map a point from one window's coordinate     |
  553. |              space to another's, such as mapping from screen coordinates to  |
  554. |              window coordinates.                                             |
  555. ------------------------------------------------------------------------------*/
  556. static IPoint
  557.   mapPoint ( const IPoint        &aPoint,
  558.              const IWindowHandle &from,
  559.              const IWindowHandle &to    );
  560.  
  561. /*------------------------------- Diagnostics ----------------------------------
  562. | The following functions are used to output information for the window:       |
  563. |   asString    - Returns a string that contains the window handle and ID.     |
  564. |   asDebugInfo - Returns a string that contains detailed information about    |
  565. |                 the window, including the information provided by asString.  |
  566. ------------------------------------------------------------------------------*/
  567. virtual IString
  568.   asString    ( ) const,
  569.   asDebugInfo ( ) const;
  570.  
  571.  
  572. class ExceptionFn : public IVBase {
  573. typedef IVBase
  574.   Inherited;
  575. /*******************************************************************************
  576. * The IWindow::ExceptionFn nested class is used to process exceptions that     *
  577. * occur when events are dispatched by the IWindow dispatcher.                  *
  578. *                                                                              *
  579. * Example:                                                                     *
  580. *                                                                              *
  581. * class MyFrameWindow : public IFrameWindow, public IWindow::ExceptionFn {     *
  582. * virtual Boolean                                                              *
  583. *   handleException (IException& exception, IEvent& event) {                   *
  584. *      return true;     // ignore the exception and continue dispatching       *
  585. * };                                                                           *
  586. *                                                                              *
  587. * MyFrameWindow :: MyFrameWindow () {                                          *
  588. *   setExceptionFunction(this);                                                *
  589. *                                                                              *
  590. *                                                                              *
  591. *******************************************************************************/
  592. public:
  593.  ~ExceptionFn ( );
  594. /*--------------------------- Exception Processing -----------------------------
  595. | The following function is used to process C++ exceptions in the IWindow      |
  596. | dispatcher:                                                                  |
  597. |   handleException - If an exception object is registered with IWindow, this  |
  598. |                     function will be called when an uncaught exception       |
  599. |                     occurs while dispatching events.  This function should   |
  600. |                     return true if the exception situation was handled and   |
  601. |                     it is safe to continue dispatching events.  If false is  |
  602. |                     returned, the exception will be thrown again.            |
  603. ------------------------------------------------------------------------------*/
  604. virtual Boolean
  605.   handleException         ( IException& dispatcherException,
  606.                             IEvent&     exceptionEvent     ) = 0;
  607. }; // IWindow::ExceptionFn
  608.  
  609.  
  610. /*----------------------------- Exception Processing ---------------------------
  611. | The following functions are used to process C++ exceptions in the IWindow    |
  612. | dispatcher:                                                                  |
  613. |   setExceptionFunction - Stores an IWindow::ExceptionFn object to be called  |
  614. |                          when an uncaught exception is detected while        |
  615. |                          dispatching window events.  If an object has        |
  616. |                          already been registered, it is returned;            |
  617. |                          otherwise, 0 is returned.                           |
  618. |   exceptionFunction    - Returns a pointer to the current exception          |
  619. |                          function, or 0 if one has not been registered.      |
  620. |   handleException      - Called when an exception is detected during the     |
  621. |                          dispatch of an event.  The default behavior is to   |
  622. |                          determine if an IWindow::ExceptionFn object has     |
  623. |                          been registered and call it.  Otherwise, false is   |
  624. |                          returned and the exception is thrown again.         |
  625. ------------------------------------------------------------------------------*/
  626. static IWindow::ExceptionFn
  627.  *setExceptionFunction    ( IWindow::ExceptionFn* exceptionObject ),
  628.  *exceptionFunction       ( );
  629.  
  630. virtual Boolean
  631.   handleException         ( IException& dispatcherException,
  632.                             IEvent&     exceptionEvent     );
  633.  
  634. protected:
  635. /*------------------------------ Implementation --------------------------------
  636. | This function provides utilities used to implement this class:               |
  637. |   addHandler      - Adds an instance of a handler class to the window.       |
  638. |   removeHandler   - Removes a previously added handler.                      |
  639. |   setColor        - Sets the window area to the indicated color.  The        |
  640. |                     window area is identified by a system-defined            |
  641. |                     presentation parameter value.                            |
  642. |   setStyle        - Sets the window style using the masking bits defined by  |
  643. |                     the OS/2 Presentation Manager Toolkit.                   |
  644. |   color           - Returns the color value of the window area, or the       |
  645. |                     passed default if no color for the area has been set.    |
  646. |                     The window area is identified by a system-defined        |
  647. |                     presentation parameter value.                            |
  648. |   style           - Returns an unsigned long representing the window's       |
  649. |                     style, as defined by the OS/2 Presentation Manager       |
  650. |                     Toolkit.                                                 |
  651. |   isPrimaryWindow - Returns true if this window has no owner and the parent  |
  652. |                     is the desktop window.                                   |
  653. |   windowUShort    - Returns the given window word (as an unsigned short).    |
  654. |   windowULong     - Returns the given window word (as an unsigned long).     |
  655. |   setWindowData   - Sets the given window word (as an unsigned short or      |
  656. |                     unsigned long).  The result indicates whether it was     |
  657. |                     successful.                                              |
  658. ------------------------------------------------------------------------------*/
  659. IWindow
  660.  &addHandler      ( IHandler* newHandler ),
  661.  &removeHandler   ( IHandler* oldHandler );
  662.  
  663. IWindow
  664.  &setColor        ( unsigned long colorArea,
  665.                     const IColor& color    );
  666.  
  667. virtual IWindow
  668.  &setStyle        ( unsigned long style );
  669.  
  670. IColor
  671.   color           ( unsigned long colorArea ) const,
  672.   color           ( unsigned long colorArea,
  673.                     const IColor& defaultColor ) const;
  674.  
  675. unsigned long
  676.   style           ( ) const;
  677.  
  678. Boolean
  679.   isPrimaryWindow ( ) const;
  680.  
  681. unsigned short
  682.   windowUShort    ( long index ) const;
  683.  
  684. unsigned long
  685.   windowULong     ( long index ) const;
  686.  
  687. IWindow
  688.  &setWindowData   ( long index, unsigned short ushort ),
  689.  &setWindowData   ( long index, unsigned long  ulong  );
  690.  
  691. /*------------------------------- Constructor ----------------------------------
  692. | The only way to construct instances of this class is by using the protected  |
  693. | default constructor, which initializes the IWindow data.  The presentation   |
  694. | window associated with a window is created by an IWindow subclass.           |
  695. ------------------------------------------------------------------------------*/
  696.   IWindow  ( );
  697.  
  698. /*---------------------------------- Layout ------------------------------------
  699. | The following function is used return the layout size:                       |
  700. |   calcMinimumSize - Returns the recommended minimum size for this IWindow    |
  701. |                     object.  This size is used by the canvas layout routine. |
  702. |                     A default operation returns the minimum size set by      |
  703. |                     users.  The size is based on the text and the current    |
  704. |                     font setting.                                            |
  705. ------------------------------------------------------------------------------*/
  706. virtual ISize
  707.   calcMinimumSize    ( ) const;
  708.  
  709. /*---------------------- Event Handling Implementation -------------------------
  710. | These functions provide the implementation of the event handling mechanism:  |
  711. |   startHandlingEvent  - Starts processing events for the window.  This is a  |
  712. |                         combination of subclassing the window procedure and  |
  713. |                         storing the window in the current thread's           |
  714. |                         collection of windows.  You can only invoke this     |
  715. |                         function once per window, typically during           |
  716. |                         construction of the window.                          |
  717. |   addToWindowSet      - Adds a window to the current thread's collection of  |
  718. |                         windows.  A valid window handle must be provided.    |
  719. |   removeFromWindowSet - Removes a window from the current thread's           |
  720. |                         collection of windows.                               |
  721. |   dispatch            - Dispatches events to the handlers associated with a  |
  722. |                         window.  If the event is not processed by a handler  |
  723. |                         or no handlers exist for the window,                 |
  724. |                         defaultProcedure is called to process the event.     |
  725. |   defaultProcedure    - Provides default processing behavior for a window    |
  726. |                         event.  This function calls the window procedure     |
  727. |                         that was returned from the window subclass during    |
  728. |                         the call to startHandlingEvent.                      |
  729. |   deleteIsInProcess   - Returns true if either the IWindow instance          |
  730. |                         destructor has been called or the presentation       |
  731. |                         window is being destroyed.                           |
  732. ------------------------------------------------------------------------------*/
  733. IWindow
  734.  &startHandlingEvent   ( const IWindowHandle& windowHandle );
  735.  
  736. static void
  737.   addToWindowSet       ( IWindow*             window,
  738.                          const IWindowHandle& windowHandle ),
  739.   removeFromWindowSet  ( IWindow*             window );
  740.  
  741. Boolean
  742.   dispatch             ( IEvent& event );
  743.  
  744. IWindow
  745.  &defaultProcedure     ( IEvent& event );
  746.  
  747. Boolean
  748.   deleteIsInProcess    ( ) const;
  749.  
  750. private:
  751. /*--------------------------------- Private ----------------------------------*/
  752. /* IWindow Flags */
  753. enum  State { autoDeleteObject=1, autoDestroyWindow=2, deleteInProcess=4,
  754.               primaryWindow=8, addedToList=16, dispatchInProcess=32,
  755.               needsDelete=64 };
  756. IWindow
  757.  &setDeleteInProcess  ( ),
  758.  &cleanUp             ( );
  759.  
  760. // setDefaultProcedure() is used by IFileDialog and IFontDialog
  761. // since they can't use startHandlingEvent().
  762. // These two classes are granted friendship below.
  763.  
  764. IWinProc
  765.  *setDefaultProcedure ( IWinProc *newDefProc );
  766.  
  767. static void
  768.   cleanUpHandler      ( IHandler & );
  769.  
  770. IWindow               ( const IWindow& );
  771. IWindow
  772.  &operator=           ( const IWindow& );
  773.  
  774. IWinProc
  775.  *pClDefWinProc;
  776. unsigned long
  777.   wndhCl,
  778.   ulClId,
  779.   ulClState,
  780.   ulClLayoutChange;
  781. IHandlerList*
  782.   pcolHandler;
  783. ISize
  784.   sizClMin;
  785.  
  786. static IWindow::ExceptionFn
  787.  *pexcClCurrent;
  788.  
  789. /* friend functions */
  790. friend void* _System _pfnwpICWinProc ( unsigned long hwnd, unsigned long ulMsg, void* mp1, void* mp2 );
  791. friend unsigned long const& key ( IWindow* const& pwin );
  792.  
  793. /* friend classes */
  794. friend class IHandler;
  795. friend class IFileDialog;
  796. friend class IFontDialog;
  797.  
  798. }; // IWindow
  799.  
  800. /*----------------------------- Inline Functions -----------------------------*/
  801. #ifndef I_NO_INLINES
  802.   #include <iwindow.inl>
  803. #endif
  804.  
  805. #endif /* _IWINDOW_ */
  806.