summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-07-17 13:48:01 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-07-17 15:32:28 +0100
commitaff838877219f0dddd3c84788cb2fdcbc42d3285 (patch)
tree65515747626f94b675a2bdbf1e1c5c01b420b104 /vcl
parentf7024571be935d3ed7549325cf35eac29df1711f (diff)
allow radiobuttons and checkbox images to be aligned from .ui
Change-Id: Iee7b970344ac85e4b8ce51f1c3b5ae6605c05843
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/button.cxx60
-rw-r--r--vcl/source/window/builder.cxx5
2 files changed, 48 insertions, 17 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 74542e68c401..f4b43517bae6 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -605,6 +605,47 @@ bool Button::IsSmallSymbol () const
return mpButtonData->mbSmallSymbol;
}
+bool Button::set_property(const OString &rKey, const OString &rValue)
+{
+ if (rKey == "image-position")
+ {
+ ImageAlign eAlign = IMAGEALIGN_LEFT;
+ WinBits nBits = GetStyle();
+ if (rValue == "left")
+ {
+ nBits &= ~(WB_CENTER | WB_RIGHT);
+ nBits |= WB_LEFT;
+ eAlign = IMAGEALIGN_LEFT;
+ }
+ else if (rValue == "right")
+ {
+ nBits &= ~(WB_CENTER | WB_LEFT);
+ nBits |= WB_RIGHT;
+ eAlign = IMAGEALIGN_RIGHT;
+ }
+ else if (rValue == "top")
+ {
+ nBits &= ~(WB_VCENTER | WB_BOTTOM);
+ nBits |= WB_TOP;
+ eAlign = IMAGEALIGN_TOP;
+ }
+ else if (rValue == "bottom")
+ {
+ nBits &= ~(WB_VCENTER | WB_TOP);
+ nBits |= WB_BOTTOM;
+ eAlign = IMAGEALIGN_BOTTOM;
+ }
+ SetImageAlign(eAlign);
+ //Its rather mad to have to set these bits when there is the other
+ //image align. Looks like e.g. the radiobuttons etc weren't converted
+ //over to image align fully.
+ SetStyle(nBits);
+ }
+ else
+ return Control::set_property(rKey, rValue);
+ return true;
+}
+
// =======================================================================
void PushButton::ImplInitPushButtonData()
@@ -1720,21 +1761,8 @@ bool PushButton::set_property(const OString &rKey, const OString &rValue)
nBits |= WB_DEFBUTTON;
SetStyle(nBits);
}
- else if (rKey == "image-position")
- {
- ImageAlign eAlign = IMAGEALIGN_LEFT;
- if (rValue == "left")
- eAlign = IMAGEALIGN_LEFT;
- else if (rValue == "right")
- eAlign = IMAGEALIGN_RIGHT;
- else if (rValue == "top")
- eAlign = IMAGEALIGN_TOP;
- else if (rValue == "bottom")
- eAlign = IMAGEALIGN_BOTTOM;
- SetImageAlign(eAlign);
- }
else
- return Control::set_property(rKey, rValue);
+ return Button::set_property(rKey, rValue);
return true;
}
@@ -2859,7 +2887,7 @@ bool RadioButton::set_property(const OString &rKey, const OString &rValue)
if (rKey == "active")
SetState(toBool(rValue));
else
- return Window::set_property(rKey, rValue);
+ return Button::set_property(rKey, rValue);
return true;
}
@@ -3805,7 +3833,7 @@ bool CheckBox::set_property(const OString &rKey, const OString &rValue)
if (rKey == "active")
SetState(toBool(rValue) ? STATE_CHECK : STATE_NOCHECK);
else
- return Window::set_property(rKey, rValue);
+ return Button::set_property(rKey, rValue);
return true;
}
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 8fa72eeab255..a0bfcecfc183 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1138,7 +1138,9 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
OString sWrap = extractCustomProperty(rMap);
if (!sWrap.isEmpty())
nBits |= WB_WORDBREAK;
- pWindow = new RadioButton(pParent, nBits);
+ RadioButton *pButton = new RadioButton(pParent, nBits);
+ pButton->SetImageAlign(IMAGEALIGN_LEFT); //default to left
+ pWindow = pButton;
}
else if (name == "GtkCheckButton")
{
@@ -1153,6 +1155,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri
new CheckBox(pParent, nBits);
if (bIsTriState)
pCheckBox->SetState(STATE_DONTKNOW);
+ pCheckBox->SetImageAlign(IMAGEALIGN_LEFT); //default to left
pWindow = pCheckBox;
}
else if (name == "GtkSpinButton")