LibreOffice Module vcl (master)  1
toolbox.h
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_INC_TOOLBOX_H
21 #define INCLUDED_VCL_INC_TOOLBOX_H
22 
23 #include <vcl/toolbox.hxx>
24 #include <vcl/controllayout.hxx>
25 
26 #include <vector>
27 
28 #define TB_DROPDOWNARROWWIDTH 11
29 
30 #define TB_MENUBUTTON_SIZE 12
31 #define TB_MENUBUTTON_OFFSET 2
32 
33 namespace vcl { class Window; }
34 
36 {
37  VclPtr<vcl::Window> mpWindow; //don't dispose mpWindow - we get copied around
38  void* mpUserData;
43  OUString maText;
44  OUString maQuickHelpText;
45  OUString maHelpText;
46  OUString maCommandStr;
47  OString maHelpId;
54  long mnSepSize;
61  sal_uInt16 mnId;
62  bool mbEnabled:1,
63  mbVisible:1,
64  mbEmptyBtn:1,
65  mbShowWindow:1,
66  mbBreak:1,
67  mbVisibleText:1, // indicates if text will definitely be drawn, influences dropdown pos
68  mbExpand:1;
69 
70  ImplToolItem();
71  ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
72  ToolBoxItemBits nItemBits );
73  ImplToolItem( sal_uInt16 nItemId, const OUString& rTxt,
74  ToolBoxItemBits nItemBits );
75  ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
76  const OUString& rTxt,
77  ToolBoxItemBits nItemBits );
78 
79  // returns the size of an item, taking toolbox orientation into account
80  // the default size is the precomputed size for standard items
81  // ie those that are just ordinary buttons (no windows or text etc.)
82  // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons
83  Size GetSize( bool bHorz, bool bCheckMaxWidth, long maxWidth, const Size& rDefaultSize );
84 
85  // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style
86  void DetermineButtonDrawStyle( ButtonType eButtonType, bool& rbImage, bool& rbText ) const;
87 
88  // returns the rectangle which contains the drop down arrow
89  // or an empty rect if there is none
90  // bHorz denotes the toolbox alignment
91  tools::Rectangle GetDropDownRect( bool bHorz ) const;
92 
93  // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars
94  bool IsClipped() const;
95 
96  // returns sal_True if the toolbar item is currently hidden i.e. they are unchecked in the toolbar Customize menu
97  bool IsItemHidden() const;
98 
99 private:
100  void init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits, bool bEmptyBtn);
101 };
102 
103 namespace vcl
104 {
105 
107 {
108  std::vector< sal_uInt16 > m_aLineItemIds;
109 };
110 
111 } /* namespace vcl */
112 
114 {
115  std::unique_ptr<vcl::ToolBoxLayoutData> m_pLayoutData;
117 
120 
121  void ImplClearLayoutData() { m_pLayoutData.reset(); }
122 
123  // called when dropdown items are clicked
125  Timer maDropdownTimer; // for opening dropdown items on "long click"
126 
127  // large or small buttons ?
129 
130  // the optional custom menu
133 
134  // called when menu button is clicked and before the popup menu is executed
136 
137  // a dummy item representing the custom menu button
140 
142 
143  bool mbIsLocked:1, // keeps last lock state from ImplDockingWindowWrapper
144  mbAssumeDocked:1, // only used during calculations to override current floating/popup mode
147  mbKeyInputDisabled:1, // no KEY input if all items disabled, closing/docking will be allowed though
148  mbIsPaintLocked:1, // don't allow paints
149  mbMenubuttonSelected:1, // menu button is highlighted
150  mbMenubuttonWasLastSelected:1, // menu button was highlighted when focus was lost
151  mbNativeButtons:1, // system supports native toolbar buttons
152  mbWillUsePopupMode:1, // this toolbox will be opened in popup mode
153  mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input
154 };
155 
156 #endif // INCLUDED_VCL_INC_TOOLBOX_H
157 
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void DetermineButtonDrawStyle(ButtonType eButtonType, bool &rbImage, bool &rbText) const
Definition: toolbox2.cxx:183
OUString maQuickHelpText
Definition: toolbox.h:44
OString maHelpId
Definition: toolbox.h:47
ToolBoxButtonSize
Definition: vclenum.hxx:293
long mnImageAngle
Definition: toolbox.h:41
bool mbMirrorMode
Definition: toolbox.h:42
ToolBoxButtonSize meButtonSize
Definition: toolbox.h:128
ToolBoxMenuType
Definition: toolbox.hxx:51
Wallpaper maDisplayBackground
Definition: toolbox.h:141
Link< ToolBox *, void > maMenuButtonHdl
Definition: toolbox.h:135
Link< ToolBox *, void > maDropdownClickHdl
Definition: toolbox.h:124
void * mpUserData
Definition: toolbox.h:38
VclPtr< PopupMenu > mpMenu
Definition: toolbox.h:131
ButtonType
Definition: vclenum.hxx:71
ToolBoxItemType
Definition: vclenum.hxx:69
ToolBoxMenuType maMenuType
Definition: toolbox.h:132
Size GetSize(bool bHorz, bool bCheckMaxWidth, long maxWidth, const Size &rDefaultSize)
Definition: toolbox2.cxx:125
bool mbEmptyBtn
Definition: toolbox.h:62
tools::Rectangle GetDropDownRect(bool bHorz) const
Definition: toolbox2.cxx:235
void ImplClearLayoutData()
Definition: toolbox.h:121
long mnDropDownArrowWidth
Definition: toolbox.h:55
ToolBoxItemBits
Definition: vclenum.hxx:50
bool mbVisible
Definition: toolbox.h:62
bool mbExpand
Definition: toolbox.h:62
ToolBox::ImplToolItems m_aItems
Definition: toolbox.h:116
bool mbEnabled
Definition: toolbox.h:62
OUString maCommandStr
Definition: toolbox.h:46
bool IsClipped() const
Definition: toolbox2.cxx:251
Image maImage
Definition: toolbox.h:39
VclPtr< vcl::Window > mpWindow
Definition: toolbox.h:37
std::unique_ptr< vcl::ToolBoxLayoutData > m_pLayoutData
Definition: toolbox.h:115
Size maItemSize
The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]...
Definition: toolbox.h:53
ToolBoxItemBits mnBits
Definition: toolbox.h:59
Size maContentSize
Size of the content (bitmap or text, without dropdown) that we have in the item.
Definition: toolbox.h:57
tools::Rectangle maRect
Definition: toolbox.h:48
bool mbVisibleText
Definition: toolbox.h:62
tools::Rectangle maCalcRect
Definition: toolbox.h:49
Definition: image.hxx:40
OUString maHelpText
Definition: toolbox.h:45
std::vector< ImplToolItem > ImplToolItems
Definition: toolbox.hxx:79
long mnSepSize
Definition: toolbox.h:54
bool mbMenubuttonWasLastSelected
Definition: toolbox.h:143
sal_uInt16 mnId
Definition: toolbox.h:61
std::vector< sal_uInt16 > m_aLineItemIds
Definition: toolbox.h:108
bool mbShowWindow
Definition: toolbox.h:62
Definition: timer.hxx:26
ImplToolItem maMenubuttonItem
Definition: toolbox.h:138
TriState
Image maOverlayImage
Definition: toolbox.h:40
TriState meState
Definition: toolbox.h:60
OUString maText
Definition: toolbox.h:43
bool IsItemHidden() const
Definition: toolbox2.cxx:256
Size maMinimalItemSize
Widget layout may request size; set it as the minimal size (like, the item will always have at least ...
Definition: toolbox.h:51
bool mbBreak
Definition: toolbox.h:62
void init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits, bool bEmptyBtn)
Definition: toolbox2.cxx:76
ToolBoxItemType meType
Definition: toolbox.h:58