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