| 67 | } |
| 68 | |
| 69 | void ToggleBitmap::OnPaint(wxPaintEvent &) { |
| 70 | wxAutoBufferedPaintDC dc(this); |
| 71 | |
| 72 | // Get background color |
| 73 | wxColour bgColor = command.IsActive(context) ? wxColour(0,255,0) : wxColour(255,0,0); |
| 74 | wxColor sysCol = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT); |
| 75 | bgColor.Set( |
| 76 | (sysCol.Red() + bgColor.Red()) / 2, |
| 77 | (sysCol.Green() + bgColor.Green()) / 2, |
| 78 | (sysCol.Blue() + bgColor.Blue()) / 2); |
| 79 | |
| 80 | dc.SetPen(*wxTRANSPARENT_PEN); |
| 81 | dc.SetBrush(wxBrush(bgColor)); |
| 82 | dc.DrawRectangle(wxPoint(0, 0), GetClientSize()); |
| 83 | |
| 84 | wxSize excess = (GetClientSize() - img.GetSize()) / 2; |
| 85 | dc.DrawBitmap(img, excess.GetX(), excess.GetY(), true); |
| 86 | } |