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 <o3tl/typed_flags_set.hxx>
29 #include <tools/degree.hxx>
30 
31 #include <limits>
32 #include <memory>
33 #include <vector>
34 
35 namespace com::sun::star::frame { class XFrame; }
36 namespace com::sun::star::frame { struct FeatureStateEvent; }
37 template <class T> class VclStatusListener;
38 
39 class Timer;
40 struct ImplToolItem;
42 class PopupMenu;
43 class VclMenuEvent;
44 class StyleSettings;
45 
46 // item ids in the custom menu may not exceed this constant
47 constexpr sal_uInt16 TOOLBOX_MENUITEM_START = 0x1000;
48 
49 // defines for the menubutton
50 enum class ToolBoxMenuType {
51  NONE = 0x0000, // no menu at all, scrolling by spin buttons
52  ClippedItems = 0x0001, // menu will contain "more" indicator
53  Customize = 0x0002 // menu will contain "customization" and "more" indicator
54 };
55 namespace o3tl
56 {
57  template<> struct typed_flags<ToolBoxMenuType> : is_typed_flags<ToolBoxMenuType, 0x0003> {};
58 }
59 
61 {
62  Normal, // traditional layout, items are centered in the toolbar
63  Locked // horizontal positions of all items remain unchanged,
64  // vertical positions of items smaller than first item are aligned to first item's vertical center,
65  // vertical positions of items larger than first item remain unchanged
66 };
67 
68 // Position of the text when icon and text are painted
70 
71 class Idle;
73 {
74  friend class FloatingWindow;
75  friend class ImplTBDragMgr;
76 
77 public:
78  using ImplToolItems = std::vector<ImplToolItem>;
79 
80  virtual FactoryFunction GetUITestFactory() const override;
81 
82  void SetCurItemId( sal_uInt16 CurID ) { mnCurItemId=CurID; }
83 
84  static constexpr auto APPEND
85  = std::numeric_limits<ImplToolItems::size_type>::max();
86 
87  static constexpr auto ITEM_NOTFOUND
88  = std::numeric_limits<ImplToolItems::size_type>::max();
89 
90 private:
91  struct ImplToolSize
92  {
95  ImplToolItems::size_type mnLines;
96  };
97 
98  std::unique_ptr<ImplToolBoxPrivateData> mpData;
99  std::vector<ImplToolSize> maFloatSizes;
100  std::unique_ptr<Idle> mpIdle;
107  tools::Long mnMaxItemWidth; // max item width
108  tools::Long mnMaxItemHeight; // max item height (for standard items)
109  tools::Long mnWinHeight; // max window height (for window items)
110  tools::Long mnLeftBorder; // inner border
117  sal_uInt16 mnLastFocusItemId;
118  sal_uInt16 mnHighItemId;
119  sal_uInt16 mnCurItemId;
120  sal_uInt16 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  mbImagesMirrored:1,
144  mbLineSpacing:1,
145  mbIsArranged:1;
163 
164 public:
165  using Window::ImplInit;
166 private:
167  SAL_DLLPRIVATE void InvalidateItem(ImplToolItems::size_type nPosition);
168  SAL_DLLPRIVATE void InvalidateSpin(bool bInvalidateUpper = true,
169  bool bInvalidateLower = true);
170  SAL_DLLPRIVATE void InvalidateMenuButton();
171 
172  SAL_DLLPRIVATE void ImplInitToolBoxData();
173  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
175  SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
176  SAL_DLLPRIVATE ImplToolItem* ImplGetItem( sal_uInt16 nId ) const;
177  SAL_DLLPRIVATE bool ImplCalcItem();
178  SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcBreaks( tools::Long nWidth, tools::Long* pMaxLineWidth, bool bCalcHorz ) const;
179  SAL_DLLPRIVATE void ImplFormat( bool bResize = false );
180  SAL_DLLPRIVATE void ImplDrawSpin(vcl::RenderContext& rRenderContext);
181  SAL_DLLPRIVATE void ImplDrawSeparator(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, const tools::Rectangle& rRect);
182  SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight );
183  using Window::ImplInvalidate;
184  SAL_DLLPRIVATE void ImplInvalidate( bool bNewCalc = false, bool bFullPaint = false );
185  SAL_DLLPRIVATE void ImplUpdateItem( ImplToolItems::size_type nIndex = ITEM_NOTFOUND );
186  SAL_DLLPRIVATE bool ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat = false );
187  SAL_DLLPRIVATE bool ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel = false );
188  SAL_DLLPRIVATE void ImplChangeHighlight( ImplToolItem const * pItem, bool bNoGrabFocus = false );
189  SAL_DLLPRIVATE bool ImplChangeHighlightUpDn( bool bUp, bool bNoCycle = false );
190  SAL_DLLPRIVATE ImplToolItems::size_type ImplGetItemLine( ImplToolItem const * pCurrentItem );
191  SAL_DLLPRIVATE ImplToolItem* ImplGetFirstValidItem( ImplToolItems::size_type nLine );
192  SAL_DLLPRIVATE bool ImplOpenItem( vcl::KeyCode aKeyCode );
193  SAL_DLLPRIVATE bool ImplActivateItem( vcl::KeyCode aKeyCode );
194  SAL_DLLPRIVATE void ImplShowFocus();
195  SAL_DLLPRIVATE void ImplHideFocus();
196  SAL_DLLPRIVATE void ImplUpdateInputEnable();
197  SAL_DLLPRIVATE void ImplFillLayoutData();
198  SAL_DLLPRIVATE bool ImplHasClippedItems();
199  SAL_DLLPRIVATE Point ImplGetPopupPosition( const tools::Rectangle& rRect ) const;
200  SAL_DLLPRIVATE bool ImplIsFloatingMode() const;
201  SAL_DLLPRIVATE bool ImplIsInPopupMode() const;
202  SAL_DLLPRIVATE const OUString& ImplGetHelpText( sal_uInt16 nItemId ) const;
203  SAL_DLLPRIVATE Size ImplGetOptimalFloatingSize();
204  SAL_DLLPRIVATE bool ImplHasExternalMenubutton();
205  SAL_DLLPRIVATE void ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem const * pItem );
206 
207  DECL_DLLPRIVATE_LINK( ImplUpdateHdl, Timer*, void );
208  DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent&, void );
209  DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl, Timer*, void );
210 
211  ToolBox (const ToolBox &) = delete;
212  ToolBox& operator= (const ToolBox &) = delete;
213 
214 public:
215  SAL_DLLPRIVATE void ImplFloatControl( bool bStart, FloatingWindow* pWindow );
216 
217  SAL_DLLPRIVATE int ImplGetDragWidth() const;
218  static SAL_DLLPRIVATE int ImplGetDragWidth( const vcl::RenderContext& rRenderContext,
219  bool bHorz );
220  SAL_DLLPRIVATE void ImplUpdateDragArea() const;
221  SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, tools::Long& rLeft, tools::Long& rTop,
222  tools::Long& rRight, tools::Long& rBottom ) const;
223  SAL_DLLPRIVATE void ImplCheckUpdate();
224  static SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext,
225  const tools::Rectangle &aDragArea, int nDragWidth,
226  WindowAlign eAlign, bool bHorz);
227 
228  SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext);
229  SAL_DLLPRIVATE void ImplDrawGradientBackground(vcl::RenderContext& rRenderContext);
230  SAL_DLLPRIVATE bool ImplDrawNativeBackground(vcl::RenderContext& rRenderContext);
231  SAL_DLLPRIVATE void ImplDrawTransparentBackground(const vcl::Region &rRegion);
232  SAL_DLLPRIVATE static void ImplDrawConstantBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion, bool bIsInPopupMode);
233  SAL_DLLPRIVATE void ImplDrawBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect);
234 
235  SAL_DLLPRIVATE void ImplErase(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, bool bHighlight, bool bHasOpenPopup = false );
236 
237  SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext);
238  SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem() const;
239  SAL_DLLPRIVATE Size ImplCalcSize( ImplToolItems::size_type nCalcLines, sal_uInt16 nCalcMode = 0 );
240  SAL_DLLPRIVATE void ImplCalcFloatSizes();
241  SAL_DLLPRIVATE Size ImplCalcFloatSize( ImplToolItems::size_type& rLines );
242  SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( Size& rMinSize, Size& rMaxSize );
243  SAL_DLLPRIVATE void ImplSetMinMaxFloatSize();
244  SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcLines( tools::Long nToolSize ) const;
245  SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( const Point& rPos ) const;
246  SAL_DLLPRIVATE void ImplLineSizing( const Point& rPos, tools::Rectangle& rRect, sal_uInt16 nLineMode );
247  SAL_DLLPRIVATE static ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList );
248  SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
249  SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
250  SAL_DLLPRIVATE ImplToolItems::size_type ImplCountLineBreaks() const;
251  SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData.get(); }
252 
253  SAL_DLLPRIVATE void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&);
254  SAL_DLLPRIVATE void ApplyForegroundSettings(vcl::RenderContext&, const StyleSettings&);
255 
256 protected:
257  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
258 
259 public:
260  ToolBox(vcl::Window* pParent, WinBits nStyle = 0);
261  ToolBox(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
262  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
263  virtual ~ToolBox() override;
264  virtual void dispose() override;
265 
266  virtual void Click();
267  void DoubleClick();
268  virtual void Activate() override;
269  virtual void Deactivate() override;
270  void Highlight();
271  virtual void Select();
272 
273  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
274  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
275  virtual void MouseMove( const MouseEvent& rMEvt ) override;
276  virtual void Tracking( const TrackingEvent& rTEvt ) override;
277  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
278  virtual void Resize() override;
279  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
280  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
281  virtual void Command( const CommandEvent& rCEvt ) override;
282  virtual void StateChanged( StateChangedType nType ) override;
283  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
284 
285  virtual void LoseFocus() override;
286  virtual void KeyInput( const KeyEvent& rKEvt ) override;
287 
288  virtual void ToggleFloatingMode() override;
289  virtual void StartDocking() override;
290  virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override;
291  virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override;
292  virtual void Resizing( Size& rSize ) override;
293  virtual Size GetOptimalSize() const override;
294  virtual void doDeferredInit(WinBits nBits) override;
295  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
296 
298  virtual void InsertItem( const OUString& rCommand,
299  const css::uno::Reference<css::frame::XFrame>& rFrame,
300  ToolBoxItemBits nBits,
301  const Size& rRequestedSize,
302  ImplToolItems::size_type nPos = APPEND );
303  void InsertItem( sal_uInt16 nItemId, const Image& rImage,
305  ImplToolItems::size_type nPos = APPEND );
306  void InsertItem( sal_uInt16 nItemId, const Image& rImage,
307  const OUString& rText,
309  ImplToolItems::size_type nPos = APPEND );
310  void InsertItem( sal_uInt16 nItemId, const OUString& rText,
312  ImplToolItems::size_type nPos = APPEND );
313  void InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow,
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, sal_uInt16 nItemId );
321  void Clear();
322 
323  void SetButtonType( ButtonType eNewType );
324  ButtonType GetButtonType() const { return meButtonType; }
325 
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;
330 
331  void SetAlign( WindowAlign eNewAlign = WindowAlign::Top );
332  WindowAlign GetAlign() const { return meAlign; }
333  bool IsHorizontal() const { return mbHorz; }
334 
335  void SetLineCount( ImplToolItems::size_type nNewLines );
336  void ShowLine( bool bNext );
337 
338  ImplToolItems::size_type GetItemCount() const;
339  ToolBoxItemType GetItemType( ImplToolItems::size_type nPos ) const;
340  ImplToolItems::size_type GetItemPos( sal_uInt16 nItemId ) const;
341  ImplToolItems::size_type GetItemPos( const Point& rPos ) const;
342  sal_uInt16 GetItemId( ImplToolItems::size_type nPos ) const;
343  sal_uInt16 GetItemId( const Point& rPos ) const;
345  sal_uInt16 GetItemId( const OUString& rCommand ) const;
346  tools::Rectangle GetItemRect( sal_uInt16 nItemId );
347  tools::Rectangle GetItemPosRect( ImplToolItems::size_type nPos );
348  tools::Rectangle const & GetOverflowRect() const;
349 
351  Size GetItemContentSize( sal_uInt16 nItemId );
352 
353  sal_uInt16 GetCurItemId() const { return mnCurItemId; }
354  sal_uInt16 GetDownItemId() const { return mnDownItemId; }
355  sal_uInt16 GetModifier() const { return mnMouseModifier; }
356 
357  void SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits );
358  ToolBoxItemBits GetItemBits( sal_uInt16 nItemId ) const;
359 
360  void SetItemExpand( sal_uInt16 nItemId, bool bExpand );
361  // e.g. a label used as an itemwindow
362  void SetItemWindowNonInteractive(sal_uInt16 nItemId, bool bNonInteractive);
363 
364 
365  void SetItemData( sal_uInt16 nItemId, void* pNewData );
366  void* GetItemData( sal_uInt16 nItemId ) const;
367  void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
368  Image GetItemImage( sal_uInt16 nItemId ) const;
369  void SetItemImageAngle( sal_uInt16 nItemId, Degree10 nAngle10 );
370  void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror );
371  void SetItemText( sal_uInt16 nItemId, const OUString& rText );
372  const OUString& GetItemText( sal_uInt16 nItemId ) const;
373  void SetItemWindow( sal_uInt16 nItemId, vcl::Window* pNewWindow );
374  vcl::Window* GetItemWindow( sal_uInt16 nItemId ) const;
375  sal_uInt16 GetHighlightItemId() const { return mnHighItemId; }
376 
377  void EndSelection();
378 
379  void SetItemDown( sal_uInt16 nItemId, bool bDown );
380 
381  void SetItemState( sal_uInt16 nItemId, TriState eState );
382  TriState GetItemState( sal_uInt16 nItemId ) const;
383 
384  void CheckItem( sal_uInt16 nItemId, bool bCheck = true );
385  bool IsItemChecked( sal_uInt16 nItemId ) const;
386 
387  void EnableItem( sal_uInt16 nItemId, bool bEnable = true );
388  bool IsItemEnabled( sal_uInt16 nItemId ) const;
389 
390  void TriggerItem( sal_uInt16 nItemId );
391 
393  void ShowItem(sal_uInt16 nItemId, bool bVisible = true);
394 
396  void HideItem(sal_uInt16 nItemId) { ShowItem( nItemId, false ); }
397 
398  bool IsItemClipped( sal_uInt16 nItemId ) const;
399  bool IsItemVisible( sal_uInt16 nItemId ) const;
400  bool IsItemReallyVisible( sal_uInt16 nItemId ) const;
401 
402  void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand );
403  OUString GetItemCommand( sal_uInt16 nItemId ) const;
404 
405  using Window::SetQuickHelpText;
406  void SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText );
407  using Window::GetQuickHelpText;
408  OUString GetQuickHelpText( sal_uInt16 nItemId ) const;
409 
410  void SetHelpText( sal_uInt16 nItemId, const OUString& rText );
411  const OUString& GetHelpText( sal_uInt16 nItemId ) const;
412 
413  void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId );
414 
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();
427 
428  // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button)
429  Size CalcMinimumWindowSizePixel();
430 
431  ImplToolItems::size_type GetFloatingLines() const;
432 
433  void SetStyle( WinBits nNewStyle );
434  WinBits GetStyle() const { return mnWinStyle; }
435 
436  // enable/disable undocking
437  void Lock( bool bLock );
438  // read configuration to determine locking behaviour
439  static bool AlwaysLocked();
440 
441  void EnableCustomize( bool bEnable = true );
442  bool IsCustomize() const { return mbCustomize; }
443 
448 
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; }
458 
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 );
472 
473  // open custommenu
474  void ExecuteCustomMenu( const tools::Rectangle& rRect = tools::Rectangle() );
475 
476  // allow Click Handler to distinguish between mouse and key input
477  bool IsKeyEvent() const { return mbIsKeyEvent; }
478 
479  // allows framework to set/query the planned popupmode
480  bool WillUsePopupMode() const;
481  void WillUsePopupMode( bool b);
482 
483  // accessibility helpers
484 
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( sal_uInt16 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, sal_uInt16& rItemID );
494 
495  static Size GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize);
496  Size GetDefaultImageSize() const;
497  void ChangeHighlight( ImplToolItems::size_type nPos );
498 
499 
500  void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
501  void statusChanged(const css::frame::FeatureStateEvent& rEvent);
502 
503  void SetToolBoxTextPosition( ToolBoxTextPosition ePosition );
504 
505  void SetLineSpacing(bool b) { mbLineSpacing = b; }
506 
507  virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
508 };
509 
510 inline void ToolBox::CheckItem( sal_uInt16 nItemId, bool bCheck )
511 {
512  SetItemState( nItemId, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE );
513 }
514 
515 inline bool ToolBox::IsItemChecked( sal_uInt16 nItemId ) const
516 {
517  return (GetItemState( nItemId ) == TRISTATE_TRUE);
518 }
519 
521 {
522  return CalcWindowSizePixel( mnLines );
523 }
524 
525 inline ToolBox::ImplToolItems::size_type ToolBox::GetFloatingLines() const
526 {
527  return mnFloatLines;
528 }
529 
530 #endif // INCLUDED_VCL_TOOLBOX_HXX
531 
532 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
WindowAlign
tools::Long mnTopBorder
Definition: toolbox.hxx:111
static void ImplCalcBorder(WindowAlign eAlign, tools::Long &rLeft, tools::Long &rTop, tools::Long &rRight, tools::Long &rBottom)
Definition: splitwin.cxx:142
void SetDoubleClickHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:450
ToolBoxLayoutMode
Definition: toolbox.hxx:60
PointerStyle meLastStyle
Definition: toolbox.hxx:149
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3949
ImplToolItems::size_type mnDockLines
Definition: toolbox.hxx:127
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: dockwin.cxx:405
Link< ToolBox *, void > maMenuButtonHdl
Definition: toolbox.hxx:158
ToolBoxButtonSize
Definition: vclenum.hxx:297
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
Link< ToolBox *, void > maActivateHdl
Definition: toolbox.hxx:155
ToolBoxMenuType
Definition: toolbox.hxx:50
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
ImplToolItems::size_type mnCurLines
Definition: toolbox.hxx:124
ToolBoxLayoutMode meLayoutMode
Definition: toolbox.hxx:151
const OUString & GetHelpText() const
Definition: window.cxx:3092
ImplToolItems::size_type mnFloatLines
Definition: toolbox.hxx:126
const OUString & GetQuickHelpText() const
Definition: window2.cxx:1232
ImplToolItems::size_type mnVisLines
Definition: toolbox.hxx:125
SAL_DLLPRIVATE ImplToolBoxPrivateData * ImplGetToolBoxPrivateData() const
Definition: toolbox.hxx:251
tools::Long mnWinHeight
Definition: toolbox.hxx:109
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
VclPtr< FloatingWindow > mpFloatWin
Definition: toolbox.hxx:104
Link< ToolBox *, void > maSelectHdl
Definition: toolbox.hxx:157
sal_uInt16 mnMouseModifier
Definition: toolbox.hxx:128
WindowAlign meAlign
Definition: toolbox.hxx:146
std::unique_ptr< ImplToolBoxPrivateData > mpData
Definition: toolbox.hxx:98
ImplToolItems::size_type GetFloatingLines() const
Definition: toolbox.hxx:525
virtual void Deactivate()
Definition: window.cxx:1838
void SetHelpId(const OString &)
Definition: window2.cxx:823
tools::Long mnWidth
Definition: toolbox.hxx:93
void SetStateChangedHdl(const Link< StateChangedType const *, void > &aLink)
Definition: toolbox.hxx:455
ToolBoxTextPosition meTextPosition
Definition: toolbox.hxx:152
bool IsKeyEvent() const
Definition: toolbox.hxx:477
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:421
WinBits GetStyle() const
Definition: toolbox.hxx:434
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1226
TRISTATE_TRUE
ButtonType
Definition: vclenum.hxx:71
ToolBoxItemType
Definition: vclenum.hxx:69
sal_uInt16 GetCurItemId() const
Definition: toolbox.hxx:353
tools::Long mnLeftBorder
Definition: toolbox.hxx:110
StateChangedType
Definition: window.hxx:317
std::vector< ImplToolSize > maFloatSizes
Definition: toolbox.hxx:99
Size CalcWindowSizePixel()
Definition: toolbox.hxx:520
sal_Int64 WinBits
tools::Long mnBottomBorder
Definition: toolbox.hxx:113
Link< DataChangedEvent const *, void > maDataChangedHandler
Definition: toolbox.hxx:160
bool IsItemChecked(sal_uInt16 nItemId) const
Definition: toolbox.hxx:515
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3351
SAL_DLLPRIVATE void ImplInvalidate(const vcl::Region *rRegion, InvalidateFlags nFlags)
Definition: paint.cxx:777
virtual Size GetOptimalSize() const override
Definition: dockwin.cxx:1015
sal_uInt16 GetHighlightItemId() const
Definition: toolbox.hxx:375
Link< ToolBox *, void > maDeactivateHdl
Definition: toolbox.hxx:156
virtual void StartDocking()
Definition: dockwin.cxx:578
Link< ToolBox *, void > maClickHdl
Definition: toolbox.hxx:153
void SetItemState(sal_uInt16 nItemId, TriState eState)
Definition: toolbox2.cxx:1162
bool IsHorizontal() const
Definition: toolbox.hxx:333
sal_uInt16 mnCurItemId
Definition: toolbox.hxx:119
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: dockwin.cxx:1032
void SetActivateHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:452
tools::Long mnHeight
Definition: toolbox.hxx:94
void SetHelpText(const OUString &rHelpText)
Definition: window2.cxx:1220
rtl::Reference< VclStatusListener< ToolBox > > mpStatusListener
StatusListener.
Definition: toolbox.hxx:162
virtual bool Docking(const Point &rPos, tools::Rectangle &rRect)
Definition: dockwin.cxx:583
virtual OUString GetDisplayText() const
Definition: window.cxx:3063
tools::Long mnMaxItemWidth
Definition: toolbox.hxx:107
virtual void EndDocking(const tools::Rectangle &rRect, bool bFloatMode)
Definition: dockwin.cxx:588
ImplToolItems::size_type mnLines
Definition: toolbox.hxx:95
const OString & GetHelpId() const
Definition: window2.cxx:828
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:390
bool IsCustomize() const
Definition: toolbox.hxx:442
APPEND
ImplToolItems::size_type mnCurPos
Definition: toolbox.hxx:121
ImageType
Definition: vclenum.hxx:326
Link< StateChangedType const *, void > maStateChangedHandler
Definition: toolbox.hxx:159
tools::Rectangle maLowerRect
Definition: toolbox.hxx:102
sal_uInt16 GetDownItemId() const
Definition: toolbox.hxx:354
void SetDataChangedHdl(const Link< DataChangedEvent const *, void > &aLink)
Definition: toolbox.hxx:456
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3859
TRISTATE_FALSE
ImplToolItems::size_type mnCurLine
Definition: toolbox.hxx:123
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
void SetDeactivateHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:453
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
Definition: toolbox.hxx:510
virtual void Resize()
Definition: window.cxx:1834
ToolBoxTextPosition
Definition: toolbox.hxx:69
TriState GetItemState(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:1222
sal_uInt16 mnDownItemId
Definition: toolbox.hxx:120
void SetSelectHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:454
virtual void LoseFocus()
Definition: window.cxx:1854
void SetClickHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:449
DECL_DLLPRIVATE_LINK(ImplHandleLayoutTimerHdl, Timer *, void)
void SetStyle(WinBits nStyle)
Definition: window.cxx:1961
virtual void StateChanged(StateChangedType nType) override
Definition: dockwin.cxx:657
constexpr sal_uInt16 TOOLBOX_MENUITEM_START
Definition: toolbox.hxx:47
DockingWindow & operator=(const DockingWindow &)=delete
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dockwin.cxx:520
void SetCurItemId(sal_uInt16 CurID)
Definition: toolbox.hxx:82
void SetLineSpacing(bool b)
Definition: toolbox.hxx:505
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1804
Degree10 mnImagesRotationAngle
Definition: toolbox.hxx:116
sal_uInt16 GetModifier() const
Definition: toolbox.hxx:355
SAL_DLLPRIVATE void ImplInitSettings()
Definition: dockwin.cxx:327
void SetMenuButtonHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:457
std::unique_ptr< Idle > mpIdle
Definition: toolbox.hxx:100
WindowAlign GetAlign() const
Definition: toolbox.hxx:332
tools::Long mnDY
Definition: toolbox.hxx:106
virtual void doDeferredInit(WinBits nBits)
Definition: dockwin.cxx:360
Definition: image.hxx:39
ButtonType meButtonType
Definition: toolbox.hxx:148
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1021
std::vector< ImplToolItem > ImplToolItems
Definition: toolbox.hxx:78
PointerStyle
Definition: ptrstyle.hxx:25
tools::Long mnDX
Definition: toolbox.hxx:105
virtual void Activate()
Definition: window.cxx:1836
tools::Rectangle maUpperRect
Definition: toolbox.hxx:101
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:408
sal_uInt16 mnHighItemId
Definition: toolbox.hxx:118
Link< ToolBox *, void > maDoubleClickHdl
Definition: toolbox.hxx:154
Definition: timer.hxx:26
void HideItem(sal_uInt16 nItemId)
Convenience method to hide items (via ShowItem).
Definition: toolbox.hxx:396
tools::Long mnLastResizeDY
Definition: toolbox.hxx:114
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1922
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: dockwin.cxx:681
TriState
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: dockwin.cxx:312
ButtonType GetButtonType() const
Definition: toolbox.hxx:324
virtual void Resizing(Size &rSize)
Definition: dockwin.cxx:638
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1868
WinBits mnWinStyle
Definition: toolbox.hxx:150
tools::Long mnMaxItemHeight
Definition: toolbox.hxx:108
virtual void ToggleFloatingMode()
Definition: dockwin.cxx:634
tools::Rectangle maPaintRect
Definition: toolbox.hxx:103
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
ImplToolItems::size_type mnLines
Definition: toolbox.hxx:122
WindowAlign meDockAlign
Definition: toolbox.hxx:147
tools::Long mnRightBorder
Definition: toolbox.hxx:112
tools::Long mnActivateCount
Definition: toolbox.hxx:115
sal_uInt16 mnLastFocusItemId
Definition: toolbox.hxx:117