1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#ifndef INCLUDED_VCL_INC_WIDGETDEFINITIONREADER_HXX
#define INCLUDED_VCL_INC_WIDGETDEFINITIONREADER_HXX
#include <vcl/dllapi.h>
#include <memory>
#include <rtl/ustring.hxx>
#include <tools/color.hxx>
#include <tools/XmlWalker.hxx>
#include <unordered_map>
#include <vector>
#include <vcl/salnativewidgets.hxx>
namespace vcl
{
enum class DrawCommandType
{
RECTANGLE,
CIRCLE,
LINE
};
class VCL_DLLPUBLIC DrawCommand
{
public:
DrawCommand(DrawCommandType aType)
: maType(aType)
, mnStrokeWidth(-1)
, mnMargin(0)
{
}
DrawCommandType maType;
Color maStrokeColor;
Color maFillColor;
sal_Int32 mnStrokeWidth;
sal_Int32 mnMargin;
};
class VCL_DLLPUBLIC RectangleDrawCommand : public DrawCommand
{
public:
sal_Int32 mnRx;
sal_Int32 mnRy;
RectangleDrawCommand()
: DrawCommand(DrawCommandType::RECTANGLE)
, mnRx(0)
, mnRy(0)
{
}
};
class VCL_DLLPUBLIC CircleDrawCommand : public DrawCommand
{
public:
CircleDrawCommand()
: DrawCommand(DrawCommandType::CIRCLE)
{
}
};
class VCL_DLLPUBLIC LineDrawCommand : public DrawCommand
{
public:
float mfX1;
float mfY1;
float mfX2;
float mfY2;
LineDrawCommand()
: DrawCommand(DrawCommandType::LINE)
{
}
};
class VCL_DLLPUBLIC WidgetDefinitionState
{
public:
OString msEnabled;
OString msFocused;
OString msPressed;
OString msRollover;
OString msDefault;
OString msSelected;
OString msButtonValue;
WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
OString const& sRollover, OString const& sDefault,
OString const& sSelected, OString const& sButtonValue);
std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands;
void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
sal_Int32 nRx, sal_Int32 nRy, sal_Int32 nMargin);
void addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
sal_Int32 nMargin);
void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2,
float fY2);
};
class VCL_DLLPUBLIC WidgetDefinitionPart
{
public:
std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
ImplControlValue const& rValue);
std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
};
class VCL_DLLPUBLIC WidgetDefinition
{
public:
Color maFaceColor;
Color maCheckedColor;
Color maLightColor;
Color maLightBorderColor;
Color maShadowColor;
Color maDarkShadowColor;
Color maButtonTextColor;
Color maButtonRolloverTextColor;
Color maRadioCheckTextColor;
Color maGroupTextColor;
Color maLabelTextColor;
Color maWindowColor;
Color maWindowTextColor;
Color maDialogColor;
Color maDialogTextColor;
Color maWorkspaceColor;
Color maMonoColor;
Color maFieldColor;
Color maFieldTextColor;
Color maFieldRolloverTextColor;
Color maActiveColor;
Color maActiveTextColor;
Color maActiveBorderColor;
Color maDeactiveColor;
Color maDeactiveTextColor;
Color maDeactiveBorderColor;
Color maMenuColor;
Color maMenuBarColor;
Color maMenuBarRolloverColor;
Color maMenuBorderColor;
Color maMenuTextColor;
Color maMenuBarTextColor;
Color maMenuBarRolloverTextColor;
Color maMenuBarHighlightTextColor;
Color maMenuHighlightColor;
Color maMenuHighlightTextColor;
Color maHighlightColor;
Color maHighlightTextColor;
Color maActiveTabColor;
Color maInactiveTabColor;
Color maTabTextColor;
Color maTabRolloverTextColor;
Color maTabHighlightTextColor;
Color maDisableColor;
Color maHelpColor;
Color maHelpTextColor;
Color maLinkColor;
Color maVisitedLinkColor;
Color maToolTextColor;
Color maFontColor;
std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maPushButtonDefinitions;
std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maRadioButtonDefinitions;
std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maEditboxDefinitions;
std::shared_ptr<WidgetDefinitionPart> getPushButtonDefinition(ControlPart ePart);
std::shared_ptr<WidgetDefinitionPart> getRadioButtonDefinition(ControlPart ePart);
std::shared_ptr<WidgetDefinitionPart> getEditboxDefinition(ControlPart ePart);
};
class VCL_DLLPUBLIC WidgetDefinitionReader
{
private:
OUString m_rFilePath;
static void
readDefinition(tools::XmlWalker& rWalker,
std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>>& rDefinition);
static void readPart(tools::XmlWalker& rWalker, std::shared_ptr<WidgetDefinitionPart> rpPart);
static void readDrawingDefinition(tools::XmlWalker& rWalker,
std::shared_ptr<WidgetDefinitionState>& rStates);
public:
WidgetDefinitionReader(OUString const& rFilePath);
bool read(WidgetDefinition& rWidgetDefinition);
};
} // end vcl namespace
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|