1 /* internal-gui.h -- common header file for the internal GUI API.
2 Copyright (C) 2003, 2004
3 National Institute of Advanced Industrial Science and Technology (AIST)
4 Registration Number H15PRO112
6 This file is part of the m17n library.
8 The m17n library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public License
10 as published by the Free Software Foundation; either version 2.1 of
11 the License, or (at your option) any later version.
13 The m17n library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the m17n library; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #ifndef _M_INTERNAL_GUI_H
24 #define _M_INTERNAL_GUI_H
28 MDEVICE_SUPPORT_OUTPUT = 1,
29 MDEVICE_SUPPORT_INPUT = 2
32 typedef struct MRealizedFont MRealizedFont;
33 typedef struct MRealizedFace MRealizedFace;
34 typedef struct MRealizedFontset MRealizedFontset;
35 typedef struct MDeviceDriver MDeviceDriver;
37 /** Information about a frame. */
43 MSymbol foreground, background, videomode;
47 /** The default face of the frame. */
50 /** The default realized face of the frame. */
53 /** The default width of one-char space. It is a width of SPACE
54 character of the default face. */
57 /** The default ascent and descent of a line. It is ascent and
58 descent of ASCII font of the default face. */
61 /** Initialized to 0 and incremented on each modification of a face
62 on which one of the realized faces is based. */
65 /** Pointer to device dependent information associated with the
69 /** The following members are set by "device_open" function of a
70 device dependent library. */
72 /** Logical OR of enum MDeviceType. */
75 /** Correction of functions to manipulate the device. */
76 MDeviceDriver *driver;
78 /** List of font drivers. */
79 MPlist *font_driver_list;
81 /** List of realized fonts. */
82 MPlist *realized_font_list;
84 /** List of realized faces. */
85 MPlist *realized_face_list;
87 /** List of realized fontsets. */
88 MPlist *realized_fontset_list;
91 #define M_CHECK_WRITABLE(frame, err, ret) \
93 if (! ((frame)->device_type & MDEVICE_SUPPORT_OUTPUT)) \
94 MERROR ((err), (ret)); \
97 #define M_CHECK_READABLE(frame, err, ret) \
99 if (! ((frame)->device_type & MDEVICE_SUPPORT_INPUT)) \
100 MERROR ((err), (ret)); \
115 GLYPH_CATEGORY_NORMAL,
116 GLYPH_CATEGORY_MODIFIER,
117 GLYPH_CATEGORY_FORMATTER
125 MRealizedFace *rface;
126 short width, ascent, descent, lbearing, rbearing;
128 unsigned enabled : 1;
129 unsigned left_padding : 1;
130 unsigned right_padding : 1;
131 unsigned otf_encoded : 1;
132 unsigned bidi_level : 6;
133 enum glyph_category category : 2;
134 enum glyph_type type : 3;
148 short width, height, ascent, descent;
149 short physical_ascent, physical_descent, lbearing, rbearing;
150 short text_ascent, text_descent, line_ascent, line_descent;
151 int indent, width_limit;
153 /* Copied for <control>.anti_alias but never set if the frame's
154 depth is less than 8. */
155 unsigned anti_alias : 1;
157 MDrawControl control;
159 struct MGlyphString *next, *top;
162 #define MGLYPH(idx) \
163 (gstring->glyphs + ((idx) >= 0 ? (idx) : (gstring->used + (idx))))
165 #define GLYPH_INDEX(g) \
166 ((g) - gstring->glyphs)
168 #define INIT_GLYPH(g) \
169 (memset (&(g), 0, sizeof (g)))
171 #define APPEND_GLYPH(gstring, g) \
172 MLIST_APPEND1 ((gstring), glyphs, (g), MERROR_DRAW)
174 #define INSERT_GLYPH(gstring, at, g) \
176 MLIST_INSERT1 ((gstring), glyphs, (at), 1, MERROR_DRAW); \
177 (gstring)->glyphs[at] = g; \
180 #define DELETE_GLYPH(gstring, at) \
182 MLIST_DELETE1 (gstring, glyphs, at, 1); \
185 #define REPLACE_GLYPHS(gstring, from, to, len) \
187 int newlen = (gstring)->used - (from); \
188 int diff = newlen - (len); \
191 MLIST_DELETE1 (gstring, glyphs, (to) + newlen, -diff); \
193 MLIST_INSERT1 ((gstring), glyphs, (to) + (len), diff, MERROR_DRAW); \
194 memmove ((gstring)->glyphs + to, (gstring)->glyphs + (from + diff), \
195 (sizeof (MGlyph)) * newlen); \
196 (gstring)->used -= newlen; \
199 #define MAKE_COMBINING_CODE(base_y, base_x, add_y, add_x, off_y, off_x) \
207 #define COMBINING_CODE_OFF_Y(code) (((code) >> 16) & 0xFF)
208 #define COMBINING_CODE_OFF_X(code) (((code) >> 8) & 0xFF)
209 #define COMBINING_CODE_BASE_X(code) (((code) >> 6) & 0x3)
210 #define COMBINING_CODE_BASE_Y(code) (((code) >> 4) & 0x3)
211 #define COMBINING_CODE_ADD_X(code) (((code) >> 2) & 0x3)
212 #define COMBINING_CODE_ADD_Y(code) ((code) & 0x3)
214 #define MAKE_COMBINING_CODE_BY_CLASS(class) (0x1000000 | class)
216 #define COMBINING_BY_CLASS_P(code) ((code) & 0x1000000)
218 #define COMBINING_CODE_CLASS(code) ((code) & 0xFFFFFF)
220 #define MAKE_PRECOMPUTED_COMBINDING_CODE() (0x2000000)
222 #define COMBINING_PRECOMPUTED_P(code) ((code) & 0x2000000)
224 typedef struct MGlyphString MGlyphString;
226 typedef struct MFontDriver MFontDriver;
235 void (*close) (MFrame *frame);
236 void *(*get_prop) (MFrame *frame, MSymbol key);
237 void (*realize_face) (MRealizedFace *rface);
238 void (*free_realized_face) (MRealizedFace *rface);
239 void (*fill_space) (MFrame *frame, MDrawWindow win,
240 MRealizedFace *rface, int reverse,
241 int x, int y, int width, int height,
243 void (*draw_empty_boxes) (MDrawWindow win, int x, int y,
244 MGlyphString *gstring,
245 MGlyph *from, MGlyph *to,
246 int reverse, MDrawRegion region);
247 void (*draw_hline) (MFrame *frame, MDrawWindow win,
248 MGlyphString *gstring,
249 MRealizedFace *rface, int reverse,
250 int x, int y, int width, MDrawRegion region);
251 void (*draw_box) (MFrame *frame, MDrawWindow win,
252 MGlyphString *gstring,
253 MGlyph *g, int x, int y, int width,
256 void (*draw_points) (MFrame *frame, MDrawWindow win,
257 MRealizedFace *rface,
258 int intensity, MDrawPoint *points, int num,
260 MDrawRegion (*region_from_rect) (MDrawMetric *rect);
261 void (*union_rect_with_region) (MDrawRegion region, MDrawMetric *rect);
262 void (*intersect_region) (MDrawRegion region1, MDrawRegion region2);
263 void (*region_add_rect) (MDrawRegion region, MDrawMetric *rect);
264 void (*region_to_rect) (MDrawRegion region, MDrawMetric *rect);
265 void (*free_region) (MDrawRegion region);
266 void (*dump_region) (MDrawRegion region);
267 MDrawWindow (*create_window) (MFrame *frame, MDrawWindow parent);
268 void (*destroy_window) (MFrame *frame, MDrawWindow win);
269 void (*map_window) (MFrame *frame, MDrawWindow win);
270 void (*unmap_window) (MFrame *frame, MDrawWindow win);
271 void (*window_geometry) (MFrame *frame, MDrawWindow win,
272 MDrawWindow parent, MDrawMetric *geometry);
273 void (*adjust_window) (MFrame *frame, MDrawWindow win,
274 MDrawMetric *current, MDrawMetric *new);
275 MSymbol (*parse_event) (MFrame *frame, void *arg, int *modifiers);
278 extern MSymbol Mlatin;
282 extern int mfont__init ();
283 extern void mfont__fini ();
285 extern int mface__init ();
286 extern void mface__fini ();
288 extern int mdraw__init ();
289 extern void mdraw__fini ();
291 extern int mfont__fontset_init ();
292 extern void mfont__fontset_fini ();
294 extern int minput__win_init ();
295 extern void minput__win_fini ();
297 #endif /* _M_INTERNAL_GUI_H */