Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Refixed: pull-down-menus-images-not-changing-state Issue
stahta01:
FYI:
I have started troubleshooting the cause of the toolbar images not changing state Issue.
Edit: correction I worked on the pull-down menus images not changing state Issue.
Tim S
Pecan:
--- Quote from: stahta01 on January 10, 2007, 01:54:36 pm ---FYI:
I have started troubleshooting the cause of the toolbar images not changing state Issue.
Tim S
--- End quote ---
Many moons ago, I futz around with this problem.
Look at the wierd ugly "redish" first debugger icon that I made. I noticed that when only two colors were used and the primary color was marked as transparent, windows would not change the icon state, or any icon that followed it in the toolbar.
Also notice that the compiler icons work fine, but they are colored. So using that idea, I colored the first debugger icon, and the others then changed state.
I was never able to figure out why, and found no info on the i'net.
Just a note that might help
pecan
stahta01:
Patch to wxWidgets 2.6_Branch to fix menuitem images not changing state
Needs tested and verified it works, I have been up for over 24 hours so use with care.
NOTE: Fixed the small issue of calling SetDisabledBitmap
Note: Added guard of defined(__WXMSW__) on most of added code.
Note: I need to fix my fix of the keybinder code also. Can't use SetBitMap must use SetBitMaps instead.
The fix of keybinder is NOT needed for this code to work right, but will be needed after my patch of the xrc method used to load wxMenuItem. I have not yet decided if fixing the xrc is something I want to do.
Tim S
--- Code: ---Index: include/wx/ownerdrw.h
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/include/wx/ownerdrw.h,v
retrieving revision 1.26
diff --unified -r1.26 ownerdrw.h
--- include/wx/ownerdrw.h 2005/06/07 18:28:47 1.26
+++ include/wx/ownerdrw.h 2007/01/10 16:27:36
@@ -169,6 +169,12 @@
size_t m_nHeight, // font height
m_nMinHeight, // minimum height, as determined by user's system settings
m_nMarginWidth; // space occupied by bitmap to the left of the item
+
+#if defined(__WXMSW__)
+ // Helper function for creating the image for disabled buttons
+ bool wxCreateGreyedImage(const wxImage& in, wxImage& out) ;
+#endif
+
};
#endif // wxUSE_OWNER_DRAWN
Index: src/msw/ownerdrw.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/msw/ownerdrw.cpp,v
retrieving revision 1.62.2.3
diff --unified -r1.62.2.3 ownerdrw.cpp
--- src/msw/ownerdrw.cpp 2006/05/29 17:35:00 1.62.2.3
+++ src/msw/ownerdrw.cpp 2007/01/10 17:20:11
@@ -36,6 +36,7 @@
#include "wx/menuitem.h"
#include "wx/fontutil.h"
#include "wx/module.h"
+#include "wx/image.h"
#if wxUSE_OWNER_DRAWN
@@ -443,6 +444,18 @@
if ( st & wxODDisabled )
{
bmp = GetDisabledBitmap();
+#if defined(__WXMSW__) && wxUSE_IMAGE && wxUSE_WXDIB
+ if ( !bmp.Ok() && m_bmpChecked.Ok() )
+ {
+ // no disabled bitmap specified but we still need to
+ // fill the space in the image list with something, so
+ // we grey out the normal bitmap
+ wxImage imgGreyed;
+ wxCreateGreyedImage(m_bmpChecked.ConvertToImage(), imgGreyed);
+ bmp = wxBitmap(imgGreyed);
+ SetDisabledBitmap(bmp);
+ }
+#endif // defined(__WXMSW__) && wxUSE_IMAGE && wxUSE_WXDIB
}
if ( !bmp.Ok() )
@@ -488,6 +501,75 @@
return true;
}
+
+#if defined(__WXMSW__) && wxUSE_IMAGE
+
+/*
+ * Make a greyed-out image suitable for disabled buttons.
+ * Code copied from common/tbarbase.cpp method wxCreateGreyedImage.
+ */
+
+bool wxOwnerDrawn::wxCreateGreyedImage(const wxImage& src, wxImage& dst)
+{
+ dst = src.Copy();
+
+ unsigned char rBg, gBg, bBg;
+ if ( src.HasMask() )
+ {
+ src.GetOrFindMaskColour(&rBg, &gBg, &bBg);
+ dst.SetMaskColour(rBg, gBg, bBg);
+ }
+ else // assuming the pixels along the edges are of the background color
+ {
+ rBg = src.GetRed(0, 0);
+ gBg = src.GetGreen(0, 0);
+ bBg = src.GetBlue(0, 0);
+ }
+
+ const wxColour colBg(rBg, gBg, bBg);
+
+ const wxColour colDark = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
+ const wxColour colLight = wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
+
+ // Second attempt, just making things monochrome
+ const int width = src.GetWidth();
+ const int height = src.GetHeight();
+
+ for ( int x = 0; x < width; x++ )
+ {
+ for ( int y = 0; y < height; y++ )
+ {
+ const int r = src.GetRed(x, y);
+ const int g = src.GetGreen(x, y);
+ const int b = src.GetBlue(x, y);
+
+ if ( r == rBg && g == gBg && b == bBg )
+ {
+ // Leave the background colour as-is
+ continue;
+ }
+
+ // Change light things to the background colour
+ wxColour col;
+ if ( r >= (colLight.Red() - 50) &&
+ g >= (colLight.Green() - 50) &&
+ b >= (colLight.Blue() - 50) )
+ {
+ col = colBg;
+ }
+ else // Change dark things to really dark
+ {
+ col = colDark;
+ }
+
+ dst.SetRGB(x, y, col.Red(), col.Green(), col.Blue());
+ }
+ }
+
+ return true;
+}
+
+#endif // defined(__WXMSW__) && wxUSE_IMAGE
#endif // wxUSE_OWNER_DRAWN
--- End code ---
stahta01:
Bug 1632888 submitted to wxWidgets
wxMSW: disabled menuitems bitmaps are NOT being grayed.
http://sourceforge.net/tracker/index.php?func=detail&aid=1632888&group_id=9863&atid=109863
Patch 1632891
https://sourceforge.net/tracker/?func=detail&atid=309863&aid=1632891&group_id=9863
Tim S
killerbot:
Thanks Tim,
I will test this out today on windows. I will continue to patch our already patched 263 dll.
However I am gonna change 2 things to your patch :
1) not a method of the class, doesn't need the state, so make it a free function, not being part at all of the interface (sp only cpp needs to be changed) --> less recompiling since no sign of it in the header
2) in the for loop x/y : x++ --> ++x and y++ --> ++y ;-)
PS : we have another issue with toolbar buttons, have a look at the find toolbar (16*16, [the 22*22 icon itself is not correct]), find and replace are the same icon, but not in the search menu .... and on linux also on the toolbar they are nicely different.
So our beloved wx expert, what do you think ??
Navigation
[0] Message Index
[#] Next page
Go to full version