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