added and documented wxDC::DrawCheckMark()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6109 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6d516e09b3
commit
cd9da20028
@ -179,6 +179,14 @@ of the bitmap (all bits set to 1), and the current text background colour to dra
|
|||||||
(all bits set to 0). See also \helpref{SetTextForeground}{wxdcsettextforeground},
|
(all bits set to 0). See also \helpref{SetTextForeground}{wxdcsettextforeground},
|
||||||
\helpref{SetTextBackground}{wxdcsettextbackground} and \helpref{wxMemoryDC}{wxmemorydc}.
|
\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}
|
\membersection{wxDC::DrawEllipse}\label{wxdcdrawellipse}
|
||||||
|
|
||||||
\func{void}{DrawEllipse}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
|
\func{void}{DrawEllipse}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
|
||||||
|
@ -43,8 +43,6 @@ WXDLLEXPORT_DATA(extern int) wxPageNumber;
|
|||||||
|
|
||||||
class WXDLLEXPORT wxDCBase : public wxObject
|
class WXDLLEXPORT wxDCBase : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_ABSTRACT_CLASS(wxDCBase)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxDCBase()
|
wxDCBase()
|
||||||
{
|
{
|
||||||
@ -112,6 +110,12 @@ public:
|
|||||||
void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
|
void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre)
|
||||||
{ DoDrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); }
|
{ 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,
|
void DrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||||
double sa, double ea)
|
double sa, double ea)
|
||||||
{ DoDrawEllipticArc(x, y, w, h, sa, ea); }
|
{ DoDrawEllipticArc(x, y, w, h, sa, ea); }
|
||||||
@ -261,7 +265,7 @@ public:
|
|||||||
|
|
||||||
virtual wxCoord GetCharHeight() const = 0;
|
virtual wxCoord GetCharHeight() const = 0;
|
||||||
virtual wxCoord GetCharWidth() const = 0;
|
virtual wxCoord GetCharWidth() const = 0;
|
||||||
|
|
||||||
void GetTextExtent(const wxString& string,
|
void GetTextExtent(const wxString& string,
|
||||||
wxCoord *x, wxCoord *y,
|
wxCoord *x, wxCoord *y,
|
||||||
wxCoord *descent = NULL,
|
wxCoord *descent = NULL,
|
||||||
@ -453,13 +457,13 @@ public:
|
|||||||
*y = y2;
|
*y = y2;
|
||||||
}
|
}
|
||||||
void GetClippingBox(long *x, long *y, long *w, long *h) const
|
void GetClippingBox(long *x, long *y, long *w, long *h) const
|
||||||
{
|
{
|
||||||
wxCoord xx,yy,ww,hh;
|
wxCoord xx,yy,ww,hh;
|
||||||
DoGetClippingBox(&xx, &yy, &ww, &hh);
|
DoGetClippingBox(&xx, &yy, &ww, &hh);
|
||||||
if (x) *x = xx;
|
if (x) *x = xx;
|
||||||
if (y) *y = yy;
|
if (y) *y = yy;
|
||||||
if (w) *w = ww;
|
if (w) *w = ww;
|
||||||
if (h) *h = hh;
|
if (h) *h = hh;
|
||||||
}
|
}
|
||||||
#endif // !Win16
|
#endif // !Win16
|
||||||
|
|
||||||
@ -485,6 +489,8 @@ protected:
|
|||||||
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
||||||
wxCoord x2, wxCoord y2,
|
wxCoord x2, wxCoord y2,
|
||||||
wxCoord xc, wxCoord yc) = 0;
|
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,
|
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||||
double sa, double ea) = 0;
|
double sa, double ea) = 0;
|
||||||
|
|
||||||
@ -605,6 +611,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxDCBase);
|
DECLARE_NO_COPY_CLASS(wxDCBase);
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxDCBase)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
virtual bool CanDrawBitmap() const { return TRUE; }
|
virtual bool CanDrawBitmap() const { return TRUE; }
|
||||||
virtual bool CanGetTextExtent() 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 void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE );
|
||||||
virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const;
|
virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const;
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public:
|
|||||||
void ComputeScaleAndOrigin();
|
void ComputeScaleAndOrigin();
|
||||||
|
|
||||||
GdkWindow *GetWindow() { return m_window; }
|
GdkWindow *GetWindow() { return m_window; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
||||||
};
|
};
|
||||||
@ -135,7 +136,7 @@ class wxPaintDC : public wxWindowDC
|
|||||||
public:
|
public:
|
||||||
wxPaintDC();
|
wxPaintDC();
|
||||||
wxPaintDC( wxWindow *win );
|
wxPaintDC( wxWindow *win );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxPaintDC)
|
DECLARE_DYNAMIC_CLASS(wxPaintDC)
|
||||||
};
|
};
|
||||||
@ -149,7 +150,7 @@ class wxClientDC : public wxWindowDC
|
|||||||
public:
|
public:
|
||||||
wxClientDC();
|
wxClientDC();
|
||||||
wxClientDC( wxWindow *win );
|
wxClientDC( wxWindow *win );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
||||||
};
|
};
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
virtual bool CanDrawBitmap() const { return TRUE; }
|
virtual bool CanDrawBitmap() const { return TRUE; }
|
||||||
virtual bool CanGetTextExtent() 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 void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE );
|
||||||
virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const;
|
virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const;
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public:
|
|||||||
void ComputeScaleAndOrigin();
|
void ComputeScaleAndOrigin();
|
||||||
|
|
||||||
GdkWindow *GetWindow() { return m_window; }
|
GdkWindow *GetWindow() { return m_window; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
||||||
};
|
};
|
||||||
@ -135,7 +136,7 @@ class wxPaintDC : public wxWindowDC
|
|||||||
public:
|
public:
|
||||||
wxPaintDC();
|
wxPaintDC();
|
||||||
wxPaintDC( wxWindow *win );
|
wxPaintDC( wxWindow *win );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxPaintDC)
|
DECLARE_DYNAMIC_CLASS(wxPaintDC)
|
||||||
};
|
};
|
||||||
@ -149,7 +150,7 @@ class wxClientDC : public wxWindowDC
|
|||||||
public:
|
public:
|
||||||
wxClientDC();
|
wxClientDC();
|
||||||
wxClientDC( wxWindow *win );
|
wxClientDC( wxWindow *win );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
||||||
};
|
};
|
||||||
|
@ -153,6 +153,8 @@ protected:
|
|||||||
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
||||||
wxCoord x2, wxCoord y2,
|
wxCoord x2, wxCoord y2,
|
||||||
wxCoord xc, wxCoord yc);
|
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,
|
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||||
double sa, double ea);
|
double sa, double ea);
|
||||||
|
|
||||||
|
@ -574,22 +574,31 @@ void MyCanvas::DrawDefault(wxDC& dc)
|
|||||||
|
|
||||||
dc.DrawIcon( wxICON(mondrian), 40, 40 );
|
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"
|
// this is the test for "blitting bitmap into DC damages selected brush"
|
||||||
// bug
|
// bug
|
||||||
|
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
|
||||||
|
wxCoord rectSize = icon.GetWidth() + 10;
|
||||||
|
wxCoord x = 100;
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.SetBrush( *wxGREEN_BRUSH );
|
dc.SetBrush( *wxGREEN_BRUSH );
|
||||||
dc.DrawRectangle(100, 10, 40, 40);
|
dc.DrawRectangle(x, 10, rectSize, rectSize);
|
||||||
dc.DrawBitmap(wxTheApp->GetStdIcon(wxICON_INFORMATION), 102, 12, TRUE);
|
dc.DrawBitmap(icon, x + 5, 15, TRUE);
|
||||||
dc.DrawRectangle(150, 10, 40, 40);
|
x += rectSize + 10;
|
||||||
dc.DrawIcon(wxTheApp->GetStdIcon(wxICON_INFORMATION), 152, 12);
|
dc.DrawRectangle(x, 10, rectSize, rectSize);
|
||||||
dc.DrawRectangle(200, 10, 40, 40);
|
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
|
// test for "transparent" bitmap drawing (it intersects with the last
|
||||||
// rectangle above)
|
// rectangle above)
|
||||||
//dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
//dc.SetBrush( *wxTRANSPARENT_BRUSH );
|
||||||
#include "../image/smile.xpm"
|
#include "../image/smile.xpm"
|
||||||
wxBitmap bmp(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.SetBrush( *wxBLACK_BRUSH );
|
||||||
dc.DrawRectangle( 0, 160, 1000, 300 );
|
dc.DrawRectangle( 0, 160, 1000, 300 );
|
||||||
@ -722,9 +731,9 @@ void MyCanvas::DrawDefault(wxDC& dc)
|
|||||||
|
|
||||||
memdc2.DrawRectangle(0, 0, totalWidth, totalHeight);
|
memdc2.DrawRectangle(0, 0, totalWidth, totalHeight);
|
||||||
|
|
||||||
memdc2.SelectObject(wxNullBitmap);
|
|
||||||
memdc2.SetPen(wxNullPen);
|
memdc2.SetPen(wxNullPen);
|
||||||
memdc2.SetBrush(wxNullBrush);
|
memdc2.SetBrush(wxNullBrush);
|
||||||
|
memdc2.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
dc.DrawBitmap(bitmap2, 500, 270);
|
dc.DrawBitmap(bitmap2, 500, 270);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,27 @@
|
|||||||
|
|
||||||
#include "wx/dc.h"
|
#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)
|
void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset)
|
||||||
{
|
{
|
||||||
int n = list->Number();
|
int n = list->Number();
|
||||||
|
@ -409,6 +409,41 @@ void wxDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2, wxCoord xc, wx
|
|||||||
CalcBoundingBox((wxCoord)(xc+radius), (wxCoord)(yc+radius));
|
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)
|
void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
|
||||||
{
|
{
|
||||||
COLORREF color = 0x00ffffff;
|
COLORREF color = 0x00ffffff;
|
||||||
|
Loading…
Reference in New Issue
Block a user