]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/ogl/ogldiag.h
ported wxSVG contrib to bakefile (patch #778614)
[wxWidgets.git] / contrib / include / wx / ogl / ogldiag.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ogldiag.h
3 // Purpose: OGL - wxDiagram class
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_OGLDIAG_H_
13 #define _OGL_OGLDIAG_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "ogldiag.h"
17 #endif
18
19
20 #if wxUSE_PROLOGIO
21 #include <wx/deprecated/wxexpr.h>
22 #endif
23
24
25 class WXDLLIMPEXP_OGL wxDiagram: public wxObject
26 {
27 DECLARE_DYNAMIC_CLASS(wxDiagram)
28
29 public:
30
31 wxDiagram();
32 virtual ~wxDiagram();
33
34 void SetCanvas(wxShapeCanvas *can);
35
36 inline wxShapeCanvas *GetCanvas() const { return m_diagramCanvas; }
37
38 virtual void Redraw(wxDC& dc);
39 virtual void Clear(wxDC& dc);
40 virtual void DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2);
41
42 // Add object to end of object list (if addAfter is NULL)
43 // or just after addAfter.
44 virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
45
46 // Add object to front of object list
47 virtual void InsertShape(wxShape *object);
48
49 void SetSnapToGrid(bool snap);
50 void SetGridSpacing(double spacing);
51 inline double GetGridSpacing() const { return m_gridSpacing; }
52 inline bool GetSnapToGrid() const { return m_snapToGrid; }
53 void Snap(double *x, double *y);
54
55 inline void SetQuickEditMode(bool qem) { m_quickEditMode = qem; }
56 inline bool GetQuickEditMode() const { return m_quickEditMode; }
57
58 virtual void RemoveShape(wxShape *object);
59 virtual void RemoveAllShapes();
60 virtual void DeleteAllShapes();
61 virtual void ShowAll(bool show);
62
63 // Find a shape by its id
64 wxShape* FindShape(long id) const;
65
66 inline void SetMouseTolerance(int tol) { m_mouseTolerance = tol; }
67 inline int GetMouseTolerance() const { return m_mouseTolerance; }
68 inline wxList *GetShapeList() const { return m_shapeList; }
69 inline int GetCount() const { return m_shapeList->GetCount(); }
70
71 // Make sure all text that should be centred, is centred.
72 void RecentreAll(wxDC& dc);
73
74 #if wxUSE_PROLOGIO
75 virtual bool SaveFile(const wxString& filename);
76 virtual bool LoadFile(const wxString& filename);
77
78 virtual void ReadNodes(wxExprDatabase& database);
79 virtual void ReadLines(wxExprDatabase& database);
80 virtual void ReadContainerGeometry(wxExprDatabase& database);
81
82 // Allow for modifying file
83 virtual bool OnDatabaseLoad(wxExprDatabase& db);
84 virtual bool OnDatabaseSave(wxExprDatabase& db);
85 virtual bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
86 virtual bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
87 virtual bool OnHeaderSave(wxExprDatabase& db, wxExpr& expr);
88 virtual bool OnHeaderLoad(wxExprDatabase& db, wxExpr& expr);
89 #endif
90
91 protected:
92 wxShapeCanvas* m_diagramCanvas;
93 bool m_quickEditMode;
94 bool m_snapToGrid;
95 double m_gridSpacing;
96 int m_mouseTolerance;
97 wxList* m_shapeList;
98 };
99
100 class WXDLLIMPEXP_OGL wxLineCrossing: public wxObject
101 {
102 public:
103 wxLineCrossing() { m_lineShape1 = NULL; m_lineShape2 = NULL; }
104 wxRealPoint m_pt1; // First line
105 wxRealPoint m_pt2;
106 wxRealPoint m_pt3; // Second line
107 wxRealPoint m_pt4;
108 wxRealPoint m_intersect;
109 wxLineShape* m_lineShape1;
110 wxLineShape* m_lineShape2;
111 };
112
113 class WXDLLIMPEXP_OGL wxLineCrossings: public wxObject
114 {
115 public:
116 wxLineCrossings();
117 ~wxLineCrossings();
118
119 void FindCrossings(wxDiagram& diagram);
120 void DrawCrossings(wxDiagram& diagram, wxDC& dc);
121 void ClearCrossings();
122
123 public:
124 wxList m_crossings;
125 };
126
127 #endif
128 // _OGL_OGLDIAG_H_