-// draw the item
-bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus st)
-{
- // we do nothing on focus change
- if ( act == wxODFocusChanged )
- return TRUE;
-
- // wxColor <-> RGB
- #define ToRGB(col) RGB(col.Red(), col.Green(), col.Blue())
- #define UnRGB(col) GetRValue(col), GetGValue(col), GetBValue(col)
-
- // set the colors
- // --------------
- DWORD colBack, colText;
- if ( st & wxODSelected ) {
- colBack = GetSysColor(COLOR_HIGHLIGHT);
- colText = GetSysColor(COLOR_HIGHLIGHTTEXT);
- }
- else {
- // fall back to default colors if none explicitly specified
- colBack = m_colBack.Ok() ? ToRGB(m_colBack) : GetSysColor(COLOR_WINDOW);
- colText = m_colText.Ok() ? ToRGB(m_colText) : GetSysColor(COLOR_WINDOWTEXT);
- }
-
- #ifdef O_DRAW_NATIVE_API
- #define hdc (HDC)dc.GetHDC()
- COLORREF colOldText = ::SetTextColor(hdc, colText),
- colOldBack = ::SetBkColor(hdc, colBack);
- #else
- dc.SetTextForeground(wxColor(UnRGB(colText)));
- dc.SetTextBackground(wxColor(UnRGB(colBack)));
- #endif
-
- // select the font and draw the text
- // ---------------------------------
-
- // determine where to draw and leave space for a check-mark.
- int x = rc.x + GetMarginWidth();
-
- // using native API because it reckognizes '&'
- #ifdef O_DRAW_NATIVE_API
- int nPrevMode = SetBkMode(hdc, TRANSPARENT);
- HBRUSH hbr = CreateSolidBrush(colBack),
- hPrevBrush = (HBRUSH) SelectObject(hdc, hbr);
-
- RECT rectAll = { rc.GetLeft(), rc.GetTop(), rc.GetRight(), rc.GetBottom() };
- FillRect(hdc, &rectAll, hbr);
-
- // use default font if no font set
- HFONT hfont;
- if ( m_font.Ok() ) {
- m_font.RealizeResource();
- hfont = (HFONT)m_font.GetResourceHandle();
- }
- else {
- hfont = (HFONT)::GetStockObject(SYSTEM_FONT);
- }