File: stack.H

package info (click to toggle)
xjig 2.4-14.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 892 kB
  • sloc: cpp: 10,177; makefile: 1,142; perl: 23
file content (118 lines) | stat: -rw-r--r-- 3,590 bytes parent folder | download | duplicates (9)
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
#ifndef _stack_h
#define _stack_h

/****************************************************************************

   This module defines some classes to organizes the puzzle tiles on the
   Main functionalities: implementation of a stacking order
                         dispatch of events down to the pieces
                         control of the double buffering
                         control zooming and panning

   The class Object will be a superclass of the puzzle tiles later on,
   even though the whole object hierarchie is actually contained in the
   object-module.

 ****************************************************************************/

// ==========================================================================

class Object {
	public:
		Object();
		virtual ~Object();

		virtual void ExposeRegion( int x, int y, int width, int height ) = 0;
		virtual void ExposeWindowRegion( Window w, int x, int y, int width, int height );

		virtual int Intersects( int x, int y, int width, int height );
		virtual int IsInside( int x, int y );

		virtual void DispatchPress( XButtonEvent * /*xbutton*/ );
		virtual void DispatchRelease( XButtonEvent * /*xbutton*/ );
		virtual void DispatchMotion( XMotionEvent * /*xmotion*/ );

		virtual void PanView( int offx, int offy );
		virtual void ZoomView( int midx, int midy, int chg );
		virtual int JoinExtent( int *x1, int *y1, int *x2, int *y2 );
		virtual int GetExtent( int *x1, int *y1, int *x2, int *y2 );

	protected:
		class Object		*next;
		class ObjectStack	*mystack;

friend class ObjectStack;
friend class DBObjectStack;
friend class WindowObjectStack;
};

// ==========================================================================

class ObjectStack {
	public:
		ObjectStack();
		virtual ~ObjectStack();

		virtual void ExposeRegion( int x1, int y1, int width, int height );
		virtual void ExposeWindowRegion( Window w, int x1, int y1, int width, int height );

		virtual void Raise( class Object *obj );		// move to top of stack
		virtual void Append( class Object *obj );		// add at top of stack
		virtual void Remove( class Object *obj );		// remove from stack

		virtual void DispatchPress( XButtonEvent *xbutton );
		virtual void DispatchRelease( XButtonEvent *xbutton );
		virtual void DispatchMotion( XMotionEvent *xmotion );

		void PanView( int offx, int offy );
		void ZoomView( int midx, int midy, int chg );
		void GetExtent( int *x1, int *y1, int *x2, int *y2 );

		Pixmap			dbmap;	// should actually by contained in DBObjectStack

	protected:
		virtual int SelectObject( class Object *current, int x, int y );

		class Object	*sel;
		class Object	*close_sel;
		class	Object	*first;

		class Object	*last_sel;
		int				last_x, last_y;
};

// ==========================================================================

class DBObjectStack : public ObjectStack {
	public:
		DBObjectStack();
		virtual ~DBObjectStack();

		void ExposeRegion( int x1, int y1, int width, int height );

		GC					gc;

	protected:
};

// ==========================================================================

class WindowObjectStack : public ObjectStack {
	public:
		WindowObjectStack();
		virtual ~WindowObjectStack();

		void ExposeWindowRegion( Window w, int x1, int y1, int width, int height );

		virtual void Raise( class Object *obj );		// move to top of stack

		void DispatchPress( XButtonEvent *xbutton );
		void DispatchRelease( XButtonEvent *xbutton );
		void DispatchMotion( XMotionEvent *xmotion );

	protected:
};

// ==========================================================================

#endif