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;
91 short width, ascent, descent, lbearing, rbearing;
94 unsigned left_padding : 1;
95 unsigned right_padding : 1;
96 unsigned otf_encoded : 1;
97 unsigned bidi_level : 6;
98 enum glyph_type type : 3;
110 short width, height, ascent, descent;
111 short physical_ascent, physical_descent, lbearing, rbearing;
112 short text_ascent, text_descent, line_ascent, line_descent;
113 int indent, width_limit;
115 /* Members to keep temporary data while layouting. */
116 short sub_width, sub_lbearing, sub_rbearing;
118 /* Copied for <control>.anti_alias but never set if the frame's
119 depth is less than 8. */
120 unsigned anti_alias : 1;
122 MDrawControl control;
126 struct MGlyphString *next, *top;
129 #define MGLYPH(idx) \
130 (gstring->glyphs + ((idx) >= 0 ? (idx) : (gstring->used + (idx))))
132 #define GLYPH_INDEX(g) \
133 ((g) - gstring->glyphs)
135 #define INIT_GLYPH(g) \
136 (memset (&(g), 0, sizeof (g)))
138 #define APPEND_GLYPH(gstring, g) \
139 MLIST_APPEND1 ((gstring), glyphs, (g), MERROR_DRAW)
141 #define INSERT_GLYPH(gstring, at, g) \
143 MLIST_INSERT1 ((gstring), glyphs, (at), 1, MERROR_DRAW); \
144 (gstring)->glyphs[at] = g; \
147 #define DELETE_GLYPH(gstring, at) \
149 MLIST_DELETE1 (gstring, glyphs, at, 1); \
152 #define REPLACE_GLYPHS(gstring, from, to, len) \
154 int newlen = (gstring)->used - (from); \
155 int diff = newlen - (len); \
158 MLIST_DELETE1 (gstring, glyphs, (to) + newlen, -diff); \
160 MLIST_INSERT1 ((gstring), glyphs, (to) + (len), diff, MERROR_DRAW); \
161 memmove ((gstring)->glyphs + to, (gstring)->glyphs + (from + diff), \
162 (sizeof (MGlyph)) * newlen); \
163 (gstring)->used -= newlen; \
166 #define MAKE_COMBINING_CODE(base_y, base_x, add_y, add_x, off_y, off_x) \
174 #define COMBINING_CODE_OFF_Y(code) (((code) >> 16) & 0xFF)
175 #define COMBINING_CODE_OFF_X(code) (((code) >> 8) & 0xFF)
176 #define COMBINING_CODE_BASE_X(code) (((code) >> 6) & 0x3)
177 #define COMBINING_CODE_BASE_Y(code) (((code) >> 4) & 0x3)
178 #define COMBINING_CODE_ADD_X(code) (((code) >> 2) & 0x3)
179 #define COMBINING_CODE_ADD_Y(code) ((code) & 0x3)
181 #define MAKE_COMBINING_CODE_BY_CLASS(class) (0x1000000 | class)
183 #define COMBINING_BY_CLASS_P(code) ((code) & 0x1000000)
185 #define COMBINING_CODE_CLASS(code) ((code) & 0xFFFFFF)
187 typedef struct MGlyphString MGlyphString;
189 typedef struct MFontDriver MFontDriver;
196 extern int mfont__init ();
197 extern void mfont__fini ();
199 extern int mface__init ();
200 extern void mface__fini ();
202 extern int mdraw__init ();
203 extern void mdraw__fini ();
205 extern int mfont__fontset_init ();
206 extern void mfont__fontset_fini ();
208 extern int minput__win_init ();
209 extern void minput__win_fini ();
211 extern int mwin__init ();
212 extern void mwin__fini ();
214 extern MWDevice *mwin__open_device (MFrame *frame, MPlist *plist);
216 extern void mwin__close_device (MFrame *frame);
218 extern void *mwin__device_get_prop (MWDevice *device, MSymbol key);
220 extern int mwin__parse_font_name (char *name, MFont *font);
222 extern char *mwin__build_font_name (MFont *font);
224 extern void mwin__realize_face (MRealizedFace *rface);
226 extern void mwin__free_realized_face (MRealizedFace *rface);
228 extern void mwin__fill_space (MFrame *frame, MDrawWindow win,
229 MRealizedFace *rface, int reverse,
230 int x, int y, int width, int height,
233 extern void mwin__draw_hline (MFrame *frame, MDrawWindow win,
234 MGlyphString *gstring,
235 MRealizedFace *rface, int reverse,
236 int x, int y, int width, MDrawRegion region);
238 extern void mwin__draw_box (MFrame *frame, MDrawWindow win,
239 MGlyphString *gstring,
240 MGlyph *g, int x, int y, int width,
243 extern void mwin__draw_points (MFrame *frame, MDrawWindow win,
244 MRealizedFace *rface,
245 int intensity, MDrawPoint *points, int num,
248 extern MDrawRegion mwin__region_from_rect (MDrawMetric *rect);
250 extern void mwin__union_rect_with_region (MDrawRegion region,
253 extern void mwin__intersect_region (MDrawRegion region1, MDrawRegion region2);
255 extern void mwin__region_add_rect (MDrawRegion region, MDrawMetric *rect);
257 extern void mwin__region_to_rect (MDrawRegion region, MDrawMetric *rect);
259 extern void mwin__free_region (MDrawRegion region);
261 extern void mwin__verify_region (MFrame *frame, MDrawRegion region);
263 extern void mwin__dump_region (MDrawRegion region);
265 extern MDrawWindow mwin__create_window (MFrame *frame, MDrawWindow parent);
267 extern void mwin__destroy_window (MFrame *frame, MDrawWindow win);
270 extern MDrawWindow mwin__event_window (void *event);
272 extern void mwin__print_event (void *event, char *win_name);
275 extern void mwin__map_window (MFrame *frame, MDrawWindow win);
277 extern void mwin__unmap_window (MFrame *frame, MDrawWindow win);
279 extern void mwin__window_geometry (MFrame *frame, MDrawWindow win,
280 MDrawWindow parent, MDrawMetric *geometry);
282 extern void mwin__adjust_window (MFrame *frame, MDrawWindow win,
283 MDrawMetric *current, MDrawMetric *new);
285 extern MSymbol mwin__parse_event (MFrame *frame, void *arg, int *modifiers);
287 #endif /* _M_INTERNAL_GUI_H */