Initial git import
[sxemacs] / src / ui / X11 / glyphs-x.h
1 /* X-specific glyphs and related.
2    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3    Copyright (C) 1995 Board of Trustees, University of Illinois.
4    Copyright (C) 1995, 1996 Ben Wing
5    Copyright (C) 1995 Sun Microsystems, Inc.
6
7 This file is part of SXEmacs
8
9 SXEmacs is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 SXEmacs is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
21
22
23 /* Synched up with:  Not in FSF. */
24
25 #ifndef INCLUDED_glyphs_x_h_
26 #define INCLUDED_glyphs_x_h_
27
28 #include "ui/glyphs.h"
29
30 #ifdef HAVE_X_WINDOWS
31
32 #include "xintrinsic.h"
33 #include "ui/lwlib/lwlib.h"
34 #include "ui/lwlib/lwlib-utils.h"
35
36 /****************************************************************************
37  *                         Image-Instance Object                            *
38  ****************************************************************************/
39
40 struct x_image_instance_data {
41         Pixmap *pixmaps;
42         Cursor cursor;
43
44         /* If depth>0, then that means that other colors were allocated when
45            this pixmap was loaded.  These are they; we need to free them when
46            finalizing the image instance. */
47         Colormap colormap;
48         unsigned long *pixels;
49         int npixels;
50
51         /* Should we hang on to the extra info from the XpmAttributes, like
52            the textual color table and the comments?   Is that useful? */
53 };
54
55 #define X_IMAGE_INSTANCE_DATA(i) ((struct x_image_instance_data *) (i)->data)
56
57 #define IMAGE_INSTANCE_X_PIXMAP(i) (X_IMAGE_INSTANCE_DATA (i)->pixmaps[0])
58 #define IMAGE_INSTANCE_X_PIXMAP_SLICE(i,slice) \
59      (X_IMAGE_INSTANCE_DATA (i)->pixmaps[slice])
60 #define IMAGE_INSTANCE_X_PIXMAP_SLICES(i) \
61      (X_IMAGE_INSTANCE_DATA (i)->pixmaps)
62 #define IMAGE_INSTANCE_X_MASK(i) \
63         (Pixmap)(IMAGE_INSTANCE_PIXMAP_MASK (i))
64 #define IMAGE_INSTANCE_X_CURSOR(i) (X_IMAGE_INSTANCE_DATA (i)->cursor)
65 #define IMAGE_INSTANCE_X_COLORMAP(i) (X_IMAGE_INSTANCE_DATA (i)->colormap)
66 #define IMAGE_INSTANCE_X_PIXELS(i) (X_IMAGE_INSTANCE_DATA (i)->pixels)
67 #define IMAGE_INSTANCE_X_NPIXELS(i) (X_IMAGE_INSTANCE_DATA (i)->npixels)
68
69 #define XIMAGE_INSTANCE_X_PIXMAP(i) \
70   IMAGE_INSTANCE_X_PIXMAP (XIMAGE_INSTANCE (i))
71 #define XIMAGE_INSTANCE_X_PIXMAP_SLICES(i) \
72   IMAGE_INSTANCE_X_PIXMAP_SLICES (XIMAGE_INSTANCE (i))
73 #define XIMAGE_INSTANCE_X_PIXMAP_SLICE(i) \
74   IMAGE_INSTANCE_X_PIXMAP_SLICE (XIMAGE_INSTANCE (i))
75 #define XIMAGE_INSTANCE_X_MASK(i) \
76   IMAGE_INSTANCE_X_MASK (XIMAGE_INSTANCE (i))
77 #define XIMAGE_INSTANCE_X_CURSOR(i) \
78   IMAGE_INSTANCE_X_CURSOR (XIMAGE_INSTANCE (i))
79 #define XIMAGE_INSTANCE_X_PIXELS(i) \
80   IMAGE_INSTANCE_X_PIXELS (XIMAGE_INSTANCE (i))
81 #define XIMAGE_INSTANCE_X_NPIXELS(i) \
82   IMAGE_INSTANCE_X_NPIXELS (XIMAGE_INSTANCE (i))
83
84 /****************************************************************************
85  *                            Subwindow Object                              *
86  ****************************************************************************/
87
88 struct x_subwindow_data {
89         union {
90                 struct {
91                         Display *display;
92                         Window parent_window;
93                         Window clip_window;
94                 } sub;
95                 struct {
96                         Widget clip_window;
97                         Position x_offset;
98                         Position y_offset;
99                         LWLIB_ID id;
100                 } wid;
101         } data;
102 };
103
104 #define X_SUBWINDOW_INSTANCE_DATA(i) ((struct x_subwindow_data *) (i)->data)
105
106 #define IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY(i) \
107   (X_SUBWINDOW_INSTANCE_DATA (i)->data.sub.display)
108 #define IMAGE_INSTANCE_X_SUBWINDOW_PARENT(i) \
109   (X_SUBWINDOW_INSTANCE_DATA (i)->data.sub.parent_window)
110 #define IMAGE_INSTANCE_X_CLIPWINDOW(i) \
111   (X_SUBWINDOW_INSTANCE_DATA (i)->data.sub.clip_window)
112 #define IMAGE_INSTANCE_X_WIDGET_XOFFSET(i) \
113   (X_SUBWINDOW_INSTANCE_DATA (i)->data.wid.x_offset)
114 #define IMAGE_INSTANCE_X_WIDGET_YOFFSET(i) \
115   (X_SUBWINDOW_INSTANCE_DATA (i)->data.wid.y_offset)
116 #define IMAGE_INSTANCE_X_WIDGET_LWID(i) \
117   (X_SUBWINDOW_INSTANCE_DATA (i)->data.wid.id)
118 #define IMAGE_INSTANCE_X_CLIPWIDGET(i) \
119   (X_SUBWINDOW_INSTANCE_DATA (i)->data.wid.clip_window)
120 #define IMAGE_INSTANCE_X_SUBWINDOW_ID(i) \
121         (*(Window*)((void*)&IMAGE_INSTANCE_SUBWINDOW_ID(i)))
122 #define IMAGE_INSTANCE_X_WIDGET_ID(i) \
123         (*(Widget*)((void*)&IMAGE_INSTANCE_SUBWINDOW_ID(i)))
124
125 #define XIMAGE_INSTANCE_X_SUBWINDOW_PARENT(i) \
126   IMAGE_INSTANCE_X_SUBWINDOW_PARENT (XIMAGE_INSTANCE (i))
127 #define XIMAGE_INSTANCE_X_SUBWINDOW_DISPLAY(i) \
128   IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (XIMAGE_INSTANCE (i))
129 #define XIMAGE_INSTANCE_X_WIDGET_XOFFSET(i) \
130   IMAGE_INSTANCE_X_WIDGET_XOFFSET (XIMAGE_INSTANCE (i))
131 #define XIMAGE_INSTANCE_X_WIDGET_YOFFSET(i) \
132   IMAGE_INSTANCE_X_WIDGET_YOFFSET (XIMAGE_INSTANCE (i))
133 #define XIMAGE_INSTANCE_X_WIDGET_LWID(i) \
134   IMAGE_INSTANCE_X_WIDGET_LWID (XIMAGE_INSTANCE (i))
135 #define XIMAGE_INSTANCE_X_CLIPWIDGET(i) \
136   IMAGE_INSTANCE_X_CLIPWIDGET (XIMAGE_INSTANCE (i))
137 #define XIMAGE_INSTANCE_X_CLIPWINDOW(i) \
138   IMAGE_INSTANCE_X_CLIPWINDOW (XIMAGE_INSTANCE (i))
139 #define XIMAGE_INSTANCE_X_WIDGET_ID(i) \
140   IMAGE_INSTANCE_X_WIDGET_ID (XIMAGE_INSTANCE (i))
141
142 #define DOMAIN_X_WIDGET(domain) \
143   ((IMAGE_INSTANCEP (domain) && \
144   X_SUBWINDOW_INSTANCE_DATA (XIMAGE_INSTANCE (domain))) ? \
145    XIMAGE_INSTANCE_X_WIDGET_ID (domain) : \
146    FRAME_X_CONTAINER_WIDGET (f) (DOMAIN_XFRAME (domain)))
147
148 #endif                          /* HAVE_X_WINDOWS */
149 #endif                          /* INCLUDED_glyphs_x_h_ */