X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fm17n-gui.c;h=c0bd14a51ce4478618d127b32ff759b51c47ec43;hb=6dd098a655551afd765159165e4b29ec9f693cb2;hp=a3f5620960010b36fff7b59b195dbbe6a48600bb;hpb=949a87877d267db3226e998eb4cfaecb77180292;p=m17n%2Fm17n-lib.git diff --git a/src/m17n-gui.c b/src/m17n-gui.c index a3f5620..c0bd14a 100644 --- a/src/m17n-gui.c +++ b/src/m17n-gui.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU Lesser General Public License along with the m17n library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 02111-1307, USA. */ /***en @@ -40,17 +40,16 @@ @addtogroup m17nGUI @brief ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¾å¤Î GUI ¥µ¥Ý¡¼¥È. - ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Î¤â¤È¤Ç¤Î M-text ¤Îɽ¼¨¤ÈÆþÎÏ¤Ë - ¤«¤«¤ï¤ë m17n GUI API ¤òÄêµÁ¤¹¤ë¡£ + ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Î¤â¤È¤Ç¤Î M-text ¤Îɽ¼¨¤ÈÆþÎϤˤ«¤«¤ï¤ë + m17n GUI API ¤òÄêµÁ¤¹¤ë¡£ - ¤³¤³¤Ç¤Î¤¹¤Ù¤Æ¤ÎÄêµÁ¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤È¤ÏÆÈΩ¤Ç¤¢¤ë¡£¤·¤«¤·¡¢¼Â - ºÝ¤Î¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤Ï¸ÄÊ̤Υ¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¾ì¹ç¤¬¤¢ - ¤ë¡£¤¿¤È¤¨¤Ð¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë m17n-X.so ¤Ï¡¢m17n GUI API ¤Î X ¥¦¥£ - ¥ó¥É¥¦ÍѤμÂÁõÎã¤Ç¤¢¤ë¡£ + ¤³¤³¤Ç¤Î¤¹¤Ù¤Æ¤ÎÄêµÁ¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤È¤ÏÆÈΩ¤Ç¤¢¤ë¡£ + ¤·¤«¤·¡¢¼ÂºÝ¤Î¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤Ï¸ÄÊ̤Υ¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¾ì¹ç¤¬¤¢¤ë¡£ + ¤¿¤È¤¨¤Ð¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë m17n-X.so ¤Ï¡¢m17n GUI API ¤Î X + ¥¦¥£¥ó¥É¥¦ÍѤμÂÁõÎã¤Ç¤¢¤ë¡£ ¸½¼Â¤Ë¤Ï¡¢GUI API ¤Ï¼ç¤Ë¥Ä¡¼¥ë¥­¥Ã¥È¥é¥¤¥Ö¥é¥ê¸þ¤±¤Ç¤¢¤ë¤«¡¢¤Þ¤¿¤Ï - XOM ¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤Æ¤ª¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é - ¤ÎľÀܤÎÍøÍѤòǰƬ¤Ë¤ª¤¤¤¿¤â¤Î¤Ç¤Ï¤Ê¤¤¡£ + XOM ¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤Æ¤ª¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤ÎľÀܤÎÍøÍѤòǰƬ¤Ë¤ª¤¤¤¿¤â¤Î¤Ç¤Ï¤Ê¤¤¡£ */ /*=*/ @@ -64,9 +63,12 @@ #include #include #include -#include #include "config.h" +#ifdef HAVE_DLFCN_H +#include +#endif + #include "m17n-gui.h" #include "m17n-misc.h" #include "internal.h" @@ -76,8 +78,6 @@ #include "fontset.h" #include "face.h" -static int win_initialized; - #ifndef DLOPEN_SHLIB_EXT #define DLOPEN_SHLIB_EXT ".so" #endif @@ -88,12 +88,12 @@ typedef struct { /** Name of the dynamic library (e.g. "libm17n-X.so"). */ char *library; - /** Handle fo the dynamic library. */ + /** Handle of the dynamic library. */ void *handle; /** Function to call just after loading the library. */ int (*init) (); /** Function to call to open a frame on the graphic device. */ - void *(*open) (MFrame *frame, MPlist *param); + int (*open) (MFrame *frame, MPlist *param); /** Function to call just before unloading the library. */ int (*fini) (); } MDeviceLibraryInterface; @@ -103,7 +103,6 @@ typedef struct static MPlist *device_library_list; - /** Close MFrame and free it. */ static void @@ -113,7 +112,7 @@ free_frame (void *object) (*frame->driver->close) (frame); M17N_OBJECT_UNREF (frame->face); - free (frame->font); + M17N_OBJECT_UNREF (frame->font_driver_list); free (object); } @@ -150,19 +149,19 @@ null_device_close (MFrame *frame) { } -void * +static void * null_device_get_prop (MFrame *frame, MSymbol key) { return NULL; } -void +static void null_device_realize_face (MRealizedFace *rface) { rface->info = NULL; } -void +static void null_device_free_realized_face (MRealizedFace *rface) { } @@ -197,20 +196,32 @@ null_device_fini () mface__free_realized ((MRealizedFace *) MPLIST_VAL (plist)); M17N_OBJECT_UNREF (null_device.realized_face_list); - MPLIST_DO (plist, null_device.realized_font_list) - mfont__free_realized ((MRealizedFont *) MPLIST_VAL (plist)); + if (MPLIST_VAL (null_device.realized_font_list)) + mfont__free_realized (MPLIST_VAL (null_device.realized_font_list)); M17N_OBJECT_UNREF (null_device.realized_font_list); return 0; } -static void * +static int null_device_open (MFrame *frame, MPlist *param) { + MFace *face; + + frame->device = NULL; frame->device_type = 0; + frame->dpi = (int) mplist_get (param, Mresolution); + if (frame->dpi == 0) + frame->dpi = 100; frame->driver = &null_driver; frame->font_driver_list = mplist (); mplist_add (frame->font_driver_list, Mfreetype, &mfont__ft_driver); - return &null_device; + frame->realized_font_list = null_device.realized_font_list; + frame->realized_face_list = null_device.realized_face_list; + frame->realized_fontset_list = null_device.realized_fontset_list; + face = mface_copy (mface__default); + mplist_push (param, Mface, face); + M17N_OBJECT_UNREF (face); + return 0; } static MDeviceLibraryInterface null_interface = @@ -220,33 +231,28 @@ static MDeviceLibraryInterface null_interface = /* Internal API */ -MSymbol Mfreetype; - -/*** @} */ -#endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */ - /* External API */ -MSymbol Mdevice; - void m17n_init_win (void) { int mdebug_mask = MDEBUG_INIT; - if (win_initialized++) + merror_code = MERROR_NONE; + if (m17n__gui_initialized++) return; m17n_init (); if (merror_code != MERROR_NONE) - return; + { + m17n__gui_initialized--; + return; + } MDEBUG_PUSH_TIME (); - Mx = msymbol ("x"); Mgd = msymbol ("gd"); - Mfreetype = msymbol ("freetype"); Mfont = msymbol ("font"); Mfont_width = msymbol ("font-width"); Mfont_ascent = msymbol ("font-ascent"); @@ -258,15 +264,12 @@ m17n_init_win (void) Mdrawable = msymbol ("drawable"); Mdepth = msymbol ("depth"); Mwidget = msymbol ("widget"); - - register_device_library (Mx, "libm17n-X"); - register_device_library (Mgd, "libm17n-gd"); + Mcolormap = msymbol ("colormap"); MDEBUG_PUSH_TIME (); if (mfont__init () < 0) goto err; MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize font module.")); - MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize win module.")); if (mfont__fontset_init () < 0) goto err; MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize fontset module.")); @@ -281,114 +284,130 @@ m17n_init_win (void) MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize input-win module.")); mframe_default = NULL; + register_device_library (Mx, "libm17n-X"); + register_device_library (Mgd, "libm17n-gd"); + return; + err: MDEBUG_POP_TIME (); MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the m17n GUI module.")); MDEBUG_POP_TIME (); - return; } void m17n_fini_win (void) { int mdebug_mask = MDEBUG_FINI; + MPlist *plist; - if (win_initialized > 1) - win_initialized--; - else + if (m17n__gui_initialized == 0 + || --m17n__gui_initialized > 0) + return; + + MDEBUG_PUSH_TIME (); + MDEBUG_PUSH_TIME (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize device modules.")); + MPLIST_DO (plist, device_library_list) { - MPlist *plist; + MDeviceLibraryInterface *interface = MPLIST_VAL (plist); - win_initialized = 0; - MDEBUG_PUSH_TIME (); - MDEBUG_PUSH_TIME (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize device modules.")); - MPLIST_DO (plist, device_library_list) + if (interface->handle && interface->fini) { - MDeviceLibraryInterface *interface = MPLIST_VAL (plist); - - if (interface->handle && interface->fini) - { - (*interface->fini) (); - dlclose (interface->handle); - } - free (interface->library); - free (interface); + (*interface->fini) (); + dlclose (interface->handle); } - M17N_OBJECT_UNREF (device_library_list); - if (null_interface.handle) - (*null_interface.fini) (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input-gui module.")); - minput__win_fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize draw module.")); - mdraw__fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize face module.")); - mface__fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize fontset module.")); - mfont__fontset_fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize font module.")); - mfont__fini (); - mframe_default = NULL; - MDEBUG_POP_TIME (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the gui modules.")); - MDEBUG_POP_TIME (); + free (interface->library); + free (interface); + } +#ifdef HAVE_FREETYPE + if (null_interface.handle) + { + (*null_interface.fini) (); + null_interface.handle = NULL; } +#endif /* not HAVE_FREETYPE */ + M17N_OBJECT_UNREF (device_library_list); + minput__win_fini (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input-gui module.")); + mdraw__fini (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize draw module.")); + mface__fini (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize face module.")); + mfont__fontset_fini (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize fontset module.")); + mfont__fini (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize font module.")); + mframe_default = NULL; + MDEBUG_POP_TIME (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the gui modules.")); + MDEBUG_POP_TIME (); m17n_fini (); } +/*** @} */ +#endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */ + /*** @addtogroup m17nFrame */ /***en - @brief A @e frame is an object corresponding to the physical device. + @brief A @e frame is an object corresponding to the graphic device. A @e frame is an object of the type #MFrame to hold various - information about each physical display/input device. Almost all - m17n GUI functions require a pointer to a frame as an - argument. */ - + information about each display/input device. Almost all m17n GUI + functions require a pointer to a frame as an argument. */ /***ja - @brief @e ¥Õ¥ì¡¼¥à¤È¤ÏʪÍýŪ¥Ç¥Ð¥¤¥¹¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë. + @brief @e ¥Õ¥ì¡¼¥à ¤È¤Ï¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð¥¤¥¹¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë. - @e ¥Õ¥ì¡¼¥à¤È¤Ï #MFrame ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢¸Ä¡¹¤ÎʪÍýŪ¤Êɽ¼¨¡¿ - ÆþÎϥǥХ¤¥¹¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î - m17n GUI API ¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÍ׵᤹¤ë¡£ */ + @e ¥Õ¥ì¡¼¥à ¤È¤Ï #MFrame + ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢¸Ä¡¹¤Îɽ¼¨¡¿ÆþÎϥǥХ¤¥¹¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£ + ¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î m17n GUI´Ø¿ô¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÍ׵᤹¤ë¡£ */ /*** @{ */ /*=*/ /***en - @name Variables: Keys of frame property (common). */ + @name Variables: Keys of frame parameter + + These are the symbols to use in a parameter to create a frame. See + the function mframe () for details. + + #Mdevice, #Mdisplay, #Mscreen, #Mdrawable, #Mdepth, and #Mcolormap + are also keys of a frame property. */ + /***ja - @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼ (¶¦ÄÌ). */ -/*** @{ */ + @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥Ñ¥é¥á¡¼¥¿ÍÑ¥­¡¼ + + ¥Õ¥ì¡¼¥à¤òÀ¸À®¤¹¤ëºÝ¤Î¥Ñ¥é¥á¡¼¥¿¤ËÍѤ¤¤ë¥·¥ó¥Ü¥ë¡£¾Ü¤·¤¯¤Ï´Ø¿ô + mframe () ¤ÎÀâÌÀ»²¾È¡£ + + #Mdevice¡¢ #Mdisplay¡¢ #Mscreen¡¢ #Mdrawable¡¢ #Mdepth¡¢#Mcolormap + ¤Ï¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤â¤¢¤ë¡£ */ + /*=*/ -MSymbol Mfont; -MSymbol Mfont_width; -MSymbol Mfont_ascent; -MSymbol Mfont_descent; + +MSymbol Mdevice, Mdisplay, Mscreen, Mdrawable, Mdepth, Mcolormap, Mwidget; + +MSymbol Mgd; /*=*/ /***en - @name Variables: Keys of frame parameter (X specific). + @name Variables: Keys of frame property - These are the symbols to use as parameter keys for the function - mframe () (which see). They are also keys of a frame property - except for #Mwidget. */ + These are the symbols to use as an argument to the function + mframe_get_prop (). */ /***ja - @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥Ñ¥é¥á¡¼¥¿ÍÑ¥­¡¼ (X ¸ÇÍ­). - - ´Ø¿ô mframe () ¤Î¥Ñ¥é¥á¡¼¥¿¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¥·¥ó¥Ü¥ë¡£( mframe - () ¤ÎÀâÌÀ»²¾È¡£) #Mwidget ¤ò½ü¤¤¤Æ¤Ï¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤â¤¢ - ¤ë¡£ - */ + @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼ + ´Ø¿ô mframe_get_prop () ¤Î°ú¿ô¤ËÍѤ¤¤é¤ì¤ë¥·¥ó¥Ü¥ë¡£ */ +/*** @{ */ /*=*/ - -MSymbol Mdisplay, Mscreen, Mdrawable, Mdepth, Mwidget, Mcolormap; - -MSymbol Mx, Mgd; +MSymbol Mfont; +MSymbol Mfont_width; +MSymbol Mfont_ascent; +MSymbol Mfont_descent; /*=*/ + /*** @} */ /*=*/ @@ -396,7 +415,7 @@ MSymbol Mx, Mgd; @brief Create a new frame. The mframe () function creates a new frame with parameters listed - in $PLIST which may be NULL. + in $PLIST which may be @c NULL. The recognized keys in $PLIST are window system dependent. @@ -404,19 +423,36 @@ MSymbol Mx, Mgd;
    -
  • #Mface, the value type must be (MFace *). +
  • #Mdevice, the value must be one of #Mx, #Mgd, and #Mnil. + + If the value is #Mx, the frame is for X Window System. The + argument #MDrawWindow specified together with the frame must be of + type @c Window. The frame is both readable and writable, thus all + GUI functions can be used. + + If the value is #Mgd, the frame is for an image object of GD + library. The argument #MDrawWindow specified together with the + frame must be of type @c gdImagePtr. The frame is writable + only, thus functions minput_XXX can't be used for the frame. + + If the value is #Mnil, the frame is for a null device. The frame + is not writable nor readable, thus functions mdraw_XXX that + require the argument #MDrawWindow and functions minput_XXX can't + be used for the frame. + +
  • #Mface, the value must be a pointer to #MFace. The value is used as the default face of the frame.
- In addition, in the m17n-X library, the following keys are - recognized. They are to specify the root window and the depth of - drawables that can be used with the frame. + In addition, if the value of the key #Mdevice is #Mx, the + following keys are recognized. They are to specify the root + window and the depth of drawables that can be used with the frame.
    -
  • #Mdrawable, the value type must be Drawable +
  • #Mdrawable, the value type must be Drawable. A parameter of key #Mdisplay must also be specified. The created frame can be used for drawables whose root window and @@ -461,6 +497,19 @@ MSymbol Mx, Mgd; The created frame uses the specified colormap. +
  • #Mfont, the value must be #Mx, #Mfreetype, or #Mxft. + + The created frame uses the specified font backend. The value #Mx + instructs to use X core fonts, #Mfreetype to use local fonts + supported by FreeType fonts, and #Mxft to use local fonts via Xft + library. You can specify this parameter more than once with + different values if you want to use multiple font backends. This + is ignored if the specified font backend is not supported on the + device. + + When this parameter is not specified, all font backend supported + on the device are used. +
@return @@ -471,37 +520,54 @@ MSymbol Mx, Mgd; @brief ¿·¤·¤¤¥Õ¥ì¡¼¥à¤òºî¤ë. ´Ø¿ô mframe () ¤Ï $PLIST Ãæ¤Î¥Ñ¥é¥á¡¼¥¿¤ò»ý¤Ä¿·¤·¤¤¥Õ¥ì¡¼¥à¤òºî¤ë¡£ - $PLIST ¤ÏNULL ¤Ç¤âÎɤ¤¡£ + $PLIST ¤Ï @c NULL ¤Ç¤âÎɤ¤¡£ + + $PLIST ¤Ë¸½¤ï¤ì¤ë¥­¡¼¤Î¤¦¤Á¤É¤ì¤¬Ç§¼±¤µ¤ì¤ë¤«¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à¤Ë°Í¸¤¹¤ë¡£ - $PLIST ¤Ë¸½¤ï¤ì¤ë¥­¡¼¤Î¤¦¤Á¤É¤ì¤¬Ç§¼±¤µ¤ì¤ë¤«¤Ï¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥à - ¤Ë°Í¸¤¹¤ë¡£¤·¤«¤·°Ê²¼¤Î¥­¡¼¤Ï¾ï¤Ëǧ¼±¤µ¤ì¤ë¡£ + °Ê²¼¤Î¥­¡¼¤Ï¾ï¤Ëǧ¼±¤µ¤ì¤ë¡£
    -
  • #Mface. ÃÍ¤Ï (MFace *) ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ +
  • #Mdevice. ÃÍ¤Ï #Mx, #Mgd, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ + + Ãͤ¬ #Mx ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï X ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥àÍѤǤ¢¤ë¡£ + ¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô #MDrawWindow ¤Ï¡¢ @c Window + ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤­¤È¤â¤Ë²Äǽ¤Ç¤¢¤ê¡¢¤¹¤Ù¤Æ¤ÎGUI + ´Ø¿ô¤¬»ÈÍѤǤ­¤ë¡£ + + Ãͤ¬ #Mgd ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï GD + ¥é¥¤¥Ö¥é¥ê¤Î¥¤¥á¡¼¥¸¥ª¥Ö¥¸¥§¥¯¥ÈÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô + #MDrawWindow ¤Ï¡¢ @c gdImagePtr ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤Ï½ñ¤­½Ð¤·ÀìÍѤǤ¢¤ê¡¢ + minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ­¤Ê¤¤¡£ + + Ãͤ¬ #Mnil ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï, null + ¥Ç¥Ð¥¤¥¹ÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤­¤Ç¤­¤Ê¤¤¤Î¤Ç¡¢°ú¿ô #MDrawWindow + ¤òɬÍפȤ¹¤ëmdraw_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤ä¡¢minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ­¤Ê¤¤¡£ + +
  • #Mface. ÃÍ¤Ï #MFace ¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ ¤³¤ÎÃͤϥե졼¥à¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
- ¤³¤ì¤Ë²Ã¤¨¤Æ¡¢m17n-X ¥é¥¤¥Ö¥é¥ê¤Ç¤Ï°Ê²¼¤Î¥­¡¼¤âǧ¼±¤¹¤ë¡£¤³¤ì¤é¤Ï - ¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¡¢¥Õ¥ì¡¼¥à¤ÇÍøÍѤǤ­¤ë drawable ¤Î¿¼¤µ¤ò»ØÄꤹ¤ë¡£ + ¤³¤ì¤é¤Î¥­¡¼¤Ë²Ã¤¨¡¢#Mdevice ¤Î¥­¡¼¤¬ #Mx + ¤Ç¤¢¤ë¾ì¹ç¤Ë¸Â¤ê°Ê²¼¤Î¥­¡¼¤âǧ¼±¤µ¤ì¤ë¡£°Ê²¼¤Î¥­¡¼¤Ï¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¡¢¥Õ¥ì¡¼¥à¤ÇÍøÍѤǤ­¤ë + drawable ¤Î¿¼¤µ¤ò»ØÄꤹ¤ë¡£
  • #Mdrawable. ÃÍ¤Ï Drawable ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ - ¥­¡¼ #Mdisplay ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤â»ØÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£À¸À®¤µ - ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤¾å¤Î»ØÄꤵ¤ì¤¿ drawable ¤ÈƱ - ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£ + ¥­¡¼ #Mdisplay ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤â»ØÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£ + À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤¾å¤Î»ØÄꤵ¤ì¤¿ drawable + ¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£ - ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mscreen ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵ - »ë¤µ¤ì¤ë¡£ + ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mscreen ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
  • #Mwidget. ÃÍ¤Ï Widget ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ - À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È - ¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£ + À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä + drawable ¤ËÍѤ¤¤é¤ì¤ë¡£ ¥­¡¼ #Mface ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤¬¤Ê¤±¤ì¤Ð¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤Ï¤³¤Î ¥¦¥£¥¸¥§¥Ã¥È¤Î¥ê¥½¡¼¥¹¤«¤éºî¤é¤ì¤ë¡£ @@ -515,26 +581,34 @@ MSymbol Mx, Mgd;
  • #Mscreen. ÃÍ¤Ï (Screen *) ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ - À¸À®¤·¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ò»ý¤Á¡¢ - ¥¹¥¯¥ê¡¼¥ó¤Î¥Ç¥Õ¥©¥ë¥È¤Î¿¼¤µ¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£ + À¸À®¤·¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ò»ý¤Á¡¢¥¹¥¯¥ê¡¼¥ó¤Î¥Ç¥Õ¥©¥ë¥È¤Î¿¼¤µ¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£ - ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mdisplay ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵ - »ë¤µ¤ì¤ë¡£ + ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mdisplay ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
  • #Mdisplay. ÃÍ¤Ï (Display *) ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ - À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥Ç¥£¥¹¥×¥ì¥¤¤Î¥Ç¥Õ¥©¥ë¥È¥¹¥¯¥ê¡¼¥ó¤È - Ʊ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ädrawables ¤ËÍѤ¤¤é¤ì¤ë¡£ + À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥Ç¥£¥¹¥×¥ì¥¤¤Î¥Ç¥Õ¥©¥ë¥È¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ädrawables ¤ËÍѤ¤¤é¤ì¤ë¡£
  • #Mcolormap. ÃÍ¤Ï (Colormap) ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£ À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥«¥é¡¼¥Þ¥Ã¥×¤ò»ÈÍѤ¹¤ë¡£ +
  • #Mfont. Ãͤϡ¢#Mx, #Mfreetype, #Mxft ¤Î¤¤¤º¤ì¤«¡£ + + À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï»ØÄꤷ¤¿¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤ò»ÈÍѤ¹¤ë¡£Ãͤ¬ + #Mx ¤Ç¤¢¤ì¤Ð X ¤Î¥³¥¢¥Õ¥©¥ó¥È¡¢#Mfreetype ¤Ç¤¢¤ì¤Ð FreeType + ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¥í¡¼¥«¥ë¥Õ¥©¥ó¥È¡¢#Mxft ¤Ç¤¢¤ì¤Ð Xft + ¥é¥¤¥Ö¥é¥ê·Ðͳ¤ÇÍѤ¤¤ë¥í¡¼¥«¥ë¥Õ¥©¥ó¥È¤ò»ÈÍѤ¹¤ë¡£ + Ê£¿ô¤Î¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤ò»ÈÍѤ·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤òÊ£¿ô²ó¡¢°Û¤Ê¤ëÃͤǻØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ + »ØÄꤷ¤¿¥Ð¥Ã¥¯¥¨¥ó¥É¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ç¥Ð¥¤¥¹¤Ç¤Ï¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£ + + ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬Ìµ¤¤¾ì¹ç¤Ë¤Ï¡¢¥Ç¥Ð¥¤¥¹¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤¹¤Ù¤Æ¤Î¥Õ¥©¥ó¥È¥Ð¥Ã¥¯¥¨¥ó¥É¤òÍøÍѤ¹¤ë¡£ +
@return - À®¸ù¤¹¤ì¤Ð mframe() ¤Ï¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤± - ¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ */ + À®¸ù¤¹¤ì¤Ð mframe() ¤Ï¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð + @c NULL ¤òÊÖ¤¹¡£ */ MFrame * mframe (MPlist *plist) @@ -562,12 +636,16 @@ mframe (MPlist *plist) if (device == Mnil) { +#ifdef HAVE_FREETYPE interface = &null_interface; if (! interface->handle) { (*interface->init) (); - interface->handle = Mt; + interface->handle = (void *) 1; } +#else /* not HAVE_FREETYPE */ + MERROR (MERROR_WIN, NULL); +#endif /* not HAVE_FREETYPE */ } else { @@ -576,37 +654,40 @@ mframe (MPlist *plist) MERROR (MERROR_WIN, NULL); if (! interface->handle) { - interface->handle = dlopen (interface->library, RTLD_NOW); - if (! interface->handle) - MERROR (MERROR_WIN, NULL); - interface->init = dlsym (interface->handle, "device_init"); - interface->open = dlsym (interface->handle, "device_open"); - interface->fini = dlsym (interface->handle, "device_fini"); - if (! interface->init || ! interface->open || ! interface->fini + if (! (interface->handle = dlopen (interface->library, RTLD_NOW)) + || ! (*(void **) (&interface->init) + = dlsym (interface->handle, "device_init")) + || ! (*(void **) (&interface->open) + = dlsym (interface->handle, "device_open")) + || ! (*(void **) (&interface->fini) + = dlsym (interface->handle, "device_fini")) || (*interface->init) () < 0) { - dlclose (interface->handle); + fprintf (stderr, "%s\n", (char *) dlerror ()); + if (interface->handle) + dlclose (interface->handle); MERROR (MERROR_WIN, NULL); } } } M17N_OBJECT (frame, free_frame, MERROR_FRAME); - if (! (frame->device = (*interface->open) (frame, plist))) + if ((*interface->open) (frame, plist) < 0) { free (frame); MERROR (MERROR_WIN, NULL); } + if (! mframe_default) + mframe_default = frame; + frame->face = mface (); MPLIST_DO (pl, plist) if (MPLIST_KEY (pl) == Mface) mface_merge (frame->face, (MFace *) MPLIST_VAL (pl)); mface__update_frame_face (frame); - - if (! mframe_default) - mframe_default = frame; - + frame->font + = frame->rface->rfont ? (MFont *) frame->rface->rfont : NULL; if (plist_created) M17N_OBJECT_UNREF (plist); return frame; @@ -623,17 +704,17 @@ mframe (MPlist *plist) @verbatim - key type of value meaning of value - --- ------------- ---------------- - Mface MFace * The default face. + key type of value meaning of value + --- ------------- ---------------- + Mface MFace * The default face. - Mfont MFont * The default font. + Mfont MFont * The default font. - Mfont_width int Width of the default font. + Mfont_width int Width of the default font. - Mfont_ascent int Ascent of the default font. + Mfont_ascent int Ascent of the default font. - Mfont_descent int Descent of the default font. + Mfont_descent int Descent of the default font. @endverbatim @@ -641,38 +722,38 @@ mframe (MPlist *plist) @verbatim - key type of value meaning of value - --- ------------- ---------------- - Mdisplay Display * Display associated with the frame. + key type of value meaning of value + --- ------------- ---------------- + Mdisplay Display * Display associated with the frame. - Mscreen int Screen number of a screen associated - with the frame. + Mscreen int Screen number of a screen associated + with the frame. - Mcolormap Colormap Colormap of the frame. + Mcolormap Colormap Colormap of the frame. - Mdepth unsigned Depth of the frame. + Mdepth unsigned Depth of the frame. @endverbatim */ /***ja @brief ¥Õ¥ì¡¼¥à¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹. - ´Ø¿ô mframe_get_prop () ¤Ï¥Õ¥ì¡¼¥à $FRAME ¤Î¥­¡¼ $KEY ¤ò»ý¤Ä¥×¥í¥Ñ - ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£Í­¸ú¤Ê¥­¡¼¤È¤½¤ÎÃͤϰʲ¼¤ÎÄ̤ꡣ + ´Ø¿ô mframe_get_prop () ¤Ï¥Õ¥ì¡¼¥à $FRAME ¤Î¥­¡¼ $KEY + ¤ò»ý¤Ä¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£Í­¸ú¤Ê¥­¡¼¤È¤½¤ÎÃͤϰʲ¼¤ÎÄ̤ꡣ @verbatim - ¥­¡¼ Ãͤη¿ ÃͤΰÕÌ£ - --- ------------- ---------------- - Mface MFace * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹ + ¥­¡¼ Ãͤη¿ ÃͤΰÕÌ£ + --- ------------- ---------------- + Mface MFace * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹ - Mfont MFont * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È + Mfont MFont * ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È - Mfont_width int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤ÎÉý + Mfont_width int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤ÎÉý - Mfont_ascent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î ascent + Mfont_ascent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î ascent - Mfont_descent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î descent + Mfont_descent int ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥©¥ó¥È¤Î descent @endverbatim @@ -680,16 +761,16 @@ mframe (MPlist *plist) @verbatim - ¥­¡¼ Ãͤη¿ ÃͤΰÕÌ£ - --- ------------- ---------------- - Mdisplay Display * ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤ + ¥­¡¼ Ãͤη¿ ÃͤΰÕÌ£ + --- ------------- ---------------- + Mdisplay Display * ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤ - Mscreen int ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥¹¥¯¥ê¡¼¥ó + Mscreen int ¥Õ¥ì¡¼¥à¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥¹¥¯¥ê¡¼¥ó ¤Î¥¹¥¯¥ê¡¼¥ó¥Ê¥ó¥Ð - Mcolormap Colormap ¥Õ¥ì¡¼¥à¤Î¥«¥é¡¼¥Þ¥Ã¥× + Mcolormap Colormap ¥Õ¥ì¡¼¥à¤Î¥«¥é¡¼¥Þ¥Ã¥× - Mdepth unsigned ¥Õ¥ì¡¼¥à¤Î¿¼¤µ + Mdepth unsigned ¥Õ¥ì¡¼¥à¤Î¿¼¤µ @endverbatim */ @@ -700,9 +781,9 @@ mframe_get_prop (MFrame *frame, MSymbol key) if (key == Mface) return frame->face; if (key == Mfont) - return &frame->rface->rfont->font; + return frame->font; if (key == Mfont_width) - return (void *) (frame->space_width); + return (void *) (frame->average_width); if (key == Mfont_ascent) return (void *) (frame->ascent); if (key == Mfont_descent) @@ -721,9 +802,8 @@ mframe_get_prop (MFrame *frame, MSymbol key) /***ja @brief ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à. - ³°ÉôÊÑ¿ô #mframe_default ¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ý - ¤Ä¡£¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ï¡¢ºÇ½é¤Ë mframe () ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤­¤Ë - ºî¤é¤ì¤ë¡£ */ + ³°ÉôÊÑ¿ô #mframe_default ¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ý¤Ä¡£ + ¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥ì¡¼¥à¤Ï¡¢ºÇ½é¤Ë mframe () ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È¤­¤Ëºî¤é¤ì¤ë¡£ */ MFrame *mframe_default;