home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / runnable / ibmc / ibmclass / inotebk.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-26  |  14.4 KB  |  282 lines

  1. #ifndef _INOTEBOOK_
  2.   #define _INOTEBOOK_
  3. /*******************************************************************************
  4. * FILE NAME: inotebk.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     Inotebk  - This class creates and manages the notebook control window.   *
  9. *                                                                              *
  10. * NOTES:                                                                       *
  11. *  1. This class is used in conjunction with IPage.                            *
  12. *  2. Methods that have a 0 default for an IPage                               *
  13. *     pointer will use the top page as the default.                            *
  14. *  3. When a pages is removed from a notebook, the IPage                       *
  15. *     object still exists...  However, the following data                      *
  16. *     (normally maintained by the notebook) is lost:                           *
  17. *      - status text (or length)                                               *
  18. *      - tab text (or length)                                                  *
  19. *      - tab bitmap                                                            *
  20. *     Therefore, removing a page from a notebook, and adding                   *
  21. *     it back again currently requires that the user reset the                 *
  22. *     bitmap, status and tab text.                                             *
  23. *                                                                              *
  24. * DESIGN NOTES:                                                                *
  25. *                                                                              *
  26. *  1. We should probably add the capability to use the same                    *
  27. *     PM window for multiple PageWindows.  Currently, to do                    *
  28. *     this, the user would have to re-implement the method                     *
  29. *     handleIt(IControlEvent) for the notification message                     *
  30. *     BKM_PAGESELECTED.  Whenever receiving this message, he                   *
  31. *     can create the PM window for the new top page, if                        *
  32. *     necessary.                                                               *
  33. *                                                                              *
  34. *  2. May want to add capability for user to use the same PM                   *
  35. *     window on multiple pages of the notebook.  Then, on                      *
  36. *     every BKM_PAGESELECTED they would have to paint the                      *
  37. *     window with the appropriate data for the new top page.                   *
  38. *                                                                              *
  39. *  3. Might want to add a method "movePage()" to change the                    *
  40. *     placement of a page in the notebook.                                     *
  41. *                                                                              *
  42. * COPYRIGHT:                                                                   *
  43. *   Licensed Materials - Property of IBM                                       *
  44. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  45. *   All Rights Reserved                                                        *
  46. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  47. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  48. *                                                                              *
  49. * $Log:   R:/IBMCLASS/IBASECTL/VCS/INOTEBK.HPV  $
  50. //
  51. //   Rev 1.3   25 Oct 1992 17:05:40   nunn
  52. //changed library name to ICLUI
  53. //
  54. //   Rev 1.2   25 Oct 1992 10:55:32   boezeman
  55. //Add documentation and converted file to skeleton.hpp format.
  56.  
  57.       Rev 1.3   26 Feb 1992 21:17:36   Ken Fichthorn
  58.    Fix order of constructor  parms
  59.  
  60.       Rev 1.2   30 Oct 1991 20:55:52   Ken Fichthorn
  61.    Palo Alto design changes.
  62.  
  63.       Rev 1.1   11 Aug 1991 19:02:08   Mike K. Chan
  64.    Original entry.
  65. *******************************************************************************/
  66. // Forward declarations for other classes:
  67. class INoteBook;
  68. class IPage;
  69. #include "icontrol.hpp"
  70. #include "irect.hpp"
  71.  
  72. /* These constants are used in method "setNoteBookColor"                 */
  73. /* They specify the region of the notebook whose color is to be changed. */
  74. /* They were necessary because the constants defined by PM were in       */
  75. /* conflict.                                                             */
  76. /*                                                                       */
  77. const unsigned long IC_NB_STATUSTEXT = (100L + 2L);
  78. const unsigned long IC_NB_BACKGROUND = (100L + 4L);
  79. const unsigned long IC_NB_SELECTIONCURSOR = (100L + 6L);
  80. const unsigned long IC_NB_BORDER = (100L + 14L);
  81. const unsigned long IC_NB_PAGEBACKGROUND = 0x0001;
  82. const unsigned long IC_NB_MAJORBACKGROUND = 0x0003;
  83. const unsigned long IC_NB_MINORBACKGROUND = 0x0005;
  84. const unsigned long IC_NB_MAJORTEXT = 0x0007;
  85. const unsigned long IC_NB_MINORTEXT = 0x0009;
  86.  
  87.  
  88. class INoteBook : public IControl {
  89. /*******************************************************************************
  90. * This class creates and manages the notebook control window.                  *
  91. *                                                                              *
  92. * To use this class, create an instance of this class as follows:              *
  93. *   #include <inotebk.hpp>                                                     *
  94. *   INoteBook *pnbkMyBook;                                                     *
  95. *   pnbkMyBook = new INoteBook( this, ID_MYBOOK,                               *
  96. *                               IRectangle(IPoint(50,15),                      *
  97. *                               ISize(425,225)));                              *
  98. *   pnbkMyBook->setMajorTabSize( ISize(50,23) );                               *
  99. *   pnbkMyBook->setMinorTabSize( ISize(90,45) );                               *
  100. *   ppgMyPage = new IPage( pnbkMyBook,                                         *
  101. *                         BKA_MAJOR | IC_DEFAULTPAGESTYLE);                    *
  102. *   ppgMyPage->setTabText( (char *)"My Tab Text" );                            *
  103. *   sprintf(msgstr, (char *)"Status text for page %d", lCount);                *
  104. *   ppgMyPage->setStatusText( msgstr );                                        *
  105. *   ppgMyPage->create(FID_CLIENT, rectZero);                                   *
  106. *                                                                              *
  107. * EXAMPLE:                                                                     *
  108. *   <sample code>                                                              *
  109. *******************************************************************************/
  110. typedef IControl
  111.   Inherited;
  112. friend class IPage;
  113.  
  114. public:
  115. INESTEDBITFLAGCLASSDEF2(Style, INoteBook, IWindow, IControl);
  116.                                     // style class definition
  117. static const Style
  118.   spiralBind,
  119.   solidBind,
  120.   backPagesBottomRight,
  121.   backPagesBottomLeft,
  122.   backPagesTopRight,
  123.   backPagesTopLeft,
  124.   majorTabRight,
  125.   majorTabLeft,
  126.   majorTabTop,
  127.   majorTabBottom,
  128.   squareTabs,
  129.   roundedTabs,
  130.   polygonTabs,
  131.   statusTextLeft,
  132.   statusTextRight,
  133.   statusTextCenter,
  134.   tabTextLeft,
  135.   tabTextRight,
  136.   tabTextCenter;
  137. static const Style&
  138.   defaultStyle;
  139.  
  140. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  141. | There are 3 ways to construct instances of this class:                       |
  142. |   1. default                                                                 |
  143. |   2. From a Dialog Template                                                  |
  144. |   3. From a Window                                                           |
  145. ------------------------------------------------------------------------------*/
  146.   INoteBook(unsigned long ulId,
  147.             const IWindow* pwndParent,
  148.             const IWindow* pwndOwner,
  149.             const IRectangle& rectInit,
  150.             Style nbs = defaultStyle);
  151.   INoteBook(unsigned long ulId,
  152.             const IWindow* pwndParent);
  153.  
  154.   INoteBook(IWindowHandle wh);
  155. virtual
  156.   ~INoteBook();
  157.  
  158. /*-------------------------------- PAGES OPERATIONS ----------------------------
  159. | removePage      - returns the three state control default style setting      |
  160. | removeAllPages  - sets the three state control default style                 |
  161. | removeTabSection- sets the three state control default style                 |
  162. ------------------------------------------------------------------------------*/
  163. void
  164.   removePage( IPage* ppgPage = 0),
  165.   removeAllPages(),
  166.   removeTabSection( IPage* ppgTabPage = 0);
  167.  
  168. /*-------------------------------- SIZE OPERATIONS -----------------------------
  169. | setMajorTabSize - Sets the size (in pixels) of the notebook's major tabs.    |
  170. | setMinorTabSize - Sets the size (in pixels) of the notebook's minor tabs.    |
  171. | setPageButtonSize-Sets the size (in pixels) of the arrow buttons used to     |
  172. |                   turn the pages of the notebook.                            |
  173. ------------------------------------------------------------------------------*/
  174. void
  175.   setMajorTabSize(const ISize& sizeMajorTab),
  176.   setMinorTabSize(const ISize& sizeMinorTab),
  177.   setPageButtonSize(const ISize& sizePageButton);
  178.  
  179. /*-------------------------------- COLOR OPERATION -----------------------------
  180. | setNoteBookColor- Sets the color of the various regions of the notebook control|
  181. ------------------------------------------------------------------------------*/
  182. void
  183.   setNoteBookColor(unsigned long ulColor, unsigned long ulColorRegion);
  184.  
  185. /*-------------------------------- PAGE OPERATIONS -----------------------------
  186. | pageSize   - Returns the maximum size for a page's window to fit in the page |
  187. |              area of the notebook control.                                   |
  188. | page       - Returns the page object with the specified page id.             |
  189. | turnToPage - Sets the specified page to be displayed as the top page.        |
  190. | topPage    - Returns the page object of the top page.                        |
  191. ------------------------------------------------------------------------------*/
  192. ISize
  193.   pageSize() const;   // get size of notebook page window
  194. IPage*
  195.   topPage() const;
  196. IPage*
  197.   page( unsigned long ulPageId) const;
  198. void
  199.   turnToPage( IPage* const ppgPage);
  200.  
  201. /*-------------------------------- MISCELLANEOUS OPERATIONS --------------------
  202. | repaintTabs     - Causes all of the tabs in the notebook to be repainted.    |
  203. | isNoteBookEmpty - Queries if the notebook is empty(contains no pages).       |
  204. ------------------------------------------------------------------------------*/
  205. void
  206.   repaintTabs();
  207. Boolean
  208.   isNoteBookEmpty() const;
  209.  
  210. /*-------------------------------- ACCESSING OPERATIONS ------------------------
  211. | firstPage    -  Returns a pointer to the first page in the notebook.         |
  212. | lastPage     -  Returns a pointer to the last page in the notebook.          |
  213. | nextPage     -  Returns a pointer to the page that follows the specified     |
  214. |                 page in the notebook.                                        |
  215. | previousPage -  Returns a pointer to the page that preceeds the specified    |
  216. |                 page in the notebook.                                        |
  217. ------------------------------------------------------------------------------*/
  218. IPage*
  219.   firstPage( unsigned long ulPageType = 0) const;
  220. IPage*
  221.   lastPage( unsigned long ulPageType = 0) const;
  222. IPage*
  223.   nextPage( const IPage* ppgLocatorPage = 0,
  224.             unsigned long ulPageType = 0) const;
  225. IPage*
  226.   previousPage( const IPage* ppgLocatorPage = 0,
  227.                 unsigned long ulPageType = 0) const;
  228.  
  229. /*-------------------------------- PAGE NUMBER OPERATIONS ----------------------
  230. | pageCountToNextMajor -  Returns the number of pages from the specified page  |
  231. |                         to the next major tab page.                          |
  232. | pageCountToNextMinor -  Returns the number of pages from the specified page  |
  233. |                         to the next minor tab page.                          |
  234. | pageCountToEnd       -  Returns the number of pages from the specified page  |
  235. |                         to the last page of the notebook.                    |
  236. | pageCount            -  Returns the total number of pages in the notebook.   |
  237. | majorTabCount        -  Returns the total number of major tab pages in the   |
  238. |                         notebook.                                            |
  239. | minorTabCount        -  Returns the total number of minor tab pages in the   |
  240. |                         major section specified.                             |
  241. ------------------------------------------------------------------------------*/
  242. long
  243.   pageCountToNextMajor( const IPage* ppgPage = 0) const,
  244.   pageCountToNextMinor( const IPage* ppgPage = 0) const,
  245.   pageCountToEnd( const IPage* ppgPage = 0) const,
  246.   pageCount() const,  // Total number of pages in notebook
  247.   majorTabCount() const,
  248.   minorTabCount( const IPage* const ppgMajorTab = 0) const;
  249.  
  250. protected:
  251. static Style
  252.   classDefaultStyle;
  253.  
  254. private :
  255. /*--------------------------------- PRIVATE ----------------------------------*/
  256. /*****************************************************************/
  257. /* Methods for inserting a page into the notebook at the front,  */
  258. /* the end, or before/after a specified "locator page".          */
  259. /*****************************************************************/
  260. void
  261.   addPageLast( IPage* const ppgNewPage),
  262.   addPageFirst( IPage* const ppgNewPage),
  263.   addPageBefore( IPage* const ppgNewPage,
  264.                  const IPage* const ppgLocatePage = 0),
  265.   addPageAfter( IPage* const ppgNewPage,
  266.                 const IPage* const ppgLocatePage = 0),
  267.   addPage( IPage* const ppgNewPage,
  268.                  unsigned long ulOrder,
  269.                  const IPage* const ppgLocatePage);
  270.  
  271. /*****************************************************************/
  272. /* Method containing code common to both the constructors.       */
  273. /*****************************************************************/
  274. void
  275.   constructStuff();
  276.  
  277. };
  278.  
  279. INESTEDBITFLAGCLASSFUNCS(Style, INoteBook);
  280.  
  281. #endif
  282.