From b07a71e09a129e37131574c7247be80c5fd112a8 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 23 Jan 2019 00:58:23 +0100 Subject: Add support for button-value to correctly draw the radiobutton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I392289f0ab284aec2ed0fb039a03fb93bf0b4aad Reviewed-on: https://gerrit.libreoffice.org/68654 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 6 ++++-- vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 16 ++++++++++------ vcl/source/gdi/WidgetDefinitionReader.cxx | 24 +++++++++++++++++++----- vcl/uiconfig/theme_definitions/definition.xml | 9 ++++----- 4 files changed, 37 insertions(+), 18 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx index e88ebac924be..01deaee91eb6 100644 --- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx +++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx @@ -78,10 +78,11 @@ public: OString msRollover; OString msDefault; OString msSelected; + OString msButtonValue; WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed, OString const& sRollover, OString const& sDefault, - OString const& sSelected); + OString const& sSelected, OString const& sButtonValue); std::vector> mpDrawCommands; @@ -94,7 +95,8 @@ public: class VCL_DLLPUBLIC WidgetDefinition { public: - std::vector> getStates(ControlState eState); + std::vector> getStates(ControlState eState, + ImplControlValue const& rValue); std::vector> maStates; }; diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 55f556349a78..2ada75fa7477 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -141,7 +141,7 @@ void munchDrawCommands(std::vector> const& rDrawCom bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ePart, const tools::Rectangle& rControlRegion, ControlState eState, - const ImplControlValue& /*rValue*/, + const ImplControlValue& rValue, const OUString& /*aCaptions*/) { bool bOldAA = m_rGraphics.getAntiAliasB2DDraw(); @@ -166,11 +166,15 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart = m_WidgetDefinitionReader.getPushButtonDefinition(ePart); if (pDefinition) { - std::shared_ptr pState - = pDefinition->getStates(eState).back(); + auto aStates = pDefinition->getStates(eState, rValue); + if (!aStates.empty()) { - munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight); - bOK = true; + std::shared_ptr pState = aStates.back(); + { + munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, + nHeight); + bOK = true; + } } } } @@ -182,7 +186,7 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart if (pDefinition) { std::shared_ptr pState - = pDefinition->getStates(eState).back(); + = pDefinition->getStates(eState, rValue).back(); { munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight); bOK = true; diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx index 85276e3a35e8..edab7b75ae4a 100644 --- a/vcl/source/gdi/WidgetDefinitionReader.cxx +++ b/vcl/source/gdi/WidgetDefinitionReader.cxx @@ -140,10 +140,12 @@ void WidgetDefinitionReader::readPushButton(tools::XmlWalker& rWalker) OString sRollover = rWalker.attribute("rollover"); OString sDefault = rWalker.attribute("default"); OString sSelected = rWalker.attribute("selected"); + OString sButtonValue = rWalker.attribute("button-value"); std::shared_ptr pState = std::make_shared(sEnabled, sFocused, sPressed, - sRollover, sDefault, sSelected); + sRollover, sDefault, sSelected, + sButtonValue); pPart->maStates.push_back(pState); readDrawingDefinition(rWalker, pState); } @@ -177,10 +179,12 @@ void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker) OString sRollover = rWalker.attribute("rollover"); OString sDefault = rWalker.attribute("default"); OString sSelected = rWalker.attribute("selected"); - + OString sButtonValue = rWalker.attribute("button-value"); + sButtonValue = sButtonValue.isEmpty() ? "any" : sButtonValue; std::shared_ptr pState = std::make_shared(sEnabled, sFocused, sPressed, - sRollover, sDefault, sSelected); + sRollover, sDefault, sSelected, + sButtonValue); pPart->maStates.push_back(pState); readDrawingDefinition(rWalker, pState); } @@ -396,7 +400,8 @@ WidgetDefinitionReader::getRadioButtonDefinition(ControlPart ePart) return std::shared_ptr(); } -std::vector> WidgetDefinition::getStates(ControlState eState) +std::vector> +WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue) { std::vector> aStatesToAdd; @@ -429,6 +434,13 @@ std::vector> WidgetDefinition::getStates( || (state->msSelected == "false" && !(eState & ControlState::SELECTED)))) bAdd = false; + ButtonValue eButtonValue = rValue.getTristateVal(); + + if (state->msButtonValue != "any" + && !((state->msButtonValue == "true" && eButtonValue == ButtonValue::On) + || (state->msButtonValue == "false" && eButtonValue != ButtonValue::On))) + bAdd = false; + if (bAdd) aStatesToAdd.push_back(state); } @@ -438,13 +450,15 @@ std::vector> WidgetDefinition::getStates( WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed, OString const& sRollover, - OString const& sDefault, OString const& sSelected) + OString const& sDefault, OString const& sSelected, + OString const& sButtonValue) : msEnabled(sEnabled) , msFocused(sFocused) , msPressed(sPressed) , msRollover(sRollover) , msDefault(sDefault) , msSelected(sSelected) + , msButtonValue(sButtonValue) { } diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml index 9ee8838fa705..ac4718d10953 100644 --- a/vcl/uiconfig/theme_definitions/definition.xml +++ b/vcl/uiconfig/theme_definitions/definition.xml @@ -56,11 +56,11 @@ - + - + @@ -68,11 +68,10 @@ - + - - + -- cgit