// clipping
// ---------------------------------------------------------------------------
+#define DO_SET_CLIPPING_BOX() \
+{ \
+ RECT rect; \
+ \
+ GetClipBox(GetHdc(), &rect); \
+ \
+ m_clipX1 = (wxCoord) XDEV2LOG(rect.left); \
+ m_clipY1 = (wxCoord) YDEV2LOG(rect.top); \
+ m_clipX2 = (wxCoord) XDEV2LOG(rect.right); \
+ m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
+}
+
void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
{
m_clipping = TRUE;
- m_clipX1 = (int)cx;
- m_clipY1 = (int)cy;
- m_clipX2 = (int)(cx + cw);
- m_clipY2 = (int)(cy + ch);
-
- DoClipping((WXHDC) m_hDC);
+ IntersectClipRect(GetHdc(), XLOG2DEV(cx), YLOG2DEV(cy),
+ XLOG2DEV(cx + cw), YLOG2DEV(cy + ch));
+ DO_SET_CLIPPING_BOX()
}
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
{
wxCHECK_RET( region.GetHRGN(), wxT("invalid clipping region") );
- wxRect box = region.GetBox();
-
m_clipping = TRUE;
- m_clipX1 = box.x;
- m_clipY1 = box.y;
- m_clipX2 = box.x + box.width;
- m_clipY2 = box.y + box.height;
#ifdef __WIN16__
SelectClipRgn(GetHdc(), (HRGN) region.GetHRGN());
#else
ExtSelectClipRgn(GetHdc(), (HRGN) region.GetHRGN(), RGN_AND);
#endif
-}
-void wxDC::DoClipping(WXHDC dc)
-{
- if (m_clipping && dc)
- {
- IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1),
- XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2));
- }
+ DO_SET_CLIPPING_BOX()
}
void wxDC::DestroyClippingRegion()
// get the color of the pixel
COLORREF pixelcolor = ::GetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y));
+ // JACS: what was this for?
+#if 0
// get the color of the pen
COLORREF pencolor = 0x00ffffff;
if (m_pen.Ok())
{
pencolor = m_pen.GetColour().GetPixel();
}
+#endif
// return the color of the pixel
if( col )
// check, if color of the pixels is the same as the color of the current
// pen and return TRUE if it is, FALSE otherwise
- return pixelcolor == pencolor;
+ // JACS, 24/02/2000: can't understand the reason for this, so returning TRUE instead.
+ // return pixelcolor == pencolor;
+
+ return TRUE;
}
void wxDC::DoCrossHair(wxCoord x, wxCoord y)
void wxDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2, wxCoord xc, wxCoord yc)
{
+ COLORREF colFgOld = 0,
+ colBgOld = 0;
+
+ if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
+ {
+ colFgOld = ::GetTextColor(GetHdc());
+ colBgOld = ::GetBkColor(GetHdc());
+
+ if (m_textForegroundColour.Ok())
+ { //just the oposite from what is expected see help on pattern brush
+ // 1 in mask becomes bk color
+ ::SetBkColor(GetHdc(), m_textForegroundColour.GetPixel() );
+ }
+ if (m_textBackgroundColour.Ok())
+ { //just the oposite from what is expected
+ // 0 in mask becomes text color
+ ::SetTextColor(GetHdc(), m_textBackgroundColour.GetPixel() );
+ }
+
+ if (m_backgroundMode == wxTRANSPARENT)
+ SetBkMode(GetHdc(), TRANSPARENT);
+ else
+ SetBkMode(GetHdc(), OPAQUE);
+ }
+
double dx = xc-x1;
double dy = yc-y1;
double radius = (double)sqrt(dx*dx+dy*dy) ;;
CalcBoundingBox((wxCoord)(xc-radius), (wxCoord)(yc-radius));
CalcBoundingBox((wxCoord)(xc+radius), (wxCoord)(yc+radius));
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ // restore the colours we changed
+ ::SetBkMode(GetHdc(), TRANSPARENT);
+ ::SetTextColor(GetHdc(), colFgOld);
+ ::SetBkColor(GetHdc(), colBgOld);
+ }
}
void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1,
// In WIN16, draw a cross
HPEN blackPen = ::CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
HPEN whiteBrush = (HPEN)::GetStockObject(WHITE_BRUSH);
- HPEN hPenOld = (HPEN)::SelectObject(hdcMem, blackPen);
- HPEN hBrushOld = (HPEN)::SelectObject(hdcMem, whiteBrush);
+ HPEN hPenOld = (HPEN)::SelectObject(GetHdc(), blackPen);
+ HPEN hBrushOld = (HPEN)::SelectObject(GetHdc(), whiteBrush);
::SetROP2(GetHdc(), R2_COPYPEN);
Rectangle(GetHdc(), x1, y1, x2, y2);
MoveTo(GetHdc(), x1, y1);
void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle)
{
- COLORREF old_textground = ::GetTextColor(GetHdc());
- COLORREF old_background = ::GetBkColor(GetHdc());
+ COLORREF colFgOld = 0,
+ colBgOld = 0;
+
if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
{
+ colFgOld = ::GetTextColor(GetHdc());
+ colBgOld = ::GetBkColor(GetHdc());
if (m_textForegroundColour.Ok())
{ //just the oposite from what is expected see help on pattern brush
SetPolyFillMode(GetHdc(),prev);
}
- if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
{
- ::SetBkMode(GetHdc(), TRANSPARENT);
- ::SetTextColor(GetHdc(), old_textground);
- ::SetBkColor(GetHdc(), old_background);
+ // restore the colours we changed
+ ::SetBkMode(GetHdc(), TRANSPARENT);
+ ::SetTextColor(GetHdc(), colFgOld);
+ ::SetBkColor(GetHdc(), colBgOld);
}
}
void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
{
+ COLORREF colFgOld = 0,
+ colBgOld = 0;
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ colFgOld = ::GetTextColor(GetHdc());
+ colBgOld = ::GetBkColor(GetHdc());
+
+ if ( m_textForegroundColour.Ok() )
+ {
+ // just the oposite from what is expected see help on pattern brush
+ // 1 in mask becomes bk color
+ ::SetBkColor(GetHdc(), m_textForegroundColour.GetPixel());
+ }
+
+ if ( m_textBackgroundColour.Ok() )
+ {
+ // 0 in mask becomes text color
+ ::SetTextColor(GetHdc(), m_textBackgroundColour.GetPixel());
+ }
+
+ // VZ: IMHO this does strictly nothing here
+ SetBkMode(GetHdc(), m_backgroundMode == wxTRANSPARENT ? TRANSPARENT
+ : OPAQUE);
+ }
+
// Now, a negative radius value is interpreted to mean
// 'the proportion of the smallest X or Y dimension'
CalcBoundingBox(x, y);
CalcBoundingBox(x2, y2);
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ // restore the colours we changed
+ ::SetBkMode(GetHdc(), TRANSPARENT);
+ ::SetTextColor(GetHdc(), colFgOld);
+ ::SetBkColor(GetHdc(), colBgOld);
+ }
}
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
+ COLORREF colFgOld = 0,
+ colBgOld = 0;
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ colFgOld = ::GetTextColor(GetHdc());
+ colBgOld = ::GetBkColor(GetHdc());
+
+ if ( m_textForegroundColour.Ok() )
+ {
+ // just the oposite from what is expected see help on pattern brush
+ // 1 in mask becomes bk color
+ ::SetBkColor(GetHdc(), m_textForegroundColour.GetPixel());
+ }
+
+ if ( m_textBackgroundColour.Ok() )
+ {
+ // 0 in mask becomes text color
+ ::SetTextColor(GetHdc(), m_textBackgroundColour.GetPixel());
+ }
+
+ // VZ: IMHO this does strictly nothing here
+ SetBkMode(GetHdc(), m_backgroundMode == wxTRANSPARENT ? TRANSPARENT
+ : OPAQUE);
+ }
+
wxCoord x2 = (x+width);
wxCoord y2 = (y+height);
CalcBoundingBox(x, y);
CalcBoundingBox(x2, y2);
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ // restore the colours we changed
+ ::SetBkMode(GetHdc(), TRANSPARENT);
+ ::SetTextColor(GetHdc(), colFgOld);
+ ::SetBkColor(GetHdc(), colBgOld);
+ }
}
// Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows
void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
{
+ COLORREF colFgOld = 0,
+ colBgOld = 0;
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ colFgOld = ::GetTextColor(GetHdc());
+ colBgOld = ::GetBkColor(GetHdc());
+
+ if ( m_textForegroundColour.Ok() )
+ {
+ // just the oposite from what is expected see help on pattern brush
+ // 1 in mask becomes bk color
+ ::SetBkColor(GetHdc(), m_textForegroundColour.GetPixel());
+ }
+
+ if ( m_textBackgroundColour.Ok() )
+ {
+ // 0 in mask becomes text color
+ ::SetTextColor(GetHdc(), m_textBackgroundColour.GetPixel());
+ }
+
+ // VZ: IMHO this does strictly nothing here
+ SetBkMode(GetHdc(), m_backgroundMode == wxTRANSPARENT ? TRANSPARENT
+ : OPAQUE);
+ }
+
wxCoord x2 = (x+w);
wxCoord y2 = (y+h);
CalcBoundingBox(x, y);
CalcBoundingBox(x2, y2);
+
+ if ( m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
+ {
+ // restore the colours we changed
+ ::SetBkMode(GetHdc(), TRANSPARENT);
+ ::SetTextColor(GetHdc(), colFgOld);
+ ::SetBkColor(GetHdc(), colBgOld);
+ }
}
void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
if (m_brush.Ok())
{
- if (m_brush.GetResourceHandle())
+ // to make sure the brush is alligned with the logical coordinates
+ wxBitmap *stipple = m_brush.GetStipple();
+ if ( stipple && stipple->Ok() )
+ {
+ ::SetBrushOrgEx(GetHdc(),
+ m_deviceOriginX % stipple->GetWidth(),
+ m_deviceOriginY % stipple->GetHeight(),
+ NULL); // don't need previous brush origin
+ }
+
+ if ( m_brush.GetResourceHandle() )
{
HBRUSH b = 0;
b = (HBRUSH) ::SelectObject(GetHdc(), (HBRUSH)m_brush.GetResourceHandle());