Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_TOOLBOX_HXX
30 : : #define _SV_TOOLBOX_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/dockwin.hxx>
35 : : #include <vcl/image.hxx>
36 : : #include <vcl/timer.hxx>
37 : : #include <vector>
38 : :
39 : : class UserDrawEvent;
40 : :
41 : : struct ImplToolItem;
42 : : struct ImplToolSize;
43 : : struct ImplToolBoxPrivateData;
44 : : class ImplTrackRect;
45 : : class PopupMenu;
46 : :
47 : : namespace vcl
48 : : {
49 : : class IImageListProvider;
50 : : }
51 : :
52 : : // -------------------------
53 : : // - ToolBoxCustomizeEvent -
54 : : // -------------------------
55 : :
56 : : #define TOOLBOX_CUSTOMIZE_RESIZE ((sal_uInt16)0xFFFE)
57 : :
58 : : class VCL_DLLPUBLIC ToolBoxCustomizeEvent
59 : : {
60 : : private:
61 : : ToolBox* mpTargetBox;
62 : : void* mpData;
63 : : sal_uInt16 mnIdFrom;
64 : : sal_uInt16 mnPosTo;
65 : :
66 : : public:
67 : : ToolBoxCustomizeEvent();
68 : : ToolBoxCustomizeEvent( ToolBox* pDropBox,
69 : : sal_uInt16 nId, sal_uInt16 nPos = 0,
70 : : void* pUserData = NULL );
71 : :
72 : : ToolBox* GetTargetBox() const { return mpTargetBox; }
73 : : sal_uInt16 GetTargetPos() const { return mnPosTo; }
74 : : sal_uInt16 GetSourceId() const { return mnIdFrom; }
75 : : void* GetData() const { return mpData; }
76 : : sal_Bool IsResized() const;
77 : : };
78 : :
79 : : inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent()
80 : : {
81 : : mpTargetBox = NULL;
82 : : mnIdFrom = 0;
83 : : mnPosTo = 0;
84 : : mpData = NULL;
85 : : }
86 : :
87 : 0 : inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent( ToolBox* pDropBox,
88 : : sal_uInt16 nId, sal_uInt16 nPos,
89 : : void* pUserData )
90 : : {
91 : 0 : mpTargetBox = pDropBox;
92 : 0 : mnIdFrom = nId;
93 : 0 : mnPosTo = nPos;
94 : 0 : mpData = pUserData;
95 : 0 : }
96 : :
97 : : inline sal_Bool ToolBoxCustomizeEvent::IsResized() const
98 : : {
99 : : if ( mnPosTo == TOOLBOX_CUSTOMIZE_RESIZE )
100 : : return sal_True;
101 : : else
102 : : return sal_False;
103 : : }
104 : :
105 : : // -------------------
106 : : // - ToolBoxItemBits -
107 : : // -------------------
108 : :
109 : : typedef sal_uInt16 ToolBoxItemBits;
110 : :
111 : : // --------------------------
112 : : // - Bits fuer ToolBoxItems -
113 : : // --------------------------
114 : :
115 : : // By changes you must also change: rsc/vclrsc.hxx
116 : : #define TIB_CHECKABLE ((ToolBoxItemBits)0x0001)
117 : : #define TIB_RADIOCHECK ((ToolBoxItemBits)0x0002)
118 : : #define TIB_AUTOCHECK ((ToolBoxItemBits)0x0004)
119 : : #define TIB_LEFT ((ToolBoxItemBits)0x0008)
120 : : #define TIB_AUTOSIZE ((ToolBoxItemBits)0x0010)
121 : : #define TIB_DROPDOWN ((ToolBoxItemBits)0x0020)
122 : : #define TIB_REPEAT ((ToolBoxItemBits)0x0040)
123 : : #define TIB_DROPDOWNONLY ((ToolBoxItemBits)0x0080 | TIB_DROPDOWN) // this button has only drop down functionality
124 : : #define TIB_TEXT_ONLY ((ToolBoxItemBits)0x0100)
125 : : #define TIB_ICON_ONLY ((ToolBoxItemBits)0x0200)
126 : : #define TIB_TEXTICON ((ToolBoxItemBits) TIB_TEXT_ONLY | TIB_ICON_ONLY )
127 : :
128 : : // -----------------
129 : : // - ToolBox-Types -
130 : : // -----------------
131 : :
132 : : #define TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004)
133 : :
134 : : #define TOOLBOX_APPEND ((sal_uInt16)0xFFFF)
135 : : #define TOOLBOX_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
136 : :
137 : : // item ids in the custom menu may not exceed this constant
138 : : #define TOOLBOX_MENUITEM_START ((sal_uInt16)0xE000)
139 : :
140 : : // defines for the menubutton
141 : : #define TOOLBOX_MENUTYPE_NONE ((sal_uInt16)0x0000) // no menu at all, scrolling by spin buttons
142 : : #define TOOLBOX_MENUTYPE_CLIPPEDITEMS ((sal_uInt16)0x0001) // menu will contain "more" indicator
143 : : #define TOOLBOX_MENUTYPE_CUSTOMIZE ((sal_uInt16)0x0002) // menu will contain "customization" and "more" indicator
144 : :
145 : : // By changes you must also change: rsc/vclrsc.hxx
146 : : enum ButtonType { BUTTON_SYMBOL, BUTTON_TEXT, BUTTON_SYMBOLTEXT };
147 : :
148 : : // By changes you must also change: rsc/vclrsc.hxx
149 : : enum ToolBoxItemType { TOOLBOXITEM_DONTKNOW, TOOLBOXITEM_BUTTON,
150 : : TOOLBOXITEM_SPACE, TOOLBOXITEM_SEPARATOR,
151 : : TOOLBOXITEM_BREAK };
152 : :
153 : : // small or large force an exact toolbox size for proper alignemnt
154 : : // dontcare will let the toolbox decide about its size
155 : : enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL, TOOLBOX_BUTTONSIZE_LARGE };
156 : :
157 : : // TBX_LAYOUT_NORMAL - traditional layout, items are centered in the toolbar
158 : : // TBX_LAYOUT_LOCKVERT - special mode (currently used for calc input/formula
159 : : // bar) where item's vertical position is locked, e.g.
160 : : // toolbox is prevented from centering the items
161 : : enum ToolBoxLayoutMode { TBX_LAYOUT_NORMAL, TBX_LAYOUT_LOCKVERT };
162 : :
163 : : struct ImplToolSize
164 : : {
165 : : long mnWidth;
166 : : long mnHeight;
167 : : sal_uInt16 mnLines;
168 : : };
169 : :
170 : : // -----------
171 : : // - ToolBox -
172 : : // -----------
173 : :
174 : : class VCL_DLLPUBLIC ToolBox : public DockingWindow
175 : : {
176 : : friend class FloatingWindow;
177 : : friend class ImplTBDragMgr;
178 : :
179 : : private:
180 : : ImplToolBoxPrivateData* mpData;
181 : : std::vector<ImplToolSize> maFloatSizes;
182 : : ImageList maImageList;
183 : : Timer maTimer;
184 : : Rectangle maUpperRect;
185 : : Rectangle maLowerRect;
186 : : Rectangle maOutDockRect;
187 : : Rectangle maInDockRect;
188 : : Rectangle maPaintRect;
189 : : FloatingWindow* mpFloatWin;
190 : : sal_uInt16 mnKeyModifier;
191 : : long mnDX;
192 : : long mnDY;
193 : : long mnMaxItemWidth; // max item width
194 : : long mnMaxItemHeight; // max item height (for standard items)
195 : : long mnWinHeight; // max window height (for window items)
196 : : long mnLeftBorder; // inner border
197 : : long mnTopBorder;
198 : : long mnRightBorder;
199 : : long mnBottomBorder;
200 : : long mnLastResizeDY;
201 : : long mnActivateCount;
202 : : sal_uInt16 mnLastFocusItemId;
203 : : sal_uInt16 mnFocusPos;
204 : : sal_uInt16 mnOutStyle;
205 : : sal_uInt16 mnHighItemId;
206 : : sal_uInt16 mnCurItemId;
207 : : sal_uInt16 mnDownItemId;
208 : : sal_uInt16 mnCurPos;
209 : : sal_uInt16 mnLines; // total number of toolbox lines
210 : : sal_uInt16 mnCurLine; // the currently visible line
211 : : sal_uInt16 mnCurLines; // number of lines due to line breaking
212 : : sal_uInt16 mnVisLines; // number of visible lines (for scrolling)
213 : : sal_uInt16 mnFloatLines; // number of lines during floating mode
214 : : sal_uInt16 mnDockLines;
215 : : sal_uInt16 mnConfigItem;
216 : : sal_uInt16 mnMouseClicks;
217 : : sal_uInt16 mnMouseModifier;
218 : : unsigned int mbDrag:1,
219 : : mbSelection:1,
220 : : mbCommandDrag:1,
221 : : mbUpper:1,
222 : : mbLower:1,
223 : : mbIn:1,
224 : : mbCalc:1,
225 : : mbFormat:1,
226 : : mbFullPaint:1,
227 : : mbHorz:1,
228 : : mbScroll:1,
229 : : mbLastFloatMode:1,
230 : : mbCustomize:1,
231 : : mbCustomizeMode:1,
232 : : mbDragging:1,
233 : : mbMenuStrings:1,
234 : : mbIsShift:1,
235 : : mbIsKeyEvent:1,
236 : : mbChangingHighlight:1;
237 : : WindowAlign meAlign;
238 : : WindowAlign meDockAlign;
239 : : ButtonType meButtonType;
240 : : PointerStyle meLastStyle;
241 : : WinBits mnWinStyle;
242 : : ToolBoxLayoutMode meLayoutMode;
243 : : Link maClickHdl;
244 : : Link maDoubleClickHdl;
245 : : Link maActivateHdl;
246 : : Link maDeactivateHdl;
247 : : Link maHighlightHdl;
248 : : Link maSelectHdl;
249 : :
250 : : public:
251 : : using Window::ImplInit;
252 : : private:
253 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
254 : : using DockingWindow::ImplInitSettings;
255 : : SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
256 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
257 : : SAL_DLLPRIVATE ImplToolItem* ImplGetItem( sal_uInt16 nId ) const;
258 : : SAL_DLLPRIVATE sal_Bool ImplCalcItem();
259 : : SAL_DLLPRIVATE sal_uInt16 ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool bCalcHorz );
260 : : SAL_DLLPRIVATE void ImplFormat( sal_Bool bResize = sal_False );
261 : : SAL_DLLPRIVATE void ImplDrawSpin( sal_Bool bUpperIn, sal_Bool bLowerIn );
262 : : SAL_DLLPRIVATE void ImplDrawSeparator( sal_uInt16 nPos, Rectangle rRect );
263 : : SAL_DLLPRIVATE void ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight = 0, sal_Bool bPaint = sal_False, sal_Bool bLayout = sal_False );
264 : : using Window::ImplInvalidate;
265 : : SAL_DLLPRIVATE void ImplInvalidate( sal_Bool bNewCalc = sal_False, sal_Bool bFullPaint = sal_False );
266 : : SAL_DLLPRIVATE void ImplUpdateItem( sal_uInt16 nIndex = 0xFFFF );
267 : : SAL_DLLPRIVATE const rtl::OUString 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 sal_Bool ImplOpenItem( KeyCode aKeyCode );
275 : : SAL_DLLPRIVATE sal_Bool ImplActivateItem( KeyCode aKeyCode );
276 : : SAL_DLLPRIVATE void ImplShowFocus();
277 : : SAL_DLLPRIVATE void ImplHideFocus();
278 : : SAL_DLLPRIVATE void ImplUpdateInputEnable();
279 : : SAL_DLLPRIVATE void ImplFillLayoutData() const;
280 : : SAL_DLLPRIVATE sal_Bool ImplHasClippedItems();
281 : : SAL_DLLPRIVATE Point ImplGetPopupPosition( const Rectangle& rRect, const Size& rSize ) const;
282 : : SAL_DLLPRIVATE void ImplExecuteCustomMenu();
283 : : SAL_DLLPRIVATE sal_Bool ImplIsFloatingMode() const;
284 : : SAL_DLLPRIVATE sal_Bool ImplIsInPopupMode() const;
285 : : SAL_DLLPRIVATE const XubString& ImplGetHelpText( sal_uInt16 nItemId ) const;
286 : : SAL_DLLPRIVATE Size ImplGetOptimalFloatingSize();
287 : : SAL_DLLPRIVATE sal_Bool ImplHasExternalMenubutton();
288 : : SAL_DLLPRIVATE void ImplDrawFloatwinBorder( ImplToolItem* pItem );
289 : :
290 : : DECL_DLLPRIVATE_LINK( ImplCallExecuteCustomMenu, void* );
291 : : DECL_DLLPRIVATE_LINK( ImplUpdateHdl, void* );
292 : : DECL_DLLPRIVATE_LINK( ImplResetAutoSizeTriesHdl, void* );
293 : : DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent* );
294 : : DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl, void* );
295 : :
296 : : // Copy assignment is forbidden and not implemented.
297 : : SAL_DLLPRIVATE ToolBox (const ToolBox &);
298 : : SAL_DLLPRIVATE ToolBox& operator= (const ToolBox &);
299 : :
300 : : SAL_DLLPRIVATE void ImplUpdateImageList(); // called if StateChanged
301 : : public:
302 : : SAL_DLLPRIVATE void ImplFloatControl( sal_Bool bStart, FloatingWindow* pWindow = NULL );
303 : : SAL_DLLPRIVATE void ImplDisableFlatButtons();
304 : :
305 : : static SAL_DLLPRIVATE int ImplGetDragWidth( ToolBox* pThis );
306 : : static SAL_DLLPRIVATE void ImplUpdateDragArea( ToolBox *pThis );
307 : : static SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop,
308 : : long& rRight, long& rBottom, const ToolBox *pThis );
309 : : static SAL_DLLPRIVATE void ImplDrawGrip( ToolBox* pThis );
310 : : static SAL_DLLPRIVATE void ImplDrawGradientBackground( ToolBox* pThis, ImplDockingWindowWrapper *pWrapper );
311 : : static SAL_DLLPRIVATE sal_Bool ImplDrawNativeBackground( ToolBox* pThis, const Region &rRegion );
312 : : static SAL_DLLPRIVATE void ImplDrawTransparentBackground( ToolBox* pThis, const Region &rRegion );
313 : : static SAL_DLLPRIVATE void ImplDrawConstantBackground( ToolBox* pThis, const Region &rRegion, sal_Bool bIsInPopupMode );
314 : : static SAL_DLLPRIVATE void ImplDrawBackground( ToolBox* pThis, const Rectangle &rRect );
315 : : static SAL_DLLPRIVATE void ImplErase( ToolBox* pThis, const Rectangle &rRect, sal_Bool bHighlight = sal_False, sal_Bool bHasOpenPopup = sal_False );
316 : : static SAL_DLLPRIVATE void ImplDrawBorder( ToolBox* pWin );
317 : : static SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem( const ToolBox* pThis );
318 : : static SAL_DLLPRIVATE Size ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uInt16 nCalcMode = 0 );
319 : : static SAL_DLLPRIVATE void ImplCalcFloatSizes( ToolBox* pThis );
320 : : static SAL_DLLPRIVATE Size ImplCalcFloatSize( ToolBox* pThis, sal_uInt16& rLines );
321 : : static SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( ToolBox* pThis, Size& rMinSize, Size& rMaxSize );
322 : : static SAL_DLLPRIVATE void ImplSetMinMaxFloatSize( ToolBox *pThis );
323 : : static SAL_DLLPRIVATE sal_uInt16 ImplCalcLines( ToolBox* pThis, long nToolSize );
324 : : static SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( ToolBox* pThis, const Point& rPos );
325 : : static SAL_DLLPRIVATE void ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode );
326 : : static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( ToolBox* pBox, const Point& rPos );
327 : : static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList );
328 : : static SAL_DLLPRIVATE void ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight );
329 : : static SAL_DLLPRIVATE sal_uInt16 ImplCountLineBreaks( const ToolBox *pThis );
330 : 4160 : SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData; }
331 : :
332 : : protected:
333 : 0 : void SetCurItemId(sal_uInt16 nSet) { mnCurItemId = nSet; }
334 : :
335 : : public:
336 : : ToolBox( Window* pParent, WinBits nStyle = 0 );
337 : : ToolBox( Window* pParent, const ResId& rResId );
338 : : ~ToolBox();
339 : :
340 : : virtual void Click();
341 : : virtual void DoubleClick();
342 : : virtual void Activate();
343 : : virtual void Deactivate();
344 : : virtual void Highlight();
345 : : virtual void Select();
346 : : virtual void Customize( const ToolBoxCustomizeEvent& rCEvt );
347 : : virtual void UserDraw( const UserDrawEvent& rUDEvt );
348 : :
349 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
350 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
351 : : virtual void MouseMove( const MouseEvent& rMEvt );
352 : : virtual void Tracking( const TrackingEvent& rTEvt );
353 : : virtual void Paint( const Rectangle& rRect );
354 : : virtual void Move();
355 : : virtual void Resize();
356 : : virtual void RequestHelp( const HelpEvent& rHEvt );
357 : : virtual long Notify( NotifyEvent& rNEvt );
358 : : virtual void Command( const CommandEvent& rCEvt );
359 : : virtual void StateChanged( StateChangedType nType );
360 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
361 : :
362 : : virtual void GetFocus();
363 : : virtual void LoseFocus();
364 : : virtual void KeyInput( const KeyEvent& rKEvt );
365 : :
366 : : virtual sal_Bool PrepareToggleFloatingMode();
367 : : virtual void ToggleFloatingMode();
368 : : virtual void StartDocking();
369 : : virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect );
370 : : virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode );
371 : : virtual void Resizing( Size& rSize );
372 : :
373 : : void InsertItem( const ResId& rResId,
374 : : sal_uInt16 nPos = TOOLBOX_APPEND );
375 : : void InsertItem( sal_uInt16 nItemId, const Image& rImage,
376 : : ToolBoxItemBits nBits = 0,
377 : : sal_uInt16 nPos = TOOLBOX_APPEND );
378 : : void InsertItem( sal_uInt16 nItemId, const Image& rImage,
379 : : const XubString& rText,
380 : : ToolBoxItemBits nBits = 0,
381 : : sal_uInt16 nPos = TOOLBOX_APPEND );
382 : : void InsertItem( sal_uInt16 nItemId, const XubString& rText,
383 : : ToolBoxItemBits nBits = 0,
384 : : sal_uInt16 nPos = TOOLBOX_APPEND );
385 : : void InsertWindow( sal_uInt16 nItemId, Window* pWindow,
386 : : ToolBoxItemBits nBits = 0,
387 : : sal_uInt16 nPos = TOOLBOX_APPEND );
388 : : void InsertSpace( sal_uInt16 nPos = TOOLBOX_APPEND );
389 : : void InsertSeparator( sal_uInt16 nPos = TOOLBOX_APPEND,
390 : : sal_uInt16 nPixSize = 0 );
391 : : void InsertBreak( sal_uInt16 nPos = TOOLBOX_APPEND );
392 : : void RemoveItem( sal_uInt16 nPos );
393 : : void CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId,
394 : : sal_uInt16 nNewPos = TOOLBOX_APPEND );
395 : : void Clear();
396 : :
397 : 0 : const ImageList& GetImageList() const { return maImageList; }
398 : : void SetImageList( const ImageList& rImageList );
399 : :
400 : : void SetButtonType( ButtonType eNewType = BUTTON_SYMBOL );
401 : 0 : ButtonType GetButtonType() const { return meButtonType; }
402 : :
403 : : // sets a fixed button size (small, large or dontcare (==autosize))
404 : : void SetToolboxButtonSize( ToolBoxButtonSize eSize );
405 : : ToolBoxButtonSize GetToolboxButtonSize() const;
406 : :
407 : : void SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP );
408 : 2118 : WindowAlign GetAlign() const { return meAlign; }
409 : 62620 : sal_Bool IsHorizontal() const { return mbHorz; }
410 : :
411 : : void SetLineCount( sal_uInt16 nNewLines );
412 : : sal_uInt16 GetLineCount() const { return mnLines; }
413 : : sal_uInt16 GetCurLine() const { return mnCurLine; }
414 : : void ShowLine( sal_Bool bNext );
415 : :
416 : : // Used to enable/disable scrolling one page at a time for toolbar
417 : : void SetPageScroll( sal_Bool b );
418 : :
419 : : sal_uInt16 GetItemCount() const;
420 : : ToolBoxItemType GetItemType( sal_uInt16 nPos ) const;
421 : : sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
422 : : sal_uInt16 GetItemPos( const Point& rPos ) const;
423 : : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
424 : : sal_uInt16 GetItemId( const Point& rPos ) const;
425 : : Rectangle GetItemRect( sal_uInt16 nItemId ) const;
426 : : Rectangle GetItemPosRect( sal_uInt16 nPos ) const;
427 : :
428 : : // retrieves the optimal position to place a popup window for this item (subtoolbar or dropdown)
429 : : Point GetItemPopupPosition( sal_uInt16 nItemId, const Size& rSize ) const;
430 : :
431 : : Rectangle GetScrollRect() const;
432 : 6 : sal_uInt16 GetCurItemId() const { return mnCurItemId; }
433 : 0 : sal_uInt16 GetDownItemId() const { return mnDownItemId; }
434 : : sal_uInt16 GetClicks() const { return mnMouseClicks; }
435 : 2 : sal_uInt16 GetModifier() const { return mnMouseModifier; }
436 : 0 : sal_uInt16 GetKeyModifier() const { return mnKeyModifier; }
437 : :
438 : : void SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits );
439 : : ToolBoxItemBits GetItemBits( sal_uInt16 nItemId ) const;
440 : :
441 : : void SetItemData( sal_uInt16 nItemId, void* pNewData );
442 : : void* GetItemData( sal_uInt16 nItemId ) const;
443 : : void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
444 : : Image GetItemImage( sal_uInt16 nItemId ) const;
445 : : void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
446 : : void SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror );
447 : : void SetItemText( sal_uInt16 nItemId, const XubString& rText );
448 : : const XubString& GetItemText( sal_uInt16 nItemId ) const;
449 : : void SetItemWindow( sal_uInt16 nItemId, Window* pNewWindow );
450 : : Window* GetItemWindow( sal_uInt16 nItemId ) const;
451 : 984 : sal_uInt16 GetHighlightItemId() const { return mnHighItemId; }
452 : :
453 : : void StartSelection();
454 : : void EndSelection();
455 : :
456 : : void SetItemDown( sal_uInt16 nItemId, sal_Bool bDown, sal_Bool bRelease = sal_True );
457 : :
458 : : void SetItemState( sal_uInt16 nItemId, TriState eState );
459 : : TriState GetItemState( sal_uInt16 nItemId ) const;
460 : :
461 : : void CheckItem( sal_uInt16 nItemId, sal_Bool bCheck = sal_True );
462 : : sal_Bool IsItemChecked( sal_uInt16 nItemId ) const;
463 : :
464 : : void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True );
465 : : sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const;
466 : :
467 : : void TriggerItem( sal_uInt16 nItemId, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False );
468 : : void ShowItem( sal_uInt16 nItemId, sal_Bool bVisible = sal_True );
469 : 21177 : void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, sal_False ); }
470 : : sal_Bool IsItemVisible( sal_uInt16 nItemId ) const;
471 : : sal_Bool IsItemReallyVisible( sal_uInt16 nItemId ) const;
472 : :
473 : : void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
474 : : const XubString& GetItemCommand( sal_uInt16 nItemId ) const;
475 : :
476 : : using Window::SetQuickHelpText;
477 : : void SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText );
478 : : using Window::GetQuickHelpText;
479 : : const XubString& GetQuickHelpText( sal_uInt16 nItemId ) const;
480 : :
481 : : void SetHelpText( sal_uInt16 nItemId, const XubString& rText );
482 : : const XubString& GetHelpText( sal_uInt16 nItemId ) const;
483 : :
484 : : void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
485 : : rtl::OString GetHelpId( sal_uInt16 nItemId ) const;
486 : :
487 : : // window size according to current alignment, floating state and number of lines
488 : : Size CalcWindowSizePixel() const;
489 : : // window size according to current alignment, floating state and a given number of lines
490 : : Size CalcWindowSizePixel( sal_uInt16 nCalcLines ) const;
491 : : // window size according to current floating state and a given number of lines and a given alignment
492 : : Size CalcWindowSizePixel( sal_uInt16 nCalcLines, WindowAlign eAlign ) const;
493 : : // floating window size according to number of lines (uses the number of line breaks)
494 : : Size CalcFloatingWindowSizePixel() const;
495 : : // floating window size with a given number of lines
496 : : Size CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const;
497 : : // automatic window size for popoup mode
498 : : Size CalcPopupWindowSizePixel() const;
499 : :
500 : : // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
501 : : Size CalcMinimumWindowSizePixel() const;
502 : :
503 : : void SetDockingRects( const Rectangle& rOutRect,
504 : : const Rectangle& rInRect );
505 : : void SetFloatingLines( sal_uInt16 nFloatLines );
506 : : sal_uInt16 GetFloatingLines() const;
507 : :
508 : 2 : void SetStyle( WinBits nNewStyle ) { mnWinStyle = nNewStyle; }
509 : 2120 : WinBits GetStyle() const { return mnWinStyle; }
510 : :
511 : : // enable/disable undocking
512 : : void Lock( sal_Bool bLock = sal_True );
513 : :
514 : : // read configuration to determine locking behaviour
515 : : static sal_Bool AlwaysLocked();
516 : :
517 : 0 : void EnableMenuStrings( sal_Bool bEnable = sal_True ) { mbMenuStrings = (bEnable != 0); }
518 : : sal_Bool IsMenuStringsEnabled() const { return mbMenuStrings; }
519 : :
520 : : void SetOutStyle( sal_uInt16 nNewStyle );
521 : 0 : sal_uInt16 GetOutStyle() const { return mnOutStyle; }
522 : :
523 : : void EnableCustomize( sal_Bool bEnable = sal_True );
524 : 0 : sal_Bool IsCustomize() { return mbCustomize; }
525 : : sal_Bool IsInCustomizeMode() const { return mbCustomizeMode; }
526 : :
527 : : void SetHelpText( const XubString& rText )
528 : : { DockingWindow::SetHelpText( rText ); }
529 : : const XubString& GetHelpText() const
530 : : { return DockingWindow::GetHelpText(); }
531 : :
532 : 4060 : void SetHelpId( const rtl::OString& rId )
533 : 4060 : { DockingWindow::SetHelpId( rId ); }
534 : 107920 : const rtl::OString& GetHelpId() const
535 : 107920 : { return DockingWindow::GetHelpId(); }
536 : :
537 : 7296 : void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
538 : : const Link& GetClickHdl() const { return maClickHdl; }
539 : 7236 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
540 : : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
541 : : void SetDropdownClickHdl( const Link& rLink );
542 : : const Link& GetDropdownClickHdl() const;
543 : 7236 : void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; }
544 : : const Link& GetActivateHdl() const { return maActivateHdl; }
545 : 7236 : void SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
546 : : const Link& GetDeactivateHdl() const { return maDeactivateHdl; }
547 : : void SetHighlightHdl( const Link& rLink ) { maHighlightHdl = rLink; }
548 : : const Link& GetHighlightHdl() const { return maHighlightHdl; }
549 : 9649 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
550 : 0 : const Link& GetSelectHdl() const { return maSelectHdl; }
551 : :
552 : : // support for custom menu (eg for configuration)
553 : : // note: this menu will also be used to display currently
554 : : // clipped toolbox items, so you should only touch
555 : : // items that you added by yourself
556 : : // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
557 : : // to allow for customization of the menu the coresponding handler is called
558 : : // when the menu button was clicked and before the menu is executed
559 : : void SetMenuType( sal_uInt16 aType = TOOLBOX_MENUTYPE_CUSTOMIZE );
560 : : sal_uInt16 GetMenuType() const;
561 : : sal_Bool IsMenuEnabled() const;
562 : : PopupMenu* GetMenu() const;
563 : : void UpdateCustomMenu();
564 : : void SetMenuButtonHdl( const Link& rLink );
565 : :
566 : : // open custommenu
567 : : void ExecuteCustomMenu();
568 : :
569 : : // allow Click Handler to detect special key
570 : : bool IsShift() const { return mbIsShift; }
571 : : // allow Click Handler to distinguish between mouse and key input
572 : 0 : sal_Bool IsKeyEvent() const { return mbIsKeyEvent; }
573 : :
574 : : // allows framework to set/query the planned popupmode
575 : : sal_Bool WillUsePopupMode() const;
576 : : void WillUsePopupMode( sal_Bool b);
577 : :
578 : : // accessibility helpers
579 : :
580 : : // gets the displayed text
581 : : String GetDisplayText() const;
582 : : // returns the bounding box for the character at index nIndex
583 : : // where nIndex is relative to the starting index of the item
584 : : // with id nItemId (in coordinates of the displaying window)
585 : : Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const;
586 : : // -1 is returned if no character is at that point
587 : : // if an index is found the corresponding item id is filled in (else 0)
588 : : long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const;
589 : :
590 : : const Size& GetDefaultImageSize() const;
591 : : void ChangeHighlight( sal_uInt16 nPos );
592 : :
593 : : void SetImageListProvider(vcl::IImageListProvider* _pProvider);
594 : : void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
595 : : };
596 : :
597 : 44250 : inline void ToolBox::CheckItem( sal_uInt16 nItemId, sal_Bool bCheck )
598 : : {
599 [ + + ]: 44250 : SetItemState( nItemId, (bCheck) ? STATE_CHECK : STATE_NOCHECK );
600 : 44250 : }
601 : :
602 : 2737 : inline sal_Bool ToolBox::IsItemChecked( sal_uInt16 nItemId ) const
603 : : {
604 : 2737 : return (GetItemState( nItemId ) == STATE_CHECK);
605 : : }
606 : :
607 : 13900 : inline Size ToolBox::CalcWindowSizePixel() const
608 : : {
609 : 13900 : return CalcWindowSizePixel( mnLines );
610 : : }
611 : :
612 : : inline Rectangle ToolBox::GetScrollRect() const
613 : : {
614 : : return maUpperRect.GetUnion( maLowerRect );
615 : : }
616 : :
617 : : inline void ToolBox::SetDockingRects( const Rectangle& rOutRect,
618 : : const Rectangle& rInRect )
619 : : {
620 : : maOutDockRect = rOutRect;
621 : : maInDockRect = rInRect;
622 : : }
623 : :
624 : 0 : inline void ToolBox::SetFloatingLines( sal_uInt16 nNewLines )
625 : : {
626 : 0 : mnFloatLines = nNewLines;
627 : 0 : }
628 : :
629 : 0 : inline sal_uInt16 ToolBox::GetFloatingLines() const
630 : : {
631 : 0 : return mnFloatLines;
632 : : }
633 : :
634 : : #endif // _SV_TOOLBOX_HXX
635 : :
636 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|