STIR 6.4.0
screen.h
Go to the documentation of this file.
1
19/*
20 Copyright (C) 2000 PARAPET partners
21 Copyright (C) 2000- 2012, IRSL
22 This file is part of STIR.
23
24 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
25
26 See STIR/LICENSE.txt for details
27*/
28
29/* Change November 1997: added next 3 lines */
30#ifdef __cplusplus
31extern "C"
32{
33#endif
34
35#ifdef __STDC__
36# define ANSI
37#endif
38
39#ifndef SC_pixel_t
40# define SC_pixel_t unsigned char
41
42/* Change 13/02/98 */
43# ifndef MSDOS16BIT
44 typedef SC_pixel_t image_t;
45# else
46 typedef SC_pixel_t huge image_t;
47# endif
48#endif /* SC_pixel_t */
49
50#ifdef SC_XWINDOWS
51# include <X11/Xlib.h>
52# include <X11/keysym.h>
53# include <X11/Xutil.h>
54
55# define SC_C_BACKGROUND 12
56# define SC_C_MAX 127 /* maximum color to be used */
57# define SC_C_FULL 255 /* maximum color available */
58
59 extern Display* SCX_display;
60 extern Window SCX_window;
61 extern GC SCX_gc;
62 /* KT 28/11/2002 added for TrueColor support */
63 extern XVisualInfo SCX_visual_info;
64 extern unsigned long SCX_color_translation[SC_C_FULL + 1];
65
66 extern int SC__curPointX, SC__curPointY, SC__filled;
67 extern unsigned long SC__color;
68 extern unsigned SCX_X_MAX(void), SCX_Y_MAX(void);
69
70/* define macro to access XVisualInfo.class.
71 This is renamed by X to c_class when compiling C++ programs.
72*/
73# if defined(__cplusplus) || defined(c_plusplus)
74# define SCX_get_class(vinfo) vinfo.c_class
75# else
76# define SCX_get_class(vinfo) vinfo.class
77# endif
78
79 extern void SCX_START(void);
80 /* KT 01/03/2000 added next declaration */
81 extern void SCX_START_BIG(void);
82 extern void SCX_STOP(int stop);
83 extern int SCX_WRITE(int* x, int* y, char* text);
84 extern void SCX_PutImg(image_t*, int x_begin, int y_begin, int lengthX, int lengthY);
85
86# define SCREEN_X_MAX 1024 /* VR299 max ??*/
87# define SCREEN_Y_MAX 864 /* VR299 max */
88# define SC_START() SCX_START()
89# define SC_START_BIG() SCX_START_BIG()
90# define SC_STOP() SCX_STOP(0)
91# define SC_STOP_CLEAR() SCX_STOP(1)
92# define SC_FLUSH() XSync(SCX_display, False)
93# define SC_X_MAX SCX_X_MAX()
94# define SC_Y_MAX SCX_Y_MAX()
95# define SC_CHAR_WIDTH 10
96# define SC_CHAR_HEIGHT 10
97# define SC_CHAR_SPACING 7
98# define SC_PutImg(image, x, y, lx, ly) SCX_PutImg(image, x, y, lx, ly)
99# define SC_TJUST(hor, ver)
100# define SC_TSTYLE(par)
101# define SC_PRMFIL(par) SC__filled = par
102# define SC_COLOR(par) XSetForeground(SCX_display, SCX_gc, SC__color = (unsigned long)SCX_color_translation[par])
103# define SC_TSIZE(par)
104# define SC_POINT() XDrawPoint(SCX_display, SCX_window, SCX_gc, SC__curPointX, SC__curPointY)
105# define SC_MOVE(x, y) \
106 { \
107 SC__curPointX = (int)(x); \
108 SC__curPointY = (int)(y); \
109 }
110# define SC_DRAW(x, y) \
111 { \
112 XDrawLine(SCX_display, SCX_window, SCX_gc, SC__curPointX, SC__curPointY, (int)(x), (int)(y)); \
113 SC_MOVE(x, y); \
114 }
115# define SC_LINE(x1, y1, x2, y2) \
116 { \
117 XDrawLine(SCX_display, SCX_window, SCX_gc, (int)(x1), (int)(y1), SC__curPointX = (int)(x2), SC__curPointY = (int)(y2)); \
118 }
119# define SC_RECT(x, y) \
120 (SC__filled ? XFillRectangle(SCX_display, \
121 SCX_window, \
122 SCX_gc, \
123 (int)Min(x, SC__curPointX), \
124 (int)Min(y, SC__curPointY), \
125 (unsigned int)abs(x - SC__curPointX), \
126 (unsigned int)abs(y - SC__curPointY)) \
127 : XDrawRectangle(SCX_display, \
128 SCX_window, \
129 SCX_gc, \
130 (int)Min(x, SC__curPointX), \
131 (int)Min(y, SC__curPointY), \
132 (unsigned int)abs(x - SC__curPointX), \
133 (unsigned int)abs(y - SC__curPointY)))
134# define SC_RECTR(x, y) \
135 (SC__filled ? XFillRectangle(SCX_display, \
136 SCX_window, \
137 SCX_gc, \
138 (x < 0 ? SC__curPointX + x : SC__curPointX), \
139 (y < 0 ? SC__curPointY + y : SC__curPointY), \
140 abs(x), \
141 abs(y)) \
142 : XDrawRectangle(SCX_display, \
143 SCX_window, \
144 SCX_gc, \
145 (x < 0 ? SC__curPointX + x : SC__curPointX), \
146 (y < 0 ? SC__curPointY + y : SC__curPointY), \
147 abs(x), \
148 abs(y)))
149# define SC_ELLIPSE(x, y) \
150 (SC__filled ? XFillArc(SCX_display, SCX_window, SCX_gc, SC__curPointX - x, SC__curPointY - y, 2 * x, 2 * y, 0, 360 * 64) \
151 : XDrawArc(SCX_display, SCX_window, SCX_gc, SC__curPointX - x, SC__curPointY - y, 2 * x, 2 * y, 0, 360 * 64))
152# define SC_CIRCLE(x) SC_ELLIPSE(x, x)
153# define SC_TEXT(str) XDrawString(SCX_display, SCX_window, SCX_gc, SC__curPointX, SC__curPointY, str, (int)strlen(str))
154 /* KT 28/11/2002 only enable mask when the visual is PseudoColor */
155# define SC_MASK(par) \
156 if (SCX_get_class(SCX_visual_info) == PseudoColor) \
157 XSetPlaneMask(SCX_display, SCX_gc, (unsigned long)par)
158# define SC_LINFUN(par) XSetFunction(SCX_display, SCX_gc, par)
159# define SC_LUTX(par, R, G, B)
160# define SC_CLEARS(par)
161# define SC_LUTINT(par)
162# define SC_CLEAR_BLOCK(color, x_b, x_e, y_b, y_e) \
163 XSetForeground(SCX_display, SCX_gc, (unsigned long)SCX_color_translation[color]); \
164 XFillRectangle( \
165 SCX_display, SCX_window, SCX_gc, Min((x_b), (x_e)), Min((y_b), (y_e)), abs((x_b) - (x_e)), abs((y_b) - (y_e))); \
166 XSetForeground(SCX_display, SCX_gc, (unsigned long)SC__color);
167# define SC_LF_REPLACE GXcopy
168# define SC_LF_XOR GXxor
169# define SC_DEPTH SCX_visual_info.depth
170# define SC_C_ANNOTATE (SC_C_MAX + 1)
171 /* two definitions for masking availability */
172 /* Note: On X-windows, masking works only properly for a PseudoColor visual
173 (i.e. 8-bit color with adjustable colormap)
174 */
175 /* KT 28/11/2002 changed value for TrueColor support */
176# define SC_M_ALL ((unsigned long)-1L)
177# define SC_M_ANNOTATE (SC_C_MAX + 1)
178
179#endif /* SC_XWINDOWS */
180
181 /* change November 1997: added this function (was SCX_SCALE before) */
182 extern void SC_SCALE(int pos_x, int pos_y, int size_x, int size_y);
183
184 typedef struct screen_image
185 {
186 image_t* image;
187 int sx, sy;
188 char* text;
189 } screen_image_t;
190 /*****************************************************************************
191 routines found in screengen.c
192 *****************************************************************************/
193 /* KT 01/03/2000 added const */
194 extern void put_textstr(int x, int y, const char* str);
195 extern int center_sc_images(
196 int* Pscale, int min_x, int max_x, int min_y, int max_y, int SIZE_X, int SIZE_Y, screen_image_t sc_image[], int nr_sc);
197 extern void draw_sc_images(int size_x, int size_y, screen_image_t sc_image[], int no);
198
199/* Change November 1997: added next 3 lines: end of extern "C" */
200#ifdef __cplusplus
201}
202#endif