1 #ifndef _stack_h
2 #define _stack_h
3 
4 /****************************************************************************
5 
6    This module defines some classes to organizes the puzzle tiles on the
7    Main functionalities: implementation of a stacking order
8                          dispatch of events down to the pieces
9                          control of the double buffering
10                          control zooming and panning
11 
12    The class Object will be a superclass of the puzzle tiles later on,
13    even though the whole object hierarchie is actually contained in the
14    object-module.
15 
16  ****************************************************************************/
17 
18 // ==========================================================================
19 
20 class Object {
21 	public:
22 		Object();
23 		virtual ~Object();
24 
25 		virtual void ExposeRegion( int x, int y, int width, int height ) = 0;
26 		virtual void ExposeWindowRegion( Window w, int x, int y, int width, int height );
27 
28 		virtual int Intersects( int x, int y, int width, int height );
29 		virtual int IsInside( int x, int y );
30 
31 		virtual void DispatchPress( XButtonEvent * /*xbutton*/ );
32 		virtual void DispatchRelease( XButtonEvent * /*xbutton*/ );
33 		virtual void DispatchMotion( XMotionEvent * /*xmotion*/ );
34 
35 		virtual void PanView( int offx, int offy );
36 		virtual void ZoomView( int midx, int midy, int chg );
37 		virtual int JoinExtent( int *x1, int *y1, int *x2, int *y2 );
38 		virtual int GetExtent( int *x1, int *y1, int *x2, int *y2 );
39 
40 	protected:
41 		class Object		*next;
42 		class ObjectStack	*mystack;
43 
44 friend class ObjectStack;
45 friend class DBObjectStack;
46 friend class WindowObjectStack;
47 };
48 
49 // ==========================================================================
50 
51 class ObjectStack {
52 	public:
53 		ObjectStack();
54 		virtual ~ObjectStack();
55 
56 		virtual void ExposeRegion( int x1, int y1, int width, int height );
57 		virtual void ExposeWindowRegion( Window w, int x1, int y1, int width, int height );
58 
59 		virtual void Raise( class Object *obj );		// move to top of stack
60 		virtual void Append( class Object *obj );		// add at top of stack
61 		virtual void Remove( class Object *obj );		// remove from stack
62 
63 		virtual void DispatchPress( XButtonEvent *xbutton );
64 		virtual void DispatchRelease( XButtonEvent *xbutton );
65 		virtual void DispatchMotion( XMotionEvent *xmotion );
66 
67 		void PanView( int offx, int offy );
68 		void ZoomView( int midx, int midy, int chg );
69 		void GetExtent( int *x1, int *y1, int *x2, int *y2 );
70 
71 		Pixmap			dbmap;	// should actually by contained in DBObjectStack
72 
73 	protected:
74 		virtual int SelectObject( class Object *current, int x, int y );
75 
76 		class Object	*sel;
77 		class Object	*close_sel;
78 		class	Object	*first;
79 
80 		class Object	*last_sel;
81 		int				last_x, last_y;
82 };
83 
84 // ==========================================================================
85 
86 class DBObjectStack : public ObjectStack {
87 	public:
88 		DBObjectStack();
89 		virtual ~DBObjectStack();
90 
91 		void ExposeRegion( int x1, int y1, int width, int height );
92 
93 		GC					gc;
94 
95 	protected:
96 };
97 
98 // ==========================================================================
99 
100 class WindowObjectStack : public ObjectStack {
101 	public:
102 		WindowObjectStack();
103 		virtual ~WindowObjectStack();
104 
105 		void ExposeWindowRegion( Window w, int x1, int y1, int width, int height );
106 
107 		virtual void Raise( class Object *obj );		// move to top of stack
108 
109 		void DispatchPress( XButtonEvent *xbutton );
110 		void DispatchRelease( XButtonEvent *xbutton );
111 		void DispatchMotion( XMotionEvent *xmotion );
112 
113 	protected:
114 };
115 
116 // ==========================================================================
117 
118 #endif
119