Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


There's a "face" colour hack that's being used for GTK+, KDE3, KDE4, CDE and Windows, with 
different comments, and written differently making it look as if there was a difference - there 
isn't as far as I can see.

Thusly I'm merging those into one function SetCheckedColorSpecialCase.

Notably OSX doesn't set the colour at all - a look from a Mac developer is probably a good idea.

ciao,
    Christian
From f302fdcf4c82a7529b658766c9bb4e063c687ef2 Mon Sep 17 00:00:00 2001
From: Christian Dywan <christian.dywan@lanedo.com>
Date: Thu, 28 Apr 2011 19:31:28 +0200
Subject: [PATCH] Unify light gray checked color special case

It's the same hack on all platforms using it.
---
 vcl/inc/vcl/settings.hxx                 |    1 +
 vcl/source/app/settings.cxx              |   15 +++++++++++++++
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx |   14 +-------------
 vcl/unx/kde/salnativewidgets-kde.cxx     |   12 +-----------
 vcl/unx/kde4/KDESalFrame.cxx             |   13 +------------
 vcl/unx/source/gdi/cdeint.cxx            |   12 +-----------
 vcl/win/source/window/salframe.cxx       |   14 +-------------
 7 files changed, 21 insertions(+), 60 deletions(-)

diff --git a/vcl/inc/vcl/settings.hxx b/vcl/inc/vcl/settings.hxx
index 4f16997..c9c0b3a 100644
--- a/vcl/inc/vcl/settings.hxx
+++ b/vcl/inc/vcl/settings.hxx
@@ -527,6 +527,7 @@ public:
     Color                           GetSeparatorColor() const;
     void                            SetCheckedColor( const Color& rColor )
                                         { CopyData(); mpData->maCheckedColor = rColor; }
+    void                            SetCheckedColorSpecialCase( );
     const Color&                    GetCheckedColor() const
                                         { return mpData->maCheckedColor; }
     void                            SetLightColor( const Color& rColor )
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 388a043..2250cf2 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -749,6 +749,21 @@ void StyleSettings::SetPreferredSymbolsStyleName( const ::rtl::OUString &rName 
)
     }
 }
 
+void StyleSettings::SetCheckedColorSpecialCase( )
+{
+    CopyData();
+    // Light gray checked color special case
+    if ( GetFaceColor() == COL_LIGHTGRAY )
+        mpData->maCheckedColor = Color( 0xCC, 0xCC, 0xCC );
+    else
+    {
+        sal_uInt8 nRed   = (sal_uInt8)(((sal_uInt16)mpData->maFaceColor.GetRed()   + 
(sal_uInt16)mpData->maLightColor.GetRed())/2);
+        sal_uInt8 nGreen = (sal_uInt8)(((sal_uInt16)mpData->maFaceColor.GetGreen() + 
(sal_uInt16)mpData->maLightColor.GetGreen())/2);
+        sal_uInt8 nBlue  = (sal_uInt8)(((sal_uInt16)mpData->maFaceColor.GetBlue()  + 
(sal_uInt16)mpData->maLightColor.GetBlue())/2);
+        mpData->maCheckedColor = Color( nRed, nGreen, nBlue );
+    }
+}
+
 // -----------------------------------------------------------------------
 
 sal_uLong StyleSettings::GetCurrentSymbolsStyle() const
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index 981d1be..bfc91ce 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -3293,19 +3293,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
     aStyleSet.SetWorkspaceColor( aBackColor );
     aStyleSet.SetFieldColor( aBackFieldColor );
     aStyleSet.SetWindowColor( aBackFieldColor );
-//    aStyleSet.SetHelpColor( aBackColor );
-    // ancient wisdom tells us a mystic algorithm how to set checked color
-    if( aBackColor == COL_LIGHTGRAY )
-        aStyleSet.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) );
-    else
-    {
-        Color aColor2 = aStyleSet.GetLightColor();
-        Color aCheck( 
(sal_uInt8)(((sal_uInt16)aBackColor.GetRed()+(sal_uInt16)aColor2.GetRed())/2),
-                      
(sal_uInt8)(((sal_uInt16)aBackColor.GetGreen()+(sal_uInt16)aColor2.GetGreen())/2),
-                      
(sal_uInt8)(((sal_uInt16)aBackColor.GetBlue()+(sal_uInt16)aColor2.GetBlue())/2)
-                      );
-        aStyleSet.SetCheckedColor( aCheck );
-    }
+    aStyleSet.SetCheckedColorSpecialCase( );
 
     // highlighting colors
     Color aHighlightColor = getColor( pStyle->base[GTK_STATE_SELECTED] );
diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx
index 5707586..1e93eaa 100644
--- a/vcl/unx/kde/salnativewidgets-kde.cxx
+++ b/vcl/unx/kde/salnativewidgets-kde.cxx
@@ -1926,17 +1926,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
     aStyleSettings.SetFaceColor( aBack );
     aStyleSettings.SetInactiveTabColor( aBack );
     aStyleSettings.SetDialogColor( aBack );
-    if( aBack == COL_LIGHTGRAY )
-        aStyleSettings.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) );
-    else
-    {
-        Color aColor2 = aStyleSettings.GetLightColor();
-        aStyleSettings.
-            SetCheckedColor( Color( 
(sal_uInt8)(((sal_uInt16)aBack.GetRed()+(sal_uInt16)aColor2.GetRed())/2),
-                        
(sal_uInt8)(((sal_uInt16)aBack.GetGreen()+(sal_uInt16)aColor2.GetGreen())/2),
-                        (sal_uInt8)(((sal_uInt16)aBack.GetBlue()+(sal_uInt16)aColor2.GetBlue())/2)
-                        ) );
-    }
+    aStyleSettings.SetCheckedColorSpecialCase( );
 
     // Selection
     aStyleSettings.SetHighlightColor( toColor( qColorGroup.highlight() ) );
diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx
index 68f9e5c..65204b0 100644
--- a/vcl/unx/kde4/KDESalFrame.cxx
+++ b/vcl/unx/kde4/KDESalFrame.cxx
@@ -263,18 +263,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
     style.SetFaceColor( aBack );
     style.SetInactiveTabColor( aBack );
     style.SetDialogColor( aBack );
-    
-    if( aBack == COL_LIGHTGRAY )
-        style.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) );
-    else
-    {
-        Color aColor2 = style.GetLightColor();
-        style.
-            SetCheckedColor( Color( 
(sal_uInt8)(((sal_uInt16)aBack.GetRed()+(sal_uInt16)aColor2.GetRed())/2),
-                        
(sal_uInt8)(((sal_uInt16)aBack.GetGreen()+(sal_uInt16)aColor2.GetGreen())/2),
-                        (sal_uInt8)(((sal_uInt16)aBack.GetBlue()+(sal_uInt16)aColor2.GetBlue())/2)
-                        ) );
-    }
+    style.SetCheckedColorSpecialCase( );
 
     // Selection
     style.SetHighlightColor( aHigh );
diff --git a/vcl/unx/source/gdi/cdeint.cxx b/vcl/unx/source/gdi/cdeint.cxx
index b222b84..8cf93af 100644
--- a/vcl/unx/source/gdi/cdeint.cxx
+++ b/vcl/unx/source/gdi/cdeint.cxx
@@ -226,17 +226,7 @@ void CDEIntegrator::GetSystemLook( AllSettings& rSettings )
         aStyleSettings.SetDialogColor( aColors[1] );
         aStyleSettings.SetMenuColor( aColors[1] );
         aStyleSettings.SetMenuBarColor( aColors[1] );
-        if ( aStyleSettings.GetFaceColor() == COL_LIGHTGRAY )
-            aStyleSettings.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) );
-        else
-        {
-            // calculate Checked color
-            Color   aColor2 = aStyleSettings.GetLightColor();
-            sal_uInt8    nRed    = (sal_uInt8)(((sal_uInt16)aColors[1].GetRed()   + 
(sal_uInt16)aColor2.GetRed())/2);
-            sal_uInt8    nGreen  = (sal_uInt8)(((sal_uInt16)aColors[1].GetGreen() + 
(sal_uInt16)aColor2.GetGreen())/2);
-            sal_uInt8    nBlue   = (sal_uInt8)(((sal_uInt16)aColors[1].GetBlue()  + 
(sal_uInt16)aColor2.GetBlue())/2);
-            aStyleSettings.SetCheckedColor( Color( nRed, nGreen, nBlue ) );
-        }
+        aStyleSettings.SetCheckedColorSpecialCase( );
     }
     rSettings.SetStyleSettings( aStyleSettings );
 }
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index 4ee94b3..eec5b2f 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -2943,19 +2943,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings )
         pSVData->maNWFData.maMenuBarHighlightTextColor = aStyleSettings.GetMenuTextColor();
         GetSalData()->mbThemeMenuSupport = TRUE;
     }
-    // Bei hellgrau geben wir die Farbe vor, damit es besser aussieht
-    if ( aStyleSettings.GetFaceColor() == COL_LIGHTGRAY )
-        aStyleSettings.SetCheckedColor( Color( 0xCC, 0xCC, 0xCC ) );
-    else
-    {
-        // Checked-Color berechnen
-        Color   aColor1 = aStyleSettings.GetFaceColor();
-        Color   aColor2 = aStyleSettings.GetLightColor();
-        BYTE    nRed    = (BYTE)(((sal_uInt16)aColor1.GetRed()   + 
(sal_uInt16)aColor2.GetRed())/2);
-        BYTE    nGreen  = (BYTE)(((sal_uInt16)aColor1.GetGreen() + 
(sal_uInt16)aColor2.GetGreen())/2);
-        BYTE    nBlue   = (BYTE)(((sal_uInt16)aColor1.GetBlue()  + 
(sal_uInt16)aColor2.GetBlue())/2);
-        aStyleSettings.SetCheckedColor( Color( nRed, nGreen, nBlue ) );
-    }
+    aStyleSettings.SetCheckedColorSpecialCase( );
 
     // caret width
     DWORD nCaretWidth = 2;
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.