bump product version to 7.6.3.2-android
[LibreOffice.git] / include / vcl / toolbox.hxx
blobe04cb3d1ae376c2449b8f7d7e07aa591de674b68
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <vcl/vclenum.hxx>
24 #include <vcl/dllapi.h>
25 #include <vcl/dockwin.hxx>
26 #include <vcl/image.hxx>
27 #include <vcl/keycod.hxx>
28 #include <vcl/toolboxid.hxx>
29 #include <o3tl/typed_flags_set.hxx>
30 #include <tools/degree.hxx>
32 #include <limits>
33 #include <memory>
34 #include <vector>
36 namespace com::sun::star::frame { class XFrame; }
38 class Timer;
39 struct ImplToolItem;
40 struct ImplToolBoxPrivateData;
41 class PopupMenu;
42 class VclMenuEvent;
43 class StyleSettings;
45 // item ids in the custom menu may not exceed this constant
46 constexpr sal_uInt16 TOOLBOX_MENUITEM_START = 0x1000;
48 // defines for the menubutton
49 enum class ToolBoxMenuType {
50 NONE = 0x0000, // no menu at all, scrolling by spin buttons
51 ClippedItems = 0x0001, // menu will contain "more" indicator
52 Customize = 0x0002 // menu will contain "customization" and "more" indicator
54 namespace o3tl
56 template<> struct typed_flags<ToolBoxMenuType> : is_typed_flags<ToolBoxMenuType, 0x0003> {};
59 enum class ToolBoxLayoutMode
61 Normal, // traditional layout, items are centered in the toolbar
62 Locked // horizontal positions of all items remain unchanged,
63 // vertical positions of items smaller than first item are aligned to first item's vertical center,
64 // vertical positions of items larger than first item remain unchanged
67 // Position of the text when icon and text are painted
68 enum class ToolBoxTextPosition { Right, Bottom };
70 class Idle;
72 /// A toolbar: contains all those icons, typically below the menu bar.
73 class VCL_DLLPUBLIC ToolBox : public DockingWindow
75 friend class FloatingWindow;
76 friend class ImplTBDragMgr;
78 public:
79 using ImplToolItems = std::vector<ImplToolItem>;
81 virtual FactoryFunction GetUITestFactory() const override;
83 void SetCurItemId( ToolBoxItemId CurID ) { mnCurItemId=CurID; }
85 static constexpr auto APPEND
86 = std::numeric_limits<ImplToolItems::size_type>::max();
88 static constexpr auto ITEM_NOTFOUND
89 = std::numeric_limits<ImplToolItems::size_type>::max();
91 private:
92 struct ImplToolSize
94 tools::Long mnWidth;
95 tools::Long mnHeight;
96 ImplToolItems::size_type mnLines;
99 std::unique_ptr<ImplToolBoxPrivateData> mpData;
100 std::vector<ImplToolSize> maFloatSizes;
101 std::unique_ptr<Idle> mpIdle;
102 tools::Rectangle maUpperRect;
103 tools::Rectangle maLowerRect;
104 tools::Rectangle maPaintRect;
105 VclPtr<FloatingWindow> mpFloatWin;
106 tools::Long mnDX;
107 tools::Long mnDY;
108 tools::Long mnMaxItemWidth; // max item width
109 tools::Long mnMaxItemHeight; // max item height (for standard items)
110 tools::Long mnWinHeight; // max window height (for window items)
111 tools::Long mnLeftBorder; // inner border
112 tools::Long mnTopBorder;
113 tools::Long mnRightBorder;
114 tools::Long mnBottomBorder;
115 tools::Long mnLastResizeDY;
116 tools::Long mnActivateCount;
117 ToolBoxItemId mnLastFocusItemId;
118 ToolBoxItemId mnHighItemId;
119 ToolBoxItemId mnCurItemId;
120 ToolBoxItemId mnDownItemId;
121 ImplToolItems::size_type mnCurPos;
122 ImplToolItems::size_type mnLines; // total number of toolbox lines
123 ImplToolItems::size_type mnCurLine; // the currently visible line
124 ImplToolItems::size_type mnCurLines; // number of lines due to line breaking
125 ImplToolItems::size_type mnVisLines; // number of visible lines (for scrolling)
126 ImplToolItems::size_type mnFloatLines; // number of lines during floating mode
127 ImplToolItems::size_type mnDockLines;
128 sal_uInt16 mnMouseModifier;
129 bool mbDrag:1,
130 mbUpper:1,
131 mbLower:1,
132 mbIn:1,
133 mbCalc:1,
134 mbFormat:1,
135 mbFullPaint:1,
136 mbHorz:1,
137 mbScroll:1,
138 mbLastFloatMode:1,
139 mbCustomize:1,
140 mbDragging:1,
141 mbIsKeyEvent:1,
142 mbChangingHighlight:1,
143 mbLineSpacing:1,
144 mbIsArranged:1;
145 WindowAlign meAlign;
146 WindowAlign meDockAlign;
147 ButtonType meButtonType;
148 PointerStyle meLastStyle;
149 WinBits mnWinStyle;
150 ToolBoxLayoutMode meLayoutMode;
151 ToolBoxTextPosition meTextPosition;
152 Link<ToolBox *, void> maClickHdl;
153 Link<ToolBox *, void> maDoubleClickHdl;
154 Link<ToolBox *, void> maActivateHdl;
155 Link<ToolBox *, void> maDeactivateHdl;
156 Link<ToolBox *, void> maSelectHdl;
157 Link<ToolBox *, void> maMenuButtonHdl;
158 Link<StateChangedType const *, void> maStateChangedHandler;
159 Link<DataChangedEvent const *, void> maDataChangedHandler;
161 public:
162 using Window::ImplInit;
163 private:
164 SAL_DLLPRIVATE void InvalidateItem(ImplToolItems::size_type nPosition);
165 SAL_DLLPRIVATE void InvalidateSpin(bool bInvalidateUpper = true,
166 bool bInvalidateLower = true);
167 SAL_DLLPRIVATE void InvalidateMenuButton();
169 SAL_DLLPRIVATE void ImplInitToolBoxData();
170 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
171 using DockingWindow::ImplInitSettings;
172 SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
173 SAL_DLLPRIVATE ImplToolItem* ImplGetItem( ToolBoxItemId nId ) const;
174 SAL_DLLPRIVATE bool ImplCalcItem();
175 SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcBreaks( tools::Long nWidth, sal_Int32* pMaxLineWidth, bool bCalcHorz ) const;
176 SAL_DLLPRIVATE void ImplFormat( bool bResize = false );
177 SAL_DLLPRIVATE void ImplDrawSpin(vcl::RenderContext& rRenderContext);
178 SAL_DLLPRIVATE void ImplDrawSeparator(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, const tools::Rectangle& rRect);
179 SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight );
180 using Window::ImplInvalidate;
181 SAL_DLLPRIVATE void ImplInvalidate( bool bNewCalc = false, bool bFullPaint = false );
182 SAL_DLLPRIVATE void ImplUpdateItem( ImplToolItems::size_type nIndex = ITEM_NOTFOUND );
183 SAL_DLLPRIVATE bool ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat = false );
184 SAL_DLLPRIVATE bool ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel = false );
185 SAL_DLLPRIVATE void ImplChangeHighlight( ImplToolItem const * pItem, bool bNoGrabFocus = false );
186 SAL_DLLPRIVATE bool ImplChangeHighlightUpDn( bool bUp, bool bNoCycle = false );
187 SAL_DLLPRIVATE ImplToolItems::size_type ImplGetItemLine( ImplToolItem const * pCurrentItem );
188 SAL_DLLPRIVATE ImplToolItem* ImplGetFirstValidItem( ImplToolItems::size_type nLine );
189 SAL_DLLPRIVATE bool ImplOpenItem( vcl::KeyCode aKeyCode );
190 SAL_DLLPRIVATE bool ImplActivateItem( vcl::KeyCode aKeyCode );
191 SAL_DLLPRIVATE void ImplShowFocus();
192 SAL_DLLPRIVATE void ImplHideFocus();
193 SAL_DLLPRIVATE void ImplUpdateInputEnable();
194 SAL_DLLPRIVATE void ImplFillLayoutData();
195 SAL_DLLPRIVATE bool ImplHasClippedItems();
196 SAL_DLLPRIVATE Point ImplGetPopupPosition( const tools::Rectangle& rRect ) const;
197 SAL_DLLPRIVATE bool ImplIsFloatingMode() const;
198 SAL_DLLPRIVATE bool ImplIsInPopupMode() const;
199 SAL_DLLPRIVATE const OUString& ImplGetHelpText( ToolBoxItemId nItemId ) const;
200 SAL_DLLPRIVATE Size ImplGetOptimalFloatingSize();
201 SAL_DLLPRIVATE bool ImplHasExternalMenubutton() const;
202 SAL_DLLPRIVATE void ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem const * pItem );
204 DECL_DLLPRIVATE_LINK( ImplUpdateHdl, Timer*, void );
205 DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent&, void );
206 DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl, Timer*, void );
208 ToolBox (const ToolBox &) = delete;
209 ToolBox& operator= (const ToolBox &) = delete;
211 public:
212 SAL_DLLPRIVATE void ImplFloatControl( bool bStart, FloatingWindow* pWindow );
214 SAL_DLLPRIVATE int ImplGetDragWidth() const;
215 static SAL_DLLPRIVATE int ImplGetDragWidth( const vcl::RenderContext& rRenderContext,
216 bool bHorz );
217 static SAL_DLLPRIVATE int ImplGetDragWidth( const vcl::Window& rWindow,
218 bool bHorz );
219 SAL_DLLPRIVATE void ImplUpdateDragArea() const;
220 SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, tools::Long& rLeft, tools::Long& rTop,
221 tools::Long& rRight, tools::Long& rBottom ) const;
222 SAL_DLLPRIVATE void ImplCheckUpdate();
223 static SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext,
224 const tools::Rectangle &aDragArea, int nDragWidth,
225 WindowAlign eAlign, bool bHorz);
227 SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext);
228 SAL_DLLPRIVATE void ImplDrawGradientBackground(vcl::RenderContext& rRenderContext);
229 SAL_DLLPRIVATE bool ImplDrawNativeBackground(vcl::RenderContext& rRenderContext) const;
230 SAL_DLLPRIVATE void ImplDrawTransparentBackground(const vcl::Region &rRegion);
231 SAL_DLLPRIVATE static void ImplDrawConstantBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion, bool bIsInPopupMode);
232 SAL_DLLPRIVATE void ImplDrawBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect);
234 SAL_DLLPRIVATE void ImplErase(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, bool bHighlight, bool bHasOpenPopup = false );
236 SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext);
237 SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem() const;
238 SAL_DLLPRIVATE Size ImplCalcSize( ImplToolItems::size_type nCalcLines, sal_uInt16 nCalcMode = 0 );
239 SAL_DLLPRIVATE void ImplCalcFloatSizes();
240 SAL_DLLPRIVATE Size ImplCalcFloatSize( ImplToolItems::size_type& rLines );
241 SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( Size& rMinSize, Size& rMaxSize );
242 SAL_DLLPRIVATE void ImplSetMinMaxFloatSize();
243 SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcLines( tools::Long nToolSize ) const;
244 SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( const Point& rPos ) const;
245 SAL_DLLPRIVATE void ImplLineSizing( const Point& rPos, tools::Rectangle& rRect, sal_uInt16 nLineMode );
246 SAL_DLLPRIVATE static ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList );
247 SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
248 SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
249 SAL_DLLPRIVATE ImplToolItems::size_type ImplCountLineBreaks() const;
250 SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData.get(); }
252 SAL_DLLPRIVATE void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
253 SAL_DLLPRIVATE void ApplyForegroundSettings(vcl::RenderContext&, const StyleSettings&);
255 protected:
256 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
258 public:
259 ToolBox(vcl::Window* pParent, WinBits nStyle = 0);
260 ToolBox(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription,
261 const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
262 virtual ~ToolBox() override;
263 virtual void dispose() override;
265 virtual void Click();
266 void DoubleClick();
267 virtual void Activate() override;
268 virtual void Deactivate() override;
269 void Highlight();
270 virtual void Select();
272 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
273 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
274 virtual void MouseMove( const MouseEvent& rMEvt ) override;
275 virtual void Tracking( const TrackingEvent& rTEvt ) override;
276 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
277 virtual void Resize() override;
278 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
279 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
280 virtual void Command( const CommandEvent& rCEvt ) override;
281 virtual void StateChanged( StateChangedType nType ) override;
282 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
284 virtual void LoseFocus() override;
285 virtual void KeyInput( const KeyEvent& rKEvt ) override;
287 virtual void ToggleFloatingMode() override;
288 virtual void StartDocking() override;
289 virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override;
290 virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override;
291 virtual void Resizing( Size& rSize ) override;
292 virtual Size GetOptimalSize() const override;
293 virtual void doDeferredInit(WinBits nBits) override;
294 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
296 /// Insert a command (like '.uno:Save').
297 virtual void InsertItem( const OUString& rCommand,
298 const css::uno::Reference<css::frame::XFrame>& rFrame,
299 ToolBoxItemBits nBits,
300 const Size& rRequestedSize,
301 ImplToolItems::size_type nPos = APPEND );
302 void InsertItem( ToolBoxItemId nItemId, const Image& rImage,
303 ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
304 ImplToolItems::size_type nPos = APPEND );
305 void InsertItem( ToolBoxItemId nItemId, const Image& rImage,
306 const OUString& rText,
307 ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
308 ImplToolItems::size_type nPos = APPEND );
309 void InsertItem( ToolBoxItemId nItemId, const OUString& rText,
310 const OUString& rCommand,
311 ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
312 ImplToolItems::size_type nPos = APPEND );
313 void InsertWindow( ToolBoxItemId nItemId, vcl::Window* pWindow,
314 ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
315 ImplToolItems::size_type nPos = APPEND );
316 void InsertSpace();
317 void InsertSeparator( ImplToolItems::size_type nPos = APPEND, sal_uInt16 nPixSize = 0 );
318 void InsertBreak( ImplToolItems::size_type nPos = APPEND );
319 void RemoveItem( ImplToolItems::size_type nPos );
320 void CopyItem( const ToolBox& rToolBox, ToolBoxItemId nItemId );
321 void Clear();
323 void SetButtonType( ButtonType eNewType );
324 ButtonType GetButtonType() const { return meButtonType; }
326 // sets a fixed button size (small, large or dontcare (==autosize))
327 void SetToolboxButtonSize( ToolBoxButtonSize eSize );
328 ToolBoxButtonSize GetToolboxButtonSize() const;
329 vcl::ImageType GetImageSize() const;
331 void SetAlign( WindowAlign eNewAlign = WindowAlign::Top );
332 WindowAlign GetAlign() const { return meAlign; }
333 bool IsHorizontal() const { return mbHorz; }
335 void SetLineCount( ImplToolItems::size_type nNewLines );
336 void ShowLine( bool bNext );
338 ImplToolItems::size_type GetItemCount() const;
339 ToolBoxItemType GetItemType( ImplToolItems::size_type nPos ) const;
340 ImplToolItems::size_type GetItemPos( ToolBoxItemId nItemId ) const;
341 ImplToolItems::size_type GetItemPos( const Point& rPos ) const;
342 ToolBoxItemId GetItemId( ImplToolItems::size_type nPos ) const;
343 ToolBoxItemId GetItemId( const Point& rPos ) const;
344 /// Map the command name (like .uno:Save) back to item id.
345 ToolBoxItemId GetItemId( const OUString& rCommand ) const;
346 tools::Rectangle GetItemRect( ToolBoxItemId nItemId );
347 tools::Rectangle GetItemPosRect( ImplToolItems::size_type nPos );
348 tools::Rectangle const & GetOverflowRect() const;
350 /// Returns size of the bitmap / text that is inside this toolbox item.
351 Size GetItemContentSize( ToolBoxItemId nItemId );
353 ToolBoxItemId GetCurItemId() const { return mnCurItemId; }
354 ToolBoxItemId GetDownItemId() const { return mnDownItemId; }
355 sal_uInt16 GetModifier() const { return mnMouseModifier; }
357 void SetItemBits( ToolBoxItemId nItemId, ToolBoxItemBits nBits );
358 ToolBoxItemBits GetItemBits( ToolBoxItemId nItemId ) const;
360 void SetItemExpand( ToolBoxItemId nItemId, bool bExpand );
361 // e.g. a label used as an itemwindow
362 void SetItemWindowNonInteractive(ToolBoxItemId nItemId, bool bNonInteractive);
365 void SetItemData( ToolBoxItemId nItemId, void* pNewData );
366 void* GetItemData( ToolBoxItemId nItemId ) const;
367 void SetItemImage( ToolBoxItemId nItemId, const Image& rImage );
368 Image GetItemImage( ToolBoxItemId nItemId ) const;
369 void SetItemImageAngle( ToolBoxItemId nItemId, Degree10 nAngle10 );
370 void SetItemImageMirrorMode( ToolBoxItemId nItemId, bool bMirror );
371 void SetItemText( ToolBoxItemId nItemId, const OUString& rText );
372 const OUString& GetItemText( ToolBoxItemId nItemId ) const;
373 void SetItemWindow( ToolBoxItemId nItemId, vcl::Window* pNewWindow );
374 vcl::Window* GetItemWindow( ToolBoxItemId nItemId ) const;
375 ToolBoxItemId GetHighlightItemId() const { return mnHighItemId; }
377 void EndSelection();
379 void SetItemDown( ToolBoxItemId nItemId, bool bDown );
381 void SetItemState( ToolBoxItemId nItemId, TriState eState );
382 TriState GetItemState( ToolBoxItemId nItemId ) const;
384 void CheckItem( ToolBoxItemId nItemId, bool bCheck = true );
385 bool IsItemChecked( ToolBoxItemId nItemId ) const;
387 void EnableItem( ToolBoxItemId nItemId, bool bEnable = true );
388 bool IsItemEnabled( ToolBoxItemId nItemId ) const;
390 void TriggerItem( ToolBoxItemId nItemId );
392 /// Shows or hides items.
393 void ShowItem(ToolBoxItemId nItemId, bool bVisible = true);
395 /// Convenience method to hide items (via ShowItem).
396 void HideItem(ToolBoxItemId nItemId) { ShowItem( nItemId, false ); }
398 bool IsItemClipped( ToolBoxItemId nItemId ) const;
399 bool IsItemVisible( ToolBoxItemId nItemId ) const;
400 bool IsItemReallyVisible( ToolBoxItemId nItemId ) const;
402 void SetItemCommand( ToolBoxItemId nItemId, const OUString& rCommand );
403 OUString GetItemCommand( ToolBoxItemId nItemId ) const;
405 using Window::SetQuickHelpText;
406 void SetQuickHelpText( ToolBoxItemId nItemId, const OUString& rText );
407 using Window::GetQuickHelpText;
408 OUString GetQuickHelpText( ToolBoxItemId nItemId ) const;
410 void SetHelpText( ToolBoxItemId nItemId, const OUString& rText );
411 const OUString& GetHelpText( ToolBoxItemId nItemId ) const;
413 void SetHelpId( ToolBoxItemId nItemId, const OUString& rHelpId );
415 // window size according to current alignment, floating state and number of lines
416 Size CalcWindowSizePixel();
417 // window size according to current alignment, floating state and a given number of lines
418 Size CalcWindowSizePixel( ImplToolItems::size_type nCalcLines );
419 // window size according to current floating state and a given number of lines and a given alignment
420 Size CalcWindowSizePixel( ImplToolItems::size_type nCalcLines, WindowAlign eAlign );
421 // floating window size according to number of lines (uses the number of line breaks)
422 Size CalcFloatingWindowSizePixel();
423 // floating window size with a given number of lines
424 Size CalcFloatingWindowSizePixel( ImplToolItems::size_type nCalcLines );
425 // automatic window size for popup mode
426 Size CalcPopupWindowSizePixel();
428 // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
429 Size CalcMinimumWindowSizePixel();
431 ImplToolItems::size_type GetFloatingLines() const;
433 void SetStyle( WinBits nNewStyle );
434 WinBits GetStyle() const { return mnWinStyle; }
436 // enable/disable undocking
437 void Lock( bool bLock );
438 // read configuration to determine locking behaviour
439 static bool AlwaysLocked();
441 void EnableCustomize( bool bEnable = true );
442 bool IsCustomize() const { return mbCustomize; }
444 using DockingWindow::SetHelpText;
445 using DockingWindow::GetHelpText;
446 using DockingWindow::SetHelpId;
447 using DockingWindow::GetHelpId;
449 void SetClickHdl( const Link<ToolBox *, void>& rLink ) { maClickHdl = rLink; }
450 void SetDoubleClickHdl( const Link<ToolBox *, void>& rLink ) { maDoubleClickHdl = rLink; }
451 void SetDropdownClickHdl( const Link<ToolBox *, void>& rLink );
452 void SetActivateHdl( const Link<ToolBox *, void>& rLink ) { maActivateHdl = rLink; }
453 void SetDeactivateHdl( const Link<ToolBox *, void>& rLink ) { maDeactivateHdl = rLink; }
454 void SetSelectHdl( const Link<ToolBox *, void>& rLink ) { maSelectHdl = rLink; }
455 void SetStateChangedHdl( const Link<StateChangedType const *, void>& aLink ) { maStateChangedHandler = aLink; }
456 void SetDataChangedHdl( const Link<DataChangedEvent const *, void>& aLink ) { maDataChangedHandler = aLink; }
457 void SetMenuButtonHdl( const Link<ToolBox *, void>& rLink ) { maMenuButtonHdl = rLink; }
459 // support for custom menu (eg for configuration)
460 // note: this menu will also be used to display currently
461 // clipped toolbox items, so you should only touch
462 // items that you added by yourself
463 // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START
464 // to allow for customization of the menu the corresponding handler is called
465 // when the menu button was clicked and before the menu is executed
466 void SetMenuType( ToolBoxMenuType aType = ToolBoxMenuType::Customize );
467 ToolBoxMenuType GetMenuType() const;
468 bool IsMenuEnabled() const;
469 PopupMenu* GetMenu() const;
470 void UpdateCustomMenu();
471 void SetMenuExecuteHdl( const Link<ToolBox *, void>& rLink );
473 // open custommenu
474 void ExecuteCustomMenu( const tools::Rectangle& rRect = tools::Rectangle() );
476 // allow Click Handler to distinguish between mouse and key input
477 bool IsKeyEvent() const { return mbIsKeyEvent; }
479 // allows framework to set/query the planned popupmode
480 bool WillUsePopupMode() const;
481 void WillUsePopupMode( bool b);
483 // accessibility helpers
485 // gets the displayed text
486 OUString GetDisplayText() const override;
487 // returns the bounding box for the character at index nIndex
488 // where nIndex is relative to the starting index of the item
489 // with id nItemId (in coordinates of the displaying window)
490 tools::Rectangle GetCharacterBounds( ToolBoxItemId nItemId, tools::Long nIndex );
491 // -1 is returned if no character is at that point
492 // if an index is found the corresponding item id is filled in (else 0)
493 tools::Long GetIndexForPoint( const Point& rPoint, ToolBoxItemId& rItemID );
495 static Size GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize);
496 Size GetDefaultImageSize() const;
497 void ChangeHighlight( ImplToolItems::size_type nPos );
500 void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
502 void SetToolBoxTextPosition( ToolBoxTextPosition ePosition );
504 void SetLineSpacing(bool b) { mbLineSpacing = b; }
506 virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
509 inline void ToolBox::CheckItem( ToolBoxItemId nItemId, bool bCheck )
511 SetItemState( nItemId, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE );
514 inline bool ToolBox::IsItemChecked( ToolBoxItemId nItemId ) const
516 return (GetItemState( nItemId ) == TRISTATE_TRUE);
519 inline Size ToolBox::CalcWindowSizePixel()
521 return CalcWindowSizePixel( mnLines );
524 inline ToolBox::ImplToolItems::size_type ToolBox::GetFloatingLines() const
526 return mnFloatLines;
529 #endif // INCLUDED_VCL_TOOLBOX_HXX
531 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */