diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-01-24 18:00:47 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-03-04 12:31:29 +0100 |
commit | abb9ce6c6eddfc7c13ce6a6caf0dcedab6c90ec4 (patch) | |
tree | eb3907f4079fc992d7383bf6ab208a2e3bf3dfe7 | |
parent | be999e2ec2e5f3bd6875f6e4c9a0811e0a23283f (diff) |
Draw basic Editbox from the theme definition
Change-Id: Ib146426b0f1b15571b41f2b64c1b0ea0ce71c94d
Reviewed-on: https://gerrit.libreoffice.org/68657
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/WidgetDefinitionReader.cxx | 20 | ||||
-rw-r--r-- | vcl/uiconfig/theme_definitions/definition.xml | 8 |
4 files changed, 48 insertions, 2 deletions
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> |