]> git.saurik.com Git - wxWidgets.git/blobdiff - src/ribbon/art_msw.cpp
Fix warnings for the OSX WebKit backend.
[wxWidgets.git] / src / ribbon / art_msw.cpp
index 4041079aeb6bc082697b621185890193355133c5..f10d562083f2167f83fcd9e10f3252919bc2e7f3 100644 (file)
@@ -144,7 +144,7 @@ void wxRibbonMSWArtProvider::SetColourScheme(
 
     // Map primary saturation from [0, 1] to [.25, .75]
     bool primary_is_gray = false;
 
     // Map primary saturation from [0, 1] to [.25, .75]
     bool primary_is_gray = false;
-    const float gray_saturation_threshold = 0.01;
+    static const double gray_saturation_threshold = 0.01;
     if(primary_hsl.saturation <= gray_saturation_threshold)
         primary_is_gray = true;
     else
     if(primary_hsl.saturation <= gray_saturation_threshold)
         primary_is_gray = true;
     else
@@ -193,9 +193,9 @@ void wxRibbonMSWArtProvider::SetColourScheme(
     m_tab_ctrl_background_brush = LikePrimary(1.0, 0.39, 0.07);
     m_tab_hover_background_colour = LikePrimary(1.3, 0.15, 0.10);
     m_tab_hover_background_top_colour = LikePrimary(1.4, 0.36, 0.08);
     m_tab_ctrl_background_brush = LikePrimary(1.0, 0.39, 0.07);
     m_tab_hover_background_colour = LikePrimary(1.3, 0.15, 0.10);
     m_tab_hover_background_top_colour = LikePrimary(1.4, 0.36, 0.08);
-    m_tab_border_pen = LikePrimary(1.4, 0.03, -0.05);  
+    m_tab_border_pen = LikePrimary(1.4, 0.03, -0.05);
     m_tab_separator_gradient_colour = LikePrimary(1.7, -0.15, -0.18);
     m_tab_separator_gradient_colour = LikePrimary(1.7, -0.15, -0.18);
-    m_tab_hover_background_top_gradient_colour = LikePrimary(1.8, 0.34, 0.13);   
+    m_tab_hover_background_top_gradient_colour = LikePrimary(1.8, 0.34, 0.13);
     m_tab_label_colour = LikePrimary(4.3, 0.13, -0.49);
     m_tab_hover_background_gradient_colour = LikeSecondary(-1.5, -0.34, 0.01);
 
     m_tab_label_colour = LikePrimary(4.3, 0.13, -0.49);
     m_tab_hover_background_gradient_colour = LikeSecondary(-1.5, -0.34, 0.01);
 
@@ -214,7 +214,7 @@ void wxRibbonMSWArtProvider::SetColourScheme(
     m_panel_minimised_label_colour = m_tab_label_colour;
 
     m_gallery_button_disabled_background_colour = LikePrimary(-2.8, -0.46, 0.09);
     m_panel_minimised_label_colour = m_tab_label_colour;
 
     m_gallery_button_disabled_background_colour = LikePrimary(-2.8, -0.46, 0.09);
-    m_gallery_button_disabled_background_top_brush = LikePrimary(-2.8, -0.36, 0.15);    
+    m_gallery_button_disabled_background_top_brush = LikePrimary(-2.8, -0.36, 0.15);
     m_gallery_hover_background_brush = LikePrimary(-0.8, 0.05, 0.15);
     m_gallery_border_pen = LikePrimary(0.7, -0.02, 0.03);
     m_gallery_button_background_top_brush = LikePrimary(0.8, 0.34, 0.13);
     m_gallery_hover_background_brush = LikePrimary(-0.8, 0.05, 0.15);
     m_gallery_border_pen = LikePrimary(0.7, -0.02, 0.03);
     m_gallery_button_background_top_brush = LikePrimary(0.8, 0.34, 0.13);
@@ -234,7 +234,7 @@ void wxRibbonMSWArtProvider::SetColourScheme(
     m_gallery_button_active_background_colour = LikeSecondary(-9.9, 0.03, -0.22);
     m_gallery_button_active_background_gradient_colour = LikeSecondary(-9.5, 0.14, -0.11);
     m_gallery_button_active_background_top_brush = LikeSecondary(-9.0, 0.15, -0.08);
     m_gallery_button_active_background_colour = LikeSecondary(-9.9, 0.03, -0.22);
     m_gallery_button_active_background_gradient_colour = LikeSecondary(-9.5, 0.14, -0.11);
     m_gallery_button_active_background_top_brush = LikeSecondary(-9.0, 0.15, -0.08);
-    
+
     m_button_bar_label_colour = m_tab_label_colour;
     m_button_bar_hover_border_pen = LikeSecondary(-6.2, -0.47, -0.14);
     m_button_bar_hover_background_gradient_colour = LikeSecondary(-0.6, 0.16, 0.04);
     m_button_bar_label_colour = m_tab_label_colour;
     m_button_bar_hover_border_pen = LikeSecondary(-6.2, -0.47, -0.14);
     m_button_bar_hover_background_gradient_colour = LikeSecondary(-0.6, 0.16, 0.04);
@@ -324,7 +324,7 @@ void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
     copy->m_button_bar_active_background_top_colour = m_button_bar_active_background_top_colour;
     copy->m_button_bar_active_background_top_gradient_colour = m_button_bar_active_background_top_gradient_colour;
     copy->m_gallery_button_background_colour = m_gallery_button_background_colour;
     copy->m_button_bar_active_background_top_colour = m_button_bar_active_background_top_colour;
     copy->m_button_bar_active_background_top_gradient_colour = m_button_bar_active_background_top_gradient_colour;
     copy->m_gallery_button_background_colour = m_gallery_button_background_colour;
-    copy->m_gallery_button_background_gradient_colour = m_gallery_button_background_gradient_colour;    
+    copy->m_gallery_button_background_gradient_colour = m_gallery_button_background_gradient_colour;
     copy->m_gallery_button_hover_background_colour = m_gallery_button_hover_background_colour;
     copy->m_gallery_button_hover_background_gradient_colour = m_gallery_button_hover_background_gradient_colour;
     copy->m_gallery_button_active_background_colour = m_gallery_button_active_background_colour;
     copy->m_gallery_button_hover_background_colour = m_gallery_button_hover_background_colour;
     copy->m_gallery_button_hover_background_gradient_colour = m_gallery_button_hover_background_gradient_colour;
     copy->m_gallery_button_active_background_colour = m_gallery_button_active_background_colour;
@@ -1035,11 +1035,14 @@ void wxRibbonMSWArtProvider::DrawTab(
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
     {
         wxBitmap icon = tab.page->GetIcon();
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
     {
         wxBitmap icon = tab.page->GetIcon();
+        if(icon.IsOk())
+        {
         int x = tab.rect.x + 4;
         if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
             x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
         dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
             icon.GetHeight()) / 2, true);
         int x = tab.rect.x + 4;
         if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0)
             x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2;
         dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 -
             icon.GetHeight()) / 2, true);
+        }
     }
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
     {
     }
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
     {
@@ -1141,12 +1144,27 @@ void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow* wnd, const wxRect&
 }
 
 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc,
 }
 
 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc,
-        wxWindow* WXUNUSED(wnd), const wxRect& rect, wxRibbonPage* page,
+        wxWindow* wnd, const wxRect& rect, wxRibbonPage* page,
         wxPoint offset, bool hovered)
 {
         wxPoint offset, bool hovered)
 {
-    wxRect background(page->GetSize());
-    page->AdjustRectToIncludeScrollButtons(&background);
-    background.height -= 2;
+    wxRect background;
+    // Expanded panels need a background - the expanded panel at
+    // best size may have a greater Y dimension higher than when 
+    // on the bar if it has a sizer. AUI art provider does not need this
+    // because it paints the panel without reference to its parent's size.
+    // Expanded panels use a wxFrame as parent (not a wxRibbonPage). 
+
+    if(wnd->GetSizer() && wnd->GetParent() != page)
+    {
+        background = wnd->GetParent()->GetSize();
+        offset = wxPoint(0,0);
+    }
+    else
+    {
+        background = page->GetSize();
+        page->AdjustRectToIncludeScrollButtons(&background);
+        background.height -= 2;
+    }
     // Page background isn't dependant upon the width of the page
     // (at least not the part of it intended to be painted by this
     // function). Set to wider than the page itself for when externally
     // Page background isn't dependant upon the width of the page
     // (at least not the part of it intended to be painted by this
     // function). Set to wider than the page itself for when externally
@@ -1788,13 +1806,13 @@ void wxRibbonMSWArtProvider::DrawMinimisedPanel(
         client_rect.width -= 2;
         client_rect.y++;
         client_rect.height = (rect.y + rect.height / 5) - client_rect.x;
         client_rect.width -= 2;
         client_rect.y++;
         client_rect.height = (rect.y + rect.height / 5) - client_rect.x;
-        dc.GradientFillLinear(client_rect, 
+        dc.GradientFillLinear(client_rect,
             m_panel_active_background_top_colour,
             m_panel_active_background_top_gradient_colour, wxSOUTH);
 
         client_rect.y += client_rect.height;
         client_rect.height = (true_rect.y + true_rect.height) - client_rect.y;
             m_panel_active_background_top_colour,
             m_panel_active_background_top_gradient_colour, wxSOUTH);
 
         client_rect.y += client_rect.height;
         client_rect.height = (true_rect.y + true_rect.height) - client_rect.y;
-        dc.GradientFillLinear(client_rect, 
+        dc.GradientFillLinear(client_rect,
             m_panel_active_background_colour,
             m_panel_active_background_gradient_colour, wxSOUTH);
     }
             m_panel_active_background_colour,
             m_panel_active_background_gradient_colour, wxSOUTH);
     }
@@ -1903,7 +1921,7 @@ void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
 
     dc.SetTextForeground(m_panel_minimised_label_colour);
     dc.DrawText(wnd->GetLabel(), xpos, ypos);
 
     dc.SetTextForeground(m_panel_minimised_label_colour);
     dc.DrawText(wnd->GetLabel(), xpos, ypos);
-    
+
 
     wxPoint arrow_points[3];
     if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
 
     wxPoint arrow_points[3];
     if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
@@ -2003,6 +2021,13 @@ void wxRibbonMSWArtProvider::DrawButtonBarButton(
                         const wxBitmap& bitmap_large,
                         const wxBitmap& bitmap_small)
 {
                         const wxBitmap& bitmap_large,
                         const wxBitmap& bitmap_small)
 {
+    if(kind == wxRIBBON_BUTTON_TOGGLE)
+    {
+        kind = wxRIBBON_BUTTON_NORMAL;
+        if(state & wxRIBBON_BUTTONBAR_BUTTON_TOGGLED)
+            state ^= wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK;
+    }
+
     if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK |
         wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK))
     {
     if(state & (wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK |
         wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK))
     {
@@ -2165,7 +2190,7 @@ void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
                             dc.DrawText(label_bottom, iX, ypos);
                             if(arrow_width != 0)
                             {
                             dc.DrawText(label_bottom, iX, ypos);
                             if(arrow_width != 0)
                             {
-                                DrawDropdownArrow(dc, 
+                                DrawDropdownArrow(dc,
                                     iX + 2 +label_w - arrow_width,
                                     ypos + label_h / 2 + 1,
                                     m_button_bar_label_colour);
                                     iX + 2 +label_w - arrow_width,
                                     ypos + label_h / 2 + 1,
                                     m_button_bar_label_colour);
@@ -2288,7 +2313,7 @@ void wxRibbonMSWArtProvider::DrawTool(
         dc.SetBrush(B);
         dc.DrawRectangle(nonrect.x, nonrect.y, nonrect.width, nonrect.height);
     }
         dc.SetBrush(B);
         dc.DrawRectangle(nonrect.x, nonrect.y, nonrect.width, nonrect.height);
     }
-    
+
     // Border
     dc.SetPen(m_toolbar_border_pen);
     if(state & wxRIBBON_TOOLBAR_TOOL_FIRST)
     // Border
     dc.SetPen(m_toolbar_border_pen);
     if(state & wxRIBBON_TOOLBAR_TOOL_FIRST)
@@ -2297,7 +2322,7 @@ void wxRibbonMSWArtProvider::DrawTool(
         dc.DrawPoint(rect.x + 1, rect.y + rect.height - 2);
     }
     else
         dc.DrawPoint(rect.x + 1, rect.y + rect.height - 2);
     }
     else
-        dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);   
+        dc.DrawLine(rect.x, rect.y + 1, rect.x, rect.y + rect.height - 1);
 
     if(state & wxRIBBON_TOOLBAR_TOOL_LAST)
     {
 
     if(state & wxRIBBON_TOOLBAR_TOOL_LAST)
     {
@@ -2312,7 +2337,7 @@ void wxRibbonMSWArtProvider::DrawTool(
         avail_width -= 8;
         if(is_split_hybrid)
         {
         avail_width -= 8;
         if(is_split_hybrid)
         {
-            dc.DrawLine(rect.x + avail_width + 1, rect.y, 
+            dc.DrawLine(rect.x + avail_width + 1, rect.y,
                 rect.x + avail_width + 1, rect.y + rect.height);
         }
         dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
                 rect.x + avail_width + 1, rect.y + rect.height);
         }
         dc.DrawBitmap(m_toolbar_drop_bitmap, bg_rect.x + avail_width + 2,
@@ -2503,7 +2528,7 @@ wxSize wxRibbonMSWArtProvider::GetGalleryClientSize(
         scroll_down.y = scroll_up.y;
         scroll_down.height = scroll_up.height;
         scroll_down.x = scroll_up.x + scroll_up.width;
         scroll_down.y = scroll_up.y;
         scroll_down.height = scroll_up.height;
         scroll_down.x = scroll_up.x + scroll_up.width;
-        scroll_down.width = scroll_up.width;        
+        scroll_down.width = scroll_up.width;
         extension.y = scroll_down.y;
         extension.height = scroll_down.height;
         extension.x = scroll_down.x + scroll_down.width;
         extension.y = scroll_down.y;
         extension.height = scroll_down.height;
         extension.x = scroll_down.x + scroll_down.width;
@@ -2521,7 +2546,7 @@ wxSize wxRibbonMSWArtProvider::GetGalleryClientSize(
         scroll_down.x = scroll_up.x;
         scroll_down.width = scroll_up.width;
         scroll_down.y = scroll_up.y + scroll_up.height;
         scroll_down.x = scroll_up.x;
         scroll_down.width = scroll_up.width;
         scroll_down.y = scroll_up.y + scroll_up.height;
-        scroll_down.height = scroll_up.height;        
+        scroll_down.height = scroll_up.height;
         extension.x = scroll_down.x;
         extension.width = scroll_down.width;
         extension.y = scroll_down.y + scroll_down.height;
         extension.x = scroll_down.x;
         extension.width = scroll_down.width;
         extension.y = scroll_down.y + scroll_down.height;
@@ -2529,7 +2554,7 @@ wxSize wxRibbonMSWArtProvider::GetGalleryClientSize(
         size.DecBy(16, 1);
         size.DecBy( 2, 1);
     }
         size.DecBy(16, 1);
         size.DecBy( 2, 1);
     }
-    
+
     if(client_offset != NULL)
         *client_offset = wxPoint(2, 1);
     if(scroll_up_button != NULL)
     if(client_offset != NULL)
         *client_offset = wxPoint(2, 1);
     if(scroll_up_button != NULL)
@@ -2609,6 +2634,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
         switch(kind)
         {
         case wxRIBBON_BUTTON_NORMAL:
         switch(kind)
         {
         case wxRIBBON_BUTTON_NORMAL:
+        case wxRIBBON_BUTTON_TOGGLE:
             *normal_region = wxRect(*button_size);
             *dropdown_region = wxRect(0, 0, 0, 0);
             break;
             *normal_region = wxRect(*button_size);
             *dropdown_region = wxRect(0, 0, 0, 0);
             break;
@@ -2642,6 +2668,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
                 dropdown_region->SetX(dropdown_region->GetX() + text_size);
                 // no break
             case wxRIBBON_BUTTON_NORMAL:
                 dropdown_region->SetX(dropdown_region->GetX() + text_size);
                 // no break
             case wxRIBBON_BUTTON_NORMAL:
+            case wxRIBBON_BUTTON_TOGGLE:
                 normal_region->SetWidth(normal_region->GetWidth() + text_size);
                 break;
             }
                 normal_region->SetWidth(normal_region->GetWidth() + text_size);
                 break;
             }
@@ -2656,7 +2683,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
             wxCoord best_width;
             dc.GetTextExtent(label, &best_width, &label_height);
             int last_line_extra_width = 0;
             wxCoord best_width;
             dc.GetTextExtent(label, &best_width, &label_height);
             int last_line_extra_width = 0;
-            if(kind != wxRIBBON_BUTTON_NORMAL)
+            if(kind != wxRIBBON_BUTTON_NORMAL && kind != wxRIBBON_BUTTON_TOGGLE)
             {
                 last_line_extra_width += 8;
             }
             {
                 last_line_extra_width += 8;
             }
@@ -2693,6 +2720,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
                 dropdown_region->height = icon_size.GetHeight() - normal_region->height;
                 break;
             case wxRIBBON_BUTTON_NORMAL:
                 dropdown_region->height = icon_size.GetHeight() - normal_region->height;
                 break;
             case wxRIBBON_BUTTON_NORMAL:
+            case wxRIBBON_BUTTON_TOGGLE:
                 *normal_region = wxRect(icon_size);
                 break;
             }
                 *normal_region = wxRect(icon_size);
                 break;
             }