X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fm17n-gui.c;h=d6e1c8e68ee5eb52a330cae4b7fa58d3e4d8382b;hb=3dbe5210009c5328999362178544d143a8f7b992;hp=cac713a1a0bdf9b818ba625b10cc4891d5af1c2d;hpb=8b6752e826a02f1a3efa94262836caa98333ee23;p=m17n%2Fm17n-lib.git diff --git a/src/m17n-gui.c b/src/m17n-gui.c index cac713a..d6e1c8e 100644 --- a/src/m17n-gui.c +++ b/src/m17n-gui.c @@ -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 ¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤Æ¤ª¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤ÎľÀܤÎÍøÍѤòǰƬ¤Ë¤ª¤¤¤¿¤â¤Î¤Ç¤Ï¤Ê¤¤¡£ */ /*=*/ @@ -79,8 +78,6 @@ #include "fontset.h" #include "face.h" -static int win_initialized; - #ifndef DLOPEN_SHLIB_EXT #define DLOPEN_SHLIB_EXT ".so" #endif @@ -232,31 +229,28 @@ static MDeviceLibraryInterface null_interface = /* Internal API */ -MSymbol Mfreetype; - -/*** @} */ -#endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */ - /* External API */ -int +void m17n_init_win (void) { int mdebug_mask = MDEBUG_INIT; - if (win_initialized++) - return 0; + merror_code = MERROR_NONE; + if (m17n__gui_initialized++) + return; m17n_init (); if (merror_code != MERROR_NONE) - return -1; + { + 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"); @@ -269,9 +263,6 @@ m17n_init_win (void) Mdepth = msymbol ("depth"); Mwidget = msymbol ("widget"); - register_device_library (Mx, "libm17n-X"); - register_device_library (Mgd, "libm17n-gd"); - MDEBUG_PUSH_TIME (); if (mfont__init () < 0) goto err; @@ -289,64 +280,66 @@ m17n_init_win (void) goto err; MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize input-win module.")); mframe_default = NULL; - return 0; + + 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 -1; } 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); + (*interface->fini) (); + dlclose (interface->handle); } + free (interface->library); + } #ifdef HAVE_FREETYPE - if (null_interface.handle) - (*null_interface.fini) (); + if (null_interface.handle) + (*null_interface.fini) (); #endif /* not HAVE_FREETYPE */ - M17N_OBJECT_UNREF (device_library_list); - 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 (); - } + M17N_OBJECT_UNREF (device_library_list); + 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 (); m17n_fini (); } +/*** @} */ +#endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */ + /*** @addtogroup m17nFrame */ /***en @brief A @e frame is an object corresponding to the graphic device. @@ -354,13 +347,12 @@ m17n_fini_win (void) A @e frame is an object of the type #MFrame to hold various information about each display/input device. Almost all m17n GUI functions require a pointer to a frame as an argument. */ - /***ja @brief @e ¥Õ¥ì¡¼¥à ¤È¤Ï¥°¥é¥Õ¥£¥Ã¥¯¥Ç¥Ð¥¤¥¹¤ËÂбþ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë. - @e ¥Õ¥ì¡¼¥à ¤È¤Ï #MFrame ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢¸Ä¡¹¤Îɽ¼¨¡¿ÆþÎ촂 - ¥Ð¥¤¥¹¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î m17n GUI - ´Ø¿ô¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÍ׵᤹¤ë¡£ */ + @e ¥Õ¥ì¡¼¥à ¤È¤Ï #MFrame + ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢¸Ä¡¹¤Îɽ¼¨¡¿ÆþÎϥǥХ¤¥¹¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£ + ¤Û¤È¤ó¤É¤¹¤Ù¤Æ¤Î m17n GUI´Ø¿ô¤Ï¡¢°ú¿ô¤È¤·¤Æ¥Õ¥ì¡¼¥à¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÍ׵᤹¤ë¡£ */ /*** @{ */ /*=*/ @@ -368,7 +360,7 @@ m17n_fini_win (void) /***en @name Variables: Keys of frame parameter - These are the symbols to use in a parameter to creat a frame. See + 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 @@ -387,7 +379,7 @@ m17n_fini_win (void) MSymbol Mdevice, Mdisplay, Mscreen, Mdrawable, Mdepth, Mcolormap, Mwidget; -MSymbol Mx, Mgd; +MSymbol Mgd; /*=*/ @@ -498,6 +490,19 @@ MSymbol Mfont_descent; The created frame uses the specified colormap. +