1 #ifndef __port_h
2 #define __port_h
3 
4 typedef enum {
5 	Normal,
6 	Smiley,
7 	Photo,
8 #ifdef HUBSYM
9 	Symbol,
10 	Cyrillic,
11 #endif
12 	DummyMode
13 } Mode;
14 
15 #ifndef __color_mapper_h
16 #	include "color_mapper.H"
17 #endif
18 
19 class Port {
20 	friend class Tile;
21 
22 public:
23 	Port( char *disp_name, char *color );
24 	~Port();
25 
close_all()26 	static void close_all()		{ while(first)	delete first; }
27 
28 	int empty_queue();					// empty event queue of port
29 	static int wait_event();			// wait for event on any port
30 
31 	void add_foreign_color( Port *first, char *color_name );
32 	void add_color( int id, char *color );
33 	void sub_color( int id );
34 
35 	void redraw( int x, int y );							// redraw tile (x,y)
36 	void redraw_score( int x );							// redraw score of player
37 	void redraw( int x1, int y1, int x2, int y2 );	// redraw X-region
38 	void draw_block( int p, int x, int y );			// draw score-block
39 
40 	static void tile_redraw( int fid );					// redraw tile on index fid
41 	static void flush_all();
42 
43 	void selected( int x, int y );	// select tile if possible
44 	unsigned long deselect( );			// deselect/flash/remove tiles
45 	int remove();							// remove tile when possible
46 
alloc_color(XColor * col)47 	unsigned long alloc_color( XColor *col )
48 				{ return mapper->alloc_color(col); }
alloc_named_color(const char * name)49 	unsigned long alloc_named_color( const char *name )
50 				{ return mapper->alloc_named_color(name); }
51 
52 	Display	*display;
53 	Pixmap	stipple_pmap;				// used for stippled drawing, when no_planes
54 	Pixmap	rstipple_pmap;				// for reversed stippled drawing
55 	Screen	*screen;
56 	Window	window;
57 	int		double_depth;
58 
59 	Cursor	normal_cursor, idle_cursor;
60 
61 	GC			gc_tile;
62 	unsigned long	light;
63 	unsigned long	bg;
64 	unsigned long	fg;
65 	unsigned long	dark;
66 	GC			gc_all;
67 
68 	GC			gc_color_n( int id );
69 
70 	const char *find_font( const char *pattern, int size );
71 
72 	void resize( int w, int h );		// recalculate sizes (redraw tiles)
73 
74 	char *color_name;						// color
75 	int	 my_id;							// id
76 
77 	int	selections;						// number of selections
78 	int	points;							// own points
79 	static int Points( int id );		// Points of port ...
80 	static void statistic();
81 
82 	static void activate_any_player();
83 	void activate_next_player();
84 	void set_active( int a );
85 	int		active;						// flag, if playing is allowed
86 
87 private:
88 	class Tile	**tile;					// field of normal tiles
89 	class Tile	*blank;					// closed field
90 	class Tile	*empty;					// empty field
91 
92 	class Color	*colors;					// anchor of color list
93 	class ColorMapper	*mapper;			// mapper to control colormap-usage
94 
95 	static Port *first;					// anchor of port list
96 	Port	*next;							// next port in list
97 
98 	int wbsizex, wbsizey;				// world score block size
99 	int wborder;                     // world border size
WWidth()100 	int WWidth()	{ return wsizex*dwidth+wbsizex*nplayers+3*wborder; }
WHeight()101 	int WHeight()	{ return wsizey*dheight+2*wborder; }
102 
103 	int sizex, sizey;						// tile size
104 	int bsizex, bsizey;					// size of score-blocks
105 	int border;								// size of border-frame
MWidth()106 	int MWidth()	{ return sizex*dwidth+nplayers*bsizex+3*border; }
MHeight()107 	int MHeight()	{ return sizey*dheight+2*border; }
MInit(int x)108 	void MInit(int x) {
109 		sizex  = x;
110 		sizey  = x*wsizey /wsizex;
111 		bsizex = x*wbsizex/wsizex;
112 		bsizey = x*wbsizey/wsizex;
113 		border = x*wborder/wsizex;
114 	}
115 
116 	int offx, offy;						// window offset for justification
117 	int width,height;						// size of window (MWidth/MHeight)
118 	Mode mode;								// tile style
119 
120 	int		lock_count;					// number of locked tiles 0,1,2
121 	int		lock[2];						// fid of locked tiles
122 	unsigned long lock_time;			// lock until ...
123 	unsigned long flash_time;			// time of next flash
124 
125 	static struct fd_set	readfds;
126 	static int				nfds;
127 
128 	Atom	WmProtocolsPropId, WmDeleteWindowPropId;
129 
130 	int ncols;								// number of colors in image
131 	unsigned long	*gif_cols;			// pixel-transformation table
132 
133 public:
134 	static int nplayers;					// number of ports
135 	static int	color_id;				// *current* color id
136 	static int	dsize;
137 	static int	dwidth, dheight;		// number of tiles
138 	static int  wsizex, wsizey;		// world tile size
139 	static Mode def_mode;				// preselected tile style
140 	static int	remove_flag;			// flag, if tiles should be removed
141 	static int	sync_flag;				// synchronous playing mode
142 	static int	resize_lock;			// flag about sizeability of tiles
143 
144 	void UpdateTime( const char *time_str );
145 	static int  def_size;				// preselected tile style
146 	static class MemImage	*gif;		// original image, when in photo-mode
147 
148 friend class ScalableFont;
149 };
150 
151 #endif
152