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