*** empty log message ***
[m17n/m17n-lib.git] / src / m17n-gui.c
index d13d248..5903bf5 100644 (file)
@@ -1,5 +1,5 @@
 /* m17n-gui.c -- body of the GUI API.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -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
@@ -88,7 +88,7 @@ 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) ();
@@ -125,9 +125,11 @@ register_device_library (MSymbol name, char *lib)
   MDeviceLibraryInterface *interface;
 
   MSTRUCT_CALLOC (interface, MERROR_WIN);
-  interface->library = malloc (strlen (lib) 
+  interface->library = malloc (strlen (M17N_MODULE_DIR) + 1
+                              + strlen (lib) 
                               + strlen (DLOPEN_SHLIB_EXT) + 1);
-  sprintf (interface->library, "%s%s", lib, DLOPEN_SHLIB_EXT);
+  sprintf (interface->library, "%s/%s%s", M17N_MODULE_DIR, lib,
+          DLOPEN_SHLIB_EXT);
   if (! device_library_list)
     device_library_list = mplist ();
   mplist_add (device_library_list, name, interface);
@@ -237,12 +239,13 @@ static MDeviceLibraryInterface null_interface =
 void
 m17n_init_win (void)
 {
-  int mdebug_mask = MDEBUG_INIT;
+  int mdebug_flag = MDEBUG_INIT;
 
   merror_code = MERROR_NONE;
   if (m17n__gui_initialized++)
     return;
   m17n_init ();
+  m17n_init_flt ();
   if (merror_code != MERROR_NONE)
     {
       m17n__gui_initialized--;
@@ -297,7 +300,7 @@ m17n_init_win (void)
 void
 m17n_fini_win (void)
 {
-  int mdebug_mask = MDEBUG_FINI;
+  int mdebug_flag = MDEBUG_FINI;
   MPlist *plist;
 
   if (m17n__gui_initialized == 0
@@ -321,7 +324,10 @@ m17n_fini_win (void)
     }
 #ifdef HAVE_FREETYPE
   if (null_interface.handle)
-    (*null_interface.fini) ();
+    {
+      (*null_interface.fini) ();
+      null_interface.handle = NULL;
+    }
 #endif /* not HAVE_FREETYPE */
   M17N_OBJECT_UNREF (device_library_list);
   minput__win_fini ();
@@ -338,6 +344,7 @@ m17n_fini_win (void)
   MDEBUG_POP_TIME ();
   MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the gui modules."));
   MDEBUG_POP_TIME ();
+  m17n_fini_flt ();
   m17n_fini ();
 }
 
@@ -367,8 +374,8 @@ m17n_fini_win (void)
     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.  */
+    @b Mdevice, @b Mdisplay, @b Mscreen, @b Mdrawable, @b Mdepth, and
+    @b Mcolormap are also keys of a frame property.  */
 
 /***ja
     @name ÊÑ¿ô¡§ ¥Õ¥ì¡¼¥à¥Ñ¥é¥á¡¼¥¿ÍÑ¥­¡¼
@@ -376,8 +383,8 @@ m17n_fini_win (void)
     ¥Õ¥ì¡¼¥à¤òÀ¸À®¤¹¤ëºÝ¤Î¥Ñ¥é¥á¡¼¥¿¤ËÍѤ¤¤ë¥·¥ó¥Ü¥ë¡£¾Ü¤·¤¯¤Ï´Ø¿ô
     mframe () ¤ÎÀâÌÀ»²¾È¡£
 
-    #Mdevice¡¢ #Mdisplay¡¢ #Mscreen¡¢ #Mdrawable¡¢ #Mdepth¡¢#Mcolormap
-    ¤Ï¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤â¤¢¤ë¡£  */
+    @b Mdevice¡¢ @b Mdisplay¡¢ @b Mscreen¡¢ @b Mdrawable¡¢ @b Mdepth¡¢
+    @b Mcolormap ¤Ï¥Õ¥ì¡¼¥à¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤Ç¤â¤¢¤ë¡£  */
 
 /*=*/
 
@@ -420,14 +427,14 @@ MSymbol Mfont_descent;
 
     <ul>
 
-    <li> #Mdevice, the value must be one of #Mx, #Mgd, and #Mnil.
+    <li> @b Mdevice, the value must be one of #Mx, @b 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
+    If the value is @b 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.
@@ -443,23 +450,23 @@ MSymbol Mfont_descent;
 
     </ul>
 
-    In addition, if the value of the key #Mdevice is #Mx, the
+    In addition, if the value of the key @b 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.
 
     <ul>
 
-    <li> #Mdrawable, the value type must be <tt>Drawable</tt>.
+    <li> @b Mdrawable, the value type must be <tt>Drawable</tt>.
 
-    A parameter of key #Mdisplay must also be specified.  The
+    A parameter of key @b Mdisplay must also be specified.  The
     created frame can be used for drawables whose root window and
     depth are the same as those of the specified drawable on the
     specified display.
 
-    When this parameter is specified, the parameter of key #Mscreen
+    When this parameter is specified, the parameter of key @b Mscreen
     is ignored.
 
-    <li> #Mwidget, the value type must be <tt>Widget</tt>.
+    <li> @b Mwidget, the value type must be <tt>Widget</tt>.
 
     The created frame can be used for drawables whose root window and
     depth are the same as those of the specified widget.
@@ -467,34 +474,34 @@ MSymbol Mfont_descent;
     If a parameter of key #Mface is not specified, the default face
     is created from the resources of the widget.
 
-    When this parameter is specified, the parameters of key #Mdisplay,
-    #Mscreen, #Mdrawable, #Mdepth are ignored.
+    When this parameter is specified, the parameters of key @b Mdisplay,
+    @b Mscreen, @b Mdrawable, @b Mdepth are ignored.
 
-    <li> #Mdepth, the value type must be <tt>unsigned</tt>.
+    <li> @b Mdepth, the value type must be <tt>unsigned</tt>.
 
     The created frame can be used for drawables of the specified
     depth.
 
-    <li> #Mscreen, the value type must be <tt>(Screen *)</tt>.
+    <li> @b Mscreen, the value type must be <tt>(Screen *)</tt>.
 
     The created frame can be used for drawables whose root window is
     the same as the root window of the specified screen, and depth is
     the same at the default depth of the screen.
 
-    When this parameter is specified, parameter of key #Mdisplay is
+    When this parameter is specified, parameter of key @b Mdisplay is
     ignored.
 
-    <li> #Mdisplay, the value type must be <tt>(Display *)</tt>.
+    <li> @b Mdisplay, the value type must be <tt>(Display *)</tt>.
 
     The created frame can be used for drawables whose root window is
     the same as the root window for the default screen of the display,
     and depth is the same as the default depth of the screen.
 
-    <li> #Mcolormap, the value type must be <tt>(Colormap)</tt>.
+    <li> @b Mcolormap, the value type must be <tt>(Colormap)</tt>.
 
     The created frame uses the specified colormap.
 
-    <li> #Mfont, the value must be #Mx, #Mfreetype, or #Mxft.
+    <li> @b 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
@@ -525,14 +532,14 @@ MSymbol Mfont_descent;
 
     <ul>
 
-    <li> #Mdevice. ÃͤϠ#Mx, #Mgd, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mdevice. ÃͤϠ#Mx, @b Mgd, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
     Ãͤ¬ #Mx ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï X ¥¦¥£¥ó¥É¥¦¥·¥¹¥Æ¥àÍѤǤ¢¤ë¡£
     ¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô #MDrawWindow ¤Ï¡¢ @c Window
     ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤ÏÆɤ߽ñ¤­¤È¤â¤Ë²Äǽ¤Ç¤¢¤ê¡¢¤¹¤Ù¤Æ¤ÎGUI 
     ´Ø¿ô¤¬»ÈÍѤǤ­¤ë¡£
 
-    Ãͤ¬ #Mgd ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï GD 
+    Ãͤ¬ @b Mgd ¤Ê¤é¤Ð¡¢¿·¤·¤¤¥Õ¥ì¡¼¥à¤Ï GD 
     ¥é¥¤¥Ö¥é¥ê¤Î¥¤¥á¡¼¥¸¥ª¥Ö¥¸¥§¥¯¥ÈÍѤǤ¢¤ë¡£¤³¤Î¥Õ¥ì¡¼¥à¤È¶¦¤Ë»ØÄꤵ¤ì¤¿°ú¿ô
     #MDrawWindow ¤Ï¡¢ @c gdImagePtr ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£¥Õ¥ì¡¼¥à¤Ï½ñ¤­½Ð¤·ÀìÍѤǤ¢¤ê¡¢
     minput_ ¤Ç»Ï¤Þ¤ë̾Á°¤Î´Ø¿ô¤Ï»ÈÍѤǤ­¤Ê¤¤¡£
@@ -547,21 +554,21 @@ MSymbol Mfont_descent;
 
     </ul>
 
-    ¤³¤ì¤é¤Î¥­¡¼¤Ë²Ã¤¨¡¢#Mdevice ¤Î¥­¡¼¤¬ #Mx 
+    ¤³¤ì¤é¤Î¥­¡¼¤Ë²Ã¤¨¡¢@b Mdevice ¤Î¥­¡¼¤¬ #Mx 
     ¤Ç¤¢¤ë¾ì¹ç¤Ë¸Â¤ê°Ê²¼¤Î¥­¡¼¤âǧ¼±¤µ¤ì¤ë¡£°Ê²¼¤Î¥­¡¼¤Ï¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¡¢¥Õ¥ì¡¼¥à¤ÇÍøÍѤǤ­¤ë 
     drawable ¤Î¿¼¤µ¤ò»ØÄꤹ¤ë¡£
 
     <ul>
 
-    <li> #Mdrawable. ÃͤϠ<tt>Drawable</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mdrawable. ÃͤϠ<tt>Drawable</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
-    ¥­¡¼ #Mdisplay ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤â»ØÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
+    ¥­¡¼ @b Mdisplay ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤â»ØÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ë¡£
     À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥×¥ì¥¤¾å¤Î»ØÄꤵ¤ì¤¿ drawable 
     ¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
 
-    ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mscreen ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
+    ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@b Mscreen ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
 
-    <li> #Mwidget. ÃͤϠ<tt>Widget</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mwidget. ÃͤϠ<tt>Widget</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
     À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤È¿¼¤µ¤ò»ý¤Ä
     drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
@@ -569,24 +576,24 @@ MSymbol Mfont_descent;
     ¥­¡¼ #Mface ¤ò»ý¤Ä¥Ñ¥é¥á¡¼¥¿¤¬¤Ê¤±¤ì¤Ð¡¢¥Ç¥Õ¥©¥ë¥È¤Î¥Õ¥§¡¼¥¹¤Ï¤³¤Î
     ¥¦¥£¥¸¥§¥Ã¥È¤Î¥ê¥½¡¼¥¹¤«¤éºî¤é¤ì¤ë¡£
 
-    ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mdisplay, #Mscreen, #Mdrawable,
-    #Mdepth ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
+    ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@b Mdisplay, @b Mscreen, @b Mdrawable,
+    @b Mdepth ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
 
-    <li> #Mdepth. ÃͤϠ<tt>unsigned</tt>  ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mdepth. ÃͤϠ<tt>unsigned</tt>  ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
     À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¿¼¤µ¤Î drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
 
-    <li> #Mscreen. ÃͤϠ<tt>(Screen *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mscreen. ÃͤϠ<tt>(Screen *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
     À¸À®¤·¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ò»ý¤Á¡¢¥¹¥¯¥ê¡¼¥ó¤Î¥Ç¥Õ¥©¥ë¥È¤Î¿¼¤µ¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ä drawable ¤ËÍѤ¤¤é¤ì¤ë¡£
 
-    ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢#Mdisplay ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
+    ¤³¤Î¥Ñ¥é¥á¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢@b Mdisplay ¤ò¥­¡¼¤È¤¹¤ë¥Ñ¥é¥á¡¼¥¿¤Ï̵»ë¤µ¤ì¤ë¡£
 
-    <li> #Mdisplay. ÃͤϠ<tt>(Display *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mdisplay. ÃͤϠ<tt>(Display *)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
     À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥Ç¥£¥¹¥×¥ì¥¤¤Î¥Ç¥Õ¥©¥ë¥È¥¹¥¯¥ê¡¼¥ó¤ÈƱ¤¸¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤ÈƱ¤¸¿¼¤µ¤ò»ý¤Ädrawables ¤ËÍѤ¤¤é¤ì¤ë¡£
 
-    <li> #Mcolormap. ÃͤϠ<tt>(Colormap)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
+    <li> @b Mcolormap. ÃͤϠ<tt>(Colormap)</tt> ·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
 
     À¸À®¤µ¤ì¤¿¥Õ¥ì¡¼¥à¤Ï¡¢»ØÄꤷ¤¿¥«¥é¡¼¥Þ¥Ã¥×¤ò»ÈÍѤ¹¤ë¡£