summaryrefslogtreecommitdiff
path: root/vcl/inc/widgetdraw/WidgetDefinition.hxx
blob: cc3eb660655753ca69abbebae23d93ba34253cfa (plain)
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/* -*- 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_WIDGETDEFINITION_HXX
#define INCLUDED_VCL_INC_WIDGETDEFINITION_HXX

#include <vcl/dllapi.h>
#include <memory>
#include <rtl/ustring.hxx>
#include <tools/color.hxx>
#include <unordered_map>
#include <vector>
#include <cstddef>
#include <boost/functional/hash.hpp>
#include <vcl/salnativewidgets.hxx>

namespace vcl
{
enum class WidgetDrawActionType
{
    RECTANGLE,
    LINE,
    IMAGE,
    EXTERNAL
};

class VCL_DLLPUBLIC WidgetDrawAction
{
public:
    WidgetDrawAction(WidgetDrawActionType aType)
        : maType(aType)
    {
    }

    WidgetDrawActionType maType;
};

class VCL_DLLPUBLIC WidgetDrawActionShape : public WidgetDrawAction
{
public:
    WidgetDrawActionShape(WidgetDrawActionType aType)
        : WidgetDrawAction(aType)
        , mnStrokeWidth(-1)
    {
    }

    Color maStrokeColor;
    Color maFillColor;
    sal_Int32 mnStrokeWidth;
};

class VCL_DLLPUBLIC WidgetDrawActionRectangle : public WidgetDrawActionShape
{
public:
    sal_Int32 mnRx;
    sal_Int32 mnRy;

    float mfX1;
    float mfY1;
    float mfX2;
    float mfY2;

    WidgetDrawActionRectangle()
        : WidgetDrawActionShape(WidgetDrawActionType::RECTANGLE)
        , mnRx(0)
        , mnRy(0)
        , mfX1(0.0f)
        , mfY1(0.0f)
        , mfX2(1.0f)
        , mfY2(1.0f)
    {
    }
};

class VCL_DLLPUBLIC WidgetDrawActionLine : public WidgetDrawActionShape
{
public:
    float mfX1;
    float mfY1;
    float mfX2;
    float mfY2;

    WidgetDrawActionLine()
        : WidgetDrawActionShape(WidgetDrawActionType::LINE)
        , mfX1(0.0)
        , mfY1(0.0)
        , mfX2(0.0)
        , mfY2(0.0)
    {
    }
};

class VCL_DLLPUBLIC WidgetDrawActionImage : public WidgetDrawAction
{
public:
    OUString msSource;

    WidgetDrawActionImage()
        : WidgetDrawAction(WidgetDrawActionType::IMAGE)
    {
    }
};

class VCL_DLLPUBLIC WidgetDrawActionExternal : public WidgetDrawAction
{
public:
    OUString msSource;

    WidgetDrawActionExternal()
        : WidgetDrawAction(WidgetDrawActionType::EXTERNAL)
    {
    }
};

struct VCL_DLLPUBLIC ControlTypeAndPart
{
    ControlType meType;
    ControlPart mePart;

    ControlTypeAndPart(ControlType eType, ControlPart ePart)
        : meType(eType)
        , mePart(ePart)
    {
    }

    bool operator==(ControlTypeAndPart const& aOther) const
    {
        return meType == aOther.meType && mePart == aOther.mePart;
    }
};

} // end vcl namespace

namespace std
{
template <> struct VCL_DLLPUBLIC hash<vcl::ControlTypeAndPart>
{
    std::size_t operator()(vcl::ControlTypeAndPart const& rControlTypeAndPart) const noexcept
    {
        std::size_t seed = 0;
        boost::hash_combine(seed, rControlTypeAndPart.meType);
        boost::hash_combine(seed, rControlTypeAndPart.mePart);
        return seed;
    }
};

} // end std namespace

namespace vcl
{
class WidgetDefinitionState
{
public:
    OString msEnabled;
    OString msFocused;
    OString msPressed;
    OString msRollover;
    OString msDefault;
    OString msSelected;
    OString msButtonValue;
    OString msExtra;

    WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
                          OString const& sRollover, OString const& sDefault,
                          OString const& sSelected, OString const& sButtonValue,
                          OString const& sExtra);

    std::vector<std::shared_ptr<WidgetDrawAction>> mpWidgetDrawActions;

    void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, float fX1,
                          float fY1, float fX2, float fY2, sal_Int32 nRx, sal_Int32 nRy);

    void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2,
                     float fY2);

    void addDrawImage(OUString const& sSource);
    void addDrawExternal(OUString const& sSource);
};

class VCL_DLLPUBLIC WidgetDefinitionPart
{
public:
    sal_Int32 mnWidth;
    sal_Int32 mnHeight;
    sal_Int32 mnMarginWidth;
    sal_Int32 mnMarginHeight;
    OString msOrientation;

    std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlType eType,
                                                                  ControlPart ePart,
                                                                  ControlState eState,
                                                                  ImplControlValue const& rValue);

    std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
};

class VCL_DLLPUBLIC WidgetDefinitionSettings
{
public:
    OString msNoActiveTabTextRaise;
    OString msCenteredTabs;
    OString msListBoxEntryMargin;
    OString msDefaultFontSize;
    OString msTitleHeight;
    OString msFloatTitleHeight;
    OString msListBoxPreviewDefaultLogicWidth;
    OString msListBoxPreviewDefaultLogicHeight;
};

class VCL_DLLPUBLIC WidgetDefinitionStyle
{
public:
    Color maFaceColor;
    Color maCheckedColor;
    Color maLightColor;
    Color maLightBorderColor;
    Color maShadowColor;
    Color maDarkShadowColor;
    Color maDefaultButtonTextColor;
    Color maButtonTextColor;
    Color maDefaultActionButtonTextColor;
    Color maActionButtonTextColor;
    Color maFlatButtonTextColor;
    Color maDefaultButtonRolloverTextColor;
    Color maButtonRolloverTextColor;
    Color maDefaultActionButtonRolloverTextColor;
    Color maActionButtonRolloverTextColor;
    Color maFlatButtonRolloverTextColor;
    Color maDefaultButtonPressedRolloverTextColor;
    Color maButtonPressedRolloverTextColor;
    Color maDefaultActionButtonPressedRolloverTextColor;
    Color maActionButtonPressedRolloverTextColor;
    Color maFlatButtonPressedRolloverTextColor;
    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;
};

class VCL_DLLPUBLIC WidgetDefinition
{
public:
    std::shared_ptr<WidgetDefinitionStyle> mpStyle;
    std::shared_ptr<WidgetDefinitionSettings> mpSettings;
    std::unordered_map<ControlTypeAndPart, std::shared_ptr<WidgetDefinitionPart>> maDefinitions;
    std::shared_ptr<WidgetDefinitionPart> getDefinition(ControlType eType, ControlPart ePart);
};

} // end vcl namespace

#endif // INCLUDED_VCL_INC_WIDGETDEFINITION_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */