/src/libreoffice/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
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 | | #include <sal/config.h> |
12 | | |
13 | | #include <string_view> |
14 | | |
15 | | #include <FileDefinitionWidgetDraw.hxx> |
16 | | #include <widgetdraw/WidgetDefinitionReader.hxx> |
17 | | |
18 | | #include <svdata.hxx> |
19 | | #include <rtl/bootstrap.hxx> |
20 | | #include <config_folders.h> |
21 | | #include <osl/file.hxx> |
22 | | |
23 | | #include <basegfx/range/b2drectangle.hxx> |
24 | | #include <basegfx/polygon/b2dpolygontools.hxx> |
25 | | #include <basegfx/tuple/b2dtuple.hxx> |
26 | | #include <basegfx/matrix/b2dhommatrixtools.hxx> |
27 | | |
28 | | #include <tools/stream.hxx> |
29 | | #include <vcl/bitmap.hxx> |
30 | | #include <vcl/BitmapTools.hxx> |
31 | | #include <vcl/gradient.hxx> |
32 | | |
33 | | #include <comphelper/seqstream.hxx> |
34 | | #include <comphelper/processfactory.hxx> |
35 | | #include <comphelper/lok.hxx> |
36 | | #include <comphelper/string.hxx> |
37 | | |
38 | | #include <com/sun/star/graphic/SvgTools.hpp> |
39 | | #include <basegfx/DrawCommands.hxx> |
40 | | #include <o3tl/string_view.hxx> |
41 | | |
42 | | using namespace css; |
43 | | |
44 | | namespace vcl |
45 | | { |
46 | | namespace |
47 | | { |
48 | | OUString lcl_getThemeDefinitionPath() |
49 | 0 | { |
50 | 0 | OUString sPath(u"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/theme_definitions/"_ustr); |
51 | 0 | rtl::Bootstrap::expandMacros(sPath); |
52 | 0 | return sPath; |
53 | 0 | } |
54 | | |
55 | | bool lcl_directoryExists(OUString const& sDirectory) |
56 | 0 | { |
57 | 0 | osl::DirectoryItem aDirectoryItem; |
58 | 0 | osl::FileBase::RC eRes = osl::DirectoryItem::get(sDirectory, aDirectoryItem); |
59 | 0 | return eRes == osl::FileBase::E_None; |
60 | 0 | } |
61 | | |
62 | | bool lcl_fileExists(OUString const& sFilename) |
63 | 0 | { |
64 | 0 | osl::File aFile(sFilename); |
65 | 0 | osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read); |
66 | 0 | return osl::FileBase::E_None == eRC; |
67 | 0 | } |
68 | | |
69 | | std::shared_ptr<WidgetDefinition> getWidgetDefinition(OUString const& rDefinitionFile, |
70 | | OUString const& rDefinitionResourcesPath) |
71 | 0 | { |
72 | 0 | auto pWidgetDefinition = std::make_shared<WidgetDefinition>(); |
73 | 0 | WidgetDefinitionReader aReader(rDefinitionFile, rDefinitionResourcesPath); |
74 | 0 | if (aReader.read(*pWidgetDefinition)) |
75 | 0 | return pWidgetDefinition; |
76 | 0 | return std::shared_ptr<WidgetDefinition>(); |
77 | 0 | } |
78 | | |
79 | | std::shared_ptr<WidgetDefinition> const& |
80 | | getWidgetDefinitionForTheme(std::u16string_view rThemenName) |
81 | 0 | { |
82 | 0 | static std::shared_ptr<WidgetDefinition> spDefinition; |
83 | 0 | if (!spDefinition) |
84 | 0 | { |
85 | 0 | OUString sSharedDefinitionBasePath = lcl_getThemeDefinitionPath(); |
86 | 0 | OUString sThemeFolder = sSharedDefinitionBasePath + rThemenName + "/"; |
87 | 0 | OUString sThemeDefinitionFile = sThemeFolder + "definition.xml"; |
88 | 0 | if (lcl_directoryExists(sThemeFolder) && lcl_fileExists(sThemeDefinitionFile)) |
89 | 0 | spDefinition = getWidgetDefinition(sThemeDefinitionFile, sThemeFolder); |
90 | 0 | } |
91 | 0 | return spDefinition; |
92 | 0 | } |
93 | | |
94 | | int getSettingValueInteger(std::string_view rValue, int nDefault) |
95 | 0 | { |
96 | 0 | if (rValue.empty()) |
97 | 0 | return nDefault; |
98 | 0 | if (!comphelper::string::isdigitAsciiString(rValue)) |
99 | 0 | return nDefault; |
100 | 0 | return o3tl::toInt32(rValue); |
101 | 0 | } |
102 | | |
103 | | bool getSettingValueBool(std::string_view rValue, bool bDefault) |
104 | 0 | { |
105 | 0 | if (rValue.empty()) |
106 | 0 | return bDefault; |
107 | 0 | if (rValue == "true" || rValue == "false") |
108 | 0 | return rValue == "true"; |
109 | 0 | return bDefault; |
110 | 0 | } |
111 | | |
112 | | } // end anonymous namespace |
113 | | |
114 | | FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics) |
115 | 0 | : m_rGraphics(rGraphics) |
116 | 0 | , m_bIsActive(false) |
117 | 0 | { |
118 | 0 | m_pWidgetDefinition = getWidgetDefinitionForTheme(u"online"); |
119 | | #ifdef IOS |
120 | | if (!m_pWidgetDefinition) |
121 | | m_pWidgetDefinition = getWidgetDefinitionForTheme(u"ios"); |
122 | | #endif |
123 | |
|
124 | 0 | if (!m_pWidgetDefinition) |
125 | 0 | return; |
126 | | |
127 | 0 | auto& pSettings = m_pWidgetDefinition->mpSettings; |
128 | |
|
129 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
130 | 0 | pSVData->maNWFData.mbNoFocusRects = true; |
131 | 0 | pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true; |
132 | 0 | pSVData->maNWFData.mbNoActiveTabTextRaise |
133 | 0 | = getSettingValueBool(pSettings->msNoActiveTabTextRaise, true); |
134 | 0 | pSVData->maNWFData.mbCenteredTabs = getSettingValueBool(pSettings->msCenteredTabs, true); |
135 | 0 | pSVData->maNWFData.mbProgressNeedsErase = true; |
136 | 0 | pSVData->maNWFData.mnStatusBarLowerRightOffset = 10; |
137 | 0 | pSVData->maNWFData.mbCanDrawWidgetAnySize = true; |
138 | |
|
139 | 0 | int nDefaultListboxEntryMargin = pSVData->maNWFData.mnListBoxEntryMargin; |
140 | 0 | pSVData->maNWFData.mnListBoxEntryMargin |
141 | 0 | = getSettingValueInteger(pSettings->msListBoxEntryMargin, nDefaultListboxEntryMargin); |
142 | |
|
143 | 0 | m_bIsActive = true; |
144 | 0 | } |
145 | | |
146 | | bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, ControlPart ePart) |
147 | 0 | { |
148 | 0 | switch (eType) |
149 | 0 | { |
150 | 0 | case ControlType::Generic: |
151 | 0 | case ControlType::Pushbutton: |
152 | 0 | case ControlType::Radiobutton: |
153 | 0 | case ControlType::Checkbox: |
154 | 0 | return true; |
155 | 0 | case ControlType::Editbox: |
156 | 0 | case ControlType::EditboxNoBorder: |
157 | 0 | case ControlType::MultilineEditbox: |
158 | 0 | return true; |
159 | 0 | case ControlType::Combobox: |
160 | 0 | case ControlType::Listbox: |
161 | 0 | if (ePart == ControlPart::HasBackgroundTexture) |
162 | 0 | return false; |
163 | 0 | return true; |
164 | 0 | case ControlType::Spinbox: |
165 | 0 | if (ePart == ControlPart::AllButtons) |
166 | 0 | return false; |
167 | 0 | return true; |
168 | 0 | case ControlType::SpinButtons: |
169 | 0 | return false; |
170 | 0 | case ControlType::TabItem: |
171 | 0 | case ControlType::TabPane: |
172 | 0 | case ControlType::TabHeader: |
173 | 0 | case ControlType::TabBody: |
174 | 0 | return true; |
175 | 0 | case ControlType::Scrollbar: |
176 | 0 | if (ePart == ControlPart::DrawBackgroundHorz |
177 | 0 | || ePart == ControlPart::DrawBackgroundVert) |
178 | 0 | return false; |
179 | 0 | return true; |
180 | 0 | case ControlType::Slider: |
181 | 0 | case ControlType::Fixedline: |
182 | 0 | case ControlType::Toolbar: |
183 | 0 | return true; |
184 | 0 | case ControlType::Menubar: |
185 | 0 | case ControlType::MenuPopup: |
186 | 0 | return true; |
187 | 0 | case ControlType::Progress: |
188 | 0 | case ControlType::LevelBar: |
189 | 0 | return true; |
190 | 0 | case ControlType::IntroProgress: |
191 | 0 | return false; |
192 | 0 | case ControlType::Tooltip: |
193 | 0 | return true; |
194 | 0 | case ControlType::WindowBackground: |
195 | 0 | case ControlType::Frame: |
196 | 0 | case ControlType::ListNode: |
197 | 0 | case ControlType::ListNet: |
198 | 0 | case ControlType::ListHeader: |
199 | 0 | return true; |
200 | 0 | } |
201 | | |
202 | 0 | return false; |
203 | 0 | } |
204 | | |
205 | | bool FileDefinitionWidgetDraw::hitTestNativeControl( |
206 | | ControlType /*eType*/, ControlPart /*ePart*/, |
207 | | const tools::Rectangle& /*rBoundingControlRegion*/, const Point& /*aPos*/, bool& /*rIsInside*/) |
208 | 0 | { |
209 | 0 | return false; |
210 | 0 | } |
211 | | |
212 | | void FileDefinitionWidgetDraw::drawPolyPolygon(SalGraphics& rGraphics, |
213 | | const basegfx::B2DHomMatrix& rObjectToDevice, |
214 | | const basegfx::B2DPolyPolygon& i_rPolyPolygon, |
215 | | double i_fTransparency) |
216 | 0 | { |
217 | 0 | rGraphics.drawPolyPolygon(rObjectToDevice, i_rPolyPolygon, i_fTransparency); |
218 | 0 | } |
219 | | |
220 | | void FileDefinitionWidgetDraw::drawPolyLine( |
221 | | SalGraphics& rGraphics, const basegfx::B2DHomMatrix& rObjectToDevice, |
222 | | const basegfx::B2DPolygon& i_rPolygon, double i_fTransparency, double i_fLineWidth, |
223 | | const std::vector<double>* i_pStroke, basegfx::B2DLineJoin i_eLineJoin, |
224 | | css::drawing::LineCap i_eLineCap, double i_fMiterMinimumAngle, bool bPixelSnapHairline) |
225 | 0 | { |
226 | 0 | rGraphics.drawPolyLine(rObjectToDevice, i_rPolygon, i_fTransparency, i_fLineWidth, i_pStroke, |
227 | 0 | i_eLineJoin, i_eLineCap, i_fMiterMinimumAngle, bPixelSnapHairline); |
228 | 0 | } |
229 | | |
230 | | void FileDefinitionWidgetDraw::drawBitmap(SalGraphics& rGraphics, const SalTwoRect& rPosAry, |
231 | | const SalBitmap& rSalBitmap) |
232 | 0 | { |
233 | 0 | rGraphics.drawBitmap(rPosAry, rSalBitmap); |
234 | 0 | } |
235 | | |
236 | | void FileDefinitionWidgetDraw::implDrawGradient(SalGraphics& rGraphics, |
237 | | const basegfx::B2DPolyPolygon& rPolyPolygon, |
238 | | const SalGradient& rGradient) |
239 | 0 | { |
240 | 0 | rGraphics.implDrawGradient(rPolyPolygon, rGradient); |
241 | 0 | } |
242 | | |
243 | | namespace |
244 | | { |
245 | | void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics, tools::Long nX, |
246 | | tools::Long nY, tools::Long nWidth, tools::Long nHeight) |
247 | 0 | { |
248 | 0 | basegfx::B2DRectangle aSVGRect = rDrawRoot.maRectangle; |
249 | |
|
250 | 0 | basegfx::B2DRange aTargetSurface(nX, nY, nX + nWidth + 1, nY + nHeight + 1); |
251 | |
|
252 | 0 | for (std::shared_ptr<gfx::DrawBase> const& pDrawBase : rDrawRoot.maChildren) |
253 | 0 | { |
254 | 0 | switch (pDrawBase->getType()) |
255 | 0 | { |
256 | 0 | case gfx::DrawCommandType::Rectangle: |
257 | 0 | { |
258 | 0 | auto const& rRectangle = static_cast<gfx::DrawRectangle const&>(*pDrawBase); |
259 | |
|
260 | 0 | basegfx::B2DRange aInputRectangle(rRectangle.maRectangle); |
261 | |
|
262 | 0 | double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth(); |
263 | 0 | double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight(); |
264 | |
|
265 | 0 | basegfx::B2DRange aFinalRectangle( |
266 | 0 | aInputRectangle.getMinX(), aInputRectangle.getMinY(), |
267 | 0 | aInputRectangle.getMaxX() + fDeltaX, aInputRectangle.getMaxY() + fDeltaY); |
268 | |
|
269 | 0 | aFinalRectangle.translate(aTargetSurface.getMinX() - 0.5, |
270 | 0 | aTargetSurface.getMinY() - 0.5); |
271 | |
|
272 | 0 | basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect( |
273 | 0 | aFinalRectangle, rRectangle.mnRx / aFinalRectangle.getWidth() * 2.0, |
274 | 0 | rRectangle.mnRy / aFinalRectangle.getHeight() * 2.0); |
275 | |
|
276 | 0 | if (rRectangle.mpFillColor) |
277 | 0 | { |
278 | 0 | rGraphics.SetLineColor(); |
279 | 0 | rGraphics.SetFillColor(Color(*rRectangle.mpFillColor)); |
280 | 0 | FileDefinitionWidgetDraw::drawPolyPolygon(rGraphics, basegfx::B2DHomMatrix(), |
281 | 0 | basegfx::B2DPolyPolygon(aB2DPolygon), |
282 | 0 | 1.0 - rRectangle.mnOpacity); |
283 | 0 | } |
284 | 0 | else if (rRectangle.mpFillGradient) |
285 | 0 | { |
286 | 0 | rGraphics.SetLineColor(); |
287 | 0 | rGraphics.SetFillColor(); |
288 | 0 | if (rRectangle.mpFillGradient->meType == gfx::GradientType::Linear) |
289 | 0 | { |
290 | 0 | auto* pLinearGradient = static_cast<gfx::LinearGradientInfo*>( |
291 | 0 | rRectangle.mpFillGradient.get()); |
292 | 0 | SalGradient aGradient; |
293 | 0 | double x, y; |
294 | |
|
295 | 0 | x = pLinearGradient->x1; |
296 | 0 | y = pLinearGradient->y1; |
297 | |
|
298 | 0 | if (x > aSVGRect.getCenterX()) |
299 | 0 | x = x + fDeltaX; |
300 | 0 | if (y > aSVGRect.getCenterY()) |
301 | 0 | y = y + fDeltaY; |
302 | |
|
303 | 0 | aGradient.maPoint1 = basegfx::B2DPoint(x + aTargetSurface.getMinX() - 0.5, |
304 | 0 | y + aTargetSurface.getMinY() - 0.5); |
305 | |
|
306 | 0 | x = pLinearGradient->x2; |
307 | 0 | y = pLinearGradient->y2; |
308 | |
|
309 | 0 | if (x > aSVGRect.getCenterX()) |
310 | 0 | x = x + fDeltaX; |
311 | 0 | if (y > aSVGRect.getCenterY()) |
312 | 0 | y = y + fDeltaY; |
313 | |
|
314 | 0 | aGradient.maPoint2 = basegfx::B2DPoint(x + aTargetSurface.getMinX() - 0.5, |
315 | 0 | y + aTargetSurface.getMinY() - 0.5); |
316 | |
|
317 | 0 | for (gfx::GradientStop const& rStop : pLinearGradient->maGradientStops) |
318 | 0 | { |
319 | 0 | Color aColor(rStop.maColor); |
320 | 0 | aColor.SetAlpha(255 |
321 | 0 | - (rStop.mfOpacity * (1.0f - rRectangle.mnOpacity))); |
322 | 0 | aGradient.maStops.emplace_back(aColor, rStop.mfOffset); |
323 | 0 | } |
324 | 0 | FileDefinitionWidgetDraw::implDrawGradient( |
325 | 0 | rGraphics, basegfx::B2DPolyPolygon(aB2DPolygon), aGradient); |
326 | 0 | } |
327 | 0 | } |
328 | 0 | if (rRectangle.mpStrokeColor) |
329 | 0 | { |
330 | 0 | rGraphics.SetLineColor(Color(*rRectangle.mpStrokeColor)); |
331 | 0 | rGraphics.SetFillColor(); |
332 | 0 | FileDefinitionWidgetDraw::drawPolyLine( |
333 | 0 | rGraphics, basegfx::B2DHomMatrix(), aB2DPolygon, 1.0 - rRectangle.mnOpacity, |
334 | 0 | rRectangle.mnStrokeWidth, |
335 | 0 | nullptr, // MM01 |
336 | 0 | basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false); |
337 | 0 | } |
338 | 0 | } |
339 | 0 | break; |
340 | 0 | case gfx::DrawCommandType::Path: |
341 | 0 | { |
342 | 0 | auto const& rPath = static_cast<gfx::DrawPath const&>(*pDrawBase); |
343 | |
|
344 | 0 | double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth(); |
345 | 0 | double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight(); |
346 | |
|
347 | 0 | basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon); |
348 | 0 | for (auto& rPolygon : aPolyPolygon) |
349 | 0 | { |
350 | 0 | for (size_t i = 0; i < rPolygon.count(); ++i) |
351 | 0 | { |
352 | 0 | auto& rPoint = rPolygon.getB2DPoint(i); |
353 | 0 | double x = rPoint.getX(); |
354 | 0 | double y = rPoint.getY(); |
355 | |
|
356 | 0 | if (x > aSVGRect.getCenterX()) |
357 | 0 | x = x + fDeltaX; |
358 | 0 | if (y > aSVGRect.getCenterY()) |
359 | 0 | y = y + fDeltaY; |
360 | 0 | rPolygon.setB2DPoint(i, basegfx::B2DPoint(x, y)); |
361 | 0 | } |
362 | 0 | } |
363 | 0 | aPolyPolygon.translate(aTargetSurface.getMinX() - 0.5, |
364 | 0 | aTargetSurface.getMinY() - 0.5); |
365 | |
|
366 | 0 | if (rPath.mpFillColor) |
367 | 0 | { |
368 | 0 | rGraphics.SetLineColor(); |
369 | 0 | rGraphics.SetFillColor(Color(*rPath.mpFillColor)); |
370 | 0 | FileDefinitionWidgetDraw::drawPolyPolygon(rGraphics, basegfx::B2DHomMatrix(), |
371 | 0 | aPolyPolygon, 1.0 - rPath.mnOpacity); |
372 | 0 | } |
373 | 0 | if (rPath.mpStrokeColor) |
374 | 0 | { |
375 | 0 | rGraphics.SetLineColor(Color(*rPath.mpStrokeColor)); |
376 | 0 | rGraphics.SetFillColor(); |
377 | 0 | for (auto const& rPolygon : std::as_const(aPolyPolygon)) |
378 | 0 | { |
379 | 0 | FileDefinitionWidgetDraw::drawPolyLine( |
380 | 0 | rGraphics, basegfx::B2DHomMatrix(), rPolygon, 1.0 - rPath.mnOpacity, |
381 | 0 | rPath.mnStrokeWidth, |
382 | 0 | nullptr, // MM01 |
383 | 0 | basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false); |
384 | 0 | } |
385 | 0 | } |
386 | 0 | } |
387 | 0 | break; |
388 | | |
389 | 0 | default: |
390 | 0 | break; |
391 | 0 | } |
392 | 0 | } |
393 | 0 | } |
394 | | |
395 | | void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDrawActions, |
396 | | SalGraphics& rGraphics, tools::Long nX, tools::Long nY, tools::Long nWidth, |
397 | | tools::Long nHeight) |
398 | 0 | { |
399 | 0 | for (std::shared_ptr<WidgetDrawAction> const& pDrawAction : rDrawActions) |
400 | 0 | { |
401 | 0 | switch (pDrawAction->maType) |
402 | 0 | { |
403 | 0 | case WidgetDrawActionType::RECTANGLE: |
404 | 0 | { |
405 | 0 | auto const& rWidgetDraw |
406 | 0 | = static_cast<WidgetDrawActionRectangle const&>(*pDrawAction); |
407 | |
|
408 | 0 | basegfx::B2DRectangle rRect( |
409 | 0 | nX + (nWidth * rWidgetDraw.mfX1), nY + (nHeight * rWidgetDraw.mfY1), |
410 | 0 | nX + (nWidth * rWidgetDraw.mfX2), nY + (nHeight * rWidgetDraw.mfY2)); |
411 | |
|
412 | 0 | basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect( |
413 | 0 | rRect, rWidgetDraw.mnRx / rRect.getWidth() * 2.0, |
414 | 0 | rWidgetDraw.mnRy / rRect.getHeight() * 2.0); |
415 | |
|
416 | 0 | rGraphics.SetLineColor(); |
417 | 0 | rGraphics.SetFillColor(rWidgetDraw.maFillColor); |
418 | 0 | FileDefinitionWidgetDraw::drawPolyPolygon( |
419 | 0 | rGraphics, basegfx::B2DHomMatrix(), basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f); |
420 | 0 | rGraphics.SetLineColor(rWidgetDraw.maStrokeColor); |
421 | 0 | rGraphics.SetFillColor(); |
422 | 0 | FileDefinitionWidgetDraw::drawPolyLine( |
423 | 0 | rGraphics, basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, |
424 | 0 | rWidgetDraw.mnStrokeWidth, nullptr, // MM01 |
425 | 0 | basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false); |
426 | 0 | } |
427 | 0 | break; |
428 | 0 | case WidgetDrawActionType::LINE: |
429 | 0 | { |
430 | 0 | auto const& rWidgetDraw = static_cast<WidgetDrawActionLine const&>(*pDrawAction); |
431 | 0 | Point aRectPoint(nX + 1, nY + 1); |
432 | |
|
433 | 0 | Size aRectSize(nWidth - 1, nHeight - 1); |
434 | |
|
435 | 0 | rGraphics.SetFillColor(); |
436 | 0 | rGraphics.SetLineColor(rWidgetDraw.maStrokeColor); |
437 | |
|
438 | 0 | basegfx::B2DPolygon aB2DPolygon{ |
439 | 0 | { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX1), |
440 | 0 | aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY1) }, |
441 | 0 | { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX2), |
442 | 0 | aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY2) }, |
443 | 0 | }; |
444 | |
|
445 | 0 | FileDefinitionWidgetDraw::drawPolyLine( |
446 | 0 | rGraphics, basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, |
447 | 0 | rWidgetDraw.mnStrokeWidth, nullptr, // MM01 |
448 | 0 | basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false); |
449 | 0 | } |
450 | 0 | break; |
451 | 0 | case WidgetDrawActionType::IMAGE: |
452 | 0 | { |
453 | 0 | double nScaleFactor = 1.0; |
454 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
455 | 0 | nScaleFactor = comphelper::LibreOfficeKit::getDPIScale(); |
456 | |
|
457 | 0 | auto const& rWidgetDraw = static_cast<WidgetDrawActionImage const&>(*pDrawAction); |
458 | 0 | auto& rCacheImages = ImplGetSVData()->maGDIData.maThemeImageCache; |
459 | 0 | OUString rCacheKey = rWidgetDraw.msSource + "@" + OUString::number(nScaleFactor); |
460 | 0 | auto aIterator = rCacheImages.find(rCacheKey); |
461 | |
|
462 | 0 | Bitmap aBitmap; |
463 | 0 | if (aIterator == rCacheImages.end()) |
464 | 0 | { |
465 | 0 | SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ); |
466 | |
|
467 | 0 | vcl::bitmap::loadFromSvg(aFileStream, u""_ustr, aBitmap, nScaleFactor); |
468 | 0 | if (!aBitmap.IsEmpty()) |
469 | 0 | { |
470 | 0 | rCacheImages.insert(std::make_pair(rCacheKey, aBitmap)); |
471 | 0 | } |
472 | 0 | } |
473 | 0 | else |
474 | 0 | { |
475 | 0 | aBitmap = aIterator->second; |
476 | 0 | } |
477 | |
|
478 | 0 | tools::Long nImageWidth = aBitmap.GetSizePixel().Width(); |
479 | 0 | tools::Long nImageHeight = aBitmap.GetSizePixel().Height(); |
480 | 0 | SalTwoRect aTR(0, 0, nImageWidth, nImageHeight, nX, nY, nImageWidth / nScaleFactor, |
481 | 0 | nImageHeight / nScaleFactor); |
482 | 0 | if (!aBitmap.IsEmpty()) |
483 | 0 | { |
484 | 0 | const std::shared_ptr<SalBitmap> pSalBitmap = aBitmap.ImplGetSalBitmap(); |
485 | 0 | FileDefinitionWidgetDraw::drawBitmap(rGraphics, aTR, *pSalBitmap); |
486 | 0 | } |
487 | 0 | } |
488 | 0 | break; |
489 | 0 | case WidgetDrawActionType::EXTERNAL: |
490 | 0 | { |
491 | 0 | auto const& rWidgetDraw |
492 | 0 | = static_cast<WidgetDrawActionExternal const&>(*pDrawAction); |
493 | |
|
494 | 0 | auto& rCacheDrawCommands = ImplGetSVData()->maGDIData.maThemeDrawCommandsCache; |
495 | |
|
496 | 0 | auto aIterator = rCacheDrawCommands.find(rWidgetDraw.msSource); |
497 | |
|
498 | 0 | if (aIterator == rCacheDrawCommands.end()) |
499 | 0 | { |
500 | 0 | SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ); |
501 | |
|
502 | 0 | const uno::Reference<uno::XComponentContext>& xContext( |
503 | 0 | comphelper::getProcessComponentContext()); |
504 | 0 | const uno::Reference<graphic::XSvgParser> xSvgParser |
505 | 0 | = graphic::SvgTools::create(xContext); |
506 | |
|
507 | 0 | std::size_t nSize = aFileStream.remainingSize(); |
508 | 0 | std::vector<sal_Int8> aBuffer(nSize + 1); |
509 | 0 | aFileStream.ReadBytes(aBuffer.data(), nSize); |
510 | 0 | aBuffer[nSize] = 0; |
511 | |
|
512 | 0 | uno::Sequence<sal_Int8> aData(aBuffer.data(), nSize + 1); |
513 | 0 | uno::Reference<io::XInputStream> aInputStream( |
514 | 0 | new comphelper::SequenceInputStream(aData)); |
515 | |
|
516 | 0 | uno::Any aAny = xSvgParser->getDrawCommands(aInputStream, u""_ustr); |
517 | 0 | if (aAny.has<sal_uInt64>()) |
518 | 0 | { |
519 | 0 | auto* pDrawRoot = reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>()); |
520 | 0 | if (pDrawRoot) |
521 | 0 | { |
522 | 0 | rCacheDrawCommands.insert( |
523 | 0 | std::make_pair(rWidgetDraw.msSource, *pDrawRoot)); |
524 | 0 | drawFromDrawCommands(*pDrawRoot, rGraphics, nX, nY, nWidth, nHeight); |
525 | 0 | } |
526 | 0 | } |
527 | 0 | } |
528 | 0 | else |
529 | 0 | { |
530 | 0 | drawFromDrawCommands(aIterator->second, rGraphics, nX, nY, nWidth, nHeight); |
531 | 0 | } |
532 | 0 | } |
533 | 0 | break; |
534 | 0 | } |
535 | 0 | } |
536 | 0 | } |
537 | | |
538 | | } // end anonymous namespace |
539 | | |
540 | | bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart ePart, |
541 | | ControlState eState, |
542 | | const ImplControlValue& rValue, tools::Long nX, |
543 | | tools::Long nY, tools::Long nWidth, |
544 | | tools::Long nHeight) |
545 | 0 | { |
546 | 0 | bool bOK = false; |
547 | 0 | auto const pPart = m_pWidgetDefinition->getDefinition(eType, ePart); |
548 | 0 | if (pPart) |
549 | 0 | { |
550 | 0 | auto const aStates = pPart->getStates(eType, ePart, eState, rValue); |
551 | 0 | if (!aStates.empty()) |
552 | 0 | { |
553 | | // use last defined state |
554 | 0 | auto const& pState = aStates.back(); |
555 | 0 | { |
556 | 0 | munchDrawCommands(pState->mpWidgetDrawActions, m_rGraphics, nX, nY, nWidth, |
557 | 0 | nHeight); |
558 | 0 | bOK = true; |
559 | 0 | } |
560 | 0 | } |
561 | 0 | } |
562 | 0 | return bOK; |
563 | 0 | } |
564 | | |
565 | | bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ePart, |
566 | | const tools::Rectangle& rControlRegion, |
567 | | ControlState eState, |
568 | | const ImplControlValue& rValue, |
569 | | const OUString& /*aCaptions*/, |
570 | | const Color& /*rBackgroundColor*/) |
571 | 0 | { |
572 | 0 | bool bOldAA = m_rGraphics.getAntiAlias(); |
573 | 0 | m_rGraphics.setAntiAlias(true); |
574 | |
|
575 | 0 | tools::Long nWidth = rControlRegion.GetWidth() - 1; |
576 | 0 | tools::Long nHeight = rControlRegion.GetHeight() - 1; |
577 | 0 | tools::Long nX = rControlRegion.Left(); |
578 | 0 | tools::Long nY = rControlRegion.Top(); |
579 | |
|
580 | 0 | bool bOK = false; |
581 | |
|
582 | 0 | switch (eType) |
583 | 0 | { |
584 | 0 | case ControlType::Pushbutton: |
585 | 0 | { |
586 | | /*bool bIsAction = false; |
587 | | const PushButtonValue* pPushButtonValue = static_cast<const PushButtonValue*>(&rValue); |
588 | | if (pPushButtonValue) |
589 | | bIsAction = pPushButtonValue->mbIsAction;*/ |
590 | |
|
591 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
592 | 0 | } |
593 | 0 | break; |
594 | 0 | case ControlType::Radiobutton: |
595 | 0 | { |
596 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
597 | 0 | } |
598 | 0 | break; |
599 | 0 | case ControlType::Checkbox: |
600 | 0 | { |
601 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
602 | 0 | } |
603 | 0 | break; |
604 | 0 | case ControlType::Combobox: |
605 | 0 | { |
606 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
607 | 0 | } |
608 | 0 | break; |
609 | 0 | case ControlType::Editbox: |
610 | 0 | case ControlType::EditboxNoBorder: |
611 | 0 | case ControlType::MultilineEditbox: |
612 | 0 | { |
613 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
614 | 0 | } |
615 | 0 | break; |
616 | 0 | case ControlType::Listbox: |
617 | 0 | { |
618 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
619 | 0 | } |
620 | 0 | break; |
621 | 0 | case ControlType::Spinbox: |
622 | 0 | { |
623 | 0 | if (rValue.getType() == ControlType::SpinButtons) |
624 | 0 | { |
625 | 0 | const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue*>(&rValue); |
626 | |
|
627 | 0 | { |
628 | 0 | ControlPart eUpButtonPart = pSpinVal->mnUpperPart; |
629 | 0 | ControlState eUpButtonState = pSpinVal->mnUpperState; |
630 | |
|
631 | 0 | tools::Long nUpperX = pSpinVal->maUpperRect.Left(); |
632 | 0 | tools::Long nUpperY = pSpinVal->maUpperRect.Top(); |
633 | 0 | tools::Long nUpperWidth = pSpinVal->maUpperRect.GetWidth() - 1; |
634 | 0 | tools::Long nUpperHeight = pSpinVal->maUpperRect.GetHeight() - 1; |
635 | |
|
636 | 0 | bOK = resolveDefinition(eType, eUpButtonPart, eUpButtonState, |
637 | 0 | ImplControlValue(), nUpperX, nUpperY, nUpperWidth, |
638 | 0 | nUpperHeight); |
639 | 0 | } |
640 | |
|
641 | 0 | if (bOK) |
642 | 0 | { |
643 | 0 | ControlPart eDownButtonPart = pSpinVal->mnLowerPart; |
644 | 0 | ControlState eDownButtonState = pSpinVal->mnLowerState; |
645 | |
|
646 | 0 | tools::Long nLowerX = pSpinVal->maLowerRect.Left(); |
647 | 0 | tools::Long nLowerY = pSpinVal->maLowerRect.Top(); |
648 | 0 | tools::Long nLowerWidth = pSpinVal->maLowerRect.GetWidth() - 1; |
649 | 0 | tools::Long nLowerHeight = pSpinVal->maLowerRect.GetHeight() - 1; |
650 | |
|
651 | 0 | bOK = resolveDefinition(eType, eDownButtonPart, eDownButtonState, |
652 | 0 | ImplControlValue(), nLowerX, nLowerY, nLowerWidth, |
653 | 0 | nLowerHeight); |
654 | 0 | } |
655 | 0 | } |
656 | 0 | else |
657 | 0 | { |
658 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
659 | 0 | } |
660 | 0 | } |
661 | 0 | break; |
662 | 0 | case ControlType::SpinButtons: |
663 | 0 | break; |
664 | 0 | case ControlType::TabItem: |
665 | 0 | case ControlType::TabHeader: |
666 | 0 | case ControlType::TabPane: |
667 | 0 | case ControlType::TabBody: |
668 | 0 | { |
669 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
670 | 0 | } |
671 | 0 | break; |
672 | 0 | case ControlType::Scrollbar: |
673 | 0 | { |
674 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
675 | 0 | } |
676 | 0 | break; |
677 | 0 | case ControlType::Slider: |
678 | 0 | { |
679 | 0 | const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue); |
680 | 0 | tools::Long nThumbX = pSliderValue->maThumbRect.Left(); |
681 | 0 | tools::Long nThumbY = pSliderValue->maThumbRect.Top(); |
682 | 0 | tools::Long nThumbWidth = pSliderValue->maThumbRect.GetWidth() - 1; |
683 | 0 | tools::Long nThumbHeight = pSliderValue->maThumbRect.GetHeight() - 1; |
684 | |
|
685 | 0 | if (ePart == ControlPart::TrackHorzArea) |
686 | 0 | { |
687 | 0 | tools::Long nCenterX = nThumbX + nThumbWidth / 2; |
688 | |
|
689 | 0 | bOK = resolveDefinition(eType, ControlPart::TrackHorzLeft, eState, rValue, nX, nY, |
690 | 0 | nCenterX - nX, nHeight); |
691 | 0 | if (bOK) |
692 | 0 | bOK = resolveDefinition(eType, ControlPart::TrackHorzRight, eState, rValue, |
693 | 0 | nCenterX, nY, nX + nWidth - nCenterX, nHeight); |
694 | 0 | } |
695 | 0 | else if (ePart == ControlPart::TrackVertArea) |
696 | 0 | { |
697 | 0 | tools::Long nCenterY = nThumbY + nThumbHeight / 2; |
698 | |
|
699 | 0 | bOK = resolveDefinition(eType, ControlPart::TrackVertUpper, eState, rValue, nX, nY, |
700 | 0 | nWidth, nCenterY - nY); |
701 | 0 | if (bOK) |
702 | 0 | bOK = resolveDefinition(eType, ControlPart::TrackVertLower, eState, rValue, nY, |
703 | 0 | nCenterY, nWidth, nY + nHeight - nCenterY); |
704 | 0 | } |
705 | |
|
706 | 0 | if (bOK) |
707 | 0 | { |
708 | 0 | bOK = resolveDefinition(eType, ControlPart::Button, |
709 | 0 | eState | pSliderValue->mnThumbState, rValue, nThumbX, |
710 | 0 | nThumbY, nThumbWidth, nThumbHeight); |
711 | 0 | } |
712 | 0 | } |
713 | 0 | break; |
714 | 0 | case ControlType::Fixedline: |
715 | 0 | { |
716 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
717 | 0 | } |
718 | 0 | break; |
719 | 0 | case ControlType::Toolbar: |
720 | 0 | { |
721 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
722 | 0 | } |
723 | 0 | break; |
724 | 0 | case ControlType::Menubar: |
725 | 0 | case ControlType::MenuPopup: |
726 | 0 | { |
727 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
728 | 0 | } |
729 | 0 | break; |
730 | 0 | case ControlType::Progress: |
731 | 0 | case ControlType::LevelBar: |
732 | 0 | { |
733 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
734 | 0 | } |
735 | 0 | break; |
736 | 0 | case ControlType::IntroProgress: |
737 | 0 | break; |
738 | 0 | case ControlType::Tooltip: |
739 | 0 | { |
740 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
741 | 0 | } |
742 | 0 | break; |
743 | 0 | case ControlType::WindowBackground: |
744 | 0 | case ControlType::Frame: |
745 | 0 | { |
746 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
747 | 0 | } |
748 | 0 | break; |
749 | 0 | case ControlType::ListNode: |
750 | 0 | case ControlType::ListNet: |
751 | 0 | case ControlType::ListHeader: |
752 | 0 | { |
753 | 0 | bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight); |
754 | 0 | } |
755 | 0 | break; |
756 | 0 | default: |
757 | 0 | break; |
758 | 0 | } |
759 | | |
760 | 0 | m_rGraphics.setAntiAlias(bOldAA); |
761 | |
|
762 | 0 | return bOK; |
763 | 0 | } |
764 | | |
765 | | bool FileDefinitionWidgetDraw::getNativeControlRegion( |
766 | | ControlType eType, ControlPart ePart, const tools::Rectangle& rBoundingControlRegion, |
767 | | ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/, |
768 | | tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion) |
769 | 0 | { |
770 | 0 | Point aLocation(rBoundingControlRegion.TopLeft()); |
771 | |
|
772 | 0 | switch (eType) |
773 | 0 | { |
774 | 0 | case ControlType::Spinbox: |
775 | 0 | { |
776 | 0 | auto const pButtonUpPart |
777 | 0 | = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonUp); |
778 | 0 | if (!pButtonUpPart) |
779 | 0 | return false; |
780 | 0 | Size aButtonSizeUp(pButtonUpPart->mnWidth, pButtonUpPart->mnHeight); |
781 | |
|
782 | 0 | auto const pButtonDownPart |
783 | 0 | = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown); |
784 | 0 | if (!pButtonDownPart) |
785 | 0 | return false; |
786 | 0 | Size aButtonSizeDown(pButtonDownPart->mnWidth, pButtonDownPart->mnHeight); |
787 | |
|
788 | 0 | auto const pEntirePart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); |
789 | |
|
790 | 0 | OString sOrientation = pEntirePart->msOrientation; |
791 | |
|
792 | 0 | if (sOrientation.isEmpty() || sOrientation == "stacked") |
793 | 0 | { |
794 | 0 | return false; |
795 | 0 | } |
796 | 0 | else if (sOrientation == "decrease-edit-increase") |
797 | 0 | { |
798 | 0 | if (ePart == ControlPart::ButtonUp) |
799 | 0 | { |
800 | 0 | Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth() |
801 | 0 | - aButtonSizeUp.Width(), |
802 | 0 | aLocation.Y()); |
803 | 0 | rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp); |
804 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
805 | 0 | return true; |
806 | 0 | } |
807 | 0 | else if (ePart == ControlPart::ButtonDown) |
808 | 0 | { |
809 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, aButtonSizeDown); |
810 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
811 | 0 | return true; |
812 | 0 | } |
813 | 0 | else if (ePart == ControlPart::SubEdit) |
814 | 0 | { |
815 | 0 | Point aPoint(aLocation.X() + aButtonSizeDown.Width(), aLocation.Y()); |
816 | 0 | Size aSize(rBoundingControlRegion.GetWidth() |
817 | 0 | - (aButtonSizeDown.Width() + aButtonSizeUp.Width()), |
818 | 0 | std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height())); |
819 | 0 | rNativeContentRegion = tools::Rectangle(aPoint, aSize); |
820 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
821 | 0 | return true; |
822 | 0 | } |
823 | 0 | else if (ePart == ControlPart::Entire) |
824 | 0 | { |
825 | 0 | Size aSize(rBoundingControlRegion.GetWidth(), |
826 | 0 | std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height())); |
827 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, aSize); |
828 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
829 | 0 | return true; |
830 | 0 | } |
831 | 0 | } |
832 | 0 | else if (sOrientation == "edit-decrease-increase") |
833 | 0 | { |
834 | 0 | if (ePart == ControlPart::ButtonUp) |
835 | 0 | { |
836 | 0 | Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth() |
837 | 0 | - aButtonSizeUp.Width(), |
838 | 0 | aLocation.Y()); |
839 | 0 | rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp); |
840 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
841 | 0 | return true; |
842 | 0 | } |
843 | 0 | else if (ePart == ControlPart::ButtonDown) |
844 | 0 | { |
845 | 0 | Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth() |
846 | 0 | - (aButtonSizeDown.Width() + aButtonSizeUp.Width()), |
847 | 0 | aLocation.Y()); |
848 | 0 | rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeDown); |
849 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
850 | 0 | return true; |
851 | 0 | } |
852 | 0 | else if (ePart == ControlPart::SubEdit) |
853 | 0 | { |
854 | 0 | Size aSize(rBoundingControlRegion.GetWidth() |
855 | 0 | - (aButtonSizeDown.Width() + aButtonSizeUp.Width()), |
856 | 0 | std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height())); |
857 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, aSize); |
858 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
859 | 0 | return true; |
860 | 0 | } |
861 | 0 | else if (ePart == ControlPart::Entire) |
862 | 0 | { |
863 | 0 | Size aSize(rBoundingControlRegion.GetWidth(), |
864 | 0 | std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height())); |
865 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, aSize); |
866 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
867 | 0 | return true; |
868 | 0 | } |
869 | 0 | } |
870 | 0 | } |
871 | 0 | break; |
872 | 0 | case ControlType::Checkbox: |
873 | 0 | case ControlType::Radiobutton: |
874 | 0 | { |
875 | 0 | auto const pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); |
876 | 0 | if (!pPart) |
877 | 0 | return false; |
878 | | |
879 | 0 | Size aSize(pPart->mnWidth, pPart->mnHeight); |
880 | 0 | rNativeContentRegion = tools::Rectangle(Point(), aSize); |
881 | 0 | return true; |
882 | 0 | } |
883 | 0 | case ControlType::TabItem: |
884 | 0 | { |
885 | 0 | auto const pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); |
886 | 0 | if (!pPart) |
887 | 0 | return false; |
888 | | |
889 | 0 | tools::Long nWidth = std::max(rBoundingControlRegion.GetWidth() + pPart->mnMarginWidth, |
890 | 0 | tools::Long(pPart->mnWidth)); |
891 | 0 | tools::Long nHeight |
892 | 0 | = std::max(rBoundingControlRegion.GetHeight() + pPart->mnMarginHeight, |
893 | 0 | tools::Long(pPart->mnHeight)); |
894 | |
|
895 | 0 | rNativeBoundingRegion = tools::Rectangle(aLocation, Size(nWidth, nHeight)); |
896 | 0 | rNativeContentRegion = rNativeBoundingRegion; |
897 | 0 | return true; |
898 | 0 | } |
899 | 0 | case ControlType::Editbox: |
900 | 0 | case ControlType::EditboxNoBorder: |
901 | 0 | case ControlType::MultilineEditbox: |
902 | 0 | { |
903 | 0 | sal_Int32 nHeight = rBoundingControlRegion.GetHeight(); |
904 | |
|
905 | 0 | auto const pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); |
906 | 0 | if (pPart) |
907 | 0 | nHeight = std::max(nHeight, pPart->mnHeight); |
908 | |
|
909 | 0 | Size aSize(rBoundingControlRegion.GetWidth(), nHeight); |
910 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, aSize); |
911 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
912 | 0 | rNativeBoundingRegion.expand(2); |
913 | 0 | return true; |
914 | 0 | } |
915 | 0 | break; |
916 | 0 | case ControlType::Scrollbar: |
917 | 0 | { |
918 | 0 | if (ePart == ControlPart::ButtonUp || ePart == ControlPart::ButtonDown |
919 | 0 | || ePart == ControlPart::ButtonLeft || ePart == ControlPart::ButtonRight) |
920 | 0 | { |
921 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, Size(0, 0)); |
922 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
923 | 0 | return true; |
924 | 0 | } |
925 | 0 | else |
926 | 0 | { |
927 | 0 | rNativeBoundingRegion = rBoundingControlRegion; |
928 | 0 | rNativeContentRegion = rNativeBoundingRegion; |
929 | 0 | return true; |
930 | 0 | } |
931 | 0 | } |
932 | 0 | break; |
933 | 0 | case ControlType::Combobox: |
934 | 0 | case ControlType::Listbox: |
935 | 0 | { |
936 | 0 | auto const pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown); |
937 | 0 | Size aComboButtonSize(pPart->mnWidth, pPart->mnHeight); |
938 | |
|
939 | 0 | if (ePart == ControlPart::ButtonDown) |
940 | 0 | { |
941 | 0 | Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth() |
942 | 0 | - aComboButtonSize.Width() - 1, |
943 | 0 | aLocation.Y()); |
944 | 0 | rNativeContentRegion = tools::Rectangle(aPoint, aComboButtonSize); |
945 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
946 | 0 | return true; |
947 | 0 | } |
948 | 0 | else if (ePart == ControlPart::SubEdit) |
949 | 0 | { |
950 | 0 | Size aSize(rBoundingControlRegion.GetWidth() - aComboButtonSize.Width(), |
951 | 0 | aComboButtonSize.Height()); |
952 | 0 | rNativeContentRegion = tools::Rectangle(aLocation + Point(1, 1), aSize); |
953 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
954 | 0 | return true; |
955 | 0 | } |
956 | 0 | else if (ePart == ControlPart::Entire) |
957 | 0 | { |
958 | 0 | Size aSize(rBoundingControlRegion.GetWidth(), aComboButtonSize.Height()); |
959 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, aSize); |
960 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
961 | 0 | rNativeBoundingRegion.expand(2); |
962 | 0 | return true; |
963 | 0 | } |
964 | 0 | } |
965 | 0 | break; |
966 | 0 | case ControlType::Slider: |
967 | 0 | if (ePart == ControlPart::ThumbHorz || ePart == ControlPart::ThumbVert) |
968 | 0 | { |
969 | 0 | rNativeContentRegion = tools::Rectangle(aLocation, Size(28, 28)); |
970 | 0 | rNativeBoundingRegion = rNativeContentRegion; |
971 | 0 | return true; |
972 | 0 | } |
973 | 0 | break; |
974 | 0 | default: |
975 | 0 | break; |
976 | 0 | } |
977 | | |
978 | 0 | return false; |
979 | 0 | } |
980 | | |
981 | | bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings) |
982 | 0 | { |
983 | 0 | StyleSettings aStyleSet = rSettings.GetStyleSettings(); |
984 | |
|
985 | 0 | auto& pDefinitionStyle = m_pWidgetDefinition->mpStyle; |
986 | |
|
987 | 0 | aStyleSet.SetFaceColor(pDefinitionStyle->maFaceColor); |
988 | 0 | aStyleSet.SetCheckedColor(pDefinitionStyle->maCheckedColor); |
989 | 0 | aStyleSet.SetLightColor(pDefinitionStyle->maLightColor); |
990 | 0 | aStyleSet.SetLightBorderColor(pDefinitionStyle->maLightBorderColor); |
991 | 0 | aStyleSet.SetShadowColor(pDefinitionStyle->maShadowColor); |
992 | 0 | aStyleSet.SetDarkShadowColor(pDefinitionStyle->maDarkShadowColor); |
993 | 0 | aStyleSet.SetDefaultButtonTextColor(pDefinitionStyle->maDefaultButtonTextColor); |
994 | 0 | aStyleSet.SetButtonTextColor(pDefinitionStyle->maButtonTextColor); |
995 | 0 | aStyleSet.SetDefaultActionButtonTextColor(pDefinitionStyle->maDefaultActionButtonTextColor); |
996 | 0 | aStyleSet.SetActionButtonTextColor(pDefinitionStyle->maActionButtonTextColor); |
997 | 0 | aStyleSet.SetFlatButtonTextColor(pDefinitionStyle->maFlatButtonTextColor); |
998 | 0 | aStyleSet.SetDefaultButtonRolloverTextColor(pDefinitionStyle->maDefaultButtonRolloverTextColor); |
999 | 0 | aStyleSet.SetButtonRolloverTextColor(pDefinitionStyle->maButtonRolloverTextColor); |
1000 | 0 | aStyleSet.SetDefaultActionButtonRolloverTextColor( |
1001 | 0 | pDefinitionStyle->maDefaultActionButtonRolloverTextColor); |
1002 | 0 | aStyleSet.SetActionButtonRolloverTextColor(pDefinitionStyle->maActionButtonRolloverTextColor); |
1003 | 0 | aStyleSet.SetFlatButtonRolloverTextColor(pDefinitionStyle->maFlatButtonRolloverTextColor); |
1004 | 0 | aStyleSet.SetDefaultButtonPressedRolloverTextColor( |
1005 | 0 | pDefinitionStyle->maDefaultButtonPressedRolloverTextColor); |
1006 | 0 | aStyleSet.SetButtonPressedRolloverTextColor(pDefinitionStyle->maButtonPressedRolloverTextColor); |
1007 | 0 | aStyleSet.SetDefaultActionButtonPressedRolloverTextColor( |
1008 | 0 | pDefinitionStyle->maDefaultActionButtonPressedRolloverTextColor); |
1009 | 0 | aStyleSet.SetActionButtonPressedRolloverTextColor( |
1010 | 0 | pDefinitionStyle->maActionButtonPressedRolloverTextColor); |
1011 | 0 | aStyleSet.SetFlatButtonPressedRolloverTextColor( |
1012 | 0 | pDefinitionStyle->maFlatButtonPressedRolloverTextColor); |
1013 | 0 | aStyleSet.SetRadioCheckTextColor(pDefinitionStyle->maRadioCheckTextColor); |
1014 | 0 | aStyleSet.SetGroupTextColor(pDefinitionStyle->maGroupTextColor); |
1015 | 0 | aStyleSet.SetLabelTextColor(pDefinitionStyle->maLabelTextColor); |
1016 | 0 | aStyleSet.SetWindowColor(pDefinitionStyle->maWindowColor); |
1017 | 0 | aStyleSet.SetWindowTextColor(pDefinitionStyle->maWindowTextColor); |
1018 | 0 | aStyleSet.SetDialogColor(pDefinitionStyle->maDialogColor); |
1019 | 0 | aStyleSet.SetDialogTextColor(pDefinitionStyle->maDialogTextColor); |
1020 | 0 | aStyleSet.SetWorkspaceColor(pDefinitionStyle->maWorkspaceColor); |
1021 | 0 | aStyleSet.SetMonoColor(pDefinitionStyle->maMonoColor); |
1022 | 0 | aStyleSet.SetFieldColor(pDefinitionStyle->maFieldColor); |
1023 | 0 | aStyleSet.SetFieldTextColor(pDefinitionStyle->maFieldTextColor); |
1024 | 0 | aStyleSet.SetFieldRolloverTextColor(pDefinitionStyle->maFieldRolloverTextColor); |
1025 | 0 | aStyleSet.SetActiveColor(pDefinitionStyle->maActiveColor); |
1026 | 0 | aStyleSet.SetActiveTextColor(pDefinitionStyle->maActiveTextColor); |
1027 | 0 | aStyleSet.SetActiveBorderColor(pDefinitionStyle->maActiveBorderColor); |
1028 | 0 | aStyleSet.SetDeactiveColor(pDefinitionStyle->maDeactiveColor); |
1029 | 0 | aStyleSet.SetDeactiveTextColor(pDefinitionStyle->maDeactiveTextColor); |
1030 | 0 | aStyleSet.SetDeactiveBorderColor(pDefinitionStyle->maDeactiveBorderColor); |
1031 | 0 | aStyleSet.SetMenuColor(pDefinitionStyle->maMenuColor); |
1032 | 0 | aStyleSet.SetMenuBarColor(pDefinitionStyle->maMenuBarColor); |
1033 | 0 | aStyleSet.SetMenuBarRolloverColor(pDefinitionStyle->maMenuBarRolloverColor); |
1034 | 0 | aStyleSet.SetMenuBorderColor(pDefinitionStyle->maMenuBorderColor); |
1035 | 0 | aStyleSet.SetMenuTextColor(pDefinitionStyle->maMenuTextColor); |
1036 | 0 | aStyleSet.SetMenuBarTextColor(pDefinitionStyle->maMenuBarTextColor); |
1037 | 0 | aStyleSet.SetMenuBarRolloverTextColor(pDefinitionStyle->maMenuBarRolloverTextColor); |
1038 | 0 | aStyleSet.SetMenuBarHighlightTextColor(pDefinitionStyle->maMenuBarHighlightTextColor); |
1039 | 0 | aStyleSet.SetMenuHighlightColor(pDefinitionStyle->maMenuHighlightColor); |
1040 | 0 | aStyleSet.SetMenuHighlightTextColor(pDefinitionStyle->maMenuHighlightTextColor); |
1041 | 0 | aStyleSet.SetHighlightColor(pDefinitionStyle->maHighlightColor); |
1042 | 0 | aStyleSet.SetHighlightTextColor(pDefinitionStyle->maHighlightTextColor); |
1043 | 0 | aStyleSet.SetActiveTabColor(pDefinitionStyle->maActiveTabColor); |
1044 | 0 | aStyleSet.SetInactiveTabColor(pDefinitionStyle->maInactiveTabColor); |
1045 | 0 | aStyleSet.SetTabTextColor(pDefinitionStyle->maTabTextColor); |
1046 | 0 | aStyleSet.SetTabRolloverTextColor(pDefinitionStyle->maTabRolloverTextColor); |
1047 | 0 | aStyleSet.SetTabHighlightTextColor(pDefinitionStyle->maTabHighlightTextColor); |
1048 | 0 | aStyleSet.SetDisableColor(pDefinitionStyle->maDisableColor); |
1049 | 0 | aStyleSet.SetHelpColor(pDefinitionStyle->maHelpColor); |
1050 | 0 | aStyleSet.SetHelpTextColor(pDefinitionStyle->maHelpTextColor); |
1051 | 0 | aStyleSet.SetLinkColor(pDefinitionStyle->maLinkColor); |
1052 | 0 | aStyleSet.SetVisitedLinkColor(pDefinitionStyle->maVisitedLinkColor); |
1053 | 0 | aStyleSet.SetToolTextColor(pDefinitionStyle->maToolTextColor); |
1054 | |
|
1055 | 0 | auto& pSettings = m_pWidgetDefinition->mpSettings; |
1056 | |
|
1057 | 0 | int nFontSize = getSettingValueInteger(pSettings->msDefaultFontSize, 10); |
1058 | 0 | vcl::Font aFont(FAMILY_SWISS, Size(0, nFontSize)); |
1059 | 0 | aFont.SetCharSet(osl_getThreadTextEncoding()); |
1060 | 0 | aFont.SetWeight(WEIGHT_NORMAL); |
1061 | 0 | aFont.SetFamilyName(u"Liberation Sans"_ustr); |
1062 | 0 | aStyleSet.SetAppFont(aFont); |
1063 | 0 | aStyleSet.SetHelpFont(aFont); |
1064 | 0 | aStyleSet.SetMenuFont(aFont); |
1065 | 0 | aStyleSet.SetToolFont(aFont); |
1066 | 0 | aStyleSet.SetGroupFont(aFont); |
1067 | 0 | aStyleSet.SetLabelFont(aFont); |
1068 | 0 | aStyleSet.SetRadioCheckFont(aFont); |
1069 | 0 | aStyleSet.SetPushButtonFont(aFont); |
1070 | 0 | aStyleSet.SetFieldFont(aFont); |
1071 | 0 | aStyleSet.SetIconFont(aFont); |
1072 | 0 | aStyleSet.SetTabFont(aFont); |
1073 | |
|
1074 | 0 | aFont.SetWeight(WEIGHT_BOLD); |
1075 | 0 | aStyleSet.SetFloatTitleFont(aFont); |
1076 | 0 | aStyleSet.SetTitleFont(aFont); |
1077 | |
|
1078 | 0 | int nTitleHeight = getSettingValueInteger(pSettings->msTitleHeight, aStyleSet.GetTitleHeight()); |
1079 | 0 | aStyleSet.SetTitleHeight(nTitleHeight); |
1080 | |
|
1081 | 0 | int nFloatTitleHeight |
1082 | 0 | = getSettingValueInteger(pSettings->msFloatTitleHeight, aStyleSet.GetFloatTitleHeight()); |
1083 | 0 | aStyleSet.SetFloatTitleHeight(nFloatTitleHeight); |
1084 | |
|
1085 | 0 | int nLogicWidth = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicWidth, |
1086 | 0 | 15); // See vcl/source/app/settings.cxx |
1087 | 0 | int nLogicHeight = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicHeight, 7); |
1088 | 0 | aStyleSet.SetListBoxPreviewDefaultLogicSize(Size(nLogicWidth, nLogicHeight)); |
1089 | |
|
1090 | 0 | rSettings.SetStyleSettings(aStyleSet); |
1091 | |
|
1092 | 0 | return true; |
1093 | 0 | } |
1094 | | |
1095 | | } // end vcl namespace |
1096 | | |
1097 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |