- (void)SelectObject(hdc, hPrevBrush);
- (void)SelectObject(hdc, hPrevFont);
- (void)SetBkMode(hdc, nPrevMode);
-
- DeleteObject(hbr);
- #else
- dc.SetFont(GetFont());
- dc.DrawText(wxStripMenuCodes(m_strName), x, rc.y);
- #endif //O_DRAW_NATIVE_API
-
- // draw the bitmap
- // ---------------
- if ( IsCheckable() && !m_bmpChecked.Ok() ) {
- if ( st & wxODChecked ) {
- // using native APIs for performance and simplicity
-#ifdef O_DRAW_NATIVE_API
- // what goes on: DrawFrameControl creates a b/w mask,
- // then we copy it to screen to have right colors
-
- // first create a monochrome bitmap in a memory DC
- HDC hdcMem = CreateCompatibleDC(hdc);
- HBITMAP hbmpCheck = CreateBitmap(GetMarginWidth(), m_nHeight, 1, 1, 0);
- SelectObject(hdcMem, hbmpCheck);
-
- // then draw a check mark into it
- RECT rect = { 0, 0, GetMarginWidth(), m_nHeight };
- if ( m_nHeight > 0 )
- {
- ::DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
- }
-
- // finally copy it to screen DC and clean up
- BitBlt(hdc, rc.x, rc.y, GetMarginWidth(), m_nHeight,
- hdcMem, 0, 0, SRCCOPY);
-
- DeleteDC(hdcMem);
- DeleteObject(hbmpCheck);
-#else
- // #### to do: perhaps using Marlett font (create equiv. font under X)
-// wxFAIL("not implemented");
-#endif //O_DRAW_NATIVE_API
- }
- }
- else {
- // for uncheckable item we use only the 'checked' bitmap
- wxBitmap bmp(GetBitmap(IsCheckable() ? ((st & wxODChecked) != 0) : TRUE));
- if ( bmp.Ok() ) {
- wxMemoryDC dcMem(&dc);
- dcMem.SelectObject(bmp);
-
- // center bitmap
- int nBmpWidth = bmp.GetWidth(),
- nBmpHeight = bmp.GetHeight();
-
- // there should be enough place!
- wxASSERT((nBmpWidth <= rc.GetWidth()) && (nBmpHeight <= rc.GetHeight()));
-
- int heightDiff = m_nHeight - nBmpHeight;
- dc.Blit(rc.x + (GetMarginWidth() - nBmpWidth) / 2,
- rc.y + heightDiff / 2,
- nBmpWidth, nBmpHeight,
- &dcMem, 0, 0, wxCOPY, TRUE /* use mask */);
-
- if ( st & wxODSelected ) {
- #ifdef O_DRAW_NATIVE_API
- RECT rectBmp = { rc.GetLeft(), rc.GetTop(),
- rc.GetLeft() + GetMarginWidth(),
- rc.GetTop() + m_nHeight-1 };
- SetBkColor(hdc, colBack);
- DrawEdge(hdc, &rectBmp, EDGE_RAISED, BF_SOFT | BF_RECT);
- #else
- int x1, y1, x2, y2;
- x1 = rc.x;
- y1 = rc.y;
- x2 = x1 + GetMarginWidth() - 1;
- y2 = y1 + m_nHeight - 1;
-
- dc.SetPen(*wxWHITE_PEN);
- dc.DrawLine(x1, y1, x2, y1);
- dc.DrawLine(x1, y1, x1, y2);
- dc.SetPen(*wxGREY_PEN);
- dc.DrawLine(x1, y2-1, x2, y2-1);
- dc.DrawLine(x2, y1, x2, y2);
- #endif //O_DRAW_NATIVE_API
- }
- }
- }