xref: /trunk/main/vcl/inc/toolbox.h (revision 2123d757)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_TOOLBOX_H
25 #define _SV_TOOLBOX_H
26 
27 #include <tools/gen.hxx>
28 #include <tools/string.hxx>
29 #include <vcl/sv.h>
30 #include <vcl/image.hxx>
31 #include <vcl/toolbox.hxx>
32 #include <vcl/controllayout.hxx>
33 #include <vcl/ImageListProvider.hxx>
34 
35 #include <vector>
36 
37 #define TB_DROPDOWNARROWWIDTH   11
38 
39 #define TB_MENUBUTTON_SIZE      12
40 #define TB_MENUBUTTON_OFFSET    2
41 
42 #define TB_SMALLIMAGESIZE       16
43 
44 #define TB_LARGEIMAGESIZE            26
45 #define TB_LARGEIMAGESIZE_INDUSTRIAL 24
46 
47 class Window;
48 
49 // ----------------
50 // - ImplToolItem -
51 // ----------------
52 
53 struct ImplToolItem
54 {
55 	Window* 			mpWindow;
56 	void*				mpUserData;
57 	Image				maImage;
58 	Image				maHighImage;
59     long				mnImageAngle;
60     bool				mbMirrorMode;
61 	XubString			maText;
62 	XubString			maQuickHelpText;
63 	XubString			maHelpText;
64 	String				maCommandStr;
65 	rtl::OString		maHelpId;
66 	Rectangle			maRect;
67 	Rectangle			maCalcRect;
68     // the overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]
69     Size                maItemSize;
70 	long				mnSepSize;
71     long                mnDropDownArrowWidth;
72 	ToolBoxItemType 	meType;
73 	ToolBoxItemBits 	mnBits;
74 	TriState			meState;
75 	sal_uInt16				mnId;
76 	sal_Bool				mbEnabled:1,
77 						mbVisible:1,
78 						mbEmptyBtn:1,
79 						mbShowWindow:1,
80 						mbBreak:1,
81                         mbVisibleText:1;    // indicates if text will definitely be drawn, influences dropdown pos
82 
83 						ImplToolItem();
84 						ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
85 									  ToolBoxItemBits nItemBits );
86 						ImplToolItem( sal_uInt16 nItemId, const XubString& rTxt,
87 									  ToolBoxItemBits nItemBits );
88 						ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
89 									  const XubString& rTxt,
90 									  ToolBoxItemBits nItemBits );
91 						~ImplToolItem();
92 
93     ImplToolItem( const ImplToolItem& );
94     ImplToolItem& operator=(const ImplToolItem&);
95 
96     // returns the size of a item, taking toolbox orientation into account
97     // the default size is the precomputed size for standard items
98     // ie those that are just ordinary buttons (no windows or text etc.)
99     // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons
100     Size                GetSize( sal_Bool bHorz, sal_Bool bCheckMaxWidth, long maxWidth, const Size& rDefaultSize );
101 
102     // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style
103     void DetermineButtonDrawStyle( ButtonType eButtonType, sal_Bool& rbImage, sal_Bool& rbText ) const;
104 
105     // returns the rectangle which contains the drop down arrow
106     // or an empty rect if there is none
107     // bHorz denotes the toolbox alignment
108     Rectangle   GetDropDownRect( sal_Bool bHorz ) const;
109 
110     // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars
111     sal_Bool IsClipped() const;
112 };
113 
114 namespace vcl
115 {
116 
117 struct ToolBoxLayoutData : public ControlLayoutData
118 {
119     std::vector< sal_uInt16 >				m_aLineItemIds;
120     std::vector< sal_uInt16 >				m_aLineItemPositions;
121 };
122 
123 
124 } /* namespace vcl */
125 
126 
127 struct ImplToolBoxPrivateData
128 {
129     vcl::ToolBoxLayoutData*			m_pLayoutData;
130     std::vector< ImplToolItem >		m_aItems;
131 
132     ImplToolBoxPrivateData();
133     ~ImplToolBoxPrivateData();
134 
ImplClearLayoutDataImplToolBoxPrivateData135     void ImplClearLayoutData() { delete m_pLayoutData; m_pLayoutData = NULL; }
136 
137     // called when dropdown items are clicked
138     Link    maDropdownClickHdl;
139     Timer	maDropdownTimer; // for opening dropdown items on "long click"
140 
141     // large or small buttons ?
142     ToolBoxButtonSize   meButtonSize;
143 
144     // the optional custom menu
145     PopupMenu*  mpMenu;
146     sal_uInt16      maMenuType;
147     sal_uIntPtr       mnEventId;
148 
149     // called when menu button is clicked and before the popup menu is executed
150     Link        maMenuButtonHdl;
151 
152     // a dummy item representing the custom menu button
153     ImplToolItem   maMenubuttonItem;
154     long           mnMenuButtonWidth;
155 
156     Wallpaper   maDisplayBackground;
157 
158     // support for highcontrast
159     vcl::IImageListProvider* mpImageListProvider;
160     vcl::ImageListType       meImageListType;
161 
162     sal_Bool    mbIsLocked:1,           // keeps last lock state from ImplDockingWindowWrapper
163             mbAssumeDocked:1,       // only used during calculations to override current floating/popup mode
164             mbAssumeFloating:1,
165             mbAssumePopupMode:1,
166             mbKeyInputDisabled:1,	// no KEY input if all items disabled, closing/docking will be allowed though
167             mbIsPaintLocked:1,		// don't allow paints
168             mbMenubuttonSelected:1, // menu button is highlighted
169             mbPageScroll:1,         // determines if we scroll a page at a time
170             mbNativeButtons:1,      // system supports native toolbar buttons
171             mbWillUsePopupMode:1,   // this toolbox will be opened in popup mode
172             mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input
173 };
174 
175 
176 #endif	// _SV_TOOLBOX_H
177