]> git.saurik.com Git - wxWidgets.git/blobdiff - src/ribbon/art_msw.cpp
New build slave for wxQt
[wxWidgets.git] / src / ribbon / art_msw.cpp
index 5f70558798991c33076f5577971d595ea60bbf11..4041079aeb6bc082697b621185890193355133c5 100644 (file)
     #pragma hdrstop
 #endif
 
-#include "wx/ribbon/art.h"
-
 #if wxUSE_RIBBON
 
+#include "wx/ribbon/art.h"
 #include "wx/ribbon/art_internal.h"
 #include "wx/ribbon/bar.h"
 #include "wx/ribbon/buttonbar.h"
@@ -26,6 +25,7 @@
 #include "wx/ribbon/toolbar.h"
 
 #ifndef WX_PRECOMP
+#include "wx/dcmemory.h"
 #endif
 
 #ifdef __WXMSW__
@@ -85,7 +85,7 @@ static const char* const gallery_extension_xpm[] = {
 wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme)
 {
     m_flags = 0;
-    m_tab_label_font = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE);
+    m_tab_label_font = *wxNORMAL_FONT;
     m_button_bar_label_font = m_tab_label_font;
     m_panel_label_font = m_tab_label_font;
 
@@ -143,21 +143,38 @@ void wxRibbonMSWArtProvider::SetColourScheme(
     // tertiary not used for anything
 
     // Map primary saturation from [0, 1] to [.25, .75]
-    primary_hsl.saturation = cos(primary_hsl.saturation * M_PI) * -0.25 + 0.5;
+    bool primary_is_gray = false;
+    const float gray_saturation_threshold = 0.01;
+    if(primary_hsl.saturation <= gray_saturation_threshold)
+        primary_is_gray = true;
+    else
+    {
+        primary_hsl.saturation = cos(primary_hsl.saturation * M_PI)
+            * -0.25 + 0.5;
+    }
 
     // Map primary luminance from [0, 1] to [.23, .83]
     primary_hsl.luminance = cos(primary_hsl.luminance * M_PI) * -0.3 + 0.53;
 
     // Map secondary saturation from [0, 1] to [0.16, 0.84]
-    secondary_hsl.saturation = cos(secondary_hsl.saturation * M_PI) * -0.34 + 0.5;
+    bool secondary_is_gray = false;
+    if(secondary_hsl.saturation <= gray_saturation_threshold)
+        secondary_is_gray = true;
+    else
+    {
+        secondary_hsl.saturation = cos(secondary_hsl.saturation * M_PI)
+            * -0.34 + 0.5;
+    }
 
     // Map secondary luminance from [0, 1] to [0.1, 0.9]
     secondary_hsl.luminance = cos(secondary_hsl.luminance * M_PI) * -0.4 + 0.5;
 
 #define LikePrimary(h, s, l) \
-    primary_hsl.ShiftHue(h ## f).Saturated(s ## f).Lighter(l ## f).ToRGB()
+    primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
+    .Lighter(l ## f).ToRGB()
 #define LikeSecondary(h, s, l) \
-    secondary_hsl.ShiftHue(h ## f).Saturated(s ## f).Lighter(l ## f).ToRGB()
+    secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
+    .Lighter(l ## f).ToRGB()
 
     m_page_border_pen = LikePrimary(1.4, 0.00, -0.08);
 
@@ -1931,10 +1948,9 @@ void wxRibbonMSWArtProvider::DrawPartialPageBackground(
     wxPoint offset(wnd->GetPosition());
     wxRibbonPage* page = NULL;
     wxWindow* parent = wnd->GetParent();
-    wxRibbonPanel* panel = NULL;
+    wxRibbonPanel* panel = wxDynamicCast(wnd, wxRibbonPanel);
     bool hovered = false;
 
-    panel = wxDynamicCast(wnd, wxRibbonPanel);
     if(panel != NULL)
     {
         hovered = allow_hovered && panel->IsHovered();
@@ -2446,6 +2462,8 @@ wxSize wxRibbonMSWArtProvider::GetPanelClientSize(
         else
             *client_offset = wxPoint(3, 2);
     }
+    if (size.x < 0) size.x = 0;
+    if (size.y < 0) size.y = 0;
 
     return size;
 }
@@ -2637,12 +2655,10 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
             wxCoord label_height;
             wxCoord best_width;
             dc.GetTextExtent(label, &best_width, &label_height);
-            int best_num_lines = 1;
             int last_line_extra_width = 0;
             if(kind != wxRIBBON_BUTTON_NORMAL)
             {
                 last_line_extra_width += 8;
-                best_num_lines = 2; // label on top line, button below
             }
             size_t i;
             for(i = 0; i < label.Len(); ++i)
@@ -2655,7 +2671,6 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
                     if(width < best_width)
                     {
                         best_width = width;
-                        best_num_lines = 2;
                     }
                 }
             }