1 /* Generic glyph data structures + display tables
2 Copyright (C) 1994 Board of Trustees, University of Illinois.
3 Copyright (C) 1995, 1996 Ben Wing
5 This file is part of XEmacs.
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Synched up with: Not in FSF. */
24 #ifndef INCLUDED_glyphs_h_
25 #define INCLUDED_glyphs_h_
27 #include "specifier.h"
30 /************************************************************************/
31 /* Image Instantiators */
32 /************************************************************************/
34 struct image_instantiator_methods;
36 /* Remember the distinction between image instantiator formats and
37 image instance types. Here's an approximate mapping:
39 image instantiator format image instance type
40 ------------------------- -------------------
44 xbm mono-pixmap, color-pixmap, pointer
45 xpm color-pixmap, mono-pixmap, pointer
46 xface mono-pixmap, color-pixmap, pointer
53 mswindows-resource pointer
57 autodetect mono-pixmap, color-pixmap, pointer, text
68 /* These are methods specific to a particular format of image instantiator
69 (e.g. xpm, string, etc.). */
71 typedef struct ii_keyword_entry ii_keyword_entry;
72 struct ii_keyword_entry
75 void (*validate) (Lisp_Object data);
82 Dynarr_declare (ii_keyword_entry);
83 } ii_keyword_entry_dynarr;
85 extern const struct struct_description iim_description;
87 enum image_instance_geometry
90 IMAGE_DESIRED_GEOMETRY,
93 IMAGE_UNSPECIFIED_GEOMETRY = ~0
96 #define WIDGET_BORDER_HEIGHT 4
97 #define WIDGET_BORDER_WIDTH 4
99 struct image_instantiator_methods
103 Lisp_Object device; /* sometimes used */
105 ii_keyword_entry_dynarr *keywords;
106 /* consoles this ii is supported on */
107 console_type_entry_dynarr *consoles;
108 /* Implementation specific methods: */
110 /* Validate method: Given an instantiator vector, signal an error if
111 it's invalid for this image-instantiator format. Note that this
112 validation only occurs after all the keyword-specific validation
113 has already been performed. This is chiefly useful for making
114 sure that certain required keywords are present. */
115 void (*validate_method) (Lisp_Object instantiator);
117 /* Normalize method: Given an instantiator, convert it to the form
118 that should be used in a glyph, for devices of type CONSOLE_TYPE.
119 Signal an error if conversion fails. */
120 Lisp_Object (*normalize_method) (Lisp_Object instantiator,
121 Lisp_Object console_type);
123 /* Possible-dest-types method: Return a mask indicating what dest types
124 are compatible with this format. */
125 int (*possible_dest_types_method) (void);
127 /* Instantiate method: Given an instantiator and a partially
128 filled-in image instance, complete the filling-in. Return
129 non-zero if the instantiation succeeds, 0 if it fails.
130 This must be present. */
131 void (*instantiate_method) (Lisp_Object image_instance,
132 Lisp_Object instantiator,
133 Lisp_Object pointer_fg,
134 Lisp_Object pointer_bg,
137 /* Property method: Given an image instance, return device specific
139 Lisp_Object (*property_method) (Lisp_Object image_instance,
140 Lisp_Object property);
141 /* Set-property method: Given an image instance, set device specific
143 Lisp_Object (*set_property_method) (Lisp_Object image_instance,
144 Lisp_Object property,
147 /* Find out the desired geometry, as given by disp, of this image
148 instance. Actual geometry is stored in the appropriate slots in the
150 void (*query_geometry_method) (Lisp_Object image_instance,
151 unsigned int* width, unsigned int* height,
152 enum image_instance_geometry disp,
155 /* Layout the instance and its children bounded by the provided
157 void (*layout_method) (Lisp_Object image_instance,
158 unsigned int width, unsigned int height,
162 /***** Calling an image-instantiator method *****/
164 #define HAS_IIFORMAT_METH_P(mstruc, m) (((mstruc)->m##_method) != 0)
165 #define IIFORMAT_METH(mstruc, m, args) (((mstruc)->m##_method) args)
167 /* Call a void-returning specifier method, if it exists */
168 #define MAYBE_IIFORMAT_METH(mstruc, m, args) \
170 struct image_instantiator_methods *MIM_mstruc = (mstruc); \
171 if (MIM_mstruc && HAS_IIFORMAT_METH_P (MIM_mstruc, m)) \
172 IIFORMAT_METH (MIM_mstruc, m, args); \
175 #define MAYBE_IIFORMAT_DEVMETH(device, mstruc, m, args) \
177 struct image_instantiator_methods *MID_mstruc = \
178 decode_ii_device (device, mstruc); \
180 MAYBE_IIFORMAT_METH(MID_mstruc, m, args); \
184 /* Call a specifier method, if it exists; otherwise return
185 the specified value */
187 #define IIFORMAT_METH_OR_GIVEN(mstruc, m, args, given) \
188 (HAS_IIFORMAT_METH_P (mstruc, m) ? \
189 IIFORMAT_METH (mstruc, m, args) : (given))
191 /***** Defining new image-instantiator types *****/
193 #define DECLARE_IMAGE_INSTANTIATOR_FORMAT(format) \
194 extern struct image_instantiator_methods *format##_image_instantiator_methods
196 #define DEFINE_IMAGE_INSTANTIATOR_FORMAT(format) \
197 struct image_instantiator_methods *format##_image_instantiator_methods
199 #define INITIALIZE_IMAGE_INSTANTIATOR_FORMAT_NO_SYM(format, obj_name) \
201 format##_image_instantiator_methods = \
202 xnew_and_zero (struct image_instantiator_methods); \
203 format##_image_instantiator_methods->symbol = Q##format; \
204 format##_image_instantiator_methods->device = Qnil; \
205 format##_image_instantiator_methods->keywords = \
206 Dynarr_new (ii_keyword_entry); \
207 format##_image_instantiator_methods->consoles = \
208 Dynarr_new (console_type_entry); \
209 add_entry_to_image_instantiator_format_list \
210 (Q##format, format##_image_instantiator_methods); \
211 dumpstruct (&format##_image_instantiator_methods, \
215 #define INITIALIZE_IMAGE_INSTANTIATOR_FORMAT(format, obj_name) \
217 defsymbol (&Q##format, obj_name); \
218 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT_NO_SYM(format, obj_name);\
221 /* Declare that image-instantiator format FORMAT has method M; used in
222 initialization routines */
223 #define IIFORMAT_HAS_METHOD(format, m) \
224 (format##_image_instantiator_methods->m##_method = format##_##m)
226 #define IIFORMAT_HAS_SHARED_METHOD(format, m, type) \
227 (format##_image_instantiator_methods->m##_method = type##_##m)
229 /* Declare that KEYW is a valid keyword for image-instantiator format
230 FORMAT. VALIDATE_FUN if a function that returns whether the data
231 is valid. The keyword may not appear more than once. */
232 #define IIFORMAT_VALID_GENERIC_KEYWORD(format, keyw, validate_fun, copy, multi) \
234 struct ii_keyword_entry entry; \
236 entry.keyword = keyw; \
237 entry.validate = validate_fun; \
238 entry.multiple_p = multi; \
239 entry.copy_p = copy; \
240 Dynarr_add (format##_image_instantiator_methods->keywords, \
244 #define IIFORMAT_VALID_KEYWORD(format, keyw, validate_fun) \
245 IIFORMAT_VALID_GENERIC_KEYWORD(format, keyw, validate_fun, 1, 0)
247 /* Same as IIFORMAT_VALID_KEYWORD except that the keyword may
248 appear multiple times. */
249 #define IIFORMAT_VALID_MULTI_KEYWORD(format, keyw, validate_fun) \
250 IIFORMAT_VALID_GENERIC_KEYWORD(format, keyw, validate_fun, 1, 1)
252 /* Same as IIFORMAT_VALID_KEYWORD execpt that the argument is not
253 copied by the specifier functions. This is necessary for things
254 like callbacks etc. */
255 #define IIFORMAT_VALID_NONCOPY_KEYWORD(format, keyw, validate_fun) \
256 IIFORMAT_VALID_GENERIC_KEYWORD(format, keyw, validate_fun, 0, 0)
258 /* Declare that image-instantiator format FORMAT is supported on
260 #define IIFORMAT_VALID_CONSOLE(console, format) \
262 struct console_type_entry entry; \
264 entry.symbol = Q##console; \
265 entry.meths = console##_console_methods; \
266 Dynarr_add (format##_image_instantiator_methods->consoles, \
270 #define DEFINE_DEVICE_IIFORMAT(type, format) \
271 DECLARE_IMAGE_INSTANTIATOR_FORMAT(format); \
272 struct image_instantiator_methods *type##_##format##_image_instantiator_methods
274 #define INITIALIZE_DEVICE_IIFORMAT(type, format) \
276 type##_##format##_image_instantiator_methods = \
277 xnew_and_zero (struct image_instantiator_methods); \
278 type##_##format##_image_instantiator_methods->symbol = Q##format; \
279 type##_##format##_image_instantiator_methods->device = Q##type; \
280 type##_##format##_image_instantiator_methods->keywords = \
281 Dynarr_new (ii_keyword_entry); \
282 add_entry_to_device_ii_format_list \
283 (Q##type, Q##format, type##_##format##_image_instantiator_methods); \
284 IIFORMAT_VALID_CONSOLE(type,format); \
285 dumpstruct (&type##_##format##_image_instantiator_methods, \
289 /* Declare that image-instantiator format FORMAT has method M; used in
290 initialization routines */
291 #define IIFORMAT_HAS_DEVMETHOD(type, format, m) \
292 (type##_##format##_image_instantiator_methods->m##_method = type##_##format##_##m)
293 #define IIFORMAT_HAS_SHARED_DEVMETHOD(type, format, m, fromformat) \
294 (type##_##format##_image_instantiator_methods->m##_method = type##_##fromformat##_##m)
296 struct image_instantiator_methods *
297 decode_device_ii_format (Lisp_Object device, Lisp_Object format,
298 Error_behavior errb);
299 struct image_instantiator_methods *
300 decode_image_instantiator_format (Lisp_Object format, Error_behavior errb);
302 void add_entry_to_image_instantiator_format_list (Lisp_Object symbol,
303 struct image_instantiator_methods *meths);
304 void add_entry_to_device_ii_format_list (Lisp_Object device, Lisp_Object symbol,
305 struct image_instantiator_methods *meths);
306 Lisp_Object find_keyword_in_vector (Lisp_Object vector,
307 Lisp_Object keyword);
308 Lisp_Object find_keyword_in_vector_or_given (Lisp_Object vector,
310 Lisp_Object default_);
311 Lisp_Object simple_image_type_normalize (Lisp_Object inst,
312 Lisp_Object console_type,
313 Lisp_Object image_type_tag);
314 Lisp_Object potential_pixmap_file_instantiator (Lisp_Object instantiator,
315 Lisp_Object file_keyword,
316 Lisp_Object data_keyword,
317 Lisp_Object console_type);
318 void check_valid_string (Lisp_Object data);
319 void check_valid_int (Lisp_Object data);
320 void check_valid_face (Lisp_Object data);
321 void check_valid_vector (Lisp_Object data);
322 void check_valid_item_list_1 (Lisp_Object items);
324 void initialize_subwindow_image_instance (Lisp_Image_Instance*);
325 void subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
326 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
327 int dest_mask, Lisp_Object domain);
328 void widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
329 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
330 int dest_mask, Lisp_Object domain);
331 void image_instance_query_geometry (Lisp_Object image_instance,
332 unsigned int* width, unsigned int* height,
333 enum image_instance_geometry disp,
335 void image_instance_layout (Lisp_Object image_instance,
336 unsigned int width, unsigned int height,
338 int invalidate_glyph_geometry_maybe (Lisp_Object glyph_or_ii, struct window* w);
340 DECLARE_DOESNT_RETURN (incompatible_image_types (Lisp_Object instantiator,
342 int desired_dest_mask));
343 DECLARE_DOESNT_RETURN (signal_image_error (CONST char *, Lisp_Object));
344 DECLARE_DOESNT_RETURN (signal_image_error_2 (CONST char *, Lisp_Object, Lisp_Object));
346 /************************************************************************/
347 /* Image Specifier Object */
348 /************************************************************************/
350 DECLARE_SPECIFIER_TYPE (image);
351 #define XIMAGE_SPECIFIER(x) XSPECIFIER_TYPE (x, image)
352 #define XSETIMAGE_SPECIFIER(x, p) XSETSPECIFIER_TYPE (x, p, image)
353 #define IMAGE_SPECIFIERP(x) SPECIFIER_TYPEP (x, image)
354 #define CHECK_IMAGE_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, image)
355 #define CONCHECK_IMAGE_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, image)
357 void set_image_attached_to (Lisp_Object obj, Lisp_Object face_or_glyph,
358 Lisp_Object property);
360 struct image_specifier
363 Lisp_Object attachee; /* face or glyph this is attached to, or nil */
364 Lisp_Object attachee_property;/* property of that face or glyph */
367 #define IMAGE_SPECIFIER_DATA(g) (SPECIFIER_TYPE_DATA (g, image))
368 #define IMAGE_SPECIFIER_ALLOWED(g) (IMAGE_SPECIFIER_DATA (g)->allowed)
369 #define IMAGE_SPECIFIER_ATTACHEE(g) (IMAGE_SPECIFIER_DATA (g)->attachee)
370 #define IMAGE_SPECIFIER_ATTACHEE_PROPERTY(g) \
371 (IMAGE_SPECIFIER_DATA (g)->attachee_property)
373 #define XIMAGE_SPECIFIER_ALLOWED(g) \
374 IMAGE_SPECIFIER_ALLOWED (XIMAGE_SPECIFIER (g))
376 /************************************************************************/
377 /* Image Instance Object */
378 /************************************************************************/
380 DECLARE_LRECORD (image_instance, Lisp_Image_Instance);
381 #define XIMAGE_INSTANCE(x) XRECORD (x, image_instance, Lisp_Image_Instance)
382 #define XSETIMAGE_INSTANCE(x, p) XSETRECORD (x, p, image_instance)
383 #define IMAGE_INSTANCEP(x) RECORDP (x, image_instance)
384 #define CHECK_IMAGE_INSTANCE(x) CHECK_RECORD (x, image_instance)
385 #define CONCHECK_IMAGE_INSTANCE(x) CONCHECK_RECORD (x, image_instance)
387 enum image_instance_type
400 #define IMAGE_NOTHING_MASK (1 << 0)
401 #define IMAGE_TEXT_MASK (1 << 1)
402 #define IMAGE_MONO_PIXMAP_MASK (1 << 2)
403 #define IMAGE_COLOR_PIXMAP_MASK (1 << 3)
404 #define IMAGE_POINTER_MASK (1 << 4)
405 #define IMAGE_SUBWINDOW_MASK (1 << 5)
406 #define IMAGE_WIDGET_MASK (1 << 6)
407 #define IMAGE_LAYOUT_MASK (1 << 7)
409 #define IMAGE_INSTANCE_TYPE_P(ii, type) \
410 (IMAGE_INSTANCEP (ii) && XIMAGE_INSTANCE_TYPE (ii) == type)
412 #define NOTHING_IMAGE_INSTANCEP(ii) \
413 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_NOTHING)
414 #define TEXT_IMAGE_INSTANCEP(ii) \
415 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_TEXT)
416 #define MONO_PIXMAP_IMAGE_INSTANCEP(ii) \
417 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_MONO_PIXMAP)
418 #define COLOR_PIXMAP_IMAGE_INSTANCEP(ii) \
419 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_COLOR_PIXMAP)
420 #define POINTER_IMAGE_INSTANCEP(ii) \
421 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_POINTER)
422 #define SUBWINDOW_IMAGE_INSTANCEP(ii) \
423 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_SUBWINDOW)
424 #define WIDGET_IMAGE_INSTANCEP(ii) \
425 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_WIDGET)
426 #define LAYOUT_IMAGE_INSTANCEP(ii) \
427 IMAGE_INSTANCE_TYPE_P (ii, IMAGE_LAYOUT)
429 #define CHECK_NOTHING_IMAGE_INSTANCE(x) do { \
430 CHECK_IMAGE_INSTANCE (x); \
431 if (!NOTHING_IMAGE_INSTANCEP (x)) \
432 x = wrong_type_argument (Qnothing_image_instance_p, (x)); \
435 #define CHECK_TEXT_IMAGE_INSTANCE(x) do { \
436 CHECK_IMAGE_INSTANCE (x); \
437 if (!TEXT_IMAGE_INSTANCEP (x)) \
438 x = wrong_type_argument (Qtext_image_instance_p, (x)); \
441 #define CHECK_MONO_PIXMAP_IMAGE_INSTANCE(x) do { \
442 CHECK_IMAGE_INSTANCE (x); \
443 if (!MONO_PIXMAP_IMAGE_INSTANCEP (x)) \
444 x = wrong_type_argument (Qmono_pixmap_image_instance_p, (x)); \
447 #define CHECK_COLOR_PIXMAP_IMAGE_INSTANCE(x) do { \
448 CHECK_IMAGE_INSTANCE (x); \
449 if (!COLOR_PIXMAP_IMAGE_INSTANCEP (x)) \
450 x = wrong_type_argument (Qcolor_pixmap_image_instance_p, (x)); \
453 #define CHECK_POINTER_IMAGE_INSTANCE(x) do { \
454 CHECK_IMAGE_INSTANCE (x); \
455 if (!POINTER_IMAGE_INSTANCEP (x)) \
456 x = wrong_type_argument (Qpointer_image_instance_p, (x)); \
459 #define CHECK_SUBWINDOW_IMAGE_INSTANCE(x) do { \
460 CHECK_IMAGE_INSTANCE (x); \
461 if (!SUBWINDOW_IMAGE_INSTANCEP (x) \
462 && !WIDGET_IMAGE_INSTANCEP (x)) \
463 x = wrong_type_argument (Qsubwindow_image_instance_p, (x)); \
466 #define CHECK_WIDGET_IMAGE_INSTANCE(x) do { \
467 CHECK_IMAGE_INSTANCE (x); \
468 if (!WIDGET_IMAGE_INSTANCEP (x)) \
469 x = wrong_type_argument (Qwidget_image_instance_p, (x)); \
472 #define CHECK_LAYOUT_IMAGE_INSTANCE(x) do { \
473 CHECK_IMAGE_INSTANCE (x); \
474 if (!LAYOUT_IMAGE_INSTANCEP (x)) \
475 x = wrong_type_argument (Qlayout_image_instance_p, (x)); \
478 struct Lisp_Image_Instance
480 struct lcrecord_header header;
483 /* The glyph from which we were instantiated. This is a weak
486 enum image_instance_type type;
487 unsigned int x_offset, y_offset; /* for layout purposes */
488 unsigned int width, height;
489 unsigned int dirty : 1;
494 unsigned int descent;
500 unsigned int slice, maxslice, timeout;
501 Lisp_Object hotspot_x, hotspot_y; /* integer or Qnil */
502 Lisp_Object filename; /* string or Qnil */
503 Lisp_Object mask_filename; /* string or Qnil */
504 Lisp_Object fg, bg; /* foreground and background colors,
505 if this is a colorized mono-pixmap
507 Lisp_Object auxdata; /* list or Qnil: any additional data
508 to be seen from lisp */
509 void* mask; /* mask that can be seen from all windowing systems */
510 } pixmap; /* used for pointers as well */
514 void* subwindow; /* specific devices can use this as necessary */
515 unsigned int being_displayed : 1; /* used to detect when needs to be unmapped */
516 unsigned int v_resize : 1; /* Whether the vsize is allowed to change. */
517 unsigned int h_resize : 1; /* Whether the hsize is allowed to change. */
518 unsigned int orientation : 1; /* Vertical or horizontal. */
519 unsigned int justification : 2; /* Left, right or center. */
520 /* Face for colors and font. We specify this here becuase we
521 want people to be able to put :face in the instantiator
522 spec. Using gyph-face is more inconvenient, although more
526 Lisp_Object props; /* properties or border*/
527 Lisp_Object items; /* a list of gui_items or children */
531 /* console-type- and image-type-specific data */
535 /* Layout bit-fields. */
536 #define LAYOUT_HORIZONTAL 0
537 #define LAYOUT_VERTICAL 1
539 #define LAYOUT_JUSTIFY_LEFT 0
540 #define LAYOUT_JUSTIFY_RIGHT 1
541 #define LAYOUT_JUSTIFY_CENTER 2
543 /* Accessor macros. */
544 #define IMAGE_INSTANCE_DEVICE(i) ((i)->device)
545 #define IMAGE_INSTANCE_NAME(i) ((i)->name)
546 #define IMAGE_INSTANCE_GLYPH(i) ((i)->glyph)
547 #define IMAGE_INSTANCE_TYPE(i) ((i)->type)
548 #define IMAGE_INSTANCE_XOFFSET(i) ((i)->x_offset)
549 #define IMAGE_INSTANCE_YOFFSET(i) ((i)->y_offset)
550 #define IMAGE_INSTANCE_WIDTH(i) ((i)->width)
551 #define IMAGE_INSTANCE_HEIGHT(i) ((i)->height)
552 #define IMAGE_INSTANCE_PIXMAP_TYPE_P(i) \
553 ((IMAGE_INSTANCE_TYPE (i) == IMAGE_MONO_PIXMAP) \
554 || (IMAGE_INSTANCE_TYPE (i) == IMAGE_COLOR_PIXMAP))
555 #define IMAGE_INSTANCE_DIRTYP(i) ((i)->dirty)
556 #define IMAGE_INSTANCE_FACE(i) \
557 XGLYPH_FACE (IMAGE_INSTANCE_GLYPH (i))
559 #define IMAGE_INSTANCE_TEXT_STRING(i) ((i)->u.text.string)
560 #define IMAGE_INSTANCE_TEXT_WIDTH(i) \
561 IMAGE_INSTANCE_WIDTH(i)
562 #define IMAGE_INSTANCE_TEXT_HEIGHT(i) \
563 IMAGE_INSTANCE_HEIGHT(i)
564 #define IMAGE_INSTANCE_TEXT_DESCENT(i) ((i)->u.text.descent)
565 #define IMAGE_INSTANCE_TEXT_ASCENT(i) \
566 (IMAGE_INSTANCE_TEXT_HEIGHT(i) - IMAGE_INSTANCE_TEXT_DESCENT(i))
568 #define IMAGE_INSTANCE_PIXMAP_WIDTH(i) \
569 IMAGE_INSTANCE_WIDTH(i)
570 #define IMAGE_INSTANCE_PIXMAP_HEIGHT(i) \
571 IMAGE_INSTANCE_HEIGHT(i)
572 #define IMAGE_INSTANCE_PIXMAP_DEPTH(i) ((i)->u.pixmap.depth)
573 #define IMAGE_INSTANCE_PIXMAP_FILENAME(i) ((i)->u.pixmap.filename)
574 #define IMAGE_INSTANCE_PIXMAP_MASK_FILENAME(i) ((i)->u.pixmap.mask_filename)
575 #define IMAGE_INSTANCE_PIXMAP_HOTSPOT_X(i) ((i)->u.pixmap.hotspot_x)
576 #define IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y(i) ((i)->u.pixmap.hotspot_y)
577 #define IMAGE_INSTANCE_PIXMAP_FG(i) ((i)->u.pixmap.fg)
578 #define IMAGE_INSTANCE_PIXMAP_BG(i) ((i)->u.pixmap.bg)
579 #define IMAGE_INSTANCE_PIXMAP_AUXDATA(i) ((i)->u.pixmap.auxdata)
580 #define IMAGE_INSTANCE_PIXMAP_MASK(i) ((i)->u.pixmap.mask)
581 #define IMAGE_INSTANCE_PIXMAP_SLICE(i) ((i)->u.pixmap.slice)
582 #define IMAGE_INSTANCE_PIXMAP_MAXSLICE(i) ((i)->u.pixmap.maxslice)
583 #define IMAGE_INSTANCE_PIXMAP_TIMEOUT(i) ((i)->u.pixmap.timeout)
585 #define IMAGE_INSTANCE_SUBWINDOW_WIDTH(i) \
586 IMAGE_INSTANCE_WIDTH(i)
587 #define IMAGE_INSTANCE_SUBWINDOW_HEIGHT(i) \
588 IMAGE_INSTANCE_HEIGHT(i)
589 #define IMAGE_INSTANCE_SUBWINDOW_ID(i) ((i)->u.subwindow.subwindow)
590 #define IMAGE_INSTANCE_SUBWINDOW_FRAME(i) ((i)->u.subwindow.frame)
591 #define IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP(i) \
592 ((i)->u.subwindow.being_displayed)
593 #define IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP(i) \
594 ((i)->u.subwindow.v_resize)
595 #define IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP(i) \
596 ((i)->u.subwindow.h_resize)
597 #define IMAGE_INSTANCE_SUBWINDOW_ORIENT(i) \
598 ((i)->u.subwindow.orientation)
599 #define IMAGE_INSTANCE_SUBWINDOW_JUSTIFY(i) \
600 ((i)->u.subwindow.justification)
602 #define IMAGE_INSTANCE_WIDGET_WIDTH(i) \
603 IMAGE_INSTANCE_WIDTH(i)
604 #define IMAGE_INSTANCE_WIDGET_HEIGHT(i) \
605 IMAGE_INSTANCE_HEIGHT(i)
606 #define IMAGE_INSTANCE_WIDGET_TYPE(i) ((i)->u.subwindow.type)
607 #define IMAGE_INSTANCE_WIDGET_PROPS(i) ((i)->u.subwindow.props)
608 #define SET_IMAGE_INSTANCE_WIDGET_FACE(i,f) \
609 ((i)->u.subwindow.face = f)
610 #define IMAGE_INSTANCE_WIDGET_FACE(i) \
611 (!NILP ((i)->u.subwindow.face) ? (i)->u.subwindow.face : \
612 !NILP (IMAGE_INSTANCE_FACE (i)) ? IMAGE_INSTANCE_FACE (i) : \
614 #define IMAGE_INSTANCE_WIDGET_ITEMS(i) ((i)->u.subwindow.items)
615 #define IMAGE_INSTANCE_WIDGET_ITEM(i) \
616 (CONSP (IMAGE_INSTANCE_WIDGET_ITEMS (i)) ? \
617 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (i)) : \
618 IMAGE_INSTANCE_WIDGET_ITEMS (i))
619 #define IMAGE_INSTANCE_WIDGET_TEXT(i) XGUI_ITEM (IMAGE_INSTANCE_WIDGET_ITEM (i))->name
621 #define IMAGE_INSTANCE_LAYOUT_CHILDREN(i) ((i)->u.subwindow.items)
622 #define IMAGE_INSTANCE_LAYOUT_BORDER(i) ((i)->u.subwindow.props)
624 #define XIMAGE_INSTANCE_DEVICE(i) \
625 IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (i))
626 #define XIMAGE_INSTANCE_NAME(i) \
627 IMAGE_INSTANCE_NAME (XIMAGE_INSTANCE (i))
628 #define XIMAGE_INSTANCE_GLYPH(i) \
629 IMAGE_INSTANCE_GLYPH (XIMAGE_INSTANCE (i))
630 #define XIMAGE_INSTANCE_TYPE(i) \
631 IMAGE_INSTANCE_TYPE (XIMAGE_INSTANCE (i))
632 #define XIMAGE_INSTANCE_XOFFSET(i) \
633 IMAGE_INSTANCE_XOFFSET (XIMAGE_INSTANCE (i))
634 #define XIMAGE_INSTANCE_YOFFSET(i) \
635 IMAGE_INSTANCE_YOFFSET (XIMAGE_INSTANCE (i))
636 #define XIMAGE_INSTANCE_DIRTYP(i) \
637 IMAGE_INSTANCE_DIRTYP (XIMAGE_INSTANCE (i))
638 #define XIMAGE_INSTANCE_WIDTH(i) \
639 IMAGE_INSTANCE_WIDTH (XIMAGE_INSTANCE (i))
640 #define XIMAGE_INSTANCE_HEIGHT(i) \
641 IMAGE_INSTANCE_HEIGHT (XIMAGE_INSTANCE (i))
642 #define XIMAGE_INSTANCE_FACE(i) \
643 IMAGE_INSTANCE_FACE (XIMAGE_INSTANCE (i))
645 #define XIMAGE_INSTANCE_TEXT_STRING(i) \
646 IMAGE_INSTANCE_TEXT_STRING (XIMAGE_INSTANCE (i))
647 #define XIMAGE_INSTANCE_TEXT_WIDTH(i) \
648 IMAGE_INSTANCE_TEXT_WIDTH (XIMAGE_INSTANCE (i))
649 #define XIMAGE_INSTANCE_TEXT_HEIGHT(i) \
650 IMAGE_INSTANCE_TEXT_HEIGHT (XIMAGE_INSTANCE (i))
651 #define XIMAGE_INSTANCE_TEXT_ASCENT(i) \
652 IMAGE_INSTANCE_TEXT_ASCENT (XIMAGE_INSTANCE (i))
653 #define XIMAGE_INSTANCE_TEXT_DESCENT(i) \
654 IMAGE_INSTANCE_TEXT_DESCENT (XIMAGE_INSTANCE (i))
656 #define XIMAGE_INSTANCE_PIXMAP_WIDTH(i) \
657 IMAGE_INSTANCE_PIXMAP_WIDTH (XIMAGE_INSTANCE (i))
658 #define XIMAGE_INSTANCE_PIXMAP_HEIGHT(i) \
659 IMAGE_INSTANCE_PIXMAP_HEIGHT (XIMAGE_INSTANCE (i))
660 #define XIMAGE_INSTANCE_PIXMAP_DEPTH(i) \
661 IMAGE_INSTANCE_PIXMAP_DEPTH (XIMAGE_INSTANCE (i))
662 #define XIMAGE_INSTANCE_PIXMAP_FILENAME(i) \
663 IMAGE_INSTANCE_PIXMAP_FILENAME (XIMAGE_INSTANCE (i))
664 #define XIMAGE_INSTANCE_PIXMAP_MASK_FILENAME(i) \
665 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (XIMAGE_INSTANCE (i))
666 #define XIMAGE_INSTANCE_PIXMAP_HOTSPOT_X(i) \
667 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (XIMAGE_INSTANCE (i))
668 #define XIMAGE_INSTANCE_PIXMAP_HOTSPOT_Y(i) \
669 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (XIMAGE_INSTANCE (i))
670 #define XIMAGE_INSTANCE_PIXMAP_FG(i) \
671 IMAGE_INSTANCE_PIXMAP_FG (XIMAGE_INSTANCE (i))
672 #define XIMAGE_INSTANCE_PIXMAP_BG(i) \
673 IMAGE_INSTANCE_PIXMAP_BG (XIMAGE_INSTANCE (i))
674 #define XIMAGE_INSTANCE_PIXMAP_MASK(i) \
675 IMAGE_INSTANCE_PIXMAP_MASK (XIMAGE_INSTANCE (i))
676 #define XIMAGE_INSTANCE_PIXMAP_SLICE(i) \
677 IMAGE_INSTANCE_PIXMAP_SLICE (XIMAGE_INSTANCE (i))
678 #define XIMAGE_INSTANCE_PIXMAP_MAXSLICE(i) \
679 IMAGE_INSTANCE_PIXMAP_MAXSLICE (XIMAGE_INSTANCE (i))
680 #define XIMAGE_INSTANCE_PIXMAP_TIMEOUT(i) \
681 IMAGE_INSTANCE_PIXMAP_TIMEOUT (XIMAGE_INSTANCE (i))
683 #define XIMAGE_INSTANCE_WIDGET_WIDTH(i) \
684 IMAGE_INSTANCE_WIDGET_WIDTH (XIMAGE_INSTANCE (i))
685 #define XIMAGE_INSTANCE_WIDGET_HEIGHT(i) \
686 IMAGE_INSTANCE_WIDGET_HEIGHT (XIMAGE_INSTANCE (i))
687 #define XIMAGE_INSTANCE_WIDGET_TYPE(i) \
688 IMAGE_INSTANCE_WIDGET_TYPE (XIMAGE_INSTANCE (i))
689 #define XIMAGE_INSTANCE_WIDGET_PROPS(i) \
690 IMAGE_INSTANCE_WIDGET_PROPS (XIMAGE_INSTANCE (i))
691 #define XIMAGE_INSTANCE_WIDGET_FACE(i) \
692 IMAGE_INSTANCE_WIDGET_FACE (XIMAGE_INSTANCE (i))
693 #define XSET_IMAGE_INSTANCE_WIDGET_FACE(i) \
694 SET_IMAGE_INSTANCE_WIDGET_FACE (XIMAGE_INSTANCE (i))
695 #define XIMAGE_INSTANCE_WIDGET_ITEM(i) \
696 IMAGE_INSTANCE_WIDGET_ITEM (XIMAGE_INSTANCE (i))
697 #define XIMAGE_INSTANCE_WIDGET_ITEMS(i) \
698 IMAGE_INSTANCE_WIDGET_ITEMS (XIMAGE_INSTANCE (i))
699 #define XIMAGE_INSTANCE_WIDGET_TEXT(i) \
700 IMAGE_INSTANCE_WIDGET_TEXT (XIMAGE_INSTANCE (i))
702 #define XIMAGE_INSTANCE_LAYOUT_CHILDREN(i) \
703 IMAGE_INSTANCE_LAYOUT_CHILDREN (XIMAGE_INSTANCE (i))
704 #define XIMAGE_INSTANCE_LAYOUT_BORDER(i) \
705 IMAGE_INSTANCE_LAYOUT_BORDER (XIMAGE_INSTANCE (i))
707 #define XIMAGE_INSTANCE_SUBWINDOW_WIDTH(i) \
708 IMAGE_INSTANCE_SUBWINDOW_WIDTH (XIMAGE_INSTANCE (i))
709 #define XIMAGE_INSTANCE_SUBWINDOW_HEIGHT(i) \
710 IMAGE_INSTANCE_SUBWINDOW_HEIGHT (XIMAGE_INSTANCE (i))
711 #define XIMAGE_INSTANCE_SUBWINDOW_ID(i) \
712 IMAGE_INSTANCE_SUBWINDOW_ID (XIMAGE_INSTANCE (i))
713 #define XIMAGE_INSTANCE_SUBWINDOW_FRAME(i) \
714 IMAGE_INSTANCE_SUBWINDOW_FRAME (XIMAGE_INSTANCE (i))
715 #define XIMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP(i) \
716 IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (XIMAGE_INSTANCE (i))
717 #define XIMAGE_INSTANCE_SUBWINDOW_ORIENT(i) \
718 IMAGE_INSTANCE_SUBWINDOW_ORIENT (XIMAGE_INSTANCE (i))
719 #define XIMAGE_INSTANCE_SUBWINDOW_JUSTIFY(i) \
720 IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (XIMAGE_INSTANCE (i))
722 #define MARK_IMAGE_INSTANCE_CHANGED(i) \
723 (IMAGE_INSTANCE_DIRTYP (i) = 1);
726 Lisp_Object evaluate_xpm_color_symbols (void);
727 Lisp_Object pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid);
728 #endif /* HAVE_XPM */
729 #ifdef HAVE_WINDOW_SYSTEM
730 Lisp_Object bitmap_to_lisp_data (Lisp_Object name, int *xhot, int *yhot,
731 int ok_if_data_invalid);
732 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width,
733 unsigned int *height, unsigned char **datap,
734 int *x_hot, int *y_hot);
735 Lisp_Object xbm_mask_file_munging (Lisp_Object alist, Lisp_Object file,
736 Lisp_Object mask_file,
737 Lisp_Object console_type);
740 /************************************************************************/
742 /************************************************************************/
754 struct lcrecord_header header;
756 enum glyph_type type;
759 Lisp_Object image; /* the actual image */
760 Lisp_Object contrib_p; /* whether to figure into line height */
761 Lisp_Object baseline; /* percent above baseline */
763 Lisp_Object face; /* if non-nil, face to use when displaying */
766 void (*after_change) (Lisp_Object glyph, Lisp_Object property,
769 unsigned int dirty : 1; /* So that we can selectively
770 redisplay changed glyphs. */
772 typedef struct Lisp_Glyph Lisp_Glyph;
774 DECLARE_LRECORD (glyph, Lisp_Glyph);
775 #define XGLYPH(x) XRECORD (x, glyph, Lisp_Glyph)
776 #define XSETGLYPH(x, p) XSETRECORD (x, p, glyph)
777 #define GLYPHP(x) RECORDP (x, glyph)
778 #define CHECK_GLYPH(x) CHECK_RECORD (x, glyph)
779 #define CONCHECK_GLYPH(x) CONCHECK_RECORD (x, glyph)
781 #define CHECK_BUFFER_GLYPH(x) do { \
783 if (XGLYPH (x)->type != GLYPH_BUFFER) \
784 x = wrong_type_argument (Qbuffer_glyph_p, (x)); \
787 #define CHECK_POINTER_GLYPH(x) do { \
789 if (XGLYPH (x)->type != GLYPH_POINTER) \
790 x = wrong_type_argument (Qpointer_glyph_p, (x)); \
793 #define CHECK_ICON_GLYPH(x) do { \
795 if (XGLYPH (x)->type != GLYPH_ICON) \
796 x = wrong_type_argument (Qicon_glyph_p, (x)); \
799 #define GLYPH_TYPE(g) ((g)->type)
800 #define GLYPH_IMAGE(g) ((g)->image)
801 #define GLYPH_CONTRIB_P(g) ((g)->contrib_p)
802 #define GLYPH_BASELINE(g) ((g)->baseline)
803 #define GLYPH_FACE(g) ((g)->face)
804 #define GLYPH_DIRTYP(g) ((g)->dirty)
806 #define XGLYPH_TYPE(g) GLYPH_TYPE (XGLYPH (g))
807 #define XGLYPH_IMAGE(g) GLYPH_IMAGE (XGLYPH (g))
808 #define XGLYPH_CONTRIB_P(g) GLYPH_CONTRIB_P (XGLYPH (g))
809 #define XGLYPH_BASELINE(g) GLYPH_BASELINE (XGLYPH (g))
810 #define XGLYPH_FACE(g) GLYPH_FACE (XGLYPH (g))
811 #define XGLYPH_DIRTYP(g) GLYPH_DIRTYP (XGLYPH (g))
813 #define MARK_GLYPH_CHANGED(g) (GLYPH_DIRTYP (g) = 1);
815 extern Lisp_Object Qxpm, Qxface, Qetched_in, Qetched_out, Qbevel_in, Qbevel_out;
816 extern Lisp_Object Q_data, Q_file, Q_color_symbols, Qconst_glyph_variable;
817 extern Lisp_Object Qxbm, Qedit_field, Qgroup, Qlabel, Qcombo_box, Qscrollbar;
818 extern Lisp_Object Qtree_view, Qtab_control, Qprogress_gauge, Q_border;
819 extern Lisp_Object Q_mask_file, Q_mask_data, Q_hotspot_x, Q_hotspot_y;
820 extern Lisp_Object Q_foreground, Q_background, Q_face, Q_descriptor, Q_group;
821 extern Lisp_Object Q_width, Q_height, Q_pixel_width, Q_pixel_height, Q_text;
822 extern Lisp_Object Q_items, Q_properties, Q_image, Q_percent, Qimage_conversion_error;
823 extern Lisp_Object Q_orientation;
824 extern Lisp_Object Vcontinuation_glyph, Vcontrol_arrow_glyph, Vhscroll_glyph;
825 extern Lisp_Object Vinvisible_text_glyph, Voctal_escape_glyph, Vtruncation_glyph;
826 extern Lisp_Object Vxemacs_logo;
828 unsigned short glyph_width (Lisp_Object glyph, Lisp_Object domain);
829 unsigned short glyph_ascent (Lisp_Object glyph, Lisp_Object domain);
830 unsigned short glyph_descent (Lisp_Object glyph, Lisp_Object domain);
831 unsigned short glyph_height (Lisp_Object glyph, Lisp_Object domain);
832 Lisp_Object glyph_baseline (Lisp_Object glyph, Lisp_Object domain);
833 Lisp_Object glyph_face (Lisp_Object glyph, Lisp_Object domain);
834 int glyph_contrib_p (Lisp_Object glyph, Lisp_Object domain);
835 Lisp_Object glyph_image_instance (Lisp_Object glyph,
837 Error_behavior errb, int no_quit);
838 void file_or_data_must_be_present (Lisp_Object instantiator);
839 void data_must_be_present (Lisp_Object instantiator);
840 Lisp_Object make_string_from_file (Lisp_Object file);
841 Lisp_Object tagged_vector_to_alist (Lisp_Object vector);
842 Lisp_Object alist_to_tagged_vector (Lisp_Object tag, Lisp_Object alist);
843 void string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
844 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
845 int dest_mask, Lisp_Object domain);
846 Lisp_Object allocate_glyph (enum glyph_type type,
847 void (*after_change) (Lisp_Object glyph,
848 Lisp_Object property,
849 Lisp_Object locale));
850 void query_string_geometry ( Lisp_Object string, Lisp_Object face,
851 unsigned int* width, unsigned int* height,
852 unsigned int* descent, Lisp_Object domain);
853 Lisp_Object query_string_font (Lisp_Object string,
854 Lisp_Object face, Lisp_Object domain);
855 Lisp_Object add_glyph_animated_timeout (EMACS_INT tickms, Lisp_Object device);
856 void disable_glyph_animated_timeout (int i);
858 /************************************************************************/
860 /************************************************************************/
862 typedef struct glyph_cachel glyph_cachel;
867 unsigned int dirty :1; /* I'm copying faces here. I'm not
868 sure why we need two dirty
869 flags. Maybe because an image
870 instance can be dirty and so we
871 need to frob this in the same way
872 as other image instance properties. */
873 unsigned int updated :1;
875 unsigned short width;
876 unsigned short ascent;
877 unsigned short descent;
880 #define CONT_GLYPH_INDEX (glyph_index) 0
881 #define TRUN_GLYPH_INDEX (glyph_index) 1
882 #define HSCROLL_GLYPH_INDEX (glyph_index) 2
883 #define CONTROL_GLYPH_INDEX (glyph_index) 3
884 #define OCT_ESC_GLYPH_INDEX (glyph_index) 4
885 #define INVIS_GLYPH_INDEX (glyph_index) 5
887 #define GLYPH_CACHEL(window, index) \
888 Dynarr_atp (window->glyph_cachels, index)
889 #define GLYPH_CACHEL_GLYPH(window, index) \
890 Dynarr_atp (window->glyph_cachels, index)->glyph
891 #define GLYPH_CACHEL_WIDTH(window, index) \
892 Dynarr_atp (window->glyph_cachels, index)->width
893 #define GLYPH_CACHEL_ASCENT(window, index) \
894 Dynarr_atp (window->glyph_cachels, index)->ascent
895 #define GLYPH_CACHEL_DESCENT(window, index) \
896 Dynarr_atp (window->glyph_cachels, index)->descent
897 #define GLYPH_CACHEL_DIRTYP(window, index) \
898 Dynarr_atp (window->glyph_cachels, index)->dirty
900 void mark_glyph_cachels (glyph_cachel_dynarr *elements);
901 void mark_glyph_cachels_as_not_updated (struct window *w);
902 void mark_glyph_cachels_as_clean (struct window *w);
903 void reset_glyph_cachels (struct window *w);
904 glyph_index get_glyph_cachel_index (struct window *w, Lisp_Object glyph);
906 #ifdef MEMORY_USAGE_STATS
907 int compute_glyph_cachel_usage (glyph_cachel_dynarr *glyph_cachels,
908 struct overhead_stats *ovstats);
909 #endif /* MEMORY_USAGE_STATS */
911 /************************************************************************/
913 /************************************************************************/
915 Lisp_Object display_table_entry (Emchar, Lisp_Object, Lisp_Object);
916 void get_display_tables (struct window *, face_index,
917 Lisp_Object *, Lisp_Object *);
919 /****************************************************************************
921 ****************************************************************************/
923 /* redisplay needs a per-frame cache of subwindows being displayed so
924 * that we known when to unmap them */
925 typedef struct subwindow_cachel subwindow_cachel;
926 struct subwindow_cachel
928 Lisp_Object subwindow;
930 unsigned int width, height;
931 unsigned int being_displayed : 1;
932 unsigned int updated : 1;
937 Dynarr_declare (subwindow_cachel);
938 } subwindow_cachel_dynarr;
940 void mark_subwindow_cachels (subwindow_cachel_dynarr *elements);
941 void mark_subwindow_cachels_as_not_updated (struct frame *f);
942 void reset_subwindow_cachels (struct frame *f);
943 void unmap_subwindow (Lisp_Object subwindow);
944 void map_subwindow (Lisp_Object subwindow, int x, int y,
945 struct display_glyph_area *dga);
946 void update_frame_subwindows (struct frame *f);
947 int find_matching_subwindow (struct frame* f, int x, int y, int width, int height);
952 unsigned int width, height;
953 struct expose_ignore *next;
956 int check_for_ignored_expose (struct frame* f, int x, int y, int width, int height);
957 extern int hold_ignored_expose_registration;
959 #endif /* INCLUDED_glyphs_h_ */