summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-05-14 17:24:10 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-05-14 17:24:10 +0100
commit135755ed9e64d4208ef5b578c9b43ad23bb4ed66 (patch)
tree3a35d971418927ba816aaa943584bd4d32eefebf /vcl
parentf6a04cb509a2c12932c6be789fdc0cdb9d447aad (diff)
gtk3: shiny native focus rectangles for checkboxes
Change-Id: I4b70878700851cc13a20321a11703c93e3f8ed49
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/button.cxx31
-rw-r--r--vcl/source/control/ilstbox.cxx10
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx17
3 files changed, 39 insertions, 19 deletions
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index f6dec45595bc..75b2fe360723 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -1659,16 +1659,14 @@ bool PushButton::set_property(const OString &rKey, const OString &rValue)
void PushButton::ShowFocus(const Rectangle& rRect)
{
- bool bNativeOK;
- if ((bNativeOK = IsNativeControlSupported(CTRL_PUSHBUTTON, PART_FOCUS)))
+ if (IsNativeControlSupported(CTRL_PUSHBUTTON, PART_FOCUS))
{
ImplControlValue aControlValue;
Rectangle aInRect(Point(), GetOutputSizePixel());
- bNativeOK = GetOutDev()->DrawNativeControl(CTRL_PUSHBUTTON, PART_FOCUS, aInRect,
- ControlState::FOCUSED, aControlValue, OUString());
+ GetOutDev()->DrawNativeControl(CTRL_PUSHBUTTON, PART_FOCUS, aInRect,
+ ControlState::FOCUSED, aControlValue, OUString());
}
- if (!bNativeOK)
- Button::ShowFocus(rRect);
+ Button::ShowFocus(rRect);
}
void OKButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
@@ -3755,6 +3753,27 @@ Size CheckBox::GetOptimalSize() const
return CalcMinimumSize();
}
+void CheckBox::ShowFocus(const Rectangle& rRect)
+{
+ if (IsNativeControlSupported(CTRL_CHECKBOX, PART_FOCUS))
+ {
+ ImplControlValue aControlValue;
+ Rectangle aInRect(Point(0, 0), GetSizePixel());
+
+ aInRect.Left() = rRect.Left(); // exclude the checkbox itself from the focusrect
+
+ //to-do, figure out a better solution here
+ aInRect.Left()-=2;
+ aInRect.Right()+=2;
+ aInRect.Top()-=2;
+ aInRect.Bottom()+=2;
+
+ DrawNativeControl(CTRL_CHECKBOX, PART_FOCUS, aInRect,
+ ControlState::FOCUSED, aControlValue, OUString());
+ }
+ Button::ShowFocus(rRect);
+}
+
ImageButton::ImageButton( vcl::Window* pParent, WinBits nStyle ) :
PushButton( pParent, nStyle )
{
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index cb6f861d3d42..f44583cc5496 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -2891,18 +2891,16 @@ void ImplWin::LoseFocus()
void ImplWin::ShowFocus(const Rectangle& rRect)
{
- bool bNativeOK;
- if ((bNativeOK = IsNativeControlSupported(CTRL_LISTBOX, PART_FOCUS)))
+ if (IsNativeControlSupported(CTRL_LISTBOX, PART_FOCUS))
{
ImplControlValue aControlValue;
vcl::Window *pWin = GetParent();
Rectangle aParentRect(Point(0, 0), pWin->GetSizePixel());
- bNativeOK = pWin->DrawNativeControl(CTRL_LISTBOX, PART_FOCUS, aParentRect,
- ControlState::FOCUSED, aControlValue, OUString());
+ pWin->DrawNativeControl(CTRL_LISTBOX, PART_FOCUS, aParentRect,
+ ControlState::FOCUSED, aControlValue, OUString());
}
- if (!bNativeOK)
- Control::ShowFocus(rRect);
+ Control::ShowFocus(rRect);
}
ImplBtn::ImplBtn( vcl::Window* pParent, WinBits nWinStyle ) :
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index d05f86b27db0..9db5f72b9014 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -895,7 +895,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
GTK_STATE_FLAG_NORMAL));
context = mpCheckButtonStyle;
styleClass = GTK_STYLE_CLASS_CHECK;
- renderType = RENDER_CHECK;
+ renderType = nPart == PART_FOCUS ? RENDER_FOCUS : RENDER_CHECK;
break;
case CTRL_RADIOBUTTON:
flags = (GtkStateFlags)(flags |
@@ -1037,14 +1037,17 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
break;
case RENDER_FOCUS:
{
- GtkBorder border;
+ if (nType != CTRL_CHECKBOX)
+ {
+ GtkBorder border;
- gtk_style_context_get_border(context, flags, &border);
+ gtk_style_context_get_border(context, flags, &border);
- nX += border.left;
- nY += border.top;
- nWidth -= border.left + border.right;
- nHeight -= border.top + border.bottom;
+ nX += border.left;
+ nY += border.top;
+ nWidth -= border.left + border.right;
+ nHeight -= border.top + border.bottom;
+ }
gtk_render_focus(context, cr, nX, nY, nWidth, nHeight);