LibreOffice Module vcl (master)  1
WidgetDefinition.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_VCL_INC_WIDGETDEFINITION_HXX
12 #define INCLUDED_VCL_INC_WIDGETDEFINITION_HXX
13 
14 #include <vcl/dllapi.h>
15 #include <memory>
16 #include <rtl/ustring.hxx>
17 #include <tools/color.hxx>
18 #include <unordered_map>
19 #include <vector>
20 #include <cstddef>
21 #include <boost/functional/hash.hpp>
22 #include <vcl/salnativewidgets.hxx>
23 
24 namespace vcl
25 {
27 {
28  RECTANGLE,
29  LINE,
30  IMAGE,
31  EXTERNAL
32 };
33 
35 {
36 public:
38  : maType(aType)
39  {
40  }
41 
43 };
44 
46 {
47 public:
49  : WidgetDrawAction(aType)
50  , mnStrokeWidth(-1)
51  {
52  }
53 
56  sal_Int32 mnStrokeWidth;
57 };
58 
60 {
61 public:
62  sal_Int32 mnRx;
63  sal_Int32 mnRy;
64 
65  float mfX1;
66  float mfY1;
67  float mfX2;
68  float mfY2;
69 
72  , mnRx(0)
73  , mnRy(0)
74  , mfX1(0.0f)
75  , mfY1(0.0f)
76  , mfX2(1.0f)
77  , mfY2(1.0f)
78  {
79  }
80 };
81 
83 {
84 public:
85  float mfX1;
86  float mfY1;
87  float mfX2;
88  float mfY2;
89 
92  , mfX1(0.0)
93  , mfY1(0.0)
94  , mfX2(0.0)
95  , mfY2(0.0)
96  {
97  }
98 };
99 
101 {
102 public:
103  OUString msSource;
104 
107  {
108  }
109 };
110 
112 {
113 public:
114  OUString msSource;
115 
118  {
119  }
120 };
121 
123 {
126 
128  : meType(eType)
129  , mePart(ePart)
130  {
131  }
132 
133  bool operator==(ControlTypeAndPart const& aOther) const
134  {
135  return meType == aOther.meType && mePart == aOther.mePart;
136  }
137 };
138 
139 } // end vcl namespace
140 
141 namespace std
142 {
143 template <> struct VCL_DLLPUBLIC hash<vcl::ControlTypeAndPart>
144 {
145  std::size_t operator()(vcl::ControlTypeAndPart const& rControlTypeAndPart) const noexcept
146  {
147  std::size_t seed = 0;
148  boost::hash_combine(seed, rControlTypeAndPart.meType);
149  boost::hash_combine(seed, rControlTypeAndPart.mePart);
150  return seed;
151  }
152 };
153 
154 } // end std namespace
155 
156 namespace vcl
157 {
159 {
160 public:
161  OString msEnabled;
162  OString msFocused;
163  OString msPressed;
164  OString msRollover;
165  OString msDefault;
166  OString msSelected;
167  OString msButtonValue;
168  OString msExtra;
169 
170  WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
171  OString const& sRollover, OString const& sDefault,
172  OString const& sSelected, OString const& sButtonValue,
173  OString const& sExtra);
174 
175  std::vector<std::shared_ptr<WidgetDrawAction>> mpWidgetDrawActions;
176 
177  void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, float fX1,
178  float fY1, float fX2, float fY2, sal_Int32 nRx, sal_Int32 nRy);
179 
180  void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2,
181  float fY2);
182 
183  void addDrawImage(OUString const& sSource);
184  void addDrawExternal(OUString const& sSource);
185 };
186 
188 {
189 public:
190  sal_Int32 mnWidth;
191  sal_Int32 mnHeight;
192  sal_Int32 mnMarginWidth;
193  sal_Int32 mnMarginHeight;
194  OString msOrientation;
195 
196  std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlType eType,
197  ControlPart ePart,
198  ControlState eState,
199  ImplControlValue const& rValue);
200 
201  std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
202 };
203 
205 {
206 public:
260 };
261 
263 {
264 public:
265  std::shared_ptr<WidgetDefinitionStyle> mpStyle;
266  std::unordered_map<ControlTypeAndPart, std::shared_ptr<WidgetDefinitionPart>> maDefinitions;
267  std::shared_ptr<WidgetDefinitionPart> getDefinition(ControlType eType, ControlPart ePart);
268 };
269 
270 } // end vcl namespace
271 
272 #endif // INCLUDED_VCL_INC_WIDGETDEFINITION_HXX
273 
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::size_t operator()(vcl::ControlTypeAndPart const &rControlTypeAndPart) const noexcept
OUString maType
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
bool operator==(ControlTypeAndPart const &aOther) const
std::vector< std::shared_ptr< WidgetDrawAction > > mpWidgetDrawActions
WidgetDrawActionType maType
std::vector< std::shared_ptr< WidgetDefinitionState > > maStates
WidgetDrawActionShape(WidgetDrawActionType aType)
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
WidgetDrawAction(WidgetDrawActionType aType)
std::unordered_map< ControlTypeAndPart, std::shared_ptr< WidgetDefinitionPart > > maDefinitions
void(* f)(TrueTypeTable *)
Definition: ttcr.cxx:466
std::shared_ptr< WidgetDefinitionStyle > mpStyle
WidgetDrawActionType
ControlTypeAndPart(ControlType eType, ControlPart ePart)