home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / ISETCV.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  26KB  |  416 lines

  1. #ifndef _ISETCV_
  2.   #define _ISETCV_
  3. /*******************************************************************************
  4. * FILE NAME: isetcv.hpp                                                        *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     ISetCanvas - This canvas class arranges its child windows in row or      *
  9. *                  column decks.                                               *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   Licensed Materials - Property of IBM                                       *
  13. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  14. *   All Rights Reserved                                                        *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. * CHANGE ACTIVITY:                                                             *
  19. *******************************************************************************/
  20. #ifndef _ICANVAS_
  21.   #include <icanvas.hpp>
  22. #endif
  23.  
  24. #ifndef _IPOINT_
  25.   #include <ipoint.hpp>
  26. #endif
  27. #ifndef _IRECT_
  28.   #include <irect.hpp>
  29. #endif
  30.  
  31. /*----------------------------------------------------------------------------*/
  32. /* Align classes on four byte boundary.                                       */
  33. /*----------------------------------------------------------------------------*/
  34. #pragma pack(4)
  35.  
  36. // Forward declarations for other classes:
  37. class IColor;
  38. class ISetCanvasObject;
  39. class IString;
  40.  
  41.  
  42. class ISetCanvas : public ICanvas {
  43. typedef ICanvas
  44.   Inherited;
  45. /*******************************************************************************
  46. * The ISetCanvas class is a window that organizes its child windows in row or  *
  47. * column decks.  "Deck" is the direction-independent term for a line of child  *
  48. * windows in a set canvas.  A horizontal deck is equivalent to a row and a     *
  49. * vertical deck is equivalent to a column.                                     *
  50. *                                                                              *
  51. * An ISetCanvas can hold more than one deck of child windows, but all the      *
  52. * decks must have the same orientation.  The decks must all be either          *
  53. * horizontal or vertical.  This class is designed to arrange fixed-size child  *
  54. * windows of similar size, such as a row of push buttons or a group of radio   *
  55. * buttons, because child windows are divided among multiple decks evenly by    *
  56. * number rather than size.  ISetCanvas also sizes and positions its child      *
  57. * windows based on their minimum sizes (see IWindow::minimumSize and           *
  58. * IWindow::calcMinimumSize) instead of the size of the canvas.                 *
  59. *                                                                              *
  60. * The ISetCanvas class provides a number of alignment and packing options to   *
  61. * allow for better control of how child windows are positioned.                *
  62. *                                                                              *
  63. * Example:                                                                     *
  64. *   ISetCanvas scvPushButtons(0, parent, owner);                               *
  65. *   scvPushButtons.setDeckOrientation(ISetCanvas::horizontal);                 *
  66. *       // add controls to the set canvas by making them child windows         *
  67. *   IPushButton pbApply(ID_APPLY, &scvPushButtons, &scvPushButtons,            *
  68. *                       IRectangle(),                                          *
  69. *                       IPushButton::classDefaultStyle |                       *
  70. *                         IPushButton::defaultButton |                         *
  71. *                         IControl::group | IControl::tabStop);                *
  72. *   IPushButton pbReset(ID_RESET, &scvPushButtons, &scvPushButtons);           *
  73. *   IPushButton pbUndo(ID_UNDO, &scvPushButtons, &scvPushButtons);             *
  74. *   IPushButton pbCancel(SC_CLOSE, &scvPushButtons, &scvPushButtons,           *
  75. *                        IRectangle(),                                         *
  76. *                        IPushButton::classDefaultStyle |                      *
  77. *                          IPushButton::systemCommand);                        *
  78. *******************************************************************************/
  79. public:
  80. class Style;                  // forward declaration for nested class
  81.  
  82. /*-------------------------- Constructor/Destructor ----------------------------
  83. | You can construct instances of this class by creating a set canvas window    |
  84. | with the specified window ID, parent window, owner window, rectangle, and    |
  85. | style.                                                                       |
  86. ------------------------------------------------------------------------------*/
  87.   ISetCanvas  ( unsigned long id,
  88.                 IWindow* parent,
  89.                 IWindow* owner,
  90.                 const IRectangle& initial = IRectangle(),
  91.                 const Style& style = defaultStyle() );
  92. virtual
  93.  ~ISetCanvas  ( );
  94.  
  95. /*---------------------------------- Style -------------------------------------
  96. | The following functions provide a means to set and query styles for          |
  97. | ISetCanvas objets:                                                           |
  98. |                                                                              |
  99. |   Style - Nested class that provides static members that define the set of   |
  100. |           valid styles for ISetCanvas objects.  These styles can be used in  |
  101. |           conjunction with the styles defined by the nested classes          |
  102. |           ICanvas::Style and IWindow::Style.  For example, you could         |
  103. |           define an instance of the ISetCanvas::Style class and initialize   |
  104. |           it like:                                                           |
  105. |             ISetCanvas::Style style = ISetCanvas::verticalDecks |            |
  106. |                                       ISetCanvas::packExpanded |             |
  107. |                                       ISetCanvas::centerAlign |              |
  108. |                                       IWindow::visible;                      |
  109. |           An object of this type is provided when the ISetCanvas objet is    |
  110. |           created.  A customizable default is used if no styles are          |
  111. |           specified.  Once the object is constructed, ISetCanvas, ICanvas,   |
  112. |           and IWindow member functions can be used to set or query the       |
  113. |           object's style.                                                    |
  114. |                                                                              |
  115. |           The declaration of the ISetCanvas::Style nested class is           |
  116. |           generated by the INESTEDBITFLAGCLASSDEF2 macro.                    |
  117. |                                                                              |
  118. | The valid ISetCanvas object styles are:                                      |
  119. |   classDefaultStyle   - Original default style for this class, which is      |
  120. |                         horizontalDecks | packTight | leftAlign | topAlign   |
  121. |                         | IWindow::visible.                                  |
  122. |   horizontalDecks     - Child windows are organized in rows.  Multiple rows  |
  123. |                         are arranged from top to bottom.  (This style        |
  124. |                         cannot be specified with verticalDecks.)             |
  125. |   verticalDecks       - Child windows are organized in columns.  Multiple    |
  126. |                         columns are arranged from left to right.  (This      |
  127. |                         style cannot be specified with horizontalDecks.)     |
  128. |   packTight           - Child windows are sized to their minimum size and    |
  129. |                         are separated within a deck by the pad amount only.  |
  130. |                         (This style cannot be specified with packEven or     |
  131. |                         packExpanded.)                                       |
  132. |   packEven            - Child windows are sized to their minimum size and    |
  133. |                         spaced so that corresponding windows in each deck    |
  134. |                         are aligned.  This gives the appearance of their     |
  135. |                         being arranged in both rows and columns.  Child      |
  136. |                         windows within a deck can be separated by more than  |
  137. |                         the pad amount as a result.  (This style cannot be   |
  138. |                         specified with packTight or packExpanded.)           |
  139. |   packExpanded        - Similar to packEven, except that the child windows   |
  140. |                         are grown rather than being spaced by more than the  |
  141. |                         pad amount.  All child windows are sized to be the   |
  142. |                         same as the largest child window.  (This style       |
  143. |                         cannot be specified with packTight or packEven.)     |
  144. |   leftAlign           - Child windows are left-aligned.  (This style is      |
  145. |                         ignored if it is used with both packTight and        |
  146. |                         horizontalDecks.  It is also ignored if it is used   |
  147. |                         with packExpanded, and cannot be specified with      |
  148. |                         rightAlign or centerAlign.)                          |
  149. |   rightAlign          - Child windows are right-aligned.  (This style is     |
  150. |                         ignored if it is used with both packTight and        |
  151. |                         horizontalDecks.  It is also ignored if it is used   |
  152. |                         with packExpanded, and cannot be specified with      |
  153. |                         leftAlign or centerAlign.)                           |
  154. |   centerAlign         - Child windows are horizontally-centered.  (This      |
  155. |                         style is ignored if it is used with both packTight   |
  156. |                         and horizontalDecks.  It is also ignored if it is    |
  157. |                         used with packExpanded, and cannot be specified      |
  158. |                         with leftAlign or rightAlign.)                       |
  159. |   topAlign            - Child windows are top-aligned.  (This style is       |
  160. |                         ignored if it is used with both packTight and        |
  161. |                         verticalDecks.  It is also ignored if it is used     |
  162. |                         with packExpanded, and cannot be specified with      |
  163. |                         bottomAlign or centerVerticalAlign.)                 |
  164. |   bottomAlign         - Child windows are bottom-aligned.  (This style is    |
  165. |                         ignored if it is used with both packTight and        |
  166. |                         verticalDecks.  It is also ignored if it is used     |
  167. |                         with packExpanded, and cannot be specified with      |
  168. |                         topAlign or centerVerticalAlign.)                    |
  169. |   centerVerticalAlign - Child windows are vertically-centered.  (This style  |
  170. |                         is ignored if it is used with both packTight and     |
  171. |                         verticalDecks.  It is also ignored if it is used     |
  172. |                         with packExpanded, and cannot be specified with      |
  173. |                         topAlign or bottomAlign.)                            |
  174. |                                                                              |
  175. | The following functions provide a means of getting and setting the default   |
  176. | style for this class:                                                        |
  177. |   defaultStyle    - Returns the current default style.  This is the same as  |
  178. |                     classDefaultStyle unless setDefaultStyle has been        |
  179. |                     called.                                                  |
  180. |   setDefaultStyle - Sets the default style for all subsequent ISetCanvas     |
  181. |                     objects.                                                 |
  182. ------------------------------------------------------------------------------*/
  183. INESTEDBITFLAGCLASSDEF2(Style, ISetCanvas, ICanvas, IWindow);
  184.                                   // style class definition
  185. static const Style
  186.   classDefaultStyle,
  187.   horizontalDecks,
  188.   verticalDecks,
  189.   packTight,
  190.   packEven,
  191.   packExpanded,
  192.   leftAlign,
  193.   rightAlign,
  194.   centerAlign,
  195.   topAlign,
  196.   bottomAlign,
  197.   centerVerticalAlign;
  198. static Style
  199.   defaultStyle       ( );
  200. static void
  201.   setDefaultStyle    ( const Style& style );
  202.  
  203. /*---------------------------- Style Manipulation ------------------------------
  204. | These functions are used to set and query the default style for new objects  |
  205. | of this class or the styles of an existing instance:                         |
  206. |   DeckOrientation    - Enumeration that specifies the directions in which    |
  207. |                        you can orient the decks of child windows.  The       |
  208. |                        valid values are:                                     |
  209. |                          horizontal - Arranges the child windows in the      |
  210. |                                       canvas horizontally in rows, from      |
  211. |                                       left to right.  Decks in rows are      |
  212. |                                       arranged from top to bottom.           |
  213. |                          vertical   - Arranges the child windows in the      |
  214. |                                       canvas vertically in columns, from     |
  215. |                                       top to bottom.  Decks in columns are   |
  216. |                                       arranged from left to right.           |
  217. |   deckOrientation    - Returns the direction of the decks.                   |
  218. |   setDeckOrientation - Sets the direction of the decks.                      |
  219. |   PackType           - Enumeration that specifies the ways in which you can  |
  220. |                        provide space between child windows in decks.  The    |
  221. |                        valid values are:                                     |
  222. |                          tight    - Child windows are sized to their         |
  223. |                                     minimum size and are separated within    |
  224. |                                     a deck by the pad amount only.           |
  225. |                          even     - Child windows are sized to their         |
  226. |                                     minimum size and spaced so that          |
  227. |                                     corresponding windows in each deck are   |
  228. |                                     aligned.  This gives the appearance of   |
  229. |                                     their being arranged in both rows and    |
  230. |                                     columns.  Child windows within a deck    |
  231. |                                     can be separated by more than the pad    |
  232. |                                     amount as a result.                      |
  233. |                          expanded - Similar to even, except the child        |
  234. |                                     windows are grown rather than being      |
  235. |                                     spaced by more than the pad amount.      |
  236. |                                     Child windows are grown to be the same   |
  237. |                                     size as the largest child window.        |
  238. |   packType           - Returns how child windows are spaced in decks.        |
  239. |   setPackType        - Sets how child windows are spaced in decks.           |
  240. |   Alignment          - Enumeration that specifies how you can align child    |
  241. |                        windows in a deck.  The valid values are:             |
  242. |                          topLeft      - Aligns the child windows in the      |
  243. |                                         canvas to the top and left edge of   |
  244. |                                         their place in a deck.               |
  245. |                          topCenter    - Aligns the child windows in the      |
  246. |                                         canvas to the top and center edge    |
  247. |                                         of their place in a deck.            |
  248. |                          topRight     - Aligns the child windows in the      |
  249. |                                         canvas to the top and right edge of  |
  250. |                                         their place in a deck.               |
  251. |                          centerLeft   - Aligns the child windows in the      |
  252. |                                         canvas to the center and left edge   |
  253. |                                         of their place in a deck.            |
  254. |                          centerCenter - Aligns the child windows in the      |
  255. |                                         canvas to the center of their place  |
  256. |                                         in a deck.                           |
  257. |                          centerRight  - Aligns the child windows in the      |
  258. |                                         canvas to the center and right edge  |
  259. |                                         of their place in a deck.            |
  260. |                          bottomLeft   - Aligns the child windows in the      |
  261. |                                         canvas to the bottom and left edge   |
  262. |                                         of their place in a deck.            |
  263. |                          bottomCenter - Aligns the child windows in the      |
  264. |                                         canvas to the bottom and center      |
  265. |                                         edge of their place in a deck.       |
  266. |                          bottomRight  - Aligns the child windows in the      |
  267. |                                         canvas to the bottom and right edge  |
  268. |                                         of their place in a deck.            |
  269. |   alignment          - Returns how child windows are aligned in decks.       |
  270. |   setAlignment       - Sets how child windows are aligned in decks.          |
  271. ------------------------------------------------------------------------------*/
  272. enum  DeckOrientation { horizontal, vertical };
  273. DeckOrientation
  274.   deckOrientation    ( ) const;
  275. ISetCanvas
  276.  &setDeckOrientation ( DeckOrientation value );
  277.  
  278. enum  PackType    { tight, even, expanded };
  279. PackType
  280.   packType           ( ) const;
  281. ISetCanvas
  282.  &setPackType        ( PackType value );
  283.  
  284. enum  Alignment   { topLeft, topCenter, topRight,
  285.                     centerLeft, centerCenter, centerRight,
  286.                     bottomLeft, bottomCenter, bottomRight };
  287. Alignment
  288.   alignment          ( ) const;
  289. ISetCanvas
  290.  &setAlignment       ( Alignment value );
  291.  
  292. /*-------------------------------- Accessors -----------------------------------
  293. | These functions provide the means of getting and setting accessible          |
  294. | attributes of instances of this class:                                       |
  295. |   deckCount    - Returns the maximum number of decks used by the canvas.     |
  296. |   margin       - Returns the margin width and height, which is the space     |
  297. |                  between the edge of the canvas and the outermost child      |
  298. |                  windows.                                                    |
  299. |   pad          - Returns the pad width and height, which is the space        |
  300. |                  between child windows in a deck and between multiple decks. |
  301. |   setDeckCount - Sets the maximum number of decks used by the canvas.        |
  302. |   setMargin    - Sets the margin width and height, which is the space        |
  303. |                  between the edge of the canvas and the outermost child      |
  304. |                  windows.                                                    |
  305. |   setPad       - Sets the pad width and height, which is the space between   |
  306. |                  child windows in a deck and between multiple decks.         |
  307. ------------------------------------------------------------------------------*/
  308. unsigned long
  309.   deckCount          ( ) const;
  310. ISize
  311.   margin             ( ) const,
  312.   pad                ( ) const;
  313. ISetCanvas
  314.  &setDeckCount       ( unsigned long decks ),
  315.  &setMargin          ( const ISize& margin ),
  316.  &setPad             ( const ISize& pad );
  317.  
  318. /*----------------------------------- Text -------------------------------------
  319. | These functions provide the means of adding a group box around the canvas,   |
  320. | removing the group box, and querying the text of the group box:              |
  321. |   setText - Causes a group box with the given text to be drawn around the    |
  322. |             canvas.  If necessary, the canvas is grown to fill the width of  |
  323. |             the group box.  If no text is specified, an existing group box   |
  324. |             is removed.                                                      |
  325. |   text    - Returns the text of the group box.  If the canvas has no         |
  326. |             surrounding group box, an empty IString is returned.             |
  327. ------------------------------------------------------------------------------*/
  328. virtual ISetCanvas
  329.  &setText            ( const char* text ),
  330.  &setText            ( const IResourceId& text );
  331. virtual IString
  332.   text               ( ) const;
  333.  
  334. /*------------------------------- Enumerations ---------------------------------
  335. | The following enumeration is defined:                                        |
  336. |   ColorArea - Enumeration that is used to specify an area of the canvas      |
  337. |               that can be affected with color.  The valid value is:          |
  338. |                 background - The portion of the canvas not occupied by any   |
  339. |                              child controls.                                 |
  340. ------------------------------------------------------------------------------*/
  341. enum ColorArea {
  342.   background
  343. };
  344.  
  345. /*---------------------------------- Color -------------------------------------
  346. | These functions set and query the color of the canvas:                       |
  347. |   setColor - Sets the specified color of the canvas.                         |
  348. |   color    - Returns the specified color of the canvas.                      |
  349. ------------------------------------------------------------------------------*/
  350. ISetCanvas
  351.  &setColor           ( ColorArea area, const IColor& color );
  352. IColor
  353.   color              ( ColorArea area ) const;
  354.  
  355. /*-------------------------------- Overrides -----------------------------------
  356. | This class overrides the following inherited function:                       |
  357. |   setLayoutDistorted - Treats a minimum size change for a child window like  |
  358. |                        a layout change.                                      |
  359. ------------------------------------------------------------------------------*/
  360. virtual ISetCanvas
  361.  &setLayoutDistorted ( unsigned long layoutAttributeOn,
  362.                        unsigned long layoutAttributeOff );
  363.  
  364. protected:
  365. /*-------------------------------- Overrides -----------------------------------
  366. | This function is overridden to position and size child windows using the     |
  367. | layout options provided by this canvas:                                      |
  368. |   layout - Positions and sizes child windows.                                |
  369. ------------------------------------------------------------------------------*/
  370. virtual ISetCanvas
  371.  &layout             ( );
  372.  
  373. /*------------------------------ Implementation --------------------------------
  374. | This function provides support for a surrounding group box:                  |
  375. |   expandForText - Determines how much larger the canvas must be to include   |
  376. |                   a group box with text.                                     |
  377. ------------------------------------------------------------------------------*/
  378. ISetCanvas
  379.  &expandForText      ( );
  380.  
  381. private:
  382. /*--------------------------------- Private ----------------------------------*/
  383.   ISetCanvas         ( const ISetCanvas& );
  384. ISetCanvas
  385.  &operator=          ( const ISetCanvas& );
  386.  
  387. static Style
  388.   currentDefaultStyle;
  389.  
  390. unsigned long
  391.   ulClNumDecks;
  392. Style
  393.   scsClStyle;
  394. ISize
  395.   sizClMargin,
  396.   sizClPad;
  397.  
  398. friend Boolean
  399.   ISetCanvasDeleter  ( ISetCanvasObject* const& element,
  400.                        void* anything );
  401. }; // ISetCanvas
  402.  
  403. INESTEDBITFLAGCLASSFUNCS(Style, ISetCanvas);
  404.  
  405. /*----------------------------------------------------------------------------*/
  406. /* Resume compiler default packing.                                           */
  407. /*----------------------------------------------------------------------------*/
  408. #pragma pack()
  409.  
  410. /*----------------------------- Inline Functions -----------------------------*/
  411. #ifndef I_NO_INLINES
  412.   #include <isetcv.inl>
  413. #endif
  414.  
  415. #endif /* _ISETCV_ */
  416.