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

  1. #ifndef _ITBAR_
  2. #define _ITBAR_
  3.  
  4. /*******************************************************************************
  5. * FILE NAME: itbar.hpp                                                         *
  6. *                                                                              *
  7. * DESCRIPTION:                                                                 *
  8. *   Declaration of the classes:                                                *
  9. *     IToolBar                                                                 *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   IBM Open Class Library                                                     *
  13. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  14. *   Licensed Material - Program-Property of IBM - 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. *******************************************************************************/
  19. #include <isetcv.hpp>
  20. #include <irect.hpp>
  21. #include <itbarbut.hpp>
  22.  
  23. class ISize;
  24. class IPoint;
  25. class IString;
  26. class IFrameWindow;
  27. class IResourceId;
  28. class IToolBarData;
  29. class IToolBarContainer;
  30. class IToolBarFrameWindow;
  31. class IToolBarFrameCursorData;
  32. class IToolBarWindowCursorData;
  33.  
  34. #pragma pack(4)
  35.  
  36.  
  37. class IToolBar : public ISetCanvas {
  38. typedef ISetCanvas
  39.   Inherited;
  40.  
  41. public:
  42. class Style;
  43. /*---------------------------- Tool Bar Location -----------------------------*/
  44. enum Location {
  45.   aboveClient,
  46.   belowClient,
  47.   leftOfClient,
  48.   rightOfClient,
  49.   floating,
  50.   hidden
  51. };
  52.  
  53. virtual IToolBar
  54.  &setLocation ( Location location );
  55.  
  56. Location
  57.   location    ( ) const;
  58.  
  59. /*------------------------------ Constructors --------------------------------*/
  60.   IToolBar ( unsigned long          identifier,
  61.              IFrameWindow*          owner,
  62.              Location               location = aboveClient,
  63.              Boolean                groupWithPreceding = false,
  64.              const Style&           style=defaultStyle());
  65.   IToolBar ( unsigned long          identifier,
  66.              IToolBar*              precedingToolBar,
  67.              Boolean                groupWithPreceding = false,
  68.              const Style&           style=defaultStyle());
  69.  
  70. virtual
  71.   ~IToolBar ( );
  72.  
  73. /*------------------------------ Style ---------------------------------------*/
  74. INESTEDBITFLAGCLASSDEF3(Style, IToolBar, ISetCanvas, ICanvas, IWindow);
  75.  
  76. static const Style
  77.   IC_IMPORTU buttonBitmapVisible,
  78.   IC_IMPORTU buttonTextVisible,
  79.   IC_IMPORTU buttonBitmapAndTextVisible,
  80.   IC_IMPORTU filterMisfits,
  81.   IC_IMPORTU noDragDrop,
  82.   IC_IMPORTU classDefaultStyle;
  83.  
  84. static Style
  85.   defaultStyle      ( );
  86.  
  87. static void
  88.   setDefaultStyle   ( const Style&    style );
  89.  
  90. virtual unsigned long
  91.   convertToGUIStyle ( const IBitFlag& style,
  92.                       Boolean         extendedOnly = false ) const;
  93.  
  94. /*------------------------- Tool Bar Contents --------------------------------*/
  95. virtual IToolBar
  96.  &addAsFirst        ( IWindow*      window,
  97.                       Boolean       startNewGroup = false ),
  98.  &addAsNext         ( IWindow*      window,
  99.                       IWindow*      referenceWindow,
  100.                       Boolean       startNewGroup = false ),
  101.  &addAsPrevious     ( IWindow*      window,
  102.                       IWindow*      referenceWindow,
  103.                       Boolean       startNewGroup = false ),
  104.  &addAsLast         ( IWindow*      window,
  105.                       Boolean       startNewGroup = false ),
  106.  &moveToFirst       ( IWindow*      window,
  107.                       Boolean       startNewGroup = false ),
  108.  &moveAfter         ( IWindow*      window,
  109.                       IWindow*      referenceWindow,
  110.                       Boolean       startNewGroup = false ),
  111.  &moveBefore        ( IWindow*      window,
  112.                       IWindow*      referenceWindow,
  113.                       Boolean       startNewGroup = false ),
  114.  &moveToLast        ( IWindow*      window,
  115.                       Boolean       startNewGroup = false ),
  116.  &remove            ( IWindow*      window );
  117.  
  118. /*----------------------- Tool Bar Button Behavior  --------------------------*/
  119. virtual IToolBar
  120.  &setButtonView  ( IToolBarButton::View buttonView );
  121.  
  122. IToolBarButton::View
  123.   buttonView      ( ) const;
  124.  
  125. /*------------------------------ Filter Misfits ------------------------------*/
  126. IToolBar
  127.  &enableMisfitFiltering  ( Boolean enable = true ),
  128.  &disableMisfitFiltering ( );
  129.  
  130. Boolean
  131.   isMisfitFilteringEnabled ( ) const;
  132.  
  133. /*----------------------- Floating Tool Bar ----------------------------------*/
  134. virtual IToolBar
  135.  &setFloatingPosition ( const IPoint& frameRelativePosition );
  136.  
  137. IPoint
  138.   floatingPosition ( ) const;
  139.  
  140. virtual IToolBar
  141.  &setFloatingTitle   ( const char* text ),
  142.  &setFloatingTitle   ( const IResourceId& text );
  143.  
  144. IString
  145.   floatingTitle      ( ) const;
  146.  
  147. virtual IToolBarFrameWindow
  148.  *floatingFrame       ( );
  149.  
  150. /*----------------------- Tool Bar Defaults ----------------------------------*/
  151. static void
  152.   setDefaultPad         ( long           pixelsOfPad      = -1 ),
  153.   setDefaultMargin      ( const ISize&   sizeOfMargin     = ISize(7,4)),
  154.   setDefaultGroupPad    ( unsigned long  pixelsOfGroupPad = 8 ),
  155.   setDefaultMisfitWidth ( unsigned long  maximumWidth     = 100 );
  156.  
  157. static long
  158.   defaultPad            ( );
  159.  
  160. static ISize
  161.   defaultMargin         ( );
  162.  
  163. static unsigned long
  164.   defaultGroupPad       ( ),
  165.   defaultMisfitWidth    ( );
  166.  
  167. /*------------------------------ Tool Bar Container --------------------------*/
  168. virtual IToolBarContainer
  169.  *toolBarContainer       ( ) const;
  170.  
  171. /*----------------------------- Canvas Layout --------------------------------*/
  172. virtual IToolBar
  173.  &setLayoutDistorted ( unsigned long layoutAttributeOn,
  174.                        unsigned long layoutAttributeOff );
  175.  
  176. /*--------------------- Expanding/Collapsing the ToolBar ---------------------*/
  177. virtual IToolBar
  178.  &expand   ( Boolean expand = true ),
  179.  &collapse ( );
  180.  
  181. Boolean
  182.   isExpanded ( ) const;
  183.  
  184. /*------------------------------- Drag Drop Support --------------------------*/
  185. virtual IToolBar
  186.  &enableDragDrop  ( Boolean enable = true ),
  187.  &disableDragDrop ( );
  188.  
  189. Boolean
  190.   allowsDragDrop  ( ) const;
  191.  
  192.  
  193. class FrameCursor : public IVBase {
  194. typedef IVBase
  195.   Inherited;
  196. public:
  197. /*------------------------------- Constructors -------------------------------*/
  198.   FrameCursor ( const IFrameWindow* frame );
  199. virtual
  200.  ~FrameCursor ( );
  201.  
  202. /*----------------------------- Cursor Functions -----------------------------*/
  203. virtual Boolean
  204.   setToFirst ( ),
  205.   setToNext  ( ),
  206.   isValid    ( ) const;
  207.  
  208. virtual void
  209.   invalidate ( );
  210.  
  211. private:
  212. friend class IToolBar;
  213. IToolBarFrameCursorData
  214.   *fToolBarFrameCursorData;
  215. };
  216.  
  217. class WindowCursor : public IVBase {
  218. typedef IVBase
  219.   Inherited;
  220. public:
  221. /*------------------------------- Constructors -------------------------------*/
  222.   WindowCursor ( const IToolBar* toolbar );
  223. virtual
  224.  ~WindowCursor ( );
  225.  
  226. /*----------------------------- Cursor Functions -----------------------------*/
  227. virtual Boolean
  228.   setToFirst ( ),
  229.   setToNext  ( ),
  230.   isValid    ( ) const;
  231.  
  232. virtual void
  233.   invalidate ( );
  234.  
  235. private:
  236. friend class IToolBar;
  237. IToolBarWindowCursorData
  238.   *fToolBarWindowCursorData;
  239. };
  240.  
  241. /*----------------------------- Cursor Functions -----------------------------*/
  242. static IToolBar
  243.   *toolBarAt ( const FrameCursor& cursor );
  244.  
  245. IWindow
  246.   *windowAt ( const WindowCursor& cursor ) const;
  247.  
  248. protected:
  249. /*------------------------------ Initialization ------------------------------*/
  250. virtual IToolBar
  251.  &initialize       ( );
  252.  
  253. virtual IToolBarContainer
  254.  *createToolBarContainer ( IFrameWindow* frame );
  255.  
  256. virtual IToolBarFrameWindow
  257.  *createFloatingFrame    ( IFrameWindow* owner );
  258.  
  259. virtual IToolBar
  260.   &filter ( );
  261.  
  262. /*---------------------------------- Layout ----------------------------------*/
  263. virtual ISize
  264.   calcMinimumSize    ( ) const;
  265.  
  266. /*-------------------------------- Private -----------------------------------*/
  267. private:
  268. IToolBar            ( const IToolBar& );
  269. IToolBar& operator= ( const IToolBar& );
  270.  
  271. void addControl ( IControl* control,
  272.                   Boolean   newGroup );
  273.  
  274. friend class IToolBarContainer;
  275. friend class IToolBarPaintHandler;
  276. friend class IToolBar::WindowCursor;
  277.  
  278. static Style
  279.   fgCurrentDefaultStyle;
  280.  
  281. IToolBarData
  282.  *fToolBarData;
  283. };
  284.  
  285. // global style functions
  286. INESTEDBITFLAGCLASSFUNCS(Style, IToolBar);
  287.  
  288.  
  289. #pragma pack()
  290.  
  291. #endif /* _ITBAR_ */
  292.  
  293.