vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 23 +++++++++- vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 44 ++++++++++++++++++- vcl/source/gdi/WidgetDefinitionReader.cxx | 59 +++++++++++++++++++++++++- vcl/uiconfig/theme_definitions/definition.xml | 8 +++ 4 files changed, 131 insertions(+), 3 deletions(-)
New commits: commit a31aea4355c32d44ae7584eedc5e6fc71bc5c233 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Fri Jan 25 16:43:54 2019 +0100 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Mar 4 12:31:42 2019 +0100 support drawing a line in theme definition Change-Id: I5cd861714a98ede80ab46e41d6d3638bdd5da97e Reviewed-on: https://gerrit.libreoffice.org/68669 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx index 5a53621c9c58..77548c72aa0c 100644 --- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx +++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx @@ -25,7 +25,8 @@ namespace vcl enum class DrawCommandType { RECTANGLE, - CIRCLE + CIRCLE, + LINE }; class VCL_DLLPUBLIC DrawCommand @@ -69,6 +70,20 @@ public: } }; +class VCL_DLLPUBLIC LineDrawCommand : public DrawCommand +{ +public: + float mfX1; + float mfY1; + float mfX2; + float mfY2; + + LineDrawCommand() + : DrawCommand(DrawCommandType::LINE) + { + } +}; + class VCL_DLLPUBLIC WidgetDefinitionState { public: @@ -90,6 +105,8 @@ public: sal_Int32 nRx, sal_Int32 nRy, sal_Int32 nMargin); void addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, sal_Int32 nMargin); + void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2, + float fY2); }; class VCL_DLLPUBLIC WidgetDefinition diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 2e3822d6c05d..600b736c3c7c 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -133,6 +133,32 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f, nullptr); } break; + case DrawCommandType::LINE: + { + auto const& rLineDrawCommand = static_cast<LineDrawCommand const&>(*pDrawCommand); + Point aRectPoint(nX + 1 + rLineDrawCommand.mnMargin, + nY + 1 + rLineDrawCommand.mnMargin); + + Size aRectSize(nWidth - 1 - 2 * rLineDrawCommand.mnMargin, + nHeight - 1 - 2 * rLineDrawCommand.mnMargin); + + rGraphics.SetFillColor(); + rGraphics.SetLineColor(rLineDrawCommand.maStrokeColor); + + basegfx::B2DPolygon aB2DPolygon{ + { aRectPoint.X() + (aRectSize.Width() * rLineDrawCommand.mfX1), + aRectPoint.Y() + (aRectSize.Height() * rLineDrawCommand.mfY1) }, + { aRectPoint.X() + (aRectSize.Width() * rLineDrawCommand.mfX2), + aRectPoint.Y() + (aRectSize.Height() * rLineDrawCommand.mfY2) }, + }; + + rGraphics.DrawPolyLine(basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f, + basegfx::B2DVector(rLineDrawCommand.mnStrokeWidth, + rLineDrawCommand.mnStrokeWidth), + basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, + 0.0f, false, nullptr); + } + break; } } } diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index 37053a56b877..3a8848f50617 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -114,6 +114,31 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker, rpState->addDrawCircle(aStrokeColor, nStrokeWidth, aFillColor, nMargin); } + else if (rWalker.name() == "line") + { + Color aStrokeColor; + readColor(rWalker.attribute("stroke"), aStrokeColor); + + OString sStrokeWidth = rWalker.attribute("stroke-width"); + sal_Int32 nStrokeWidth = -1; + if (!sStrokeWidth.isEmpty()) + nStrokeWidth = sStrokeWidth.toInt32(); + + OString sX1 = rWalker.attribute("x1"); + float fX1 = sX1.isEmpty() ? -1.0 : sX1.toFloat(); + + OString sY1 = rWalker.attribute("y1"); + float fY1 = sY1.isEmpty() ? -1.0 : sY1.toFloat(); + + OString sX2 = rWalker.attribute("x2"); + float fX2 = sX2.isEmpty() ? -1.0 : sX2.toFloat(); + + OString sY2 = rWalker.attribute("y2"); + float fY2 = sY2.isEmpty() ? -1.0 : sY2.toFloat(); + + rpState->addDrawLine(aStrokeColor, nStrokeWidth, fX1, fY1, fX2, fY2); + } + rWalker.next(); } rWalker.parent(); @@ -483,6 +508,20 @@ void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeW mpDrawCommands.push_back(std::move(pCommand)); } +void WidgetDefinitionState::addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, + float fY1, float fX2, float fY2) +{ + std::shared_ptr<DrawCommand> pCommand(std::make_shared<LineDrawCommand>()); + pCommand->maStrokeColor = aStrokeColor; + pCommand->mnStrokeWidth = nStrokeWidth; + LineDrawCommand& rLineCommand = static_cast<LineDrawCommand&>(*pCommand); + rLineCommand.mfX1 = fX1; + rLineCommand.mfY1 = fY1; + rLineCommand.mfX2 = fX2; + rLineCommand.mfY2 = fY2; + mpDrawCommands.push_back(std::move(pCommand)); +} + } // end vcl namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit abb9ce6c6eddfc7c13ce6a6caf0dcedab6c90ec4 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Thu Jan 24 18:00:47 2019 +0100 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Mon Mar 4 12:31:29 2019 +0100 Draw basic Editbox from the theme definition Change-Id: Ib146426b0f1b15571b41f2b64c1b0ea0ce71c94d Reviewed-on: https://gerrit.libreoffice.org/68657 Reviewed-by: Tomaž Vajngerl <[email protected]> Tested-by: Tomaž Vajngerl <[email protected]> diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx index 2f06c4ffa78a..5a53621c9c58 100644 --- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx +++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx @@ -114,6 +114,8 @@ private: void readPushButton(tools::XmlWalker& rWalker); void readRadioButton(tools::XmlWalker& rWalker); + void readEditbox(tools::XmlWalker& rWalker); + static void readDrawingDefinition(tools::XmlWalker& rWalker, std::shared_ptr<WidgetDefinitionState>& rStates); @@ -171,9 +173,11 @@ public: std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maPushButtonDefinitions; std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maRadioButtonDefinitions; + std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maEditboxDefinitions; std::shared_ptr<WidgetDefinition> getPushButtonDefinition(ControlPart ePart); std::shared_ptr<WidgetDefinition> getRadioButtonDefinition(ControlPart ePart); + std::shared_ptr<WidgetDefinition> getEditboxDefinition(ControlPart ePart); WidgetDefinitionReader(OUString const& rFilePath); bool read(); diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 2ada75fa7477..2e3822d6c05d 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -45,14 +45,15 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr { case ControlType::Generic: case ControlType::Pushbutton: - return true; case ControlType::Radiobutton: return true; case ControlType::Checkbox: case ControlType::Combobox: + return false; case ControlType::Editbox: case ControlType::EditboxNoBorder: case ControlType::MultilineEditbox: + return true; case ControlType::Listbox: case ControlType::Spinbox: case ControlType::SpinButtons: @@ -196,9 +197,24 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart break; case ControlType::Checkbox: case ControlType::Combobox: + break; case ControlType::Editbox: case ControlType::EditboxNoBorder: case ControlType::MultilineEditbox: + { + std::shared_ptr<WidgetDefinition> pDefinition + = m_WidgetDefinitionReader.getEditboxDefinition(ePart); + if (pDefinition) + { + std::shared_ptr<WidgetDefinitionState> pState + = pDefinition->getStates(eState, rValue).back(); + { + munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight); + bOK = true; + } + } + } + break; case ControlType::Listbox: case ControlType::Spinbox: case ControlType::SpinButtons: diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index 84db52e68ddc..37053a56b877 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -174,6 +174,11 @@ void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker) readDefinition(rWalker, maRadioButtonDefinitions); } +void WidgetDefinitionReader::readEditbox(tools::XmlWalker& rWalker) +{ + readDefinition(rWalker, maEditboxDefinitions); +} + bool WidgetDefinitionReader::read() { if (!lcl_fileExists(m_rFilePath)) @@ -266,6 +271,10 @@ bool WidgetDefinitionReader::read() { readRadioButton(aWalker); } + else if (aWalker.name() == "editbox") + { + readEditbox(aWalker); + } aWalker.next(); } aWalker.parent(); @@ -377,6 +386,15 @@ WidgetDefinitionReader::getRadioButtonDefinition(ControlPart ePart) return std::shared_ptr<WidgetDefinition>(); } +std::shared_ptr<WidgetDefinition> WidgetDefinitionReader::getEditboxDefinition(ControlPart ePart) +{ + auto aIterator = maEditboxDefinitions.find(xmlControlPart(ePart)); + + if (aIterator != maEditboxDefinitions.end()) + return aIterator->second; + return std::shared_ptr<WidgetDefinition>(); +} + std::vector<std::shared_ptr<WidgetDefinitionState>> WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue) { @@ -457,7 +475,7 @@ void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStro void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor, sal_Int32 nMargin) { - std::unique_ptr<DrawCommand> pCommand(std::make_unique<CircleDrawCommand>()); + std::shared_ptr<DrawCommand> pCommand(std::make_shared<CircleDrawCommand>()); pCommand->maStrokeColor = aStrokeColor; pCommand->maFillColor = aFillColor; pCommand->mnStrokeWidth = nStrokeWidth; diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml index ac4718d10953..2bd0212007ee 100644 --- a/vcl/uiconfig/theme_definitions/definition.xml +++ b/vcl/uiconfig/theme_definitions/definition.xml @@ -78,4 +78,12 @@ </part> </radiobutton> + <editbox> + <part value="Entire"> + <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any"> + <rect stroke="#C7C7C7" fill="#FFFFFF" stroke-width="1" rx="5" ry="5" margin="0"/> + </state> + </part> + </editbox> + </widgets> _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
