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
26 typedef struct MWDevice MWDevice;
30 typedef struct MRealizedFont MRealizedFont;
31 typedef struct MRealizedFace MRealizedFace;
32 typedef struct MRealizedFontset MRealizedFontset;
34 /** Information about a frame. */
40 /** Pointer to a window-system dependent device object associated
44 MSymbol foreground, background, videomode;
48 /** The default face of the frame. */
51 /** The default realized face of the frame. */
54 /** The default width of one-char space. It is a width of SPACE
55 character of the default face. */
58 /** The default ascent and descent of a line. It is ascent and
59 descent of ASCII font of the default face. */
62 /** The following three members are set by mwin__open_device (). */
64 /** List of realized fonts. */
65 MPlist *realized_font_list;
67 /** List of realized faces. */
68 MPlist *realized_face_list;
70 /** List of realized fontsets. */
71 MPlist *realized_fontset_list;
73 /** Initialized to 0 and incremented on each modification of a face
74 on which one of the realized faces is based. */
95 short width, ascent, descent, lbearing, rbearing;
98 unsigned left_padding : 1;
99 unsigned right_padding : 1;
100 unsigned otf_encoded : 1;
101 unsigned bidi_level : 6;
102 enum glyph_type type : 3;
117 short width, height, ascent, descent;
118 short physical_ascent, physical_descent, lbearing, rbearing;
119 short text_ascent, text_descent, line_ascent, line_descent;
120 int indent, width_limit;
122 /* Members to keep temporary data while layouting. */
123 short sub_width, sub_lbearing, sub_rbearing;
125 /* Copied for <control>.anti_alias but never set if the frame's
126 depth is less than 8. */
127 unsigned anti_alias : 1;
129 MDrawControl control;
133 struct MGlyphString *next, *top;
136 #define MGLYPH(idx) \
137 (gstring->glyphs + ((idx) >= 0 ? (idx) : (gstring->used + (idx))))
139 #define GLYPH_INDEX(g) \
140 ((g) - gstring->glyphs)
142 #define INIT_GLYPH(g) \
143 (memset (&(g), 0, sizeof (g)))
145 #define APPEND_GLYPH(gstring, g) \
146 MLIST_APPEND1 ((gstring), glyphs, (g), MERROR_DRAW)
148 #define INSERT_GLYPH(gstring, at, g) \
150 MLIST_INSERT1 ((gstring), glyphs, (at), 1, MERROR_DRAW); \
151 (gstring)->glyphs[at] = g; \
154 #define DELETE_GLYPH(gstring, at) \
156 MLIST_DELETE1 (gstring, glyphs, at, 1); \
159 #define REPLACE_GLYPHS(gstring, from, to, len) \
161 int newlen = (gstring)->used - (from); \
162 int diff = newlen - (len); \
165 MLIST_DELETE1 (gstring, glyphs, (to) + newlen, -diff); \
167 MLIST_INSERT1 ((gstring), glyphs, (to) + (len), diff, MERROR_DRAW); \
168 memmove ((gstring)->glyphs + to, (gstring)->glyphs + (from + diff), \
169 (sizeof (MGlyph)) * newlen); \
170 (gstring)->used -= newlen; \
173 #define MAKE_COMBINING_CODE(base_y, base_x, add_y, add_x, off_y, off_x) \
181 #define COMBINING_CODE_OFF_Y(code) (((code) >> 16) & 0xFF)
182 #define COMBINING_CODE_OFF_X(code) (((code) >> 8) & 0xFF)
183 #define COMBINING_CODE_BASE_X(code) (((code) >> 6) & 0x3)
184 #define COMBINING_CODE_BASE_Y(code) (((code) >> 4) & 0x3)
185 #define COMBINING_CODE_ADD_X(code) (((code) >> 2) & 0x3)
186 #define COMBINING_CODE_ADD_Y(code) ((code) & 0x3)
188 #define MAKE_COMBINING_CODE_BY_CLASS(class) (0x1000000 | class)
190 #define COMBINING_BY_CLASS_P(code) ((code) & 0x1000000)
192 #define COMBINING_CODE_CLASS(code) ((code) & 0xFFFFFF)
194 typedef struct MGlyphString MGlyphString;
196 typedef struct MFontDriver MFontDriver;
203 extern int mfont__init ();
204 extern void mfont__fini ();
206 extern int mface__init ();
207 extern void mface__fini ();
209 extern int mdraw__init ();
210 extern void mdraw__fini ();
212 extern int mfont__fontset_init ();
213 extern void mfont__fontset_fini ();
215 extern int minput__win_init ();
216 extern void minput__win_fini ();
218 extern int mwin__init ();
219 extern void mwin__fini ();
221 extern MWDevice *mwin__open_device (MFrame *frame, MPlist *plist);
223 extern void mwin__close_device (MFrame *frame);
225 extern void *mwin__device_get_prop (MWDevice *device, MSymbol key);
227 extern int mwin__parse_font_name (char *name, MFont *font);
229 extern char *mwin__build_font_name (MFont *font);
231 extern void mwin__realize_face (MRealizedFace *rface);
233 extern void mwin__free_realized_face (MRealizedFace *rface);
235 extern void mwin__fill_space (MFrame *frame, MDrawWindow win,
236 MRealizedFace *rface, int reverse,
237 int x, int y, int width, int height,
240 extern void mwin__draw_rect (MFrame *frame, MDrawWindow win,
242 int x, int y, int width, int height,
245 extern void mwin__draw_empty_boxes (MDrawWindow win, int x, int y,
246 MGlyphString *gstring,
247 MGlyph *from, MGlyph *to,
248 int reverse, MDrawRegion region);
250 extern void mwin__draw_hline (MFrame *frame, MDrawWindow win,
251 MGlyphString *gstring,
252 MRealizedFace *rface, int reverse,
253 int x, int y, int width, MDrawRegion region);
255 extern void mwin__draw_box (MFrame *frame, MDrawWindow win,
256 MGlyphString *gstring,
257 MGlyph *g, int x, int y, int width,
260 extern void mwin__draw_points (MFrame *frame, MDrawWindow win,
261 MRealizedFace *rface,
262 int intensity, MDrawPoint *points, int num,
265 extern MDrawRegion mwin__region_from_rect (MDrawMetric *rect);
267 extern void mwin__union_rect_with_region (MDrawRegion region,
270 extern void mwin__intersect_region (MDrawRegion region1, MDrawRegion region2);
272 extern void mwin__region_add_rect (MDrawRegion region, MDrawMetric *rect);
274 extern void mwin__region_to_rect (MDrawRegion region, MDrawMetric *rect);
276 extern void mwin__free_region (MDrawRegion region);
278 extern void mwin__verify_region (MFrame *frame, MDrawRegion region);
280 extern void mwin__dump_region (MDrawRegion region);
282 extern MDrawWindow mwin__create_window (MFrame *frame, MDrawWindow parent);
284 extern void mwin__destroy_window (MFrame *frame, MDrawWindow win);
287 extern MDrawWindow mwin__event_window (void *event);
289 extern void mwin__print_event (void *event, char *win_name);
292 extern void mwin__map_window (MFrame *frame, MDrawWindow win);
294 extern void mwin__unmap_window (MFrame *frame, MDrawWindow win);
296 extern void mwin__window_geometry (MFrame *frame, MDrawWindow win,
297 MDrawWindow parent, MDrawMetric *geometry);
299 extern void mwin__adjust_window (MFrame *frame, MDrawWindow win,
300 MDrawMetric *current, MDrawMetric *new);
302 extern MSymbol mwin__parse_event (MFrame *frame, void *arg, int *modifiers);
304 #endif /* _M_INTERNAL_GUI_H */