Fixed wxToolBar colour mapping problem (I hope)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9144 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -102,6 +102,13 @@ protected:
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
||||
|
||||
static bool sm_coloursInit; // Have we initialized the colour table yet?
|
||||
static long sm_stdColours[6]; // The RGB values of the standard 6 colours
|
||||
|
||||
public:
|
||||
void MapBitmap(WXHBITMAP bitmap, int width, int height);
|
||||
|
||||
};
|
||||
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
@@ -109,7 +109,7 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// adjust toolbar bitmap colours
|
||||
static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
|
||||
// static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin macros
|
||||
@@ -474,7 +474,7 @@ bool wxToolBar::Realize()
|
||||
#endif // USE_BITMAP_MASKS/!USE_BITMAP_MASKS
|
||||
|
||||
// Map to system colours
|
||||
wxMapBitmap(hBitmap, totalBitmapWidth, totalBitmapHeight);
|
||||
MapBitmap((WXHBITMAP) hBitmap, totalBitmapWidth, totalBitmapHeight);
|
||||
|
||||
int bitmapId = 0;
|
||||
|
||||
@@ -1006,16 +1006,64 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
// system colors. Note that they are in BGR format because this is what Windows
|
||||
// wants (and not RGB)
|
||||
|
||||
/*
|
||||
#define BGR_BUTTONTEXT (RGB(000,000,000)) // black
|
||||
#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
|
||||
#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
|
||||
#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
|
||||
#define BGR_BACKGROUNDSEL (RGB(000,000,255)) // blue
|
||||
#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
|
||||
*/
|
||||
|
||||
void wxMapBitmap(HBITMAP hBitmap, int width, int height)
|
||||
bool wxToolBar::sm_coloursInit = FALSE;
|
||||
long wxToolBar::sm_stdColours[6];
|
||||
|
||||
void wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
|
||||
{
|
||||
COLORMAP ColorMap[] =
|
||||
if (!sm_coloursInit)
|
||||
{
|
||||
// When a bitmap is loaded, the RGB values can change. So we need to have a
|
||||
// reference bitmap which can tell us what the RGB values change to.
|
||||
wxBitmap stdColourBitmap("wxBITMAP_STD_COLOURS", wxBITMAP_TYPE_RESOURCE);
|
||||
if (stdColourBitmap.Ok())
|
||||
{
|
||||
wxMemoryDC memDC;
|
||||
memDC.SelectObject(stdColourBitmap);
|
||||
|
||||
int i = 0;
|
||||
wxColour colour;
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
memDC.GetPixel(i, 0, & colour);
|
||||
sm_stdColours[i] = RGB(colour.Red(), colour.Green(), colour.Blue());
|
||||
}
|
||||
sm_coloursInit = TRUE;
|
||||
memDC.SelectObject(wxNullBitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm_stdColours[0] = RGB(000,000,000) ;
|
||||
sm_stdColours[1] = RGB(128,128,128) ;
|
||||
sm_stdColours[2] = RGB(192,192,192) ;
|
||||
sm_stdColours[3] = RGB(255,255,255) ;
|
||||
sm_stdColours[4] = RGB(000,000,255) ;
|
||||
sm_stdColours[5] = RGB(255,000,255) ;
|
||||
sm_coloursInit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
HBITMAP hBitmap = (HBITMAP) bitmap;
|
||||
|
||||
COLORMAP ColorMap[5];
|
||||
|
||||
ColorMap[0].from = sm_stdColours[0]; ColorMap[0].to = COLOR_BTNTEXT; // black (0, 0 0)
|
||||
ColorMap[1].from = sm_stdColours[1]; ColorMap[1].to = COLOR_BTNSHADOW; // dark grey (128, 128, 128)
|
||||
ColorMap[2].from = sm_stdColours[2]; ColorMap[2].to = COLOR_BTNFACE; // bright grey (192, 192, 192)
|
||||
ColorMap[3].from = sm_stdColours[3]; ColorMap[3].to = COLOR_BTNHIGHLIGHT; // white (255, 255, 255)
|
||||
// ColorMap[4].from = sm_stdColours[4]; ColorMap[4].to = COLOR_HIGHLIGHT; // blue (0, 0, 255)
|
||||
ColorMap[4].from = sm_stdColours[5]; ColorMap[4].to = COLOR_WINDOW; // magenta (255, 0, 255)
|
||||
|
||||
#if 0
|
||||
{
|
||||
{BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
|
||||
{BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
|
||||
@@ -1024,6 +1072,7 @@ void wxMapBitmap(HBITMAP hBitmap, int width, int height)
|
||||
/* {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue */
|
||||
{BGR_BACKGROUND, COLOR_WINDOW} // magenta
|
||||
};
|
||||
#endif
|
||||
|
||||
int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
|
||||
int n;
|
||||
|
Reference in New Issue
Block a user