(all bits set to 0). See also \helpref{SetTextForeground}{wxdcsettextforeground},
\helpref{SetTextBackground}{wxdcsettextbackground} and \helpref{wxMemoryDC}{wxmemorydc}.
+\membersection{wxDC::DrawCheckMark}\label{wxdcdrawcheckmark}
+
+\func{void}{DrawCheckMark}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
+
+\func{void}{DrawCheckMark}{\param{const wxRect \&}{rect}}
+
+Draws a check mark inside the given rectangle.
+
\membersection{wxDC::DrawEllipse}\label{wxdcdrawellipse}
\func{void}{DrawEllipse}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
class WXDLLEXPORT wxDCBase : public wxObject
{
- DECLARE_ABSTRACT_CLASS(wxDCBase)
-
public:
wxDCBase()
{
void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
{ DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
+ void DrawCheckMark(wxCoord x, wxCoord y,
+ wxCoord width, wxCoord height)
+ { DoDrawCheckMark(x, y, width, height); }
+ void DrawCheckMark(const wxRect& rect)
+ { DoDrawCheckMark(rect.x, rect.y, rect.width, rect.height); }
+
void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea)
{ DoDrawEllipticArc(x, y, w, h, sa, ea); }
virtual wxCoord GetCharHeight() const = 0;
virtual wxCoord GetCharWidth() const = 0;
-
+
void GetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
*y = y2;
}
void GetClippingBox(long *x, long *y, long *w, long *h) const
- {
- wxCoord xx,yy,ww,hh;
- DoGetClippingBox(&xx, &yy, &ww, &hh);
- if (x) *x = xx;
- if (y) *y = yy;
- if (w) *w = ww;
- if (h) *h = hh;
+ {
+ wxCoord xx,yy,ww,hh;
+ DoGetClippingBox(&xx, &yy, &ww, &hh);
+ if (x) *x = xx;
+ if (y) *y = yy;
+ if (w) *w = ww;
+ if (h) *h = hh;
}
#endif // !Win16
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc) = 0;
+ virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
+ wxCoord width, wxCoord height);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea) = 0;
private:
DECLARE_NO_COPY_CLASS(wxDCBase);
+ DECLARE_ABSTRACT_CLASS(wxDCBase)
};
// ----------------------------------------------------------------------------
virtual bool CanDrawBitmap() const { return TRUE; }
virtual bool CanGetTextExtent() const { return TRUE; }
+//protected:
virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE );
virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const;
void ComputeScaleAndOrigin();
GdkWindow *GetWindow() { return m_window; }
-
+
private:
DECLARE_DYNAMIC_CLASS(wxWindowDC)
};
public:
wxPaintDC();
wxPaintDC( wxWindow *win );
-
+
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
};
public:
wxClientDC();
wxClientDC( wxWindow *win );
-
+
private:
DECLARE_DYNAMIC_CLASS(wxClientDC)
};
virtual bool CanDrawBitmap() const { return TRUE; }
virtual bool CanGetTextExtent() const { return TRUE; }
+//protected:
virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE );
virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const;
void ComputeScaleAndOrigin();
GdkWindow *GetWindow() { return m_window; }
-
+
private:
DECLARE_DYNAMIC_CLASS(wxWindowDC)
};
public:
wxPaintDC();
wxPaintDC( wxWindow *win );
-
+
private:
DECLARE_DYNAMIC_CLASS(wxPaintDC)
};
public:
wxClientDC();
wxClientDC( wxWindow *win );
-
+
private:
DECLARE_DYNAMIC_CLASS(wxClientDC)
};
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc);
+ virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
+ wxCoord width, wxCoord height);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea);
dc.DrawIcon( wxICON(mondrian), 40, 40 );
+ dc.DrawCheckMark(5, 80, 15, 15);
+ dc.DrawCheckMark(25, 80, 30, 30);
+ dc.DrawCheckMark(60, 80, 60, 60);
+
// this is the test for "blitting bitmap into DC damages selected brush"
// bug
+ wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
+ wxCoord rectSize = icon.GetWidth() + 10;
+ wxCoord x = 100;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush( *wxGREEN_BRUSH );
- dc.DrawRectangle(100, 10, 40, 40);
- dc.DrawBitmap(wxTheApp->GetStdIcon(wxICON_INFORMATION), 102, 12, TRUE);
- dc.DrawRectangle(150, 10, 40, 40);
- dc.DrawIcon(wxTheApp->GetStdIcon(wxICON_INFORMATION), 152, 12);
- dc.DrawRectangle(200, 10, 40, 40);
+ dc.DrawRectangle(x, 10, rectSize, rectSize);
+ dc.DrawBitmap(icon, x + 5, 15, TRUE);
+ x += rectSize + 10;
+ dc.DrawRectangle(x, 10, rectSize, rectSize);
+ dc.DrawIcon(wxTheApp->GetStdIcon(wxICON_INFORMATION), x + 5, 15);
+ x += rectSize + 10;
+ dc.DrawRectangle(x, 10, rectSize, rectSize);
// test for "transparent" bitmap drawing (it intersects with the last
// rectangle above)
//dc.SetBrush( *wxTRANSPARENT_BRUSH );
#include "../image/smile.xpm"
wxBitmap bmp(smile_xpm);
- dc.DrawBitmap(bmp, 210, 30, TRUE);
+ dc.DrawBitmap(bmp, x + rectSize - 20, rectSize - 10, TRUE);
dc.SetBrush( *wxBLACK_BRUSH );
dc.DrawRectangle( 0, 160, 1000, 300 );
memdc2.DrawRectangle(0, 0, totalWidth, totalHeight);
- memdc2.SelectObject(wxNullBitmap);
memdc2.SetPen(wxNullPen);
memdc2.SetBrush(wxNullBrush);
+ memdc2.SelectObject(wxNullBitmap);
dc.DrawBitmap(bitmap2, 500, 270);
}
#include "wx/dc.h"
+void wxDCBase::DoDrawCheckMark(wxCoord x1, wxCoord y1,
+ wxCoord width, wxCoord height)
+{
+ wxCHECK_RET( Ok(), wxT("invalid window dc") );
+
+ wxCoord x2 = x1 + width,
+ y2 = y1 + height;
+
+ // this is to yield width of 3 for width == height == 10
+ SetPen(wxPen(GetTextForeground(), (width + height + 1) / 7, wxSOLID));
+
+ // we're drawing a scaled version of wx/generic/tick.xpm here
+ wxCoord x3 = x1 + (4*width) / 10, // x of the tick bottom
+ y3 = y1 + height / 2; // y of the left tick branch
+ DoDrawLine(x1, y3, x3, y2);
+ DoDrawLine(x3, y2, x2, y1);
+
+ CalcBoundingBox(x1, y1);
+ CalcBoundingBox(x2, y2);
+}
+
void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset)
{
int n = list->Number();
CalcBoundingBox((wxCoord)(xc+radius), (wxCoord)(yc+radius));
}
+void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1,
+ wxCoord width, wxCoord height)
+{
+ wxCoord x2 = x1 + width,
+ y2 = y1 + height;
+
+#if defined(__WIN32__) && !defined(__SC__)
+ RECT rect;
+ rect.left = x1;
+ rect.top = y1;
+ rect.right = x2;
+ rect.bottom = y2;
+
+ DrawFrameControl(GetHdc(), &rect, DFC_MENU, DFCS_MENUCHECK);
+#else // Win16
+ // 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);
+ ::SetROP2(GetHdc(), R2_COPYPEN);
+ Rectangle(GetHdc(), x1, y1, x2, y2);
+ MoveTo(GetHdc(), x1, y1);
+ LineTo(GetHdc(), x2, y2);
+ MoveTo(GetHdc(), x2, y1);
+ LineTo(GetHdc(), x1, y2);
+ ::SelectObject(GetHdc(), hPenOld);
+ ::SelectObject(GetHdc(), hBrushOld);
+ ::DeleteObject(blackPen);
+#endif // Win32/16
+
+ CalcBoundingBox(x1, y1);
+ CalcBoundingBox(x2, y2);
+}
+
void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
{
COLORREF color = 0x00ffffff;