1 /* m17n-gui.c -- body of the 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., 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 (lib)
129 + strlen (DLOPEN_SHLIB_EXT) + 1);
130 sprintf (interface->library, "%s%s", lib, DLOPEN_SHLIB_EXT);
131 if (! device_library_list)
132 device_library_list = mplist ();
133 mplist_add (device_library_list, name, interface);
139 /** Null device support. */
142 MPlist *realized_fontset_list;
143 MPlist *realized_font_list;
144 MPlist *realized_face_list;
148 null_device_close (MFrame *frame)
153 null_device_get_prop (MFrame *frame, MSymbol key)
159 null_device_realize_face (MRealizedFace *rface)
165 null_device_free_realized_face (MRealizedFace *rface)
169 static MDeviceDriver null_driver =
172 null_device_get_prop,
173 null_device_realize_face,
174 null_device_free_realized_face
180 null_device.realized_fontset_list = mplist ();
181 null_device.realized_font_list = mplist ();
182 null_device.realized_face_list = mplist ();
191 MPLIST_DO (plist, null_device.realized_fontset_list)
192 mfont__free_realized_fontset ((MRealizedFontset *) MPLIST_VAL (plist));
193 M17N_OBJECT_UNREF (null_device.realized_fontset_list);
195 MPLIST_DO (plist, null_device.realized_face_list)
196 mface__free_realized ((MRealizedFace *) MPLIST_VAL (plist));
197 M17N_OBJECT_UNREF (null_device.realized_face_list);
199 if (MPLIST_VAL (null_device.realized_font_list))
200 mfont__free_realized (MPLIST_VAL (null_device.realized_font_list));
201 M17N_OBJECT_UNREF (null_device.realized_font_list);
206 null_device_open (MFrame *frame, MPlist *param)
210 frame->device = NULL;
211 frame->device_type = 0;
212 frame->dpi = (int) mplist_get (param, Mresolution);
215 frame->driver = &null_driver;
216 frame->font_driver_list = mplist ();
217 mplist_add (frame->font_driver_list, Mfreetype, &mfont__ft_driver);
218 frame->realized_font_list = null_device.realized_font_list;
219 frame->realized_face_list = null_device.realized_face_list;
220 frame->realized_fontset_list = null_device.realized_fontset_list;
221 face = mface_copy (mface__default);
222 mplist_push (param, Mface, face);
223 M17N_OBJECT_UNREF (face);
227 static MDeviceLibraryInterface null_interface =
228 { NULL, NULL, null_device_init, null_device_open, null_device_fini };
240 int mdebug_mask = MDEBUG_INIT;
242 merror_code = MERROR_NONE;
243 if (m17n__gui_initialized++)
246 if (merror_code != MERROR_NONE)
248 m17n__gui_initialized--;
254 Mgd = msymbol ("gd");
256 Mfont = msymbol ("font");
257 Mfont_width = msymbol ("font-width");
258 Mfont_ascent = msymbol ("font-ascent");
259 Mfont_descent = msymbol ("font-descent");
260 Mdevice = msymbol ("device");
262 Mdisplay = msymbol ("display");
263 Mscreen = msymbol ("screen");
264 Mdrawable = msymbol ("drawable");
265 Mdepth = msymbol ("depth");
266 Mwidget = msymbol ("widget");
267 Mcolormap = msymbol ("colormap");
270 if (mfont__init () < 0)
272 MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize font module."));
273 if (mfont__fontset_init () < 0)
275 MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize fontset module."));
276 if (mface__init () < 0)
278 MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize face module."));
279 if (mdraw__init () < 0)
281 MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize draw module."));
282 if (minput__win_init () < 0)
284 MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize input-win module."));
285 mframe_default = NULL;
287 register_device_library (Mx, "libm17n-X");
288 register_device_library (Mgd, "libm17n-gd");
293 MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the m17n GUI module."));
300 int mdebug_mask = MDEBUG_FINI;
303 if (m17n__gui_initialized == 0
304 || --m17n__gui_initialized > 0)
309 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize device modules."));
310 MPLIST_DO (plist, device_library_list)
312 MDeviceLibraryInterface *interface = MPLIST_VAL (plist);
314 if (interface->handle && interface->fini)
316 (*interface->fini) ();
317 dlclose (interface->handle);
319 free (interface->library);
323 if (null_interface.handle)
325 (*null_interface.fini) ();
326 null_interface.handle = NULL;
328 #endif /* not HAVE_FREETYPE */
329 M17N_OBJECT_UNREF (device_library_list);
331 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input-gui module."));
333 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize draw module."));
335 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize face module."));
336 mfont__fontset_fini ();
337 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize fontset module."));
339 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize font module."));
340 mframe_default = NULL;
342 MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the gui modules."));
348 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
350 /*** @addtogroup m17nFrame */
352 @brief A @e frame is an object corresponding to the graphic device.
354 A @e frame is an object of the type #MFrame to hold various
355 information about each display/input device. Almost all m17n GUI
356 functions require a pointer to a frame as an argument. */
358 @brief @e ¥Õ¥ì¡¼¥à ¤È¤Ï¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð¥¤¥¹¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë.
360 @e ¥Õ¥ì¡¼¥à ¤È¤Ï #MFrame
361 ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢¸Ä¡¹¤Îɽ¼¨¡¿ÆþÎϥǥХ¤¥¹¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
362 ¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î m17n GUI´Ø¿ô¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÍ׵᤹¤ë¡£ */
368 @name Variables: Keys of frame parameter
370 These are the symbols to use in a parameter to create a frame. See
371 the function mframe () for details.
373 #Mdevice, #Mdisplay, #Mscreen, #Mdrawable, #Mdepth, and #Mcolormap
374 are also keys of a frame property. */
377 @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥Ñ¥é¥á¡¼¥¿ÍÑ¥¡¼
379 ¥Õ¥ì¡¼¥à¤òÀ¸À®¤¹¤ëºÝ¤Î¥Ñ¥é¥á¡¼¥¿¤ËÍѤ¤¤ë¥·¥ó¥Ü¥ë¡£¾Ü¤·¤¯¤Ï´Ø¿ô
380 mframe () ¤ÎÀâÌÀ»²¾È¡£
382 #Mdevice¡¢ #Mdisplay¡¢ #Mscreen¡¢ #Mdrawable¡¢ #Mdepth¡¢#Mcolormap
383 ¤Ï¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼¤Ç¤â¤¢¤ë¡£ */
387 MSymbol Mdevice, Mdisplay, Mscreen, Mdrawable, Mdepth, Mcolormap, Mwidget;
394 @name Variables: Keys of frame property
396 These are the symbols to use as an argument to the function
397 mframe_get_prop (). */
399 @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥¡¼
401 ´Ø¿ô mframe_get_prop () ¤Î°ú¿ô¤ËÍѤ¤¤é¤ì¤ë¥·¥ó¥Ü¥ë¡£ */
406 MSymbol Mfont_ascent;
407 MSymbol Mfont_descent;
415 @brief Create a new frame.
417 The mframe () function creates a new frame with parameters listed
418 in $PLIST which may be @c NULL.
420 The recognized keys in $PLIST are window system dependent.
422 The following key is always recognized.
426 <li> #Mdevice, the value must be one of #Mx, #Mgd, and #Mnil.
428 If the value is #Mx, the frame is for X Window System. The
429 argument #MDrawWindow specified together with the frame must be of
430 type @c Window. The frame is both readable and writable, thus all
431 GUI functions can be used.
433 If the value is #Mgd, the frame is for an image object of GD
434 library. The argument #MDrawWindow specified together with the
435 frame must be of type @c gdImagePtr. The frame is writable
436 only, thus functions minput_XXX can't be used for the frame.
438 If the value is #Mnil, the frame is for a null device. The frame
439 is not writable nor readable, thus functions mdraw_XXX that
440 require the argument #MDrawWindow and functions minput_XXX can't
441 be used for the frame.
443 <li> #Mface, the value must be a pointer to #MFace.
445 The value is used as the default face of the frame.
449 In addition, if the value of the key #Mdevice is #Mx, the
450 following keys are recognized. They are to specify the root
451 window and the depth of drawables that can be used with the frame.
455 <li> #Mdrawable, the value type must be <tt>Drawable</tt>.
457 A parameter of key #Mdisplay must also be specified. The
458 created frame can be used for drawables whose root window and
459 depth are the same as those of the specified drawable on the
462 When this parameter is specified, the parameter of key #Mscreen
465 <li> #Mwidget, the value type must be <tt>Widget</tt>.
467 The created frame can be used for drawables whose root window and
468 depth are the same as those of the specified widget.
470 If a parameter of key #Mface is not specified, the default face
471 is created from the resources of the widget.
473 When this parameter is specified, the parameters of key #Mdisplay,
474 #Mscreen, #Mdrawable, #Mdepth are ignored.
476 <li> #Mdepth, the value type must be <tt>unsigned</tt>.
478 The created frame can be used for drawables of the specified
481 <li> #Mscreen, the value type must be <tt>(Screen *)</tt>.
483 The created frame can be used for drawables whose root window is
484 the same as the root window of the specified screen, and depth is
485 the same at the default depth of the screen.
487 When this parameter is specified, parameter of key #Mdisplay is
490 <li> #Mdisplay, the value type must be <tt>(Display *)</tt>.
492 The created frame can be used for drawables whose root window is
493 the same as the root window for the default screen of the display,
494 and depth is the same as the default depth of the screen.
496 <li> #Mcolormap, the value type must be <tt>(Colormap)</tt>.
498 The created frame uses the specified colormap.
500 <li> #Mfont, the value must be #Mx, #Mfreetype, or #Mxft.
502 The created frame uses the specified font backend. The value #Mx
503 instructs to use X core fonts, #Mfreetype to use local fonts
504 supported by FreeType fonts, and #Mxft to use local fonts via Xft
505 library. You can specify this parameter more than once with
506 different values if you want to use multiple font backends. This
507 is ignored if the specified font backend is not supported on the
510 When this parameter is not specified, all font backend supported
511 on the device are used.
516 If the operation was successful, mframe () returns a pointer to a
517 newly created frame. Otherwise, it returns @c NULL. */
520 @brief ¿·¤·¤¤¥Õ¥ì¡¼¥à¤òºî¤ë.
522 ´Ø¿ô mframe () ¤Ï $PLIST Ãæ¤Î¥Ñ¥é¥á¡¼¥¿¤ò»ý¤Ä¿·¤·¤¤¥Õ¥ì¡¼¥à¤òºî¤ë¡£
523 $PLIST ¤Ï @c NULL ¤Ç¤âÎɤ¤¡£
525 $PLIST ¤Ë¸½¤ï¤ì¤ë¥¡¼¤Î¤¦¤Á¤É¤ì¤¬Ç§¼±¤µ¤ì¤ë¤«¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¡£
527 °Ê²¼¤Î¥¡¼¤Ï¾ï¤Ëǧ¼±¤µ¤ì¤ë¡£
531 <li> #Mdevice. ÃÍ¤Ï #Mx, #Mgd, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
533 Ãͤ¬ #Mx ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï X ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥àÍѤǤ¢¤ë¡£
534 ¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô #MDrawWindow ¤Ï¡¢ @c Window
535 ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤¤È¤â¤Ë²Äǽ¤Ç¤¢¤ê¡¢¤¹¤Ù¤Æ¤ÎGUI
538 Ãͤ¬ #Mgd ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï GD
539 ¥é¥¤¥Ö¥é¥ê¤Î¥¤¥á¡¼¥¸¥ª¥Ö¥¸¥§¥¯¥ÈÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô
540 #MDrawWindow ¤Ï¡¢ @c gdImagePtr ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤Ï½ñ¤½Ð¤·ÀìÍѤǤ¢¤ê¡¢
541 minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ¤Ê¤¤¡£
543 Ãͤ¬ #Mnil ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï, null
544 ¥Ç¥Ð¥¤¥¹ÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤¤Ç¤¤Ê¤¤¤Î¤Ç¡¢°ú¿ô #MDrawWindow
545 ¤òɬÍפȤ¹¤ëmdraw_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤ä¡¢minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ¤Ê¤¤¡£
547 <li> #Mface. ÃÍ¤Ï #MFace ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
549 ¤³¤ÎÃͤϥե졼¥à¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
553 ¤³¤ì¤é¤Î¥¡¼¤Ë²Ã¤¨¡¢#Mdevice ¤Î¥¡¼¤¬ #Mx
554 ¤Ç¤¢¤ë¾ì¹ç¤Ë¸Â¤ê°Ê²¼¤Î¥¡¼¤âǧ¼±¤µ¤ì¤ë¡£°Ê²¼¤Î¥¡¼¤Ï¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¡¢¥Õ¥ì¡¼¥à¤ÇÍøÍѤǤ¤ë
555 drawable ¤Î¿¼¤µ¤ò»ØÄꤹ¤ë¡£
559 <li> #Mdrawable. ÃÍ¤Ï <tt>Drawable</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
561 ¥¡¼ #Mdisplay ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤â»ØÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
562 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤¾å¤Î»ØÄꤵ¤ì¤¿ drawable
563 ¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
565 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mscreen ¤ò¥¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
567 <li> #Mwidget. ÃÍ¤Ï <tt>Widget</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
569 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä
570 drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
572 ¥¡¼ #Mface ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤¬¤Ê¤±¤ì¤Ð¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤Ï¤³¤Î
573 ¥¦¥£¥¸¥§¥Ã¥È¤Î¥ê¥½¡¼¥¹¤«¤éºî¤é¤ì¤ë¡£
575 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mdisplay, #Mscreen, #Mdrawable,
576 #Mdepth ¤ò¥¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
578 <li> #Mdepth. ÃÍ¤Ï <tt>unsigned</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
580 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¿¼¤µ¤Î drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
582 <li> #Mscreen. ÃÍ¤Ï <tt>(Screen *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
584 À¸À®¤·¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ò»ý¤Á¡¢¥¹¥¯¥ê¡¼¥ó¤Î¥Ç¥Õ¥©¥ë¥È¤Î¿¼¤µ¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
586 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mdisplay ¤ò¥¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
588 <li> #Mdisplay. ÃÍ¤Ï <tt>(Display *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
590 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥Ç¥£¥¹¥×¥ì¥¤¤Î¥Ç¥Õ¥©¥ë¥È¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ädrawables ¤ËÍѤ¤¤é¤ì¤ë¡£
592 <li> #Mcolormap. ÃÍ¤Ï <tt>(Colormap)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
594 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥«¥é¡¼¥Þ¥Ã¥×¤ò»ÈÍѤ¹¤ë¡£
596 <li> #Mfont. Ãͤϡ¢#Mx, #Mfreetype, #Mxft ¤Î¤¤¤º¤ì¤«¡£
598 À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï»ØÄꤷ¤¿¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤ò»ÈÍѤ¹¤ë¡£Ãͤ¬
599 #Mx ¤Ç¤¢¤ì¤Ð X ¤Î¥³¥¢¥Õ¥©¥ó¥È¡¢#Mfreetype ¤Ç¤¢¤ì¤Ð FreeType
600 ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥í¡¼¥«¥ë¥Õ¥©¥ó¥È¡¢#Mxft ¤Ç¤¢¤ì¤Ð Xft
601 ¥é¥¤¥Ö¥é¥ê·Ðͳ¤ÇÍѤ¤¤ë¥í¡¼¥«¥ë¥Õ¥©¥ó¥È¤ò»ÈÍѤ¹¤ë¡£
602 Ê£¿ô¤Î¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤ò»ÈÍѤ·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤òÊ£¿ô²ó¡¢°Û¤Ê¤ëÃͤǻØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£
603 »ØÄꤷ¤¿¥Ð¥Ã¥¯¥¨¥ó¥É¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ç¥Ð¥¤¥¹¤Ç¤Ï¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
605 ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬Ìµ¤¤¾ì¹ç¤Ë¤Ï¡¢¥Ç¥Ð¥¤¥¹¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤¹¤Ù¤Æ¤Î¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤òÍøÍѤ¹¤ë¡£
610 À®¸ù¤¹¤ì¤Ð mframe() ¤Ï¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð
614 mframe (MPlist *plist)
617 int plist_created = 0;
620 MDeviceLibraryInterface *interface;
624 pl = mplist_find_by_key (plist, Mdevice);
626 device = MPLIST_VAL (pl);
640 interface = &null_interface;
641 if (! interface->handle)
643 (*interface->init) ();
644 interface->handle = (void *) 1;
646 #else /* not HAVE_FREETYPE */
647 MERROR (MERROR_WIN, NULL);
648 #endif /* not HAVE_FREETYPE */
652 interface = mplist_get (device_library_list, device);
654 MERROR (MERROR_WIN, NULL);
655 if (! interface->handle)
657 if (! (interface->handle = dlopen (interface->library, RTLD_NOW))
658 || ! (interface->init
659 = (int (*) ()) dlsym (interface->handle, "device_init"))
660 || ! (interface->open
661 = (int (*) (MFrame *, MPlist *)) dlsym (interface->handle,
663 || ! (interface->fini
664 = (int (*) ()) dlsym (interface->handle, "device_fini"))
665 || (*interface->init) () < 0)
667 fprintf (stderr, "%s\n", (char *) dlerror ());
668 if (interface->handle)
669 dlclose (interface->handle);
670 MERROR (MERROR_WIN, NULL);
675 M17N_OBJECT (frame, free_frame, MERROR_FRAME);
676 if ((*interface->open) (frame, plist) < 0)
679 MERROR (MERROR_WIN, NULL);
682 if (! mframe_default)
683 mframe_default = frame;
685 frame->face = mface ();
686 MPLIST_DO (pl, plist)
687 if (MPLIST_KEY (pl) == Mface)
688 mface_merge (frame->face, (MFace *) MPLIST_VAL (pl));
689 mface__update_frame_face (frame);
691 = frame->rface->rfont ? (MFont *) frame->rface->rfont : NULL;
693 M17N_OBJECT_UNREF (plist);
700 @brief Return property value of frame.
702 The mframe_get_prop () function returns a value of property $KEY
703 of frame $FRAME. The valid keys and the corresponding return
704 values are as follows.
708 key type of value meaning of value
709 --- ------------- ----------------
710 Mface MFace * The default face.
712 Mfont MFont * The default font.
714 Mfont_width int Width of the default font.
716 Mfont_ascent int Ascent of the default font.
718 Mfont_descent int Descent of the default font.
722 In the m17n-X library, the followings are also accepted.
726 key type of value meaning of value
727 --- ------------- ----------------
728 Mdisplay Display * Display associated with the frame.
730 Mscreen int Screen number of a screen associated
733 Mcolormap Colormap Colormap of the frame.
735 Mdepth unsigned Depth of the frame.
740 @brief ¥Õ¥ì¡¼¥à¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹.
742 ´Ø¿ô mframe_get_prop () ¤Ï¥Õ¥ì¡¼¥à $FRAME ¤Î¥¡¼ $KEY
743 ¤ò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£Í¸ú¤Ê¥¡¼¤È¤½¤ÎÃͤϰʲ¼¤ÎÄ̤ꡣ
748 --- ------------- ----------------
749 Mface MFace * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹
751 Mfont MFont * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È
753 Mfont_width int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤ÎÉý
755 Mfont_ascent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î ascent
757 Mfont_descent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î descent
761 m17n-X ¥é¥¤¥Ö¥é¥ê¤Ç¤Ï¡¢°Ê²¼¤Î¥¡¼¤â»ÈÍѤǤ¤ë¡£
766 --- ------------- ----------------
767 Mdisplay Display * ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤
769 Mscreen int ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥¹¥¯¥ê¡¼¥ó
772 Mcolormap Colormap ¥Õ¥ì¡¼¥à¤Î¥«¥é¡¼¥Þ¥Ã¥×
774 Mdepth unsigned ¥Õ¥ì¡¼¥à¤Î¿¼¤µ
780 mframe_get_prop (MFrame *frame, MSymbol key)
786 if (key == Mfont_width)
787 return (void *) (frame->average_width);
788 if (key == Mfont_ascent)
789 return (void *) (frame->ascent);
790 if (key == Mfont_descent)
791 return (void *) (frame->descent);
792 return (*frame->driver->get_prop) (frame, key);
798 @brief The default frame.
800 The external variable #mframe_default contains a pointer to the
801 default frame that is created by the first call of mframe (). */
804 @brief ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à.
806 ³°ÉôÊÑ¿ô #mframe_default ¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ý¤Ä¡£
807 ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ï¡¢ºÇ½é¤Ë mframe () ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤¤Ëºî¤é¤ì¤ë¡£ */
809 MFrame *mframe_default;