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