1 /* internal-gui.h -- common header file for the internal GUI API.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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., 51 Franklin Street, Fifth Floor,
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. */
59 /** The default ascent and descent of a line. It is ascent and
60 descent of ASCII font of the default face. */
63 /** Initialized to 0 and incremented on each modification of a face
64 on which one of the realized faces is based. */
67 /** Pointer to device dependent information associated with the
71 /** The following members are set by "device_open" function of a
72 device dependent library. */
74 /** Logical OR of enum MDeviceType. */
77 /** Resolution (dots per inch) of the device. */
80 /** Correction of functions to manipulate the device. */
81 MDeviceDriver *driver;
83 /** List of font drivers. */
84 MPlist *font_driver_list;
86 /** List of realized fonts. */
87 MPlist *realized_font_list;
89 /** List of realized faces. */
90 MPlist *realized_face_list;
92 /** List of realized fontsets. */
93 MPlist *realized_fontset_list;
96 #define M_CHECK_WRITABLE(frame, err, ret) \
98 if (! ((frame)->device_type & MDEVICE_SUPPORT_OUTPUT)) \
99 MERROR ((err), (ret)); \
102 #define M_CHECK_READABLE(frame, err, ret) \
104 if (! ((frame)->device_type & MDEVICE_SUPPORT_INPUT)) \
105 MERROR ((err), (ret)); \
120 GLYPH_CATEGORY_NORMAL,
121 GLYPH_CATEGORY_MODIFIER,
122 GLYPH_CATEGORY_FORMATTER
128 MRealizedFace *rface;
129 unsigned left_padding : 1;
130 unsigned right_padding : 1;
131 unsigned enabled : 1;
132 unsigned bidi_level : 6;
133 unsigned category : 2;
147 short width, height, ascent, descent;
148 short physical_ascent, physical_descent, lbearing, rbearing;
149 short text_ascent, text_descent, line_ascent, line_descent;
150 int indent, width_limit;
152 /* Copied for <control>.anti_alias but never set if the frame's
153 depth is less than 8. */
154 unsigned anti_alias : 1;
156 MDrawControl control;
158 struct MGlyphString *next, *top;
161 #define MGLYPH(idx) \
162 (gstring->glyphs + ((idx) >= 0 ? (idx) : (gstring->used + (idx))))
164 #define GLYPH_INDEX(g) \
165 ((g) - gstring->glyphs)
167 #define INIT_GLYPH(g) \
168 (memset (&(g), 0, sizeof (g)))
170 #define APPEND_GLYPH(gstring, g) \
171 MLIST_APPEND1 ((gstring), glyphs, (g), MERROR_DRAW)
173 #define INSERT_GLYPH(gstring, at, g) \
175 MLIST_INSERT1 ((gstring), glyphs, (at), 1, MERROR_DRAW); \
176 (gstring)->glyphs[at] = g; \
179 #define DELETE_GLYPH(gstring, at) \
181 MLIST_DELETE1 (gstring, glyphs, at, 1); \
184 #define REPLACE_GLYPHS(gstring, from, to, len) \
186 int newlen = (gstring)->used - (from); \
187 int diff = newlen - (len); \
190 MLIST_DELETE1 (gstring, glyphs, (to) + newlen, -diff); \
192 MLIST_INSERT1 ((gstring), glyphs, (to) + (len), diff, MERROR_DRAW); \
193 memmove ((gstring)->glyphs + to, (gstring)->glyphs + (from + diff), \
194 (sizeof (MGlyph)) * newlen); \
195 (gstring)->used -= newlen; \
198 typedef struct MGlyphString MGlyphString;
207 void (*close) (MFrame *frame);
208 void *(*get_prop) (MFrame *frame, MSymbol key);
209 void (*realize_face) (MRealizedFace *rface);
210 void (*free_realized_face) (MRealizedFace *rface);
211 void (*fill_space) (MFrame *frame, MDrawWindow win,
212 MRealizedFace *rface, int reverse,
213 int x, int y, int width, int height,
215 void (*draw_empty_boxes) (MDrawWindow win, int x, int y,
216 MGlyphString *gstring,
217 MGlyph *from, MGlyph *to,
218 int reverse, MDrawRegion region);
219 void (*draw_hline) (MFrame *frame, MDrawWindow win,
220 MGlyphString *gstring,
221 MRealizedFace *rface, int reverse,
222 int x, int y, int width, MDrawRegion region);
223 void (*draw_box) (MFrame *frame, MDrawWindow win,
224 MGlyphString *gstring,
225 MGlyph *g, int x, int y, int width,
228 void (*draw_points) (MFrame *frame, MDrawWindow win,
229 MRealizedFace *rface,
230 int intensity, MDrawPoint *points, int num,
232 MDrawRegion (*region_from_rect) (MDrawMetric *rect);
233 void (*union_rect_with_region) (MDrawRegion region, MDrawMetric *rect);
234 void (*intersect_region) (MDrawRegion region1, MDrawRegion region2);
235 void (*region_add_rect) (MDrawRegion region, MDrawMetric *rect);
236 void (*region_to_rect) (MDrawRegion region, MDrawMetric *rect);
237 void (*free_region) (MDrawRegion region);
238 void (*dump_region) (MDrawRegion region);
239 MDrawWindow (*create_window) (MFrame *frame, MDrawWindow parent);
240 void (*destroy_window) (MFrame *frame, MDrawWindow win);
241 void (*map_window) (MFrame *frame, MDrawWindow win);
242 void (*unmap_window) (MFrame *frame, MDrawWindow win);
243 void (*window_geometry) (MFrame *frame, MDrawWindow win,
244 MDrawWindow parent, MDrawMetric *geometry);
245 void (*adjust_window) (MFrame *frame, MDrawWindow win,
246 MDrawMetric *current, MDrawMetric *new);
247 MSymbol (*parse_event) (MFrame *frame, void *arg, int *modifiers);
250 extern MSymbol Mlatin;
254 extern int mfont__init ();
255 extern void mfont__fini ();
257 extern int mface__init ();
258 extern void mface__fini ();
260 extern int mdraw__init ();
261 extern void mdraw__fini ();
263 extern int mfont__fontset_init ();
264 extern void mfont__fontset_fini ();
266 extern int minput__win_init ();
267 extern void minput__win_fini ();
269 #endif /* _M_INTERNAL_GUI_H */