LibreOffice Module vcl (master)  1
FileDefinitionWidgetDraw.cxx
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 
13 
14 #include <sal/config.h>
15 #include <svdata.hxx>
16 #include <rtl/bootstrap.hxx>
17 #include <config_folders.h>
18 #include <osl/file.hxx>
19 
23 
24 #include <tools/stream.hxx>
25 #include <vcl/bitmapex.hxx>
26 #include <vcl/BitmapTools.hxx>
27 
28 #include <comphelper/seqstream.hxx>
30 #include <comphelper/lok.hxx>
31 
32 #include <com/sun/star/graphic/SvgTools.hpp>
33 #include <basegfx/DrawCommands.hxx>
34 
35 using namespace css;
36 
37 namespace vcl
38 {
39 namespace
40 {
41 OUString lcl_getThemeDefinitionPath()
42 {
43  OUString sPath("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/theme_definitions/");
44  rtl::Bootstrap::expandMacros(sPath);
45  return sPath;
46 }
47 
48 bool lcl_directoryExists(OUString const& sDirectory)
49 {
50  osl::DirectoryItem aDirectoryItem;
51  osl::FileBase::RC eRes = osl::DirectoryItem::get(sDirectory, aDirectoryItem);
52  return eRes == osl::FileBase::E_None;
53 }
54 
55 bool lcl_fileExists(OUString const& sFilename)
56 {
57  osl::File aFile(sFilename);
58  osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
59  return osl::FileBase::E_None == eRC;
60 }
61 
62 std::shared_ptr<WidgetDefinition> getWidgetDefinition(OUString const& rDefinitionFile,
63  OUString const& rDefinitionResourcesPath)
64 {
65  auto pWidgetDefinition = std::make_shared<WidgetDefinition>();
66  WidgetDefinitionReader aReader(rDefinitionFile, rDefinitionResourcesPath);
67  if (aReader.read(*pWidgetDefinition))
68  return pWidgetDefinition;
69  return std::shared_ptr<WidgetDefinition>();
70 }
71 
72 std::shared_ptr<WidgetDefinition> const& getWidgetDefinitionForTheme(OUString const& rThemenName)
73 {
74  static std::shared_ptr<WidgetDefinition> spDefinition;
75  if (!spDefinition)
76  {
77  OUString sSharedDefinitionBasePath = lcl_getThemeDefinitionPath();
78  OUString sThemeFolder = sSharedDefinitionBasePath + rThemenName + "/";
79  OUString sThemeDefinitionFile = sThemeFolder + "definition.xml";
80  if (lcl_directoryExists(sThemeFolder) && lcl_fileExists(sThemeDefinitionFile))
81  spDefinition = getWidgetDefinition(sThemeDefinitionFile, sThemeFolder);
82  }
83  return spDefinition;
84 }
85 
86 } // end anonymous namespace
87 
88 FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics)
89  : m_rGraphics(rGraphics)
90  , m_bIsActive(false)
91 {
93  m_pWidgetDefinition = getWidgetDefinitionForTheme("online");
94 #ifdef IOS
96  m_pWidgetDefinition = getWidgetDefinitionForTheme("ios");
97 #endif
98 
100  {
101  ImplSVData* pSVData = ImplGetSVData();
102  pSVData->maNWFData.mbNoFocusRects = true;
103  pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true;
104  pSVData->maNWFData.mbNoActiveTabTextRaise = true;
105  pSVData->maNWFData.mbCenteredTabs = true;
106  pSVData->maNWFData.mbProgressNeedsErase = true;
108  pSVData->maNWFData.mbCanDrawWidgetAnySize = true;
109  pSVData->maNWFData.mnListBoxEntryMargin = 20;
110 
111  m_bIsActive = true;
112  }
113 }
114 
116 {
117  switch (eType)
118  {
123  return true;
126  return false;
127  return true;
131  return true;
134  return false;
135  return true;
137  if (ePart == ControlPart::AllButtons)
138  return false;
139  return true;
141  return false;
146  return true;
150  return false;
151  return true;
152  case ControlType::Slider:
155  return true;
158  return true;
160  return true;
162  return false;
164  return true;
166  case ControlType::Frame:
170  return true;
171  }
172 
173  return false;
174 }
175 
177  ControlType /*eType*/, ControlPart /*ePart*/,
178  const tools::Rectangle& /*rBoundingControlRegion*/, const Point& /*aPos*/, bool& /*rIsInside*/)
179 {
180  return false;
181 }
182 
183 namespace
184 {
185 void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics, long nX, long nY,
186  long nWidth, long nHeight)
187 {
188  basegfx::B2DRectangle aSVGRect = rDrawRoot.maRectangle;
189 
190  basegfx::B2DRange aTargetSurface(nX, nY, nX + nWidth + 1, nY + nHeight + 1);
191 
192  for (std::shared_ptr<gfx::DrawBase> const& pDrawBase : rDrawRoot.maChildren)
193  {
194  switch (pDrawBase->getType())
195  {
197  {
198  auto const& rRectangle = static_cast<gfx::DrawRectangle const&>(*pDrawBase);
199 
200  basegfx::B2DRange aInputRectangle(rRectangle.maRectangle);
201 
202  double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth();
203  double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight();
204 
205  basegfx::B2DRange aFinalRectangle(
206  aInputRectangle.getMinX(), aInputRectangle.getMinY(),
207  aInputRectangle.getMaxX() + fDeltaX, aInputRectangle.getMaxY() + fDeltaY);
208 
210  aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5));
211 
213  aFinalRectangle, rRectangle.mnRx / aFinalRectangle.getWidth() * 2.0,
214  rRectangle.mnRy / aFinalRectangle.getHeight() * 2.0);
215 
216  if (rRectangle.mpFillColor)
217  {
218  rGraphics.SetLineColor();
219  rGraphics.SetFillColor(Color(*rRectangle.mpFillColor));
221  basegfx::B2DPolyPolygon(aB2DPolygon),
222  1.0 - rRectangle.mnOpacity, nullptr);
223  }
224  if (rRectangle.mpStrokeColor)
225  {
226  rGraphics.SetLineColor(Color(*rRectangle.mpStrokeColor));
227  rGraphics.SetFillColor();
228  rGraphics.DrawPolyLine(
229  basegfx::B2DHomMatrix(), aB2DPolygon, 1.0 - rRectangle.mnOpacity,
230  basegfx::B2DVector(rRectangle.mnStrokeWidth, rRectangle.mnStrokeWidth),
231  basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false,
232  nullptr);
233  }
234  }
235  break;
237  {
238  auto const& rPath = static_cast<gfx::DrawPath const&>(*pDrawBase);
239 
240  double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth();
241  double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight();
242 
243  basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon);
244  for (auto& rPolygon : aPolyPolygon)
245  {
246  for (size_t i = 0; i < rPolygon.count(); ++i)
247  {
248  auto& rPoint = rPolygon.getB2DPoint(i);
249  double x = rPoint.getX();
250  double y = rPoint.getY();
251 
252  if (x > aSVGRect.getCenterX())
253  x = x + fDeltaX;
254  if (y > aSVGRect.getCenterY())
255  y = y + fDeltaY;
256  rPolygon.setB2DPoint(i, basegfx::B2DPoint(x, y));
257  }
258  }
259  aPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(
260  aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5));
261 
262  if (rPath.mpFillColor)
263  {
264  rGraphics.SetLineColor();
265  rGraphics.SetFillColor(Color(*rPath.mpFillColor));
266  rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), aPolyPolygon,
267  1.0 - rPath.mnOpacity, nullptr);
268  }
269  if (rPath.mpStrokeColor)
270  {
271  rGraphics.SetLineColor(Color(*rPath.mpStrokeColor));
272  rGraphics.SetFillColor();
273  for (auto const& rPolygon : aPolyPolygon)
274  {
275  rGraphics.DrawPolyLine(
276  basegfx::B2DHomMatrix(), rPolygon, 1.0 - rPath.mnOpacity,
277  basegfx::B2DVector(rPath.mnStrokeWidth, rPath.mnStrokeWidth),
278  basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false,
279  nullptr);
280  }
281  }
282  }
283  break;
284 
285  default:
286  break;
287  }
288  }
289 }
290 
291 void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDrawActions,
292  SalGraphics& rGraphics, long nX, long nY, long nWidth, long nHeight)
293 {
294  for (std::shared_ptr<WidgetDrawAction> const& pDrawAction : rDrawActions)
295  {
296  switch (pDrawAction->maType)
297  {
299  {
300  auto const& rWidgetDraw
301  = static_cast<WidgetDrawActionRectangle const&>(*pDrawAction);
302 
303  basegfx::B2DRectangle rRect(
304  nX + (nWidth * rWidgetDraw.mfX1), nY + (nHeight * rWidgetDraw.mfY1),
305  nX + (nWidth * rWidgetDraw.mfX2), nY + (nHeight * rWidgetDraw.mfY2));
306 
308  rRect, rWidgetDraw.mnRx / rRect.getWidth() * 2.0,
309  rWidgetDraw.mnRy / rRect.getHeight() * 2.0);
310 
311  rGraphics.SetLineColor();
312  rGraphics.SetFillColor(rWidgetDraw.maFillColor);
314  basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f, nullptr);
315  rGraphics.SetLineColor(rWidgetDraw.maStrokeColor);
316  rGraphics.SetFillColor();
317  rGraphics.DrawPolyLine(
318  basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f,
319  basegfx::B2DVector(rWidgetDraw.mnStrokeWidth, rWidgetDraw.mnStrokeWidth),
320  basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, nullptr);
321  }
322  break;
324  {
325  auto const& rWidgetDraw = static_cast<WidgetDrawActionLine const&>(*pDrawAction);
326  Point aRectPoint(nX + 1, nY + 1);
327 
328  Size aRectSize(nWidth - 1, nHeight - 1);
329 
330  rGraphics.SetFillColor();
331  rGraphics.SetLineColor(rWidgetDraw.maStrokeColor);
332 
333  basegfx::B2DPolygon aB2DPolygon{
334  { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX1),
335  aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY1) },
336  { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX2),
337  aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY2) },
338  };
339 
340  rGraphics.DrawPolyLine(
341  basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f,
342  basegfx::B2DVector(rWidgetDraw.mnStrokeWidth, rWidgetDraw.mnStrokeWidth),
343  basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false, nullptr);
344  }
345  break;
347  {
348  double nScaleFactor = 1.0;
351 
352  auto const& rWidgetDraw = static_cast<WidgetDrawActionImage const&>(*pDrawAction);
353  auto& rCacheImages = ImplGetSVData()->maGDIData.maThemeImageCache;
354  OUString rCacheKey = rWidgetDraw.msSource + "@" + OUString::number(nScaleFactor);
355  auto aIterator = rCacheImages.find(rCacheKey);
356 
357  BitmapEx aBitmap;
358  if (aIterator == rCacheImages.end())
359  {
360  SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ);
361 
362  vcl::bitmap::loadFromSvg(aFileStream, "", aBitmap, nScaleFactor);
363  if (!!aBitmap)
364  {
365  rCacheImages.insert(std::make_pair(rCacheKey, aBitmap));
366  }
367  }
368  else
369  {
370  aBitmap = aIterator->second;
371  }
372 
373  long nImageWidth = aBitmap.GetSizePixel().Width();
374  long nImageHeight = aBitmap.GetSizePixel().Height();
375  SalTwoRect aTR(0, 0, nImageWidth, nImageHeight, nX, nY, nImageWidth / nScaleFactor,
376  nImageHeight / nScaleFactor);
377  if (!!aBitmap)
378  {
379  const std::shared_ptr<SalBitmap> pSalBitmap
380  = aBitmap.GetBitmap().ImplGetSalBitmap();
381  if (aBitmap.IsAlpha())
382  {
383  const std::shared_ptr<SalBitmap> pSalBitmapAlpha
384  = aBitmap.GetAlpha().ImplGetSalBitmap();
385  rGraphics.DrawBitmap(aTR, *pSalBitmap, *pSalBitmapAlpha, nullptr);
386  }
387  else
388  {
389  rGraphics.DrawBitmap(aTR, *pSalBitmap, nullptr);
390  }
391  }
392  }
393  break;
395  {
396  auto const& rWidgetDraw
397  = static_cast<WidgetDrawActionExternal const&>(*pDrawAction);
398 
399  auto& rCacheDrawCommands = ImplGetSVData()->maGDIData.maThemeDrawCommandsCache;
400 
401  auto aIterator = rCacheDrawCommands.find(rWidgetDraw.msSource);
402 
403  gfx::DrawRoot aDrawRoot;
404 
405  if (aIterator == rCacheDrawCommands.end())
406  {
407  SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ);
408 
409  uno::Reference<uno::XComponentContext> xContext(
411  const uno::Reference<graphic::XSvgParser> xSvgParser
412  = graphic::SvgTools::create(xContext);
413 
414  std::size_t nSize = aFileStream.remainingSize();
415  std::vector<sal_Int8> aBuffer(nSize + 1);
416  aFileStream.ReadBytes(aBuffer.data(), nSize);
417  aBuffer[nSize] = 0;
418 
419  uno::Sequence<sal_Int8> aData(aBuffer.data(), nSize + 1);
420  uno::Reference<io::XInputStream> aInputStream(
422 
423  uno::Any aAny = xSvgParser->getDrawCommands(aInputStream, "");
424  if (aAny.has<sal_uInt64>())
425  {
426  auto* pDrawRoot = reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
427  if (pDrawRoot)
428  {
429  rCacheDrawCommands.insert(
430  std::make_pair(rWidgetDraw.msSource, *pDrawRoot));
431  drawFromDrawCommands(*pDrawRoot, rGraphics, nX, nY, nWidth, nHeight);
432  }
433  }
434  }
435  else
436  {
437  drawFromDrawCommands(aIterator->second, rGraphics, nX, nY, nWidth, nHeight);
438  }
439  }
440  break;
441  }
442  }
443 }
444 
445 } // end anonymous namespace
446 
448  ControlState eState,
449  const ImplControlValue& rValue, long nX, long nY,
450  long nWidth, long nHeight)
451 {
452  bool bOK = false;
453  auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ePart);
454  if (pPart)
455  {
456  auto const& aStates = pPart->getStates(eType, ePart, eState, rValue);
457  if (!aStates.empty())
458  {
459  // use last defined state
460  auto const& pState = aStates.back();
461  {
462  munchDrawCommands(pState->mpWidgetDrawActions, m_rGraphics, nX, nY, nWidth,
463  nHeight);
464  bOK = true;
465  }
466  }
467  }
468  return bOK;
469 }
470 
472  const tools::Rectangle& rControlRegion,
473  ControlState eState,
474  const ImplControlValue& rValue,
475  const OUString& /*aCaptions*/)
476 {
477  bool bOldAA = m_rGraphics.getAntiAliasB2DDraw();
479 
480  long nWidth = rControlRegion.GetWidth() - 1;
481  long nHeight = rControlRegion.GetHeight() - 1;
482  long nX = rControlRegion.Left();
483  long nY = rControlRegion.Top();
484 
485  bool bOK = false;
486 
487  switch (eType)
488  {
490  {
491  /*bool bIsAction = false;
492  const PushButtonValue* pPushButtonValue = static_cast<const PushButtonValue*>(&rValue);
493  if (pPushButtonValue)
494  bIsAction = pPushButtonValue->mbIsAction;*/
495 
496  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
497  }
498  break;
500  {
501  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
502  }
503  break;
505  {
506  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
507  }
508  break;
510  {
511  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
512  }
513  break;
517  {
518  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
519  }
520  break;
522  {
523  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
524  }
525  break;
527  {
528  if (rValue.getType() == ControlType::SpinButtons)
529  {
530  const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue*>(&rValue);
531 
532  {
533  ControlPart eUpButtonPart = pSpinVal->mnUpperPart;
534  ControlState eUpButtonState = pSpinVal->mnUpperState;
535 
536  long nUpperX = pSpinVal->maUpperRect.Left();
537  long nUpperY = pSpinVal->maUpperRect.Top();
538  long nUpperWidth = pSpinVal->maUpperRect.GetWidth() - 1;
539  long nUpperHeight = pSpinVal->maUpperRect.GetHeight() - 1;
540 
541  bOK = resolveDefinition(eType, eUpButtonPart, eUpButtonState,
542  ImplControlValue(), nUpperX, nUpperY, nUpperWidth,
543  nUpperHeight);
544  }
545 
546  if (bOK)
547  {
548  ControlPart eDownButtonPart = pSpinVal->mnLowerPart;
549  ControlState eDownButtonState = pSpinVal->mnLowerState;
550 
551  long nLowerX = pSpinVal->maLowerRect.Left();
552  long nLowerY = pSpinVal->maLowerRect.Top();
553  long nLowerWidth = pSpinVal->maLowerRect.GetWidth() - 1;
554  long nLowerHeight = pSpinVal->maLowerRect.GetHeight() - 1;
555 
556  bOK = resolveDefinition(eType, eDownButtonPart, eDownButtonState,
557  ImplControlValue(), nLowerX, nLowerY, nLowerWidth,
558  nLowerHeight);
559  }
560  }
561  else
562  {
563  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
564  }
565  }
566  break;
568  break;
573  {
574  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
575  }
576  break;
578  {
579  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
580  }
581  break;
582  case ControlType::Slider:
583  {
584  const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue);
585  long nThumbX = pSliderValue->maThumbRect.Left();
586  long nThumbY = pSliderValue->maThumbRect.Top();
587  long nThumbWidth = pSliderValue->maThumbRect.GetWidth() - 1;
588  long nThumbHeight = pSliderValue->maThumbRect.GetHeight() - 1;
589 
590  if (ePart == ControlPart::TrackHorzArea)
591  {
592  long nCenterX = nThumbX + nThumbWidth / 2;
593 
594  bOK = resolveDefinition(eType, ControlPart::TrackHorzLeft, eState, rValue, nX, nY,
595  nCenterX - nX, nHeight);
596  if (bOK)
597  bOK = resolveDefinition(eType, ControlPart::TrackHorzRight, eState, rValue,
598  nCenterX, nY, nX + nWidth - nCenterX, nHeight);
599  }
600  else if (ePart == ControlPart::TrackVertArea)
601  {
602  long nCenterY = nThumbY + nThumbHeight / 2;
603 
604  bOK = resolveDefinition(eType, ControlPart::TrackVertUpper, eState, rValue, nX, nY,
605  nWidth, nCenterY - nY);
606  if (bOK)
607  bOK = resolveDefinition(eType, ControlPart::TrackVertLower, eState, rValue, nY,
608  nCenterY, nWidth, nY + nHeight - nCenterY);
609  }
610 
611  if (bOK)
612  {
614  eState | pSliderValue->mnThumbState, rValue, nThumbX,
615  nThumbY, nThumbWidth, nThumbHeight);
616  }
617  }
618  break;
620  {
621  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
622  }
623  break;
625  {
626  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
627  }
628  break;
631  {
632  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
633  }
634  break;
636  {
637  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
638  }
639  break;
641  break;
643  {
644  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
645  }
646  break;
648  case ControlType::Frame:
649  {
650  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
651  }
652  break;
656  {
657  bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
658  }
659  break;
660  default:
661  break;
662  }
663 
665 
666  return bOK;
667 }
668 
670  ControlType eType, ControlPart ePart, const tools::Rectangle& rBoundingControlRegion,
671  ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/,
672  tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion)
673 {
674  Point aLocation(rBoundingControlRegion.TopLeft());
675 
676  switch (eType)
677  {
679  {
680  auto const& pButtonUpPart
681  = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonUp);
682  if (!pButtonUpPart)
683  return false;
684  Size aButtonSizeUp(pButtonUpPart->mnWidth, pButtonUpPart->mnHeight);
685 
686  auto const& pButtonDownPart
687  = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown);
688  if (!pButtonDownPart)
689  return false;
690  Size aButtonSizeDown(pButtonDownPart->mnWidth, pButtonDownPart->mnHeight);
691 
692  auto const& pEntirePart
693  = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
694  OString sOrientation = pEntirePart->msOrientation;
695 
696  if (sOrientation.isEmpty() || sOrientation == "decrease-edit-increase")
697  {
698  if (ePart == ControlPart::ButtonUp)
699  {
700  Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
701  - aButtonSizeUp.Width(),
702  aLocation.Y());
703  rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
704  rNativeBoundingRegion = rNativeContentRegion;
705  return true;
706  }
707  else if (ePart == ControlPart::ButtonDown)
708  {
709  rNativeContentRegion = tools::Rectangle(aLocation, aButtonSizeDown);
710  rNativeBoundingRegion = rNativeContentRegion;
711  return true;
712  }
713  else if (ePart == ControlPart::SubEdit)
714  {
715  Point aPoint(aLocation.X() + aButtonSizeDown.Width(), aLocation.Y());
716  Size aSize(rBoundingControlRegion.GetWidth()
717  - (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
718  std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
719  rNativeContentRegion = tools::Rectangle(aPoint, aSize);
720  rNativeBoundingRegion = rNativeContentRegion;
721  return true;
722  }
723  else if (ePart == ControlPart::Entire)
724  {
725  Size aSize(rBoundingControlRegion.GetWidth(),
726  std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
727  rNativeContentRegion = tools::Rectangle(aLocation, aSize);
728  rNativeBoundingRegion = rNativeContentRegion;
729  return true;
730  }
731  }
732  else if (sOrientation == "edit-decrease-increase")
733  {
734  if (ePart == ControlPart::ButtonUp)
735  {
736  Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
737  - aButtonSizeUp.Width(),
738  aLocation.Y());
739  rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
740  rNativeBoundingRegion = rNativeContentRegion;
741  return true;
742  }
743  else if (ePart == ControlPart::ButtonDown)
744  {
745  Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
746  - (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
747  aLocation.Y());
748  rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeDown);
749  rNativeBoundingRegion = rNativeContentRegion;
750  return true;
751  }
752  else if (ePart == ControlPart::SubEdit)
753  {
754  Size aSize(rBoundingControlRegion.GetWidth()
755  - (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
756  std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
757  rNativeContentRegion = tools::Rectangle(aLocation, aSize);
758  rNativeBoundingRegion = rNativeContentRegion;
759  return true;
760  }
761  else if (ePart == ControlPart::Entire)
762  {
763  Size aSize(rBoundingControlRegion.GetWidth(),
764  std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
765  rNativeContentRegion = tools::Rectangle(aLocation, aSize);
766  rNativeBoundingRegion = rNativeContentRegion;
767  return true;
768  }
769  }
770  }
771  break;
773  {
774  auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
775  if (!pPart)
776  return false;
777 
778  Size aSize(pPart->mnWidth, pPart->mnHeight);
779  rNativeContentRegion = tools::Rectangle(Point(), aSize);
780  return true;
781  }
783  {
784  auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
785  if (!pPart)
786  return false;
787 
788  Size aSize(pPart->mnWidth, pPart->mnHeight);
789  rNativeContentRegion = tools::Rectangle(Point(), aSize);
790  return true;
791  }
793  {
794  auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
795  if (!pPart)
796  return false;
797 
798  long nWidth = std::max(rBoundingControlRegion.GetWidth() + pPart->mnMarginWidth,
799  long(pPart->mnWidth));
800  long nHeight = std::max(rBoundingControlRegion.GetHeight() + pPart->mnMarginHeight,
801  long(pPart->mnHeight));
802 
803  rNativeBoundingRegion = tools::Rectangle(aLocation, Size(nWidth, nHeight));
804  rNativeContentRegion = rNativeBoundingRegion;
805  return true;
806  }
810  {
811  sal_Int32 nHeight = rBoundingControlRegion.GetHeight();
812 
813  auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
814  if (pPart)
815  nHeight = std::max(nHeight, pPart->mnHeight);
816 
817  Size aSize(rBoundingControlRegion.GetWidth(), nHeight);
818  rNativeContentRegion = tools::Rectangle(aLocation, aSize);
819  rNativeBoundingRegion = rNativeContentRegion;
820  rNativeBoundingRegion.expand(2);
821  return true;
822  }
823  break;
825  {
826  if (ePart == ControlPart::ButtonUp || ePart == ControlPart::ButtonDown
827  || ePart == ControlPart::ButtonLeft || ePart == ControlPart::ButtonRight)
828  {
829  rNativeContentRegion = tools::Rectangle(aLocation, Size(0, 0));
830  rNativeBoundingRegion = rNativeContentRegion;
831  return true;
832  }
833  else
834  {
835  rNativeBoundingRegion = rBoundingControlRegion;
836  rNativeContentRegion = rNativeBoundingRegion;
837  return true;
838  }
839  }
840  break;
843  {
844  auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown);
845  Size aComboButtonSize(pPart->mnWidth, pPart->mnHeight);
846 
847  if (ePart == ControlPart::ButtonDown)
848  {
849  Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
850  - aComboButtonSize.Width(),
851  aLocation.Y() + 1);
852  rNativeContentRegion = tools::Rectangle(aPoint, aComboButtonSize);
853  rNativeBoundingRegion = rNativeContentRegion;
854  return true;
855  }
856  else if (ePart == ControlPart::SubEdit)
857  {
858  Size aSize(rBoundingControlRegion.GetWidth() - aComboButtonSize.Width(),
859  aComboButtonSize.Height());
860  rNativeContentRegion = tools::Rectangle(aLocation + Point(1, 1), aSize);
861  rNativeBoundingRegion = rNativeContentRegion;
862  return true;
863  }
864  else if (ePart == ControlPart::Entire)
865  {
866  Size aSize(rBoundingControlRegion.GetWidth(), aComboButtonSize.Height());
867  rNativeContentRegion = tools::Rectangle(aLocation, aSize);
868  rNativeBoundingRegion = rNativeContentRegion;
869  rNativeBoundingRegion.expand(1);
870  return true;
871  }
872  }
873  break;
874  case ControlType::Slider:
875  if (ePart == ControlPart::ThumbHorz || ePart == ControlPart::ThumbVert)
876  {
877  rNativeContentRegion = tools::Rectangle(aLocation, Size(28, 28));
878  rNativeBoundingRegion = rNativeContentRegion;
879  return true;
880  }
881  break;
882  default:
883  break;
884  }
885 
886  return false;
887 }
888 
890 {
891  StyleSettings aStyleSet = rSettings.GetStyleSettings();
892 
893  auto pDefinitionStyle = m_pWidgetDefinition->mpStyle;
894 
895  aStyleSet.SetFaceColor(pDefinitionStyle->maFaceColor);
896  aStyleSet.SetCheckedColor(pDefinitionStyle->maCheckedColor);
897  aStyleSet.SetLightColor(pDefinitionStyle->maLightColor);
898  aStyleSet.SetLightBorderColor(pDefinitionStyle->maLightBorderColor);
899  aStyleSet.SetShadowColor(pDefinitionStyle->maShadowColor);
900  aStyleSet.SetDarkShadowColor(pDefinitionStyle->maDarkShadowColor);
901  aStyleSet.SetButtonTextColor(pDefinitionStyle->maButtonTextColor);
902  aStyleSet.SetButtonRolloverTextColor(pDefinitionStyle->maButtonRolloverTextColor);
903  aStyleSet.SetRadioCheckTextColor(pDefinitionStyle->maRadioCheckTextColor);
904  aStyleSet.SetGroupTextColor(pDefinitionStyle->maGroupTextColor);
905  aStyleSet.SetLabelTextColor(pDefinitionStyle->maLabelTextColor);
906  aStyleSet.SetWindowColor(pDefinitionStyle->maWindowColor);
907  aStyleSet.SetWindowTextColor(pDefinitionStyle->maWindowTextColor);
908  aStyleSet.SetDialogColor(pDefinitionStyle->maDialogColor);
909  aStyleSet.SetDialogTextColor(pDefinitionStyle->maDialogTextColor);
910  aStyleSet.SetWorkspaceColor(pDefinitionStyle->maWorkspaceColor);
911  aStyleSet.SetMonoColor(pDefinitionStyle->maMonoColor);
912  aStyleSet.SetFieldColor(pDefinitionStyle->maFieldColor);
913  aStyleSet.SetFieldTextColor(pDefinitionStyle->maFieldTextColor);
914  aStyleSet.SetFieldRolloverTextColor(pDefinitionStyle->maFieldRolloverTextColor);
915  aStyleSet.SetActiveColor(pDefinitionStyle->maActiveColor);
916  aStyleSet.SetActiveTextColor(pDefinitionStyle->maActiveTextColor);
917  aStyleSet.SetActiveBorderColor(pDefinitionStyle->maActiveBorderColor);
918  aStyleSet.SetDeactiveColor(pDefinitionStyle->maDeactiveColor);
919  aStyleSet.SetDeactiveTextColor(pDefinitionStyle->maDeactiveTextColor);
920  aStyleSet.SetDeactiveBorderColor(pDefinitionStyle->maDeactiveBorderColor);
921  aStyleSet.SetMenuColor(pDefinitionStyle->maMenuColor);
922  aStyleSet.SetMenuBarColor(pDefinitionStyle->maMenuBarColor);
923  aStyleSet.SetMenuBarRolloverColor(pDefinitionStyle->maMenuBarRolloverColor);
924  aStyleSet.SetMenuBorderColor(pDefinitionStyle->maMenuBorderColor);
925  aStyleSet.SetMenuTextColor(pDefinitionStyle->maMenuTextColor);
926  aStyleSet.SetMenuBarTextColor(pDefinitionStyle->maMenuBarTextColor);
927  aStyleSet.SetMenuBarRolloverTextColor(pDefinitionStyle->maMenuBarRolloverTextColor);
928  aStyleSet.SetMenuBarHighlightTextColor(pDefinitionStyle->maMenuBarHighlightTextColor);
929  aStyleSet.SetMenuHighlightColor(pDefinitionStyle->maMenuHighlightColor);
930  aStyleSet.SetMenuHighlightTextColor(pDefinitionStyle->maMenuHighlightTextColor);
931  aStyleSet.SetHighlightColor(pDefinitionStyle->maHighlightColor);
932  aStyleSet.SetHighlightTextColor(pDefinitionStyle->maHighlightTextColor);
933  aStyleSet.SetActiveTabColor(pDefinitionStyle->maActiveTabColor);
934  aStyleSet.SetInactiveTabColor(pDefinitionStyle->maInactiveTabColor);
935  aStyleSet.SetTabTextColor(pDefinitionStyle->maTabTextColor);
936  aStyleSet.SetTabRolloverTextColor(pDefinitionStyle->maTabRolloverTextColor);
937  aStyleSet.SetTabHighlightTextColor(pDefinitionStyle->maTabHighlightTextColor);
938  aStyleSet.SetDisableColor(pDefinitionStyle->maDisableColor);
939  aStyleSet.SetHelpColor(pDefinitionStyle->maHelpColor);
940  aStyleSet.SetHelpTextColor(pDefinitionStyle->maHelpTextColor);
941  aStyleSet.SetLinkColor(pDefinitionStyle->maLinkColor);
942  aStyleSet.SetVisitedLinkColor(pDefinitionStyle->maVisitedLinkColor);
943  aStyleSet.SetToolTextColor(pDefinitionStyle->maToolTextColor);
944  aStyleSet.SetFontColor(pDefinitionStyle->maFontColor);
945 
946  vcl::Font aFont(FAMILY_SWISS, Size(0, 10));
947  aFont.SetCharSet(osl_getThreadTextEncoding());
948  aFont.SetWeight(WEIGHT_NORMAL);
949  aFont.SetFamilyName("Liberation Sans");
950  aStyleSet.SetAppFont(aFont);
951  aStyleSet.SetHelpFont(aFont);
952  aStyleSet.SetMenuFont(aFont);
953  aStyleSet.SetToolFont(aFont);
954  aStyleSet.SetGroupFont(aFont);
955  aStyleSet.SetLabelFont(aFont);
956  aStyleSet.SetRadioCheckFont(aFont);
957  aStyleSet.SetPushButtonFont(aFont);
958  aStyleSet.SetFieldFont(aFont);
959  aStyleSet.SetIconFont(aFont);
960  aStyleSet.SetTabFont(aFont);
961 
962  aFont.SetWeight(WEIGHT_BOLD);
963  aStyleSet.SetFloatTitleFont(aFont);
964  aStyleSet.SetTitleFont(aFont);
965 
966  aStyleSet.SetTitleHeight(16);
967  aStyleSet.SetFloatTitleHeight(12);
968  aStyleSet.SetListBoxPreviewDefaultLogicSize(Size(16, 16));
969 
970  rSettings.SetStyleSettings(aStyleSet);
971 
972  return true;
973 }
974 
975 } // end vcl namespace
976 
977 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetCheckedColor(const Color &rColor)
void SetMenuFont(const vcl::Font &rFont)
Point TopLeft() const
long Width() const
double getCenterY() const
void SetTabRolloverTextColor(const Color &rColor)
void loadFromSvg(SvStream &rStream, const OUString &sPath, BitmapEx &rBitmapEx, double fScalingFactor)
Definition: BitmapTools.cxx:61
void SetHighlightColor(const Color &rColor)
long GetWidth() const
void SetHelpFont(const vcl::Font &rFont)
basegfx::B2DRange maRectangle
bool mbCanDrawWidgetAnySize
Definition: svdata.hxx:288
long GetHeight() const
double getHeight() const
void SetFontColor(const Color &rColor)
const char aData[]
void SetFieldFont(const vcl::Font &rFont)
void SetMenuBorderColor(const Color &rColor)
ControlType getType() const
void SetMenuTextColor(const Color &rColor)
bool mbNoActiveTabTextRaise
Definition: svdata.hxx:283
void SetStyleSettings(const StyleSettings &rSet)
long Height() const
void SetMonoColor(const Color &rColor)
void SetLightColor(const Color &rColor)
void SetMenuBarRolloverTextColor(const Color &rColor)
int mnStatusBarLowerRightOffset
Definition: svdata.hxx:266
const std::shared_ptr< SalBitmap > & ImplGetSalBitmap() const
Definition: bitmap.hxx:518
void SetIconFont(const vcl::Font &rFont)
void SetRadioCheckFont(const vcl::Font &rFont)
void SetFieldRolloverTextColor(const Color &rColor)
const StyleSettings & GetStyleSettings() const
ImplSVNWFData maNWFData
Definition: svdata.hxx:357
void SetWindowColor(const Color &rColor)
void SetWeight(FontWeight)
Definition: font/font.cxx:214
bool mbNoFocusRectsForFlatButtons
Definition: svdata.hxx:281
ControlPart mnLowerPart
void SetCharSet(rtl_TextEncoding)
Definition: font/font.cxx:128
void SetMenuHighlightColor(const Color &rColor)
float x
void SetButtonTextColor(const Color &rColor)
tools::Rectangle maLowerRect
void SetDialogColor(const Color &rColor)
void SetActiveTabColor(const Color &rColor)
ImplSVGDIData maGDIData
Definition: svdata.hxx:353
int mnListBoxEntryMargin
Definition: svdata.hxx:300
void SetLinkColor(const Color &rColor)
void SetDeactiveBorderColor(const Color &rColor)
void SetDeactiveColor(const Color &rColor)
WEIGHT_BOLD
bool resolveDefinition(ControlType eType, ControlPart ePart, ControlState eState, const ImplControlValue &rValue, long nX, long nY, long nWidth, long nHeight)
tools::Rectangle maUpperRect
bool IsAlpha() const
Definition: bitmapex.cxx:226
double getWidth() const
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
void SetMenuBarRolloverColor(const Color &rColor)
void SetMenuHighlightTextColor(const Color &rColor)
void SetDialogTextColor(const Color &rColor)
void SetMenuColor(const Color &rColor)
void SetMenuBarTextColor(const Color &rColor)
bool updateSettings(AllSettings &rSettings) override
long Top() const
void SetTitleHeight(long nSize)
void DrawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, const OutputDevice *pOutDev)
void DrawPolyLine(sal_uInt32 nPoints, SalPoint const *pPtAry, const OutputDevice *pOutDev)
void DrawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32 *pPoints, PCONSTSALPOINT *pPtAry, const OutputDevice *pOutDev)
float y
std::vector< std::shared_ptr< DrawBase > > maChildren
o3tl::lru_map< OUString, BitmapEx > maThemeImageCache
Definition: svdata.hxx:191
Bitmap GetBitmap(const Color *pTransReplaceColor=nullptr) const
Definition: bitmapex.cxx:236
ControlPart mnUpperPart
ControlState mnUpperState
virtual void SetFillColor()=0
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:66
void SetFamilyName(const OUString &rFamilyName)
Definition: font/font.cxx:106
bool getNativeControlRegion(ControlType eType, ControlPart ePart, const tools::Rectangle &rBoundingControlRegion, ControlState eState, const ImplControlValue &aValue, const OUString &aCaption, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) override
Get the native control regions for the control part.
virtual void SetLineColor()=0
The edit field part of a control, e.g.
void SetMenuBarColor(const Color &rColor)
int i
void SetButtonRolloverTextColor(const Color &rColor)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
ControlState mnLowerState
void SetGroupTextColor(const Color &rColor)
void SetMenuBarHighlightTextColor(const Color &rColor)
void SetDisableColor(const Color &rColor)
WEIGHT_NORMAL
void SetFieldColor(const Color &rColor)
void SetAppFont(const vcl::Font &rFont)
list_const_iterator_t find(const Key &key)
void SetRadioCheckTextColor(const Color &rColor)
o3tl::lru_map< OUString, gfx::DrawRoot > maThemeDrawCommandsCache
Definition: svdata.hxx:192
bool getAntiAliasB2DDraw() const
Definition: salgdi.hxx:84
void SetVisitedLinkColor(const Color &rColor)
bool hitTestNativeControl(ControlType eType, ControlPart ePart, const tools::Rectangle &rBoundingControlRegion, const Point &aPos, bool &rIsInside) override
Query if a position is inside the native widget part.
void SetLabelTextColor(const Color &rColor)
tools::Rectangle maThumbRect
void SetInactiveTabColor(const Color &rColor)
void SetToolFont(const vcl::Font &rFont)
void SetFloatTitleFont(const vcl::Font &rFont)
bool isNativeControlSupported(ControlType eType, ControlPart ePart) override
Query the platform layer for native control support.
double getCenterX() const
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
void SetTabTextColor(const Color &rColor)
void SetToolTextColor(const Color &rColor)
void SetGroupFont(const vcl::Font &rFont)
void SetPushButtonFont(const vcl::Font &rFont)
void SetFaceColor(const Color &rColor)
void SetLightBorderColor(const Color &rColor)
AlphaMask GetAlpha() const
Definition: bitmapex.cxx:268
void SetTitleFont(const vcl::Font &rFont)
bool mbNoFocusRects
Definition: svdata.hxx:280
void SetLabelFont(const vcl::Font &rFont)
bool mbProgressNeedsErase
Definition: svdata.hxx:285
void SetWorkspaceColor(const Color &rColor)
ControlState mnThumbState
FAMILY_SWISS
void setAntiAliasB2DDraw(bool bNew)
Definition: salgdi.hxx:83
Reference< XComponentContext > getProcessComponentContext()
void expand(long nExpandBy)
long Left() const
void SetHelpColor(const Color &rColor)
void SetActiveBorderColor(const Color &rColor)
void SetListBoxPreviewDefaultLogicSize(Size const &rSize)
void SetTabFont(const vcl::Font &rFont)
bool drawNativeControl(ControlType eType, ControlPart ePart, const tools::Rectangle &rBoundingControlRegion, ControlState eState, const ImplControlValue &aValue, const OUString &aCaptions) override
Draw the requested control.
void SetDeactiveTextColor(const Color &rColor)
void(* f)(TrueTypeTable *)
Definition: ttcr.cxx:481
void SetFieldTextColor(const Color &rColor)
void SetShadowColor(const Color &rColor)
void SetActiveTextColor(const Color &rColor)
void SetTabHighlightTextColor(const Color &rColor)
std::shared_ptr< WidgetDefinition > m_pWidgetDefinition
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
void SetHelpTextColor(const Color &rColor)
const Size & GetSizePixel() const
Definition: bitmapex.hxx:83
void SetWindowTextColor(const Color &rColor)
void SetHighlightTextColor(const Color &rColor)
void SetDarkShadowColor(const Color &rColor)
void SetFloatTitleHeight(long nSize)
void SetActiveColor(const Color &rColor)
bool mbCenteredTabs
Definition: svdata.hxx:282