xref: /trunk/main/vcl/inc/vcl/toolbox.hxx (revision 0d63794c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_TOOLBOX_HXX
25 #define _SV_TOOLBOX_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/dockwin.hxx>
30 #include <vcl/image.hxx>
31 #include <vcl/timer.hxx>
32 #include <vcl/virdev.hxx>
33 
34 class UserDrawEvent;
35 
36 struct ImplToolItem;
37 struct ImplToolSizeArray;
38 struct ImplToolSize;
39 struct ImplToolBoxPrivateData;
40 class  ImplTrackRect;
41 class  PopupMenu;
42 
43 namespace vcl
44 {
45     class IImageListProvider;
46 }
47 
48 // -------------------------
49 // - ToolBoxCustomizeEvent -
50 // -------------------------
51 
52 #define TOOLBOX_CUSTOMIZE_RESIZE        ((sal_uInt16)0xFFFE)
53 
54 class VCL_DLLPUBLIC ToolBoxCustomizeEvent
55 {
56 private:
57     ToolBox*    mpTargetBox;
58     void*       mpData;
59     sal_uInt16      mnIdFrom;
60     sal_uInt16      mnPosTo;
61 
62 public:
63                 ToolBoxCustomizeEvent();
64                 ToolBoxCustomizeEvent( ToolBox* pDropBox,
65                                        sal_uInt16 nId, sal_uInt16 nPos = 0,
66                                        void* pUserData = NULL );
67 
GetTargetBox() const68     ToolBox*    GetTargetBox() const { return mpTargetBox; }
GetTargetPos() const69     sal_uInt16      GetTargetPos() const { return mnPosTo; }
GetSourceId() const70     sal_uInt16      GetSourceId() const { return mnIdFrom; }
GetData() const71     void*       GetData() const { return mpData; }
72     sal_Bool        IsResized() const;
73 };
74 
ToolBoxCustomizeEvent()75 inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent()
76 {
77     mpTargetBox = NULL;
78     mnIdFrom    = 0;
79     mnPosTo     = 0;
80     mpData      = NULL;
81 }
82 
ToolBoxCustomizeEvent(ToolBox * pDropBox,sal_uInt16 nId,sal_uInt16 nPos,void * pUserData)83 inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent( ToolBox* pDropBox,
84                                                      sal_uInt16 nId, sal_uInt16 nPos,
85                                                      void* pUserData )
86 {
87     mpTargetBox = pDropBox;
88     mnIdFrom    = nId;
89     mnPosTo     = nPos;
90     mpData      = pUserData;
91 }
92 
IsResized() const93 inline sal_Bool ToolBoxCustomizeEvent::IsResized() const
94 {
95     if ( mnPosTo == TOOLBOX_CUSTOMIZE_RESIZE )
96         return sal_True;
97     else
98         return sal_False;
99 }
100 
101 // -------------------
102 // - ToolBoxItemBits -
103 // -------------------
104 
105 typedef sal_uInt16 ToolBoxItemBits;
106 
107 // --------------------------
108 // - Bits fuer ToolBoxItems -
109 // --------------------------
110 
111 // By changes you must also change: rsc/vclrsc.hxx
112 #define TIB_CHECKABLE           ((ToolBoxItemBits)0x0001)
113 #define TIB_RADIOCHECK          ((ToolBoxItemBits)0x0002)
114 #define TIB_AUTOCHECK           ((ToolBoxItemBits)0x0004)
115 #define TIB_LEFT                ((ToolBoxItemBits)0x0008)
116 #define TIB_AUTOSIZE            ((ToolBoxItemBits)0x0010)
117 #define TIB_DROPDOWN            ((ToolBoxItemBits)0x0020)
118 #define TIB_REPEAT              ((ToolBoxItemBits)0x0040)
119 #define TIB_DROPDOWNONLY        ((ToolBoxItemBits)0x0080 | TIB_DROPDOWN)    // this button has only drop down functionality
120 #define TIB_TEXT_ONLY           ((ToolBoxItemBits)0x0100)
121 #define TIB_ICON_ONLY           ((ToolBoxItemBits)0x0200)
122 #define TIB_TEXTICON            ((ToolBoxItemBits) TIB_TEXT_ONLY | TIB_ICON_ONLY )
123 
124 // -----------------
125 // - ToolBox-Types -
126 // -----------------
127 
128 #define TOOLBOX_STYLE_OUTBUTTON     ((sal_uInt16)0x0001)
129 #define TOOLBOX_STYLE_HANDPOINTER   ((sal_uInt16)0x0002)
130 #define TOOLBOX_STYLE_FLAT          ((sal_uInt16)0x0004)
131 
132 #define TOOLBOX_APPEND              ((sal_uInt16)0xFFFF)
133 #define TOOLBOX_ITEM_NOTFOUND       ((sal_uInt16)0xFFFF)
134 
135 // item ids in the custom menu may not exceed this constant
136 #define TOOLBOX_MENUITEM_START      ((sal_uInt16)0xE000)
137 
138 // defines for the menubutton
139 #define TOOLBOX_MENUTYPE_NONE           ((sal_uInt16)0x0000)    // no menu at all, scrolling by spin buttons
140 #define TOOLBOX_MENUTYPE_CLIPPEDITEMS   ((sal_uInt16)0x0001)    // menu will contain "more" indicator
141 #define TOOLBOX_MENUTYPE_CUSTOMIZE      ((sal_uInt16)0x0002)    // menu will contain "customization" and "more" indicator
142 
143 // By changes you must also change: rsc/vclrsc.hxx
144 enum ButtonType { BUTTON_SYMBOL, BUTTON_TEXT, BUTTON_SYMBOLTEXT };
145 
146 // By changes you must also change: rsc/vclrsc.hxx
147 enum ToolBoxItemType { TOOLBOXITEM_DONTKNOW, TOOLBOXITEM_BUTTON,
148                        TOOLBOXITEM_SPACE, TOOLBOXITEM_SEPARATOR,
149                        TOOLBOXITEM_BREAK };
150 
151 // small or large force an exact toolbox size for proper alignemnt
152 // dontcare will let the toolbox decide about its size
153 enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL, TOOLBOX_BUTTONSIZE_LARGE };
154 
155 // used for internal sizing calculations
156 enum FloatingSizeMode { FSMODE_AUTO, FSMODE_FAVOURWIDTH, FSMODE_FAVOURHEIGHT };
157 
158 // -----------
159 // - ToolBox -
160 // -----------
161 
162 class VCL_DLLPUBLIC ToolBox : public DockingWindow
163 {
164     friend class FloatingWindow;
165     friend class ImplTBDragMgr;
166 
167 private:
168     ImplToolBoxPrivateData*		mpData;
169     VirtualDevice*      		mpBtnDev; // TODO: remove unused member
170     ImplToolSizeArray*  mpFloatSizeAry;
171     XubString           maCvtStr;
172     XubString           maNextToolBoxStr;
173     ImageList           maImageList;
174     Timer               maTimer;
175     Rectangle           maUpperRect;
176     Rectangle           maLowerRect;
177     Rectangle           maNextToolRect;
178     Rectangle           maOutDockRect;
179     Rectangle           maInDockRect;
180     Rectangle           maPaintRect;
181     FloatingWindow*     mpFloatWin;
182     sal_uInt16              mnKeyModifier;
183     long                mnDX;
184     long                mnDY;
185     long                mnMaxItemWidth;    // max item width
186     long                mnMaxItemHeight;   // max item height (for standard items)
187     long                mnWinHeight;    // max window height (for window items)
188     long                mnBorderX;      // custom border
189     long                mnBorderY;
190     long                mnLeftBorder;   // inner border
191     long                mnTopBorder;
192     long                mnRightBorder;
193     long                mnBottomBorder;
194     long                mnLastResizeDY;
195     long                mnActivateCount;
196     sal_uInt16              mnLastFocusItemId;
197 	sal_uInt16				mnFocusPos;
198     sal_uInt16              mnOutStyle;
199     sal_uInt16              mnHighItemId;
200     sal_uInt16              mnCurItemId;
201     sal_uInt16              mnDownItemId;
202     sal_uInt16              mnCurPos;
203     sal_uInt16              mnLines;        // total number of toolbox lines
204     sal_uInt16              mnCurLine;      // the currently visible line
205     sal_uInt16              mnCurLines;     // number of lines due to line breaking
206     sal_uInt16              mnVisLines;     // number of visible lines (for scrolling)
207     sal_uInt16              mnFloatLines;   // number of lines during floating mode
208     sal_uInt16              mnDockLines;
209     sal_uInt16              mnConfigItem;
210     sal_uInt16              mnMouseClicks;
211     sal_uInt16              mnMouseModifier;
212     unsigned int        mbDrag:1,
213                         mbSelection:1,
214                         mbCommandDrag:1,
215                         mbUpper:1,
216                         mbLower:1,
217                         mbNextTool:1,
218                         mbIn:1,
219                         mbCalc:1,
220                         mbFormat:1,
221                         mbFullPaint:1,
222                         mbHorz:1,
223                         mbScroll:1,
224                         mbLastFloatMode:1,
225                         mbCustomize:1,
226                         mbCustomizeMode:1,
227                         mbDragging:1,
228                         mbHideStatusText:1,
229                         mbMenuStrings:1,
230                         mbIsShift:1,
231                         mbIsKeyEvent:1,
232                         mbChangingHighlight:1;
233     WindowAlign         meAlign;
234     WindowAlign         meDockAlign;
235     ButtonType          meButtonType;
236     PointerStyle        meLastStyle;
237     WinBits             mnWinStyle;
238     Link                maClickHdl;
239     Link                maDoubleClickHdl;
240     Link                maActivateHdl;
241     Link                maDeactivateHdl;
242     Link                maHighlightHdl;
243     Link                maSelectHdl;
244     Link                maNextToolBoxHdl;
245 
246     public:
247     using Window::ImplInit;
248     private:
249     SAL_DLLPRIVATE void            ImplInit( Window* pParent, WinBits nStyle );
250 //    #if 0 // _SOLAR__PRIVATE
251     using DockingWindow::ImplInitSettings;
252 //    #endif
253     SAL_DLLPRIVATE void            ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
254     SAL_DLLPRIVATE void            ImplLoadRes( const ResId& rResId );
255     SAL_DLLPRIVATE ImplToolItem*   ImplGetItem( sal_uInt16 nId ) const;
256     SAL_DLLPRIVATE sal_Bool            ImplCalcItem();
257     SAL_DLLPRIVATE sal_uInt16          ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool bCalcHorz );
258     SAL_DLLPRIVATE void            ImplFormat( sal_Bool bResize = sal_False );
259     SAL_DLLPRIVATE void            ImplDrawSpin( sal_Bool bUpperIn, sal_Bool bLowerIn );
260     SAL_DLLPRIVATE void            ImplDrawNext( sal_Bool bIn );
261     SAL_DLLPRIVATE void            ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight = sal_False, sal_Bool bPaint = sal_False, sal_Bool bLayout = sal_False );
262     using Window::ImplInvalidate;
263     SAL_DLLPRIVATE void            ImplInvalidate( sal_Bool bNewCalc = sal_False, sal_Bool bFullPaint = sal_False );
264     SAL_DLLPRIVATE void            ImplUpdateItem( sal_uInt16 nIndex = 0xFFFF );
265     SAL_DLLPRIVATE void            ImplStartCustomizeMode();
266     SAL_DLLPRIVATE void            ImplEndCustomizeMode();
267     SAL_DLLPRIVATE const XubString& ImplConvertMenuString( const XubString& rStr );
268     SAL_DLLPRIVATE sal_Bool            ImplHandleMouseMove( const MouseEvent& rMEvt, sal_Bool bRepeat = sal_False );
269     SAL_DLLPRIVATE sal_Bool            ImplHandleMouseButtonUp( const MouseEvent& rMEvt, sal_Bool bCancel = sal_False );
270 	SAL_DLLPRIVATE void			   ImplChangeHighlight( ImplToolItem* pItem, sal_Bool bNoGrabFocus = sal_False );
271 	SAL_DLLPRIVATE sal_Bool			   ImplChangeHighlightUpDn( sal_Bool bUp, sal_Bool bNoCycle = sal_False );
272     SAL_DLLPRIVATE sal_uInt16          ImplGetItemLine( ImplToolItem* pCurrentItem );
273     SAL_DLLPRIVATE ImplToolItem*   ImplGetFirstValidItem( sal_uInt16 nLine );
274     SAL_DLLPRIVATE ImplToolItem*   ImplGetLastValidItem( sal_uInt16 nLine );
275     SAL_DLLPRIVATE sal_Bool            ImplOpenItem( KeyCode aKeyCode );
276     SAL_DLLPRIVATE sal_Bool            ImplActivateItem( KeyCode aKeyCode );
277     SAL_DLLPRIVATE void            ImplShowFocus();
278     SAL_DLLPRIVATE void            ImplHideFocus();
279 	SAL_DLLPRIVATE void			   ImplUpdateInputEnable();
280     SAL_DLLPRIVATE void			   ImplFillLayoutData() const;
281     SAL_DLLPRIVATE void            ImplUpdateCustomMenu();
282     SAL_DLLPRIVATE sal_Bool            ImplHasClippedItems();
283     SAL_DLLPRIVATE Point           ImplGetPopupPosition( const Rectangle& rRect, const Size& rSize ) const;
284     SAL_DLLPRIVATE void            ImplExecuteCustomMenu();
285     SAL_DLLPRIVATE sal_Bool            ImplIsFloatingMode() const;
286     SAL_DLLPRIVATE sal_Bool            ImplIsInPopupMode() const;
287     SAL_DLLPRIVATE const XubString& ImplGetHelpText( sal_uInt16 nItemId ) const;
288     SAL_DLLPRIVATE Size            ImplGetOptimalFloatingSize( FloatingSizeMode eMode );
289     SAL_DLLPRIVATE sal_Bool            ImplHasExternalMenubutton();
290     SAL_DLLPRIVATE void            ImplDrawFloatwinBorder( ImplToolItem* pItem );
291 
292     DECL_DLLPRIVATE_LINK(          ImplCallExecuteCustomMenu, void* );
293     DECL_DLLPRIVATE_LINK(          ImplUpdateHdl, void* );
294     DECL_DLLPRIVATE_LINK(          ImplResetAutoSizeTriesHdl, void* );
295     DECL_DLLPRIVATE_LINK(          ImplCustomMenuListener, VclMenuEvent* );
296     DECL_DLLPRIVATE_LINK(          ImplDropdownLongClickHdl, ToolBox* );
297 
298 //#if 0 // _SOLAR__PRIVATE
299     // Copy assignment is forbidden and not implemented.
300 	SAL_DLLPRIVATE                 ToolBox (const ToolBox &);
301 	SAL_DLLPRIVATE        ToolBox& operator= (const ToolBox &);
302 
303     SAL_DLLPRIVATE void            ImplUpdateImageList(); // called if StateChanged
304 public:
305     SAL_DLLPRIVATE void            ImplFloatControl( sal_Bool bStart, FloatingWindow* pWindow = NULL );
306 	SAL_DLLPRIVATE void            ImplDisableFlatButtons();
307 
308     static SAL_DLLPRIVATE int ImplGetDragWidth( ToolBox* pThis );
309     static SAL_DLLPRIVATE void ImplUpdateDragArea( ToolBox *pThis );
310     static SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop,
311                                                long& rRight, long& rBottom, const ToolBox *pThis );
312     static SAL_DLLPRIVATE void ImplDrawGrip( ToolBox* pThis );
313     static SAL_DLLPRIVATE void ImplDrawGradientBackground( ToolBox* pThis, ImplDockingWindowWrapper *pWrapper );
314     static SAL_DLLPRIVATE sal_Bool ImplDrawNativeBackground( ToolBox* pThis, const Region &rRegion );
315     static SAL_DLLPRIVATE void ImplDrawTransparentBackground( ToolBox* pThis, const Region &rRegion );
316     static SAL_DLLPRIVATE void ImplDrawConstantBackground( ToolBox* pThis, const Region &rRegion, sal_Bool bIsInPopupMode );
317     static SAL_DLLPRIVATE void ImplDrawBackground( ToolBox* pThis, const Rectangle &rRect );
318     static SAL_DLLPRIVATE void ImplErase( ToolBox* pThis, const Rectangle &rRect, sal_Bool bHighlight = sal_False, sal_Bool bHasOpenPopup = sal_False );
319     static SAL_DLLPRIVATE void ImplDrawBorder( ToolBox* pWin );
320     static SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem( const ToolBox* pThis );
321     static SAL_DLLPRIVATE Size ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uInt16 nCalcMode = 0 );
322     static SAL_DLLPRIVATE void ImplCalcFloatSizes( ToolBox* pThis );
323     static SAL_DLLPRIVATE Size ImplCalcFloatSize( ToolBox* pThis, sal_uInt16& rLines );
324     static SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( ToolBox* pThis, Size& rMinSize, Size& rMaxSize );
325     static SAL_DLLPRIVATE void ImplSetMinMaxFloatSize( ToolBox *pThis );
326     static SAL_DLLPRIVATE sal_uInt16 ImplCalcLines( ToolBox* pThis, long nToolSize );
327     static SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( ToolBox* pThis, const Point& rPos );
328     static SAL_DLLPRIVATE void ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode );
329     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( ToolBox* pBox, const Point& rPos );
330     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList );
331     static SAL_DLLPRIVATE void ImplDrawToolArrow( ToolBox* pBox, long nX, long nY, sal_Bool bBlack, sal_Bool bColTransform,
332                                                   sal_Bool bLeft = sal_False, sal_Bool bTop = sal_False,
333                                                   long nSize = 6 );
334     static SAL_DLLPRIVATE void SetToolArrowClipregion( ToolBox* pBox, long nX, long nY,
335                                                        sal_Bool bLeft = sal_False, sal_Bool bTop = sal_False,
336                                                        long nSize = 6 );
337     static SAL_DLLPRIVATE void ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight );
338     static SAL_DLLPRIVATE sal_uInt16 ImplCountLineBreaks( const ToolBox *pThis );
ImplGetToolBoxPrivateData() const339     SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData; }
340 //#endif
341 
342 protected:
SetCurItemId(sal_uInt16 nSet)343     void                SetCurItemId(sal_uInt16 nSet) { mnCurItemId = nSet; }
344 
345 public:
346                         ToolBox( Window* pParent, WinBits nStyle = 0 );
347                         ToolBox( Window* pParent, const ResId& rResId );
348                         ~ToolBox();
349 
350     virtual void        Click();
351     virtual void        DoubleClick();
352     virtual void        Activate();
353     virtual void        Deactivate();
354     virtual void        Highlight();
355     virtual void        Select();
356     virtual void        NextToolBox();
357     virtual void        Customize( const ToolBoxCustomizeEvent& rCEvt );
358     virtual void        UserDraw( const UserDrawEvent& rUDEvt );
359 
360     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
361     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
362     virtual void        MouseMove( const MouseEvent& rMEvt );
363     virtual void        Tracking( const TrackingEvent& rTEvt );
364     virtual void        Paint( const Rectangle& rRect );
365     virtual void        Move();
366     virtual void        Resize();
367     virtual void        RequestHelp( const HelpEvent& rHEvt );
368     virtual long        Notify( NotifyEvent& rNEvt );
369     virtual void        Command( const CommandEvent& rCEvt );
370     virtual void        StateChanged( StateChangedType nType );
371     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
372 
373 	virtual void        GetFocus();
374 	virtual void        LoseFocus();
375 	virtual void        KeyInput( const KeyEvent& rKEvt );
376 
377     virtual sal_Bool        PrepareToggleFloatingMode();
378     virtual void        ToggleFloatingMode();
379     virtual void        StartDocking();
380     virtual sal_Bool        Docking( const Point& rPos, Rectangle& rRect );
381     virtual void        EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
382     virtual void        Resizing( Size& rSize );
383 
384     void                InsertItem( const ResId& rResId,
385                                     sal_uInt16 nPos = TOOLBOX_APPEND );
386     void                InsertItem( sal_uInt16 nItemId, const Image& rImage,
387                                     ToolBoxItemBits nBits = 0,
388                                     sal_uInt16 nPos = TOOLBOX_APPEND );
389     void                InsertItem( sal_uInt16 nItemId, const Image& rImage,
390                                     const XubString& rText,
391                                     ToolBoxItemBits nBits = 0,
392                                     sal_uInt16 nPos = TOOLBOX_APPEND );
393     void                InsertItem( sal_uInt16 nItemId, const XubString& rText,
394                                     ToolBoxItemBits nBits = 0,
395                                     sal_uInt16 nPos = TOOLBOX_APPEND );
396     void                InsertWindow( sal_uInt16 nItemId, Window* pWindow,
397                                       ToolBoxItemBits nBits = 0,
398                                       sal_uInt16 nPos = TOOLBOX_APPEND );
399     void                InsertSpace( sal_uInt16 nPos = TOOLBOX_APPEND );
400     void                InsertSeparator( sal_uInt16 nPos = TOOLBOX_APPEND,
401                                          sal_uInt16 nPixSize = 0 );
402     void                InsertBreak( sal_uInt16 nPos = TOOLBOX_APPEND );
403     void                RemoveItem( sal_uInt16 nPos );
404     void                MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos = TOOLBOX_APPEND );
405     void                CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId,
406                                   sal_uInt16 nNewPos = TOOLBOX_APPEND );
407     void                CopyItems( const ToolBox& rToolBox );
408     void                Clear();
409     void                RecalcItems();
410 
GetImageList() const411     const ImageList&    GetImageList() const { return maImageList; }
412     void				SetImageList( const ImageList& rImageList );
413 
414     void                SetButtonType( ButtonType eNewType = BUTTON_SYMBOL );
GetButtonType() const415     ButtonType          GetButtonType() const { return meButtonType; }
416 
417     // sets a fixed button size (small, large or dontcare (==autosize))
418     void                SetToolboxButtonSize( ToolBoxButtonSize eSize );
419     ToolBoxButtonSize   GetToolboxButtonSize() const;
420 
421     void                SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP );
GetAlign() const422     WindowAlign         GetAlign() const { return meAlign; }
IsHorizontal() const423     sal_Bool                IsHorizontal() const { return mbHorz; }
424 
425     void                SetLineCount( sal_uInt16 nNewLines );
GetLineCount() const426     sal_uInt16              GetLineCount() const { return mnLines; }
GetCurLine() const427     sal_uInt16              GetCurLine() const { return mnCurLine; }
428     void                ShowLine( sal_Bool bNext );
429 
430     // Used to enable/disable scrolling one page at a time for toolbar
431     void                SetPageScroll( sal_Bool b );
432     sal_Bool                GetPageScroll();
433 
434     void                SetNextToolBox( const XubString& rStr );
GetNextToolBox() const435     const XubString&    GetNextToolBox() const { return maNextToolBoxStr; }
436 
437     sal_uInt16              GetItemCount() const;
438     ToolBoxItemType     GetItemType( sal_uInt16 nPos ) const;
439     sal_uInt16              GetItemPos( sal_uInt16 nItemId ) const;
440     sal_uInt16              GetItemPos( const Point& rPos ) const;
441     sal_uInt16              GetItemId( sal_uInt16 nPos ) const;
442     sal_uInt16              GetItemId( const Point& rPos ) const;
443     Rectangle           GetItemRect( sal_uInt16 nItemId ) const;
444     Rectangle           GetItemPosRect( sal_uInt16 nPos ) const;
445     Rectangle           GetItemDropDownRect( sal_uInt16 nItemId ) const;
446     Rectangle           GetItemPosDropDownRect( sal_uInt16 nPos ) const;
447 
448     // retrieves the optimal position to place a popup window for this item (subtoolbar or dropdown)
449     Point               GetItemPopupPosition( sal_uInt16 nItemId, const Size& rSize ) const;
450 
451     Rectangle           GetScrollRect() const;
452     Rectangle           GetMenubuttonRect() const;
GetCurItemId() const453     sal_uInt16              GetCurItemId() const { return mnCurItemId; }
GetDownItemId() const454     sal_uInt16              GetDownItemId() const { return mnDownItemId; }
GetClicks() const455     sal_uInt16              GetClicks() const { return mnMouseClicks; }
GetModifier() const456     sal_uInt16              GetModifier() const { return mnMouseModifier; }
GetKeyModifier() const457 	sal_uInt16				GetKeyModifier() const { return mnKeyModifier; }
458 
459     void                SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits );
460     ToolBoxItemBits     GetItemBits( sal_uInt16 nItemId ) const;
461 
462     void                SetItemData( sal_uInt16 nItemId, void* pNewData );
463     void*               GetItemData( sal_uInt16 nItemId ) const;
464     void                SetItemImage( sal_uInt16 nItemId, const Image& rImage );
465     Image               GetItemImage( sal_uInt16 nItemId ) const;
466     void				SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
467     long				GetItemImageAngle( sal_uInt16 nItemId ) const;
468     void				SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror );
469     sal_Bool				GetItemImageMirrorMode( sal_uInt16 ) const;
470     void                SetItemHighImage( sal_uInt16 nItemId, const Image& rImage );
471     Image               GetItemHighImage( sal_uInt16 nItemId ) const;
472     void                SetItemText( sal_uInt16 nItemId, const XubString& rText );
473     const XubString&    GetItemText( sal_uInt16 nItemId ) const;
474     void                SetItemWindow( sal_uInt16 nItemId, Window* pNewWindow );
475     Window*             GetItemWindow( sal_uInt16 nItemId ) const;
GetHighlightItemId() const476     sal_uInt16              GetHighlightItemId() const { return mnHighItemId; }
477 
478     void                StartSelection();
479     void                EndSelection();
480 
481     void                SetItemDown( sal_uInt16 nItemId, sal_Bool bDown, sal_Bool bRelease = sal_True );
482     sal_Bool                IsItemDown( sal_uInt16 nItemId ) const;
483 
484     void                SetItemState( sal_uInt16 nItemId, TriState eState );
485     TriState            GetItemState( sal_uInt16 nItemId ) const;
486 
487     void                CheckItem( sal_uInt16 nItemId, sal_Bool bCheck = sal_True );
488     sal_Bool                IsItemChecked( sal_uInt16 nItemId ) const;
489 
490     void                EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True );
491     sal_Bool                IsItemEnabled( sal_uInt16 nItemId ) const;
492 
493     void                TriggerItem( sal_uInt16 nItemId, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False );
494     void                ShowItem( sal_uInt16 nItemId, sal_Bool bVisible = sal_True );
HideItem(sal_uInt16 nItemId)495     void                HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, sal_False ); }
496     sal_Bool                IsItemVisible( sal_uInt16 nItemId ) const;
497     sal_Bool                IsItemReallyVisible( sal_uInt16 nItemId ) const;
498 
499     void                SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
500     const XubString&    GetItemCommand( sal_uInt16 nItemId ) const;
501 
502     using Window::SetQuickHelpText;
503     void                SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText );
504     using Window::GetQuickHelpText;
505     const XubString&    GetQuickHelpText( sal_uInt16 nItemId ) const;
506 
507     void                SetHelpText( sal_uInt16 nItemId, const XubString& rText );
508     const XubString&    GetHelpText( sal_uInt16 nItemId ) const;
509 
510     void                SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
511     rtl::OString        GetHelpId( sal_uInt16 nItemId ) const;
512 
513     //  window size according to current alignment, floating state and number of lines
514     Size                CalcWindowSizePixel() const;
515     //  window size according to current alignment, floating state and a given number of lines
516     Size                CalcWindowSizePixel( sal_uInt16 nCalcLines ) const;
517     //  window size according to current floating state and a given number of lines and a given alignment
518     Size                CalcWindowSizePixel( sal_uInt16 nCalcLines, WindowAlign eAlign ) const;
519     // floating window size according to number of lines (uses the number of line breaks)
520     Size                CalcFloatingWindowSizePixel() const;
521     // floating window size with a given number of lines
522     Size                CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const;
523     // automatic window size for popoup mode
524     Size                CalcPopupWindowSizePixel() const;
525 
526     // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
527     Size                CalcMinimumWindowSizePixel() const;
528 
529     void                SetDockingRects( const Rectangle& rOutRect,
530                                          const Rectangle& rInRect );
531     void                SetFloatingLines( sal_uInt16 nFloatLines );
532     sal_uInt16              GetFloatingLines() const;
533 
534     void                SetBorder( long nX, long nY );
GetBorderX() const535     long                GetBorderX() const { return mnBorderX; }
GetBorderY() const536     long                GetBorderY() const { return mnBorderY; }
537 
SetStyle(WinBits nNewStyle)538     void                SetStyle( WinBits nNewStyle ) { mnWinStyle = nNewStyle; }
GetStyle() const539     WinBits             GetStyle() const { return mnWinStyle; }
540 
541     // enable/disable undocking
542     void                Lock( sal_Bool bLock = sal_True );
543 
544     // read configuration to determine locking behaviour
545     static sal_Bool         AlwaysLocked();
546 
EnableMenuStrings(sal_Bool bEnable=sal_True)547     void                EnableMenuStrings( sal_Bool bEnable = sal_True ) { mbMenuStrings = (bEnable != 0); }
IsMenuStringsEnabled() const548     sal_Bool                IsMenuStringsEnabled() const { return mbMenuStrings; }
549 
550     void                SetOutStyle( sal_uInt16 nNewStyle );
GetOutStyle() const551     sal_uInt16              GetOutStyle() const { return mnOutStyle; }
552 
553     void                EnableCustomize( sal_Bool bEnable = sal_True );
IsCustomize()554     sal_Bool                IsCustomize() { return mbCustomize; }
555     void                StartCustomize( const Rectangle& rRect, void* pData = NULL );
556     void                SetCustomizeMode( sal_Bool );
IsInCustomizeMode() const557     sal_Bool                IsInCustomizeMode() const { return mbCustomizeMode; }
558 
559     static void         StartCustomizeMode();
560     static void         EndCustomizeMode();
561     static sal_Bool         IsCustomizeMode();
562 
SetHelpText(const XubString & rText)563     void                SetHelpText( const XubString& rText )
564                             { DockingWindow::SetHelpText( rText ); }
GetHelpText() const565     const XubString&    GetHelpText() const
566                             { return DockingWindow::GetHelpText(); }
567 
SetHelpId(const rtl::OString & rId)568     void                SetHelpId( const rtl::OString& rId )
569                             { DockingWindow::SetHelpId( rId ); }
GetHelpId() const570     const rtl::OString& GetHelpId() const
571                             { return DockingWindow::GetHelpId(); }
572 
SetClickHdl(const Link & rLink)573     void                SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
GetClickHdl() const574     const Link&         GetClickHdl() const { return maClickHdl; }
SetDoubleClickHdl(const Link & rLink)575     void                SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
GetDoubleClickHdl() const576     const Link&         GetDoubleClickHdl() const { return maDoubleClickHdl; }
577     void                SetDropdownClickHdl( const Link& rLink );
578     const Link&         GetDropdownClickHdl() const;
SetActivateHdl(const Link & rLink)579     void                SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
GetActivateHdl() const580     const Link&         GetActivateHdl() const { return maActivateHdl; }
SetDeactivateHdl(const Link & rLink)581     void                SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
GetDeactivateHdl() const582     const Link&         GetDeactivateHdl() const { return maDeactivateHdl; }
SetHighlightHdl(const Link & rLink)583     void                SetHighlightHdl( const Link& rLink ) { maHighlightHdl = rLink; }
GetHighlightHdl() const584     const Link&         GetHighlightHdl() const { return maHighlightHdl; }
SetSelectHdl(const Link & rLink)585     void                SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
GetSelectHdl() const586     const Link&         GetSelectHdl() const { return maSelectHdl; }
SetNextToolBoxHdl(const Link & rLink)587     void                SetNextToolBoxHdl( const Link& rLink ) { maNextToolBoxHdl = rLink; }
GetNextToolBoxHdl() const588     const Link&         GetNextToolBoxHdl() const { return maNextToolBoxHdl; }
589 
590     // support for custom menu (eg for configuration)
591     // note: this menu will also be used to display currently
592     //       clipped toolbox items, so you should only touch
593     //       items that you added by yourself
594     //       the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
595     // to allow for customization of the menu the coresponding handler is called
596     // when the menu button was clicked and before the menu is executed
597     void                SetMenuType( sal_uInt16 aType = TOOLBOX_MENUTYPE_CUSTOMIZE );
598     sal_uInt16              GetMenuType() const;
599     sal_Bool                IsMenuEnabled() const;
600     PopupMenu*          GetMenu() const;
601     void                SetMenuButtonHdl( const Link& rLink );
602     const Link&         GetMenuButtonHdl() const;
603 
604     // open custommenu
605     void                ExecuteCustomMenu();
606 
607     // allow Click Handler to detect special key
IsShift() const608     sal_Bool                IsShift() const { return mbIsShift; }
609     // allow Click Handler to distinguish between mouse and key input
IsKeyEvent() const610     sal_Bool                IsKeyEvent() const { return mbIsKeyEvent; }
611 
612     // allows framework to set/query the planned popupmode
613     sal_Bool                WillUsePopupMode() const;
614     void                WillUsePopupMode( sal_Bool b);
615 
616     // accessibility helpers
617 
618     // gets the displayed text
619     String GetDisplayText() const;
620     // returns the bounding box for the character at index nIndex
621 	// where nIndex is relative to the starting index of the item
622     // with id nItemId (in coordinates of the displaying window)
623     Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const;
624     // -1 is returned if no character is at that point
625     // if an index is found the corresponding item id is filled in (else 0)
626     long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const;
627     // returns the number of portions in the result of GetDisplayText()
628     long GetTextCount() const;
629     // returns the interval [start,end] of text portion nText
630     // returns [-1,-1] for an invalid text number
631     Pair GetTextStartEnd( long nText ) const;
632     // returns the item id for text portion nText or 0 if nText is invalid
633     sal_uInt16 GetDisplayItemId( long nText ) const;
634 
635     const Size&         GetDefaultImageSize() const;
636     void                ChangeHighlight( sal_uInt16 nPos );
637 
638     void SetImageListProvider(vcl::IImageListProvider* _pProvider);
639 };
640 
CheckItem(sal_uInt16 nItemId,sal_Bool bCheck)641 inline void ToolBox::CheckItem( sal_uInt16 nItemId, sal_Bool bCheck )
642 {
643     SetItemState( nItemId, (bCheck) ? STATE_CHECK : STATE_NOCHECK );
644 }
645 
IsItemChecked(sal_uInt16 nItemId) const646 inline sal_Bool ToolBox::IsItemChecked( sal_uInt16 nItemId ) const
647 {
648     return (GetItemState( nItemId ) == STATE_CHECK);
649 }
650 
CalcWindowSizePixel() const651 inline Size ToolBox::CalcWindowSizePixel() const
652 {
653     return CalcWindowSizePixel( mnLines );
654 }
655 
GetScrollRect() const656 inline Rectangle ToolBox::GetScrollRect() const
657 {
658     return maUpperRect.GetUnion( maLowerRect );
659 }
660 
SetDockingRects(const Rectangle & rOutRect,const Rectangle & rInRect)661 inline void ToolBox::SetDockingRects( const Rectangle& rOutRect,
662                                       const Rectangle& rInRect )
663 {
664     maOutDockRect = rOutRect;
665     maInDockRect = rInRect;
666 }
667 
SetFloatingLines(sal_uInt16 nNewLines)668 inline void ToolBox::SetFloatingLines( sal_uInt16 nNewLines )
669 {
670     mnFloatLines = nNewLines;
671 }
672 
GetFloatingLines() const673 inline sal_uInt16 ToolBox::GetFloatingLines() const
674 {
675     return mnFloatLines;
676 }
677 
678 #endif  // _SV_TOOLBOX_HXX
679