Add support for button-value to correctly draw the radiobutton
Change-Id: I392289f0ab284aec2ed0fb039a03fb93bf0b4aad Reviewed-on: https://gerrit.libreoffice.org/68654 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
parent
2e77a44ea1
commit
b07a71e09a
@ -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<std::shared_ptr<DrawCommand>> mpDrawCommands;
|
||||
|
||||
@ -94,7 +95,8 @@ public:
|
||||
class VCL_DLLPUBLIC WidgetDefinition
|
||||
{
|
||||
public:
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState);
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
|
||||
ImplControlValue const& rValue);
|
||||
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
|
||||
};
|
||||
|
@ -141,7 +141,7 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> 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<WidgetDefinitionState> 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<WidgetDefinitionState> 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<WidgetDefinitionState> pState
|
||||
= pDefinition->getStates(eState).back();
|
||||
= pDefinition->getStates(eState, rValue).back();
|
||||
{
|
||||
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
|
||||
bOK = true;
|
||||
|
@ -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<WidgetDefinitionState> pState
|
||||
= std::make_shared<WidgetDefinitionState>(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<WidgetDefinitionState> pState
|
||||
= std::make_shared<WidgetDefinitionState>(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<WidgetDefinition>();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> WidgetDefinition::getStates(ControlState eState)
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>>
|
||||
WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue)
|
||||
{
|
||||
std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
|
||||
|
||||
@ -429,6 +434,13 @@ std::vector<std::shared_ptr<WidgetDefinitionState>> 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<std::shared_ptr<WidgetDefinitionState>> 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,11 @@
|
||||
|
||||
<pushbutton>
|
||||
<part value="Entire">
|
||||
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any">
|
||||
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
|
||||
<rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="5" ry="5" margin="0"/>
|
||||
</state>
|
||||
|
||||
<state enabled="true" focused="any" pressed="any" rollover="true" default="any" selected="any">
|
||||
<state enabled="true" focused="any" pressed="any" rollover="true" default="any" selected="any" button-value="any">
|
||||
<rect stroke="#007AFF" fill="#007AFF" stroke-width="1" rx="5" ry="5" margin="0"/>
|
||||
</state>
|
||||
</part>
|
||||
@ -68,11 +68,10 @@
|
||||
|
||||
<radiobutton>
|
||||
<part value="Entire">
|
||||
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any">
|
||||
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="false">
|
||||
<circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/>
|
||||
<circ stroke="#007AFF" fill="#007AFF" stroke-width="1" margin="3"/>
|
||||
</state>
|
||||
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any">
|
||||
<state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="true">
|
||||
<circ stroke="#007AFF" fill="#FFFFFF" stroke-width="1" margin="0"/>
|
||||
<circ stroke="#007AFF" fill="#007AFF" stroke-width="1" margin="3"/>
|
||||
</state>
|
||||
|
Loading…
x
Reference in New Issue
Block a user