/src/libreoffice/vcl/inc/widgetdraw/WidgetDefinition.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | */ |
10 | | |
11 | | #pragma once |
12 | | |
13 | | #include <vcl/dllapi.h> |
14 | | #include <memory> |
15 | | #include <rtl/ustring.hxx> |
16 | | #include <tools/color.hxx> |
17 | | #include <unordered_map> |
18 | | #include <vector> |
19 | | #include <cstddef> |
20 | | #include <o3tl/hash_combine.hxx> |
21 | | #include <vcl/salnativewidgets.hxx> |
22 | | |
23 | | namespace vcl |
24 | | { |
25 | | enum class WidgetDrawActionType |
26 | | { |
27 | | RECTANGLE, |
28 | | LINE, |
29 | | IMAGE, |
30 | | EXTERNAL |
31 | | }; |
32 | | |
33 | | class VCL_DLLPUBLIC WidgetDrawAction |
34 | | { |
35 | | public: |
36 | | WidgetDrawAction(WidgetDrawActionType aType) |
37 | 0 | : maType(aType) |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | WidgetDrawActionType maType; |
42 | | }; |
43 | | |
44 | | class VCL_DLLPUBLIC WidgetDrawActionShape : public WidgetDrawAction |
45 | | { |
46 | | public: |
47 | | WidgetDrawActionShape(WidgetDrawActionType aType) |
48 | 0 | : WidgetDrawAction(aType) |
49 | 0 | , mnStrokeWidth(-1) |
50 | 0 | { |
51 | 0 | } |
52 | | |
53 | | Color maStrokeColor; |
54 | | Color maFillColor; |
55 | | sal_Int32 mnStrokeWidth; |
56 | | }; |
57 | | |
58 | | class VCL_DLLPUBLIC WidgetDrawActionRectangle : public WidgetDrawActionShape |
59 | | { |
60 | | public: |
61 | | sal_Int32 mnRx; |
62 | | sal_Int32 mnRy; |
63 | | |
64 | | float mfX1; |
65 | | float mfY1; |
66 | | float mfX2; |
67 | | float mfY2; |
68 | | |
69 | | WidgetDrawActionRectangle() |
70 | 0 | : WidgetDrawActionShape(WidgetDrawActionType::RECTANGLE) |
71 | 0 | , mnRx(0) |
72 | 0 | , mnRy(0) |
73 | 0 | , mfX1(0.0f) |
74 | 0 | , mfY1(0.0f) |
75 | 0 | , mfX2(1.0f) |
76 | 0 | , mfY2(1.0f) |
77 | 0 | { |
78 | 0 | } |
79 | | }; |
80 | | |
81 | | class VCL_DLLPUBLIC WidgetDrawActionLine : public WidgetDrawActionShape |
82 | | { |
83 | | public: |
84 | | float mfX1; |
85 | | float mfY1; |
86 | | float mfX2; |
87 | | float mfY2; |
88 | | |
89 | | WidgetDrawActionLine() |
90 | 0 | : WidgetDrawActionShape(WidgetDrawActionType::LINE) |
91 | 0 | , mfX1(0.0) |
92 | 0 | , mfY1(0.0) |
93 | 0 | , mfX2(0.0) |
94 | 0 | , mfY2(0.0) |
95 | 0 | { |
96 | 0 | } |
97 | | }; |
98 | | |
99 | | class VCL_DLLPUBLIC WidgetDrawActionImage : public WidgetDrawAction |
100 | | { |
101 | | public: |
102 | | OUString msSource; |
103 | | |
104 | | WidgetDrawActionImage() |
105 | 0 | : WidgetDrawAction(WidgetDrawActionType::IMAGE) |
106 | 0 | { |
107 | 0 | } |
108 | | }; |
109 | | |
110 | | class VCL_DLLPUBLIC WidgetDrawActionExternal : public WidgetDrawAction |
111 | | { |
112 | | public: |
113 | | OUString msSource; |
114 | | |
115 | | WidgetDrawActionExternal() |
116 | 0 | : WidgetDrawAction(WidgetDrawActionType::EXTERNAL) |
117 | 0 | { |
118 | 0 | } |
119 | | }; |
120 | | |
121 | | struct VCL_DLLPUBLIC ControlTypeAndPart |
122 | | { |
123 | | ControlType meType; |
124 | | ControlPart mePart; |
125 | | |
126 | | ControlTypeAndPart(ControlType eType, ControlPart ePart) |
127 | 0 | : meType(eType) |
128 | 0 | , mePart(ePart) |
129 | 0 | { |
130 | 0 | } |
131 | | |
132 | | bool operator==(ControlTypeAndPart const& aOther) const |
133 | 0 | { |
134 | 0 | return meType == aOther.meType && mePart == aOther.mePart; |
135 | 0 | } |
136 | | }; |
137 | | |
138 | | } // end vcl namespace |
139 | | |
140 | | namespace std |
141 | | { |
142 | | template <> struct VCL_DLLPUBLIC hash<vcl::ControlTypeAndPart> |
143 | | { |
144 | | std::size_t operator()(vcl::ControlTypeAndPart const& rControlTypeAndPart) const noexcept |
145 | 0 | { |
146 | 0 | std::size_t seed = 0; |
147 | 0 | o3tl::hash_combine(seed, rControlTypeAndPart.meType); |
148 | 0 | o3tl::hash_combine(seed, rControlTypeAndPart.mePart); |
149 | 0 | return seed; |
150 | 0 | } |
151 | | }; |
152 | | |
153 | | } // end std namespace |
154 | | |
155 | | namespace vcl |
156 | | { |
157 | | class WidgetDefinitionState |
158 | | { |
159 | | public: |
160 | | OString msEnabled; |
161 | | OString msFocused; |
162 | | OString msPressed; |
163 | | OString msRollover; |
164 | | OString msDefault; |
165 | | OString msSelected; |
166 | | OString msButtonValue; |
167 | | OString msExtra; |
168 | | |
169 | | WidgetDefinitionState(OString sEnabled, OString sFocused, OString sPressed, OString sRollover, |
170 | | OString sDefault, OString sSelected, OString sButtonValue, |
171 | | OString sExtra); |
172 | | |
173 | | std::vector<std::shared_ptr<WidgetDrawAction>> mpWidgetDrawActions; |
174 | | |
175 | | void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, float fX1, |
176 | | float fY1, float fX2, float fY2, sal_Int32 nRx, sal_Int32 nRy); |
177 | | |
178 | | void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2, |
179 | | float fY2); |
180 | | |
181 | | void addDrawImage(OUString const& sSource); |
182 | | void addDrawExternal(OUString const& sSource); |
183 | | }; |
184 | | |
185 | | class VCL_DLLPUBLIC WidgetDefinitionPart |
186 | | { |
187 | | public: |
188 | | sal_Int32 mnWidth; |
189 | | sal_Int32 mnHeight; |
190 | | sal_Int32 mnMarginWidth; |
191 | | sal_Int32 mnMarginHeight; |
192 | | OString msOrientation; |
193 | | |
194 | | std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlType eType, |
195 | | ControlPart ePart, |
196 | | ControlState eState, |
197 | | ImplControlValue const& rValue); |
198 | | |
199 | | std::vector<std::shared_ptr<WidgetDefinitionState>> maStates; |
200 | | }; |
201 | | |
202 | | class VCL_DLLPUBLIC WidgetDefinitionSettings |
203 | | { |
204 | | public: |
205 | | OString msNoActiveTabTextRaise; |
206 | | OString msCenteredTabs; |
207 | | OString msListBoxEntryMargin; |
208 | | OString msDefaultFontSize; |
209 | | OString msTitleHeight; |
210 | | OString msFloatTitleHeight; |
211 | | OString msListBoxPreviewDefaultLogicWidth; |
212 | | OString msListBoxPreviewDefaultLogicHeight; |
213 | | }; |
214 | | |
215 | | class VCL_DLLPUBLIC WidgetDefinitionStyle |
216 | | { |
217 | | public: |
218 | | Color maFaceColor; |
219 | | Color maCheckedColor; |
220 | | Color maLightColor; |
221 | | Color maLightBorderColor; |
222 | | Color maShadowColor; |
223 | | Color maDarkShadowColor; |
224 | | Color maDefaultButtonTextColor; |
225 | | Color maButtonTextColor; |
226 | | Color maDefaultActionButtonTextColor; |
227 | | Color maActionButtonTextColor; |
228 | | Color maFlatButtonTextColor; |
229 | | Color maDefaultButtonRolloverTextColor; |
230 | | Color maButtonRolloverTextColor; |
231 | | Color maDefaultActionButtonRolloverTextColor; |
232 | | Color maActionButtonRolloverTextColor; |
233 | | Color maFlatButtonRolloverTextColor; |
234 | | Color maDefaultButtonPressedRolloverTextColor; |
235 | | Color maButtonPressedRolloverTextColor; |
236 | | Color maDefaultActionButtonPressedRolloverTextColor; |
237 | | Color maActionButtonPressedRolloverTextColor; |
238 | | Color maFlatButtonPressedRolloverTextColor; |
239 | | Color maRadioCheckTextColor; |
240 | | Color maGroupTextColor; |
241 | | Color maLabelTextColor; |
242 | | Color maWindowColor; |
243 | | Color maWindowTextColor; |
244 | | Color maDialogColor; |
245 | | Color maDialogTextColor; |
246 | | Color maWorkspaceColor; |
247 | | Color maMonoColor; |
248 | | Color maFieldColor; |
249 | | Color maFieldTextColor; |
250 | | Color maFieldRolloverTextColor; |
251 | | Color maActiveColor; |
252 | | Color maActiveTextColor; |
253 | | Color maActiveBorderColor; |
254 | | Color maDeactiveColor; |
255 | | Color maDeactiveTextColor; |
256 | | Color maDeactiveBorderColor; |
257 | | Color maMenuColor; |
258 | | Color maMenuBarColor; |
259 | | Color maMenuBarRolloverColor; |
260 | | Color maMenuBorderColor; |
261 | | Color maMenuTextColor; |
262 | | Color maMenuBarTextColor; |
263 | | Color maMenuBarRolloverTextColor; |
264 | | Color maMenuBarHighlightTextColor; |
265 | | Color maMenuHighlightColor; |
266 | | Color maMenuHighlightTextColor; |
267 | | Color maHighlightColor; |
268 | | Color maHighlightTextColor; |
269 | | Color maActiveTabColor; |
270 | | Color maInactiveTabColor; |
271 | | Color maTabTextColor; |
272 | | Color maTabRolloverTextColor; |
273 | | Color maTabHighlightTextColor; |
274 | | Color maDisableColor; |
275 | | Color maHelpColor; |
276 | | Color maHelpTextColor; |
277 | | Color maLinkColor; |
278 | | Color maVisitedLinkColor; |
279 | | Color maToolTextColor; |
280 | | }; |
281 | | |
282 | | class VCL_DLLPUBLIC WidgetDefinition |
283 | | { |
284 | | public: |
285 | | std::shared_ptr<WidgetDefinitionStyle> mpStyle; |
286 | | std::shared_ptr<WidgetDefinitionSettings> mpSettings; |
287 | | std::unordered_map<ControlTypeAndPart, std::shared_ptr<WidgetDefinitionPart>> maDefinitions; |
288 | | std::shared_ptr<WidgetDefinitionPart> getDefinition(ControlType eType, ControlPart ePart); |
289 | | }; |
290 | | |
291 | | } // end vcl namespace |
292 | | |
293 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |