Main Page   Class Hierarchy   Compound List   File List   Compound Members  

doubledc.h

00001 
00002 // Name:        doubledc.h
00003 // Purpose:     wxDoubleDCBase class
00006 // Licence:     wxWindows licence
00008 #ifndef _DOUBLEDC
00009 #define _DOUBLEDC
00010 
00011 #ifdef __GNUG__
00012 #pragma interface
00013 #endif
00014 
00015 #define MAX_POINTS_TODRAW 40000
00016 #define MININT -30000
00017 #define MAXINT  30000
00018 
00019 // ----------------------------------------------------------------------------
00020 // headers
00021 // ----------------------------------------------------------------------------
00022 
00023 #include <math.h>
00024 
00025 #include "wxmatrix.h"
00026 #include "wx/image.h"
00027 #include "wx/geometry.h"
00028 #include "wx/wxprec.h"
00029 
00030 #ifdef __BORLANDC__
00031     #pragma hdrstop
00032 #endif
00033 
00034 #ifndef WX_PRECOMP
00035     #include "wx/wx.h"
00036 #endif
00037 
00039 
00063 class WXDLLEXPORT wxDoubleDCBase
00064 {
00065 public:
00066 
00068     wxDoubleDCBase();
00069 
00071     virtual ~wxDoubleDCBase();
00072 
00074     wxDC* SetDC(wxDC* newdc);
00075 
00077     wxDC* GetDC(){return m_dc;};
00078 
00080     double      GetScaleFactorX(){return m_scalefactor_x;};
00081 
00083     double      GetScaleFactorY(){return m_scalefactor_y;};
00084 
00086     int         GetClipCode(double,double);
00087 
00089     bool        Clipping(double&,double&);
00090 
00092     bool        Clipping(double&,double&,double&,double&);
00093 
00095     wxTransformMatrix   GetInverseMappingMatrix();
00096 
00098     wxTransformMatrix   GetMappingMatrix();
00099 
00101 
00108     void SetMapping(int dwxi, int dwyi,double vx1,double vy1,double vx2,double vy2,bool border);
00109 
00110     /* ------------------
00111     // graphic primitives
00112     --------------------*/
00113 
00114     void FloodFill(double x, double y, const wxColour& col,
00115                    int style = wxFLOOD_SURFACE);
00116     void FloodFill(const wxPoint2DDouble& pt, const wxColour& col,
00117                    int style = wxFLOOD_SURFACE);
00118     bool GetPixel(double x, double y, wxColour *col);
00119     bool GetPixel(const wxPoint2DDouble& pt, wxColour *col);
00120 
00122     void DrawLine(double x1, double y1, double x2, double y2);
00123 
00125     void DrawLine(const wxPoint2DDouble& pt1, const wxPoint2DDouble& pt2);
00126     void CrossHair(double x, double y);
00127     void CrossHair(const wxPoint2DDouble& pt);
00128     void DrawArc(double x1, double y1, double x2, double y2,
00129                  double xc, double yc);
00130     void DrawArc(const wxPoint2DDouble& pt1, const wxPoint2DDouble& pt2, const wxPoint2DDouble& centre);
00131 
00133     void DrawCheckMark(double x, double y,
00134                        double width, double height);
00135     void DrawCheckMark(const wxRect2DDouble& rect);
00136 
00137     void DrawEllipticArc(double x, double y, double w, double h,
00138                          double sa, double ea);
00139     void DrawEllipticArc(const wxPoint2DDouble& pt, const wxSize& sz,
00140                          double sa, double ea);
00141     void DrawPoint(double x, double y);
00142     void DrawPoint(const wxPoint2DDouble& pt);
00143 
00146     void DrawLines(int n, wxPoint2DDouble points[],
00147                    double xoffset = 0, double yoffset = 0);
00148 
00150 
00154     void DrawLines(const wxList *list,
00155                    double xoffset = 0, double yoffset = 0);
00156 
00158 
00163     void DrawPolygon(int n, wxPoint2DDouble points[],
00164                      double xoffset = 0, double yoffset = 0,
00165                      int fillStyle = wxODDEVEN_RULE);
00166 
00167     void DrawPolygon(const wxList *list,
00168                      double xoffset = 0, double yoffset = 0,
00169                      int fillStyle = wxODDEVEN_RULE);
00170 
00173     void DrawRectangle(double x, double y, double width, double height);
00174     void DrawRectangle(const wxPoint2DDouble& pt, const wxSize& sz);
00175     void DrawRectangle(const wxRect2DDouble& rect);
00176 
00178 
00187     void DrawRoundedRectangle(double x, double y, double width, double height,
00188                               double radius);
00189     void DrawRoundedRectangle(const wxPoint2DDouble& pt, const wxSize& sz,
00190                              double radius);
00191     void DrawRoundedRectangle(const wxRect2DDouble& r, double radius);
00192 
00194     void DrawCircle(double x, double y, double radius);
00196     void DrawEllipse(double x, double y, double width, double height);
00197     void DrawEllipse(const wxPoint2DDouble& pt, const wxSize& sz);
00198     void DrawEllipse(const wxRect2DDouble& rect);
00199 
00200 /*
00201     void DrawIcon(const wxIcon& icon, double x, double y);
00202     void DrawIcon(const wxIcon& icon, const wxPoint2DDouble& pt);
00203 
00204     void DrawBitmap(const wxBitmap &bmp, double x, double y,
00205                     bool useMask = FALSE);
00206     void DrawBitmap(const wxBitmap &bmp, const wxPoint2DDouble& pt,
00207                     bool useMask = FALSE);
00208 */
00209     void DrawText(const wxString& text, double x, double y);
00210     void DrawText(const wxString& text, const wxPoint2DDouble& pt);
00211 
00213     void DrawRotatedText(const wxString& text, double x, double y, double angle);
00214     void DrawRotatedText(const wxString& text, const wxPoint2DDouble& pt, double angle);
00215 /*
00216     bool Blit(double xdest, double ydest, double width, double height,
00217               wxDC *source, double xsrc, double ysrc,
00218               int rop = wxCOPY, bool useMask = FALSE);
00219     bool Blit(const wxPoint2DDouble& destPt, const wxSize& sz,
00220               wxDC *source, const wxPoint2DDouble& srcPt,
00221               int rop = wxCOPY, bool useMask = FALSE);
00222 */
00223 
00224 #if wxUSE_SPLINES
00225 
00226     void DrawSpline(int n, wxPoint2DDouble points[]);
00227 
00228 /*    void DrawSpline(wxList *points);
00229 */
00230 #endif // wxUSE_SPLINES
00231 
00232 
00233     /*
00234     // global DC operations
00235     // --------------------
00236     */
00237 
00239     virtual void Clear();
00240 
00241     virtual bool StartDoc(const wxString& WXUNUSED(message)) { return TRUE; }
00242     virtual void EndDoc() { }
00243 
00244     virtual void StartPage() { }
00245     virtual void EndPage() { }
00246 
00247     /*
00248     // set objects to use for drawing
00249     */
00250 
00252     virtual void SetFont(const wxFont& font,double size);
00253     virtual void SetPen(const wxPen& pen) ;
00254     virtual void SetBrush(const wxBrush& brush) ;
00255     virtual void SetBackground(const wxBrush& brush);
00256     virtual void SetBackgroundMode(int mode);
00257     virtual void SetPalette(const wxPalette& palette);
00258 
00259     /*
00260     // clipping region
00261     */
00262 
00264     void SetClippingRegionWin(wxCoord minx,wxCoord miny,wxCoord maxx,wxCoord maxy);
00265 
00267     void SetClippingRegion(double minx,double miny,double maxx,double maxy);
00268 
00270     void DestroyClippingRegion();
00271 
00273     void ClearClippingRegion();
00274 
00276     void ExtendClippingRegion(double x, double y);
00277 
00279     virtual void GetClippingBox(double& x, double& y,
00280                               double& w, double& h) const;
00282     virtual void GetVirtualSize(double& x, double& y,
00283                               double& w, double& h) const;
00284     /*
00285     // text extent
00286     // -----------
00287 
00288     //    virtual double GetCharHeight() const;
00289     //    virtual double GetCharWidth() const;
00290 
00291     //    void GetTextExtent(const wxString& string,
00292     //                       double *x, double *y,
00293     //                       double *descent = NULL,
00294     //                       double *externalLeading = NULL,
00295     //                       wxFont *theFont = NULL) const;
00296 
00297     // size and resolution
00298     // -------------------
00299 
00300     // in device units
00301     //    void GetSize(int *width, int *height) const;
00302     //    wxSize GetSize() const;
00303     // in mm
00304     //    void GetSizeMM(int* width, int* height) const;
00305     //    wxSize GetSizeMM() const;
00306 
00307     // coordinates conversions
00308     // -----------------------
00309 
00310     // This group of functions does actual conversion of the input, as you'd
00311     // expect.
00312     */
00313 
00315     double DeviceToLogicalX(double x) const;
00317     double DeviceToLogicalY(double y) const;
00319     double DeviceToLogicalXRel(double x) const;
00321     double DeviceToLogicalYRel(double y) const;
00323     double LogicalToDeviceX(double x) const;
00325     double LogicalToDeviceY(double y) const;
00327     double LogicalToDeviceXRel(double x) const;
00329     double LogicalToDeviceYRel(double y) const;
00330 
00331     /*
00332     // Resolution in Pixels per inch
00333     //    virtual wxSize GetPPI() const;
00334     */
00335 
00336     virtual bool Ok() const { return m_ok; }
00337 
00338     /*
00339     // accessors
00340     // ---------
00341     */
00342 
00343 
00344     /* const...*/
00345     int GetBackgroundMode() const { return m_backgroundMode; }
00346     const wxBrush&  GetBackground() const { return m_backgroundBrush; }
00347     const wxBrush&  GetBrush() const { return m_brush; }
00348     const wxFont&   GetFont() const { return m_font; }
00349     const wxPen&    GetPen() const { return m_pen; }
00350     const wxColour& GetTextBackground() const { return m_textBackgroundColour; }
00351     const wxColour& GetTextForeground() const { return m_textForegroundColour; }
00352 
00353     /* ... and non const */
00354     wxBrush&  GetBackground() { return m_backgroundBrush; }
00355     wxBrush&  GetBrush() { return m_brush; }
00356     wxFont&   GetFont() { return m_font; }
00357     wxPen&    GetPen() { return m_pen; }
00358     wxColour& GetTextBackground() { return m_textBackgroundColour; }
00359     wxColour& GetTextForeground() { return m_textForegroundColour; }
00360 
00364     virtual void SetTextForeground(const wxColour& colour);
00365 
00369     virtual void SetTextBackground(const wxColour& colour);
00370 
00372 
00400     int GetLogicalFunction() const { return m_logicalFunction; }
00401 
00403     virtual void SetLogicalFunction(int function) ;
00404 
00407     virtual void CalcBoundingBox(double x, double y)
00408     {
00409       if ( m_isBBoxValid )
00410       {
00411          if ( x < m_minX ) m_minX = x;
00412          if ( y < m_minY ) m_minY = y;
00413          if ( x > m_maxX ) m_maxX = x;
00414          if ( y > m_maxY ) m_maxY = y;
00415       }
00416       else
00417       {
00418          m_isBBoxValid = TRUE;
00419 
00420          m_minX = x;
00421          m_minY = y;
00422          m_maxX = x;
00423          m_maxY = y;
00424       }
00425     }
00426 
00429     void ResetBoundingBox()
00430     {
00431         m_isBBoxValid = FALSE;
00432 
00433         m_minX = m_maxX = m_minY = m_maxY = 0;
00434         if (m_dc)
00435             m_dc->ResetBoundingBox();
00436     }
00437 
00439     double MinX() const { return m_minX; }
00441     double MaxX() const { return m_maxX; }
00443     double MinY() const { return m_minY; }
00445     double MaxY() const { return m_maxY; }
00446 
00448     void GetTextExtent(const wxString& string,
00449                        long *x, long *y,
00450                        long *descent = NULL,
00451                        long *externalLeading = NULL,
00452                        wxFont *theFont = NULL) const;
00453 
00454 
00456     double m_virt_minX, m_virt_minY, m_virt_maxX, m_virt_maxY;
00457 
00458 protected:
00459 
00461     bool m_colour:1;
00462 
00464     bool m_ok:1;
00465 
00467     bool m_clipping:1;
00468 
00470     bool m_isInteractive:1;
00471 
00473     bool m_isBBoxValid:1;
00474 
00476     bool m_isVirtualValid:1;
00477 
00479     double m_minX, m_minY, m_maxX, m_maxY;
00480 
00482     double m_clipX1, m_clipY1, m_clipX2, m_clipY2;
00483 
00485     int m_logicalFunction;
00487     int m_backgroundMode;
00489     int m_mappingMode;
00491     double m_fontsize;
00493     wxPen             m_pen;
00495     wxBrush           m_brush;
00497     wxBrush           m_backgroundBrush;
00499     wxColour          m_textForegroundColour;
00501     wxColour          m_textBackgroundColour;
00503     wxFont            m_font;
00505     wxPalette         m_palette;
00506 
00508     wxTransformMatrix m_mapping_matrix;
00509 
00511     wxTransformMatrix m_inverse_mapping;
00512 
00514     double                              m_scalefactor_x;
00516     double                              m_scalefactor_y;
00517 
00519     wxDC*                           m_dc;
00520 
00523     wxPoint*                m_todraw;
00524 
00525 private:
00526 };
00527 
00528 #endif
00529 
doubledc.h Source File -- Thu Nov 28 21:24:56 2002 -- 28 Nov 2002 -- 1.2.18 -- -- . -- Main Page