- HPEN oldp;
- HBRUSH oldb ;
-
- HPEN penBorder;
- HPEN penLight;
- HPEN penShadow;
- HBRUSH brushFace;
- COLORREF ms_color;
-
- ms_color = GetSysColor(COLOR_WINDOWFRAME) ;
- penBorder = CreatePen(PS_SOLID,0,ms_color) ;
-
- ms_color = GetSysColor(COLOR_BTNSHADOW) ;
- penShadow = CreatePen(PS_SOLID,0,ms_color) ;
-
- ms_color = GetSysColor(COLOR_BTNHIGHLIGHT) ;
- penLight = CreatePen(PS_SOLID,0,ms_color) ;
-
- ms_color = GetSysColor(COLOR_BTNFACE) ;
- brushFace = CreateSolidBrush(ms_color) ;
-
- oldp = (HPEN) SelectObject( (HDC) dc, GetStockObject( NULL_PEN ) ) ;
- oldb = (HBRUSH) SelectObject( (HDC) dc, brushFace ) ;
- Rectangle( (HDC) dc, left, top, right, bottom ) ;
- SelectObject( (HDC) dc, penBorder) ;
- MoveToEx((HDC) dc,left+1,top,NULL);LineTo((HDC) dc,right-1,top);
- MoveToEx((HDC) dc,left,top+1,NULL);LineTo((HDC) dc,left,bottom-1);
- MoveToEx((HDC) dc,left+1,bottom-1,NULL);LineTo((HDC) dc,right-1,bottom-1);
- MoveToEx((HDC) dc,right-1,top+1,NULL);LineTo((HDC) dc,right-1,bottom-1);
-
- SelectObject( (HDC) dc, penShadow) ;
- if (sel)
- {
- MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ;
- LineTo((HDC) dc, left+1 ,top+1) ;
- LineTo((HDC) dc, right-2 ,top+1) ;
- }
- else
- {
- MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ;
- LineTo((HDC) dc, right-2 ,bottom-2) ;
- LineTo((HDC) dc, right-2 ,top) ;
- MoveToEx((HDC) dc,left+2 ,bottom-3 ,NULL) ;
- LineTo((HDC) dc, right-3 ,bottom-3) ;
- LineTo((HDC) dc, right-3 ,top+1) ;
-
- SelectObject( (HDC) dc, penLight) ;
-
- MoveToEx((HDC) dc,left+1 ,bottom-2 ,NULL) ;
- LineTo((HDC) dc, left+1 ,top+1) ;
- LineTo((HDC) dc, right-2 ,top+1) ;
- }
- SelectObject((HDC) dc,oldp) ;
- SelectObject((HDC) dc,oldb) ;
-
- DeleteObject(penBorder);
- DeleteObject(penLight);
- DeleteObject(penShadow);
- DeleteObject(brushFace);
+ if ( !m_brushDisabled.Ok() )
+ {
+ // draw a bitmap with two black and two background colour pixels
+ wxBitmap bmp(2, 2);
+ wxMemoryDC dc;
+ dc.SelectObject(bmp);
+ dc.SetPen(*wxBLACK_PEN);
+ dc.DrawPoint(0, 0);
+ dc.DrawPoint(1, 1);
+ dc.SetPen(GetBackgroundColour());
+ dc.DrawPoint(0, 1);
+ dc.DrawPoint(1, 0);
+
+ m_brushDisabled = wxBrush(bmp);
+ }
+
+ SelectInHDC selectBrush((HDC)dc, GetHbrushOf(m_brushDisabled));
+
+ // ROP for "dest |= pattern" operation -- as it doesn't have a standard
+ // name, give it our own
+ static const DWORD PATTERNPAINT = 0xFA0089UL;
+
+ if ( with_marg )
+ {
+ left += m_marginX;
+ top += m_marginY;
+ right -= 2 * m_marginX;
+ bottom -= 2 * m_marginY;
+ }
+
+ ::PatBlt( (HDC) dc, left, top, right, bottom, PATTERNPAINT);