1 /* m17n-gui.c -- body of the GUI API.
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
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,
25 @brief GUI support for a window system.
27 This section defines the m17n GUI API concerning M-text drawing
28 and inputting under a window system.
30 All the definitions here are independent of window systems. An
31 actual library file, however, can depend on a specific window
32 system. For instance, the library file m17n-X.so is an example of
33 implementation of the m17n GUI API for the X Window System.
35 Actually the GUI API is mainly for toolkit libraries or to
36 implement XOM, not for direct use from application programs.
41 @brief ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤Î GUI ¥µ¥Ý¡¼¥È.
43 ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Î¤â¤È¤Ç¤Î M-text ¤Îɽ¼¨¤ÈÆþÎϤˤ«¤«¤ï¤ë
44 m17n GUI API ¤òÄêµÁ¤¹¤ë¡£
46 ¤³¤³¤Ç¤Î¤¹¤Ù¤Æ¤ÎÄêµÁ¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤È¤ÏÆÈΩ¤Ç¤¢¤ë¡£
47 ¤·¤«¤·¡¢¼ÂºÝ¤Î¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤Ï¸ÄÊ̤Υ¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¾ì¹ç¤¬¤¢¤ë¡£
48 ¤¿¤È¤¨¤Ð¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë m17n-X.so ¤Ï¡¢m17n GUI API ¤Î X
49 ¥¦¥£¥ó¥É¥¦ÍѤμÂÁõÎã¤Ç¤¢¤ë¡£
51 ¸½¼Â¤Ë¤Ï¡¢GUI API ¤Ï¼ç¤Ë¥Ä¡¼¥ë¥¥Ã¥È¥é¥¤¥Ö¥é¥ê¸þ¤±¤Ç¤¢¤ë¤«¡¢¤Þ¤¿¤Ï
52 XOM ¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤Æ¤ª¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤ÎľÀܤÎÍøÍѤòǰƬ¤Ë¤ª¤¤¤¿¤â¤Î¤Ç¤Ï¤Ê¤¤¡£
57 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
58 /*** @addtogroup m17nInternal
73 #include "m17n-misc.h"
76 #include "internal-gui.h"
81 #ifndef DLOPEN_SHLIB_EXT
82 #define DLOPEN_SHLIB_EXT ".so"
85 /** Information about a dynamic library supporting a specific graphic
89 /** Name of the dynamic library (e.g. "libm17n-X.so"). */
91 /** Handle of the dynamic library. */
93 /** Function to call just after loading the library. */
95 /** Function to call to open a frame on the graphic device. */
96 int (*open) (MFrame *frame, MPlist *param);
97 /** Function to call just before unloading the library. */
99 } MDeviceLibraryInterface;
102 /** Plist of device symbol vs MDeviceLibraryInterface. */
104 static MPlist *device_library_list;
106 /** Close MFrame and free it. */
109 free_frame (void *object)
111 MFrame *frame = (MFrame *) object;
113 (*frame->driver->close) (frame);
114 M17N_OBJECT_UNREF (frame->face);
115 M17N_OBJECT_UNREF (frame->font_driver_list);
120 /** Register a dynamic library of name LIB by a key NAME. */
123 register_device_library (MSymbol name, char *lib)
125 MDeviceLibraryInterface *interface;
127 MSTRUCT_CALLOC (interface, MERROR_WIN);
128 interface->library = malloc (strlen (M17N_MODULE_DIR) + 1
130 + strlen (DLOPEN_SHLIB_EXT) + 1);
131 sprintf (interface->library, "%s/%s%s", M17N_MODULE_DIR, lib,
133 if (! device_library_list)
134 device_library_list = mplist ();
135 mplist_add (device_library_list, name, interface);
141 /** Null device support. */
144 MPlist *realized_fontset_list;
145 MPlist *realized_font_list;
146 MPlist *realized_face_list;
150 null_device_close (MFrame *frame)
155 null_device_get_prop (MFrame *frame, MSymbol key)
161 null_device_realize_face (MRealizedFace *rface)
167 null_device_free_realized_face (MRealizedFace *rface)
171 static MDeviceDriver null_driver =
174 null_device_get_prop,
175 null_device_realize_face,
176 null_device_free_realized_face
182 null_device.realized_fontset_list = mplist ();
183 null_device.realized_font_list = mplist ();
184 null_device.realized_face_list = mplist ();
193 MPLIST_DO (plist, null_device.realized_fontset_list)
194 mfont__free_realized_fontset ((MRealizedFontset *) MPLIST_VAL (plist));
195 M17N_OBJECT_UNREF (null_device.realized_fontset_list);
197 MPLIST_DO (plist, null_device.realized_face_list)
198 mface__free_realized ((MRealizedFace *) MPLIST_VAL (plist));
199 M17N_OBJECT_UNREF (null_device.realized_face_list);
201 if (MPLIST_VAL (null_device.realized_font_list))
202 mfont__free_realized (MPLIST_VAL (null_device.realized_font_list));
203 M17N_OBJECT_UNREF (null_device.realized_font_list);
208 null_device_open (MFrame *frame, MPlist *param)
212 frame->device = NULL;
213 frame->device_type = 0;
214 frame->dpi = (int) mplist_get (param, Mresolution);
217 frame->driver = &null_driver;
218 frame->font_driver_list = mplist ();
219 mplist_add (frame->font_driver_list, Mfreetype, &mfont__ft_driver);
220 frame->realized_font_list = null_device.realized_font_list;
221 frame->realized_face_list = null_device.realized_face_list;
222 frame->realized_fontset_list = null_device.realized_fontset_list;
223 face = mface_copy (mface__default);
224 mplist_push (param, Mface, face);
225 M17N_OBJECT_UNREF (face);
229 static MDeviceLibraryInterface null_interface =
230 { NULL, NULL, null_device_init, null_device_open, null_device_fini };
242 int mdebug_flag = MDEBUG_INIT;
244 merror_code = MERROR_NONE;
245 if (m17n__gui_initialized++)
249 if (merror_code != MERROR_NONE)
251 m17n__gui_initialized--;
257 Mgd = msymbol ("gd");
259 Mfont = msymbol ("font");
260 Mfont_width = msymbol ("font-width");
261 Mfont_ascent = msymbol ("font-ascent");
262 Mfont_descent = msymbol ("font-descent");
263 Mdevice = msymbol ("device");
265 Mdisplay = msymbol ("display");
266 Mscreen = msymbol ("screen");
267 Mdrawable = msymbol ("drawable");
268 Mdepth = msymbol ("depth");
269 Mwidget = msymbol ("widget");
270 Mcolormap = msymbol ("colormap");
273 if (mfont__init () < 0)
275 MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize font module."));
276 if (mfont__fontset_init () < 0)
278 MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize fontset module."));
279 if (mface__init () < 0)
281 MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize face module."));
282 if (mdraw__init () < 0)
284 MDEBUG_PRINT_TIME ("INIT", (mdebug__output, " to initialize draw module."));
285 if (minput__win_init () < 0)
287 MDEBUG_PRINT_TIME ("INIT",
288 (mdebug__output, " to initialize input-win module."));
289 mframe_default = NULL;
291 register_device_library (Mx, "libm17n-X");
292 register_device_library (Mgd, "libm17n-gd");
297 MDEBUG_PRINT_TIME ("INIT",
298 (mdebug__output, " to initialize the m17n GUI module."));
305 int mdebug_flag = MDEBUG_FINI;
308 if (m17n__gui_initialized == 0
309 || --m17n__gui_initialized > 0)
314 MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize device modules."));
315 MPLIST_DO (plist, device_library_list)
317 MDeviceLibraryInterface *interface = MPLIST_VAL (plist);
319 if (interface->handle && interface->fini)
321 (*interface->fini) ();
322 dlclose (interface->handle);
324 free (interface->library);
328 if (null_interface.handle)
330 (*null_interface.fini) ();
331 null_interface.handle = NULL;
333 #endif /* not HAVE_FREETYPE */
334 M17N_OBJECT_UNREF (device_library_list);
336 MDEBUG_PRINT_TIME ("FINI",
337 (mdebug__output, " to finalize input-gui module."));
339 MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize draw module."));
341 MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize face module."));
342 mfont__fontset_fini ();
343 MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize fontset module."));
345 MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize font module."));
346 mframe_default = NULL;
348 MDEBUG_PRINT_TIME ("FINI", (mdebug__output, " to finalize the gui modules."));
355 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
357 /*** @addtogroup m17nFrame */
359 @brief A @e frame is an object corresponding to the graphic device.
361 A @e frame is an object of the type #MFrame to hold various
362 information about each display/input device. Almost all m17n GUI
363 functions require a pointer to a frame as an argument. */
365 @brief @e ¥Õ¥ì¡¼¥à ¤È¤Ï¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð¥¤¥¹¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë.
367 @e ¥Õ¥ì¡¼¥à ¤È¤Ï #MFrame
368 ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢¸Ä¡¹¤Îɽ¼¨¡¿ÆþÎϥǥХ¤¥¹¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
369 ¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î m17n GUI´Ø¿ô¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÍ׵᤹¤ë¡£ */
375 @name Variables: Keys of frame parameter
377 These are the symbols to use in a parameter to create a frame. See
378 the function mframe () for details.
380 @b Mdevice, @b Mdisplay, @b Mscreen, @b Mdrawable, @b Mdepth, and
381 @b Mcolormap are also keys of a frame property. */
384 @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥Ñ¥é¥á¡¼¥¿ÍÑ¥¡¼
386 ¥Õ¥ì¡¼¥à¤òÀ¸À®¤¹¤ëºÝ¤Î¥Ñ¥é¥á¡¼¥¿¤ËÍѤ¤¤ë¥·¥ó¥Ü¥ë¡£¾Ü¤·¤¯¤Ï´Ø¿ô
387 mframe () ¤ÎÀâÌÀ»²¾È¡£
389 @b Mdevice¡¢ @b Mdisplay¡¢ @b Mscreen¡¢ @b Mdrawable¡¢ @b Mdepth¡¢
390 @b Mcolormap ¤Ï¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤Ç¤â¤¢¤ë¡£ */
394 MSymbol Mdevice, Mdisplay, Mscreen, Mdrawable, Mdepth, Mcolormap, Mwidget;
401 @name Variables: Keys of frame property
403 These are the symbols to use as an argument to the function
404 mframe_get_prop (). */
406 @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼
408 ´Ø¿ô mframe_get_prop () ¤Î°ú¿ô¤ËÍѤ¤¤é¤ì¤ë¥·¥ó¥Ü¥ë¡£ */
413 MSymbol Mfont_ascent;
414 MSymbol Mfont_descent;
422 @brief Create a new frame.
424 The mframe () function creates a new frame with parameters listed
425 in $PLIST which may be @c NULL.
427 The recognized keys in $PLIST are window system dependent.
429 The following key is always recognized.
433 <li> @b Mdevice, the value must be one of #Mx, @b Mgd, and #Mnil.
435 If the value is #Mx, the frame is for X Window System. The
436 argument #MDrawWindow specified together with the frame must be of
437 type @c Window. The frame is both readable and writable, thus all
438 GUI functions can be used.
440 If the value is @b Mgd, the frame is for an image object of GD
441 library. The argument #MDrawWindow specified together with the
442 frame must be of type @c gdImagePtr. The frame is writable
443 only, thus functions minput_XXX can't be used for the frame.
445 If the value is #Mnil, the frame is for a null device. The frame
446 is not writable nor readable, thus functions mdraw_XXX that
447 require the argument #MDrawWindow and functions minput_XXX can't
448 be used for the frame.
450 <li> #Mface, the value must be a pointer to #MFace.
452 The value is used as the default face of the frame.
456 In addition, if the value of the key @b Mdevice is #Mx, the
457 following keys are recognized. They are to specify the root
458 window and the depth of drawables that can be used with the frame.
462 <li> @b Mdrawable, the value type must be <tt>Drawable</tt>.
464 A parameter of key @b Mdisplay must also be specified. The
465 created frame can be used for drawables whose root window and
466 depth are the same as those of the specified drawable on the
469 When this parameter is specified, the parameter of key @b Mscreen
472 <li> @b Mwidget, the value type must be <tt>Widget</tt>.
474 The created frame can be used for drawables whose root window and
475 depth are the same as those of the specified widget.
477 If a parameter of key #Mface is not specified, the default face
478 is created from the resources of the widget.
480 When this parameter is specified, the parameters of key @b Mdisplay,
481 @b Mscreen, @b Mdrawable, @b Mdepth are ignored.
483 <li> @b Mdepth, the value type must be <tt>unsigned</tt>.
485 The created frame can be used for drawables of the specified
488 <li> @b Mscreen, the value type must be <tt>(Screen *)</tt>.
490 The created frame can be used for drawables whose root window is
491 the same as the root window of the specified screen, and depth is
492 the same at the default depth of the screen.
494 When this parameter is specified, parameter of key @b Mdisplay is
497 <li> @b Mdisplay, the value type must be <tt>(Display *)</tt>.
499 The created frame can be used for drawables whose root window is
500 the same as the root window for the default screen of the display,
501 and depth is the same as the default depth of the screen.
503 <li> @b Mcolormap, the value type must be <tt>(Colormap)</tt>.
505 The created frame uses the specified colormap.
507 <li> @b Mfont, the value must be #Mx, #Mfreetype, or #Mxft.
509 The created frame uses the specified font backend. The value #Mx
510 instructs to use X core fonts, #Mfreetype to use local fonts
511 supported by FreeType fonts, and #Mxft to use local fonts via Xft
512 library. You can specify this parameter more than once with
513 different values if you want to use multiple font backends. This
514 is ignored if the specified font backend is not supported on the
517 When this parameter is not specified, all font backend supported
518 on the device are used.
523 If the operation was successful, mframe () returns a pointer to a
524 newly created frame. Otherwise, it returns @c NULL. */
527 @brief ¿·¤·¤¤¥Õ¥ì¡¼¥à¤òºî¤ë.
529 ´Ø¿ô mframe () ¤Ï $PLIST Ãæ¤Î¥Ñ¥é¥á¡¼¥¿¤ò»ý¤Ä¿·¤·¤¤¥Õ¥ì¡¼¥à¤òºî¤ë¡£
530 $PLIST ¤Ï @c NULL ¤Ç¤âÎɤ¤¡£
532 $PLIST ¤Ë¸½¤ï¤ì¤ë¥¡¼¤Î¤¦¤Á¤É¤ì¤¬Ç§¼±¤µ¤ì¤ë¤«¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¡£
534 °Ê²¼¤Î¥¡¼¤Ï¾ï¤Ëǧ¼±¤µ¤ì¤ë¡£
538 <li> @b Mdevice. ÃÍ¤Ï #Mx, @b Mgd, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
540 Ãͤ¬ #Mx ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï X ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥àÍѤǤ¢¤ë¡£
541 ¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô #MDrawWindow ¤Ï¡¢ @c Window
542 ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤¤È¤â¤Ë²Äǽ¤Ç¤¢¤ê¡¢¤¹¤Ù¤Æ¤ÎGUI
545 Ãͤ¬ @b Mgd ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï GD
546 ¥é¥¤¥Ö¥é¥ê¤Î¥¤¥á¡¼¥¸¥ª¥Ö¥¸¥§¥¯¥ÈÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô
547 #MDrawWindow ¤Ï¡¢ @c gdImagePtr ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤Ï½ñ¤½Ð¤·ÀìÍѤǤ¢¤ê¡¢
548 minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ¤Ê¤¤¡£
550 Ãͤ¬ #Mnil ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï, null
551 ¥Ç¥Ð¥¤¥¹ÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤¤Ç¤¤Ê¤¤¤Î¤Ç¡¢°ú¿ô #MDrawWindow
552 ¤òɬÍפȤ¹¤ëmdraw_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤ä¡¢minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ¤Ê¤¤¡£
554 <li> #Mface. ÃÍ¤Ï #MFace ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
556 ¤³¤ÎÃͤϥե졼¥à¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
560 ¤³¤ì¤é¤Î¥¡¼¤Ë²Ã¤¨¡¢@b Mdevice ¤Î¥¡¼¤¬ #Mx
561 ¤Ç¤¢¤ë¾ì¹ç¤Ë¸Â¤ê°Ê²¼¤Î¥¡¼¤âǧ¼±¤µ¤ì¤ë¡£°Ê²¼¤Î¥¡¼¤Ï¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¡¢¥Õ¥ì¡¼¥à¤ÇÍøÍѤǤ¤ë
562 drawable ¤Î¿¼¤µ¤ò»ØÄꤹ¤ë¡£
566 <li> @b Mdrawable. ÃÍ¤Ï <tt>Drawable</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
568 ¥¡¼ @b Mdisplay ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤â»ØÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
569 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤¾å¤Î»ØÄꤵ¤ì¤¿ drawable
570 ¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
572 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@b Mscreen ¤ò¥¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
574 <li> @b Mwidget. ÃÍ¤Ï <tt>Widget</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
576 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä
577 drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
579 ¥¡¼ #Mface ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤¬¤Ê¤±¤ì¤Ð¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤Ï¤³¤Î
580 ¥¦¥£¥¸¥§¥Ã¥È¤Î¥ê¥½¡¼¥¹¤«¤éºî¤é¤ì¤ë¡£
582 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@b Mdisplay, @b Mscreen, @b Mdrawable,
583 @b Mdepth ¤ò¥¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
585 <li> @b Mdepth. ÃÍ¤Ï <tt>unsigned</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
587 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¿¼¤µ¤Î drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
589 <li> @b Mscreen. ÃÍ¤Ï <tt>(Screen *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
591 À¸À®¤·¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ò»ý¤Á¡¢¥¹¥¯¥ê¡¼¥ó¤Î¥Ç¥Õ¥©¥ë¥È¤Î¿¼¤µ¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
593 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@b Mdisplay ¤ò¥¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
595 <li> @b Mdisplay. ÃÍ¤Ï <tt>(Display *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
597 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥Ç¥£¥¹¥×¥ì¥¤¤Î¥Ç¥Õ¥©¥ë¥È¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ädrawables ¤ËÍѤ¤¤é¤ì¤ë¡£
599 <li> @b Mcolormap. ÃÍ¤Ï <tt>(Colormap)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
601 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥«¥é¡¼¥Þ¥Ã¥×¤ò»ÈÍѤ¹¤ë¡£
603 <li> #Mfont. Ãͤϡ¢#Mx, #Mfreetype, #Mxft ¤Î¤¤¤º¤ì¤«¡£
605 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï»ØÄꤷ¤¿¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤ò»ÈÍѤ¹¤ë¡£Ãͤ¬
606 #Mx ¤Ç¤¢¤ì¤Ð X ¤Î¥³¥¢¥Õ¥©¥ó¥È¡¢#Mfreetype ¤Ç¤¢¤ì¤Ð FreeType
607 ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥í¡¼¥«¥ë¥Õ¥©¥ó¥È¡¢#Mxft ¤Ç¤¢¤ì¤Ð Xft
608 ¥é¥¤¥Ö¥é¥ê·Ðͳ¤ÇÍѤ¤¤ë¥í¡¼¥«¥ë¥Õ¥©¥ó¥È¤ò»ÈÍѤ¹¤ë¡£
609 Ê£¿ô¤Î¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤ò»ÈÍѤ·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤òÊ£¿ô²ó¡¢°Û¤Ê¤ëÃͤǻØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
610 »ØÄꤷ¤¿¥Ð¥Ã¥¯¥¨¥ó¥É¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ç¥Ð¥¤¥¹¤Ç¤Ï¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
612 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬Ìµ¤¤¾ì¹ç¤Ë¤Ï¡¢¥Ç¥Ð¥¤¥¹¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤¹¤Ù¤Æ¤Î¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤òÍøÍѤ¹¤ë¡£
617 À®¸ù¤¹¤ì¤Ð mframe() ¤Ï¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð
621 mframe (MPlist *plist)
624 int plist_created = 0;
627 MDeviceLibraryInterface *interface;
631 pl = mplist_find_by_key (plist, Mdevice);
633 device = MPLIST_VAL (pl);
647 interface = &null_interface;
648 if (! interface->handle)
650 (*interface->init) ();
651 interface->handle = (void *) 1;
653 #else /* not HAVE_FREETYPE */
654 MERROR (MERROR_WIN, NULL);
655 #endif /* not HAVE_FREETYPE */
659 interface = mplist_get (device_library_list, device);
661 MERROR (MERROR_WIN, NULL);
662 if (! interface->handle)
664 if (! (interface->handle = dlopen (interface->library, RTLD_NOW))
665 || ! (interface->init
666 = (int (*) ()) dlsym (interface->handle, "device_init"))
667 || ! (interface->open
668 = (int (*) (MFrame *, MPlist *)) dlsym (interface->handle,
670 || ! (interface->fini
671 = (int (*) ()) dlsym (interface->handle, "device_fini"))
672 || (*interface->init) () < 0)
674 fprintf (stderr, "%s\n", (char *) dlerror ());
675 if (interface->handle)
676 dlclose (interface->handle);
677 MERROR (MERROR_WIN, NULL);
682 M17N_OBJECT (frame, free_frame, MERROR_FRAME);
683 if ((*interface->open) (frame, plist) < 0)
686 MERROR (MERROR_WIN, NULL);
689 if (! mframe_default)
690 mframe_default = frame;
692 frame->face = mface ();
693 MPLIST_DO (pl, plist)
694 if (MPLIST_KEY (pl) == Mface)
695 mface_merge (frame->face, (MFace *) MPLIST_VAL (pl));
696 mface__update_frame_face (frame);
698 = frame->rface->rfont ? (MFont *) frame->rface->rfont : NULL;
700 M17N_OBJECT_UNREF (plist);
707 @brief Return property value of frame.
709 The mframe_get_prop () function returns a value of property $KEY
710 of frame $FRAME. The valid keys and the corresponding return
711 values are as follows.
715 key type of value meaning of value
716 --- ------------- ----------------
717 Mface MFace * The default face.
719 Mfont MFont * The default font.
721 Mfont_width int Width of the default font.
723 Mfont_ascent int Ascent of the default font.
725 Mfont_descent int Descent of the default font.
729 In the m17n-X library, the followings are also accepted.
733 key type of value meaning of value
734 --- ------------- ----------------
735 Mdisplay Display * Display associated with the frame.
737 Mscreen int Screen number of a screen associated
740 Mcolormap Colormap Colormap of the frame.
742 Mdepth unsigned Depth of the frame.
747 @brief ¥Õ¥ì¡¼¥à¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹.
749 ´Ø¿ô mframe_get_prop () ¤Ï¥Õ¥ì¡¼¥à $FRAME ¤Î¥¡¼ $KEY
750 ¤ò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£Í¸ú¤Ê¥¡¼¤È¤½¤ÎÃͤϰʲ¼¤ÎÄ̤ꡣ
755 --- ------------- ----------------
756 Mface MFace * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹
758 Mfont MFont * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È
760 Mfont_width int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤ÎÉý
762 Mfont_ascent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î ascent
764 Mfont_descent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î descent
768 m17n-X ¥é¥¤¥Ö¥é¥ê¤Ç¤Ï¡¢°Ê²¼¤Î¥¡¼¤â»ÈÍѤǤ¤ë¡£
773 --- ------------- ----------------
774 Mdisplay Display * ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤
776 Mscreen int ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥¹¥¯¥ê¡¼¥ó
779 Mcolormap Colormap ¥Õ¥ì¡¼¥à¤Î¥«¥é¡¼¥Þ¥Ã¥×
781 Mdepth unsigned ¥Õ¥ì¡¼¥à¤Î¿¼¤µ
787 mframe_get_prop (MFrame *frame, MSymbol key)
793 if (key == Mfont_width)
794 return (void *) (frame->average_width);
795 if (key == Mfont_ascent)
796 return (void *) (frame->ascent);
797 if (key == Mfont_descent)
798 return (void *) (frame->descent);
799 return (*frame->driver->get_prop) (frame, key);
805 @brief The default frame.
807 The external variable #mframe_default contains a pointer to the
808 default frame that is created by the first call of mframe (). */
811 @brief ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à.
813 ³°ÉôÊÑ¿ô #mframe_default ¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ý¤Ä¡£
814 ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ï¡¢ºÇ½é¤Ë mframe () ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤¤Ëºî¤é¤ì¤ë¡£ */
816 MFrame *mframe_default;