wxWidgets中wxRibbonButtonBar EnableButton问题修改

Don't send events for disabled ribbon bar buttons.

Hover and activation events were sent even for the disabled buttons which was
unexpected and inconsistent with wxRibbonToolBar, so don't do it.

http://trac.wxwidgets.org/changeset/72574

Index: src/ribbon/buttonbar.cpp

===================================================================

--- src/ribbon/buttonbar.cpp	(revision 71780)

+++ src/ribbon/buttonbar.cpp	(working copy)

@@ -958,7 +958,7 @@

         wxRect btn_rect;
         btn_rect.SetTopLeft(m_layout_offset + instance.position);
         btn_rect.SetSize(size.size);
-        if(btn_rect.Contains(cursor))
+        if(btn_rect.Contains(cursor) && !(instance.base->state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED))
         {
             new_hovered = &instance;
             new_hovered_state = instance.base->state;
@@ -1047,7 +1047,7 @@

         wxRect btn_rect;
         btn_rect.SetTopLeft(m_layout_offset + instance.position);
         btn_rect.SetSize(size.size);
-        if(btn_rect.Contains(cursor))
+        if( btn_rect.Contains(cursor) && !(instance.base->state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED) )
         {
             m_active_button = &instance;
             cursor -= btn_rect.GetTopLeft();
@@ -1067,7 +1067,7 @@

 {
     wxPoint cursor(evt.GetPosition());
 
-    if(m_active_button)
+    if( m_active_button && !(m_active_button->base->state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED) )
     {
         wxRibbonButtonBarButtonSizeInfo& size =
             m_active_button->base->sizes[m_active_button->size];

使用VS环境开发的话,重新编译wxRibbon库非常方便,直接编译wxWidgets-2.9.4\build\msw下面wx_vcX_ribbon即可

wxRibbon需要依赖一些wxWidgets的基础库,由于之前已经有了全部的库(直接下载下来的,或者自己编译的),把这几个基础库添加给ribbon链接就行了

最终的结果是只要重新编译ribbon库,其他的库都不用变动

enable状态

disable状态,但是还是可以点击的

修改之后,已经变成禁用状态了,无法点击


你可能感兴趣的:(wxWidgets中wxRibbonButtonBar EnableButton问题修改)