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

Draw basic spinbox from the theme definition

Change-Id: I9b8379846a82f51365da7e7e2fd63cc21eb575a2
Reviewed-on: https://gerrit.libreoffice.org/68714Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 25709fb4
......@@ -65,7 +65,11 @@ bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, Contr
case ControlType::MultilineEditbox:
return true;
case ControlType::Listbox:
return false;
case ControlType::Spinbox:
if (ePart == ControlPart::AllButtons)
return false;
return true;
case ControlType::SpinButtons:
case ControlType::TabItem:
case ControlType::TabPane:
......@@ -301,7 +305,71 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
}
break;
case ControlType::Listbox:
break;
case ControlType::Spinbox:
{
if (rValue.getType() == ControlType::SpinButtons)
{
const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue*>(&rValue);
ControlPart eUpButtonPart = pSpinVal->mnUpperPart;
ControlState eUpButtonState = pSpinVal->mnUpperState;
ControlPart eDownButtonPart = pSpinVal->mnLowerPart;
ControlState eDownButtonState = pSpinVal->mnLowerState;
{
std::shared_ptr<WidgetDefinitionPart> pPart
= m_aWidgetDefinition.getDefinition(eType, eUpButtonPart);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eUpButtonState, ImplControlValue()).back();
{
munchDrawCommands(
pState->mpDrawCommands, m_rGraphics, pSpinVal->maUpperRect.Left(),
pSpinVal->maUpperRect.Top(), pSpinVal->maUpperRect.GetWidth() - 1,
pSpinVal->maUpperRect.GetHeight() - 1);
bOK = true;
}
}
}
if (bOK)
{
std::shared_ptr<WidgetDefinitionPart> pPart
= m_aWidgetDefinition.getDefinition(eType, eDownButtonPart);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eDownButtonState, ImplControlValue()).back();
{
munchDrawCommands(
pState->mpDrawCommands, m_rGraphics, pSpinVal->maLowerRect.Left(),
pSpinVal->maLowerRect.Top(), pSpinVal->maLowerRect.GetWidth() - 1,
pSpinVal->maLowerRect.GetHeight() - 1);
bOK = true;
}
}
}
}
else
{
std::shared_ptr<WidgetDefinitionPart> pPart
= m_aWidgetDefinition.getDefinition(eType, ePart);
if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
= pPart->getStates(eState, ImplControlValue()).back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth,
nHeight);
bOK = true;
}
}
}
}
break;
case ControlType::SpinButtons:
case ControlType::TabItem:
case ControlType::TabPane:
......@@ -334,12 +402,53 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
}
bool FileDefinitionWidgetDraw::getNativeControlRegion(
ControlType eType, ControlPart /*ePart*/, const tools::Rectangle& /*rBoundingControlRegion*/,
ControlType eType, ControlPart ePart, const tools::Rectangle& rBoundingControlRegion,
ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/,
tools::Rectangle& /*rNativeBoundingRegion*/, tools::Rectangle& rNativeContentRegion)
tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion)
{
switch (eType)
{
case ControlType::Spinbox:
{
Size aButtonSize(44, 26);
Point aLocation(rBoundingControlRegion.TopLeft());
if (ePart == ControlPart::ButtonUp)
{
rNativeContentRegion = tools::Rectangle(
Point(aLocation.X() + rBoundingControlRegion.GetWidth() - aButtonSize.Width(),
aLocation.Y()),
aButtonSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::ButtonDown)
{
rNativeContentRegion
= tools::Rectangle(Point(aLocation.X() + rBoundingControlRegion.GetWidth()
- (2 * aButtonSize.Width()),
aLocation.Y()),
aButtonSize);
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::SubEdit)
{
rNativeContentRegion = tools::Rectangle(
aLocation, Size(rBoundingControlRegion.GetWidth() - (2 * aButtonSize.Width()),
aButtonSize.Height()));
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
else if (ePart == ControlPart::Entire)
{
rNativeContentRegion = tools::Rectangle(
aLocation, Size(rBoundingControlRegion.GetWidth(), aButtonSize.Height()));
rNativeBoundingRegion = rNativeContentRegion;
return true;
}
}
break;
case ControlType::Checkbox:
rNativeContentRegion = tools::Rectangle(Point(), Size(44, 26));
return true;
......
......@@ -158,6 +158,11 @@ bool getControlTypeForXmlString(OString const& rString, ControlType& reType)
reType = ControlType::Combobox;
bReturn = true;
}
else if (rString == "spinbox")
{
reType = ControlType::Spinbox;
bReturn = true;
}
return bReturn;
}
......
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