SUBJECT :±¹Á¦È­µÈ Motif ÇÁ·Î±×·¥À» À§ÇÑ ±âÃÊ ¾È³»¼­



\Copyright(1992, Çѱ¹°úÇбâ¼ú¿ø GUI ÄÁ¼Ò½Ã¾ö ÇÁ·ÎÁ§Æ®)
\Copyright  (1993, Çö´ëÀüÀÚ »ê¾÷ ÁÖ½Äȸ»ç)

½ÃÀÛÇϸ鼭

ÀÌ ¾È³»¼­´Â Motif ÇÁ·Î±×·¡¹ÖÀ» Çغ» °æÇèÀÌ
ÀÖ´Â »ç¶÷ÀÌ ±¹Á¦È­µÈ Motif ÇÁ·Î±×·¥À» ½ÃÀÛÇϴµ¥
µµ¿òÀ» ÁÖ°íÀÚ ¾²¿©Á³´Ù. µû¶ó¼­ ÀÌ ¾È³»¼­´Â
Motif³ª C ÇÁ·Î±×·¥¿¡ °æÇèÀÌ ÀÖ´Â »ç¶÷µéÀ»
°¡Á¤ÇÑ´Ù.

\section*{Ã¥ÀÇ ³»¿ë}

Motif 1.2¿¡¼­´Â ±¹Á¦È­µÈ ÀÀ¿ëÇÁ·Î±×·¥ÀÌ
ÀÛ¼ºµÉ ¼ö ÀÖµµ·Ï »ó´çÇÑ º¯È­°¡ ÀÖ¾ú´Ù. ´ëºÎºÐÀÇ
º¯È­´Â ÅؽºÆ® À§ÁþÀ̳ª ÅؽºÆ® Çʵå
À§Áþ¿¡ ÀÖÀ¸¸ç Compound String ºÎºÐ¿¡¼­´Â
X11R5¿¡¼­ Á¦°øÇÏ´Â ÆùÆ®ÁýÇÕÀ» Áö¿øÇϱâ À§ÇÑ
º¯È­°¡ ÀÖ´Ù. ¶ÇÇÑ input method¸¦
Áö¿øÇϱâ À§ÇÑ ÅøŶ ·¹À̾îÀÇ ¶óÀ̺귯¸®°¡
Áö¿øµÈ´Ù.  (±¹Á¦È­¿Í °ü·ÃÇÏ¿© Motif 1.2¿¡¼­ÀÇ
ÀÚ¼¼ÇÑ Á¤º¸¸¦ ¿øÇÏ´Â ºÐÀº Implementer's
Guide¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù.)

±×·¯³ª ½ÇÁ¦·Î ÀÌ·¯ÇÑ º¯È­´Â ÀÀ¿ëÇÁ·Î±×·¥ÀÇ
ÀÔÀå¿¡¼­´Â Å©°Ô ½Å°æ¾²Áö ¾Ê¾Æµµ µÈ´Ù. Áï,
±âÁ¸ÀÇ Motif 1.1¿¡ ±â¹ÝÀ» µÐ ÀÀ¿ëÇÁ·Î±×·¥ÀÌ
Å« º¯È­¾øÀÌ Motif 1.2 ȯ°æÀ¸·Î ¿Å¾Æ°¥ ¼ö
ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù.
ÀÌ ¾È³»¼­¿¡¼­´Â ÀÀ¿ëÇÁ·Î±×·¡¸Ó°¡
Motif 1.2¿¡¼­ ¾î´À ƯÁ¤ ¾ð¾î¸¦ ±¸ÇöÇÏ°íÀÚ
ÇÒ ¶§ ¾Ë¾Æ¾ß ÇÏ´Â ³»¿ëÀ» ¸îÀå¿¡ ³ª´©¾î¼­ ´Ù·ç°í ÀÖ´Ù.

ÀÌ ¾È³»¼­ÀÇ ³»¿ëÀº ´ÙÀ½°ú °°ÀÌ ²Ù¸çÁ® ÀÖ´Ù.

2 Àå  MotifÀÇ ±¹Á¦È­¿¡ ´ëÇÑ ¼³¸íÀ» ÇÏ°í ÀÖ´Ù.
3 Àå  ·ÎÄÉÀÏÀÇ ÁöÁ¤¿¡ °üÇÏ¿© ¼³¸íÇÑ´Ù.
4 Àå  Compound StringÀ» »ç¿ëÇÏ´Â ¹æ¹ý¿¡ ´ëÇؼ­ ¼³¸íÇÑ´Ù.
5 Àå  ÅؽºÆ® À§Áþ¿¡ ´ëÇؼ­ ¼³¸íÇÏ°í ÀÖ´Ù.
6 Àå  ÇϳªÀÇ ¿ÏÀüÇÑ ÇÁ·Î±×·¥ÀÇ ¿¹¸¦ º¸ÀδÙ.

\chapter 2 {MotifÀÇ ±¹Á¦È­}

\section{±¹Á¦È­¿Í Áö¿ªÈ­ÀÇ Çʿ伺}

ÄÄÇ»ÅÍ°¡ ¼¼°è ¿©·¯ ³ª¶ó¿¡ º¸±ÞµÊ¿¡ µû¶ó,
ÇÁ·Î±×·¥À» ¸¸µå´Â »ç¶÷µéÀº ÀÚ½ÅÀÇ
ÇÁ·Î±×·¥¿¡ ´Ù¸¥³ª¶óÀÇ ¾ð¾î¸¦ Áö¿øÇϱâ
À§ÇÏ¿© Çѱ¹¿ë, ÀϺ»¿ë, µ¶ÀÏ¿ë µî ¿©·¯°³ÀÇ
¹öÁ¯À» ¸¸µé¾î ¿Ô´Ù. ±×·¯³ª ÀÌ ÀÛ¾÷Àº
°°Àº ÇÁ·Î±×·¥ÀÏÁö¶óµµ ´Ù¸¥ ¾ð¾î¸¦
Áö¿øÇϱâ À§ÇÏ¿© ¼Ò½ºÄڵ带 º¯°æÇØ¾ß µÇ±â
¶§¹®¿¡ °¢°¢ÀÇ ¹öÁ¯µéÀÌ È£È¯¼ºÀÌ ¾øÀ»
»Ó ¾Æ´Ï¶ó ¼ÒÇÁÆ®¿þ¾îÀÇ °³¹ß¿¡ ÀÌÁß
»ïÁßÀÇ ³ë·ÂÀÌ µé°Ô µÈ´Ù.

±¹Á¦È­´Â ÇÁ·Î±×·¥À» ¾î´À ƯÁ¤ ¾ð¾î³ª
Áö¿ªÀû Ư¼ö¼º¿¡ ±¹ÇѵÇÁö ¾Êµµ·Ï ¸¸µå´Â °ÍÀÌ´Ù.
Áï, °¢°¢ÀÇ ¾ð¾î¿¡¼­ ÇÊ¿äÇÑ ¿ä¼Ò¸¦
¼Ò½ºÀÇ º¯°æ¾øÀÌ Áö¿øÇÒ ¼ö ÀÖµµ·Ï ÇÏ´Â
±¸Á¶¸¦ ¸¸µå´Â °ÍÀ» ¸»ÇÑ´Ù. Áö¿ªÈ­´Â ÀÌ·¸°Ô
±¹Á¦È­µÈ ÇÁ·Î±×·¥¿¡ ½ÇÁ¦·Î ƯÁ¤
¾ð¾î³ª Áö¿ªÀû Ư¼ö¼ºÀ» Áö¿øÇÒ ¼ö ÀÖµµ·Ï
µ¥ÀÌŸº£À̽º³ª ¼­ºñ½º¸¦ Á¦°øÇØÁØ´Ù.

\section{±¹Á¦È­µÈ MotifÀÇ ±¸Á¶}

ÅؽºÆ® ÀÔ·ÂÀº XmIm ¶óÀ̺귯¸®¸¦
ÅëÇÏ¿© X11R5¿¡¼­ Á¦°øÇÏ´Â ±â´ÉÀ» ÀÌ¿ëÇÏ¿©
¹Þ¾ÆµéÀÌ°Ô µÇ°í º¸¿ÏµÈ Compound
String ±â´ÉÀ» ÀÌ¿ëÇÏ¿© ÁÖ·Î ¸Þ´ºÀÇ ¶óº§À̳ª
¸Þ¼¼Áöµî¿¡¼­ ´Ù¸¥¾ð¾î¸¦ Áö¿øÇÒ ¼ö
ÀÖµµ·Ï ÇÑ´Ù.


\chapter 3 {·ÎÄÉÀÏÀÇ ÁöÁ¤}

\section{setlocale}

±¹Á¦È­µÈ ÀÀ¿ëÇÁ·Î±×·¥Àº ·ÎÄÉÀÏÀ» Á¤ÀÇÇÏ´Â
°ÍºÎÅÍ ½ÃÀÛÇÏ°Ô µÈ´Ù. setlocale()Àº
POSIX¿¡ Á¤ÀÇµÈ ·ÎÄÉÀÏ Á¤ÀÇ ÇÔ¼öÀÌ´Ù.
Çü½ÄÀº ´ÙÀ½°ú °°´Ù.

    #include 

    char *setlocale(category, locale)
        int category;
        char *locale;

    category  ·ÎÄÉÀÏÀ» Á¤ÇÒ ¹üÁÖ¸¦ ¸»ÇÑ´Ù.
              LC_CTYPE, LC_COLLATE, LC_CTIME,
              LC_NUMERIC, LC_MONETARY, LC_MESSAGES
                °°Àº ¿©·¯ ¹üÁÖ°¡ ÀÖ´Ù.
    locale    ·ÎÄÉÀÏÀ» ÁöÁ¤ÇÏ´Â ¹®ÀÚ¿­ÀÌ´Ù.
              ¸¸¾à ``''À» ÁöÁ¤Çϸé category¿Í
                °°Àº À̸§ÀÇ È¯°æº¯¼ö¿¡¼­ °ªÀ» °¡Á®¿Â´Ù.
                ±× À̸§ÀÇ È¯°æº¯¼ö°¡
                ¾øÀ¸¸é LANGÀ̶ó´Â ȯ°æº¯¼ö¿¡¼­ ±× °ªÀ»
                °¡Á®¿Â´Ù.

½ÇÁ¦·Î ÇÁ·Î±×·¥¿¡¼­´Â ´ÙÀ½°ú °°ÀÌ ¾²´Â °æ¿ì°¡ ¸¹´Ù.

    setlocale(LC_CTYPE, "");


¿©±â¼­ LC_CTYPEÀº ¹®ÀÚÀÇ º¯È¯°ú ºÐ·ù¿¡
¿µÇâÀ» ÁÖ´Â ·ÎÄÉÀÏ ¹üÁÖ·Î ±¹Á¦È­µÈ
Motif´Â ÁÖ·Î ÀÌ ·ÎÄÉÀÏ ¹üÁÖÀÇ ¿µÇâÀ»
¹Þ´Â´Ù. °ªÀ¸·Î ``''À» ÁöÁ¤ÇÏ¿´À¸¹Ç·Î ȯ°æº¯¼ö
LC_CTYPE¿¡¼­ °ªÀ» °¡Á®¿Â´Ù. ¸¸¾à LC_CTYPEÀÌ
Á¤ÀǵÇÁö ¾Ê¾ÒÀ¸¸é ȯ°æº¯¼ö LANG¿¡¼­
±× °ªÀ» °¡Á®¿Â´Ù.

\chapter 4 {Compound StringÀÇ »ç¿ë}

±¹Á¦È­µÈ ÀÀ¿ëÇÁ·Î±×·¥À» ¸¸µé °æ¿ì º¸Åë µÎ°³ ÀÌ»óÀÇ
¹®ÀÚÁýÇÕÀ» ¸¸µé¾î »ç¿ëÇÏ°Ô µÈ´Ù
(¿¹¸¦ µé¸é, Çѱ۰ú ¿µ¾î).
Motif 1.2¿¡¼­´Â compound stringÀÇ ÇϳªÀÇ
¼¼±×¸ÕÆ®°¡ ¿©·¯°³ÀÇ ¹®ÀÚÁýÇÕÀ¸·Î
µÇ¾îÀÖ´Â ÅؽºÆ®¸¦ Áö¿øÇÑ´Ù. Áï, compound
stringÀÇ ÇϳªÀÇ ¼¼±×¸ÕÆ®´Â
ÀڽŰú °°Àº charsetÀÇ tag¸¦ Áö´Ñ ÆùÆ®
ÁýÇÕÀ¸·Î ±×·ÁÁø´Ù.
¿¹¸¦ µé¾î "Çö´ëÀüÀÚ »ê¾÷ ÁÖ½Äȸ»ç S/W R & D 
Center"¶ó´Â ¹®ÀÚ¿­À» ¶óº§ À§ÁþÀÇ
¶óº§ ½ºÆ®¸µÀ¸·Î »ç¿ëÇÏ°íÀÚ ÇÒ °æ¿ì,
¸ÕÀú ¹®ÀÚ¿­À» compound stringÀ¸·Î º¯È¯ÇÏ°í,
À̸¦ ±×¸± ¶§ »ç¿ëÇÏ´Â ÆùÆ® ¸®½ºÆ®¸¦
¸¸µå´Â µÎ ´Ü°èÀÇ ÀÛ¾÷À» ÅëÇؼ­ ÀÌ·ç¾îÁø´Ù.

\section{Compound StringÀÇ »ý¼º}

ÅؽºÆ® À§ÁþÀ» Á¦¿ÜÇÏ°í À§Áþ¿¡ ÅؽºÆ®
µ¥ÀÌŸ¸¦ ±×¸®´Â À§ÁþµéÀº (¿¹¸¦ µé¸é,
¶óº§ À§Áþ) XmStringÀ̶ó°í ÇÏ´Â µ¥ÀÌŸ
ŸÀÔÀ» ÇÊ¿ä·Î ÇÑ´Ù.  µû¶ó¼­ »ç¿ëÀÚ´Â
ÀϹÝÀûÀÎ ½ºÆ®¸µÀ» ¸ÕÀú XmStringÀ¸·Î
º¯È¯½ÃÄÑÁà¾ß ÇÑ´Ù.   ÀϹÝÀûÀÎ C ½ºÆ®¸µÀ»
XmStringÀ¸·Î º¯È¯Çϱâ À§Çؼ­ º¸Åë
XmStringCreate()À̶ó´Â
ÇÔ¼ö¸¦ »ç¿ëÇϴµ¥ ±× Çü½ÄÀº ´ÙÀ½°ú °°´Ù.

    #include 

    XmString XmStringCreate(text, charset)
        char *text;
        XmStringCharSet charset;

½ÇÁ¦ ÇÁ·Î±×·¥ÀÇ ¿¹¸¦ µé¸é ´ÙÀ½°ú °°´Ù.

    XmString xmString;

    xmString = XmStringCreate("Çö´ëÀüÀÚ S/W ¿¬±¸¼Ò Áß´ëÇü °³¹ß½Ç'',
                    ``koreanEUC'');
    .....
    XmStringFree(xmString);

ÀÌ·¸°Ô ÇÏ¿© ¸¸µé¾îÁø ½ºÆ®¸µÀº ¸®¼Ò½º
XmNlabelStringÀÇ °ªÀ¸·Î ÁöÁ¤ÇϰԵȴÙ.
¿©±â¼­ ¸¸µé¾îÁö´Â ¼¼±×¸ÕÆ®ÀÇ charsetÀº
ÀÌ ¼¼±×¸ÕÆ®¸¦ ½ÇÁ¦·Î ±×¸± ¶§ »ç¿ëÇÏ´Â
ÆùÆ® ÁýÇÕÀ» ÁöÁ¤ÇÏ´Â ÆùÆ® ¸®½ºÆ®¿¡¼­ÀÇ ÇØ´ç
ÆùÆ® ÁýÇÕÀÇ charset°ú °°¾Æ¾ß ÇÑ´Ù.
Áï, ´ÙÀ½ ´Ü°è¿¡¼­ »ý¼ºµÇ´Â ÆùÆ®
¸®½ºÆ®¿¡¼­ ``koreanEUC''¶ó´Â tag¸¦
°¡Áø ÆùÆ® ÁýÇÕ¿¡ ÀÇÇÏ¿© À§¿¡¼­ ¸¸µç
compound stringÀÌ ±×·ÁÁø´Ù.

\section{ÆùÆ® ¸®½ºÆ®ÀÇ »ý¼º}

½ÇÁ¦·Î À§¿¡¼­ ¸¸µç XmStringÀÇ ¼¼±×¸ÕÆ®¸¦
±×¸®´Âµ¥ »ç¿ëµÇ´Â ÆùÆ® ¸®½ºÆ®¸¦ ¸¸µå´Â
°úÁ¤ÀÌ´Ù.
¸ÕÀú ÆùÆ®ÁýÇÕÀ» XCreateFontSet()À» ÀÌ¿ëÇÏ¿©
¸¸µé°í À̸¦ ÀÌ¿ëÇÏ¿© ÇϳªÀÇ
ÆùÆ® ¸®½ºÆ® ¿£Ã÷¸®¸¦ ¸¸µç´Ù. À̶§ »ç¿ëÇÏ´Â
ÇÔ¼ö´Â XmFontListEntryCreate()Àε¥
±× Çü½ÄÀº ´ÙÀ½°ú °°´Ù.

    #include 

    XmFontListEntry XmFontListEntryCreate(tag, type, font)
        char *tag;
        XmFontType type;
        XtPointer font;

¿©±â¼­ tag´Â ½ÇÁ¦·Î ÀÌ ÆùÆ®ÁýÇÕÀ»
½á¼­ ±×¸®°íÀÚÇÏ´Â ÅؽºÆ® ¼¼±×¸ÕÆ®ÀÇ
tag¿Í °°¾Æ¾ß ÇÑ´Ù.  ÀÌ·¸°Ô ¸¸µé¾îÁø
ÆùÆ® ¸®½ºÆ® ¿£Ã÷¸®¸¦ À§ÁþÀÌ »ç¿ëÇÏ´Â
ÆùÆ® ¸®½ºÆ®¿¡ ³Ö´Â °úÁ¤ÀÌ ÇÊ¿äÇѵ¥
ÀÌ´Â XmFontListAppendEntry()¶ó´Â
ÇÔ¼ö¸¦ ÅëÇÏ¿© ÀÌ·ç¾îÁø´Ù.

    #include 

    XmFontList XmFontListAppendEntry(list, entry)
        XmFontList list;
        XmFontListEntry entry;

ÀÌ·¸°Ô ÇÏ¿© ¸¸µé¾îÁø ÆùÆ® ¸®½ºÆ®´Â À§ÁþÀÇ
¸®¼Ò½º XmNfontList¿¡ ÁöÁ¤ÇÏ°Ô µÈ´Ù.
ÀÌ·¯ÇÑ °úÁ¤ÀÇ ½ÇÁ¦ ÇÁ·Î±×·¥ÀÇ ¿¹¸¦ µé¸é
´ÙÀ½°ú °°´Ù.

#define FONTSET
"*-clean-bold-r-*--16-*,*-myeongjo-bold-r-*--16-*-ksc5601.1987-1"

    XFontSet fontSet;
    int missing_charset_count;
    char **missing_charset_list;
    char *def_string;
    XmFontListEntry flEntry;
    XmFontList fontList;

    fontSet = XCreateFontSet(display, FONTSET, &missing_charset_list,
            &missing_charset_count, &def_string);
    flEntry = XmFontListEntryCreate("koreanEUC", XmFONT_IS_FONTSET, fontSet);
    fontList = XmFontListAppendEntry(fontList, flEntry);

    n = 0;
    XtSetArg(args[n], XmNfontList, fontList); n++;
    XtSetValues(widget, args, n);

\section{¸®¼Ò½º ÆÄÀÏÀÇ »ç¿ë}

XmFONTLIST_DEFAULT_TAG¶ó´Â tag¸¦ °¡Áö´Â
compound stringÀº ½ÇÁ¦·Î ÀÀ¿ëÇÁ·Î±×·¥ÀÌ
¼Ò½º¾È¿¡ ÇϵåÄÚµùÀ» ÇÏÁö ¾Ê´õ¶óµµ ¸®¼Ò½º
ÆÄÀÏ¿¡ ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. ¸¶Âù°¡Áö·Î
°°Àº tag¸¦ °¡Áö´Â ÆùÆ® ¸®½ºÆ®µµ ¸®¼Ò½º ÆÄÀÏ¿¡
ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù.
À§¿¡¼­ ³ªÅ¸³­ ÄÚµå´Â ½ÇÁ¦·Î ´ÙÀ½°ú °°ÀÌ
¸®¼Ò½º ÆÄÀÏ¿¡ Ç¥ÇöÇÏ¿©µµ °°Àº È¿°ú¸¦
°®´Â´Ù.

widget name.labelString:    Çö´ëÀüÀÚ S/W ¿¬±¸¼Ò Áß´ëÇü °³¹ß½Ç
widget name.fontList:
*-clean-bold-r-*--16-*;*-myeongjo-bold-r-*--16-ksc5601.1987-1:

\chapter 5 {ÅؽºÆ® À§Áþ}

Motif1.2¿¡¼­´Â ±¹Á¦È­µÈ ÅؽºÆ® À§ÁþÀ» Á¦°øÇÑ´Ù.
ÀÌ´Â ±¹Á¦È­µÈ ÅؽºÆ® À§ÁþÀÌ ½ÇÁ¦·Î ÇѱÛÀ̳ª
ÀϺ»¾î µîÀ» ¹Ù²ÙÁö ¾Ê°íµµ ÀÀ¿ëÀ» Áö¿øÇÒ
¼ö ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. ÅؽºÆ® À§ÁþÀÇ
µ¿ÀÛÀº »ç¿ëÀÚ°¡ ȯ°æº¯¼ö¸¦ Á¤ÇÏ¸é ±×¿¡ µû¶ó
µ¿ÀÛÇϱ⠶§¹®¿¡ ÀÀ¿ëÇÁ·Î±×·¥Àº ±âÁ¸ÀÇ
API¸¦ ±×´ë·Î »ç¿ëÇÏ¿© ÇѱÛÀÌ ÀԷµǴ °ÍÀ» Áö¿øÇÒ ¼ö ÀÖ´Ù.

¸¸¾à ÀÀ¿ëÇÁ·Î±×·¥ÀÌ ³»ºÎÄÚµå·Î¼­ wide character¸¦ ¾²°íÀÚ Çϸé
»õ·Î Á¤ÀÇµÈ ÅؽºÆ® À§ÁþÀÇ
wide character public interface¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
ÀÚ¼¼ÇÑ ³»¿ëÀº Reference ManualÀ» ÂüÁ¶Çϱ⠹ٶõ´Ù.

ÅؽºÆ® À§ÁþÀ» »ç¿ëÇÒ¶§ ÇÑ°¡Áö ¾Ë¾Æ¾ß µÉ °ÍÀº
»ç¿ëÀÚ³ª ÀÀ¿ëÇÁ·Î±×·¡¸Ó°¡ ÅؽºÆ® À§ÁþÀÌ »ç¿ëÇÏ´Â
input method³ª input styleÀ» ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀÌ´Ù.
Áï, ´ÙÀ½°ú °°Àº µÎ°¡Áö ¸®¼Ò½º°¡ Á¤ÀÇµÉ ¼ö ÀÖ´Ù.

    XmNinputMethod
        Type:   String
        Default:    NULL
        Access: CSG

ÀÌ ¸®¼Ò½º´Â input methodÀÇ ·ÎÄÉÀÏ º¯ÇüÀÚ¸¦ ÁöÁ¤ÇÒ ¶§ ¾²ÀδÙ.

    XmNpreeditType
        Type:   String
        Default:    "OnTheSpot,OverTheSpot,OffTheSpot,Root"
        Access: CSG

ÀÌ ¸®¼Ò½º´Â ÀÔ·Â ½ºÅ¸ÀÏÀ» ÁöÁ¤ÇÒ ¶§ ¾²ÀδÙ.

°á±¹ »ç¿ëÀÚ³ª ÀÀ¿ëÇÁ·Î±×·¡¸Ó°¡ OffTheSpot ¹æ½ÄÀ¸·Î ÀÔ·ÂÀ» ¹Þ°íÀÚ ÇÒ °æ¿ì
¾Æ·¡¿Í °°ÀÌ ¸®¼Ò½º ÆÄÀÏ¿¡ ÁöÁ¤ÇÏ¸é µÈ´Ù.

    *preeditType: OffTheSpot

MotifÀÇ Text[Field] WidgetÀ» »ç¿ëÇÒ ¶§ ÁÖÀÇÇÒ Á¡Àº ¸¸¾à Application¿¡¼­
¿©·¯°³ÀÇ Text[Filed] WidgetÀ» ¸¸µé¾î ÀÌ°÷ Àú°÷¿¡¼­ ÀÔ·ÂÀ» ÇÒ °æ¿ì 
´Ù¸¥ Text[Field] WidgetÀ̳ª ¿ÏÀüÈ÷ ´Ù¸¥ WidgetÀ¸·Î ¿Å±â±â Àü¿¡ ¹Ýµå½Ã 
ÀԷ»óŸ¦ ¿µ¹®À¸·Î ¸ÂÃß¾î ³õ¾Æ¾ß ÇÑ´Ù´Â °ÍÀÌ´Ù.


\chapter 6 {¿ÏÀüÇÑ ¿¹}

ÀÌ Àå¿¡¼­´Â ±× µ¿¾È µû·Îµû·Î ¼³¸íÇß´ø
°ÍµéÀ» ¹­¾î¼­ ¿ÏÀüÈ÷ ½ÇÇàµÇ´Â
ÇÁ·Î±×·¥ÀÇ ¸®½ºÆ®¿Í ±×¿¡ µû¸¥ ¸®¼Ò½º
ÆÄÀÏÀ» º¸¿©ÁÜÀ¸·Î½á µ¶ÀÚ ¿©·¯ºÐÀÇ ÀÌÇظ¦
µ½°íÀÚ ÇÑ´Ù. ¾Æ·¡ÀÇ ¿¹¿¡¼­´Â ¾Õ¿¡¼­
¼³¸íµÇÁö ¾ÊÀº ºÎºÐÀÌ ¸¹Àºµ¥
ÀÌ´Â ±âº»ÀûÀ¸·Î Motif 1.1ÀÇ ÇÁ·Î±×·¥
½ºÅ¸ÀÏ°ú °°±â ¶§¹®¿¡ ¿©±â¼­ Ãß°¡·Î
¼³¸íÇÏÁö ¾Ê´Â´Ù.

/*
 * sample.c:
 *  Sample program
 */

#include 
#include 
#include 
#include 
#include 
#include 

#define FONTSET
"*-clean-bold-r-*--16-*,*-myeongjo-bold-r-*--16-*-ksc5601.1987-1"

void Quit(widget, client_data, call_data)
    Widget widget;
    XtPointer client_data;
    XtPointer call_data;
{   /* Quit */
    XtCloseDisplay(XtDisplay(widget));
    exit(0);
}   /* Quit */

Widget CreateQuitButton(parent, name, fontList)
    Widget parent;
    char *name;
    XmFontList fontList;
{   /* CreateQuitButton */
    Widget quit;
    XmString quitString;
    Arg args[10];
    int n;


    quitString = XmStringCreate(``³¡³»±â'', ``koreanEUC'');
    n = 0;
    XtSetArg(args[n], XmNlabelString, quitString); n++;
    XtSetArg(args[n], XmNfontList, fontList); n++;
    quit = XtCreateManagedWidget(name, xmPushButtonWidgetClass, parent,
                    args, n);
    XtAddCallback(quit, XmNactivateCallback, Quit, NULL);
    XmStringFree(quitString);

    return(quit);
}   /* CreateQuitButton */

Widget CreateLabelWidget(parent, name, fontList)
    Widget parent;
    char *name;
    XmFontList fontList;
{   /* CreateLabelWidget */
    Widget label;
    XmString xmString;
    Arg args[10];
    int n;


    /* ¶óº§·Î »ç¿ëµÉ Compound StringÀ» ¸¸µç´Ù. */\\
    xmString = XmStringCreate(``Çö´ëÀüÀÚ S/W ¿¬±¸¼Ò '', ``koreanEUC'');
    n = 0;

    XtSetArg(args[n], XmNlabelString, xmString); n++;
    XtSetArg(args[n], XmNfontList, fontList); n++;
    label = XtCreateManagedWidget(name, xmLabelWidgetClass, parent, args, n);
    XmStringFree(xmString);
    return(label);
}   /* CreateLabelWidget */

Widget CreateTextFieldWidget(parent, name)
    Widget parent;
    char *name;
{   /* CreateTextFieldWidget */
    Widget textF;

    textF = XtCreateManagedWidget(name, xmTextFieldWidgetClass, parent, NULL,
0);
    return(textF);
}   /* CreateTextFieldWidget */

main(argc, argv)
    int argc;
    char *argv[];
{   /* main */
    Widget topLevel, rowColumn, quitB, label, textF;
    XtAppContext appCons;
    Arg args[10];
    int n;
    XFontSet fontSet;
    int missing_charset_count;
    char **missing_charset_list;
    char *def_string;
    XmFontList fontList;
    XmFontListEntry flEntry;


    /* ·ÎÄÉÀÏÀÇ ÁöÁ¤ */
    setlocale(LC_CTYPE, "");

    topLevel = XtAppInitialize(&appCons, "Sample", NULL, 0, &argc, argv,
                    NULL, NULL, 0);         +
    n = 0;
    XtSetArg(args[n], XmNallowShellResize, True); n++;
    XtSetValues(topLevel, args, n);

    n = 0;
    XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
    rowColumn = XtCreateManagedWidget("rowColumn", xmRowColumnWidgetClass,
                    topLevel, args, n);


    /* ÆùÆ® ¸®½ºÆ®¸¦ ¸¸µç´Ù. */

    fontSet = XCreateFontSet(XtDisplay(topLevel), FONTSET,
&missing_charset_list,
            &missing_charset_count, &def_string);
    flEntry = XmFontListEntryCreate("koreanEUC", XmFONT_IS_FONTSET, fontSet);
    fontList = XmFontListAppendEntry((XmFontList) NULL, flEntry);

    quitB = CreateQuitButton(rowColumn, "quitB", fontList);
    label = CreateLabelWidget(rowColumn, "label", fontList);
    textF = CreateTextFieldWidget(rowColumn, "textF");

    XtRealizeWidget(topLevel);
    XtAppMainLoop(appCons);
}   /* main */


´ÙÀ½Àº À§ÀÇ ÇÁ·Î±×·¥À» ½ÇÇà½ÃÅ°±â À§ÇÑ »ùÇà ¸®¼Ò½º ÆÄÀÏÀÇ ³»¿ëÀÌ´Ù.

sample*XmTextField.fontList:
*-clean-bold-r-*--16-*;*-myeongjo-bold-r-*--16-*-ksc5601.1987-1





















     < X11R5/Motif-1.2 ¼³Ä¡ ¿ä·É >

 1. X11R5¿Í Motif-1.2ÀÇ ½ÇÇà È­ÀϵéÀÇ Å©±â´Â ¾à 120MB Á¤µµÀ̹ǷΠÀÌ ¸¸Å­ÀÇ Disk
Space¸¦
 ¸¶·ÃÇÑ´Ù. (X-Terminal¿ë fontÀÎ Super-X¸¦ Áö¿ì¸é ¾à 80MB) 2. /usr file system¿¡ ÀÌ Á¤µµÀÇ disk space°¡ ÀÖÀ» °æ¿ì¿¡´Â ÀÌ Package¸¦ System Directory¿¡ InstallÇÑ´Ù.  # cd / # tar xvfp /dev/rst0
 3. ´Ù¸¥ file systemÀ¸·Î installÇÒ °æ¿ì(space °¡ ÀÖ´Â directory¸¦ $TARGET À̶ó
¸é)
     # cd $TARGET
     # tar xvfp /dev/rst0
     # ls -F
          usr/
     # cd usr ;  ls -F
          bin/	include/	lib/	local/
 4. À§ 3.ÀÇ °æ¿ì¿¡´Â system directory·Î symbolic link¸¦ ½ÃÄÑÁØ´Ù.
     # ln -s $TARGET/usr/bin/X11   /usr/bin/X11
     # ln -s $TARGET/usr/include/Xm   /usr/include/Xm
     # ln -s $TARGET/usr/include/X11   /usr/include/X11
     # ln -s $TARGET/usr/include/Mrm   /usr/include/Mrm
     # ln -s $TARGET/usr/include/uil   /usr/include/uil
     # ln -s $TARGET/usr/lib/X11   /usr/lib/X11
 5. X11R5¿Í Motif¿¡ °ü·ÃµÈ ¶óÀ̺귯¸®¸¦ system directory·Î move½ÃŲ´Ù.
     # cp -r $TARGET/usr/local   /usr  (ÇÑÀÚ »çÀü)
     # mv $TARGET/usr/lib/lib*   /usr/lib
 6. move½ÃŲ ¶óÀ̺귯¸®¸¦ Á¤µ·ÇÑ´Ù.
     # ranlib  /usr/lib/libX*.a  /usr/lib/libX*sa*  /usr/lib/liboldX*.a
     /usr/lib/libphigs.a
 7. À§¿Í °°ÀÌ ¼³Ä¡ÇÑ ÈÄ¿¡´Â Çö´ë ÀüÀÚ·Î hostid¸¦ ¾Ë·ÁÁÖ¾î ÀÌ¿¡ ÇØ´çÇÏ´Â serial
number¸¦ ¹Þ¾Æ
  file¿¡ ÀúÀåÇÑ´Ù.
     # hostid
          xxxxxxxx
     À§ °ªÀ»  S/W ÇÁ¶óÀÚ·Î ¾Ë·ÁÁÖ¸é serial number¸¦ °ð¹Ù·Î ¹Þ´Â´Ù.
     ¸¸¾à serial number°¡ yyyyyy ¶ó¸é
     # cd /usr/lib/X11
     # vi License.dat
          yyyyyy°ªÀ» ÀÔ·ÂÇÑ´Ù. (´Ù¸¥ key°¡ µé¾î°¡¸é ¾ÈµÈ´Ù)
      ½ÇÁ¦·Î À§ number´Â hexa°ªÀ¸·Î ³ªÅ¸³­´Ù.
 8. installÇÑ X11R5¿Í  Motif°¡ Àß ÀÛµ¿Çϵµ·Ï RebootingÇÑ´Ù.
     # /etc/reboot
 9. ÀÌÁ¦ºÎÅÍ X11R5¿Í Motif-1.2¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
     # xinit
10. ÇѱÛÈ­µÈ ÀÀ¿ë ÇÁ·Î±×·¥(¿¡: hterm)À» ½ÇÇà ½ÃÅ°±â Àü¿¡´Â ¹Ýµå½Ã ÇÑ±Û ÀÔ·Â
±â(is)¸¦
     ½ÇÇà½ÃÄÑ¾ß ÇÑ´Ù.
11. ÇÑ±Û ÀԷ±âÀÇ Motif VersionÀº misÀÌ´Ù.
12. /usr/lib/X11/korean¿¡ ÀÖ´Â system.mwmrc¿Í ±× ¹Ø¿¡ ÀÖ´Â app-defaults/MwmÀ»
»ç¿ëÀÚÀÇ $HOME
     ¹ØÀÇ .mwmrc¿Í  MwmÀ¸·Î °¢°¢ copy ÇÏ¿© »ç¿ëÀÚÀÇ ±âÈ£¿¡ µû¶ó mwmÀ» ¹Ù²Ù¾î
     »ç¿ëÇÒ ¼ö ÀÖ´Ù.




 <Âü°í>
   Super-X terminal¿¡¼­ À§ÀÇ Product¸¦ ½ÇÇà½ÃÅ°°íÀÚ ÇÒ ¶§.

  ¿ì¼± X-TerminalÀÌ ¼­¹ö¸¦ download¹Þ°í ÀÖ´Â host¸¦ ã´Â´Ù.
 ±×·±ÈÄ¿¡, ±× host¿¡¼­ Super-X¶ó´Â ¼­¹ö°¡ ÀÖ´Â PATH¸¦ ã¾Æ¼­ Super-X¾Æ·¡¿¡ ÀÖ´Â
fonts·Î
 °£´Ù. ±×¸®°í, °Å±â¿¡ ÀÖ´Â misc¶ó´Â directory¸¦ misc.org·Î move½ÃÄÑ backup ¹ÞÀº
ÈÄ, À§¿¡¼­ ¹ÞÀº
 X11R5/Motif-1.2 ½ÇÇà È­ÀÏÁß¿¡ usr/lib/X11/fonts¹Ø¿¡ ÀÖ´Â Super-X.misc¸¦
Super-X/fonts¾Æ·¡ÀÇ
 misc·Î rename½ÃÄÑ copyÇϰųª, symbolic link½ÃŲ´Ù.

{±¹Á¦È­µÈ X À©µµ¿ì ½Ã½ºÅÛ ÇÁ·Î±×·¥À» À§ÇÑ ±âÃÊ ¾È³»¼­}

Çѱ¹°úÇбâ¼ú¿ø ÀΰøÁö´É¿¬±¸¼¾ÅÍ GUI Consortium Project}
\Copyright{1992, GUI Consortium Project}
\Copyright(1993,  Hyundai Electronics Industries. Co., Ltd)

\chapter*{½ÃÀÛÇϸ鼭}

ÀÌ Ã¥Àº X À©µµ¿ì ÇÁ·Î±×·¥À» ÇØ º¸½Å °æÇèÀÌ ÀÖ´Â ºÐÀÌ ±¹Á¦È­µÈ
X À©µµ¿ì ÇÁ·Î±×·¥À» ½ÃÀÛÇÒ ¶§ µµ¿òÀ» µå¸®·Á°í ¾²¿©Á³½À´Ï´Ù.
µû¶ó¼­ ÀÌ Ã¥À» ÀÐÀ¸½Ã´Â ºÐÀº X À©µµ¿ì³ª C ÇÁ·Î±×·¥¿¡ Àͼ÷Çؾß
ÇÕ´Ï´Ù.

\section*{Ã¥ÀÇ ³»¿ë}

ÀÌ Ã¥ÀÇ ³»¿ëÀº ´ÙÀ½°ú °°ÀÌ ²Ù¸çÁ® ÀÖ½À´Ï´Ù.
1 Àå  X À©µµ¿ì ½Ã½ºÅÛÀÇ ±¹Á¦È­¿¡ °ü·ÃÇÏ¿© ¼³¸íÀ» µå¸³´Ï´Ù.
2 Àå  ÀÔ·Â ¼­¹ö¿Í ¿¬°áÇÏ´Â ¹æ¹ý¿¡ ´ëÇÏ¿© ¼³¸íÀ» µå¸³´Ï´Ù.
3 Àå  ÀÔ·Â ¼­¹ö·ÎºÎÅÍ ÀÔ·ÂÀ» ¹Þ´Â ¹æ¹ýÀ» ¼³¸íÇÕ´Ï´Ù.
4 Àå  ÀÔ·Â ¼­¹öÀÇ È¯°æÀ» ¹Ù²Ù´Â ¹æ¹ýÀ» ¼³¸íÇÕ´Ï´Ù.
5 Àå  Ãâ·ÂÇÏ´Â ¹æ¹ý¿¡ ´ëÇÏ¿© ¼³¸íµå¸³´Ï´Ù.

\chapter{X À©µµ¿ìÀÇ ±¹Á¦È­}

\section{±¹Á¦È­¿Í Áö¿ªÈ­ÀÇ Çʿ伺}

ÄÄÇ»ÅÍ°¡ ¼¼°è ¿©·¯ ³ª¶ó¿¡ º¸±ÞµÊ¿¡ µû¶ó, ÇÁ·Î±×·¥À» ¸¸µå´Â »ç¶÷µéÀº
ÇÑ ÇÁ·Î±×·¥À» Çѱ¹¿ë, ¹Ì±¹¿ë, ÀϺ»¿ë µî °¢ Áö¿ª¿¡ ¸Â°Ô ¿©·¯ °³¸¦
¸¸µé°Ô µÇ¾ú½À´Ï´Ù. ±×·¯³ª ÀÌ ÀÛ¾÷Àº ¸Å¿ì ¾î·Á¿îµ¥ ±× ÀÌÀ¯´Â Áö±¸»ó¿¡¼­
ÄÄÇ»Å͸¦ ¾²´Â ³ª¶ó°¡ ¼ö ½Ê °³°¡ ³ÑÀ¸¹Ç·Î °°Àº ÇÁ·Î±×·¥À» ¼ö ½Ê ¹ø
°íÃÄ¾ß Çϱ⠶§¹®ÀÔ´Ï´Ù. ±×·¡¼­ ³ª¿Â »ý°¢ÀÌ ±¹Á¦È­¿Í Áö¿ªÈ­¶ó´Â °³³äÀÔ´Ï´Ù.

±¹Á¦È­¶õ ÇÁ·Î±×·¥À» ¾î¶² ƯÁ¤ÇÑ Áö¿ª¿¡ ±¹ÇѵÇÁö ¾Êµµ·Ï ¸¸µå´Â
°ÍÀ» ¸»ÇÕ´Ï´Ù. Áö¿ªÈ­¶õ ±¹Á¦È­µÈ ÇÁ·Î±×·¥À» °¢ Áö¿ª¿¡ ¸Â°Ô ¸¸µå´Â ÀÛ¾÷À»
¸»ÇÕ´Ï´Ù. ÀÌ ¶§ ±¹Á¦È­µÈ ÇÁ·Î±×·¥Àº ¼öÁ¤µÇÁö ¾Ê½À´Ï´Ù. ¿¹·Î ³¯Â¥¸¦
Ç¥½ÃÇÏ´Â ÇÁ·Î±×·¥À» »ý°¢ÇØ º¾½Ã´Ù. ±¹Á¦È­µÇÁö ¾ÊÀº ÇÁ·Î±×·¥¿¡¼­´Â
³¯Â¥¸¦ ¹Ù·Î ¾î¶² Áö¿ª¿¡ ¸Â´Â Çü½ÄÀ¸·Î Ç¥½ÃÇÕ´Ï´Ù. ±×·¯³ª ±¹Á¦È­µÈ
ÇÁ·Î±×·¥¿¡¼­´Â ±× Áö¿ª¿¡¼­ ³¯Â¥¸¦ Ç¥½ÃÇÏ´Â Çü½Ä¿¡ ´ëÇÑ Á¤º¸¸¦ °¡Á®¿Í¼­
±× Çü½Ä¿¡ ¸Â°Ô Ãâ·ÂÇÕ´Ï´Ù.

±¹Á¦È­µÈ X À©µµ¿ì ½Ã½ºÅÛ¿¡¼­´Â ÀÀ¿ëÇÁ·Î±×·¥Àº Áö¿ª¿¡ °ü°è¾øÀÌ ¸¸µé¾îÁö°í
±× Áö¿ª¿¡ Ưº°ÇÑ ÀÔ·ÂÀº ÀÔ·Â ¼­¹ö°¡ Ãâ·ÂÀº ±¹Á¦È­µÈ X ¶óÀ̺귯¸®°¡ ÇÏ°Ô
µË´Ï´Ù. ¿©±â¼­ I18NÀº InternationalizationÀÇ ¾àÀÚÀÔ´Ï´Ù. (I¿Í n»çÀÌ¿¡
±ÛÀÚ°¡ 18 °³ÀÔ´Ï´Ù.) ¸¶Âù°¡Áö·Î L10NÀº LocalizationÀÇ ¾àÀÚÀÔ´Ï´Ù.

\chapter{XIM °úÀÇ ¿¬°á}

ÀÌ Àå¿¡¼­´Â ÀÀ¿ëÇÁ·Î±×·¥ÀÌ Á¦ÀÏ ¸ÕÀú ÇØ¾ß ÇÒ ÀÏÀÎ ÀÔ·Â ¼­¹ö¿ÍÀÇ ¿¬°áÀ»
ÇÏ´Â ¹ý¿¡ ´ëÇؼ­ ¾Ë¾Æ º¸°Ú½À´Ï´Ù. °£·«ÇÏ°Ô ÇØ¾ß ÇÒ ÀÛ¾÷À» ³ª¿­Çϸé
´ÙÀ½°ú °°½À´Ï´Ù.

\item setlocale
\item XOpenDisplay
\item XOpenIM
\item XCreateWindow
\item XCreateFontSet
\item XCreateIC

ÀÌ Áß¿¡¼­ XOpenDisplay ¿Í XCreateWindow ´Â º¸ÅëÀÇ X À©µµ¿ì ÇÁ·Î±×·¥¿¡¼­µµ
ÇÏ´Â ÀÛ¾÷À̹ǷΠ¿©±â¼­´Â ¼³¸íÇÏÁö ¾Ê°Ú½À´Ï´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº ´Ù¸¥ Ã¥À»
ÂüÁ¶ÇϽʽÿä.

\section{setlocale}

±¹Á¦È­µÈ X À©µµ¿ì ½Ã½ºÅÛÀº ³»ºÎÀûÀ¸·Î locale(·ÎÄÉÀÏ) À̶ó°í ÇÏ´Â Á¤º¸¸¦ °¡Áö°í
Àִµ¥, ÀÌ Á¤º¸´Â ÇÁ·Î±×·¥ÀÌ ¾î¶² Áö¿ª¿¡ Ưº°ÇÑ Ã³¸®¸¦ ÇØ¾ß ÇÒ °æ¿ì---¹®ÀÚ¿­À»
ÀԷ¹޴´ٰųª Ãâ·ÂÇÏ´Â °æ¿ì---¿¡ »ç¿ëµË´Ï´Ù. µû¶ó¼­ ¸ðµç ÇÁ·Î±×·¥Àº
·ÎÄÉÀÏÀ» Á¤ÇÏ´Â °ÍºÎÅÍ ½ÃÀÛÇØ¾ß ÇÕ´Ï´Ù. setlocale() ÇÔ¼ö´Â ÀÌ
·ÎÄÉÀÏÀ» °áÁ¤ÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. Çü½ÄÀº ´ÙÀ½°ú °°½À´Ï´Ù.

#include 

char *setlocale(category, locale)
int category;
char *locale;

category  ·ÎÄÉÀÏÀ» Á¤ÇÒ ¹üÁÖ¸¦ ¸»ÇÕ´Ï´Ù. LC_CTYPE, LC_COLLATE, LC_CTIME,
           LC_NUMERIC, LC_MONETARY, LC_MESSAGES °°Àº ¿©·¯ ¹üÁÖ°¡
       ÀÖ½À´Ï´Ù.
locale  ·ÎÄÉÀÏÀ» ÁöÁ¤ÇÏ´Â ¹®ÀÚ¿­ÀÔ´Ï´Ù. ¸¸¾à  "" À» ÁöÁ¤Çϸé
       category¿Í °°Àº À̸§ÀÇ È¯°æº¯¼ö¿¡¼­ °ªÀ» °¡Á®¿É´Ï´Ù.
       ±× À̸§ÀÇ È¯°æº¯¼ö°¡ ¾øÀ¸¸é LANGÀ̶ó´Â ȯ°æº¯¼ö¿¡¼­ °ªÀ»
       °¡Á®¿É´Ï´Ù.

½ÇÁ¦·Î ÇÁ·Î±×·¥¿¡¼­´Â ´ÙÀ½°ú °°ÀÌ ¾²´Â °æ¿ì°¡ ¸¹½À´Ï´Ù.

     setlocale(LC_CTYPE, "");

¿©±â¼­ LC_CTYPE Àº ¹®ÀÚÀÇ º¯È¯°ú ºÐ·ù¿¡ ¿µÇâÀ» ÁÖ´Â ·ÎÄÉÀÏ ¹üÁÖ·Î
±¹Á¦È­µÈ X À©µµ¿ì ½Ã½ºÅÛÀº ÁÖ·Î ÀÌ ·ÎÄÉÀÏ ¹üÁÖÀÇ ¿µÇâÀ» ¹Þ½À´Ï´Ù.
°ªÀ¸·Î´Â "" À» ÁöÁ¤ÇÏ¿´À¸¹Ç·Î ȯ°æº¯¼ö LC_CTYPE¿¡¼­ °ªÀ»
°¡Á®¿É´Ï´Ù. ¸¸¾à LC_CTYPEÀÌ ¾øÀ¸¸é LANGÀ̶ó´Â ȯ°æº¯¼ö¿¡¼­ °ªÀ»
°¡Á®¿É´Ï´Ù.

\section{XOpenIM}

ÇÁ·Î±×·¥ÀÌ ÀÔ·Â ¼­¹ö·ÎºÎÅÍ ÀÔ·ÂÀ» ¹Þ±â À§Çؼ­´Â ÀÔ·Â ¼­¹ö¿Í ¿¬°áÀ»
ÇØ¾ß ÇÕ´Ï´Ù. ÀÌ ÀÏÀ» ÇØÁÖ´Â ÇÔ¼ö°¡ XOpenIMÀÔ´Ï´Ù. Çü½ÄÀº ´ÙÀ½°ú °°½À´Ï´Ù.

#include 

XIM XOpenIM(display, rdb, res_name, res_class)
Display* display;
XrmDatabase rdb;
char* res_name;
char* res_class;

display     XOpenDisplay¿¡¼­ ¾òÀº µð½ºÇ÷¹ÀÌÀÔ´Ï´Ù.
rdb         ¸®¼Ò½º µ¥ÀÌŸ º£À̽ºÀÔ´Ï´Ù.
res_name    ¸®¼Ò½º À̸§ÀÔ´Ï´Ù.
res_class   ¸®¼Ò½º Ŭ·¡½ºÀÔ´Ï´Ù.

½ÇÁ¦ÀÇ ÇÁ·Î±×·¥ ¿¹¸¦ º¸¸é ´ÙÀ½°ú °°°Ô µË´Ï´Ù.

     XIM im;
     Display *display;

     display = XOpenDisplay("");
     im = XOpenIM(display, NULL, NULL, NULL);
     if (im == NULL) {
         fprintf(stderr, "can't open IM\n");
         exit(1);
     }

À§ÀÇ ÀÛ¾÷À» ÇÑ ÈÄ¿¡´Â º¸ÅëÀÇ X ÇÁ·Î±×·¥°ú °°ÀÌ Ã¢ ¸¸µå´Â ÀÛ¾÷À»
ÇÏ¸é µË´Ï´Ù.

\section{XCreateFontSet}

±¹Á¦È­µÈ ÇÁ·Î±×·¥À» Â¥°Ô µÇ¸é º¸Åë µÎ °³ ÀÌ»óÀÇ ¹®ÀÚÁýÇÕÀ» »ç¿ëÇÏ°Ô
µË´Ï´Ù. (¿¹¸¦ µé¸é Çѱ۰ú ¿µ¹®) ±×·±µ¥ ÇÁ·Î±×·¥¿¡¼­ ´ÙÀ½°ú °°Àº
¹®ÀÚ¿­À» Ãâ·ÂÇÑ´Ù°í ÇÒ °æ¿ì,

Çö´ëÀüÀÚ »ê¾÷ÁÖ½Äȸ»ç  Software R & D Center

ÀÀ¿ëÇÁ·Î±×·¥¿¡¼­ ÀÏÀÏÀÌ ¾î´À ºÎºÐÀÌ ÇѱÛÀÌ°í ¾î´À ºÎºÐÀÌ ¿µ¹®ÀÎÁö
°¡·Á¼­ Ãâ·ÂÇÑ´Ù´Â °ÍÀº »ó´çÈ÷ ±ÍÂúÀº ÀÛ¾÷ÀÔ´Ï´Ù. ÀÌ·± ÀÛ¾÷À» ½±°Ô
Çϱâ À§Çؼ­ ±¹Á¦È­µÈ X ÇÁ·Î±×·¥¿¡¼­´Â ÆíÀǸ¦ À§Çؼ­ ÆùÆ®ÁýÇÕÀ̶ó´Â
°ÍÀ» Á¦°øÇÕ´Ï´Ù.

½ÇÁ¦·Î ÆùÆ®ÁýÇÕÀ» ¸¸µå´Â ºÎºÐÀ» º¸ÀÌ¸é ´ÙÀ½°ú °°½À´Ï´Ù.

     #define DEFFONTLIST
"*-clean-bold-r-*-c-80-iso8859-1,*-myungjo-bold-r-*-c-160-ksc5601.1987-1"

     int missing_charset_count;
     char **missing_charset_list;
     char *def_string;
     XFontSet fontset;

     fontset = XCreateFontSet(display, DEFFONTLIST,
                   &missing_charset_list,
                   &missing_charset_count, &def_string);

¿©±â¼­ ¾µ·Á°í ÇÏ´Â ÆùÆ®´Â µÎ°¡Áö Áï clean-bold¿Í ¸íÁ¶ÀÔ´Ï´Ù.
(ÆùÆ®À̸§¿¡ ´ëÇؼ­´Â ÀÚ¼¼ÇÏ°Ô ¼³¸íÇÏÁö ¾Ê°Ú½À´Ï´Ù. ´Ù¸¥ Ã¥À» ÂüÁ¶ÇϽʽÿä.)
ÀڱⰡ ¾µ·Á°í ÇÏ´Â ÆùÆ®µéÀ» `,' ·Î±¸ºÐÇÏ¿© ³ª¿­ÇÏ´Â °ÍÀ» ¾Ë¼ö ÀÖ½À´Ï´Ù.
XCreateFontSetÀ» ºÎ¸¥ ÈÄ¿¡´Â ¾µ·Á°í ÇÏ´Â ÆùÆ®µéÁß¿¡¼­ ºüÁø °ÍÀÇ
°¹¼ö°¡ missing_charset_count¿¡, ºüÁø ÆùÆ®µéÀÇ À̸§ÀÌ
missing_charset_list¿¡ µ¹·ÁÁ®¼­ ¿É´Ï´Ù. def_stringÀº ºüÁø °Í ´ë½Å
¾²ÀÏ ÆùÆ®ÀÇ À̸§ÀÔ´Ï´Ù.

\section{XCreateIC}

\subsection{ÀÔ·Â ½ºÅ¸ÀÏ}

ÆùÆ®ÁýÇÕÀ» ¸¸µç ÈÄ¿¡´Â ÀÀ¿ëÇÁ·Î±×·¥ÀÌ ÀÔ·ÂÀ» ¾î¶² ¹æ½ÄÀ¸·Î ¹ÞÀ» °ÍÀÎÁö¸¦
°áÁ¤ÇØ¾ß ÇÕ´Ï´Ù. ÀÀ¿ëÇÁ·Î±×·¥ÀÌ ÀÔ·ÂÀ» ¹Þ´Â ¹æ½Ä¿¡´Â ´ÙÀ½°ú °°Àº 4 °¡Áö
¹æ¹ýÀÌ ÀÖ½À´Ï´Ù.

On-the-spot ¹æ½Ä
      »ç¿ëÀÚ°¡ ÇÑ ±ÛÀÚ¸¦ ÃÄ ³ÖÀ» ¶§¸¶´Ù ¸Å¹ø ÀÔ·ÂÀ» ¹Þ´Â ¹æ½Ä
Over-the-spot ¹æ½Ä
      »ç¿ëÀÚ°¡ ÃÄ ³Ö´Â ±ÛÀÚ°¡ ¸ð¾ÆÁ®¼­ ÀÀ¿ëÇÁ·Î±×·¥¿¡ Àü´ÞµÇ´Â
      ¹æ½Ä. Áö±Ý ¸ð¾ÆÁö´Â ±ÛÀÚ´Â Ä¿¼­ÀÇ ¿À¸¥ ÂÊ¿¡ ±×·ÁÁö°Ô µË´Ï´Ù.
Off-the-spot ¹æ½Ä
      »ç¿ëÀÚ°¡ ÃÄ ³Ö´Â ±ÛÀÚ°¡ ¸ð¾ÆÁ®¼­ ÀÀ¿ëÇÁ·Î±×·¥¿¡ Àü´ÞµÇ´Â
      ¹æ½Ä. Áö±Ý ¸ð¾ÆÁö°í ÀÖ´Â ±ÛÀÚµéÀÌ À©µµ¿ìÀÇ ¾Æ·¡¿¡ ³ªÅ¸³ª´Â
      °ÍÀÌ Over-the-spot°ú ´Ù¸¨´Ï´Ù.
Root-window ¹æ½Ä
      Off-the-spot ¹æ½Ä°ú ºñ½ÁÇϳª Áö±Ý ¸ð¾ÆÁö°í ÀÖ´Â ±ÛÀÚ°¡
      Àüüȭ¸éÀÇ ¾Æ·¡¿¡ ³ªÅ¸³ª°Ô µË´Ï´Ù.

À§ÀÇ 4 ¹æ½ÄÀº ´ÙÀ½°ú °°Àº ºñÆ® ¸¶½ºÅ©µéÀÇ Á¶ÇÕÀ¸·Î Ç¥ÇöµË´Ï´Ù.

     #define OnTheSpot   (XIMPreeditCallbacks|XIMStatusArea)
     #define OffTheSpot  (XIMPreeditArea|XIMStatusArea)
     #define OverTheSpot (XIMPreeditPosition|XIMStatusArea)
     #define RootWindow  (XIMPreeditNothing|XIMStatusNothing)

¿©±â¼­ º¸¸é OnTheSpotÀº ÇÁ¸®¿¡µðÆ® Äݹé°ú »óÅ Áö¿ªÀÌ ÀÖ°í,
OffTheSpotÀº ÇÁ¸®¿¡µðÆ® Áö¿ª°ú »óÅ Áö¿ª, OverTheSpotÀº ÇÁ¸®¿¡µðÆ®
À§Ä¡¿Í »óÅ Áö¿ª, RootWindow´Â ÇÁ¸®¿¡µðÆ® »óÅÂÁö¿ª µÑ ´Ù ¾ø´Â
°ÍÀ» ³ªÅ¸³À´Ï´Ù.

À§ÀÇ ¹æ½ÄÁß ¸î°¡Áö°¡ ÀÔ·Â ¼­¹ö¿¡¼­ Á¦°øµÇ´ÂÁö ¾Ë¾Æº¸±â À§Çؼ­´Â
XGetIMValues¶ó´Â ÇÔ¼ö¸¦ ¾¹´Ï´Ù. ¾Æ·¡ ÇÁ·Î±×·¥¿¡¼­´Â ¿ì¸®°¡ ¿øÇÏ´Â
ÀԷ¹æ½ÄÀÌ Over-the-spotÀÎ °ÍÀ¸·Î µÇ¾î ÀÖ½À´Ï´Ù.

     XIMStyles *ximstyles;
     XIMStyle style;

     style = OverTheSpot;
     XGetIMValues(im, XNQueryInputStyle, &ximstyles, NULL);
     for (i = 0; i < ximstyles->count_styles; i++)
         if (ximstyles->supported_styles[i] == style)
             break;
     if (i == ximstyles->count_styles) {
         fprintf(stderr, "style not supported\n");
         exit(1);
     }

\subsection{XVaCreateNestedList}

ÀÔ·Â ¼­¹ö°¡ ÀÚ½ÅÀÌ ¿øÇÏ´Â ÀÔ·Â ¹æ½ÄÀ» Á¦°øÇÏ´Â °ÍÀ» È®ÀÎÇÑ ÈÄ¿¡´Â
ÀÔ·Â ¹®¸ÆÀ» ¸¸µå´Â ÀÛ¾÷À» ÇÕ´Ï´Ù. ÀÔ·Â ¹®¸ÆÀ» ¸¸µå´Â ÇÔ¼ö´Â XCreateICÀε¥,
ÀÌ ÇÔ¼ö¸¦ ºÎ¸¦ ¶§ ÇÁ¸® ¿¡µðÆ® â¿¡ ´ëÇÑ Á¤º¸¿Í »óÅ Áö¿ª¿¡ ´ëÇÑ Á¤º¸¸¦ ³Ñ°Ü
ÁÖ¾î¾ßÇÕ´Ï´Ù. ÀÌ Á¤º¸´Â XVaNestedList¶ó´Â ÀڷᱸÁ¶¸¦ ÅëÇØ Àü´ÞÇØ ÁÝ´Ï´Ù.
XVaNestedList¸¦ ¸¸µå´Â ÇÔ¼ö´Â XVaCreateNestedListÀÔ´Ï´Ù.

½ÇÁ¦ÀÇ ¿¹¸¦ º¸ÀÌ¸é ´ÙÀ½°ú °°ÀÌ µË´Ï´Ù.

     XPoint overspot;
     XVaNestedList list, preeditlist;

     overspot.x = 0;
     overspot.y = 0;
     list = XVaCreateNestedList(0,
                XNSpotLocation, &overspot,
                XNForeground, fore,
                XNBackground, back,
                XNFontSet, fontset,
                NULL);
     preedit_list = XVaCreateNestedList(0,
                XNPreeditAttributes, list,
                NULL);

XVaCreateNestedListÀÇ Á¦ÀÏ Ã³À½ÀÇ ÀÎÀÚ 0Àº ±×³É º¸³»ÁÖ´Â °ÍÀ¸·Î
½ÇÇà¿¡ ¾Æ¹« ¿µÇâÀ» ¹ÌÄ¡Áö ¾Ê½À´Ï´Ù. SpotLocationÀº ÇÁ¸® ¿¡µðÆ®
âÀÌ ³ªÅ¸³¯ À§Ä¡¸¦ ¸»ÇÕ´Ï´Ù. ¿©±â¼­´Â ±×³É (0, 0)À¸·Î µÇ¾î ÀÖ½À´Ï´Ù.
ÀÌ Á¤º¸´Â ÇÁ·Î±×·¥ ½ÇÇàÁß¿¡ °è¼Ó º¯ÇÏ°Ô µÇ¹Ç·Î ÃʱⰪÀ¸·Ð ¹«¾ùÀ»
Á־ º° »ó°üÀÌ ¾ø½À´Ï´Ù.
Foreground´Â ÇÁ¸®¿¡µðÆ® âÀÇ Àü°æ»ö, Background´Â ÇÁ¸®¿¡µðÆ® âÀÇ
¹è°æ»öÀÔ´Ï´Ù. ±×¸®°í FontSetÀº ÇÁ¸®¿¡µðÆ® â¿¡¼­ ¾²ÀÏ ÆùÆ® ÁýÇÕÀÔ´Ï´Ù.

»óÅ Áö¿ª¿¡ ´ëÇؼ­´Â ´ÙÀ½°ú °°ÀÌ Á¤º¸¸¦ ¸¸µé¾î µÓ´Ï´Ù.

     list = XVaCreateNestedList(0,
             XNForeground, fore,
             XNBackground, back,
             XNFontSet, fontset,
             NULL);
     status_list = XVaCreateNestedList(0,
             XNStatusAttributes, list,
             NULL);

¿©±â±îÁö ÇÑ ÈÄ¿¡´Â XCreateIC¸¦ ºÎ¸£¸é µË´Ï´Ù.

     XIC ic;

     ic = XCreateIC(im, XNInputStyle, style,
                        XNClientWindow, win,
                        XNFocusWindow, win,
                        XNVaNestedList, preedit_list,
                        XNVaNestedList, status_list,
                        NULL);

¿©±â¼­ ClientWindow¿Í FocusWindow´Â ÀÔ·Â ¼­¹ö·Î ºÎÅÍ ÀÔ·ÂÀ» ¹ÞÀ»
À©µµ¿ì¸¦ ¸»ÇÕ´Ï´Ù.

\section{On-the-spotÀÎ °æ¿ì}

ÀÔ·Â ½ºÅ¸ÀÏÀÌ on-the-spotÀÏ °æ¿ì¿¡´Â ÀÔ·Â ¼­¹ö¿¡¼­ ÄݹéµéÀ» ºÒ·¯ÁֹǷÎ
ÀÌ ÄݹéµéÀ» µî·ÏÇØ¾ß ÇÕ´Ï´Ù. ÀÌ Äݹ鿡 °üÇÑ Á¤º¸´Â XIMCallbackÀ̶ó´Â
ÀڷᱸÁ¶¸¦ ÅëÇؼ­ ±â¼úµË´Ï´Ù. ½ÇÁ¦ÀÇ ¿¹¸¦ º¸ÀÌ¸é ´ÙÀ½°ú °°½À´Ï´Ù.

     static XIMCallback PreeditStartCallbackStruct = {
         NULL, (XIMProc) PreeditStartCallback
     };
     static XIMCallback PreeditDoneCallbackStruct = {
         NULL, (XIMProc) PreeditDoneCallback
     };
     static XIMCallback PreeditDrawCallbackStruct = {
         NULL, (XIMProc) PreeditDrawCallback
     };
    static  XIMCallback PreeditCaretCallbackStruct = {
         NULL, (XIMProc) PreeditCaretCallback
     };

     if (style & XIMPreeditCallbacks) { /* on-the-spot */
         list = XVaCreateNestedList(0,
                 XNPreeditStartCallback, &PreeditStartCallbackStruct,
                 XNPreeditDoneCallback, &PreeditDoneCallbackStruct,
                 XNPreeditDrawCallback, &PreeditDrawCallbackStruct,
                 XNPreeditCaretCallback, &PreeditCaretCallbackStruct,
                 NULL);
         preedit_list = XVaCreateNestedList(0,
                 XNPreeditAttributes, list,
                 NULL);
     }
     else {
         ...  /* non on-the-spot */
     }

À§¿¡¼­ preedit_list¸¦ ¸¸µå´Â ºÎºÐÀ» Á¦¿ÜÇÑ ³ª¸ÓÁö(»óÅ ¿µ¿ª ºÎºÐ)´Â ¾Õ¿¡¼­
¼³¸íÇÑ´ë·Î ÇÏ½Ã¸é µË´Ï´Ù.
PreeditStartCallback, PreeditDrawCallback µîÀº Äݹé ÇÔ¼öÀÇ À̸§À¸·Î ½ÇÁ¦
ÀÌ ÇÔ¼ö°¡ ¾î¶»°Ô ±¸¼ºµÇ´ÂÁö¿¡ ´ëÇؼ­´Â ÀÔ·ÂÀ» ´Ù·ç´Â Àå¿¡¼­ ¼³¸íÇÏ°Ú½À´Ï´Ù.

\chapter{ÀÔ·Â ¹Þ±â}

ÀԷ¿¡ °ü·ÃµÈ ÇÔ¼ö´Â XFilterEvent¿Í XmbLookupString, XSetICFocus,
XUnsetICFocus ÀÔ´Ï´Ù.

\section{XFilterEvent}

XFilterEvent´Â XNextEvent¸¦ ºÎ¸¥ ´ÙÀ½¿¡ ¹Ýµå½Ã ½ÇÇà½ÃÄÑ ÁÖ¾î¾ß¸¸
ÇÕ´Ï´Ù.(ÀϺ»¿¡¼­ ±¸ÇöÇÑ ¹æ½Ä¿¡¼­´Â XmbLookupString¿¡¼­ ÀÚµ¿À¸·Î ÇÏ°Ô
µÇ¾î ÀÖ½À´Ï´Ù.).
±×·³À¸·Î¼­ À̺¥Æ®°¡ ÀԷ¼­¹ö¿¡ Àü´ÞµÇ¾î ÀԷ¼­¹ö°¡ Á¦´ë·Î µ¿ÀÛÇÏ°Ô µË´Ï´Ù.
XFilterEventÀÇ Çü½ÄÀº ´ÙÀ½°ú °°½À´Ï´Ù.

Bool XFilterEvent(event, window)
XEvent* event;
Window window;

event         XNextEvent¿¡¼­ ¹ÞÀº À̺¥Æ®ÀÔ´Ï´Ù.
window         ±× À̺¥Æ®°¡ °¥ À©µµ¿ìÀÔ´Ï´Ù.
µ¹·ÁÁÖ´Â °ª   ¸¸¾à True¸¦ µ¹·Á¹ÞÀ¸¸é ÀÌ À̺¥Æ®´Â ÀԷ¼­¹ö¿¡¼­
               ó¸®Çß´Ù´Â ¶æÀÔ´Ï´Ù. ÀÀ¿ëÇÁ·Î±×·¥¿¡¼­´Â 󸮸¦ Çϸé
                 ¾ÈµË´Ï´Ù. ¸¸¾à False¸¦ µ¹·Á ¹ÞÀ¸¸é ÀÌ°ÍÀº ÀԷ¼­¹ö¿¡¼­
                 ó¸®ÇÏÁö ¾ÊÀº À̺¥Æ®ÀÔ´Ï´Ù. ÀÀ¿ëÇÁ·Î±×·¥¿¡¼­ ó¸®Çؾß
                 ÇÕ´Ï´Ù.

windowÀÎÀÚ¿¡´Â 0À» Á־ µË´Ï´Ù. ±×·³ event ÀڷᱸÁ¶
¾ÈÀÇ window¸¦ ÀÌ¿ëÇÏ°Ô µË´Ï´Ù. ½ÇÁ¦ÀÇ ¿¹¸¦ º¸¸é ´ÙÀ½°ú °°½À´Ï´Ù.

     XEvent event;

     while (1) {
         XNextEvent(display, &event);
         if (XFilterEvent(&event, win) == True)
             continue;
         switch (event.type) {
             ...
         }
     }

\section{XmbLookupString}

º¸ÅëÀÇ X À©µµ¿ì ÇÁ·Î±×·¥¿¡¼­´Â KeyPress À̺¥Æ®¸¦ ¹ÞÀ¸¸é
XLookupStringÀ» ºÒ·¯¼­ À̺¥Æ®¿¡¼­ ½ºÆ®¸µÀ¸·Î º¯È¯À» ÇÏ°Ô µË´Ï´Ù.
±¹Á¦È­µÈ X À©µµ¿ì ÇÁ·Î±×·¥¿¡¼­´Â XLookupString ´ë½Å¿¡ XmbLookupString
À» ºÒ·¯ÁÖ¾î¾ß¸¸ ÇÕ´Ï´Ù. ÀÌ ÇÔ¼ö°¡ ¾²ÀÌ´Â ¿¹¸¦ º¸ÀÌ¸é ´ÙÀ½°ú °°ÀÌ
µË´Ï´Ù.

     KeySym keysym;
     char buf[MAX_BUF];
     Status status;
     int len;

     len = XmbLookupString(ic, &event, buf, MAX_BUF, &keysym, &status);
     if (len > 0) {
         ...
     }
    else {
         ...
     }

¿©±â¼­ lenÀÌ 0º¸´Ù Å©¸é ¹®ÀÚ¿­ÀÌ ÀÔ·ÂµÈ °ÍÀ̹ǷΠ¹®ÀÚ¿­À» ó¸®Çϸé
µË´Ï´Ù. lenÀÌ 0º¸´Ù Å©Áö ¾ÊÀ¸¸é ¹®ÀÚ¿­ÀÌ µÉ ¼ö ¾ø´Â Å°(¿¹¸¦ µé¸é È­»ìÇ¥ Å°)°¡
ÀÔ·ÂµÈ °ÍÀ̹ǷΠkeysymÀ» º¸°í ÀÌ¿¡ ¸Â´Â 󸮸¦ ÇÏ¸é µË´Ï´Ù.

\section{XSetICFocus, XUnsetICFocus}

ÀÀ¿ëÇÁ·Î±×·¥ÀÇ Ã¢ÀÌ ÀÔ·Â Æ÷Ä¿½º¸¦ ¹ÞÀ» ¶§¿Í ÀÒ¾î ¹ö¸± ¶§¸¶´Ù
XSetICFocus, XUnsetICFocus¸¦ ºÒ·¯ ÁÖ¾î¾ß ÇÕ´Ï´Ù.
½ÇÁ¦ÀÇ ¿¹¸¦ º¸¸é

      switch (event.type) {
      ...
      case EnterNotify:
          XSetICFocus(ic);
          ...
          break;
      case LeaveNotify:
          XUnsetICFocus(ic);
          ...
          break;
      ...
      }

¿©±â¼­´Â ¸¶¿ì½º°¡ â¿¡ µé¾î¿À¸é XSetICFocus â¿¡¼­ ³ª°¡¸é
XUnsetICFocus¸¦ ºÒ·¯ ÁÖ°í ÀÖ½À´Ï´Ù. ½ÇÁ¦ ÇÁ·Î±×·¥¿¡¼­´Â
FocusOut À̺¥Æ®¿Í FocusIn À̺¥Æ®ÀÏ ¶§µµ ó¸®ÇØ ÁÖ´Â °ÍÀÌ
ÁÁ°Ú½À´Ï´Ù.

\section{On-the-spotÀÏ °æ¿ì}

On-the-spotÀÏ °æ¿ì¿¡´Â ¸Å ±ÛÀÚ°¡ ´­·ÁÁú ¶§ ¸¶´Ù ÄݹéÀÌ ºÒ·ÁÁö¹Ç·Î
Á¶±Ý º¹ÀâÇÏ°Ô µË´Ï´Ù. ÀüüÀûÀÎ ¼ø¼­¸¦ °£´ÜÇÏ°Ô ¼³¸íÇÏ¸é ´ÙÀ½°ú °°½À´Ï´Ù.

»ç¿ëÀÚ°¡ shift+spaceµîÀ» ´­·¯  ÇÑ±Û ¸ðµå¸¦ ½ÃÀÛÇϸé
ÀԷ¼­¹ö´Â ÀÌ ¶§ PreeditStartCallbackÀ» ºÎ¸¨´Ï´Ù. ÀÌ ¶§ ÀÀ¿ëÇÁ·Î±×·¥Àº
ÇÁ¸® ¿¡µðÆ®°¡ ½ÃÀÛµÆÀ½À» ¾Ë°í ÀÌ¿¡ ´ëÇÑ Áغñ¸¦ ÇØ¾ß ÇÕ´Ï´Ù.
°è¼ÓÇؼ­ »ç¿ëÀÚ°¡ ÇÑ±Û ¹®ÀÚ¿­À» ÀÔ·ÂÇÏ°Ô µÇ¸é ÀԷ¼­¹ö´Â PreeditDrawCallbackÀ»
ºÒ·¯ ÁÝ´Ï´Ù. ÀÌ ¶§ ÀÀ¿ëÇÁ·Î±×·¥ÀÌ °¢ ¹®ÀÚ¸¦ ±×¸®°Ô µË´Ï´Ù. »ç¿ëÀÚ°¡
¹®ÀÚ¿­À» ÀÔ·ÂÇÏ´Â µµÁß¿¡ È­»ìǥ۵îÀ» »ç¿ëÇؼ­ ij·µÀ» ¿òÁ÷ÀÌ°Ô µÇ¸é
ÀԷ¼­¹ö´Â PreeditCaretCallbackÀ» ºÒ·¯ÁÝ´Ï´Ù. ÀÌ ¶§ ÀÀ¿ëÇÁ·Î±×·¥Àº
¾Ë¸Â°Ô ij·µÀ» ¿òÁ÷¿© ÁÖ¾î¾ß ÇÕ´Ï´Ù. ¸¶Áö¸·À¸·Î »ç¿ëÀÚ°¡ shift+space¸¦ ´Ù½Ã
ÀÔ·ÂÇϸé ÀԷ¼­¹ö´Â PreeditDoneCallbackÀ» ºÎ¸¨´Ï´Ù. ÀÌ ¶§ ÀÀ¿ëÇÁ·Î±×·¥Àº
ÇÁ¸®¿¡µðÆ®°¡ ³¡³µÀ½À» ¾Ë°í ÀÌ¿¡ ´ëÀÀÇÏ´Â ÀÛ¾÷À» ÇÕ´Ï´Ù.

À§¿Í °°Àº ½Ã³ª¸®¿À »ó¿¡¼­ °¢°¢¿¡ ´ëÇؼ­ Á»´õ ÀÚ¼¼È÷ ¾Ë¾Æ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.

\subsection{XIMProc}

ÀԷ¼­¹ö¿¡¼­ ºÎ¸£´Â Äݹé ÇÔ¼öµéÀº ´ÙÀ½°ú °°Àº Çü½ÄÀ» °®°í ÀÖ½À´Ï´Ù.

fucntion(ic, client_data, call_data)
XIC ic;
XPointer client_data;
XPointer call_data;

ic            XCreateIC¿¡¼­ »ý±ä icÀÔ´Ï´Ù.
client_data  XIMCallbackÀÇ Ã¹¹ø° ¸â¹öÀÔ´Ï´Ù.
call_data    °¢ Äݹ鸶´Ù ´Þ¶óÁö´Â ÀԷ¼­¹ö¿¡¼­ ÁÖ´Â Á¤º¸ÀÔ´Ï´Ù.

¿©±â¼­ client_data´Â XIMCallback ÀڷᱸÁ¶ÀÇ Ã¹¹ø° ¸â¹ö·Î¼­
ÀÀ¿ëÇÁ·Î±×·¥ÀÇ ÇÊ¿ä¿¡ µû¶ó¼­ ¹Þ°í ½ÍÀº ÀڷḦ ¹Ì¸® Á¤ÇصθéµË´Ï´Ù.

\subsection{PreeditStartCallback}

PreeditStartCallbackÀº »ç¿ëÀÚ°¡ ÇÁ¸®¿¡µðÆ®¸¦ ½ÃÀÛÇÏ¸é ºÒ¸®´Â ÇÔ¼öÀÔ´Ï´Ù.
call_data´Â NULLÀÔ´Ï´Ù. ÀÀ¿ëÇÁ·Î±×·¥Àº ÀÌ ÇÔ¼ö°¡ ºÒ·ÁÁö¸é ÇÁ¸®¿¡µðÆ®¸¦
½ÃÀÛÇϱ⿡ ÇÊ¿äÇÑ ÀÛ¾÷À» ÇÕ´Ï´Ù. ¿¹¸¦ µéÀÚ¸é ¹öÆÛÀÇ ÃʱâÈ­µîÀ» µé ¼ö
ÀÖ°Ú½À´Ï´Ù.

\subsection{PreeditDrawCallback}

PreeditDrawCallbackÀº ÇÁ¸®¿¡µðÆ®°¡ ½ÃÀÛµÈ ÈÄ »ç¿ëÀÚ°¡ Å°¸¦ ÀÔ·ÂÇÒ ¶§¸¶´Ù
ºÒ·ÁÁö´Â ÇÔ¼öÀÔ´Ï´Ù. call_data¿¡´Â XIMPreeditDrawCallbackStruct¶õ ÀÚ·á
±¸Á¶°¡ µé¾î¿É´Ï´Ù. ÀÌ ÀڷᱸÁ¶´Â ´ÙÀ½°ú °°Àº ¸ð¾çÀ» ÇÏ°í ÀÖ½À´Ï´Ù.

typedef struct _XIMPreeditDrawCallbackStruct{
        int caret;
        int chg_first;
        int chg_length;
        XIMText *text;
} XIMPreeditDrawCallbackStruct;

¿©±â¼­ caretÀº Áö±Ý Ä¿¼­ÀÇ À§Ä¡, chg_first´Â ¹Ù²Ù¾î¾ß ÇÒ ½ºÆ®¸µÀÇ
óÀ½À» ³ªÅ¸³»´Â À妽º, chg_length´Â ¹Ù²Ù¾î¾ß ÇÒ ¹®ÀÚ¿­ÀÇ ±æÀÌ,
text´Â ¹Ù²ãÁú ¹®ÀÚ¿­¿¡ ´ëÇÑ Á¤º¸¸¦ °®°í ÀÖ½À´Ï´Ù.

XIMText´Â ´ÙÀ½°ú °°Àº ¸ð¾çÀ¸·Î µÇ¾î ÀÖ½À´Ï´Ù.

typedef struct _XIMText{
        unsigned short length;
        XIMFeedback *feedback;
        Bool encoding_is_wchar;
        union {
               char *multi_byte;
               wchar_t *wide_char;
        } string;
} XIMText;

¿©±â¼­ length´Â ¹Ù²ãÁú ¹®ÀÚ¿­ÀÇ ±æÀÌ feedbackÀº ÀÌ ¹®ÀÚ¿­À» ¾î¶»°Ô
Ç¥½ÃÇÒ °ÍÀΰ¡¿¡ ´ëÇÑ Á¤º¸·Î ÇöÀçÀÇ ±¸Çö¿¡¼­´Â XIMReverse·Î µÇ¾î ÀÖ½À´Ï´Ù.
encoding_is_wchar´Â ´ÙÀ½ ¸â¹öÀÎ stringÀÌ wchar·Î ÀÎÄÚµùµÇ¾î ÀÖ´ÂÁö
multi_byte·Î µÇ¾î ÀÖ´ÂÁö¿¡ ´ëÇÑ Á¤º¸ÀÔ´Ï´Ù. ÇöÀçÀÇ ±¸Çö¿¡¼­´Â Ç×»ó
FalseÀÔ´Ï´Ù. Áï ´ÙÀ½ÀÇ string¸â¹ö´Â Ç×»ó multi_byteÇü½ÄÀÔ´Ï´Ù.

ÀÌÇظ¦ µ½±â À§Çؼ­ »ç¿ëÀÚ°¡ ´ÙÀ½°ú °°Àº ¹®ÀÚ¿­À» ÀÔ·ÂÇÒ °æ¿ì ºÒ·ÁÁö´Â
Äݹéµé°ú call_data¸¦ ¼³¸íÇØ º¸°Ú½À´Ï´Ù.

shift+space  ¤¾¤¿ shift+space

shift+space  1 PreeditStartCallbackÀÌ ºÒ·ÁÁý´Ï´Ù.
¤¾           2 PreeditDrawCallbackÀÌ ºÒ·ÁÁý´Ï´Ù.
              call_data¿¡ ¿À´Â Á¤º¸´Â ´ÙÀ½°ú °°½À´Ï´Ù.
         caret = 1, chg_first = 0, chg_length = 0,
         text$rightarrow$length = 2, text$rightarrow$string.multi_byte
              = ``¤¾''
         ÀÌ Á¤º¸¸¦ Çؼ®ÇÏ¸é ¹öÆÛÀÇ 0 ¹ø° ¹®ÀÚºÎÅÍ
         ±æÀÌ 0ÀÇ ¹®ÀÚ¿­À» ±æÀÌ 2ÀÇ ``¤¾''ÀÚ¶õ ¹®ÀÚ¿­·Î
         ¹Ù²Ù°í(Áï, ``¤¾''À» »ðÀÔÇÏ°í) ij·µÀ» 1¹ø° ¹®ÀÚµÚ
          Áï ``¤¾''ÀÚ µÚ¿¡ ±×¸®¶ó´Â ¶æÀÔ´Ï´Ù.
¤¿           3 PreeditDrawCallbackÀÌ ºÒ·ÁÁý´Ï´Ù.
              call_data¿¡ ¿À´Â Á¤º¸´Â ´ÙÀ½°ú °°½À´Ï´Ù.
             caret = 1, chg_first = 0, chg_length = 1,
         text$rightarrow$length = 2, text$rightarrow$string.multi_byte
              = ``ÇÏ''
         ÀÌ Á¤º¸¸¦ Çؼ®ÇÏ¸é ¹öÆÛÀÇ 0 ¹ø° ¹®ÀÚºÎÅÍ ±æÀÌ
              1ÀÇ ¹®ÀÚ¿­À» ±æÀÌ 2ÀÇ ¹®ÀÚ¿­ ``ÇÏ''·Î ¹Ù²Ù°í
              (Áï, ``¤¾''À» ``ÇÏ''·Î ¹Ù²Ù°í) ij·µÀ» 1¹ø° ¹®ÀÚ µÚ
          Áï ``ÇÏ''ÀÚ µÚ¿¡ ±×¸®¶ó´Â ¶æÀÔ´Ï´Ù.
shift+space  4 PreeditDoneCallbackÀÌ ºÒ·ÁÁý´Ï´Ù.

¿©±â¼­ ÁÖÀÇÇØ¾ß ÇÒ °ÍÀº chg_first¿Í chg\lengthÀÇ °ªÀº ÇÑ±Û ¿µ¹®¿¡
°ü°è¾øÀÌ ÇÑ ±ÛÀÚ¸¦ 1·Î Ä¡´Â °ÍÀÌ°í (¿¹·Î ``ÇѱÛabc''´Â 5)
 text$rightarrow$length´Â ÇѱÛÀº 2, ¿µ¹®Àº 1·Î Ä¡´Â °ÍÀÔ´Ï´Ù.
(¿¹·Î ``ÇѱÛabc''´Â 7)

\subsection{PreeditCaretCallback}

PreeditCaretCallbackÀº »ç¿ëÀÚ°¡ ÇÁ¸®¿¡µðÆ® µµÁß È­»ìǥ۸¦ ´©¸£¸é
ºÒ·ÁÁý´Ï´Ù. ÀÌ ÇÔ¼öÀÇ call_data´Â XIMPreeditCaretCallbackStructÀε¥
´ÙÀ½°ú °°ÀÌ ¼±¾ðµÇ¾î ÀÖ½À´Ï´Ù.

typedef struct _XIMPreeditCaretCallbackStruct {
        int position;
        XIMCaretDirection direction;
        XIMCaretStyle style;
} XIMPreeditCaretCallbackStruct;

¿©±â¼­ positionÀº ÇöÀçÀÇ caretÀÇ À§Ä¡¸¦, directionÀº ij·µÀÌ ¾î´À ¹æÇâÀ¸·Î
¿òÁ÷¿´´Â°¡¸¦ styleÀº ij·µÀ» ¾î¶² ¸ð¾çÀ¸·Î ±×¸± °ÍÀÎÁö¸¦ ¸»ÇÕ´Ï´Ù.
ÇöÀçÀÇ ±¸Çö¿¡¼­´Â directionÀº XIMForwardChar¿Í XIMBackwardChar µÎ °¡Áö
»ÓÀÔ´Ï´Ù.

ÀÌ ÇÔ¼ö´Â ij·µÀ» »õ·Î¿î À§Ä¡¿¡ ±×¸°ÈÄ¿¡ »õ·Î¿î ij·µÀÇ À§Ä¡¸¦
µ¹·ÁÁÖ¾î¾ß¸¸ ÇÕ´Ï´Ù.

\subsection{PreeditDoneCallback}

PreeditDoneCallbackÀº »ç¿ëÀÚ°¡ ÇÁ¸®¿¡µðÆ®¸¦ ½ÃÀÛÇÏ¸é ºÒ¸®´Â ÇÔ¼öÀÔ´Ï´Ù.
call_data´Â NULLÀÔ´Ï´Ù. ÀÀ¿ëÇÁ·Î±×·¥Àº ÀÌ ÇÔ¼ö°¡ ºÒ·ÁÁö¸é ÇÁ¸®¿¡µðÆ®¸¦
¸¶Ä¡´Â ÀÛ¾÷À» ÇÕ´Ï´Ù.

ÁÖÀÇÇÒ Á¡Àº on-the-spotÀÎ °æ¿ì¿¡ preeditÀÌ ³¡³ª°í ³­ µÚ preedit µ¿¾È
ÀÔ·ÂµÈ ¹®ÀÚµéÀ» ¸ð¾Æ¼­ ÇϳªÀÇ ¹®ÀÚ¿­·Î ÀԷ¼­¹ö°¡ µ¹·ÁÁֹǷΠÀÌ¿¡
´ëºñÇØ¾ß ÇÕ´Ï´Ù. ¿¹¸¦ µé¸é ¹®¼­ ÆíÁý±â°°Àº ÀÀ¿ëÇÁ·Î±×·¥ÀÇ °æ¿ì
preedit µ¿¾È PreeditDrawCallback¿¡¼­ ÀÌ¹Ì ¹®ÀÚµéÀ» ¹öÆÛ¿¡ »ðÀÔÇϵµ·Ï
ÇÁ·Î±×·¥À» ¸¸µå´Â °æ¿ì°¡ Àִµ¥ ÀÌ °æ¿ì preeditÀÌ ³¡³ª°í ³­ µÚ ±× µ¿¾È
ÀԷµȴø ¹®ÀÚ¿­ÀÌ ¿À¹Ç·Î ÀÌ °ÍÀ» ¶Ç Çѹø ¹öÆÛ¿¡ »ðÀÔÇÏ°Ô µÇ´Â ¼ö°¡ ÀÖ½À´Ï´Ù.
ÀÌ¿¡ ´ëÇÑ ÇØ°áÃ¥À¸·Î´Â PreeditDoneCallbackÀÌ ºÒ¸®°í ³­µÚ¿¡ ¿À´Â KeyPress
À̺¥Æ®´Â ¹«½ÃÇϵµ·Ï ÇÏ´Â °Íµµ ÇÑ ¹æ¹ýÀÔ´Ï´Ù. ¶Ç´Â PreeditDrawCallback¿¡¼­
¹®ÀÚµéÀ» ±×¸®±â¸¸ ÇÏ°í ¹öÆÛ¿¡ »ðÀÔÇÏÁö´Â ¾Ê´Ù°¡ KeyPress°¡ ¿ÔÀ» ¶§
»ðÀÔÇÏ´Â ¼öµµ ÀÖ°Ú½À´Ï´Ù.

\chapter{ȯ°æ ¹Ù²Ù±â}

Over-the-spotÀÏ °æ¿ì¿¡´Â ÀÔ·Â ¼­¹ö¿¡°Ô ÇöÀç Ä¿¼­°¡ ¾îµð¿¡ ÀÖ´ÂÁö¸¦
°¡¸£ÃÄ ÁÖ¾î¾ß ÀÔ·Â ¼­¹ö°¡ Á¦ À§Ä¡¿¡ preedit âÀ» ¸¸µé ¼ö°¡ ÀÖ½À´Ï´Ù.
ÀÌ°ÍÀº XSetICValues¶õ ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ÇÏ°Ô µË´Ï´Ù.

    over_spot.x = 0;
    over_spot.y = 20;
    list = XVaCreateNestedList(0,
               XNSpotLocation, &over_spot,
               NULL);
    preedit_list = XVaCreatedNestedList(0,
               XNPreeditAttributes, list,
               NULL);
    XSetICValues(ic, XNVaNestedList, preedit_list, NULL);

À§¿Í °°ÀÌ ÇÏ°Ô µÇ¸é ÀԷ¼­¹ö°¡ ´ÙÀ½¿¡ preedit âÀ» ±×¸± ¶§
(0,20) À§Ä¡¿¡ ±×¸®°Ô µË´Ï´Ù. ÀÌ¿Í °°Àº ÀÛ¾÷Àº ¸Å¹ø Ä¿¼­°¡ ¿òÁ÷ÀÏ ¶§¸¶´Ù
ÇØ ÁÖ¸é µÇ°Ú½À´Ï´Ù.

\chapter{Ãâ·Â Çϱâ}

¹®ÀÚ¿­À» Ãâ·ÂÇÏ´Â ÇÔ¼ö´Â XmbDrawString°ú XmbDrawImageStringÀ¸·Î
ÀÌ °ÍÀº º¸Åë X À©µµ¿ì ÇÁ·Î±×·¥ÀÇ XDrawString°ú XDrawImageString¿¡
´ëÀÀµË´Ï´Ù. XmbDrawString°ú XmbDrawImageStringÀº ÀÎÀÚ·Î font_setÀ»
Çϳª ´õ Àü´ÞÇÏ´Â °ÍÀÌ ´Ù¸¨´Ï´Ù. ½ÇÁ¦ÀÇ ¿¹¸¦ º¸À̸é

XmbDrawString(display, win, font_set, gc, 0, 20, "°¡³ª´Ù¶ó abc", 12);

ÀÌ °æ¿ì ``°¡³ª´Ù¶ó abc''¶ó´Â ¹®ÀÚ¿­À» (0, 20) À§Ä¡¿¡ ±×·Á ÁÖ°Ô µË´Ï´Ù.


     ¡Ø Âü°í : ±¹Á¦È­¸¦ ±âÃʷΠ¥¿©Áø ¸ðµç ÇÁ·Î±×·¥µéÀº ÀԷ¼­¹ö°¡ À̹Ì
          ½ÇÇàÁßÀÎ ÈÄ¿¡¾ß ºñ·Î¼Ò ½ÇÇàµÉ ¼ö ÀÖ½À´Ï´Ù.
          (¿¹ : is (ÀÔ·Â ¼­¹ö) ¸¦ ½ÇÇà½ÃŲÈÄ , hterm ( ÇÑ±Û xterm) À» ½ÇÇà½Ãų
          ¼ö
          ÀÖÀ½)