1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_TOOLBOX_HXX
21 #define INCLUDED_VCL_TOOLBOX_HXX
23 #include <com/sun/star/frame/XFrame.hpp>
24 #include <rsc/rsc-vcl-shared-types.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/dockwin.hxx>
27 #include <vcl/image.hxx>
28 #include <vcl/timer.hxx>
29 #include <vcl/idle.hxx>
36 struct ImplToolBoxPrivateData
;
40 #define TOOLBOX_CUSTOMIZE_RESIZE ((sal_uInt16)0xFFFE)
42 class VCL_DLLPUBLIC ToolBoxCustomizeEvent
45 VclPtr
<ToolBox
> mpTargetBox
;
51 ToolBoxCustomizeEvent();
52 ToolBoxCustomizeEvent( ToolBox
* pDropBox
,
53 sal_uInt16 nId
, sal_uInt16 nPos
= 0,
54 void* pUserData
= NULL
);
56 ToolBox
* GetTargetBox() const { return mpTargetBox
; }
57 sal_uInt16
GetTargetPos() const { return mnPosTo
; }
58 sal_uInt16
GetSourceId() const { return mnIdFrom
; }
59 void* GetData() const { return mpData
; }
60 bool IsResized() const;
63 inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent()
71 inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent( ToolBox
* pDropBox
,
72 sal_uInt16 nId
, sal_uInt16 nPos
,
75 mpTargetBox
= pDropBox
;
81 inline bool ToolBoxCustomizeEvent::IsResized() const
83 if ( mnPosTo
== TOOLBOX_CUSTOMIZE_RESIZE
)
89 #define TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004)
91 #define TOOLBOX_APPEND ((sal_uInt16)0xFFFF)
92 #define TOOLBOX_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
94 // item ids in the custom menu may not exceed this constant
95 #define TOOLBOX_MENUITEM_START ((sal_uInt16)0xE000)
97 // defines for the menubutton
98 #define TOOLBOX_MENUTYPE_NONE ((sal_uInt16)0x0000) // no menu at all, scrolling by spin buttons
99 #define TOOLBOX_MENUTYPE_CLIPPEDITEMS ((sal_uInt16)0x0001) // menu will contain "more" indicator
100 #define TOOLBOX_MENUTYPE_CUSTOMIZE ((sal_uInt16)0x0002) // menu will contain "customization" and "more" indicator
102 // small or large force an exact toolbox size for proper alignemnt
103 // dontcare will let the toolbox decide about its size
104 enum ToolBoxButtonSize
{ TOOLBOX_BUTTONSIZE_DONTCARE
, TOOLBOX_BUTTONSIZE_SMALL
, TOOLBOX_BUTTONSIZE_LARGE
};
106 // TBX_LAYOUT_NORMAL - traditional layout, items are centered in the toolbar
107 // TBX_LAYOUT_LOCKVERT - special mode (currently used for calc input/formula
108 // bar) where item's vertical position is locked, e.g.
109 // toolbox is prevented from centering the items
110 enum ToolBoxLayoutMode
{ TBX_LAYOUT_NORMAL
, TBX_LAYOUT_LOCKVERT
};
119 class VCL_DLLPUBLIC ToolBox
: public DockingWindow
121 friend class FloatingWindow
;
122 friend class ImplTBDragMgr
;
125 ImplToolBoxPrivateData
* mpData
;
126 std::vector
<ImplToolSize
> maFloatSizes
;
127 ImageList maImageList
;
129 Rectangle maUpperRect
;
130 Rectangle maLowerRect
;
131 Rectangle maOutDockRect
;
132 Rectangle maInDockRect
;
133 Rectangle maPaintRect
;
134 VclPtr
<FloatingWindow
> mpFloatWin
;
135 sal_uInt16 mnKeyModifier
;
138 long mnMaxItemWidth
; // max item width
139 long mnMaxItemHeight
; // max item height (for standard items)
140 long mnWinHeight
; // max window height (for window items)
141 long mnLeftBorder
; // inner border
146 long mnActivateCount
;
147 sal_uInt16 mnLastFocusItemId
;
148 sal_uInt16 mnFocusPos
;
149 sal_uInt16 mnOutStyle
;
150 sal_uInt16 mnHighItemId
;
151 sal_uInt16 mnCurItemId
;
152 sal_uInt16 mnDownItemId
;
154 sal_uInt16 mnLines
; // total number of toolbox lines
155 sal_uInt16 mnCurLine
; // the currently visible line
156 sal_uInt16 mnCurLines
; // number of lines due to line breaking
157 sal_uInt16 mnVisLines
; // number of visible lines (for scrolling)
158 sal_uInt16 mnFloatLines
; // number of lines during floating mode
159 sal_uInt16 mnDockLines
;
160 sal_uInt16 mnConfigItem
;
161 sal_uInt16 mnMouseClicks
;
162 sal_uInt16 mnMouseModifier
;
181 mbChangingHighlight
:1;
183 WindowAlign meDockAlign
;
184 ButtonType meButtonType
;
185 PointerStyle meLastStyle
;
187 ToolBoxLayoutMode meLayoutMode
;
188 Link
<ToolBox
*, void> maClickHdl
;
189 Link
<ToolBox
*, void> maDoubleClickHdl
;
190 Link
<ToolBox
*, void> maActivateHdl
;
191 Link
<ToolBox
*, void> maDeactivateHdl
;
192 Link
<ToolBox
*, void> maSelectHdl
;
193 Link
<CommandEvent
const *, void> maCommandHandler
;
194 Link
<StateChangedType
const *, void> maStateChangedHandler
;
195 Link
<DataChangedEvent
const *, void> maDataChangedHandler
;
198 using Window::ImplInit
;
200 SAL_DLLPRIVATE
void InvalidateItem(sal_uInt16 nPosition
);
201 SAL_DLLPRIVATE
void InvalidateSpin(bool bUpperIn
, bool bLowerIn
);
202 SAL_DLLPRIVATE
void InvalidateMenuButton();
204 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
205 using DockingWindow::ImplInitSettings
;
206 SAL_DLLPRIVATE
void ImplInitSettings( bool bFont
, bool bForeground
, bool bBackground
);
207 SAL_DLLPRIVATE
void ImplLoadRes( const ResId
& rResId
);
208 SAL_DLLPRIVATE ImplToolItem
* ImplGetItem( sal_uInt16 nId
) const;
209 SAL_DLLPRIVATE
bool ImplCalcItem();
210 SAL_DLLPRIVATE sal_uInt16
ImplCalcBreaks( long nWidth
, long* pMaxLineWidth
, bool bCalcHorz
);
211 SAL_DLLPRIVATE
void ImplFormat( bool bResize
= false );
212 SAL_DLLPRIVATE
void ImplDrawSpin(vcl::RenderContext
& rRenderContext
, bool bUpperIn
, bool bLowerIn
);
213 SAL_DLLPRIVATE
void ImplDrawSeparator(vcl::RenderContext
& rRenderContext
, sal_uInt16 nPos
, const Rectangle
& rRect
);
214 SAL_DLLPRIVATE
void ImplDrawItem(vcl::RenderContext
& rRenderContext
, sal_uInt16 nPos
, sal_uInt16 nHighlight
= 0, bool bPaint
= false, bool bLayout
= false );
215 using Window::ImplInvalidate
;
216 SAL_DLLPRIVATE
void ImplInvalidate( bool bNewCalc
= false, bool bFullPaint
= false );
217 SAL_DLLPRIVATE
void ImplUpdateItem( sal_uInt16 nIndex
= 0xFFFF );
218 SAL_DLLPRIVATE
const OUString
ImplConvertMenuString( const OUString
& rStr
);
219 SAL_DLLPRIVATE
bool ImplHandleMouseMove( const MouseEvent
& rMEvt
, bool bRepeat
= false );
220 SAL_DLLPRIVATE
bool ImplHandleMouseButtonUp( const MouseEvent
& rMEvt
, bool bCancel
= false );
221 SAL_DLLPRIVATE
void ImplChangeHighlight( ImplToolItem
* pItem
, bool bNoGrabFocus
= false );
222 SAL_DLLPRIVATE
bool ImplChangeHighlightUpDn( bool bUp
, bool bNoCycle
= false );
223 SAL_DLLPRIVATE sal_uInt16
ImplGetItemLine( ImplToolItem
* pCurrentItem
);
224 SAL_DLLPRIVATE ImplToolItem
* ImplGetFirstValidItem( sal_uInt16 nLine
);
225 SAL_DLLPRIVATE
bool ImplOpenItem( vcl::KeyCode aKeyCode
);
226 SAL_DLLPRIVATE
bool ImplActivateItem( vcl::KeyCode aKeyCode
);
227 SAL_DLLPRIVATE
void ImplShowFocus();
228 SAL_DLLPRIVATE
void ImplHideFocus();
229 SAL_DLLPRIVATE
void ImplUpdateInputEnable();
230 SAL_DLLPRIVATE
void ImplFillLayoutData() const;
231 SAL_DLLPRIVATE
bool ImplHasClippedItems();
232 SAL_DLLPRIVATE Point
ImplGetPopupPosition( const Rectangle
& rRect
, const Size
& rSize
) const;
233 SAL_DLLPRIVATE
void ImplExecuteCustomMenu();
234 SAL_DLLPRIVATE
bool ImplIsFloatingMode() const;
235 SAL_DLLPRIVATE
bool ImplIsInPopupMode() const;
236 SAL_DLLPRIVATE
const OUString
& ImplGetHelpText( sal_uInt16 nItemId
) const;
237 SAL_DLLPRIVATE Size
ImplGetOptimalFloatingSize();
238 SAL_DLLPRIVATE
bool ImplHasExternalMenubutton();
239 SAL_DLLPRIVATE
void ImplDrawFloatwinBorder(vcl::RenderContext
& rRenderContext
, ImplToolItem
* pItem
);
241 DECL_DLLPRIVATE_LINK( ImplCallExecuteCustomMenu
, void* );
242 DECL_DLLPRIVATE_LINK_TYPED( ImplUpdateHdl
, Idle
*, void );
243 DECL_DLLPRIVATE_LINK( ImplResetAutoSizeTriesHdl
, void* );
244 DECL_DLLPRIVATE_LINK( ImplCustomMenuListener
, VclMenuEvent
* );
245 DECL_DLLPRIVATE_LINK_TYPED( ImplDropdownLongClickHdl
, Timer
*, void );
247 ToolBox (const ToolBox
&) SAL_DELETED_FUNCTION
;
248 ToolBox
& operator= (const ToolBox
&) SAL_DELETED_FUNCTION
;
251 SAL_DLLPRIVATE
void ImplFloatControl( bool bStart
, FloatingWindow
* pWindow
= NULL
);
252 SAL_DLLPRIVATE
void ImplDisableFlatButtons();
254 static SAL_DLLPRIVATE
int ImplGetDragWidth( ToolBox
* pThis
);
255 static SAL_DLLPRIVATE
void ImplUpdateDragArea( ToolBox
*pThis
);
256 static SAL_DLLPRIVATE
void ImplCalcBorder( WindowAlign eAlign
, long& rLeft
, long& rTop
,
257 long& rRight
, long& rBottom
, const ToolBox
*pThis
);
259 SAL_DLLPRIVATE
void ImplDrawGrip(vcl::RenderContext
& rRenderContext
);
260 SAL_DLLPRIVATE
void ImplDrawGradientBackground(vcl::RenderContext
& rRenderContext
, ImplDockingWindowWrapper
*pWrapper
);
261 SAL_DLLPRIVATE
bool ImplDrawNativeBackground(vcl::RenderContext
& rRenderContext
, const vcl::Region
&rRegion
);
262 SAL_DLLPRIVATE
void ImplDrawTransparentBackground(vcl::RenderContext
& rRenderContext
, const vcl::Region
&rRegion
);
263 SAL_DLLPRIVATE
void ImplDrawConstantBackground(vcl::RenderContext
& rRenderContext
, const vcl::Region
&rRegion
, bool bIsInPopupMode
);
264 SAL_DLLPRIVATE
void ImplDrawBackground(vcl::RenderContext
& rRenderContext
, const Rectangle
&rRect
);
266 SAL_DLLPRIVATE
void ImplErase(vcl::RenderContext
& rRenderContext
, const Rectangle
&rRect
, bool bHighlight
= false, bool bHasOpenPopup
= false );
268 SAL_DLLPRIVATE
void ImplDrawBorder(vcl::RenderContext
& rRenderContext
);
269 static SAL_DLLPRIVATE
const ImplToolItem
*ImplGetFirstClippedItem( const ToolBox
* pThis
);
270 static SAL_DLLPRIVATE Size
ImplCalcSize( const ToolBox
* pThis
, sal_uInt16 nCalcLines
, sal_uInt16 nCalcMode
= 0 );
271 static SAL_DLLPRIVATE
void ImplCalcFloatSizes( ToolBox
* pThis
);
272 static SAL_DLLPRIVATE Size
ImplCalcFloatSize( ToolBox
* pThis
, sal_uInt16
& rLines
);
273 static SAL_DLLPRIVATE
void ImplCalcMinMaxFloatSize( ToolBox
* pThis
, Size
& rMinSize
, Size
& rMaxSize
);
274 static SAL_DLLPRIVATE
void ImplSetMinMaxFloatSize( ToolBox
*pThis
);
275 static SAL_DLLPRIVATE sal_uInt16
ImplCalcLines( ToolBox
* pThis
, long nToolSize
);
276 static SAL_DLLPRIVATE sal_uInt16
ImplTestLineSize( ToolBox
* pThis
, const Point
& rPos
);
277 static SAL_DLLPRIVATE
void ImplLineSizing( ToolBox
* pThis
, const Point
& rPos
, Rectangle
& rRect
, sal_uInt16 nLineMode
);
278 static SAL_DLLPRIVATE sal_uInt16
ImplFindItemPos( ToolBox
* pBox
, const Point
& rPos
);
279 static SAL_DLLPRIVATE sal_uInt16
ImplFindItemPos( const ImplToolItem
* pItem
, const std::vector
< ImplToolItem
>& rList
);
280 SAL_DLLPRIVATE
void ImplDrawMenuButton(vcl::RenderContext
& rRenderContext
, bool bHighlight
);
281 SAL_DLLPRIVATE
void ImplDrawButton(vcl::RenderContext
& rRenderContext
, const Rectangle
&rRect
, sal_uInt16 highlight
, bool bChecked
, bool bEnabled
, bool bIsWindow
);
282 static SAL_DLLPRIVATE sal_uInt16
ImplCountLineBreaks( const ToolBox
*pThis
);
283 SAL_DLLPRIVATE ImplToolBoxPrivateData
* ImplGetToolBoxPrivateData() const { return mpData
; }
286 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) SAL_OVERRIDE
;
287 void SetCurItemId(sal_uInt16 nSet
)
293 ToolBox( vcl::Window
* pParent
, WinBits nStyle
= 0 );
294 ToolBox( vcl::Window
* pParent
, const ResId
& rResId
);
296 virtual void dispose() SAL_OVERRIDE
;
298 virtual void Click();
300 virtual void Activate() SAL_OVERRIDE
;
301 virtual void Deactivate() SAL_OVERRIDE
;
303 virtual void Select();
305 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
306 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
307 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
308 virtual void Tracking( const TrackingEvent
& rTEvt
) SAL_OVERRIDE
;
309 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
310 virtual void Move() SAL_OVERRIDE
;
311 virtual void Resize() SAL_OVERRIDE
;
312 virtual void RequestHelp( const HelpEvent
& rHEvt
) SAL_OVERRIDE
;
313 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
314 virtual void Command( const CommandEvent
& rCEvt
) SAL_OVERRIDE
;
315 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
316 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
318 virtual void GetFocus() SAL_OVERRIDE
;
319 virtual void LoseFocus() SAL_OVERRIDE
;
320 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
322 virtual bool PrepareToggleFloatingMode() SAL_OVERRIDE
;
323 virtual void ToggleFloatingMode() SAL_OVERRIDE
;
324 virtual void StartDocking() SAL_OVERRIDE
;
325 virtual bool Docking( const Point
& rPos
, Rectangle
& rRect
) SAL_OVERRIDE
;
326 virtual void EndDocking( const Rectangle
& rRect
, bool bFloatMode
) SAL_OVERRIDE
;
327 virtual void Resizing( Size
& rSize
) SAL_OVERRIDE
;
328 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
330 void InsertItem( const ResId
& rResId
,
331 sal_uInt16 nPos
= TOOLBOX_APPEND
);
332 /// Insert a command (like '.uno:Save').
333 virtual void InsertItem( const OUString
& rCommand
,
334 const css::uno::Reference
<css::frame::XFrame
>& rFrame
,
335 ToolBoxItemBits nBits
= ToolBoxItemBits::NONE
,
336 const Size
& rRequestedSize
= Size(),
337 sal_uInt16 nPos
= TOOLBOX_APPEND
);
338 void InsertItem( sal_uInt16 nItemId
, const Image
& rImage
,
339 ToolBoxItemBits nBits
= ToolBoxItemBits::NONE
,
340 sal_uInt16 nPos
= TOOLBOX_APPEND
);
341 void InsertItem( sal_uInt16 nItemId
, const Image
& rImage
,
342 const OUString
& rText
,
343 ToolBoxItemBits nBits
= ToolBoxItemBits::NONE
,
344 sal_uInt16 nPos
= TOOLBOX_APPEND
);
345 void InsertItem( sal_uInt16 nItemId
, const OUString
& rText
,
346 ToolBoxItemBits nBits
= ToolBoxItemBits::NONE
,
347 sal_uInt16 nPos
= TOOLBOX_APPEND
);
348 void InsertWindow( sal_uInt16 nItemId
, vcl::Window
* pWindow
,
349 ToolBoxItemBits nBits
= ToolBoxItemBits::NONE
,
350 sal_uInt16 nPos
= TOOLBOX_APPEND
);
351 void InsertSpace( sal_uInt16 nPos
= TOOLBOX_APPEND
);
352 void InsertSeparator( sal_uInt16 nPos
= TOOLBOX_APPEND
,
353 sal_uInt16 nPixSize
= 0 );
354 void InsertBreak( sal_uInt16 nPos
= TOOLBOX_APPEND
);
355 void RemoveItem( sal_uInt16 nPos
);
356 void CopyItem( const ToolBox
& rToolBox
, sal_uInt16 nItemId
,
357 sal_uInt16 nNewPos
= TOOLBOX_APPEND
);
360 const ImageList
& GetImageList() const { return maImageList
; }
361 void SetImageList( const ImageList
& rImageList
);
363 void SetButtonType( ButtonType eNewType
= ButtonType::SYMBOLONLY
);
364 ButtonType
GetButtonType() const { return meButtonType
; }
366 // sets a fixed button size (small, large or dontcare (==autosize))
367 void SetToolboxButtonSize( ToolBoxButtonSize eSize
);
368 ToolBoxButtonSize
GetToolboxButtonSize() const;
370 void SetAlign( WindowAlign eNewAlign
= WINDOWALIGN_TOP
);
371 WindowAlign
GetAlign() const { return meAlign
; }
372 bool IsHorizontal() const { return mbHorz
; }
374 void SetLineCount( sal_uInt16 nNewLines
);
375 sal_uInt16
GetLineCount() const { return mnLines
; }
376 sal_uInt16
GetCurLine() const { return mnCurLine
; }
377 void ShowLine( bool bNext
);
379 // Used to enable/disable scrolling one page at a time for toolbar
380 void SetPageScroll( bool b
);
382 sal_uInt16
GetItemCount() const;
383 ToolBoxItemType
GetItemType( sal_uInt16 nPos
) const;
384 sal_uInt16
GetItemPos( sal_uInt16 nItemId
) const;
385 sal_uInt16
GetItemPos( const Point
& rPos
) const;
386 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
387 sal_uInt16
GetItemId( const Point
& rPos
) const;
388 /// Map the command name (like .uno:Save) back to item id.
389 sal_uInt16
GetItemId( const OUString
& rCommand
) const;
390 Rectangle
GetItemRect( sal_uInt16 nItemId
) const;
391 Rectangle
GetItemPosRect( sal_uInt16 nPos
) const;
393 /// Returns size of the bitmap / text that is inside this toolbox item.
394 Size
GetItemContentSize( sal_uInt16 nItemId
) const;
396 /// Retrieves the optimal position to place a popup window for this item (subtoolbar or dropdown)
397 Point
GetItemPopupPosition( sal_uInt16 nItemId
, const Size
& rSize
) const;
399 Rectangle
GetScrollRect() const;
400 sal_uInt16
GetCurItemId() const { return mnCurItemId
; }
401 sal_uInt16
GetDownItemId() const { return mnDownItemId
; }
402 sal_uInt16
GetClicks() const { return mnMouseClicks
; }
403 sal_uInt16
GetModifier() const { return mnMouseModifier
; }
404 sal_uInt16
GetKeyModifier() const { return mnKeyModifier
; }
406 void SetItemBits( sal_uInt16 nItemId
, ToolBoxItemBits nBits
);
407 ToolBoxItemBits
GetItemBits( sal_uInt16 nItemId
) const;
409 void SetItemExpand( sal_uInt16 nItemId
, bool bExpand
);
411 void SetItemData( sal_uInt16 nItemId
, void* pNewData
);
412 void* GetItemData( sal_uInt16 nItemId
) const;
413 void SetItemImage( sal_uInt16 nItemId
, const Image
& rImage
);
414 Image
GetItemImage( sal_uInt16 nItemId
) const;
415 Image
GetItemImageOriginal( sal_uInt16 nItemId
) const;
416 void SetItemImageAngle( sal_uInt16 nItemId
, long nAngle10
);
417 void SetItemImageMirrorMode( sal_uInt16 nItemId
, bool bMirror
);
418 void SetItemText( sal_uInt16 nItemId
, const OUString
& rText
);
419 const OUString
& GetItemText( sal_uInt16 nItemId
) const;
420 void SetItemWindow( sal_uInt16 nItemId
, vcl::Window
* pNewWindow
);
421 vcl::Window
* GetItemWindow( sal_uInt16 nItemId
) const;
422 sal_uInt16
GetHighlightItemId() const { return mnHighItemId
; }
424 void StartSelection();
427 void SetItemDown( sal_uInt16 nItemId
, bool bDown
, bool bRelease
= true );
429 void SetItemState( sal_uInt16 nItemId
, TriState eState
);
430 TriState
GetItemState( sal_uInt16 nItemId
) const;
432 void CheckItem( sal_uInt16 nItemId
, bool bCheck
= true );
433 bool IsItemChecked( sal_uInt16 nItemId
) const;
435 void EnableItem( sal_uInt16 nItemId
, bool bEnable
= true );
436 bool IsItemEnabled( sal_uInt16 nItemId
) const;
438 void TriggerItem( sal_uInt16 nItemId
, bool bShift
= false, bool bCtrl
= false );
440 /// Shows or hides items.
441 void ShowItem(sal_uInt16 nItemId
, bool bVisible
= true);
442 /// Overload to provide ShowItem via command id.
443 void ShowItem(const OUString
& rCommand
, bool bVisible
= true) { ShowItem(GetItemId(rCommand
), bVisible
); }
445 /// Convenience method to hide items (via ShowItem).
446 void HideItem(sal_uInt16 nItemId
) { ShowItem( nItemId
, false ); }
447 /// Overload to provide HideItem via command id.
448 void HideItem(const OUString
& rCommand
) { ShowItem(rCommand
, false); }
450 bool IsItemVisible( sal_uInt16 nItemId
) const;
451 bool IsItemReallyVisible( sal_uInt16 nItemId
) const;
453 void SetItemCommand( sal_uInt16 nItemId
, const OUString
& rCommand
);
454 const OUString
GetItemCommand( sal_uInt16 nItemId
) const;
456 using Window::SetQuickHelpText
;
457 void SetQuickHelpText( sal_uInt16 nItemId
, const OUString
& rText
);
458 using Window::GetQuickHelpText
;
459 const OUString
& GetQuickHelpText( sal_uInt16 nItemId
) const;
461 void SetHelpText( sal_uInt16 nItemId
, const OUString
& rText
);
462 const OUString
& GetHelpText( sal_uInt16 nItemId
) const;
464 void SetHelpId( sal_uInt16 nItemId
, const OString
& rHelpId
);
465 OString
GetHelpId( sal_uInt16 nItemId
) const;
467 // window size according to current alignment, floating state and number of lines
468 Size
CalcWindowSizePixel() const;
469 // window size according to current alignment, floating state and a given number of lines
470 Size
CalcWindowSizePixel( sal_uInt16 nCalcLines
) const;
471 // window size according to current floating state and a given number of lines and a given alignment
472 Size
CalcWindowSizePixel( sal_uInt16 nCalcLines
, WindowAlign eAlign
) const;
473 // floating window size according to number of lines (uses the number of line breaks)
474 Size
CalcFloatingWindowSizePixel() const;
475 // floating window size with a given number of lines
476 Size
CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines
) const;
477 // automatic window size for popoup mode
478 Size
CalcPopupWindowSizePixel() const;
480 // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
481 Size
CalcMinimumWindowSizePixel() const;
483 void SetDockingRects( const Rectangle
& rOutRect
,
484 const Rectangle
& rInRect
);
485 void SetFloatingLines( sal_uInt16 nFloatLines
);
486 sal_uInt16
GetFloatingLines() const;
488 void SetStyle( WinBits nNewStyle
);
489 WinBits
GetStyle() const { return mnWinStyle
; }
491 // enable/disable undocking
492 void Lock( bool bLock
= true );
494 // read configuration to determine locking behaviour
495 static bool AlwaysLocked();
497 void EnableMenuStrings( bool bEnable
= true ) { mbMenuStrings
= bEnable
; }
498 bool IsMenuStringsEnabled() const { return mbMenuStrings
; }
500 void SetOutStyle( sal_uInt16 nNewStyle
);
501 sal_uInt16
GetOutStyle() const { return mnOutStyle
; }
503 void EnableCustomize( bool bEnable
= true );
504 bool IsCustomize() { return mbCustomize
; }
505 bool IsInCustomizeMode() const { return mbCustomizeMode
; }
507 using DockingWindow::SetHelpText
;
508 using DockingWindow::GetHelpText
;
509 using DockingWindow::SetHelpId
;
510 using DockingWindow::GetHelpId
;
512 void SetClickHdl( const Link
<ToolBox
*, void>& rLink
) { maClickHdl
= rLink
; }
513 void SetDoubleClickHdl( const Link
<ToolBox
*, void>& rLink
) { maDoubleClickHdl
= rLink
; }
514 void SetDropdownClickHdl( const Link
<ToolBox
*, void>& rLink
);
515 void SetActivateHdl( const Link
<ToolBox
*, void>& rLink
) { maActivateHdl
= rLink
; }
516 void SetDeactivateHdl( const Link
<ToolBox
*, void>& rLink
) { maDeactivateHdl
= rLink
; }
517 void SetSelectHdl( const Link
<ToolBox
*, void>& rLink
) { maSelectHdl
= rLink
; }
518 const Link
<ToolBox
*, void>& GetSelectHdl() const { return maSelectHdl
; }
519 void SetCommandHdl( const Link
<CommandEvent
const *, void>& aLink
) { maCommandHandler
= aLink
; }
520 void SetStateChangedHdl( const Link
<StateChangedType
const *, void>& aLink
) { maStateChangedHandler
= aLink
; }
521 void SetDataChangedHdl( const Link
<DataChangedEvent
const *, void>& aLink
) { maDataChangedHandler
= aLink
; }
523 // support for custom menu (eg for configuration)
524 // note: this menu will also be used to display currently
525 // clipped toolbox items, so you should only touch
526 // items that you added by yourself
527 // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
528 // to allow for customization of the menu the coresponding handler is called
529 // when the menu button was clicked and before the menu is executed
530 void SetMenuType( sal_uInt16 aType
= TOOLBOX_MENUTYPE_CUSTOMIZE
);
531 sal_uInt16
GetMenuType() const;
532 bool IsMenuEnabled() const;
533 PopupMenu
* GetMenu() const;
534 void UpdateCustomMenu();
535 void SetMenuButtonHdl( const Link
<ToolBox
*, void>& rLink
);
538 void ExecuteCustomMenu();
540 // allow Click Handler to detect special key
541 bool IsShift() const { return mbIsShift
; }
542 // allow Click Handler to distinguish between mouse and key input
543 bool IsKeyEvent() const { return mbIsKeyEvent
; }
545 // allows framework to set/query the planned popupmode
546 bool WillUsePopupMode() const;
547 void WillUsePopupMode( bool b
);
549 // accessibility helpers
551 // gets the displayed text
552 OUString
GetDisplayText() const SAL_OVERRIDE
;
553 // returns the bounding box for the character at index nIndex
554 // where nIndex is relative to the starting index of the item
555 // with id nItemId (in coordinates of the displaying window)
556 Rectangle
GetCharacterBounds( sal_uInt16 nItemId
, long nIndex
) const;
557 // -1 is returned if no character is at that point
558 // if an index is found the corresponding item id is filled in (else 0)
559 long GetIndexForPoint( const Point
& rPoint
, sal_uInt16
& rItemID
) const;
561 static Size
GetDefaultImageSize(bool bLarge
);
562 Size
GetDefaultImageSize() const;
563 void ChangeHighlight( sal_uInt16 nPos
);
565 void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout
);
568 inline void ToolBox::CheckItem( sal_uInt16 nItemId
, bool bCheck
)
570 SetItemState( nItemId
, (bCheck
) ? TRISTATE_TRUE
: TRISTATE_FALSE
);
573 inline bool ToolBox::IsItemChecked( sal_uInt16 nItemId
) const
575 return (GetItemState( nItemId
) == TRISTATE_TRUE
);
578 inline Size
ToolBox::CalcWindowSizePixel() const
580 return CalcWindowSizePixel( mnLines
);
583 inline Rectangle
ToolBox::GetScrollRect() const
585 return maUpperRect
.GetUnion( maLowerRect
);
588 inline void ToolBox::SetDockingRects( const Rectangle
& rOutRect
,
589 const Rectangle
& rInRect
)
591 maOutDockRect
= rOutRect
;
592 maInDockRect
= rInRect
;
595 inline void ToolBox::SetFloatingLines( sal_uInt16 nNewLines
)
597 mnFloatLines
= nNewLines
;
600 inline sal_uInt16
ToolBox::GetFloatingLines() const
605 #endif // INCLUDED_VCL_TOOLBOX_HXX
607 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */