]> git.saurik.com Git - wxWidgets.git/blob - utils/ogl/src/drawn.h
spurious error messages from wxRegKey::HasValue() suppressed
[wxWidgets.git] / utils / ogl / src / drawn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: drawn.h
3 // Purpose: wxDrawnShape
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 12/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _OGL_DRAWN_H_
13 #define _OGL_DRAWN_H_
14
15 #ifdef __GNUG__
16 #pragma interface "drawn.h"
17 #endif
18
19 #include "basic.h"
20
21 class wxDrawnShape;
22 class wxPseudoMetaFile: public wxObject
23 {
24 DECLARE_DYNAMIC_CLASS(wxPseudoMetaFile)
25 public:
26 wxPseudoMetaFile();
27 wxPseudoMetaFile(wxPseudoMetaFile& mf);
28 ~wxPseudoMetaFile();
29
30 void Draw(wxDC& dc, float xoffset, float yoffset);
31
32 #ifdef PROLOGIO
33 void WritePrologAttributes(wxExpr *clause);
34 void ReadPrologAttributes(wxExpr *clause);
35 #endif
36
37 void Clear();
38
39 void Copy(wxPseudoMetaFile& copy);
40
41 void Scale(float sx, float sy);
42 void ScaleTo(float w, float h); // Scale to fit size
43 void Translate(float x, float y);
44
45 // Rotate about the given axis by theta radians from the x axis.
46 void Rotate(float x, float y, float theta);
47
48 bool LoadFromMetaFile(char *filename, float *width, float *height);
49
50 void GetBounds(float *minX, float *minY, float *maxX, float *maxY);
51
52 // Calculate size from current operations
53 void CalculateSize(wxDrawnShape* shape);
54
55 inline wxList& GetOutlineColours() const { return (wxList&) m_outlineColours; }
56 inline wxList& GetFillColours() const { return (wxList&) m_fillColours; }
57 inline void SetRotateable(bool rot) { m_rotateable = rot; }
58 inline bool GetRotateable() const { return m_rotateable; }
59
60 inline void SetSize(float w, float h) { m_width = w; m_height = h; }
61
62 inline void SetFillBrush(wxBrush* brush) { m_fillBrush = brush; }
63 inline wxBrush* GetFillBrush() const { return m_fillBrush; }
64
65 inline void SetOutlinePen(wxPen* pen) { m_outlinePen = pen; }
66 inline wxPen* GetOutlinePen() const { return m_outlinePen; }
67
68 public:
69 /// Set of functions for drawing into a pseudo metafile.
70 /// They use integers, but doubles are used internally for accuracy
71 /// when scaling.
72
73 virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
74 virtual void DrawRectangle(const wxRect& rect);
75 virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
76 virtual void DrawEllipse(const wxRect& rect);
77 virtual void DrawPoint(const wxPoint& pt);
78 virtual void DrawText(const wxString& text, const wxPoint& pt);
79 virtual void DrawLines(int n, wxPoint pts[]);
80 virtual void DrawPolygon(int n, wxPoint pts[]);
81 virtual void DrawSpline(int n, wxPoint pts[]);
82
83 virtual void SetClippingRect(const wxRect& rect);
84 virtual void DestroyClippingRect();
85
86 virtual void SetPen(wxPen* pen, bool isOutline = FALSE); // TODO: eventually, just store GDI object attributes, not actual
87 virtual void SetBrush(wxBrush* brush, bool isFill = FALSE); // pens/brushes etc.
88 virtual void SetFont(wxFont* font);
89 virtual void SetTextColour(const wxColour& colour);
90 virtual void SetBackgroundColour(const wxColour& colour);
91 virtual void SetBackgroundMode(int mode);
92
93 public:
94 bool m_rotateable;
95 float m_width;
96 float m_height;
97 wxList m_ops; // List of drawing operations (see drawnp.h)
98 wxList m_gdiObjects; // List of pens, brushes and fonts for this object.
99
100 // Pen/brush specifying outline/fill colours
101 // to override operations.
102 wxPen* m_outlinePen;
103 wxBrush* m_fillBrush;
104 wxList m_outlineColours; // List of the GDI operations that comprise the outline
105 wxList m_fillColours; // List of the GDI operations that fill the shape
106 float m_currentRotation;
107 };
108
109 class wxDrawnShape: public wxRectangleShape
110 {
111 DECLARE_DYNAMIC_CLASS(wxDrawnShape)
112 public:
113 wxDrawnShape();
114 ~wxDrawnShape();
115
116 void OnDraw(wxDC& dc);
117
118 #ifdef PROLOGIO
119 // Prolog database stuff
120 char *GetFunctor();
121 void WritePrologAttributes(wxExpr *clause);
122 void ReadPrologAttributes(wxExpr *clause);
123 #endif
124
125 // Does the copying for this object
126 void Copy(wxShape& copy);
127
128 void Scale(float sx, float sy);
129 void Translate(float x, float y);
130 // Rotate about the given axis by theta radians from the x axis.
131 void Rotate(float x, float y, float theta);
132
133 // Get current rotation
134 inline float GetRotation() const { return m_rotation; }
135
136 void SetSize(float w, float h, bool recursive = TRUE);
137 bool LoadFromMetaFile(char *filename);
138
139 inline void SetSaveToFile(bool save) { m_saveToFile = save; }
140 inline wxPseudoMetaFile& GetMetaFile() const { return (wxPseudoMetaFile&) m_metafile; }
141
142 /// Set of functions for drawing into a pseudo metafile.
143 /// They use integers, but doubles are used internally for accuracy
144 /// when scaling.
145
146 virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
147 virtual void DrawRectangle(const wxRect& rect);
148 virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
149 virtual void DrawEllipse(const wxRect& rect);
150 virtual void DrawPoint(const wxPoint& pt);
151 virtual void DrawText(const wxString& text, const wxPoint& pt);
152 virtual void DrawLines(int n, wxPoint pts[]);
153 virtual void DrawPolygon(int n, wxPoint pts[]);
154 virtual void DrawSpline(int n, wxPoint pts[]);
155
156 virtual void SetClippingRect(const wxRect& rect);
157 virtual void DestroyClippingRect();
158
159 virtual void SetPen(wxPen* pen, bool isOutline = FALSE); // TODO: eventually, just store GDI object attributes, not actual
160 virtual void SetBrush(wxBrush* brush, bool isFill = FALSE); // pens/brushes etc.
161 virtual void SetFont(wxFont* font);
162 virtual void SetTextColour(const wxColour& colour);
163 virtual void SetBackgroundColour(const wxColour& colour);
164 virtual void SetBackgroundMode(int mode);
165
166 // Set the width/height according to the shapes in the metafile.
167 // Call this after drawing into the shape.
168 inline void CalculateSize() { m_metafile.CalculateSize(this); }
169
170 private:
171 wxPseudoMetaFile m_metafile;
172
173 // Don't save all wxDrawnShape metafiles to file: sometimes
174 // we take the metafile data from a symbol library.
175 bool m_saveToFile;
176 };
177
178 #endif
179 // _DRAWN_H_
180