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