1 /*
2  * $Id: window.h,v 1.6 2001/01/10 20:16:32 danny Exp $
3  *
4  * Copyright � 1992, 1993, 1999 Free Software Foundation, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this software; see the file COPYING.  If not, write to
18  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef WINDOWH
22 #define WINDOWH
23 
24 
25 #include "cell.h"
26 #include "line.h"
27 
28 /* The tty windows datastructures: */
29 
30 
31 struct window
32 {
33   /* Do not change these directly. */
34   int id;
35   int win_over;			/* Where the data in this window starts */
36   int win_down;			/*   on the screen.  */
37   struct rng screen;		/* Cells visible. recenter_* updates this. */
38   int flags;			/* You must use io_set_win_flags and perhaps */
39 				/*   io_recenter_cur_win */
40 
41   /* Number of lines of spreadsheet that can fit in this window.
42      This only changes when the screen is resized,
43      win->flags&WIN_EDGES changes, or a window is either
44      created or destroyed */
45   int numr;
46 
47   /* Number of text columns that can fit in this window.
48      This changes when the screen is resized,
49      win->flags&WIN_EDGES changes, a window is created or
50      destoryed, or win->lh_wid changes.  In the last case
51      win->numc+win->lh_wid remains a constant. */
52   int numc;
53 
54   /*
55    * Number of columns and rows for right and bottom edges.
56    * As this changes, numc and numr change accordingly.
57    */
58   int bottom_edge_r;
59   int right_edge_c;
60 
61   /* These values may be changed at any time. */
62   /* -1 if this window isn't linked to any others, else
63      contains the index into wins of the window this one is
64      linked to */
65   int link;
66 
67   /* Number of columns taken up by the row numbers at the
68      left hand edge of the screen.  Zero if edges is
69      win->flags&WIN_EDGES is off (by definition).  Seven (or
70      five) if win->flags&WIN_PAG_HZ (to make things easier).
71      Ranges between three "R9 " to seven "R32767 " depending on
72      the number of the highest row on the screen.  */
73   int lh_wid;
74 
75 
76   /* Cursor row/column in this window */
77   /* Note that the external variables curow, cucol are used for
78      the currently active cursor position, so if you want
79      cwin->curow and cwin->cucol to be accurate, you have to
80      set them yourself. */
81   CELLREF win_curow;
82   CELLREF win_cucol;
83 
84   VOIDSTAR *win_slops;	/* Slops in this window (tty only) */
85 };
86 
87 struct mouse_event
88 {
89   int seq;
90   int row;
91   int col;
92   int button;
93   int downp;
94   int location;			/* See #defines, below. */
95   CELLREF r;
96   CELLREF c;
97   struct mouse_event * next;
98   struct mouse_event * prev;
99 };
100 
101 /* Window flags:
102    0x01	Locked horizontally
103    0x02	Locked vertically
104    0x04	Page Horizontally
105    0x08	Page Vertically
106    0x10	Edges disabled
107    0x20	Edges standout
108    */
109 #define WIN_LCK_HZ	0x01
110 #define WIN_LCK_VT	0x02
111 #define WIN_PAG_HZ	0x04
112 #define WIN_PAG_VT	0x08
113 #define WIN_EDGES	0x10
114 #define WIN_EDGE_REV	0x20
115 
116 #if 0
117 #define	scr_lines	Global->scr_lines
118 #define	scr_cols	Global->scr_cols
119 #endif
120 
121 /* These control the layout of input and status lines. */
122 #define	user_input	Global->user_input
123 #define	user_status	Global->user_status
124 /* #define	input		Global->input */
125 /* #define	status		Global->status */
126 #define	input_rows	Global->input_rows
127 #define	status_rows	Global->status_rows
128 
129 /* These control the layout of edge labels. */
130 #define	label_rows	Global->label_rows
131 #define	label_emcols	Global->label_emcols
132 
133 /* Temporary hacks for displaying multi-line messages. */
134 /* If this is non-0, it should be displayed instead of
135  * the windows of cells.  This is a temporary hack.
136  * Use set_info to change this.
137  */
138 /* #define	current_info	Global->current_info */
139 
140 #define	info_rows	Global->info_rows
141 /* #define	info_line	Global->info_line */
142 #define	info_over	Global->info_over
143 
144 /* Window borders: */
145 #define	default_right_border	Global->default_right_border
146 #define	default_bottom_border	Global->default_bottom_border
147 
148 /* The window list. */
149 #define	nwin		Global->nwin
150 #define	cwin		Global->cwin
151 #define	wins		Global->wins
152 #define	win_id		Global->win_id
153 
154 /* This is stored as the button number when a dequeue failes. */
155 #define MOUSE_QERROR	-1
156 /* These are the possible mouse locations. */
157 #define MOUSE_ON_INPUT    -1
158 #define MOUSE_ON_STATUS   -2
159 #define MOUSE_ON_EDGE	  -3
160 
161 #define MOUSE_CHAR '\034'
162 
163 extern int win_label_cols (struct window * win, CELLREF hr);
164 extern int win_label_rows (struct window * win);
165 extern void io_set_label_size (int r, int c);
166 extern void io_set_scr_size (int lines, int cols);
167 extern void io_set_input_rows (int n);
168 extern void io_set_status_rows (int n);
169 extern void io_set_input_status (int inp, int stat, int redraw);
170 extern void io_set_cwin (struct window *win);
171 extern void io_pr_cell (CELLREF r, CELLREF c, CELL *cp);
172 extern void io_redo_region (struct rng * rng);
173 extern void io_win_open (int hv, int where);
174 extern void io_win_close (struct window *win);
175 extern void io_move_cell_cursor (CELLREF rr, CELLREF cc);
176 extern void io_shift_cell_cursor (int dirn, int repeat);
177 extern void io_scroll_cell_cursor (int magic, int repeat);
178 extern void io_recenter_cur_win (void);
179 extern void io_recenter_all_win (void);
180 extern void io_set_win_flags (struct window *w, int f);
181 extern void io_write_window_config (struct line * out);
182 extern void io_read_window_config (char * line);
183 extern int enqueue_mouse_event (int r, int c, int button, int downp);
184 extern void dequeue_mouse_event (struct mouse_event *out, int seq);
185 extern void io_init_windows (int sl, int sc, int ui, int us, int ir, int sr,
186 		 int lr, int lc) ;
187 
188 #endif
189