Kaydet (Commit) abb9ce6c authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

Draw basic Editbox from the theme definition

Change-Id: Ib146426b0f1b15571b41f2b64c1b0ea0ce71c94d
Reviewed-on: https://gerrit.libreoffice.org/68657Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst be999e2e
...@@ -114,6 +114,8 @@ private: ...@@ -114,6 +114,8 @@ private:
void readPushButton(tools::XmlWalker& rWalker); void readPushButton(tools::XmlWalker& rWalker);
void readRadioButton(tools::XmlWalker& rWalker); void readRadioButton(tools::XmlWalker& rWalker);
void readEditbox(tools::XmlWalker& rWalker);
static void readDrawingDefinition(tools::XmlWalker& rWalker, static void readDrawingDefinition(tools::XmlWalker& rWalker,
std::shared_ptr<WidgetDefinitionState>& rStates); std::shared_ptr<WidgetDefinitionState>& rStates);
...@@ -171,9 +173,11 @@ public: ...@@ -171,9 +173,11 @@ public:
std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maPushButtonDefinitions; 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>> maRadioButtonDefinitions;
std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maEditboxDefinitions;
std::shared_ptr<WidgetDefinition> getPushButtonDefinition(ControlPart ePart); std::shared_ptr<WidgetDefinition> getPushButtonDefinition(ControlPart ePart);
std::shared_ptr<WidgetDefinition> getRadioButtonDefinition(ControlPart ePart); std::shared_ptr<WidgetDefinition> getRadioButtonDefinition(ControlPart ePart);
std::shared_ptr<WidgetDefinition> getEditboxDefinition(ControlPart ePart);
WidgetDefinitionReader(OUString const& rFilePath); WidgetDefinitionReader(OUString const& rFilePath);
bool read(); bool read();
......
...@@ -45,14 +45,15 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr ...@@ -45,14 +45,15 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr
{ {
case ControlType::Generic: case ControlType::Generic:
case ControlType::Pushbutton: case ControlType::Pushbutton:
return true;
case ControlType::Radiobutton: case ControlType::Radiobutton:
return true; return true;
case ControlType::Checkbox: case ControlType::Checkbox:
case ControlType::Combobox: case ControlType::Combobox:
return false;
case ControlType::Editbox: case ControlType::Editbox:
case ControlType::EditboxNoBorder: case ControlType::EditboxNoBorder:
case ControlType::MultilineEditbox: case ControlType::MultilineEditbox:
return true;
case ControlType::Listbox: case ControlType::Listbox:
case ControlType::Spinbox: case ControlType::Spinbox:
case ControlType::SpinButtons: case ControlType::SpinButtons:
...@@ -196,9 +197,24 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ...@@ -196,9 +197,24 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
break; break;
case ControlType::Checkbox: case ControlType::Checkbox:
case ControlType::Combobox: case ControlType::Combobox:
break;
case ControlType::Editbox: case ControlType::Editbox:
case ControlType::EditboxNoBorder: case ControlType::EditboxNoBorder:
case ControlType::MultilineEditbox: 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::Listbox:
case ControlType::Spinbox: case ControlType::Spinbox:
case ControlType::SpinButtons: case ControlType::SpinButtons:
......
...@@ -174,6 +174,11 @@ void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker) ...@@ -174,6 +174,11 @@ void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker)
readDefinition(rWalker, maRadioButtonDefinitions); readDefinition(rWalker, maRadioButtonDefinitions);
} }
void WidgetDefinitionReader::readEditbox(tools::XmlWalker& rWalker)
{
readDefinition(rWalker, maEditboxDefinitions);
}
bool WidgetDefinitionReader::read() bool WidgetDefinitionReader::read()
{ {
if (!lcl_fileExists(m_rFilePath)) if (!lcl_fileExists(m_rFilePath))
...@@ -266,6 +271,10 @@ bool WidgetDefinitionReader::read() ...@@ -266,6 +271,10 @@ bool WidgetDefinitionReader::read()
{ {
readRadioButton(aWalker); readRadioButton(aWalker);
} }
else if (aWalker.name() == "editbox")
{
readEditbox(aWalker);
}
aWalker.next(); aWalker.next();
} }
aWalker.parent(); aWalker.parent();
...@@ -377,6 +386,15 @@ WidgetDefinitionReader::getRadioButtonDefinition(ControlPart ePart) ...@@ -377,6 +386,15 @@ WidgetDefinitionReader::getRadioButtonDefinition(ControlPart ePart)
return std::shared_ptr<WidgetDefinition>(); 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>> std::vector<std::shared_ptr<WidgetDefinitionState>>
WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue) WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue)
{ {
...@@ -457,7 +475,7 @@ void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStro ...@@ -457,7 +475,7 @@ void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStro
void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth,
Color aFillColor, sal_Int32 nMargin) 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->maStrokeColor = aStrokeColor;
pCommand->maFillColor = aFillColor; pCommand->maFillColor = aFillColor;
pCommand->mnStrokeWidth = nStrokeWidth; pCommand->mnStrokeWidth = nStrokeWidth;
......
...@@ -78,4 +78,12 @@ ...@@ -78,4 +78,12 @@
</part> </part>
</radiobutton> </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> </widgets>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment