xref: /aoo41x/main/vcl/inc/toolbox.h (revision 25d782d7)
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 
52 class Window;
53 
54 // ----------------
55 // - ImplToolItem -
56 // ----------------
57 
58 struct ImplToolItem
59 {
60 	Window* 			mpWindow;
61 	void*				mpUserData;
62 	Image				maImage;
63 	Image				maHighImage;
64     long				mnImageAngle;
65     bool				mbMirrorMode;
66 	XubString			maText;
67 	XubString			maQuickHelpText;
68 	XubString			maHelpText;
69 	String				maCommandStr;
70 	rtl::OString		maHelpId;
71 	Rectangle			maRect;
72 	Rectangle			maCalcRect;
73     // the overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]
74     Size                maItemSize;
75 	long				mnSepSize;
76     long                mnDropDownArrowWidth;
77 	ToolBoxItemType 	meType;
78 	ToolBoxItemBits 	mnBits;
79 	TriState			meState;
80 	sal_uInt16				mnId;
81 	sal_Bool				mbEnabled:1,
82 						mbVisible:1,
83 						mbEmptyBtn:1,
84 						mbShowWindow:1,
85 						mbBreak:1,
86                         mbVisibleText:1;    // indicates if text will definitely be drawn, influences dropdown pos
87 
88 						ImplToolItem();
89 						ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
90 									  ToolBoxItemBits nItemBits );
91 						ImplToolItem( sal_uInt16 nItemId, const XubString& rTxt,
92 									  ToolBoxItemBits nItemBits );
93 						ImplToolItem( sal_uInt16 nItemId, const Image& rImage,
94 									  const XubString& rTxt,
95 									  ToolBoxItemBits nItemBits );
96 						~ImplToolItem();
97 
98     ImplToolItem( const ImplToolItem& );
99     ImplToolItem& operator=(const ImplToolItem&);
100 
101     // returns the size of a item, taking toolbox orientation into account
102     // the default size is the precomputed size for standard items
103     // ie those that are just ordinary buttons (no windows or text etc.)
104     // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons
105     Size                GetSize( sal_Bool bHorz, sal_Bool bCheckMaxWidth, long maxWidth, const Size& rDefaultSize );
106 
107     // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style
108     void DetermineButtonDrawStyle( ButtonType eButtonType, sal_Bool& rbImage, sal_Bool& rbText ) const;
109 
110     // returns the rectangle which contains the drop down arrow
111     // or an empty rect if there is none
112     // bHorz denotes the toolbox alignment
113     Rectangle   GetDropDownRect( sal_Bool bHorz ) const;
114 
115     // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars
116     sal_Bool IsClipped() const;
117 };
118 
119 namespace vcl
120 {
121 
122 struct ToolBoxLayoutData : public ControlLayoutData
123 {
124     std::vector< sal_uInt16 >				m_aLineItemIds;
125     std::vector< sal_uInt16 >				m_aLineItemPositions;
126 };
127 
128 
129 } /* namespace vcl */
130 
131 
132 struct ImplToolBoxPrivateData
133 {
134     vcl::ToolBoxLayoutData*			m_pLayoutData;
135     std::vector< ImplToolItem >		m_aItems;
136 
137     ImplToolBoxPrivateData();
138     ~ImplToolBoxPrivateData();
139 
140     void ImplClearLayoutData() { delete m_pLayoutData; m_pLayoutData = NULL; }
141 
142     // called when dropdown items are clicked
143     Link    maDropdownClickHdl;
144     Timer	maDropdownTimer; // for opening dropdown items on "long click"
145 
146     // large or small buttons ?
147     ToolBoxButtonSize   meButtonSize;
148 
149     // the optional custom menu
150     PopupMenu*  mpMenu;
151     sal_uInt16      maMenuType;
152     sal_uIntPtr       mnEventId;
153 
154     // called when menu button is clicked and before the popup menu is executed
155     Link        maMenuButtonHdl;
156 
157     // a dummy item representing the custom menu button
158     ImplToolItem   maMenubuttonItem;
159     long           mnMenuButtonWidth;
160 
161     Wallpaper   maDisplayBackground;
162 
163     // support for highcontrast
164     vcl::IImageListProvider* mpImageListProvider;
165     vcl::ImageListType       meImageListType;
166 
167     sal_Bool    mbIsLocked:1,           // keeps last lock state from ImplDockingWindowWrapper
168             mbAssumeDocked:1,       // only used during calculations to override current floating/popup mode
169             mbAssumeFloating:1,
170             mbAssumePopupMode:1,
171             mbKeyInputDisabled:1,	// no KEY input if all items disabled, closing/docking will be allowed though
172             mbIsPaintLocked:1,		// don't allow paints
173             mbMenubuttonSelected:1, // menu button is highlighted
174             mbPageScroll:1,         // determines if we scroll a page at a time
175             mbNativeButtons:1,      // system supports native toolbar buttons
176             mbWillUsePopupMode:1,   // this toolbox will be opened in popup mode
177             mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input
178 };
179 
180 
181 #endif	// _SV_TOOLBOX_H
182