home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / inotebk.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  18.2 KB  |  589 lines

  1. #ifndef _INOTEBK_
  2. #define _INOTEBK_
  3. /*******************************************************************************
  4. * FILE NAME: inotebk.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IPageHandle                                                              *
  9. *     INotebook                                                                *
  10. *     INotebook::Cursor                                                        *
  11. *     INotebook::PageSettings                                                  *
  12. *                                                                              *
  13. * COPYRIGHT:                                                                   *
  14. *   IBM Open Class Library                                                     *
  15. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  16. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  17. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  18. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  19. *                                                                              *
  20. *******************************************************************************/
  21. #include <icontrol.hpp>
  22. #include <irect.hpp>
  23. #include <istring.hpp>
  24. #include <ihandle.hpp>
  25. #include <ipoint.hpp>
  26.  
  27. class IResourceId;
  28. class ITabBitmapMgr;
  29. class INotebookData;
  30. class INotebookCursorData;
  31. class INotebookPageSettingsData;
  32. class IColor;
  33.  
  34.   class IPageClipWindow;
  35.   class ITabCtrlPageSequence;
  36.  
  37. #pragma pack(4)
  38.  
  39. class IPageHandle : public IHandle {
  40. typedef IHandle
  41.   Inherited;
  42. public:
  43. /*------------------------------- Constructors -------------------------------*/
  44.   IPageHandle ( Value pageId = 0 );
  45.  
  46. /*-------------------------------- Page Handle -------------------------------*/
  47.   operator Value ( ) const;
  48.  
  49. }; // class IPageHandle
  50.  
  51.  
  52. class INotebook : public IControl {
  53. typedef IControl
  54.   Inherited;
  55. public:
  56. class Style;
  57. /*------------------------------- Constructors -------------------------------*/
  58.   INotebook   ( unsigned long        windowId,
  59.                 IWindow*             parent,
  60.                 IWindow*             owner,
  61.                 const IRectangle&    initial = IRectangle(),
  62.                 const Style&         style = defaultStyle() );
  63.  
  64.   INotebook   ( unsigned long        windowId,
  65.                 IWindow*             parentAndOwner );
  66.   INotebook   ( const IWindowHandle& handle );
  67.  
  68. virtual
  69.  ~INotebook   ( );
  70.  
  71. /*---------------------------------- Styles ----------------------------------*/
  72. INESTEDBITFLAGCLASSDEF2(Style, INotebook, IWindow, IControl);
  73.                                     // style class definition
  74. static const Style
  75.   IC_IMPORTU classDefaultStyle,
  76.   IC_IMPORTU pmCompatible,
  77.   IC_IMPORTU spiralBinding,
  78.   IC_IMPORTU solidBinding,
  79.   IC_IMPORTU backPagesBottomRight,
  80.   IC_IMPORTU backPagesBottomLeft,
  81.   IC_IMPORTU backPagesTopRight,
  82.   IC_IMPORTU backPagesTopLeft,
  83.   IC_IMPORTU majorTabsRight,
  84.   IC_IMPORTU majorTabsLeft,
  85.   IC_IMPORTU majorTabsTop,
  86.   IC_IMPORTU majorTabsBottom,
  87.   IC_IMPORTU squareTabs,
  88.   IC_IMPORTU roundedTabs,
  89.   IC_IMPORTU polygonTabs,
  90.   IC_IMPORTU allTabsVisible,
  91.   IC_IMPORTU handleDrawTabs,
  92.   IC_IMPORTU statusTextLeft,
  93.   IC_IMPORTU statusTextRight,
  94.   IC_IMPORTU statusTextCenter,
  95.   IC_IMPORTU tabTextLeft,
  96.   IC_IMPORTU tabTextRight,
  97.   IC_IMPORTU tabTextCenter;
  98.  
  99. static Style
  100.   defaultStyle      ( );
  101.  
  102. static void
  103.   setDefaultStyle   ( const Style&    style );
  104.  
  105. virtual unsigned long
  106.   convertToGUIStyle ( const IBitFlag& style,
  107.                       Boolean         extendedOnly = false ) const;
  108.  
  109. /*----------------------------- Status Text ------------------------------------*/
  110. enum TextAlignment {
  111.   left,
  112.   right,
  113.   center
  114. };
  115.  
  116. virtual INotebook
  117.  &setStatusTextAlignment ( TextAlignment       alignment ),
  118.  &setStatusText          ( const IPageHandle&  referencePage,
  119.                            const char*         statusText ),
  120.  &setStatusText          ( const IPageHandle&  referencePage,
  121.                            const IResourceId&  resourceId );
  122.  
  123. virtual TextAlignment
  124.   statusTextAlignment    ( ) const;
  125.  
  126. /*------------------------------- Tab Support --------------------------------*/
  127. enum TabShape {
  128.   square,
  129.   rounded,
  130.   polygon
  131. };
  132.  
  133. virtual INotebook
  134.  &setTabShape         ( TabShape             tabShape ),
  135.  &setMajorTabSize     ( const ISize&         sizeMajorTab ),
  136.  &setMinorTabSize     ( const ISize&         sizeMinorTab );
  137.  
  138. virtual TabShape
  139.   tabShape            ( ) const;
  140.  
  141. virtual INotebook
  142.  &setTabTextAlignment ( TextAlignment        alignment ),
  143.  &refreshTabs         ( ),
  144.  &setTabText          ( const IPageHandle&   referencePage,
  145.                         const char*          tabText ),
  146.  &setTabText          ( const IPageHandle&   referencePage,
  147.                         const IResourceId&   resourceId ),
  148.  &setTabBitmap        ( const IPageHandle&   referencePage,
  149.                         const IBitmapHandle& bitmap ),
  150.  &setTabBitmap        ( const IPageHandle&   referencePage,
  151.                         const IResourceId&   resourceId );
  152.  
  153. virtual TextAlignment
  154.   tabTextAlignment    ( ) const;
  155.  
  156. Boolean
  157.   areAllTabsVisible   ( ) const,
  158.   isDrawTabsEnabled   ( ) const;
  159.  
  160. /*------------------------------ Page Button ---------------------------------*/
  161. virtual INotebook
  162.  &setPageButtonSize ( const ISize& sizePageButton );
  163.  
  164. /*----------------------------- Orientation ----------------------------------*/
  165. enum Orientation {
  166.   backpagesBottomTabsRight,
  167.   backpagesTopTabsRight,
  168.   backpagesBottomTabsLeft,
  169.   backpagesTopTabsLeft,
  170.   backpagesRightTabsTop,
  171.   backpagesLeftTabsTop,
  172.   backpagesRightTabsBottom,
  173.   backpagesLeftTabsBottom
  174. };
  175.  
  176. virtual INotebook
  177.  &setOrientation   ( Orientation orientation );
  178.  
  179. virtual Orientation
  180.   orientation      ( ) const;
  181.  
  182. /*----------------------------- Binding Support ------------------------------*/
  183. enum Binding {
  184.   spiral,
  185.   solid
  186. };
  187.  
  188. virtual INotebook
  189.  &setBinding     ( Binding binding );
  190.  
  191. virtual Binding
  192.   binding        ( ) const;
  193.  
  194. /*------------------------------ Colors --------------------------------------*/
  195. #ifndef IC_WIN_FLAGNOP
  196. virtual IColor
  197.   backgroundColor              ( ) const;
  198. #endif //!IC_WIN_FLAGNOP
  199. #ifndef IC_MOTIFWIN_FLAGNOP
  200. virtual IColor
  201.   hiliteBackgroundColor        ( ) const,
  202. #endif //!IC_MOTIFWIN_FLAGNOP
  203.   pageBackgroundColor          ( ) const,
  204.   majorTabBackgroundColor      ( ) const,
  205.   minorTabBackgroundColor      ( ) const,
  206.   majorTabForegroundColor      ( ) const,
  207.   minorTabForegroundColor      ( ) const;
  208.  
  209. virtual INotebook
  210.  &setPageBackgroundColor       ( const IColor& color ),
  211.  &setMajorTabBackgroundColor   ( const IColor& color ),
  212.  &setMinorTabBackgroundColor   ( const IColor& color ),
  213.  &setMajorTabForegroundColor   ( const IColor& color ),
  214.  &setMinorTabForegroundColor   ( const IColor& color );
  215.  
  216.  
  217. virtual INotebook
  218.  &resetPageBackgroundColor     ( ),
  219.  &resetMajorTabBackgroundColor ( ),
  220.  &resetMinorTabBackgroundColor ( ),
  221.  &resetMajorTabForegroundColor ( ),
  222.  &resetMinorTabForegroundColor ( );
  223.  
  224. /*--------------------------- Native Control Support -------------------------*/
  225. Boolean
  226.   isPMCompatible ( ) const;
  227.  
  228.  
  229. class PageSettings : public IVBase {
  230. typedef IVBase
  231.   Inherited;
  232. friend class INotebook;
  233. public:
  234. /*-------------------------------- Attributes --------------------------------*/
  235. INESTEDBITFLAGCLASSDEF0(Attribute, INotebook::PageSettings);
  236. static const Attribute
  237.   IC_IMPORTU autoPageSize,
  238.   IC_IMPORTU statusTextOn,
  239.   IC_IMPORTU majorTab,
  240.   IC_IMPORTU minorTab,
  241.   IC_IMPORTU noAttribute;
  242.  
  243. /*------------------------------- Constructors -------------------------------*/
  244.   PageSettings  ( );
  245.   PageSettings  ( const Attribute&               attribute );
  246.   PageSettings  ( const char*                    tabText,
  247.                   const char*                    statusText = 0,
  248.                   const Attribute&               pageAttribute = noAttribute );
  249.   PageSettings  ( const IBitmapHandle&           tabBitmap,
  250.                   const char*                    statusText = 0,
  251.                   const Attribute&               pageAttribute = noAttribute );
  252.   PageSettings  ( const INotebook::PageSettings& pageSettings );
  253.   PageSettings
  254.    &operator =  ( const INotebook::PageSettings& pageSettings );
  255.  
  256. virtual
  257.   ~PageSettings ( );
  258.  
  259.  
  260. /*----------------------------- Status Text ------------------------------------*/
  261. virtual INotebook::PageSettings
  262.  &setStatusText     ( const char*        statusText ),
  263.  &setStatusText     ( const IResourceId& resourceId );
  264.  
  265. virtual IString
  266.   statusText        ( ) const;
  267.  
  268. Boolean
  269.   isStatusTextOn    ( ) const;
  270.  
  271. /*--------------------------------- Tabs -------------------------------------*/
  272. virtual INotebook::PageSettings
  273.  &setTabText        ( const char*          tabText ),
  274.  &setTabText        ( const IResourceId&   resourceId ),
  275.  &setTabBitmap      ( const IBitmapHandle& bitmap ),
  276.  &setTabBitmap      ( const IResourceId&   resourceId );
  277.  
  278. virtual IString
  279.   tabText           ( ) const;
  280.  
  281. virtual IBitmapHandle
  282.   tabBitmap         ( ) const;
  283.  
  284. Boolean
  285.   isMajorTab        ( ) const,
  286.   isMinorTab        ( ) const;
  287.  
  288.  
  289. /*---------------------------- Application Data ------------------------------*/
  290. virtual INotebook::PageSettings
  291.  &setUserData       ( unsigned long userData );
  292.  
  293. virtual unsigned long
  294.   userData          ( ) const;
  295.  
  296. /*---------------------------- Automatic Sizing ------------------------------*/
  297. Boolean
  298.   isAutoSize       ( ) const;
  299.  
  300. private:
  301. /*-------------------------------- Private -----------------------------------*/
  302. Attribute
  303.   pageStyle;
  304. IBitmapHandle
  305.   savedTabBitmap;
  306. unsigned long
  307.   savedUserData;
  308. IString
  309.   savedStatusText,
  310.   savedTabText;
  311.  
  312. INotebookPageSettingsData
  313.  *fPageSettingsData;
  314. }; // INotebook::PageSettings
  315.  
  316.  
  317. class Cursor : public IVBase {
  318. typedef IVBase
  319.   Inherited;
  320. public :
  321. /*------------------------------- Constructors -------------------------------*/
  322.   Cursor  ( const INotebook& notebook );
  323.  
  324. virtual
  325.   ~Cursor ( );
  326.  
  327. /*------------------------------ Page Iteration ------------------------------*/
  328. virtual Boolean
  329.   setToFirst    ( ),
  330.   setToNext     ( ),
  331.   setToPrevious ( ),
  332.   setToLast     ( ),
  333.   isValid       ( ) const;
  334.  
  335. virtual void
  336.   invalidate    ( );
  337.  
  338. /*------------------------------- Page Retrieval -----------------------------*/
  339. virtual IPageHandle
  340.   first      ( ),
  341.   next       ( ),
  342.   previous   ( ),
  343.   last       ( ),
  344.   current    ( ) const;
  345.  
  346. void
  347.   setCurrent ( const IPageHandle& current );
  348.  
  349.  
  350. private:
  351. /*----------------------------- Hidden Members -------------------------------*/
  352. Cursor       ( const Cursor& cursor );
  353. Cursor
  354.  &operator=  ( const Cursor& cursor );
  355.  
  356. /*--------------------------------- Private ----------------------------------*/
  357. const INotebook
  358.  &nbCl;
  359. unsigned long
  360.   ulClCurrentPageId;
  361. unsigned long
  362.   ulClReferences;
  363.  
  364. INotebookCursorData
  365.  *fCursorData;
  366. }; // INotebook::Cursor
  367.  
  368.  
  369. /*------------------------------ Page Addition -------------------------------*/
  370. virtual IPageHandle
  371.   addFirstPage      ( const PageSettings& pageInfo,
  372.                       IWindow*            pageWindow = 0 ),
  373.   addLastPage       ( const PageSettings& pageInfo,
  374.                       IWindow*            pageWindow = 0 ),
  375.   addPageBefore     ( const PageSettings& pageInfo,
  376.                       const IPageHandle&  referencePage,
  377.                       IWindow*            pageWindow = 0 ),
  378.   addPageAfter      ( const PageSettings& pageInfo,
  379.                       const IPageHandle&  referencePage,
  380.                       IWindow*            pageWindow = 0 ),
  381.   addPageBefore     ( const PageSettings& pageInfo,
  382.                       const Cursor&       cursor,
  383.                       IWindow*            pageWindow = 0 ),
  384.   addPageAfter      ( const PageSettings& pageInfo,
  385.                       const Cursor&       cursor,
  386.                       IWindow*            pageWindow = 0 );
  387.  
  388. /*------------------------------- Page Removal -------------------------------*/
  389. virtual INotebook
  390.  &removePage        ( const IPageHandle&  page ),
  391.  &removePage        ( const Cursor&       cursor ),
  392.  &removeAllPages    ( ),
  393.  &removeTabSection  ( const IPageHandle&  page ),
  394.  &removeTabSection  ( const Cursor&       cursor );
  395.  
  396. /*---------------------------- Page Manipulation -----------------------------*/
  397. virtual INotebook
  398.  &turnToPage        ( const IPageHandle&  page ),
  399.  &turnToPage        ( const Cursor&       cursor );
  400.  
  401. virtual IPageHandle
  402.   topPage           ( ) const,
  403.   firstPage         ( ) const,
  404.   lastPage          ( ) const,
  405.   nextPage          ( const IPageHandle&  referencePage ) const,
  406.   previousPage      ( const IPageHandle&  referencePage ) const;
  407.  
  408. /*---------------------------- Page Information ------------------------------*/
  409. PageSettings
  410.   pageSettings      ( const Cursor&       cursor ) const,
  411.   pageSettings      ( const IPageHandle&  page ) const;
  412.  
  413. /*---------------------------- Application Data ------------------------------*/
  414. virtual INotebook
  415.  &setUserData       ( const IPageHandle& referencePage,
  416.                       unsigned long      userData );
  417.  
  418. /*------------------------- Page Window Association --------------------------*/
  419. virtual IWindow
  420.  *window            ( const Cursor&      cursor ) const,
  421.  *window            ( const IPageHandle& page ) const;
  422.  
  423. virtual INotebook
  424.  &setWindow         ( const Cursor&      cursor,
  425.                             IWindow*     pageWindow = 0 ),
  426.  &setWindow         ( const IPageHandle& referencePage,
  427.                             IWindow*     pageWindow = 0 );
  428.  
  429.  
  430. /*------------------------------- Page Support -------------------------------*/
  431. virtual ISize
  432.   pageSize        ( ) const,
  433.   notebookSize    ( const IPageHandle& page ) const;
  434.  
  435. virtual unsigned long
  436.   totalPages      ( ) const,
  437.   pagesToMajorTab ( const IPageHandle& page ) const,
  438.   pagesToMajorTab ( const Cursor&      cursor ) const,
  439.   pagesToMinorTab ( const IPageHandle& page ) const,
  440.   pagesToMinorTab ( const Cursor&      cursor ) const,
  441.   pagesToEnd      ( const IPageHandle& page ) const,
  442.   pagesToEnd      ( const Cursor&      cursor ) const;
  443.  
  444. virtual Boolean
  445.   isEmpty         ( ) const;
  446.  
  447. /*-------------------------- Notification Members ----------------------------*/
  448. static INotificationId const
  449.   IC_IMPORTU pageBackgroundColorId,
  450.   IC_IMPORTU majorTabBackgroundColorId,
  451.   IC_IMPORTU minorTabBackgroundColorId,
  452.   IC_IMPORTU majorTabForegroundColorId,
  453.   IC_IMPORTU minorTabForegroundColorId,
  454.   IC_IMPORTU orientationId;
  455.  
  456. virtual IWindow
  457.  &enableNotification ( Boolean enable=true );
  458.  
  459. protected:
  460. /*------------------------------ Layout Support ------------------------------*/
  461. virtual ISize
  462.   calcMinimumSize ( ) const;
  463.  
  464.  
  465. private:
  466. /*----------------------------- Hidden Members -------------------------------*/
  467. INotebook   ( const INotebook& notebook );
  468. INotebook
  469.  &operator= ( const INotebook& notebook );
  470.  
  471. /*--------------------------------- Private ----------------------------------*/
  472. INotebookData
  473.  *fNotebookData;
  474.  
  475. static Style
  476.   currentDefaultStyle;
  477.  
  478. unsigned long
  479.   queryPage      ( void* mp1, void* mp2 ) const,
  480.   insertPage     ( void* mp1, void* mp2 );
  481.  
  482. Boolean
  483.   deletePage     ( void* mp1, void* mp2 );
  484.  
  485. short
  486.   queryPageCount ( void* mp1, void* mp2 ) const;
  487.  
  488. IPageHandle
  489.   insertPageInfo2 ( const PageSettings& pageInfo,
  490.                     const IPageHandle&  referencePage,
  491.                     IWindow*            window,
  492.                     unsigned long       fPosition ),
  493.   insertPageInfo ( const PageSettings& pageInfo,
  494.                    const IPageHandle&  referencePage,
  495.                    IWindow*            window,
  496.                    unsigned long       fPosition );
  497.  
  498.  
  499. ITabBitmapMgr
  500.  *bmClTabBitmapMgr;
  501. unsigned long
  502.   ulClValidate;
  503.  
  504. friend class INotebook::Cursor;
  505. friend class INotebookHandler;
  506.  
  507. INESTEDBITFLAGCLASSDEF0(clrFlags, INotebook);
  508. static const clrFlags
  509.   IC_IMPORTU bgnPageColor,
  510.   IC_IMPORTU bgnMajorColor,
  511.   IC_IMPORTU bgnMinorColor,
  512.   IC_IMPORTU fgnMajorColor,
  513.   IC_IMPORTU fgnMinorColor;
  514.  
  515. INotebook::clrFlags
  516.   colorFlags;
  517.  
  518. void setNotebookColors   ( unsigned long color,
  519.                            unsigned long colorArea );
  520. void storeNotebookColors ( unsigned long color,
  521.                            unsigned long
  522.                            colorArea );
  523. IColor UnsignedLongAsRGB ( unsigned long color ) const;
  524.  
  525. struct NotebookColors
  526. {
  527.   unsigned long  pageBackgroundColor;
  528.   unsigned long  majorTabBackgroundColor;
  529.   unsigned long  minorTabBackgroundColor;
  530.   unsigned long  majorTabForegroundColor;
  531.   unsigned long  minorTabForegroundColor;
  532. };
  533. NotebookColors
  534.  *pnotebookColors;
  535.  
  536.  
  537. // Tab control related functions and members
  538.  
  539. friend IPageClipWindow;
  540.  
  541. static Boolean
  542.   hasBeenRegistered;
  543.  
  544. IWindow
  545.  *pageClippingWindow ( ) const;
  546.  
  547. Boolean
  548.   processTabSelect   ( void*        pPageSelNotify,
  549.                        Boolean      bSelectPending ) const;
  550.  
  551. void
  552.   showTopPage        ( long         iPageIndex,
  553.                        void*        pRect,
  554.                        Boolean      bNotResizing = true ) const,
  555.   adjustRect         ( Boolean      bTabCtrlSize,
  556.                        void*        pRect ) const,
  557.   tabControlResize   ( const ISize& newSize ) const;
  558.  
  559. ITabCtrlPageSequence
  560.   *pTabCtrlPageSeqCl;
  561. unsigned long
  562.   ulClPagesInserted;
  563.  
  564. ITabCtrlPageSequence
  565.  *tabPageHandleCollection ( ) const;
  566.  
  567. long
  568.   tabPageIndex            ( const IPageHandle&  pageHandle ) const;
  569.  
  570. IPageHandle
  571.   tabPageHandle           ( unsigned long       ulPosition ) const,
  572.   insertTabPage           ( const PageSettings& pageInfo,
  573.                             const IPageHandle&  referencePage,
  574.                             unsigned long       ulPosition );
  575.  
  576. Boolean
  577.   removeTabPage           ( const IPageHandle&  pageHandle );
  578.  
  579.  
  580. }; // INotebook
  581.  
  582. INESTEDBITFLAGCLASSFUNCS(Style, INotebook);
  583.  
  584. #pragma pack()
  585.  
  586.   #include <inotebk.inl>
  587.  
  588. #endif /* _INOTEBK_ */
  589.