[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Thu May 14 09:25:18 PDT 2015


 include/vcl/button.hxx                        |    1 
 vcl/source/control/button.cxx                 |   31 ++++++++++++++++++++------
 vcl/source/control/ilstbox.cxx                |   10 +++-----
 vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx |   17 ++++++++------
 4 files changed, 40 insertions(+), 19 deletions(-)

New commits:
commit 135755ed9e64d4208ef5b578c9b43ad23bb4ed66
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 14 17:24:10 2015 +0100

    gtk3: shiny native focus rectangles for checkboxes
    
    Change-Id: I4b70878700851cc13a20321a11703c93e3f8ed49

diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index 18b56e0..ef64257 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -495,6 +495,7 @@ public:
     void            SetLegacyNoTextAlign( bool bVal ) { mbLegacyNoTextAlign = bVal; }
 
     virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
+    virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
 };
 
 inline void CheckBox::Check( bool bCheck )
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index f6dec45..75b2fe3 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 cb6f861..f44583c 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 d05f86b..9db5f72 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);
 


More information about the Libreoffice-commits mailing list