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