]> git.saurik.com Git - wxWidgets.git/blobdiff - src/ribbon/art_msw.cpp
Remove unnecessary base class OnPaint() call from wxGenericColourDialog.
[wxWidgets.git] / src / ribbon / art_msw.cpp
index 5f70558798991c33076f5577971d595ea60bbf11..3dc95656ef91419f3e2b64f054b25c3eedc54f72 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__
@@ -82,10 +82,22 @@ static const char* const gallery_extension_xpm[] = {
   " xxx ",
   "  x  "};
 
+static const char* const panel_extension_xpm[] = {
+  "7 7 2 1",
+  "  c None",
+  "x c #FF00FF",
+  "xxxxxx ",
+  "x      ",
+  "x      ",
+  "x  x  x",
+  "x   xxx",
+  "x   xxx",
+  "   xxxx"};
+
 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 +155,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;
+    static const double 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);
 
@@ -176,9 +205,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_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_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);
 
@@ -195,9 +224,13 @@ void wxRibbonMSWArtProvider::SetColourScheme(
     m_panel_label_colour = LikePrimary(2.8, -0.14, -0.35);
     m_panel_hover_label_colour = m_panel_label_colour;
     m_panel_minimised_label_colour = m_tab_label_colour;
+    m_panel_hover_button_background_brush = LikeSecondary(-0.9, 0.16, -0.07);
+    m_panel_hover_button_border_pen = LikeSecondary(-3.9, -0.16, -0.14);
+    SetColour(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR, LikePrimary(1.4, -0.21, -0.23));
+    SetColour(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR, LikePrimary(1.5, -0.24, -0.29));
 
     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);
@@ -217,7 +250,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_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);
@@ -267,6 +300,10 @@ void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
         copy->m_gallery_down_bitmap[i] = m_gallery_down_bitmap[i];
         copy->m_gallery_extension_bitmap[i] = m_gallery_extension_bitmap[i];
     }
+    for(int i = 0; i < 2; ++i)
+    {
+        copy->m_panel_extension_bitmap[i] = m_panel_extension_bitmap[i];
+    }
     copy->m_toolbar_drop_bitmap = m_toolbar_drop_bitmap;
 
     copy->m_primary_scheme_colour = m_primary_scheme_colour;
@@ -286,6 +323,8 @@ void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
     copy->m_panel_label_colour = m_panel_label_colour;
     copy->m_panel_hover_label_colour = m_panel_hover_label_colour;
     copy->m_panel_minimised_label_colour = m_panel_minimised_label_colour;
+    copy->m_panel_button_face_colour = m_panel_button_face_colour;
+    copy->m_panel_button_hover_face_colour = m_panel_button_hover_face_colour;
     copy->m_panel_active_background_colour = m_panel_active_background_colour;
     copy->m_panel_active_background_gradient_colour = m_panel_active_background_gradient_colour;
     copy->m_panel_active_background_top_colour = m_panel_active_background_top_colour;
@@ -307,7 +346,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_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;
@@ -322,6 +361,7 @@ void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
     copy->m_tab_ctrl_background_brush = m_tab_ctrl_background_brush;
     copy->m_panel_label_background_brush = m_panel_label_background_brush;
     copy->m_panel_hover_label_background_brush = m_panel_hover_label_background_brush;
+    copy->m_panel_hover_button_background_brush = m_panel_hover_button_background_brush;
     copy->m_gallery_hover_background_brush = m_gallery_hover_background_brush;
     copy->m_gallery_button_background_top_brush = m_gallery_button_background_top_brush;
     copy->m_gallery_button_hover_background_top_brush = m_gallery_button_hover_background_top_brush;
@@ -337,6 +377,7 @@ void wxRibbonMSWArtProvider::CloneTo(wxRibbonMSWArtProvider* copy) const
     copy->m_panel_border_gradient_pen = m_panel_border_gradient_pen;
     copy->m_panel_minimised_border_pen = m_panel_minimised_border_pen;
     copy->m_panel_minimised_border_gradient_pen = m_panel_minimised_border_gradient_pen;
+    copy->m_panel_hover_button_border_pen = m_panel_hover_button_border_pen;
     copy->m_tab_border_pen = m_tab_border_pen;
     copy->m_gallery_border_pen = m_gallery_border_pen;
     copy->m_button_bar_hover_border_pen = m_button_bar_hover_border_pen;
@@ -390,6 +431,8 @@ void wxRibbonMSWArtProvider::SetFlags(long flags)
     Reload(wxRIBBON_ART_GALLERY_BUTTON_HOVER_FACE_COLOUR);
     Reload(wxRIBBON_ART_GALLERY_BUTTON_ACTIVE_FACE_COLOUR);
     Reload(wxRIBBON_ART_GALLERY_BUTTON_DISABLED_FACE_COLOUR);
+    Reload(wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR);
+    Reload(wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR);
 #undef Reload
 }
 
@@ -630,6 +673,10 @@ wxColour wxRibbonMSWArtProvider::GetColour(int id) const
             return m_panel_active_background_colour;
         case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
             return m_panel_active_background_gradient_colour;
+        case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR:
+            return m_panel_button_face_colour;
+        case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR:
+            return m_panel_button_hover_face_colour;
         case wxRIBBON_ART_PAGE_BORDER_COLOUR:
             return m_page_border_pen.GetColour();
         case wxRIBBON_ART_PAGE_BACKGROUND_TOP_COLOUR:
@@ -880,6 +927,14 @@ void wxRibbonMSWArtProvider::SetColour(int id, const wxColor& colour)
         case wxRIBBON_ART_PANEL_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
             m_panel_active_background_gradient_colour = colour;
             break;
+        case wxRIBBON_ART_PANEL_BUTTON_FACE_COLOUR:
+            m_panel_button_face_colour = colour;
+            m_panel_extension_bitmap[0] = wxRibbonLoadPixmap(panel_extension_xpm, colour);
+            break;
+        case wxRIBBON_ART_PANEL_BUTTON_HOVER_FACE_COLOUR:
+            m_panel_button_hover_face_colour = colour;
+            m_panel_extension_bitmap[1] = wxRibbonLoadPixmap(panel_extension_xpm, colour);
+            break;
         case wxRIBBON_ART_PAGE_BORDER_COLOUR:
             m_page_border_pen.SetColour(colour);
             break;
@@ -1018,11 +1073,14 @@ void wxRibbonMSWArtProvider::DrawTab(
     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);
+        }
     }
     if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
     {
@@ -1124,12 +1182,27 @@ void wxRibbonMSWArtProvider::ReallyDrawTabSeparator(wxWindow* wnd, const wxRect&
 }
 
 void wxRibbonMSWArtProvider::DrawPartialPageBackground(wxDC& dc,
-        wxWindow* WXUNUSED(wnd), const wxRect& rect, wxRibbonPage* page,
+        wxWindow* wnd, const wxRect& rect, wxRibbonPage* page,
         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
@@ -1429,6 +1502,7 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
 
     wxRect true_rect(rect);
     RemovePanelPadding(&true_rect);
+    bool has_ext_button = wnd->HasExtButton();
 
     int label_height;
     {
@@ -1456,6 +1530,11 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
         label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight());
         label_height = label_rect.GetHeight();
 
+        wxRect label_bg_rect = label_rect;
+
+        if(has_ext_button)
+            label_rect.SetWidth(label_rect.GetWidth() - 13);
+
         if(label_size.GetWidth() > label_rect.GetWidth())
         {
             // Test if there is enough length for 3 letters and ...
@@ -1484,7 +1563,7 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
             }
         }
 
-        dc.DrawRectangle(label_rect.GetX(), label_rect.GetY(), label_rect.GetWidth(), label_rect.GetHeight());
+        dc.DrawRectangle(label_bg_rect);
         if(clip_label)
         {
             wxDCClipper clip(dc, label_rect);
@@ -1498,6 +1577,19 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
                 label_rect.y +
                 (label_rect.GetHeight() - label_size.GetHeight()) / 2);
         }
+
+        if(has_ext_button)
+        {
+            if(wnd->IsExtButtonHovered())
+            {
+                dc.SetPen(m_panel_hover_button_border_pen);
+                dc.SetBrush(m_panel_hover_button_background_brush);
+                dc.DrawRoundedRectangle(label_rect.GetRight(), label_rect.GetBottom() - 13, 13, 13, 1.0);
+                dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true);
+            }
+            else
+                dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true);
+        }
     }
 
     if(wnd->IsHovered())
@@ -1513,6 +1605,15 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
     DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen);
 }
 
+wxRect wxRibbonMSWArtProvider::GetPanelExtButtonArea(wxDC& WXUNUSED(dc),
+                        const wxRibbonPanel* WXUNUSED(wnd),
+                        wxRect rect)
+{
+    RemovePanelPadding(&rect);
+    rect = wxRect(rect.GetRight()-13, rect.GetBottom()-13, 13, 13);
+    return rect;
+}
+
 void wxRibbonMSWArtProvider::DrawGalleryBackground(
                         wxDC& dc,
                         wxRibbonGallery* wnd,
@@ -1771,13 +1872,13 @@ void wxRibbonMSWArtProvider::DrawMinimisedPanel(
         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;
-        dc.GradientFillLinear(client_rect, 
+        dc.GradientFillLinear(client_rect,
             m_panel_active_background_colour,
             m_panel_active_background_gradient_colour, wxSOUTH);
     }
@@ -1886,7 +1987,7 @@ void wxRibbonMSWArtProvider::DrawMinimisedPanelCommon(
 
     dc.SetTextForeground(m_panel_minimised_label_colour);
     dc.DrawText(wnd->GetLabel(), xpos, ypos);
-    
+
 
     wxPoint arrow_points[3];
     if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
@@ -1931,10 +2032,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();
@@ -1987,6 +2087,13 @@ void wxRibbonMSWArtProvider::DrawButtonBarButton(
                         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))
     {
@@ -2149,7 +2256,7 @@ void wxRibbonMSWArtProvider::DrawButtonBarButtonForeground(
                             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);
@@ -2221,6 +2328,12 @@ void wxRibbonMSWArtProvider::DrawTool(
                 wxRibbonButtonKind kind,
                 long state)
 {
+    if(kind == wxRIBBON_BUTTON_TOGGLE)
+    {
+        if(state & wxRIBBON_TOOLBAR_TOOL_TOGGLED)
+            state ^= wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK;
+    }
+
     wxRect bg_rect(rect);
     bg_rect.Deflate(1);
     if((state & wxRIBBON_TOOLBAR_TOOL_LAST) == 0)
@@ -2272,7 +2385,7 @@ void wxRibbonMSWArtProvider::DrawTool(
         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)
@@ -2281,7 +2394,7 @@ void wxRibbonMSWArtProvider::DrawTool(
         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)
     {
@@ -2291,12 +2404,12 @@ void wxRibbonMSWArtProvider::DrawTool(
 
     // Foreground
     int avail_width = bg_rect.GetWidth();
-    if(kind != wxRIBBON_BUTTON_NORMAL)
+    if(kind & wxRIBBON_BUTTON_DROPDOWN)
     {
         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,
@@ -2446,6 +2559,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;
 }
@@ -2485,7 +2600,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.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;
@@ -2503,7 +2618,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.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;
@@ -2511,7 +2626,7 @@ wxSize wxRibbonMSWArtProvider::GetGalleryClientSize(
         size.DecBy(16, 1);
         size.DecBy( 2, 1);
     }
-    
+
     if(client_offset != NULL)
         *client_offset = wxPoint(2, 1);
     if(scroll_up_button != NULL)
@@ -2591,6 +2706,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
         switch(kind)
         {
         case wxRIBBON_BUTTON_NORMAL:
+        case wxRIBBON_BUTTON_TOGGLE:
             *normal_region = wxRect(*button_size);
             *dropdown_region = wxRect(0, 0, 0, 0);
             break;
@@ -2624,6 +2740,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
                 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;
             }
@@ -2637,12 +2754,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)
+            if(kind != wxRIBBON_BUTTON_NORMAL && kind != wxRIBBON_BUTTON_TOGGLE)
             {
                 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 +2770,6 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
                     if(width < best_width)
                     {
                         best_width = width;
-                        best_num_lines = 2;
                     }
                 }
             }
@@ -2678,6 +2792,7 @@ bool wxRibbonMSWArtProvider::GetButtonBarButtonSize(
                 dropdown_region->height = icon_size.GetHeight() - normal_region->height;
                 break;
             case wxRIBBON_BUTTON_NORMAL:
+            case wxRIBBON_BUTTON_TOGGLE:
                 *normal_region = wxRect(icon_size);
                 break;
             }
@@ -2739,7 +2854,7 @@ wxSize wxRibbonMSWArtProvider::GetToolSize(
     size.IncBy(7, 6);
     if(is_last)
         size.IncBy(1, 0);
-    if(kind != wxRIBBON_BUTTON_NORMAL)
+    if(kind & wxRIBBON_BUTTON_DROPDOWN)
     {
         size.IncBy(8, 0);
         if(dropdown_region)