]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't duplicate wxImage::ConvertToDisabled() in wxAUI code.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Jul 2011 23:36:44 +0000 (23:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Jul 2011 23:36:44 +0000 (23:36 +0000)
Just reuse the existing function.

Also add an example of showing a disabled bitmap to the aui sample.

Closes #13303.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/aui/auidemo.cpp
src/aui/auibar.cpp

index b6bb96102fbf85cbf1338423dcc8f4785b18e631..08d5d136d981e8bd6d6b0ddd2b05628743d06c37 100644 (file)
@@ -798,7 +798,7 @@ MyFrame::MyFrame(wxWindow* parent,
     tb2->SetToolBitmapSize(wxSize(16,16));
 
     wxBitmap tb2_bmp1 = wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(16,16));
-    tb2->AddTool(ID_SampleItem+6, wxT("Test"), tb2_bmp1);
+    tb2->AddTool(ID_SampleItem+6, wxT("Disabled"), tb2_bmp1);
     tb2->AddTool(ID_SampleItem+7, wxT("Test"), tb2_bmp1);
     tb2->AddTool(ID_SampleItem+8, wxT("Test"), tb2_bmp1);
     tb2->AddTool(ID_SampleItem+9, wxT("Test"), tb2_bmp1);
@@ -811,6 +811,7 @@ MyFrame::MyFrame(wxWindow* parent,
     tb2->AddTool(ID_SampleItem+14, wxT("Test"), tb2_bmp1);
     tb2->AddTool(ID_SampleItem+15, wxT("Test"), tb2_bmp1);
     tb2->SetCustomOverflowItems(prepend_items, append_items);
+    tb2->EnableTool(ID_SampleItem+6, false);
     tb2->Realize();
 
 
index 9d86d69a0c3043e29643214c4895181e657d209d..a64ed0cce5a5074148e97538111fb7f9194cc7ca 100644 (file)
@@ -69,41 +69,6 @@ const int BUTTON_DROPDOWN_WIDTH = 10;
 wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
                              const wxColour& color);
 
-static wxBitmap MakeDisabledBitmap(wxBitmap& bmp)
-{
-    wxImage image = bmp.ConvertToImage();
-
-    int mr, mg, mb;
-    mr = image.GetMaskRed();
-    mg = image.GetMaskGreen();
-    mb = image.GetMaskBlue();
-
-    unsigned char* data = image.GetData();
-    int width = image.GetWidth();
-    int height = image.GetHeight();
-    bool has_mask = image.HasMask();
-
-    for (int y = height-1; y >= 0; --y)
-    {
-        for (int x = width-1; x >= 0; --x)
-        {
-            data = image.GetData() + (y*(width*3))+(x*3);
-            unsigned char* r = data;
-            unsigned char* g = data+1;
-            unsigned char* b = data+2;
-
-            if (has_mask && *r == mr && *g == mg && *b == mb)
-                continue;
-
-            *r = wxColour::AlphaBlend(*r, 255, 0.4);
-            *g = wxColour::AlphaBlend(*g, 255, 0.4);
-            *b = wxColour::AlphaBlend(*b, 255, 0.4);
-        }
-    }
-
-    return wxBitmap(image);
-}
-
 static wxColor GetBaseColor()
 {
 
@@ -996,10 +961,7 @@ wxAuiToolBarItem* wxAuiToolBar::AddTool(int tool_id,
         // no disabled bitmap specified, we need to make one
         if (item.bitmap.IsOk())
         {
-            //wxImage img = item.bitmap.ConvertToImage();
-            //wxImage grey_version = img.ConvertToGreyscale();
-            //item.disabled_bitmap = wxBitmap(grey_version);
-            item.disabled_bitmap = MakeDisabledBitmap(item.bitmap);
+            item.disabled_bitmap = item.bitmap.ConvertToDisabled();
         }
     }
     m_items.Add(item);