static wxBitmap ConvertToDisabled(const wxBitmap& bmp) { #if wxVERSION_NUMBER >= 3100 && !defined(__WXMSW__) // Convert the image to disabled // It seems that m_bitmap.ConvertToDisabled() looses the scale // factor, so use this kind of conversion wxImage img = bmp.ConvertToImage(); img = img.ConvertToDisabled(); // Keep the original m_bitmap scale factor wxBitmap disabledBmp = wxBitmap(img, -1, bmp.GetScaleFactor()); return disabledBmp; #else return bmp.ConvertToDisabled(); #endif }
wxBitmap OverlayTool::DoAddBitmap(const wxBitmap& bmp, const wxColour& colour) const { wxMemoryDC dcMem; wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxBitmap bitmap(16, 16, 32); dcMem.SelectObject(bitmap); // Draw white background dcMem.SetPen( wxPen(col) ); dcMem.SetBrush( wxBrush(col) ); dcMem.DrawRectangle(wxPoint(0, 0), wxSize(16, 16)); // Draw the base icon dcMem.DrawBitmap(bmp.ConvertToDisabled(), wxPoint(0, 0), true); wxColour c2 = DrawingUtils::LightColour(colour, 3.0); dcMem.GradientFillLinear(wxRect(wxPoint(0, 1), wxSize(2, 14)), colour, c2, wxSOUTH); //// Draw a small 2 pixel vertical line //wxBitmap coverBmp(16, 16, 32); //{ // wxAlphaPixelData pixData(coverBmp); // // // Set the fill pixels // int red = colour.Red(); // int green = colour.Green(); // int blue = colour.Blue(); // wxAlphaPixelData::Iterator p(pixData); // for (int y=0; y<16; y++) { // p.MoveTo(pixData, 0, y); // for (int x=0; x<16; x++) { // p.Red() = red; // p.Green() = green; // p.Blue() = blue; // p.Alpha() = 90; // ++p; // } // } //} // //dcMem.DrawBitmap(coverBmp, wxPoint(0, 0)); dcMem.SelectObject(wxNullBitmap); return bitmap; }
void DragEffectBitmapButton::SetBitmap(const wxBitmap &bpm) { wxBitmapButton::SetBitmap(bpm); wxBitmapButton::SetBitmapDisabled(bpm.ConvertToDisabled()); }