00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __WXDCDRAWER_H__
00016 #define __WXDCDRAWER_H__
00017
00018 #ifndef WX_PRECOMP
00019 #include "wx/wx.h"
00020 #endif
00021
00022
00023
00024
00025 #include <wx/dcclient.h>
00026 #include <wx/dcmemory.h>
00027
00028 #include "wx/artbase/drawer2d.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class A2DARTBASEDLLEXP a2dDcDrawer : public a2dDrawer2D
00044 {
00045 public:
00046
00047
00048 a2dDcDrawer( int width = 0, int height = 0 );
00049
00050
00051 a2dDcDrawer( const wxSize& size );
00052
00053
00054
00055
00056
00057
00058 void SetBufferSize( int w, int h );
00059
00060 wxBitmap GetBuffer() const { return wxBitmap( 0, 0 ); }
00061
00062
00063 wxBitmap GetSubBitmap( wxRect sub_rect ) const;
00064
00065
00066 virtual ~a2dDcDrawer();
00067
00068
00069 a2dDcDrawer( const a2dDcDrawer& other );
00070
00071 a2dDcDrawer( const a2dDrawer2D& other );
00072
00073 virtual void BlitBuffer( wxRect rect, const wxPoint& bufferpos = wxPoint( 0, 0 ) );
00074
00075 virtual void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos = wxPoint( 0, 0 ) );
00076
00077 void ResetStyle();
00078
00079
00080 virtual void BeginDraw();
00081
00082
00083 virtual void EndDraw();
00084
00085
00086 virtual wxDC* GetRenderDC() const { return m_renderDC; }
00087
00088
00089
00090
00091
00092
00093
00094 void SetRenderDC( wxDC* dc );
00095
00096 wxDC* GetDeviceDC() const { return m_deviceDC; }
00097
00098 void SetClippingRegion( a2dVertexList* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00099
00100 virtual void ExtendClippingRegion( a2dVertexList* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE, a2dBooleanClip clipoperation = a2dCLIP_AND );
00101
00102 virtual void ExtendAndPushClippingRegion( a2dVertexList* points, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE, a2dBooleanClip clipoperation = a2dCLIP_AND );
00103
00104 void PopClippingRegion();
00105
00106 void SetClippingRegionDev( wxCoord minx, wxCoord miny, wxCoord width, wxCoord height );
00107 void SetClippingRegion( double minx, double miny, double maxx, double maxy );
00108 void DestroyClippingRegion();
00109
00110
00111
00112
00113 void DrawImage( const wxImage& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00114
00115 void DrawImage( const a2dImageRGBA& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00116
00117 void DrawRoundedRectangle( double x, double y, double width, double height, double radius, bool pixelsize = false );
00118
00119
00120 void DrawVpath( const a2dVpath* path );
00121
00122 void DrawPolyPolygon( a2dListOfa2dVertexList polylist, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00123
00124
00125 void DrawCircle( double xc, double yc, double radius );
00126
00127 void DrawEllipse( double xc, double yc, double width, double height );
00128
00129 void DrawLine( double x1, double y1, double x2, double y2 );
00130
00131
00132 void DrawPoint( double xc, double yc );
00133
00134 virtual void DeviceDrawAnnotation( const wxString& text, wxCoord x, wxCoord y, const wxFont& font );
00135
00136 protected:
00137
00138 virtual void DoSetDrawStyle( a2dDrawStyle drawstyle );
00139
00140 void DoSetActiveStroke();
00141
00142 void DoSetActiveFill();
00143
00144
00145 virtual void DeviceDrawPolygon( unsigned int n, bool spline , wxPolygonFillMode fillStyle );
00146
00147
00148 virtual void DeviceDrawLines( unsigned int n, bool spline );
00149
00150 void DeviceDrawLine( double x1, double y1, double x2, double y2 );
00151
00152 void DeviceDrawHorizontalLine( int x1, int y1, int x2, bool use_stroke_color);
00153
00154 void DeviceDrawVerticalLine( int x1, int y1, int y2, bool use_stroke_color);
00155
00156 void DeviceDrawPixel( int x1, int y1, unsigned char r, unsigned char g, unsigned char b, unsigned char a );
00157
00158
00159 void DeviceDrawBitmap( const wxBitmap &bmp, double x, double y,
00160 bool useMask = false );
00161
00162 void SetLogicalFunction( wxRasterOperationMode function );
00163
00164
00165 virtual void DrawCharDc( wxChar c );
00166
00167 virtual void DrawTextDc( const wxString& text, double x, double y );
00168
00169
00170 virtual void DrawCharFreetype( wxChar c );
00171
00172
00173
00174 wxDC* m_renderDC;
00175
00176
00177
00178 wxClientDC* m_deviceDC;
00179
00180
00181 bool m_externalDc;
00182
00183 private:
00184
00185 wxRegion m_clip;
00186
00187 DECLARE_DYNAMIC_CLASS( a2dDcDrawer )
00188 };
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 class A2DARTBASEDLLEXP a2dMemDcDrawer : public a2dDcDrawer
00204 {
00205 public:
00206
00207
00208 a2dMemDcDrawer( int width = 0, int height = 0 );
00209
00210
00211 a2dMemDcDrawer( const wxSize& size );
00212
00213
00214 virtual void BeginDraw();
00215
00216
00217 virtual void EndDraw();
00218
00219
00220 wxBitmap GetBuffer() const {return m_buffer;}
00221
00222
00223 void SetBufferSize( int w, int h );
00224
00225
00226 wxBitmap GetSubBitmap( wxRect sub_rect ) const;
00227
00228
00229 virtual ~a2dMemDcDrawer();
00230
00231
00232 a2dMemDcDrawer( const a2dMemDcDrawer& other );
00233
00234
00235
00236
00237 void DrawImage( const wxImage& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00238
00239 void DrawImage( const a2dImageRGBA& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00240
00241 void CopyIntoBuffer( const wxBitmap& bitm );
00242
00243 virtual void BlitBuffer( wxRect rect, const wxPoint& bufferpos = wxPoint( 0, 0 ) );
00244
00245 virtual void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos = wxPoint( 0, 0 ) );
00246
00247 virtual void ShiftBuffer( int dxy, bool yshift );
00248
00249 protected:
00250
00251 virtual void DrawPolygon( const a2dVertexList* list, bool spline = false, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
00252
00253 virtual void DeviceDrawPolygon( unsigned int n, bool spline , wxPolygonFillMode fillStyle );
00254
00255
00256 wxBitmap m_buffer;
00257
00258
00259 wxMemoryDC* m_memdc;
00260
00261 private:
00262
00263 DECLARE_DYNAMIC_CLASS( a2dMemDcDrawer )
00264 };
00265
00266 #if wxART2D_USE_GRAPHICS_CONTEXT
00267
00268
00269
00270
00271
00272
00273
00274 class a2dGcDrawer : public a2dGcBaseDrawer
00275 {
00276 DECLARE_DYNAMIC_CLASS(a2dGcDrawer)
00277
00278 public:
00279
00280
00281 a2dGcDrawer( int width = 0, int height = 0 );
00282
00283
00284 a2dGcDrawer( const wxSize& size );
00285
00286
00287
00288 a2dGcDrawer( const wxBitmap& bitmap );
00289
00290
00291 wxBitmap GetBuffer() const;
00292
00293
00294 a2dGcDrawer( const a2dGcDrawer& other );
00295
00296 a2dGcDrawer( const a2dDrawer2D& other );
00297
00298
00299 void SetBufferSize( int w, int h );
00300
00301
00302 wxBitmap GetSubBitmap( wxRect sub_rect ) const;
00303
00304 virtual ~a2dGcDrawer();
00305
00306 virtual void SetYaxis( bool up );
00307
00308 void InitContext();
00309
00310 void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos = wxPoint(0,0) );
00311
00312 void ShiftBuffer( int dxy, bool yshift );
00313
00314 void DrawPoint( double xc, double yc );
00315
00316 void DrawImage( const wxImage& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00317
00318 void DrawImage( const a2dImageRGBA& image, double x, double y, double width, double height, wxUint8 Opacity = 255 );
00319
00320 protected:
00321
00322 void DoSetActiveStroke();
00323
00324 void DoSetActiveFill();
00325
00326 void DoSetActiveFont( const a2dFont& font );
00327
00328
00329 wxBitmap m_buffer;
00330
00331
00332 wxMemoryDC m_memdc;
00333
00334
00335 bool m_externalDc;
00336 };
00337
00338 #endif // wxART2D_USE_GRAPHICS_CONTEXT
00339
00340
00341 #endif
00342