File: canvas.h

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (119 lines) | stat: -rw-r--r-- 3,684 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Portions Copyright (C) 1998 - 2011, Julian Smart
// Portions Copyright (C) 2011 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// canvas.h - wxShapeCanvas
//
//////////////////////////////////////////////////////////////////////////

#ifndef _OGL_CANVAS_H_
#define _OGL_CANVAS_H_

// Drag states
#define NoDragging             0
#define StartDraggingLeft      1
#define ContinueDraggingLeft   2
#define StartDraggingRight     3
#define ContinueDraggingRight  4

#ifdef __WXMSW__
#define OGL_USE_BUFFERED_PAINT 1
#else
#define OGL_USE_BUFFERED_PAINT 0
#endif


extern const wxChar *wxShapeCanvasNameStr;

// When drag_count reaches 0, process drag message

class wxDiagram;

class wxShapeCanvas: public wxScrolledWindow
{
	DECLARE_DYNAMIC_CLASS(wxShapeCanvas)
public:
	wxShapeCanvas(wxWindow *parent = NULL, wxWindowID id = -1,
	              const wxPoint &pos = wxDefaultPosition,
	              const wxSize &size = wxDefaultSize,
	              long style = wxBORDER | wxRETAINED,
	              const wxString &name = wxShapeCanvasNameStr);
	~wxShapeCanvas();

	inline void SetDiagram(wxDiagram *diag)
	{
		m_shapeDiagram = diag;
	}
	inline wxDiagram *GetDiagram() const
	{
		return m_shapeDiagram;
	}

	virtual void OnLeftClick(double x, double y, int keys = 0);
	virtual void OnRightClick(double x, double y, int keys = 0);

	virtual void OnDragLeft(bool draw, double x, double y, int keys = 0); // Erase if draw false
	virtual void OnBeginDragLeft(double x, double y, int keys = 0);
	virtual void OnEndDragLeft(double x, double y, int keys = 0);

	virtual void OnDragRight(bool draw, double x, double y, int keys = 0); // Erase if draw false
	virtual void OnBeginDragRight(double x, double y, int keys = 0);
	virtual void OnEndDragRight(double x, double y, int keys = 0);

	// Find object for mouse click, of given wxClassInfo (NULL for any type).
	// If notImage is non-NULL, don't find an object that is equal to or a descendant of notImage
	virtual wxShape *FindShape(double x, double y, int *attachment, wxClassInfo *info = NULL, wxShape *notImage = NULL);
	wxShape *FindFirstSensitiveShape(double x, double y, int *new_attachment, int op);
	wxShape *FindFirstSensitiveShape1(wxShape *image, int op);

	// Redirect to wxDiagram object
	virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
	virtual void InsertShape(wxShape *object);
	virtual void RemoveShape(wxShape *object);
	virtual bool GetQuickEditMode();
	virtual void Redraw(wxDC &dc);
	void Snap(double *x, double *y);

	// Returns the current scroll position
	wxPoint GetCurrentPixelScrollPosition();

	void ResetDragState()
	{
		m_dragState = NoDragging;
	}

#if OGL_USE_BUFFERED_PAINT
	/// Recreate buffer bitmap if necessary
	bool RecreateBuffer(const wxSize &size = wxDefaultSize);
#endif

	virtual void DrawBackground(wxDC &dc, bool transformed = FALSE);

	// Events
	void OnPaint(wxPaintEvent &event);
	void OnMouseEvent(wxMouseEvent &event);
	void OnEraseBackground(wxEraseEvent &event);

protected:
	wxDiagram        *m_shapeDiagram;
	int               m_dragState;
	double             m_oldDragX, m_oldDragY;     // Previous drag coordinates
	double             m_firstDragX, m_firstDragY; // INITIAL drag coordinates
	bool              m_checkTolerance;           // Whether to check drag tolerance
	wxShape          *m_draggedShape;
	int               m_draggedAttachment;

#if OGL_USE_BUFFERED_PAINT
	/// Buffer bitmap
	wxBitmap                m_bufferBitmap;
#endif

	DECLARE_EVENT_TABLE()
};

#endif
// _OGL_CANVAS_H_