1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClientDC, wxPaintDC and wxWindowDC classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DCCLIENT_H_
13 #define _WX_DCCLIENT_H_
16 #pragma interface "dcclient.h"
21 // -----------------------------------------------------------------------------
23 // -----------------------------------------------------------------------------
25 class WXDLLEXPORT wxWindowDC
;
26 class WXDLLEXPORT wxWindow
;
28 // Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented
29 // differently. On many platforms, however, they will be the same.
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 class WXDLLEXPORT wxWindowDC
: public wxDC
37 DECLARE_DYNAMIC_CLASS(wxWindowDC
)
41 wxWindowDC( wxWindow
*win
);
45 // TODO this function is Motif-only for now - should it go into base class?
46 void Clear(const wxRect
& rect
);
48 // implement base class pure virtuals
49 // ----------------------------------
53 virtual void SetFont(const wxFont
& font
);
54 virtual void SetPen(const wxPen
& pen
);
55 virtual void SetBrush(const wxBrush
& brush
);
56 virtual void SetBackground(const wxBrush
& brush
);
57 virtual void SetBackgroundMode(int mode
);
58 virtual void SetPalette(const wxPalette
& palette
);
59 virtual void SetLogicalFunction( int function
);
61 virtual void SetTextForeground(const wxColour
& colour
);
62 virtual void SetTextBackground(const wxColour
& colour
);
64 virtual wxCoord
GetCharHeight() const;
65 virtual wxCoord
GetCharWidth() const;
66 virtual void DoGetTextExtent(const wxString
& string
,
67 wxCoord
*x
, wxCoord
*y
,
68 wxCoord
*descent
= NULL
,
69 wxCoord
*externalLeading
= NULL
,
70 wxFont
*theFont
= NULL
) const;
72 virtual bool CanDrawBitmap() const;
73 virtual bool CanGetTextExtent() const;
75 virtual int GetDepth() const;
76 virtual wxSize
GetPPI() const;
78 virtual void DestroyClippingRegion();
80 // Helper function for setting clipping
83 // implementation from now on
84 // --------------------------
86 WXGC
GetGC() const { return m_gc
; }
87 WXGC
GetBackingGC() const { return m_gcBacking
; }
88 WXDisplay
* GetDisplay() const { return m_display
; }
89 bool GetAutoSetting() const { return m_autoSetting
; }
90 void SetAutoSetting(bool flag
) { m_autoSetting
= flag
; }
93 // note that this function will call colour.SetPixel,
94 // and will do one of curCol = colour, curCol = wxWHITE, curCol = wxBLACK
95 // roundToWhite has an effect for monochrome display only
96 // if roundToWhite == TRUE then the colour will be set to white unless
97 // it is RGB 0x000000;if roundToWhite == FALSE the colour wull be set to
98 // black unless it id RGB 0xffffff
99 int CalculatePixel(wxColour
& colour
, wxColour
& curCol
,
100 bool roundToWhite
) const;
101 // sets the foreground pixel taking into account the
102 // currently selected logical operation
103 void SetForegroundPixelWithLogicalFunction(int pixel
);
105 virtual bool DoFloodFill(wxCoord x
, wxCoord y
, const wxColour
& col
,
106 int style
= wxFLOOD_SURFACE
);
108 virtual bool DoGetPixel(wxCoord x
, wxCoord y
, wxColour
*col
) const;
110 virtual void DoDrawPoint(wxCoord x
, wxCoord y
);
111 virtual void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
113 virtual void DoDrawArc(wxCoord x1
, wxCoord y1
,
114 wxCoord x2
, wxCoord y2
,
115 wxCoord xc
, wxCoord yc
);
116 virtual void DoDrawEllipticArc(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
117 double sa
, double ea
);
119 virtual void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
120 virtual void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
121 wxCoord width
, wxCoord height
,
123 virtual void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
125 virtual void DoCrossHair(wxCoord x
, wxCoord y
);
127 virtual void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
128 virtual void DoDrawRotatedText(const wxString
&text
, wxCoord x
, wxCoord y
, double angle
);
130 virtual bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
131 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
132 int rop
= wxCOPY
, bool useMask
= FALSE
, wxCoord xsrcMask
= -1, wxCoord ysrcMask
= -1);
134 virtual void DoSetClippingRegionAsRegion(const wxRegion
& region
);
135 virtual void DoSetClippingRegion(wxCoord x
, wxCoord y
,
136 wxCoord width
, wxCoord height
);
138 virtual void DoDrawLines(int n
, wxPoint points
[],
139 wxCoord xoffset
, wxCoord yoffset
);
140 virtual void DoDrawPolygon(int n
, wxPoint points
[],
141 wxCoord xoffset
, wxCoord yoffset
,
142 int fillStyle
= wxODDEVEN_RULE
);
146 WXDisplay
* m_display
;
148 WXRegion m_currentRegion
; // Current clipping region (incl. paint clip region)
149 WXRegion m_userRegion
; // User-defined clipping region
150 WXPixmap m_pixmap
; // Pixmap for drawing on
152 // Not sure if we'll need all of these
153 int m_backgroundPixel
;
154 wxColour m_currentColour
;
155 // int m_currentBkMode;
156 int m_currentPenWidth
;
157 int m_currentPenJoin
;
158 int m_currentPenCap
;
159 int m_currentPenDashCount
;
160 wxMOTIFDash
* m_currentPenDash
;
161 wxBitmap m_currentStipple
;
164 int m_autoSetting
; // See comment in dcclient.cpp
168 class WXDLLEXPORT wxPaintDC
: public wxWindowDC
170 DECLARE_DYNAMIC_CLASS(wxPaintDC
)
174 wxPaintDC(wxWindow
* win
);
179 class WXDLLEXPORT wxClientDC
: public wxWindowDC
181 DECLARE_DYNAMIC_CLASS(wxClientDC
)
185 wxClientDC(wxWindow
* win
) : wxWindowDC(win
) { }