Mercurial > hg > xemacs-beta
comparison src/glyphs.h @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | b2472a1930f2 |
children | 6330739388db |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
24 #ifndef _XEMACS_GLYPHS_H_ | 24 #ifndef _XEMACS_GLYPHS_H_ |
25 #define _XEMACS_GLYPHS_H_ | 25 #define _XEMACS_GLYPHS_H_ |
26 | 26 |
27 #include "specifier.h" | 27 #include "specifier.h" |
28 | 28 |
29 /***************************************************************************** | 29 /************************************************************************/ |
30 * Image Instantiators * | 30 /* Image Instantiators */ |
31 *****************************************************************************/ | 31 /************************************************************************/ |
32 | 32 |
33 struct image_instantiator_methods; | 33 struct image_instantiator_methods; |
34 | 34 |
35 /* Remember the distinction between image instantiator formats and | 35 /* Remember the distinction between image instantiator formats and |
36 image instance types. Here's an approximate mapping: | 36 image instance types. Here's an approximate mapping: |
37 | 37 |
38 image instantiator format image instance type | 38 image instantiator format image instance type |
39 ------------------------- ------------------- | 39 ------------------------- ------------------- |
40 nothing nothing | 40 nothing nothing |
41 string text | 41 string text |
42 formatted-string text | 42 formatted-string text |
43 xbm mono-pixmap, color-pixmap, pointer | 43 xbm mono-pixmap, color-pixmap, pointer |
44 xpm color-pixmap, mono-pixmap, pointer | 44 xpm color-pixmap, mono-pixmap, pointer |
45 xface mono-pixmap, color-pixmap, pointer | 45 xface mono-pixmap, color-pixmap, pointer |
46 gif color-pixmap | 46 gif color-pixmap |
47 jpeg color-pixmap | 47 jpeg color-pixmap |
48 png color-pixmap | 48 png color-pixmap |
49 tiff color-pixmap | 49 tiff color-pixmap |
50 cursor-font pointer | 50 cursor-font pointer |
51 font pointer | 51 font pointer |
52 subwindow subwindow | 52 subwindow subwindow |
53 inherit mono-pixmap | 53 inherit mono-pixmap |
54 autodetect mono-pixmap, color-pixmap, pointer, | 54 autodetect mono-pixmap, color-pixmap, pointer, text |
55 text | |
56 */ | 55 */ |
57 | 56 |
58 /* These are methods specific to a particular format of image instantiator | 57 /* These are methods specific to a particular format of image instantiator |
59 (e.g. xpm, string, etc.). */ | 58 (e.g. xpm, string, etc.). */ |
60 | 59 |
118 struct image_instantiator_methods *_maybe_iiformat_meth_mstruc = (mstruc); \ | 117 struct image_instantiator_methods *_maybe_iiformat_meth_mstruc = (mstruc); \ |
119 if (HAS_IIFORMAT_METH_P (_maybe_iiformat_meth_mstruc, m)) \ | 118 if (HAS_IIFORMAT_METH_P (_maybe_iiformat_meth_mstruc, m)) \ |
120 IIFORMAT_METH (_maybe_iiformat_meth_mstruc, m, args); \ | 119 IIFORMAT_METH (_maybe_iiformat_meth_mstruc, m, args); \ |
121 } while (0) | 120 } while (0) |
122 | 121 |
123 MAC_DECLARE_EXTERN (struct image_instantiator_methods *, | |
124 MTiiformat_meth_or_given) | |
125 | |
126 /* Call a specifier method, if it exists; otherwise return | 122 /* Call a specifier method, if it exists; otherwise return |
127 the specified value */ | 123 the specified value */ |
128 | 124 |
129 #define IIFORMAT_METH_OR_GIVEN(mstruc, m, args, given) \ | 125 #define IIFORMAT_METH_OR_GIVEN(mstruc, m, args, given) \ |
130 MAC_BEGIN \ | 126 (HAS_IIFORMAT_METH_P (mstruc, m) ? \ |
131 MAC_DECLARE (struct image_instantiator_methods *, \ | 127 IIFORMAT_METH (mstruc, m, args) : (given)) |
132 MTiiformat_meth_or_given, mstruc) \ | |
133 HAS_IIFORMAT_METH_P (MTiiformat_meth_or_given, m) ? \ | |
134 IIFORMAT_METH (MTiiformat_meth_or_given, m, args) : (given) \ | |
135 MAC_END | |
136 | 128 |
137 /***** Defining new image-instantiator types *****/ | 129 /***** Defining new image-instantiator types *****/ |
138 | 130 |
139 #define DECLARE_IMAGE_INSTANTIATOR_FORMAT(format) \ | 131 #define DECLARE_IMAGE_INSTANTIATOR_FORMAT(format) \ |
140 extern struct image_instantiator_methods *format##_image_instantiator_methods | 132 extern struct image_instantiator_methods *format##_image_instantiator_methods |
143 struct image_instantiator_methods *format##_image_instantiator_methods | 135 struct image_instantiator_methods *format##_image_instantiator_methods |
144 | 136 |
145 #define INITIALIZE_IMAGE_INSTANTIATOR_FORMAT(format, obj_name) \ | 137 #define INITIALIZE_IMAGE_INSTANTIATOR_FORMAT(format, obj_name) \ |
146 do { \ | 138 do { \ |
147 format##_image_instantiator_methods = \ | 139 format##_image_instantiator_methods = \ |
148 xnew_and_zero (struct image_instantiator_methods); \ | 140 xnew_and_zero (struct image_instantiator_methods); \ |
149 defsymbol (&Q##format, obj_name); \ | 141 defsymbol (&Q##format, obj_name); \ |
150 format##_image_instantiator_methods->symbol = Q##format; \ | 142 format##_image_instantiator_methods->symbol = Q##format; \ |
151 format##_image_instantiator_methods->keywords = \ | 143 format##_image_instantiator_methods->keywords = \ |
152 Dynarr_new (ii_keyword_entry); \ | 144 Dynarr_new (ii_keyword_entry); \ |
153 add_entry_to_image_instantiator_format_list \ | 145 add_entry_to_image_instantiator_format_list \ |
184 entry.multiple_p = 1; \ | 176 entry.multiple_p = 1; \ |
185 Dynarr_add (format##_image_instantiator_methods->keywords, \ | 177 Dynarr_add (format##_image_instantiator_methods->keywords, \ |
186 entry); \ | 178 entry); \ |
187 } while (0) | 179 } while (0) |
188 | 180 |
189 extern Lisp_Object Qimage_conversion_error; | |
190 | |
191 extern Lisp_Object Q_data, Q_file; | |
192 | |
193 void add_entry_to_image_instantiator_format_list (Lisp_Object symbol, | 181 void add_entry_to_image_instantiator_format_list (Lisp_Object symbol, |
194 struct image_instantiator_methods *meths); | 182 struct image_instantiator_methods *meths); |
195 Lisp_Object find_keyword_in_vector (Lisp_Object vector, | 183 Lisp_Object find_keyword_in_vector (Lisp_Object vector, |
196 Lisp_Object keyword); | 184 Lisp_Object keyword); |
197 Lisp_Object find_keyword_in_vector_or_given (Lisp_Object vector, | 185 Lisp_Object find_keyword_in_vector_or_given (Lisp_Object vector, |
201 void check_valid_int (Lisp_Object data); | 189 void check_valid_int (Lisp_Object data); |
202 DECLARE_DOESNT_RETURN (incompatible_image_types (Lisp_Object instantiator, | 190 DECLARE_DOESNT_RETURN (incompatible_image_types (Lisp_Object instantiator, |
203 int given_dest_mask, | 191 int given_dest_mask, |
204 int desired_dest_mask)); | 192 int desired_dest_mask)); |
205 | 193 |
206 /***************************************************************************** | 194 /************************************************************************/ |
207 * Image Specifier Object * | 195 /* Image Specifier Object */ |
208 *****************************************************************************/ | 196 /************************************************************************/ |
209 | 197 |
210 DECLARE_SPECIFIER_TYPE (image); | 198 DECLARE_SPECIFIER_TYPE (image); |
211 extern Lisp_Object Qimage; | |
212 #define XIMAGE_SPECIFIER(x) XSPECIFIER_TYPE (x, image) | 199 #define XIMAGE_SPECIFIER(x) XSPECIFIER_TYPE (x, image) |
213 #define XSETIMAGE_SPECIFIER(x, p) XSETSPECIFIER_TYPE (x, p, image) | 200 #define XSETIMAGE_SPECIFIER(x, p) XSETSPECIFIER_TYPE (x, p, image) |
214 #define IMAGE_SPECIFIERP(x) SPECIFIER_TYPEP (x, image) | 201 #define IMAGE_SPECIFIERP(x) SPECIFIER_TYPEP (x, image) |
215 #define CHECK_IMAGE_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, image) | 202 #define CHECK_IMAGE_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, image) |
216 #define CONCHECK_IMAGE_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, image) | 203 #define CONCHECK_IMAGE_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, image) |
232 (IMAGE_SPECIFIER_DATA (g)->attachee_property) | 219 (IMAGE_SPECIFIER_DATA (g)->attachee_property) |
233 | 220 |
234 #define XIMAGE_SPECIFIER_ALLOWED(g) \ | 221 #define XIMAGE_SPECIFIER_ALLOWED(g) \ |
235 IMAGE_SPECIFIER_ALLOWED (XIMAGE_SPECIFIER (g)) | 222 IMAGE_SPECIFIER_ALLOWED (XIMAGE_SPECIFIER (g)) |
236 | 223 |
237 /***************************************************************************** | 224 /************************************************************************/ |
238 * Image Instance Object * | 225 /* Image Instance Object */ |
239 *****************************************************************************/ | 226 /************************************************************************/ |
240 | 227 |
241 DECLARE_LRECORD (image_instance, struct Lisp_Image_Instance); | 228 DECLARE_LRECORD (image_instance, struct Lisp_Image_Instance); |
242 #define XIMAGE_INSTANCE(x) \ | 229 #define XIMAGE_INSTANCE(x) \ |
243 XRECORD (x, image_instance, struct Lisp_Image_Instance) | 230 XRECORD (x, image_instance, struct Lisp_Image_Instance) |
244 #define XSETIMAGE_INSTANCE(x, p) XSETRECORD (x, p, image_instance) | 231 #define XSETIMAGE_INSTANCE(x, p) XSETRECORD (x, p, image_instance) |
262 #define IMAGE_TEXT_MASK (1 << 1) | 249 #define IMAGE_TEXT_MASK (1 << 1) |
263 #define IMAGE_MONO_PIXMAP_MASK (1 << 2) | 250 #define IMAGE_MONO_PIXMAP_MASK (1 << 2) |
264 #define IMAGE_COLOR_PIXMAP_MASK (1 << 3) | 251 #define IMAGE_COLOR_PIXMAP_MASK (1 << 3) |
265 #define IMAGE_POINTER_MASK (1 << 4) | 252 #define IMAGE_POINTER_MASK (1 << 4) |
266 #define IMAGE_SUBWINDOW_MASK (1 << 5) | 253 #define IMAGE_SUBWINDOW_MASK (1 << 5) |
267 | |
268 extern Lisp_Object Qnothing_image_instance_p, Qtext_image_instance_p; | |
269 extern Lisp_Object Qmono_pixmap_image_instance_p; | |
270 extern Lisp_Object Qcolor_pixmap_image_instance_p; | |
271 extern Lisp_Object Qpointer_image_instance_p; | |
272 extern Lisp_Object Qsubwindow_image_instance_p; | |
273 | 254 |
274 #define IMAGE_INSTANCE_TYPE_P(ii, type) \ | 255 #define IMAGE_INSTANCE_TYPE_P(ii, type) \ |
275 (IMAGE_INSTANCEP (ii) && XIMAGE_INSTANCE_TYPE (ii) == type) | 256 (IMAGE_INSTANCEP (ii) && XIMAGE_INSTANCE_TYPE (ii) == type) |
276 | 257 |
277 #define NOTHING_IMAGE_INSTANCEP(ii) \ | 258 #define NOTHING_IMAGE_INSTANCEP(ii) \ |
404 #define XIMAGE_INSTANCE_PIXMAP_FG(i) \ | 385 #define XIMAGE_INSTANCE_PIXMAP_FG(i) \ |
405 IMAGE_INSTANCE_PIXMAP_FG (XIMAGE_INSTANCE (i)) | 386 IMAGE_INSTANCE_PIXMAP_FG (XIMAGE_INSTANCE (i)) |
406 #define XIMAGE_INSTANCE_PIXMAP_BG(i) \ | 387 #define XIMAGE_INSTANCE_PIXMAP_BG(i) \ |
407 IMAGE_INSTANCE_PIXMAP_BG (XIMAGE_INSTANCE (i)) | 388 IMAGE_INSTANCE_PIXMAP_BG (XIMAGE_INSTANCE (i)) |
408 | 389 |
409 /***************************************************************************** | 390 /************************************************************************/ |
410 * Glyph Object * | 391 /* Glyph Object */ |
411 *****************************************************************************/ | 392 /************************************************************************/ |
412 | 393 |
413 enum glyph_type | 394 enum glyph_type |
414 { | 395 { |
415 GLYPH_UNKNOWN, | 396 GLYPH_UNKNOWN, |
416 GLYPH_BUFFER, | 397 GLYPH_BUFFER, |
442 #define GLYPHP(x) RECORDP (x, glyph) | 423 #define GLYPHP(x) RECORDP (x, glyph) |
443 #define GC_GLYPHP(x) GC_RECORDP (x, glyph) | 424 #define GC_GLYPHP(x) GC_RECORDP (x, glyph) |
444 #define CHECK_GLYPH(x) CHECK_RECORD (x, glyph) | 425 #define CHECK_GLYPH(x) CHECK_RECORD (x, glyph) |
445 #define CONCHECK_GLYPH(x) CONCHECK_RECORD (x, glyph) | 426 #define CONCHECK_GLYPH(x) CONCHECK_RECORD (x, glyph) |
446 | 427 |
447 extern Lisp_Object Qbuffer_glyph_p, Qpointer_glyph_p, Qicon_glyph_p; | |
448 | |
449 #define CHECK_BUFFER_GLYPH(x) do { \ | 428 #define CHECK_BUFFER_GLYPH(x) do { \ |
450 CHECK_GLYPH (x); \ | 429 CHECK_GLYPH (x); \ |
451 if (XGLYPH (x)->type != GLYPH_BUFFER) \ | 430 if (XGLYPH (x)->type != GLYPH_BUFFER) \ |
452 x = wrong_type_argument (Qbuffer_glyph_p, (x)); \ | 431 x = wrong_type_argument (Qbuffer_glyph_p, (x)); \ |
453 } while (0) | 432 } while (0) |
474 #define XGLYPH_IMAGE(g) GLYPH_IMAGE (XGLYPH (g)) | 453 #define XGLYPH_IMAGE(g) GLYPH_IMAGE (XGLYPH (g)) |
475 #define XGLYPH_CONTRIB_P(g) GLYPH_CONTRIB_P (XGLYPH (g)) | 454 #define XGLYPH_CONTRIB_P(g) GLYPH_CONTRIB_P (XGLYPH (g)) |
476 #define XGLYPH_BASELINE(g) GLYPH_BASELINE (XGLYPH (g)) | 455 #define XGLYPH_BASELINE(g) GLYPH_BASELINE (XGLYPH (g)) |
477 #define XGLYPH_FACE(g) GLYPH_FACE (XGLYPH (g)) | 456 #define XGLYPH_FACE(g) GLYPH_FACE (XGLYPH (g)) |
478 | 457 |
479 extern Lisp_Object Vtruncation_glyph, Vcontinuation_glyph, Voctal_escape_glyph; | 458 extern Lisp_Object Q_data, Q_file, Qconst_glyph_variable; |
480 extern Lisp_Object Vcontrol_arrow_glyph, Vinvisible_text_glyph, Vhscroll_glyph; | 459 extern Lisp_Object Qimage_conversion_error; |
460 extern Lisp_Object Vcontinuation_glyph, Vcontrol_arrow_glyph, Vhscroll_glyph; | |
461 extern Lisp_Object Vinvisible_text_glyph, Voctal_escape_glyph, Vtruncation_glyph; | |
481 extern Lisp_Object Vxemacs_logo; | 462 extern Lisp_Object Vxemacs_logo; |
482 | 463 |
483 unsigned short glyph_width (Lisp_Object glyph, Lisp_Object frame_face, | 464 unsigned short glyph_width (Lisp_Object glyph, Lisp_Object frame_face, |
484 face_index window_findex, | 465 face_index window_findex, |
485 Lisp_Object window); | 466 Lisp_Object window); |
510 Lisp_Object allocate_glyph (enum glyph_type type, | 491 Lisp_Object allocate_glyph (enum glyph_type type, |
511 void (*after_change) (Lisp_Object glyph, | 492 void (*after_change) (Lisp_Object glyph, |
512 Lisp_Object property, | 493 Lisp_Object property, |
513 Lisp_Object locale)); | 494 Lisp_Object locale)); |
514 | 495 |
515 /***************************************************************************** | 496 /************************************************************************/ |
516 * Glyph Cachels * | 497 /* Glyph Cachels */ |
517 *****************************************************************************/ | 498 /************************************************************************/ |
518 | 499 |
519 typedef struct glyph_cachel glyph_cachel; | 500 typedef struct glyph_cachel glyph_cachel; |
520 struct glyph_cachel | 501 struct glyph_cachel |
521 { | 502 { |
522 Lisp_Object glyph; | 503 Lisp_Object glyph; |
532 #define HSCROLL_GLYPH_INDEX (glyph_index) 2 | 513 #define HSCROLL_GLYPH_INDEX (glyph_index) 2 |
533 #define CONTROL_GLYPH_INDEX (glyph_index) 3 | 514 #define CONTROL_GLYPH_INDEX (glyph_index) 3 |
534 #define OCT_ESC_GLYPH_INDEX (glyph_index) 4 | 515 #define OCT_ESC_GLYPH_INDEX (glyph_index) 4 |
535 #define INVIS_GLYPH_INDEX (glyph_index) 5 | 516 #define INVIS_GLYPH_INDEX (glyph_index) 5 |
536 | 517 |
537 #define GLYPH_CACHEL(window, index) \ | 518 #define GLYPH_CACHEL(window, index) \ |
538 Dynarr_atp (window->glyph_cachels, index) | 519 Dynarr_atp (window->glyph_cachels, index) |
539 #define GLYPH_CACHEL_GLYPH(window, index) \ | 520 #define GLYPH_CACHEL_GLYPH(window, index) \ |
540 Dynarr_atp (window->glyph_cachels, index)->glyph | 521 Dynarr_atp (window->glyph_cachels, index)->glyph |
541 #define GLYPH_CACHEL_WIDTH(window, index) \ | 522 #define GLYPH_CACHEL_WIDTH(window, index) \ |
542 Dynarr_atp (window->glyph_cachels, index)->width | 523 Dynarr_atp (window->glyph_cachels, index)->width |
543 #define GLYPH_CACHEL_ASCENT(window, index) \ | 524 #define GLYPH_CACHEL_ASCENT(window, index) \ |
544 Dynarr_atp (window->glyph_cachels, index)->ascent | 525 Dynarr_atp (window->glyph_cachels, index)->ascent |
545 #define GLYPH_CACHEL_DESCENT(window, index) \ | 526 #define GLYPH_CACHEL_DESCENT(window, index) \ |
546 Dynarr_atp (window->glyph_cachels, index)->descent | 527 Dynarr_atp (window->glyph_cachels, index)->descent |
547 | 528 |
548 void mark_glyph_cachels (glyph_cachel_dynarr *elements, | 529 void mark_glyph_cachels (glyph_cachel_dynarr *elements, |
549 void (*markobj) (Lisp_Object)); | 530 void (*markobj) (Lisp_Object)); |
550 void mark_glyph_cachels_as_not_updated (struct window *w); | 531 void mark_glyph_cachels_as_not_updated (struct window *w); |
552 #ifdef MEMORY_USAGE_STATS | 533 #ifdef MEMORY_USAGE_STATS |
553 int compute_glyph_cachel_usage (glyph_cachel_dynarr *glyph_cachels, | 534 int compute_glyph_cachel_usage (glyph_cachel_dynarr *glyph_cachels, |
554 struct overhead_stats *ovstats); | 535 struct overhead_stats *ovstats); |
555 #endif /* MEMORY_USAGE_STATS */ | 536 #endif /* MEMORY_USAGE_STATS */ |
556 | 537 |
557 /***************************************************************************** | 538 /************************************************************************/ |
558 * Display Tables * | 539 /* Display Tables */ |
559 *****************************************************************************/ | 540 /************************************************************************/ |
560 | 541 |
561 #define DISP_TABLE_SIZE 256 | 542 #define DISP_TABLE_SIZE 256 |
562 #define DISP_CHAR_ENTRY(dp, c) ((c < (dp)->size) ? (dp)->contents[c] : Qnil) | 543 #define DISP_CHAR_ENTRY(dp, c) ((c < (dp)->size) ? (dp)->contents[c] : Qnil) |
563 | 544 |
564 struct Lisp_Vector *get_display_table (struct window *, face_index); | 545 struct Lisp_Vector *get_display_table (struct window *, face_index); |