Initial commit, 3-52-19 alpha
[cls.git] / src / include / iview.h
blob22d5059b78e0cd81a409a503d0a04a4617197d03
1 #define BASIC_IVIEW 0
3 typedef int ColorCode;
5 typedef enum {
6 MouseClick = 0,
7 MouseMove = 1
8 } MouseEventType;
10 typedef enum {
11 NoModifiers = 0,
12 ExtendModifier = 1,
13 OptionModifier = 2,
14 OptionExtendModifier = 3
15 } MouseClickModifier;
17 typedef enum {
18 pointInvisible,
19 pointNormal,
20 pointHilited,
21 pointSelected
22 } PointState;
24 typedef enum {
25 selecting,
26 brushing,
27 usermode
28 } MouseMode;
30 #ifdef MACINTOSH
31 #define thePort qd.thePort
32 #define arrow qd.arrow
33 #ifdef THINK_C
34 #define RETURNCHAR '\r'
35 #endif /* THINK_C */
36 #ifdef applec
37 #define RETURNCHAR '\n'
38 #endif /* applec */
39 #ifdef __MWERKS__
40 #define RETURNCHAR '\r'
41 #endif /* __MWERKS__ */
42 #else
43 #ifdef SUNVIEW
44 typedef struct {
45 int h, v;
46 } Point;
47 #else
48 typedef struct {
49 int h, v;
50 } Point;
51 typedef struct {
52 int left, right, width, height;
53 } Rect;
54 #endif /* SUNVIEW */
55 #endif /* MACINTOSH */
57 #ifdef MACINTOSH
58 #define IVIEW_WINDOW WindowPtr
59 #define IVIEW_MENU MenuHandle
61 #define InitialTop (20 + GetMBarHeight())
62 #define InitialLeft 10
63 #define MOUSE_TOLERANCE 0
65 # define gray qd.gray
66 # define black qd.black
67 # define thePort qd.thePort
68 # define screenBits qd.screenBits
69 # define arrow qd.arrow
70 # undef extend
71 #ifdef applec
72 VOID PtoCstr _((StringPtr s));
73 VOID CtoPstr _((char * s));
74 #endif /* applec */
76 typedef struct {
77 LVAL Object; /* elements of window_data */
78 int idleOn, frontOnly; /* elements of window_data */
79 int mouse_x, mouse_y; /* elements of window_data */
80 WindowPtr window;
81 void (*FreeMem) _((IVIEW_WINDOW));
82 ColorCode backColor, drawColor;
83 int canvasWidth, canvasHeight;
84 int lineType, drawMode, lineWidth;
85 long RefCon;
86 int use_color;
87 int hasHscroll, hasVscroll, view_h, view_v;
88 int v_scroll_inc[2], h_scroll_inc[2];
89 ControlHandle hscroll, vscroll;
90 int initialized;
91 int symbolMode;
92 int cursor;
93 Rect clip_rect;
94 int clipped;
95 } StGWWinInfo;
97 extern Rect scroll_bar_bounds();
99 #define GetWRefCon(w) (((WindowPeek)(w))->refCon)
101 #define BAG_RES 1800
102 #define GLASS_RES 1801
103 #define CAN_RES 1802
104 #define BRUSH_RES 1803
105 #define HAND_RES 1804
106 #define FINGER_RES 1805
107 #endif /* MACINTOSH */
109 #ifdef UNIX
110 #ifdef GNUPLOT
111 #define Window long
112 #define Menu long
113 #define StGWWinInfo VOID
114 #define StGWWinInfo VOID
115 #endif /* GNUPLOT */
116 #define IVIEW_WINDOW Window
117 #define IVIEW_MENU Menu
118 #endif /* UNIX */
120 #ifdef SUNVIEW
121 typedef struct {
122 long Object; /* elements of window_data */
123 int idleOn, frontOnly; /* elements of window_data */
124 int mouse_x, mouse_y; /* elements of window_data */
125 IVIEW_WINDOW window;
126 int (*FreeMem)();
127 IVIEW_MENU menu;
128 int (*MenuAction)(), (*MenuShow)(), (*MenuUpdate)();
129 ColorCode backColor, drawColor;
130 int canvasWidth, canvasHeight;
131 int lineType, drawMode, lineWidth;
132 Canvas content_canvas;
133 long RefCon;
134 int use_color;
135 int hasHscroll, hasVscroll, view_h, view_v;
136 int v_scroll_inc[2], h_scroll_inc[2];
137 /* ControlHandle hscroll, vscroll; +++ */
138 int initialized;
139 int symbolMode;
140 int cursor;
141 Rect clip_rect;
142 int clipped;
143 } StGWWinInfo;
144 #endif /* SUNVIEW */
146 #ifdef X11WINDOWS
147 typedef struct {
148 LVAL Object; /* elements of window_data */
149 int idleOn, frontOnly; /* elements of window_data */
150 int mouse_x, mouse_y; /* elements of window_data */
151 Window window, panel;
152 VOID (*FreeMem) _((IVIEW_WINDOW));
153 ColorCode backColor, drawColor;
154 int canvasWidth, canvasHeight;
155 int lineType, drawMode, lineWidth;
156 long RefCon;
157 int use_color;
158 int hasHscroll, hasVscroll, view_h, view_v;
159 int v_scroll_inc[2], h_scroll_inc[2];
160 Window hscroll, vscroll;
161 int initialized;
162 int symbolMode;
163 int cursor;
164 int clip_left, clip_top, clip_width, clip_height;
165 int clipped;
166 int frame_width, frame_height;
167 GC gc, erase_gc, xor_gc;
168 int go_away, has_menu_button;
169 } StGWWinInfo;
170 #endif /* X11WINDOWS */
172 #ifdef _Windows
173 #define IVIEW_WINDOW HWND
174 #define IVIEW_MENU HMENU
176 typedef struct {
177 LVAL Object; /* elements of window_data */
178 int idleOn; /* elements of window_data */
179 int mouse_x, mouse_y; /* elements of window_data */
180 IVIEW_WINDOW window;
181 void (*FreeMem)(HWND);
182 ColorCode backColor, drawColor;
183 int canvasWidth, canvasHeight;
184 int lineType, drawMode, lineWidth;
185 long RefCon;
186 int use_color;
187 int hasHscroll, hasVscroll, view_h, view_v;
188 int v_scroll_inc[2], h_scroll_inc[2];
189 int initialized;
190 int symbolMode;
191 int cursor;
192 RECT clip_rect;
193 int clipped;
194 LOGPEN drawPen;
195 int rect_offset;
196 int bPrinting;
197 int cxPrintPos, cyPrintPos;
198 } StGWWinInfo;
200 /* Access Defines */
201 #define SETWINOBJECT(w, d) SetWindowLong((HWND) (w), 0, (LONG) (d))
202 #define GETWINOBJECT(w) ((LVAL) GetWindowLong((HWND) (w), 0))
203 #define SETGWINFO(w, d) SetWindowLong((HWND) (w), 4, (LONG) (d))
204 #define GETGWINFO(w) ((StGWWinInfo *) GetWindowLong((HWND) (w), 4))
206 /* GDI defines */
207 #define GET_DC(w) (currentDC ? currentDC : GetDC((HWND) (w)))
208 #define RELEASE_DC(w, d) if (!currentDC) ReleaseDC((HWND) (w), (HDC) (d))
209 #define GET_DRAW_PEN(g) ((g)->drawPen)
210 #define RELEASE_PEN(p) DeleteObject(p);
211 #define SET_PEN(h,g) SelectObject(h, CreatePenIndirect(&GET_DRAW_PEN(g)))
212 #define RESTORE_PEN(h,p) RELEASE_PEN(SelectObject(h,p))
213 #define GET_DRAW_BRUSH(g) CreateSolidBrush(get_color((g)->drawColor))
214 #define GET_ERASE_BRUSH(g) CreateSolidBrush(get_color((g)->backColor))
215 #define SET_DRAW_BRUSH(h,g) SelectObject(h, GET_DRAW_BRUSH(g))
216 #define SET_ERASE_BRUSH(h,g) SelectObject(h, GET_ERASE_BRUSH(g))
217 #define RELEASE_BRUSH(b) DeleteObject(b)
218 #define RESTORE_BRUSH(h,b) RELEASE_BRUSH(SelectObject(h,b))
219 #endif /* _Windows */
221 extern StGWWinInfo *StGWObWinInfo _((LVAL object));
222 extern long StGWGetRefCon _((StGWWinInfo *));
223 extern long StGWGetColRefCon _((unsigned int index));
224 extern long StGWGetCursRefCon _((unsigned int index));
225 extern long StGWGetSymRefCon _((unsigned int index));
227 extern IVIEW_WINDOW IViewWindowNew _((LVAL object, int is_GW));
228 extern ColorCode StGWDrawColor _((StGWWinInfo *));
229 extern ColorCode StGWBackColor _((StGWWinInfo *));
230 extern LVAL IViewWindowGetObject _((IVIEW_WINDOW w));
231 StGWWinInfo *IViewWindowWinInfo _((IVIEW_WINDOW w));
233 extern IVIEW_WINDOW IViewNew _((LVAL object));
234 extern IVIEW_WINDOW IViewSpinNew _((LVAL object));
235 extern IVIEW_WINDOW IViewScatmatNew _((LVAL object));
236 extern IVIEW_WINDOW IViewListNew _((LVAL object));
237 extern IVIEW_WINDOW IViewHistNew _((LVAL object));
239 #define ARROW_CURSOR 0
240 #define WATCH_CURSOR 1
241 #define CROSS_CURSOR 2
242 #define BRUSH_CURSOR 3
243 #define HAND_CURSOR 4
244 #define FINGER_CURSOR 5
245 #define HOUR_GLASS_CURSOR 6
246 #define TRASH_BAG_CURSOR 7
247 #define TRASH_CAN_CURSOR 8
249 typedef char *IViewReallocData;
251 #ifdef MACINTOSH
252 #define Fixed Fixed_
253 #define FixRound FixRound_
254 #endif /* MACINTOSH */
256 typedef long Fixed;
258 typedef struct basic_points {
259 int num_points, num_variables;
260 double *scale, *location, **transformation;
261 IViewReallocData *data, *screen_data;
262 int recalculateScreenPoints, fixed;
263 } *IViewBasicPoints;
265 #define NOCOLOR 255
266 typedef unsigned char color_index;
268 typedef struct point_symbol {
269 int normal, highlighted;
270 } PointSymbol;
272 typedef struct point_info {
273 PointState state, screen_state;
274 char marked, masked;
275 color_index color;
276 PointSymbol symbol;
277 char *label;
278 } PointInfo;
280 typedef struct line_info {
281 int next, type;
282 char masked, width;
283 color_index color;
284 } LineInfo;
286 #ifdef USESTRINGS
287 typedef struct string_info {
288 char *string;
289 char masked, up, h, v;
290 color_index color;
291 } StringInfo;
292 #endif /* USESTRINGS */
294 typedef struct iview_data {
295 #ifdef USESTRINGS
296 IViewBasicPoints points, lines, strings;
297 IViewReallocData pointInfo, lineInfo, stringInfo;
298 #else
299 IViewBasicPoints points, lines;
300 IViewReallocData pointInfo, lineInfo;
301 #endif /* USESTRINGS */
302 double *mins, *maxes, *scale, *location;
303 int *screen_mins, *screen_maxes;
304 char **variableLabels;
305 int recalculateScreenPoints, transformed;
306 double **transformation;
307 } *IViewData;
309 #define IVIEW_WINDOW_NULL(w) (w == (IVIEW_WINDOW) 0)