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