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