/src/libreoffice/include/vcl/toolbox.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_VCL_TOOLBOX_HXX |
21 | | #define INCLUDED_VCL_TOOLBOX_HXX |
22 | | |
23 | | #include <vcl/vclenum.hxx> |
24 | | #include <vcl/dllapi.h> |
25 | | #include <vcl/dockwin.hxx> |
26 | | #include <vcl/toolboxid.hxx> |
27 | | #include <o3tl/typed_flags_set.hxx> |
28 | | #include <tools/degree.hxx> |
29 | | |
30 | | #include <limits> |
31 | | #include <memory> |
32 | | #include <vector> |
33 | | |
34 | | namespace com::sun::star::frame { class XFrame; } |
35 | | namespace vcl { class KeyCode; } |
36 | | |
37 | | class Image; |
38 | | class Timer; |
39 | | struct ImplToolItem; |
40 | | struct ImplToolBoxPrivateData; |
41 | | class PopupMenu; |
42 | | class VclMenuEvent; |
43 | | class StyleSettings; |
44 | | |
45 | | // item ids in the custom menu may not exceed this constant |
46 | | constexpr sal_uInt16 TOOLBOX_MENUITEM_START = 0x1000; |
47 | | |
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 |
53 | | }; |
54 | | namespace o3tl |
55 | | { |
56 | | template<> struct typed_flags<ToolBoxMenuType> : is_typed_flags<ToolBoxMenuType, 0x0003> {}; |
57 | | } |
58 | | |
59 | | enum class ToolBoxLayoutMode |
60 | | { |
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 |
65 | | }; |
66 | | |
67 | | // Position of the text when icon and text are painted |
68 | | enum class ToolBoxTextPosition { Right, Bottom }; |
69 | | |
70 | | class Idle; |
71 | | |
72 | | /// A toolbar: contains all those icons, typically below the menu bar. |
73 | | class VCL_DLLPUBLIC ToolBox : public DockingWindow |
74 | | { |
75 | | friend class FloatingWindow; |
76 | | friend class ImplTBDragMgr; |
77 | | |
78 | | public: |
79 | | using ImplToolItems = std::vector<ImplToolItem>; |
80 | | |
81 | | virtual FactoryFunction GetUITestFactory() const override; |
82 | | |
83 | 0 | void SetCurItemId( ToolBoxItemId CurID ) { mnCurItemId=CurID; } |
84 | | |
85 | | static constexpr auto APPEND |
86 | | = std::numeric_limits<ImplToolItems::size_type>::max(); |
87 | | |
88 | | static constexpr auto ITEM_NOTFOUND |
89 | | = std::numeric_limits<ImplToolItems::size_type>::max(); |
90 | | |
91 | | private: |
92 | | struct ImplToolSize |
93 | | { |
94 | | tools::Long mnWidth; |
95 | | tools::Long mnHeight; |
96 | | ImplToolItems::size_type mnLines; |
97 | | }; |
98 | | |
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; |
160 | | |
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(); |
168 | | |
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 | | static SAL_DLLPRIVATE void ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem const * pItem ); |
203 | | |
204 | | DECL_DLLPRIVATE_LINK( ImplUpdateHdl, Timer*, void ); |
205 | | DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent&, void ); |
206 | | DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl, Timer*, void ); |
207 | | |
208 | | ToolBox (const ToolBox &) = delete; |
209 | | ToolBox& operator= (const ToolBox &) = delete; |
210 | | |
211 | | public: |
212 | | SAL_DLLPRIVATE void ImplFloatControl( bool bStart, FloatingWindow* pWindow ); |
213 | | |
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); |
226 | | |
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); |
233 | | |
234 | | SAL_DLLPRIVATE void ImplErase(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, bool bHighlight, bool bHasOpenPopup = false ); |
235 | | |
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 | 0 | SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData.get(); } |
251 | | |
252 | | SAL_DLLPRIVATE void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&); |
253 | | SAL_DLLPRIVATE void ApplyForegroundSettings(vcl::RenderContext&, const StyleSettings&); |
254 | | |
255 | | protected: |
256 | | virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; |
257 | | |
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; |
264 | | |
265 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
266 | | |
267 | | virtual void Click(); |
268 | | SAL_DLLPRIVATE void DoubleClick(); |
269 | | virtual void Activate() override; |
270 | | virtual void Deactivate() override; |
271 | | SAL_DLLPRIVATE void Highlight(); |
272 | | virtual void Select(); |
273 | | |
274 | | virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; |
275 | | virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; |
276 | | virtual void MouseMove( const MouseEvent& rMEvt ) override; |
277 | | virtual void Tracking( const TrackingEvent& rTEvt ) override; |
278 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
279 | | virtual void Resize() override; |
280 | | virtual void RequestHelp( const HelpEvent& rHEvt ) override; |
281 | | virtual bool EventNotify( NotifyEvent& rNEvt ) override; |
282 | | virtual void Command( const CommandEvent& rCEvt ) override; |
283 | | virtual void StateChanged( StateChangedType nType ) override; |
284 | | virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; |
285 | | |
286 | | virtual void LoseFocus() override; |
287 | | virtual void KeyInput( const KeyEvent& rKEvt ) override; |
288 | | |
289 | | virtual void ToggleFloatingMode() override; |
290 | | virtual void StartDocking() override; |
291 | | virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override; |
292 | | virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override; |
293 | | virtual void Resizing( Size& rSize ) override; |
294 | | virtual Size GetOptimalSize() const override; |
295 | | virtual void doDeferredInit(WinBits nBits) override; |
296 | | virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; |
297 | | |
298 | | /// Insert a command (like '.uno:Save'). |
299 | | virtual void InsertItem( const OUString& rCommand, |
300 | | const css::uno::Reference<css::frame::XFrame>& rFrame, |
301 | | ToolBoxItemBits nBits, |
302 | | const Size& rRequestedSize, |
303 | | ImplToolItems::size_type nPos = APPEND ); |
304 | | void InsertItem( ToolBoxItemId nItemId, const Image& rImage, |
305 | | ToolBoxItemBits nBits = ToolBoxItemBits::NONE, |
306 | | ImplToolItems::size_type nPos = APPEND ); |
307 | | void InsertItem( ToolBoxItemId nItemId, const Image& rImage, |
308 | | const OUString& rText, |
309 | | ToolBoxItemBits nBits = ToolBoxItemBits::NONE, |
310 | | ImplToolItems::size_type nPos = APPEND ); |
311 | | void InsertItem( ToolBoxItemId nItemId, const OUString& rText, |
312 | | const OUString& rCommand, |
313 | | ToolBoxItemBits nBits = ToolBoxItemBits::NONE, |
314 | | ImplToolItems::size_type nPos = APPEND ); |
315 | | void InsertWindow( ToolBoxItemId nItemId, vcl::Window* pWindow, |
316 | | ToolBoxItemBits nBits = ToolBoxItemBits::NONE, |
317 | | ImplToolItems::size_type nPos = APPEND ); |
318 | | void InsertSpace(); |
319 | | void InsertSeparator( ImplToolItems::size_type nPos = APPEND, sal_uInt16 nPixSize = 0 ); |
320 | | void InsertBreak( ImplToolItems::size_type nPos = APPEND ); |
321 | | void RemoveItem( ImplToolItems::size_type nPos ); |
322 | | SAL_DLLPRIVATE void CopyItem( const ToolBox& rToolBox, ToolBoxItemId nItemId ); |
323 | | virtual void Clear(); |
324 | | |
325 | | void SetButtonType( ButtonType eNewType ); |
326 | 0 | ButtonType GetButtonType() const { return meButtonType; } |
327 | | |
328 | | // sets a fixed button size (small, large or dontcare (==autosize)) |
329 | | void SetToolboxButtonSize( ToolBoxButtonSize eSize ); |
330 | | ToolBoxButtonSize GetToolboxButtonSize() const; |
331 | | vcl::ImageType GetImageSize() const; |
332 | | |
333 | | void SetAlign( WindowAlign eNewAlign = WindowAlign::Top ); |
334 | 0 | WindowAlign GetAlign() const { return meAlign; } |
335 | 0 | bool IsHorizontal() const { return mbHorz; } |
336 | | |
337 | | void SetLineCount( ImplToolItems::size_type nNewLines ); |
338 | | SAL_DLLPRIVATE void ShowLine( bool bNext ); |
339 | | |
340 | | ImplToolItems::size_type GetItemCount() const; |
341 | | ToolBoxItemType GetItemType( ImplToolItems::size_type nPos ) const; |
342 | | ImplToolItems::size_type GetItemPos( ToolBoxItemId nItemId ) const; |
343 | | ImplToolItems::size_type GetItemPos( const Point& rPos ) const; |
344 | | ToolBoxItemId GetItemId( ImplToolItems::size_type nPos ) const; |
345 | | SAL_DLLPRIVATE ToolBoxItemId GetItemId( const Point& rPos ) const; |
346 | | /// Map the command name (like .uno:Save) back to item id. |
347 | | ToolBoxItemId GetItemId( const OUString& rCommand ) const; |
348 | | tools::Rectangle GetItemRect( ToolBoxItemId nItemId ); |
349 | | tools::Rectangle GetItemPosRect( ImplToolItems::size_type nPos ); |
350 | | SAL_DLLPRIVATE tools::Rectangle const & GetOverflowRect() const; |
351 | | |
352 | | /// Returns size of the bitmap / text that is inside this toolbox item. |
353 | | Size GetItemContentSize( ToolBoxItemId nItemId ); |
354 | | |
355 | 0 | ToolBoxItemId GetCurItemId() const { return mnCurItemId; } |
356 | 0 | ToolBoxItemId GetDownItemId() const { return mnDownItemId; } |
357 | 0 | sal_uInt16 GetModifier() const { return mnMouseModifier; } |
358 | | |
359 | | void SetItemBits( ToolBoxItemId nItemId, ToolBoxItemBits nBits ); |
360 | | ToolBoxItemBits GetItemBits( ToolBoxItemId nItemId ) const; |
361 | | |
362 | | SAL_DLLPRIVATE void SetItemExpand( ToolBoxItemId nItemId, bool bExpand ); |
363 | | // e.g. a label used as an itemwindow |
364 | | void SetItemWindowNonInteractive(ToolBoxItemId nItemId, bool bNonInteractive); |
365 | | |
366 | | |
367 | | void SetItemData( ToolBoxItemId nItemId, void* pNewData ); |
368 | | void* GetItemData( ToolBoxItemId nItemId ) const; |
369 | | void SetItemImage( ToolBoxItemId nItemId, const Image& rImage ); |
370 | | SAL_DLLPRIVATE Image GetItemImage( ToolBoxItemId nItemId ) const; |
371 | | void SetItemImageAngle( ToolBoxItemId nItemId, Degree10 nAngle10 ); |
372 | | void SetItemImageMirrorMode( ToolBoxItemId nItemId, bool bMirror ); |
373 | | void SetItemText( ToolBoxItemId nItemId, const OUString& rText ); |
374 | | const OUString& GetItemText( ToolBoxItemId nItemId ) const; |
375 | | void SetItemWindow( ToolBoxItemId nItemId, vcl::Window* pNewWindow ); |
376 | | vcl::Window* GetItemWindow( ToolBoxItemId nItemId ) const; |
377 | 0 | ToolBoxItemId GetHighlightItemId() const { return mnHighItemId; } |
378 | | |
379 | | void EndSelection(); |
380 | | |
381 | | void SetItemDown( ToolBoxItemId nItemId, bool bDown ); |
382 | | |
383 | | void SetItemState( ToolBoxItemId nItemId, TriState eState ); |
384 | | TriState GetItemState( ToolBoxItemId nItemId ) const; |
385 | | |
386 | | void CheckItem( ToolBoxItemId nItemId, bool bCheck = true ); |
387 | | bool IsItemChecked( ToolBoxItemId nItemId ) const; |
388 | | |
389 | | void EnableItem( ToolBoxItemId nItemId, bool bEnable = true ); |
390 | | bool IsItemEnabled( ToolBoxItemId nItemId ) const; |
391 | | |
392 | | void TriggerItem( ToolBoxItemId nItemId ); |
393 | | |
394 | | bool ItemHasDropdown( ToolBoxItemId nItemId ); |
395 | | void TriggerItemDropdown( ToolBoxItemId nItemId ); |
396 | | |
397 | | /// Shows or hides items. |
398 | | void ShowItem(ToolBoxItemId nItemId, bool bVisible = true); |
399 | | |
400 | | /// Convenience method to hide items (via ShowItem). |
401 | 0 | void HideItem(ToolBoxItemId nItemId) { ShowItem( nItemId, false ); } |
402 | | |
403 | | bool IsItemClipped( ToolBoxItemId nItemId ) const; |
404 | | bool IsItemVisible( ToolBoxItemId nItemId ) const; |
405 | | bool IsItemReallyVisible( ToolBoxItemId nItemId ) const; |
406 | | |
407 | | void SetItemCommand( ToolBoxItemId nItemId, const OUString& rCommand ); |
408 | | OUString GetItemCommand( ToolBoxItemId nItemId ) const; |
409 | | |
410 | | using Window::SetQuickHelpText; |
411 | | void SetQuickHelpText( ToolBoxItemId nItemId, const OUString& rText ); |
412 | | using Window::GetQuickHelpText; |
413 | | OUString GetQuickHelpText( ToolBoxItemId nItemId ) const; |
414 | | |
415 | | void SetHelpText( ToolBoxItemId nItemId, const OUString& rText ); |
416 | | const OUString& GetHelpText( ToolBoxItemId nItemId ) const; |
417 | | |
418 | | void SetHelpId( ToolBoxItemId nItemId, const OUString& rHelpId ); |
419 | | |
420 | | using DockingWindow::SetAccessibleName; |
421 | | SAL_DLLPRIVATE void SetAccessibleName(ToolBoxItemId nItemId, const OUString& rName ); |
422 | | OUString GetAccessibleName(ToolBoxItemId nItemId) const; |
423 | | |
424 | | // window size according to current alignment, floating state and number of lines |
425 | | Size CalcWindowSizePixel(); |
426 | | // window size according to current alignment, floating state and a given number of lines |
427 | | Size CalcWindowSizePixel( ImplToolItems::size_type nCalcLines ); |
428 | | // window size according to current floating state and a given number of lines and a given alignment |
429 | | Size CalcWindowSizePixel( ImplToolItems::size_type nCalcLines, WindowAlign eAlign ); |
430 | | // floating window size according to number of lines (uses the number of line breaks) |
431 | | Size CalcFloatingWindowSizePixel(); |
432 | | // floating window size with a given number of lines |
433 | | Size CalcFloatingWindowSizePixel( ImplToolItems::size_type nCalcLines ); |
434 | | // automatic window size for popup mode |
435 | | Size CalcPopupWindowSizePixel(); |
436 | | |
437 | | // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button) |
438 | | Size CalcMinimumWindowSizePixel(); |
439 | | |
440 | | ImplToolItems::size_type GetFloatingLines() const; |
441 | | |
442 | | void SetStyle( WinBits nNewStyle ); |
443 | 0 | WinBits GetStyle() const { return mnWinStyle; } |
444 | | |
445 | | // enable/disable undocking |
446 | | SAL_DLLPRIVATE void Lock( bool bLock ); |
447 | | |
448 | | void EnableCustomize( bool bEnable = true ); |
449 | 0 | bool IsCustomize() const { return mbCustomize; } |
450 | | |
451 | | using DockingWindow::SetHelpText; |
452 | | using DockingWindow::GetHelpText; |
453 | | using DockingWindow::SetHelpId; |
454 | | using DockingWindow::GetHelpId; |
455 | | |
456 | 0 | void SetClickHdl( const Link<ToolBox *, void>& rLink ) { maClickHdl = rLink; } |
457 | 0 | void SetDoubleClickHdl( const Link<ToolBox *, void>& rLink ) { maDoubleClickHdl = rLink; } |
458 | | void SetDropdownClickHdl( const Link<ToolBox *, void>& rLink ); |
459 | 0 | void SetActivateHdl( const Link<ToolBox *, void>& rLink ) { maActivateHdl = rLink; } |
460 | 0 | void SetDeactivateHdl( const Link<ToolBox *, void>& rLink ) { maDeactivateHdl = rLink; } |
461 | 0 | void SetSelectHdl( const Link<ToolBox *, void>& rLink ) { maSelectHdl = rLink; } |
462 | 0 | void SetStateChangedHdl( const Link<StateChangedType const *, void>& aLink ) { maStateChangedHandler = aLink; } |
463 | 0 | void SetDataChangedHdl( const Link<DataChangedEvent const *, void>& aLink ) { maDataChangedHandler = aLink; } |
464 | 0 | void SetMenuButtonHdl( const Link<ToolBox *, void>& rLink ) { maMenuButtonHdl = rLink; } |
465 | | |
466 | | // support for custom menu (eg for configuration) |
467 | | // note: this menu will also be used to display currently |
468 | | // clipped toolbox items, so you should only touch |
469 | | // items that you added by yourself |
470 | | // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START |
471 | | // to allow for customization of the menu the corresponding handler is called |
472 | | // when the menu button was clicked and before the menu is executed |
473 | | void SetMenuType( ToolBoxMenuType aType = ToolBoxMenuType::Customize ); |
474 | | ToolBoxMenuType GetMenuType() const; |
475 | | SAL_DLLPRIVATE bool IsMenuEnabled() const; |
476 | | PopupMenu* GetMenu() const; |
477 | | SAL_DLLPRIVATE void UpdateCustomMenu(PopupMenu* pMenu); |
478 | | void SetMenuExecuteHdl( const Link<ToolBox *, void>& rLink ); |
479 | | |
480 | | // open custommenu |
481 | | SAL_DLLPRIVATE void ExecuteCustomMenu( const tools::Rectangle& rRect = tools::Rectangle() ); |
482 | | |
483 | | // allow Click Handler to distinguish between mouse and key input |
484 | 0 | bool IsKeyEvent() const { return mbIsKeyEvent; } |
485 | | |
486 | | // allows framework to set/query the planned popupmode |
487 | | bool WillUsePopupMode() const; |
488 | | void WillUsePopupMode( bool b); |
489 | | |
490 | | // accessibility helpers |
491 | | |
492 | | // gets the displayed text |
493 | | OUString GetDisplayText() const override; |
494 | | // returns the bounding box for the character at index nIndex |
495 | | // where nIndex is relative to the starting index of the item |
496 | | // with id nItemId (in coordinates of the displaying window) |
497 | | tools::Rectangle GetCharacterBounds( ToolBoxItemId nItemId, tools::Long nIndex ); |
498 | | // -1 is returned if no character is at that point |
499 | | // if an index is found the corresponding item id is filled in (else 0) |
500 | | tools::Long GetIndexForPoint( const Point& rPoint, ToolBoxItemId& rItemID ); |
501 | | |
502 | | static Size GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize); |
503 | | Size GetDefaultImageSize() const; |
504 | | void ChangeHighlight( ImplToolItems::size_type nPos ); |
505 | | |
506 | | |
507 | | void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout ); |
508 | | |
509 | | void SetToolBoxTextPosition( ToolBoxTextPosition ePosition ); |
510 | | |
511 | 0 | void SetLineSpacing(bool b) { mbLineSpacing = b; } |
512 | | |
513 | | virtual void DumpAsPropertyTree(tools::JsonWriter&) override; |
514 | | }; |
515 | | |
516 | | inline void ToolBox::CheckItem( ToolBoxItemId nItemId, bool bCheck ) |
517 | 0 | { |
518 | 0 | SetItemState( nItemId, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE ); |
519 | 0 | } |
520 | | |
521 | | inline bool ToolBox::IsItemChecked( ToolBoxItemId nItemId ) const |
522 | 0 | { |
523 | 0 | return (GetItemState( nItemId ) == TRISTATE_TRUE); |
524 | 0 | } |
525 | | |
526 | | inline Size ToolBox::CalcWindowSizePixel() |
527 | 0 | { |
528 | 0 | return CalcWindowSizePixel( mnLines ); |
529 | 0 | } |
530 | | |
531 | | inline ToolBox::ImplToolItems::size_type ToolBox::GetFloatingLines() const |
532 | 0 | { |
533 | 0 | return mnFloatLines; |
534 | 0 | } |
535 | | |
536 | | #endif // INCLUDED_VCL_TOOLBOX_HXX |
537 | | |
538 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |