|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/vibrant/ncbidraw.h |
source navigation diff markup identifier search freetext search file search |
1 /* ncbidraw.h
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: ncbidraw.h
27 *
28 * Author: Jonathan Kans
29 *
30 * Version Creation Date: 1/1/91
31 *
32 * $Revision: 6.10 $
33 *
34 * File Description:
35 * Vibrant drawing procedure definitions
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 *
40 * ==========================================================================
41 */
42
43 #ifndef _NCBIDRAW_
44 #define _NCBIDRAW_
45
46 #ifndef _NCBI_
47 #include <ncbi.h>
48 #endif
49
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 /*** PORTABLE GRAPHIC PRIMITIVE OBJECT TYPES ***/
56
57 /*
58 * Platform independent point and rectangle data structures.
59 */
60
61 typedef struct Nlm_point {
62 Nlm_Int2 x;
63 Nlm_Int2 y;
64 } Nlm_PoinT, PNTR Nlm_PointPtr;
65
66 typedef struct Nlm_rect {
67 Nlm_Int2 left;
68 Nlm_Int2 top;
69 Nlm_Int2 right;
70 Nlm_Int2 bottom;
71 } Nlm_RecT, PNTR Nlm_RectPtr;
72
73 typedef Nlm_Handle Nlm_RegioN;
74
75 typedef struct Nlm_font {
76 Nlm_VoidPtr dummy;
77 } HNDL Nlm_FonT;
78
79 /*** GLOBAL VARIABLES ***/
80
81 /*
82 * The update region contains the update region on drawing requests,
83 * and contains at least the visible region during other callbacks.
84 * Clipping is set to the update region on drawing events. The
85 * update rectangle has the minimum rectangular boundary of the
86 * update region. These variables are kept up to date by the Vibrant
87 * event loop.
88 */
89
90 extern Nlm_RegioN Nlm_updateRgn;
91 extern Nlm_RecT Nlm_updateRect;
92
93 /*
94 * The standard systemFont and programFont variables are used to
95 * specify fonts for dialog objects and scrolling text objects.
96 */
97
98 extern Nlm_FonT Nlm_systemFont;
99 extern Nlm_FonT Nlm_programFont;
100
101 /*
102 * Miscellaneous constants for pixel sizes of the standard font.
103 */
104
105 extern Nlm_Int2 Nlm_stdAscent;
106 extern Nlm_Int2 Nlm_stdDescent;
107 extern Nlm_Int2 Nlm_stdLeading;
108 extern Nlm_Int2 Nlm_stdFontHeight;
109 extern Nlm_Int2 Nlm_stdLineHeight;
110 extern Nlm_Int2 Nlm_stdCharWidth;
111
112 /*** DRAWING PROCEDURES ***/
113
114 void Nlm_SetUpDrawingTools (void);
115 void Nlm_CleanUpDrawingTools(void);
116
117 /*
118 * It is not necessary to create a new font when switching colors. The
119 * family for GetFont can be Roman, Swiss, Modern, Script, or Decorative.
120 */
121
122 /*
123 * ScrollRect will erase and invalidate all invalid regions.
124 */
125
126 void Nlm_ResetDrawingTools(void);
127
128 void Nlm_CopyMode(void);
129 void Nlm_MergeMode(void);
130 void Nlm_InvertMode(void);
131 void Nlm_EraseMode(void);
132
133 void Nlm_Black(void);
134 void Nlm_Red(void);
135 void Nlm_Green(void);
136 void Nlm_Blue(void);
137 void Nlm_Cyan(void);
138 void Nlm_Magenta(void);
139 void Nlm_Yellow(void);
140 void Nlm_White(void);
141 void Nlm_Gray(void);
142 void Nlm_LtGray(void);
143 void Nlm_DkGray(void);
144 void Nlm_SelectColor(Nlm_Uint1 red, Nlm_Uint1 green, Nlm_Uint1 blue);
145 Nlm_Uint4 Nlm_GetColorRGB(Nlm_Uint1 red, Nlm_Uint1 green, Nlm_Uint1 blue);
146 Nlm_Uint4 Nlm_GetColor(void);
147 void Nlm_SetColorEx (Nlm_Uint4 color);
148 void Nlm_SetColor(Nlm_Uint4 color);
149 void Nlm_InvertColors(void);
150 void Nlm_DecodeColor(Nlm_Uint4 color, Nlm_Uint1Ptr red, Nlm_Uint1Ptr green, Nlm_Uint1Ptr blue);
151
152 void Nlm_Solid(void);
153 void Nlm_Dark(void);
154 void Nlm_Medium(void);
155 void Nlm_Light(void);
156 void Nlm_Empty(void);
157 void Nlm_SetPenPattern(Nlm_VoidPtr pattern);
158 void Nlm_Dotted(void);
159 void Nlm_Dashed(void);
160 void Nlm_WidePen(Nlm_Int2 width);
161
162 /* Under X11 -- pen offset, dash length and gap length
163 * Under Win-NT -- parameter "offset" ignored(always zero)
164 * Other platforms -- exactly analogous to "Nlm_Dotted()"
165 */
166 void Nlm_SetPenDash(Nlm_Uint1 offset, Nlm_Uint1 dash, Nlm_Uint1 gap);
167
168 /* esl++ */
169 /*** FONT HANDLING PROCEDURES ***/
170
171 /* font styles */
172 #define STYLE_REGULAR 0
173 #define STYLE_BOLD 1
174 #define STYLE_ITALIC 2
175 #define STYLE_BOLD_ITALIC 3
176 #define STYLE_UNDERLINE 4
177 /* (other bits are used for platform-specific styles) */
178
179 /* font charset */
180 #define CHARSET_NULL 0
181 #define CHARSET_ANSI 1
182 #define CHARSET_SYMBOL 2
183 #define CHARSET_KANJI 3 /* Japanese Kanji */
184 #define CHASET_HANGUL 4 /* Korean character set */
185
186 /* font pitch */
187 #define PITCH_NULL 0
188 #define PITCH_FIXED 1
189 #define PITCH_VARIABLE 2
190
191 /* font family */
192 #define FAMILY_NULL 0
193 #define FAMILY_ROMAN 1
194 #define FAMILY_SWISS 2
195 #define FAMILY_MODERN 3
196 #define FAMILY_SCRIPT 4
197 #define FAMILY_DECORATIVE 5
198 #define FAMILY_GOTHIC 6 /* Japanese Kanji or Korean Hangle */
199 #define FAMILY_MINCHOU 7 /* Japanese Kanji */
200
201 #define FONT_NAME_SIZE 32
202
203 typedef struct Nlm_fontspec {
204 Nlm_Char name [FONT_NAME_SIZE];
205 Nlm_Int2 size;
206 Nlm_Uint1 style;
207 Nlm_Uint1 charset;
208 Nlm_Uint1 pitch;
209 Nlm_Uint1 family;
210 } Nlm_FontSpec, PNTR Nlm_FontSpecPtr;
211
212 Nlm_FonT Nlm_CreateFont(Nlm_FontSpecPtr fsp);
213 Nlm_FonT Nlm_GetResidentFont(Nlm_FontSpecPtr fsp);
214 Nlm_FonT Nlm_CopyFont(Nlm_FonT font);
215 Nlm_FonT Nlm_DeleteFont(Nlm_FonT font);
216 Nlm_FonT Nlm_FindNextResidentFont(Nlm_FonT font);
217 Nlm_Boolean Nlm_GetFontSpec(Nlm_FonT font, Nlm_FontSpecPtr fsp);
218 Nlm_Boolean Nlm_EqualFontSpec(Nlm_FontSpecPtr fsp1, Nlm_FontSpecPtr fsp2);
219
220 /*
221 * The functions below return the specifications for common fonts.
222 * The return value points to the static buffer that is owerwritten
223 * by next call to any of these functions.
224 * Example: FonT f = CreateFont (Times (24, STYLE_BOLD_ITALIC);
225 */
226 extern Nlm_FontSpecPtr Nlm_Helvetica(Nlm_Int2 size, Nlm_Uint1 style);
227 extern Nlm_FontSpecPtr Nlm_Times(Nlm_Int2 size, Nlm_Uint1 style);
228 extern Nlm_FontSpecPtr Nlm_Courier(Nlm_Int2 size, Nlm_Uint1 style);
229 extern Nlm_FontSpecPtr Nlm_Symbol(Nlm_Int2 size, Nlm_Uint1 style);
230 extern Nlm_FontSpecPtr Nlm_Gothic(Nlm_Int2 size, Nlm_Uint1 style);
231 extern Nlm_FontSpecPtr Nlm_Minchou(Nlm_Int2 size, Nlm_Uint1 style);
232 extern Nlm_FontSpecPtr Nlm_GothicFixed(Nlm_Int2 size, Nlm_Uint1 style);
233 extern Nlm_FontSpecPtr Nlm_MinchouFixed(Nlm_Int2 size, Nlm_Uint1 style);
234
235 /* esl++ end */
236
237 Nlm_FonT Nlm_GetFont(Nlm_CharPtr name, Nlm_Int2 size, Nlm_Boolean bld, Nlm_Boolean itlc, Nlm_Boolean undrln, Nlm_CharPtr fmly);
238 Nlm_FonT Nlm_GetFontEx(Nlm_CharPtr name, Nlm_Int2 size, Nlm_Boolean bld, Nlm_Boolean itlc, Nlm_Boolean undrln, Nlm_CharPtr fmly, Nlm_CharPtr chset, Nlm_Boolean fixed);
239 Nlm_FonT Nlm_ParseFont(Nlm_CharPtr spec);
240 Nlm_FonT Nlm_ParseFontEx(Nlm_CharPtr scrSpec, Nlm_CharPtr prtSpec);
241 void Nlm_SelectFont(Nlm_FonT f);
242 void Nlm_AssignPrinterFont(Nlm_FonT scrnFont, Nlm_FonT prtrFont);
243
244 Nlm_Int2 Nlm_CharWidth(Nlm_Char ch);
245 Nlm_Int2 Nlm_StringWidth(const Nlm_Char* text);
246 Nlm_Int2 Nlm_TextWidth(const Nlm_Char* text, size_t len);
247 Nlm_Int2 Nlm_Ascent(void);
248 Nlm_Int2 Nlm_Descent(void);
249 Nlm_Int2 Nlm_Leading(void);
250 Nlm_Int2 Nlm_FontHeight(void);
251 Nlm_Int2 Nlm_LineHeight(void);
252 Nlm_Int2 Nlm_MaxCharWidth(void);
253
254 /* Calculate(based on the presently active font) and return maximum
255 * number of characters from the string "str" which can be fit into
256 * "*max_width" pixels.
257 * Return 0 if the "str" is NULL or empty or if the curr.font is NULL.
258 */
259 size_t Nlm_FitStringWidth(const Nlm_Char PNTR str, Nlm_Int4 max_width);
260
261 void Nlm_SetPen(Nlm_PoinT pt);
262 void Nlm_GetPen(Nlm_PointPtr pt);
263 void Nlm_SetPenWidth(Nlm_Int2 width);
264
265 void Nlm_PaintChar(Nlm_Char ch);
266 void Nlm_PaintString(Nlm_CharPtr text);
267 void Nlm_PaintStringEx(Nlm_CharPtr text, Nlm_Int2 x, Nlm_Int2 y);
268 void CDECL Nlm_PaintText(char *format, ...);
269
270 void Nlm_DrawString(Nlm_RectPtr r, Nlm_CharPtr text, Nlm_Char jst, Nlm_Boolean gray);
271 void Nlm_DrawText(Nlm_RectPtr r, Nlm_CharPtr text, size_t len, Nlm_Char jst, Nlm_Boolean gray);
272
273 void Nlm_MoveTo(Nlm_Int2 x, Nlm_Int2 y);
274 void Nlm_LineTo(Nlm_Int2 x, Nlm_Int2 y);
275 void Nlm_DrawLine(Nlm_PoinT pt1, Nlm_PoinT pt2);
276
277 void Nlm_LoadPt(Nlm_PointPtr pt, Nlm_Int2 x, Nlm_Int2 y);
278 void Nlm_AddPt(Nlm_PoinT src, Nlm_PointPtr dst);
279 void Nlm_SubPt(Nlm_PoinT src, Nlm_PointPtr dst);
280 Nlm_Boolean Nlm_EqualPt(Nlm_PoinT p1, Nlm_PoinT p2);
281 Nlm_Boolean Nlm_PtInRect(Nlm_PoinT pt, Nlm_RectPtr r);
282 Nlm_Boolean Nlm_PtInRgn(Nlm_PoinT pt, Nlm_RegioN rgn);
283
284 void Nlm_LoadRect(Nlm_RectPtr r, Nlm_Int2 lf, Nlm_Int2 tp, Nlm_Int2 rt, Nlm_Int2 bt);
285 void Nlm_UpsetRect(Nlm_RectPtr r, Nlm_Int2 lf, Nlm_Int2 tp, Nlm_Int2 rt, Nlm_Int2 bt);
286 void Nlm_OffsetRect(Nlm_RectPtr r, Nlm_Int2 dx, Nlm_Int2 dy);
287 void Nlm_InsetRect(Nlm_RectPtr r, Nlm_Int2 dx, Nlm_Int2 dy);
288 Nlm_Boolean Nlm_SectRect(Nlm_RectPtr src1, Nlm_RectPtr src2, Nlm_RectPtr dst);
289 Nlm_Boolean Nlm_UnionRect(Nlm_RectPtr src1, Nlm_RectPtr src2, Nlm_RectPtr dst);
290 Nlm_Boolean Nlm_EqualRect(Nlm_RectPtr r1, Nlm_RectPtr r2);
291 Nlm_Boolean Nlm_EmptyRect(Nlm_RectPtr r);
292 Nlm_Boolean Nlm_RectInRect(Nlm_RectPtr r1, Nlm_RectPtr r2);
293 Nlm_Boolean Nlm_RectInRgn(Nlm_RectPtr r, Nlm_RegioN rgn);
294
295 void Nlm_EraseRect(Nlm_RectPtr r);
296 void Nlm_FrameRect(Nlm_RectPtr r);
297 void Nlm_PaintRect(Nlm_RectPtr r);
298 void Nlm_InvertRect(Nlm_RectPtr r);
299 void Nlm_ScrollRect(Nlm_RectPtr r, Nlm_Int2 dx, Nlm_Int2 dy);
300
301 void Nlm_EraseOval(Nlm_RectPtr r);
302 void Nlm_FrameOval(Nlm_RectPtr r);
303 void Nlm_PaintOval(Nlm_RectPtr r);
304 void Nlm_InvertOval(Nlm_RectPtr r);
305
306 void Nlm_EraseRoundRect(Nlm_RectPtr r, Nlm_Int2 ovlWid, Nlm_Int2 ovlHgt);
307 void Nlm_FrameRoundRect(Nlm_RectPtr r, Nlm_Int2 ovlWid, Nlm_Int2 ovlHgt);
308 void Nlm_PaintRoundRect(Nlm_RectPtr r, Nlm_Int2 ovlWid, Nlm_Int2 ovlHgt);
309 void Nlm_InvertRoundRect(Nlm_RectPtr r, Nlm_Int2 ovlWid, Nlm_Int2 ovlHgt);
310
311 void Nlm_EraseArc(Nlm_RectPtr r, Nlm_PoinT start, Nlm_PoinT end);
312 void Nlm_FrameArc(Nlm_RectPtr r, Nlm_PoinT start, Nlm_PoinT end);
313 void Nlm_PaintArc(Nlm_RectPtr r, Nlm_PoinT start, Nlm_PoinT end);
314 void Nlm_InvertArc(Nlm_RectPtr r, Nlm_PoinT start, Nlm_PoinT end);
315
316 /* Special case of an arc(90 grad) */
317 typedef enum {
318 eQ_RightTop = 1,
319 eQ_LeftTop = 2,
320 eQ_LeftBottom = 3,
321 eQ_RightBottom = 4
322 } Nlm_EQuadrant;
323 #define EQuadrant Nlm_EQuadrant
324
325 void Nlm_EraseQuadrant(Nlm_RectPtr r, Nlm_EQuadrant quadrant);
326 void Nlm_FrameQuadrant(Nlm_RectPtr r, Nlm_EQuadrant quadrant);
327 void Nlm_PaintQuadrant(Nlm_RectPtr r, Nlm_EQuadrant quadrant);
328 void Nlm_InvertQuadrant(Nlm_RectPtr r, Nlm_EQuadrant quadrant);
329
330
331 void Nlm_ErasePoly(Nlm_Int2 num, Nlm_PointPtr pts);
332 void Nlm_FramePoly(Nlm_Int2 num, Nlm_PointPtr pts);
333 void Nlm_PaintPoly(Nlm_Int2 num, Nlm_PointPtr pts);
334 void Nlm_InvertPoly(Nlm_Int2 num, Nlm_PointPtr pts);
335
336 Nlm_RegioN Nlm_CreateRgn(void);
337 Nlm_RegioN Nlm_DestroyRgn(Nlm_RegioN rgn);
338 void Nlm_ClearRgn(Nlm_RegioN rgn);
339 void Nlm_LoadRectRgn(Nlm_RegioN rgn, Nlm_Int2 lf, Nlm_Int2 tp, Nlm_Int2 rt, Nlm_Int2 bt);
340 void Nlm_OffsetRgn(Nlm_RegioN rgn, Nlm_Int2 dx, Nlm_Int2 dy);
341 void Nlm_SectRgn(Nlm_RegioN src1, Nlm_RegioN src2, Nlm_RegioN dst);
342 void Nlm_UnionRgn(Nlm_RegioN src1, Nlm_RegioN src2, Nlm_RegioN dst);
343 void Nlm_DiffRgn(Nlm_RegioN src1, Nlm_RegioN src2, Nlm_RegioN dst);
344 void Nlm_XorRgn(Nlm_RegioN src1, Nlm_RegioN src2, Nlm_RegioN dst);
345 Nlm_Boolean Nlm_EqualRgn(Nlm_RegioN rgn1, Nlm_RegioN rgn2);
346 Nlm_Boolean Nlm_EmptyRgn(Nlm_RegioN rgn);
347
348 void Nlm_EraseRgn(Nlm_RegioN rgn);
349 void Nlm_FrameRgn(Nlm_RegioN rgn);
350 void Nlm_PaintRgn(Nlm_RegioN rgn);
351 void Nlm_InvertRgn(Nlm_RegioN rgn);
352
353 void Nlm_ClipRect(Nlm_RectPtr r);
354 void Nlm_ClipRgn(Nlm_RegioN rgn);
355 void Nlm_ResetClip(void);
356
357 void Nlm_ValidRect(Nlm_RectPtr r);
358 void Nlm_InvalRect(Nlm_RectPtr r);
359 void Nlm_ValidRgn(Nlm_RegioN rgn);
360 void Nlm_InvalRgn(Nlm_RegioN rgn);
361
362 void Nlm_CopyBits(Nlm_RectPtr r, Nlm_VoidPtr source);
363
364 typedef struct {
365 Nlm_Uint1 red;
366 Nlm_Uint1 green;
367 Nlm_Uint1 blue;
368 } Nlm_RGBColoR, PNTR Nlm_RGBColoRPtr;
369
370 void Nlm_CopyPixmap(Nlm_RectPtr r, Nlm_Int1Ptr source,
371 Nlm_Uint1 totalColors,
372 Nlm_RGBColoRPtr colorTable);
373
374 /* Try to read alternate color set from the user-specified file;
375 * <table_index> <red> <green> <blue> [<name>].
376 * Return number of updated colors
377 */
378 size_t Nlm_UpdateColorTable(Nlm_RGBColoR table[], size_t table_size,
379 const Nlm_Char PNTR filename);
380 #define UpdateColorTable Nlm_UpdateColorTable
381
382
383 /* [WIN_GIF] Create a GIF image with the given attributes, and set it as
384 * the current drawable.
385 */
386 Nlm_Boolean Nlm_CreateGIF(Nlm_Int2 width, Nlm_Int2 height,
387 Nlm_Boolean transparent);
388 #define CreateGIF Nlm_CreateGIF
389
390 /* [WIN_GIF] Save current GIF drawable to output stream "out".
391 */
392 Nlm_Boolean Nlm_SaveGIF(FILE* out);
393 #define SaveGIF Nlm_SaveGIF
394
395 /* [WIN_GIF] Destroy current GIF drawable (if any).
396 */
397 void Nlm_DestroyGIF(void);
398 #define DestroyGIF Nlm_DestroyGIF
399
400 /* [WIN_GIF] Make GIF image "im" be the current drawable.
401 * Return the previous one.
402 */
403 struct gdImageStruct* Nlm_SetCurrentGIF(struct gdImageStruct* im);
404 #define SetCurrentGIF Nlm_SetCurrentGIF
405
406
407 /* If the application is using GUI or just drawing(picture) functionality */
408 Nlm_Boolean Nlm_VibrantIsGUI(void);
409 #define VibrantIsGUI Nlm_VibrantIsGUI
410
411 #ifdef __cplusplus
412 }
413 #endif
414
415 #endif
416
417 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |