-
- (void)SelectObject(hdc, hPrevBrush);
- (void)SelectObject(hdc, hPrevFont);
- (void)SetBkMode(hdc, nPrevMode);
- #else
- dc.SetFont(GetFont());
- dc.DrawText(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 )
- {
-#ifndef __SC__
- DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
-#endif
- }
-
- // 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);
-// if (heightDiff = -1)
-// heightDiff = -2;
-
- //MT: blit with mask enabled.
- dc.Blit(rc.x + (GetMarginWidth() - nBmpWidth) / 2,
- rc.y + heightDiff / 2,
- nBmpWidth, nBmpHeight,
- &dcMem, 0, 0, wxCOPY, TRUE);
-
- if ( st & wxODSelected ) {
- #ifdef O_DRAW_NATIVE_API
- RECT rectBmp = { rc.GetLeft(), rc.GetTop(),
- rc.GetLeft() + GetMarginWidth(),
- rc.GetTop() + m_nHeight };
- SetBkColor(hdc, colBack);
- DrawEdge(hdc, &rectBmp, EDGE_RAISED, BF_SOFT | BF_RECT);
- #else
- // ## to write portable DrawEdge
- #endif //O_DRAW_NATIVE_API
- }
+ else
+ {
+ wxBitmap bmp;
+
+ if ( st & wxODDisabled )
+ {
+ bmp = GetDisabledBitmap();
+ }
+
+ if ( !bmp.Ok() )
+ {
+ // for not checkable bitmaps we should always use unchecked one
+ // because their checked bitmap is not set
+ bmp = GetBitmap(!IsCheckable() || (st & wxODChecked));
+
+#if wxUSE_IMAGE
+ if ( bmp.Ok() && st & wxODDisabled )
+ {
+ // we need to grey out the bitmap as we don't have any specific
+ // disabled bitmap
+ wxImage imgGrey = bmp.ConvertToImage().ConvertToGreyscale();
+ if ( imgGrey.Ok() )
+ bmp = wxBitmap(imgGrey);
+ }
+#endif // wxUSE_IMAGE
+ }
+
+ if ( bmp.Ok() )
+ {
+ wxMemoryDC dcMem(&dc);
+ dcMem.SelectObjectAsSource(bmp);
+
+ // center bitmap
+ int nBmpWidth = bmp.GetWidth(),
+ nBmpHeight = bmp.GetHeight();
+
+ // there should be enough space!
+ wxASSERT((nBmpWidth <= rc.GetWidth()) && (nBmpHeight <= rc.GetHeight()));
+
+ int heightDiff = m_nHeight - nBmpHeight;
+ dc.Blit(rc.x + (margin - nBmpWidth) / 2,
+ rc.y + heightDiff / 2,
+ nBmpWidth, nBmpHeight,
+ &dcMem, 0, 0, wxCOPY, true /* use mask */);
+
+ if ( ( st & wxODSelected ) && !( st & wxODDisabled ) && draw_bitmap_edge )
+ {
+ RECT rectBmp = { rc.GetLeft(), rc.GetTop(),
+ rc.GetLeft() + margin,
+ rc.GetTop() + m_nHeight };
+ SetBkColor(hdc, colBack);
+
+ DrawEdge(hdc, &rectBmp, BDR_RAISEDINNER, BF_RECT);
+ }
+ }