1992.12.23 SUBJECT: Xview Á¤¸® MEANING OF THIS MEMO: Xview ÀÇ °³³ä Á¤¸® CONTENTS: 1. XView and X Window System 2. The XView Programmer's Model 3. Example program & compile DISCRIPTION: 1. XView and X Window System -XView(X window-system-based Visual/Integrated Environment for Workstation)Àº ³»ÀçµÈ À©µµ¿ì ½Ã½ºÅÛÀÇ ¸¹Àº ÀÚ¼¼ÇÑ ºÎºÐÀ» ¾ËÇÊ¿ä¾øÀÌ programmer °¡ application ¿¡ ´ëÇÑ interface ¸¦ °¡´ÉÇÏ°Ô ÇØÁØ´Ù. ±×·¯³ª X window ¿¡ ´ëÇÑ °³³äÀº ²À ÀÖ¾î¾ß ÇÑ´Ù. -ÀÌ ÅøŶÀº Sun Microsystem ÀÇ ±âÁ¸ KERNEL-base ÀÇ SunView ¸¦ À§ÇÑ X ·ÎÀÇ º¯È¯ ÀÌ´Ù. Áï, ¿÷½ºÅ×ÀÌ¼Ç ½ÃÀå¿¡¼ 2000 ¿©°¡ÁöÀÇ SunView application ÀÌ ÀÖ°í, ¸¹Àº programmer µéÀÌ SunView application programmer's interface(API)¿¡ Àͼ÷ÇÑ »óÅÂÀ̹ǷΠXView ·Î ÇÏ¿© X marketplace ¿¡ µé¾î°¡°ÔÇÔÀÌ´Ù. -¾î¶² toolkit °ú ¸¶Âù°¡Áö·Î XView µµ canvases, scrollbars,menus ±×¸®°í control pannels °°Àº ³»ÀåµÈ user-interface objects ¸¦ Á¦°øÇÑ´Ù. - XView ´Â X window system ÀÇ °¡Àå lowest level ÀÎ XLib ¸¦ base ·Î ÇÑ´Ù. 1.1 X window system -X window system Àº network_based graphics system À̸ç 1984³â MIT ¿¡¼ °³¹ßÇÏ¿´À¸¸ç Áö±ÝÀº 1987 ³â¿¡ ¹ßÇ¥ÇÑ X version À» ¹ßÀü½ÃÄÑ¿À°í ÀÖ´Ù. X11 Àº industory standard window system À¸·Î ¹Þ¾Æµé¿©Áö¸ç DEC,HP, Sun,AT&T ¿¡¼ ¹ßÀü½ÃÅ°¸ç Áö¿øÇÏ°í ÀÖ´Ù. -´ëºÎºÐÀÇ window system Àº ±×ÀÚü°¡ operating system °ú ¹ÐÁ¢°Ô ¿¬°èµÇ¸ç single workstation °ú °°Àº ´ÜÁö ºÐ¸®µÈ ½Ã½ºÅÛ¿¡ µ¹¾Æ°¡´Â kernel_base ÀÌ´Ù. ±×·¯³ª X ´Â ¾î¶² OS ÀÇ ºÎºÐÀ̾ƴ϶ó user_level program ÀÌ¸ç ±× ±¸Á¶´Â client_server model À» ±âº» À¸·Î ÇÑ´Ù. ¾Æ½Ã´Â¹Ù¿Í °°ÀÌ ÀϹÝÀûÀÎ server-client ¿Í´Â °³³äÀÌ Æ²¸°´Ù. Áï, server ¶ó°í ºÒ¸®´Â X display server ´Â keyboard , mouse °°Àº input device ·Î ºÎÅÍ ¸ðµç input À» ´Ù·ç°í ¶ÇÇÑ ½ÇÇàµÇ°í ÀÖ´Â ´Ù¸¥ client µé·ÎºÎÅÍ input µµ ÃßÀûÇÑ´Ù. server ´Â pc, worstation °ú special terminal ¿¡¼µµ À¯¿ëÇÏ¸ç ´Ù¸¥ machine ¿¡¼ download Çϰųª ROM ¾È¿¡ ÀúÀåµÇ¾î ÀÖ°í display capability ¸¦ Á¦°øÇÏ¸ç º¸´Ù ±âº»ÀûÀθ鿡¼´Â client application °ú local display h/w »çÀÌÀÇ ¸Å°³Ã¼(intermediary) ·Î¼ È°µ¿ÇÑ´Ù. client ´Â ƯÁ¤ÇÑ ÀÏÀ» ¼öÇàÇÏ´Â application program À¸·Î server ¿¡ÀÇÇØ h/w display ¿Í Åë½ÅÇÏ´Â request(for information, process etc)¸¦ ¸¸µç´Ù. X protocol Àº client °¡ server ¿¡°Ô information À» À§ÇÑ network »óÀÇ Åë½ÅÀ» À§ÇÑ°ÍÀÌ´Ù. -Window manager ´Â ƯÁ¤ÇÑ system À§¿¡ X ÀÇ look and feel À» °ÅÀÇ °áÁ¤ÇÏ¸ç ¸î°¡ÁöÀÇ window manager °¡ Á¸ÀçÇϸç MIT ÀÇ standard release ¿¡ µ¹¾Æ°¡´Â°ÍÀº twm(release 4) ÀÌ´Ù. Áï, multi application ÀÌ µ¿½Ã¿¡ running µÇ¸é input ÀÇ ¿ä±¸¿¡´ëÇÑ conflicting ¿¡ ´ëÇØ rules µéÀÌ Á¸ÀçÇؾ߸¸ ÇÑ´Ù. ´ëºÎºÐÀÇ window system °ú´Â ´Þ¸® X ´Â ÀÌ·¯ÇÑ rules ´Â ¾øÁö¸¸ ´ë½Å window manager ¶ó°í ºÒ¸®´Â special client °¡ ÀÖ´Ù. window manager ´Â server's display »ó¿¡¼ application ÀÇ main window ÀÇ position ¹× size ¸¦ À¯Áö °ü¸®ÇÑ´Ù. ¶ÇÇÑ another client ·Î ¼ ÀüÅëÀûÀ¸·Î screen space, olor resources,keyboard ¸¦ Æ÷ÇÔÇÑ physical resources ¸¦ ¿ä±¸ÇÏ´Â traffic ¿¡¼ÀÇ Á¶Á¤Çϴ Ưº°ÇÑ Ã¥ÀÓÀÌ ÁÖ¾îÁø´Ù. ±×¸®°í, window manager ´Â user °¡ screen »ó¿¡¼ window ¸¦ ¿Å±â°í resize ÇÏ°í new application À» start ÇÏ°í window °¡ overlap ÀÎÁö tiled(side by side), keyboard focus(click-to-type) À» ¹Ù²Ù±âÀ§ÇØ pointer button À» ´·¯¾ßÇÏ´ÂÁöÀÇ window system ÀÇ ¸¹Àº ºÎºÐÀ» manage ÇÑ´Ù. (window hint : application ÀÌ screen space ³ª resources ÀÇ ¿ä±¸¿¡´ëÇØ window manager ÀÇ ±³ÅëÁ¤¸®¸¦ À§ÇØ Áִ Ưº°ÇÑ Á¤º¸·Î¼ XView toolkit Àº application ÀÌ windowmanager hints ¸¦ setting ÇÏ´Â Æí¸®ÇÑ ¹æ¹ýÀ» Á¦°ø) -X ´Â screen »óÀÇ dot ÀÇ ¸ðµç pixel ¿¡ bit-mapped display ¸¦ control ÇÑ´Ù. ÀÌ·¯ÇÑ ÀÌÀ¯ ¶§¹®¿¡ °¡ÀåÁß¿äÇÑ client ÁßÀÇ Çϳª°¡ terminal emulator ÀÌ´Ù. terminal emulator ´Â multi-user system ¿¡ log in ÇÏ°í standard apphanumeric terminal ¿¡¼ »ç¿ëÇϱâÀ§ÇØ ±¸¼ºµÈ application µéÀ» ¼öÇàÇÑ´Ù. xterm ÀÌ °¡Àå ³Î¸® »ç¿ëµÇ´Â terminal emulator ÀÌ°í DEC VT102 terminal À̳ª tektronix 4014 ¸¦ º¸¿©ÁÖ³ª Çѹø¿¡ Çϳª¸¸ active ÇÑ´Ù. -X Consortium : window manager ¿Í ´Ù¸¥ client °£ÀÇ interaction À» À§ÇÑ ±Ô¾à(convention) À¸·Î 1989, july ¿¡ Ç¥ÁØȵǾúÀ¸¸ç ÀÌ ±Ô¾à¿¡ °üÇÑ manual ÀÌ ICCCM(Inter-Client Communications Conventions Manual) ÀÌ´Ù. ÀÌ ³»¿ëÀº application °£ÀÇ transferring data ¸¦ À§ÇÑ rules,layout schemes, transfer of keyboard focus, colormap installation µîÀ¸·Î application °ú window manager ÀÇ Ç¥ÁØÈ·Î ¼·Î´Ù¸¥ toolkit µé·Î ¸¸µé¾îÁø applicatin µéÀÌ °°Àº server »ó¿¡¼ °øÁ¸ÇÏ°í µ¹¾Æ°¥¼öÀÖ°Ô µÇ¾ú´Ù. ------------ --------------- ------------- DISPLAY MOUSE KEYBOARD ------------- --------------- ------------- -------------- Application -------------- -------------- XView Toolkit Device -------------- -------------- ----------------- Xlib X11 Server Window Manager -------------- -------------- ----------------- <----------------------------------------------------------------------> NETWORK fig 1-4. The S/W architecture of X applications 1.2 Handling Events -X °¡ Á¦°øÇÏ´Â window ´Â XView application °ú X server °£ ÀÇ connection ÀÌ´Ù. X windows µéÀÌ XView ¿¡ Áß¿äÇÑ ÀÌÀ¯´Â ÀÌ·¯ÇÑ X windows °¡ user ÀÇ ¸ñÀû¿¡ ºÎÇյǴ input À» À§ÇÑ target À̱⠶§¹®ÀÌ´Ù. ´Ù½Ã¸»Çϸé, ÀÌ·¯ÇÑ X window µéÀº user ·Î ºÎÅÍ events ¸¦ ¾ò°í XView ¼¼°è·Î events ¸¦ pass ÇÏ´Â ½ÇÁ¦ÀûÀÎ objects ÀÌ´Ù. X event ´Â server ¿¡ ÀÇÇØ º¸³»Áø application ¿¡ ¹æ±Ý ÀÏ¾î³ Èï¹ÌÀÖ´Â Çö»óÀÇ ±× ¹«¾ùÀ» Ç¥½ÃÇÏ´Â data structure ÀÌ´Ù. °¢ event µéÀÇ ³»¿ëÀº user's input,window system ,OS, application µî ÀÌ´Ù. ¿¹¸¦ µé¸é user °¡ keyboard ÀÛ¾÷ ¶Ç´Â mouse ¸¦ click Çϴ°ÍÀÌ event ¸¦ »ý¼ºÇϸç window ¸¦ screen ¿¡¼ ¿òÁ÷ÀÌ´Â°Í ¶ÇÇÑ event ¸¦ ¸¸µå´Â°ÍÀÌ´Ù. ¿©±â¼ ÀÏ¾î³ event ¸¦ screen »óÀÇ ´Ù¾çÇÑ window µé¿¡°Ô º¸³»´Â°ÍÀÌ ¹Ù·Î server ÀÇ ÀÏ ÀÌ´Ù. ¿©±â¼ »õ·Î¿î Á¤ÀÇ°¡ ³ª¿À´Âµ¥ server ¿Í application °£ ÀÇ event dispatch mechanism ÀÌ ¹Ù·Î Notifier ÀÌ´Ù.(Chap 19 ÂüÁ¶: Notifier maintains the flow of control in an application.) ¿¹¸¦ µé¸é, user °¡ window ¿¡¼ A ¸¦ Ä¡¸é X ´Â ±× event ¸¦ XView ¿¡°Ô ³Ñ°ÜÁÖ°í XView ´Â ÇØ´ç application ¿¡°Ô ÁÖ°í client ÀÇ application ÀÇ event procedure ¿¡ ÀÇÇØ ÀÌ event °¡ Çؼ®ÇÏ¿© ¿ªÀ¸·Î ±× window ¿¡ display µÈ´Ù. °á±¹ control Àº top level ¿¡ return µÇ¸ç ´ÙÀ½ event °¡ ÀÐÇôÁø´Ù. Server Pipe Signal XView Notifier Translate Events XView Distribute Events Application Application Application Client Event Event Event Procedure Procedure Procedure fig 1-5 The Notifier exists between the server and XView application 1.3 Development of the XView Toolkit -Kernel_based window system ÀÎ Sunview Toolkit Àº Sun Windows ¿¡ based µÇ¾î ÀÖÀ¸¸ç ÀÌ°ÍÀº single computer °¡ application, user's display, keyboard ¸¦ control ÇÑ´Ù. X window system Àº window system ÀÇ »õ ÀåÀ» ¿¾ú´Ù. Áï, ÀÌ°ÍÀº display ¸¦ control ÇÏ´Â server ¿Í ¼·Î´Ù¸¥ system ¿¡ µ¹¾Æ°¡´Â client application À» °¡Áö´Â server base ÀÌ´Ù. ¿À´Ã³¯ ¼öõ°³ÀÇ Sunview application ÀÌ Á¸ÀçÇϸç XView ÀÇ ¸ñÇ¥ÁßÀÇ Çϳª´Â ÀÌ·¯ÇÑ application À» X window ¿¡ porting ÇÏ´Â °ÍÀ̸ç Ãß°¡·Î Sun Àº ±× source code ¸¦ XView toolkit ¿¡ ¿ÏÀü freely available ÇÏ°Ô ¸¸µë. ±×°ÍÀº standard MIT X distribution »Ó¸¸ ¾Æ´Ï¶ó SVR4 ¿¡ °ð porting µÉ°ÍÀÌ´Ù. XView ´Â ´ÙÀ½°ú °°Àº window sets ¸¦ Á¦°øÇÑ´Ù. * Canvases - program ÀÌ draw µÇ´Â window *Text subwindows - editing ±â´ÉÀÌ ³»ÀåµÈ windows *Panels - buttons,choice items,sliders µîÀ» Æ÷ÇÔÇÑ window *TTy subwindows - character based terminal À» emulate ÇÏ´Â window ÀÌ·¯ÇÑ windows µéÀº frames ¶ó´Â window ¾ÈÀÇ subwindow ·Î¼ Á¸ÀçÇÑ´Ù. Frames ´Â transitory ¶Ç´Â permanent ÇÒ¼öÀÖ´Ù. ÀϽÃÀûÀÎ user ¿ÍÀÇ interaction À» À§ÇØ menu ¿¡´Â screen »ó¿¡ ¾î´À°÷¿¡µçÁö pop-up ÀÌ ÀÖÀ»¼ö ÀÖ´Ù. 1.4 OPENLOOK Graphical User Interface -XView Toolkit ÀÇ Áß¿äÇÑ Æ¯Â¡Àº OPENLOOK GUI ¸¦ ¼öÇà¹× ½ÇÇàÇϴ°ÍÀÌ´Ù.` OPENLOOK GUI ÀÇ ¸ñÀûÀº user ¿¡°Ô °£´ÜÇÏ°í ÀÏ°ü¼º ÀÖÀ¸¸ç È¿À²ÀûÀÎ Interface ¸¦ Á¦°øÇÏ´Â °ÍÀÌ´Ù. OPENLOOK Àº Sun °ú AT&T ¿¡¼ SVR4 ÀÇ graphical user interface standard ·Î Á¦°øµÇ°í ÀÖ´Ù. °³¹ßÀ» ÇÏ´Â »ç¶÷µéÀÌ Ç¥ÁØÀ¸·Î ÇÔÀ¸·Î½á ´Ù¾çÇÑ application À» ÀÏ°ü¼ºÀÖ°Ô ¶ÇÇÑ system ¿¡ ±¸¾Ö¾øÀÌ °¡´ÉÇÏ´Ù´Â°Í ÀÌ´Ù. 2.The XView Programmer's Model 2.1 Object-oriented Programming -programmer ¿¡°Ô´Â XView °¡ object-oriented toolkit ÀÌ´Ù. XView objects ´Â application ÀÇ user interface ·Î ºÎÅÍ ±¸¼ºµÇ´Â °ÍÀ¸·Î blocks À» ¸¸µå´Â °ÍÀÌ´Ù. °¢ application Àº Ưº°ÇÑ package ·Î ºÎÅÍÀÇ object ·Î »ý°¢µÇ¾îÁú¼ö ÀÖ´Ù. °¢ package ´Â user °¡ object ·Î ±¸¼ºÇϱâ À§ÇØ ¼±ÅÃÇÒ¼öÀִ Ư¼º ÀÇ list ¸¦ Á¦°øÇϸç ÀûÀýÇÑ package µé·ÎºÎÅÍ object ¸¦ ¼±ÅÃÇÏ¿© ÇÊ¿äÇÑ application À» À§ÇÑ user interface ¸¦ ¸¸µé¼ö°¡ ÀÖ´Ù. XView ´Â object-oriented programming ÀÇ ±Ùº»ÀûÀÎ ¿øÄ¢µéÀ» ±Ùº»À¸·Î ÇÑ´Ù. *Objects are represented in a class hierarchy. *Objects are opaque data type. *Objects ´Â function À» ÅëÇÏ¿© message ¸¦ setting ÇÒ¼öÀִ Ư¡À» °¡Áü. *Objects ´Â event ¿¡ ÀÇÇØ ±¸µ¿µÇ´Â callback procedure ¸¦ °¡Áø´Ù. 2.1.1 Object Class Hierachy -XView ´Â tree ±¸Á¶·Î½á Object ÀÇ class ¸¦ Á¤ÀÇÇÑ´Ù. ¿¹¸¦µé¾î Frame Àº ´õ general ÇÑ class ÀÎ window ÀÇ subclass ÀÌ´Ù. Generic Object Server Screen Cursor (Drawable) Fullscreen Font Menu Server Image Window Frame Tty (Openwin) Scrollbar Icon Text Canvas Panel fig 2-1 XView class hierachy -°¢ class ´Â ´Ù¸¥ classes ³ª packages ¿Í´Â unique ÇÑ features ¸¦ °¡Áø´Ù. XView ¿¡¼ ÇϳªÀÇ class ´Â ¿¬°üµÈ function set ÀÎ package ¶ó°íµµ Á¾Á¾ ºÒ¸°´Ù. ±×·¯³ª Notifier package °°Àº object class ±¸Á¶ÀÇ ±¸¼º¿ä¼Ò °¡ ¾Æ´Ñ xview package µµ ÀÖ´Ù. - ÀϺΠobject ´Â visual ÀÌ°í ´Ù¸¥°ÍµéÀº non-visual ÀÌ´Ù. visual objects ´Â windows, scrollbars,frames,panels, panel item µîÀÌ°í, non-visual objects ´Â °¢°¢ ÇüÅ°¡ ¾Èº¸À̴°ÍÀÌÁö¸¸ visual objects ¿¡¼ µµ¿òÀ» ÁÖ´Â information À» °¡Áö°í ÀÖÀ¸¸ç , server , screen, font ovbjects°¡ ÀÖ´Ù. ¿¹¸¦µé¸é,screen Àº objects °¡ °¡Áú¼öÀÖ´Â default bg, fg color °ª°ú color type °ú °°Àº information À» Á¦°øÇÑ´Ù. - visual,non-visualÀÇ ¸ðµç objectsµéÀº ÀÌ object classing system ÀÇ ºÎºÐÀÌ´Ù. XView ´Â object-oriented model ·Î½áÀÇ static subclassing °ú chained inheritance ¸¦ °¡Áø´Ù. µû¶ó¼ ÇϳªÀÇ Æ¯Á¤ class ÀÇ ¸ðµç object µéÀº super class ¶ó°í ºÒ¸®´Â parent class ÀÇ properties ¸¦ ³»ÀçÇÏ°í ÀÖ´Ù. Generic Object ÀÎ XV_OBJECT ´Â ¸ðµç object µéÀÌ °¡Áö´Â ¾î¶² basic properties ¸¦ °¡Áø´Ù. ¿¹¸¦µé¸é °°Àº object ´Â screen »ó¿¡¼ storage ¸¦ ÃÖÀûÈ ÇϱâÀ§ÇØ ¿©·¯Àå¼Ò¿¡ ³ªÅ¸³¯¼ö°¡ ÀÖ´Ù. ÀÌ·¯ÇÑ ±â·ÏÀ» À¯ÁöÇϱâÀ§ÇØ Generic Object ´Â objects ÀÇ instances ÀÇ È½¼ö¿¡ ´ëÇÑ reference ¸¦ °¡Áö°í ÀÖ´Ù. ¸ðµç objects ´Â owner ¸¦ °¡Áö°í ÀÖÀ¸¹Ç·Î object ÀÇ parent ´Â ±× object ÀÇ generic part ºÎºÐ¿¡ ±â·Ï µÇ¾î ÀÖ´Ù. ÇϳªÀÇ object °¡ Ưº°ÇÑ ±â´É¼öÇàÀÇ Çʿ伺À¸·Î lower-level classes °¡ ±× ±â´ÉÀ» ¼öÇàÇϱâÀ§ÇØ Æ¯¼ºµéÀ» define ÇÏ°í ÀÖ´Ù. °¢ class ´Â ±× dbject ÀÇ ¸ðµç instance Áß¿¡ °øÀ¯µÇ¾î Áö´Â Ư¼ºµéÀ» Æ÷ÇÔÇÏ°í ÀÖ´Ù. ¿¹¸¦µé¸é, panels ´Â PANEL package ÀÇ ÀϺκÐÀÌ´Ù. ¸ðµç panel µéÀº ±× object ÀÇ °¢ instance °¡ ´Þ¶ó¼ properties°¡ ´Þ¶óÁö´õ¶óµµ PANEL package ÀÇ Æ¯¼ºµéÀº °øÀ¯ÇÏ°í ÀÖ´Ù. -À§¿¡¼ ¾ð±ÞÇÏ¿´µíÀÌ XView ´Â subclassing À» »ç¿ëÇϹǷΠ°¢ package ´Â superclass ÀÇ properties ¸¦ ³»ºÎÀûÀ¸·Î °¡Áø´Ù. PANEL package ´Â window dimension, screen »óÀÇ À§Ä¡,thickness,depth, visual and colormap information À» °¡Áö´Â WINDOW package ÀÇ Æ¯¼ºÀ» °¡Áú¼ö°¡ Àִµ¥ ±× ÀÌÀ¯´Â WINDOW package ÀÇ subpackage À̱⶧¹®ÀÌ´Ù. ¶ÇÇÑ, WINDOW package ´Â ¸ðµç objectµéÀÌ ±×·¸µíÀÌ root object ÀÎ XV_OBJECT ÀÇ subclass À̹ǷΠpanel ÀÌ size ¿Í position of itself °°Àº generic information ¿¡ access °¡ °¡´É ÇÏ´Ù. 2.1.2 Object Handles - user °¡ ÇϳªÀÇ object ¸¦ ¸¸µé¶§ XView function Àº ±× object ¿¡ ´ëÇØ ÇϳªÀÇ handle À» return ÇÑ´Ù.ÈÄ¿¡ user °¡ ±× object ¿¡ ´ëÇÑ »óųª Á¤º¸¸¦ ¾Ë°í ½ÍÀ»¶§´Â ÀûÀýÇÑ function ¿¡ handle À» pass ÇÏ¸é µÈ´Ù. object handles ÀÇ ±¸Çö ¹æ¹ýÀº information hiding ¹æ¹ýÀ» ¾²°í ÀÖÀ¸¹Ç·Î ÀÌ ÇÚµéÀº ±× Àǹ̿¡¼ opaqueÇϱ⠶§¹®¿¡ ±× object ¸¦ ³ªÅ¸³»´Â ½ÇÁ¦ÀûÀÎ data structure ¸¦ ÅëÇÏ¿©´Â ¾Ë¼ö°¡ ¾ø´Ù. °¢ object type Àº handle ¿¡ ÀÏÄ¡ÇÏ´Â type À» °¡Áø´Ù. C language °¡ opaque type ¸¦ °®Áö¾ÊÀ¸¹Ç·Î À§¿¡¼ ¾ð±ÞµÈ ¸ðµç opaque data type Àº XView type ÀÇ Xv_opaque ¶Ç´Â Xv_object ÀÇ typedef' ÀÌ´Ù. opaque data type ¿¡ Ãß°¡·Î¼ pointerµé¿¡ ÂüÁ¶µÇ´Â°ÍÀÌ ¾Æ´Ï¶ó structure µé¿¡ ÂüÁ¶°¡ µÇ´Â ¸î°¡Áö typedef µéÀÌÀÖ´Ù.(Event,Rect,Rectlist) table 2-1. XView Objects,Owners,Packages and Data Types Object Owner Package Handle Data type canvas frame CANVAS Canvas cursor window or screen CURSOR Xv_cursor font root window FONT Xv_font frame frame or root window FRAME Frame icon window or screen ICON Icon menu server MENU Menu openwin frame OPENWIN Openwin panel frame PANEL Panel screen null SCREEN Screen scrollbar panel or canvas SCROLLBAR Scrollbar server null SERVER Server tty frame TTY Tty window frame WINDOW Xv_window 2.2 Attribute-based Functions -complex ÇÏ°í flexible ÇÑ objects µéÀ» ±âº»À¸·Î »ç¿ëµÇ°í ÀÖ´Â XView ¿Í °°Àº model ¿¡¼ ±× dbjects ¸¦ ¾î¶»°Ô client °¡ ¿î¿ëÇÒ°ÍÀΰ¡ ÀÇ ¹®Á¦°¡ ÀÖ´Ù. XView interface ÀÇ basic idea ´Â ¸¹Àº attribute µéÀ» argument ·Î °¡Áö´Â ¸î°³ÀÇ function µéÀ» Á¦°øÇÏ°í ÀÖ´Ù. 2.2.1 Creating and Manuplating Objects -programmer °¡ object handle À» ÂüÁ¶ÇÏ¿© ¾î¶² object ¸¦ ¿î¿ëÇÏ´Â ¸î°¡Áö function µéÀÌ ÀÖ´Ù. * xv_init() : server ¿ÍÀÇ connection À» ±¸ÃàÇϸç Notifier ¿Í Defaults/Resource-Manager database ¸¦ ÃʱâÈ Çϸç server resource-manager database ¸¦ load Çϸç ~/.Xdefaults database ¿Í passing µÈ attributes ¸¦ Àд´Ù. * xv_create() : objects ¸¦ »ý¼ºÇÑ´Ù. * xv_destroy() : objects ¸¦ ÁäÀδÙ. * xv_find() : ¾î¶² Á¶°Ç¿¡ ¸Â´Â object ¸¦ ã´Â´Ù. ¾øÀ¸¸é »õ·Î ¸¸µç´Ù. * xv_get() : attribute ÀÇ °ªÀ» ÃëÇÑ´Ù. * xv_set() : attribute ÀÇ °ªÀ» setting ÇÑ´Ù. -À§ÀÇ 6°³ÀÇ function À¸·Î XView ¿¡¼ °¡´ÉÇÑ ¸ðµç package µé·ÎºÎÅÍ objects µéÀÌ »ý¼ºµÇ°í ¿î¿ëµÇ¾îÁø´Ù. programmer °¡ ¾î¶°ÇÑ package ·Î ºÎÅÍ ÇÑ object ÀÇ °æ¿ì¸¦ ¸¸µé±â¸¦ ¿øÇÑ´Ù¸é xv_create() ¸¦ ÀÌ¿ëÇÑ´Ù. Panel panel; panel = xv_create(panel_parent,PANEL,NULL); - ¿©±â¿¡¼ PANEL package ·ÎºÎÅÍ ÇϳªÀÇ panelÀÌ »ý±â´Âµ¥ object-specific ÇÑ attribute °¡ »ý·«µÇ¾úÀ¸¹Ç·Î panel ÀÇ default properties °ªÀ» °¡Áö¸ç »õ·Î¿î panel object ¿¡ ´ëÇÑ return µÈ handle ÀÌ º¯¼ö panel ¿¡ ÀúÀåµÇ¸ç ÀÌ handle Àº pointer °¡ ¾Æ´Ï°í ±× object ÀÚü¿¡´ëÇÑ ¾î¶² À¯¿ëÇÑ information µµ °¡Áö°í ÀÖÁö ¾Ê´Ù. 2.2.2 Changing Object Attributes - programmer ´Â xv_create() ·Î ºÎÅÍ ÇϳªÀÇ parameter·Î return µÈ ±× handle À» function xv_get() °ú xv_set() ¿¡ »ç¿ëÇÏ¿© ±× object ÀÇ attribute ¸¦ ¾ò°í setting ÇÑ´Ù. panel=xv_create(...) xv_set(panel,PANEL_LAYOUT,PANEL_HORIZONTAL,NULL); - ±× panel ¿¡¼ ¾ò¾îÁø handleÀº PANEL package attribute ¸¦ º¯°æÇϴµ¥ ¾²ÀÓ PANEL_LAYOUT ÀÇ °ªÀº PANEL_HORIZONTAL À̸ç, variable argument ÀÇ ³¡Àº NULL ·Î ³ªÅ¸³»´Â³× NULL Àº »ó¼ö 0 °¡ ¾Æ´Ï¸ç terminating argument ·Î ¾²¿©¾ß¸¸ÇÑ´Ù. 2.2.3 Types of Attributes - Attribute ´Â ¼¼°³ÀÇ ¹üÁÖ·Î ³ª´©¾î Áø´Ù. * generic : ¸ðµç XView objects ¿¡ Àû¿ëµÇ´Â attributes. * common : ¸¹Àº objects ¿¡ ÀÇÇØ Áö¿øµÇ´Â attributes ÀÌÁö¸¸ ¸ðµç objects ¿¡ Àû¿ëµÇÁö´Â ¾Ê´Â attributes. * specific : Ưº°ÇÑ package ¶Ç´Â object ÀÇ class ¿¡ Àû¿ëµÇ´Â attributes. - XView ´Â ÇϳªÀÇ attribute ÀÇ ¾²ÀÓÀ» À̸§À» ÅëÇÏ¿© ¾Ë¼öÀÖ°Ô ÇÑ´Ù. Áï, Ưº°ÇÑ package ¿¡ Àû¿ëµÉ attribute µéÀº ±× package name ¿¡ ÀÇÇØ ¾ÕºÎºÐÀÌ prefix µÇ¾îÀÖ´Ù. ¿¹¸¦µé¸é, CANVAS_*, CURSOR_*, FRAME_*, ICON_*, PANEL_*,SCROLLBAR_*, TEXTSW_*, TTY_*, µîÀÌ´Ù. - common °ú generic attributes ´Â ¸î°¡Áö ¼·Î´Ù¸¥ object type ÀÇ Àû¿ëÀ» À§Çؼ XV_. À¸·Î prefix µÇ¾îÁø´Ù. ¿¹¸¦µé¸é, generic attribute ÀÇ XV_HEIGHT ´Â ¸ðµç objects ¿¡ Àû¿ëµÇ´Âµ¥ ÀÌ´Â ¸ðµç object µéÀÌ ¹Ýµå½Ã ³ôÀ̸¦ °¡Áö±â ¶§¹®ÀÌ´Ù. ¹Ý´ë·Î, ´ÜÁö window ¿¡ Àû¿ëµÇ´Â attribute ´Â WIN_. À¸·Î prefix µÇ¾îÁü. WIN_HEIGHT ¿Í WIN_WIDTH °°Àº attributes ´Â panel À̳ª canvas µéÀÌ ³ªÅ¸³ªµç »ó°ü¾øÀÌ ¸ðµç window ¿¡ Àû¿ëµÈ´Ù. attribute value part ÀÇ value part ´Â attribute ¸¶´Ù Ʋ¸°´Ù. ÀÌ·¯ÇÑ ÀÌÀ¯´Â ±× attribute °¡ ´Ù¾çÇÑ ¹üÀ§ÀÇ º¯¼ö ¸¦ ³ªÅ¸³¾¼öµµ Àֱ⠶§¹®ÀÌ´Ù. Panel_item panel_item; panel_item=xv_create(panel,PANEL_CYCLE, XV_WIDTH, 50, XV_HEIGHT, 25, PANEL_LABEL_X, 100, PANEL_LABEL_Y, 100, PANEL_LABEL_STRING, "Open File" PANEL_CHOICE_STRINGS, "Append to file", "Overwrite contents", NULL, NULL); - PANEL_CHOICE_STRINGS ¸¦ Á¦¿ÜÇÑ ¸ðµç attributes ´Â single value ¸¦ °®´Â´Ù. PANEL_CHOICE_STRINGS attribute ´Â string ÀÇ list ¸¦ °¡Áö¸ç NULL ·Î ³¡³´Ù. ¸¶Áö¸· NULL Àº xv_create() function À¸·Î pass µÈ attribute º¯¼ö°ªÀ» ³¡³½´Ù. 2.4 Types of Objects - ¿©±â¿¡¼´Â °³³äÀûÀÎ Â÷¿ø¿¡¼ XView °¡ Á¦°øÇÏ´Â ´Ù¾çÇÑ Á¾·ùÀÇ object ¸¦ ¼³¸íÇÏ°íÀÚ ÇÑ´Ù. ¸¹Àº °æ¿ì¿¡ ÀÖ¾î OPENLOOK GUI Specification Guide ·Î ºÎÅÍ ¹ßÃéµÈ ±×¸²µéÀÌ object ÀÇ ¿Ü°üÀ» ¼³¸íÇϴµ¥ ¾²¿©Áø´Ù. object °¡ ¾î¶»°Ô ¸¸µé¾îÁö¸ç ±×µéÀÇ Æ¯¼ºµéÀº ¹«¾ùÀÎÁö¿¡ ´ëÇÑ »ó¼¼ÇÑ ³»¿ëµéÀº °¢ dbject Ư¡º°·Î °¢ chapter º°·Î ´Ù·é´Ù.(Manual ÂüÁ¶) ´ÙÀ½Àº »ý¼ºµÇ¾î Áú¼ö ÀÖ´Â object ÀÇ list ÀÌ´Ù. * Generic Objects * Windows * Frames * Openwins * Canvases * Text Windows * Menus * Scrollbars 2.4.1 Generic Objects - ÀÌ °ÍÀº °èÃþ±¸Á¶ ¿¡¼ root object ÀÌ´Ù. ÀÌ ÀÚü°¡ function À» °®Áö ¾ÊÀ¸¹Ç·Î ¾Æ¹«µµ Generic Object ÀÇ instance ¸¦ ¸¸µé¼ö°¡ ¾ø´Ù.(hidden class) Generic Object Server Screen Cursor (Drawable) Fullscreen Font Menu Server Image Window Frame Tty (Openwin) Scrollbar Icon Text Canvas Panel Generic Object Server Screen Cursor (Drawable) Fullscreen Font Menu Server Image Window Frame Tty (Openwin) Scrollbar Icon Text Canvas Panel fig2-2. Object creation is top down; attribute setting is bottom up - ¸ÕÀú, Generic Object °¡ ¸¸µé¾î Áö°í ±× object ÀÇ subclass ÀÇ object °¡ topdown ¹æ½ÄÀ¸·Î ¸¸µé¾îÁö°í bottom up ¹æ½ÄÀ¸·Î °¡¸é¼ program »óÀÇ ÁÖ¾îÁø attribute °¡ setting µÇ¾îÁø´Ù. ÇϳªÀÇ panel À» ¸¸µå´Â ¾Æ·¡ÀÇ °æ¿ì¸¦ »ý°¢ÇØ º¸ÀÚ. extern xv_font font; Panel panel; panel= xv_create(frame, PANEL, XV_Y, 5, WIN_HEIGHT, 50, PANEL_FONT, font, NULL); - À§¿¡¼ ÇϳªÀÇ panel ÀÌ ¸¸µé¾î Áú¶§ °¡Àå¸ÕÀú »ý¼ºµÇ´Â °ÍÀÌ Generic Object ÀÌ´Ù.´ÙÀ½¿¡, panel object ¿¡ ÀÇÇØ ÇϳªÀÇ window °¡ ¸¸µé¾îÁø´Ù. °¢°¢Àº ÇØ´ç °èÃþ¿¡ Ç¥½ÃµÈ default °ªÀ¸·Î topdown ¹æ½ÄÀ¸·Î object °¡ ¸¸µé¾î Áö¸ç, ¿©±â¿¡¼ ¿ª¼øÀ¸·Î xv_create() ¿¡ ÀÇÇØ ÁÖ¾îÁø attribute ·Î setting µÇ¾îÁø´Ù. panel ÀÇ x, y position ÀÌ setting µÉ¶§ y °ª¸¸ setting µÇ¾ú´Âµ¥ ÀÌ´Â ±× panel ÀÇ width °¡ extend µÉ¼öÀִٴ°ÍÀ» parent panel ¿¡°Ô »ý¼ºµÇ´Â window package °¡ ¾Ë¸®´Â°ÍÀÌ´Ù. ¿©±â¼ parent ´Â owner ÀÎ frame ÀÌ´Ù. 2.4.2 Window Objects - ¸¹Àº XView objects ´Â display ¿Í events ¸¦ receive ÇϱâÀ§ÇØ X window ¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Ù. ¿¹¸¦µé¸é, frames, tty windows,scrollbars,icons µîÀÌ ÀÖ´Ù. XView window class ´Â Generic Object class ¿Í °°ÀÌ hidden class À̹ǷΠ¿Ü°üÀûÀ¸·Î´Â ¸¸µé¾î ÁöÁö ¾Ê´Â´Ù. Áï, ±× window ÀÇ subclass ÀÎ object °¡ ¸¸µé¾îÁø´Ù. ÀÌ°ÍÀº panel items ¸¦ Á¦¿ÜÇÏ°í´Â ´ëºÎºÐÀÇ visual object ¸¦ Æ÷ÇÔÇÑ´Ù. Nonvisual object ´Â À̸§À» °¡Áö¹Ç·Î window ÀÇ subclass °¡ ¾Æ´Ï°Å³ª windows ¸¦ Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù.¿¹¸¦µé¸é, Fonts ´Â window ¿¡ display µÇ°Å³ª ¸Þ¸ð¸® image ·Î Ç¥ÇöµÇ°Å³ª bitmap À» °¡ÁöÁö »ç¿ëµÉ windows ¸¦ ¿ä±¸Çϰųª Æ÷ÇÔ ÇÏÁö´Â ¸øÇÑ´Ù. ÀϺΠwindows ÀÇ attribute ´Â depth ³ª forground color background color ¸¦ °¡Áú¼ö°¡ ÀÖ´Ù. 2.4.3 Frames and Subframes - µÎ°³ÀÇ frame ÀÇ Á¾·ù°¡ ÀÖ´Ù. * Base frames * Pop-up frames - ÇϳªÀÇ ¿¹¿Ü·Î½á ¸ðµç frames ´Â frame °ú tild(¼·Î overlap µÉ¼ö¾ø´Â) ¿¡ ÀÇÇØ bound µÇ´Â sunwindow ¸¦ °¡Áö´Â free-floating window µéÀÌ´Ù. - Base fame : root window ¿¡ »óÁÖÇÏ¸é¼ ¸ðµç frame µéÀÌ ¼·Î overlap ÇÏ´õ¶óµµ ¾î¶² ´Ù¸¥ window ¿¡ Á¦¾àÀ» ¹ÞÁö¾Ê´Â´Ù. ÀÌ´Â ¶Ç ÇϳªÀÇ base frame Àº ´Ù¸¥ application °ú °ü·ÃµÇ¹Ç·Î application ÀÇ frame À¸·Î ¾Ë·ÁÁ® ÀÖ´Ù. Subframe Àº ±× owner °¡ frame ÀÎ frames µé·Î½á ±× application ÀÇ base frame ¿¡ ÀÇÇØ controll µÇ¾îÁø´Ù. OPENLOOK GUI Specification Guide ·Î ºÎÅÍ base frame ÀÇ ÀüüÀûÀÎ ÇüŸ¦ º¼¼ö°¡ Àִµ¥ ¸¸¾à window manager ´Ù¸£¸é base fame Àº ´Ù¸¦¼öÀÖ´Ù. ¿Ö³ÄÇϸé, XView ´Â window manager ¿¡°Ô hints ¸¦ ÁÜÀ¸·Î½á title bar information, resize corners µîÀÇ Æ¯Â¡À» Æ÷ÇÔÇÑ attribute ¸¦ Á¤ÀÇÇϱ⠶§¹®ÀÌ´Ù.¸¸¾à OPENLOOK window manager °¡ ¾²ÀÌÁö ¾Ê´Â´Ù¸é ÀÌ·¯ÇÑ attribute ¸¦ º¸ÀåÇÒ¼ö°¡ ¾ø´Ù. - Pop-up frame : ÀüÇüÀûÀ¸·Î Çѹø ¶Ç´Â ±× ÀÌ»óÀÇ ÀϽÃÀûÀ¸·Î »ç¿ëµÇ´Â frame ÀÌ´Ù. ÀÌ°ÍÀº ±× frame ÀÇ ÁÂÃø»ó´Ü ÀÇ pushpin ¿¡ÀÇÇØ control µÈ´Ù. pop-up frame ÀÇ Á¾·ù´Â ´ÙÀ½°ú °°´Ù. *Command frame - ÇϳªÀÇ command ¸¦ À§ÇØ operland ¸¦ Á¦°øÇϸç parameter ¸¦ setting ÇÑ´Ù. ÀÌ°ÍÀº default panel À» °¡Áö´Â ÇϳªÀÇ subframe À¸·Î½á ¼öÇàµÇ¾îÁø´Ù. *Help frame - ±× object ¸¦ À§ÇÑ help text ¸¦ display Çϸç subframe ³»ÀÇ ÇϳªÀÇ text subwindow ·Î ¼öÇàµÇ¾îÁø´Ù. *Notices - ÀÌ°ÍÀº special pop-up window ·Î½á request ¸¦ conform ÇÏ°í user ÀÇ ÁÖÀÇ»çÇ׿¡ ´ëÇÑ ¸Þ¼¼Áö, condition À» display ÇÑ´Ù. 2.4.4 Subwindows - Subwindow ´Â ¸î°¡Áö ±âº»ÀûÀÎ Ãø¸é¿¡¼ frame °ú ´Ù¸£´Ù. ±×µéÀº °áÄÚ µ¶¸³ÀûÀ¸·Î Á¸ÀçÇÏÁö¸øÇÏ°í Ç×»ó owner ¸¦ °¡Áö¸ç frame À̳ª ´Ù¸¥ window ¿¡ÀÇÇØ À¯ÁöµÈ´Ù.¶ÇÇÑ ÀÚüÀûÀ¸·Î ÀÚ½ÅÀÇ frame À» °®Áö¸øÇÑ´Ù. frame ÀÌ ÀÚÀ¯·ÎÀÌ screen »ó¿¡ ¿òÁ÷¿© Áú¼öÀִ¹ݸé subwindow ´Â ±×µéÀÌ ¼ÓÇÑ frame ÀÇ °æ°è¾È¿¡¼ Á¦ÇÑÀ» ¹Þ´Â´Ù.±×¸®°í frame ¿¡ ´ëÁ¶ÀûÀ¸·Î subwindow ´Â tiled(¼·Î overlap ¾ÈµÇ´Â°Í) ÀÌ´Ù. ÀÌ·¯ÇÑ Á¦ÇѹüÀ§¾È¿¡¼ program À̳ª user ¿¡ ÀÇÇØ ¿òÁ÷¿©Áö°í resize µÈ´Ù. Canvas subwindow ¿Í text subwindow µéÀº OPENWIN package ÀÇ subclass ÀÌ´Ù. *Canvas Subwindows : canvas ´Â °¡Àå ÀüÇüÀûÀÎ subwindow ÀÌ´Ù. ÀÌ°ÍÀº XLib graphics ÀÇ °á°ú°¡ display µÇ´Â °÷ÀÌ´Ù. canvas object ´Â visible window ÀÇ size º¸´Ù ´õ Å« ¿µ¿ª¿¡ application ÀÌ ±×·ÁÁö´Â °ÍÀ» °¡´ÉÇÏ°Ô²û configuration µÈ´Ù. ÀüüÀûÀÎ ±×¸²ÀÇ È¸é ÀÌ ³ªÅ¸³ª´Â window °¡ paint window ¶ó°í ºÒ¸°´Ù. paint window ÀÇ visible portion À» view window ¶ó°í ÇÑ´Ù. canvas subwindow ¿¡³ªÅ¸³ª´Â °ÍÀÌ ¹Ù·Î view window ÀÌ´Ù. *Text Subwindows : ¶Ç´Ù¸¥ basic window type ÀÌ text subwindow ÀÌ´Ù. ÀÌ´Â OPENLOOK text editing model À» »ç¿ëÇÏ¿© ±âº»ÀûÀÎ text editing ´É·ÂÀ» Á¦°øÇÑ´Ù. *Panels : buttons °ú setting ÀÌ dispaly µÇ´Â control area(Á¶Àý¿µ¿ª) ÀÌ´Ù. ÀÌ°ÍÀº pane ¾È¿¡¼ ´ÙÀ½ÀÇ menu µéÀÇ º´ÇüµÈ Á¶ÇÕÀ¸·Î ±¸¼ºµÈ´Ù. -Buttons,Check boxes,Sliders, Gauges, Text and numeric fields * Menus : ÀÌ°ÍÀº Generic Object ÀÇ subclass ÀÌ´Ù. ÀÌ ÀÚü´Â ÇϳªÀÇ windowless object ÀÌ´Ù. user ¿¡ÀÇÇØ activate µÇ´Â°æ¿ì´Â window ¾È¿¡¼ÀÌ°í 3 type ÀÇ menu °¡ ÀÖ´Ù. 1)Pop-up menu ; user °¡ ÇÏ´ÏÀÇ window ¿¡¼ menu button À» ´·¶À»¶§ display µÇ´Â menu. 2)Pullright menu ; menu ÀÇ ¿À¸¥ÂÊ¿¡ menu ·Î½á display . 3)Pulldown menu ; panel À§¿¡¼ menu button ÀÇ ¾Æ·¡¿¡ display. * Scrollbars :ÀÌ°ÍÀº ´Ù¾çÇÑ subwindow ¿¡ ÀÚüÀûÀ¸·Î ºÙ¾î¼ Á¸ÀçÇÏ´Â object. ÀÌ°ÍÀº cable À̶óºÒ¸®´Â bar À§¿¡¼ OPENLOOK metaphor ¸¦ ±¸ÇöÇÑ´Ù. ÇϳªÀÇ visual object À̹ǷΠWINDOW class ÀÇ subclass ÀÌ´Ù. SCROLLBAR package ´Â ´ÜÁö scrollbar window ¸¸ °ü¸®ÇÑ´Ù. ÀÌ°ÍÀº ¶Ç ¼öÆò ¶Ç´Â ¼öÁ÷À¸·Î oriented µÇ¾îÀÖ´Ù. ±×·¯³ª Text subwindows °°Àº °ÍµéÀº default ·Î ¼öÁ÷¸¸ Á¦°øÇÏ°í ¼öÆò scrollbar ´Â Çã¿ëÇÏÁö¾Ê´Â´Ù. *Icons : ¾ÆÀÌÄÜÀº application ÀÌ ´ÝÇôÁ³À»¶§ ±× application À» ³ªÅ¸³»´Â ÀÛÀº image ÀÌ´Ù. ICON package ´Â ¸Å¿ìÀÛ°í graphic À» display ÇÏ°í input À» ¹Þ¾ÆµéÀÌ´Â window À̹ǷΠÀÌ°ÍÀº WINDOW package ÀÇ subclass ÀÌ´Ù. user °¡ ICON package ¿¡¼ setting ÇÒ¼öÀÖ´Â À¯ÀÏÇÑ attribute ´Â window¾È¿¡¼ display µÉ image ¸¦ ³ªÅ¸³»°í ±× imageÀÇ geometry ¸¦ iconedit ·Î ±¸ÇöÇÒ¼ö°¡ ÀÖ´Ù. 2.4.5 Nonvisual Objects - screen »ó¿¡´Â ³ªÅ¸³ªÁö ¾ÊÁö¸¸ Generic Object ÀÇ subclass ÀÎ ¸î°¡Áö nonvisual objects µéÀÌ ÀÖ´Ù. SERVER : ÀÌ package ´Â X server ¿Í interact ÇÑ´Ù. window-server ´Â screen ¿¡ ±×¸²À» ±×¸®°í user ÀÇ input À» ¹Þ´Â program À¸·Î Ưº°ÇÑ application ¿¡ setting µÉ¼öÀÖ´Â information °ú user-configurable resources µéÀ» À¯Áö°ü¸®ÇÑ´Ù. SCREEN : ÀÌ object ´Â visual Ư¼º°ú physical screen ÀÇ ´Ù¸¥ Ư¼ºµéÀ» ³ªÅ¸³»¸ç XLib SCREEN object ¿Í ºÐ¸®µÇ¾î ÀÖ´Ù. FONT : ÀÌ font package ´Â programmer °¡ font family ¿Í style °°Àº ´Ù¾çÇÑ attribute ÀÇ fonts µéÀ» ¿ä±¸ÇÒ¼ö ÀÖµµ·ÏÇϸç name , size, scling À¸·Î½á Á¢±Ù°¡´ÉÇÏ´Ù. CURSOR : cursor ¶Ç´Â pointer ´Â screen »ó¿¡¼ mouse ÀÇ À§Ä¡¸¦ ³ªÅ¸³»´Â visual object ÀÌ´Ù. CMS : Colormap segments(cms) ·Î½á color specification À» Á¦°øÇÏ´Â window ¿Í °ü·ÃµÇ´Â object ·Î½á Cms objects ´Â multiple window ¿Í °øÀ¯µÇ¾î Áú¼ö°¡ ÀÖ´Ù. - ÀÌ·¯ÇÑ objects µéÀº X window system °ú ¹ÐÁ¢ÇÑ ¿¬°ü°ü°è¿¡ ÀÖÀ¸¸ç X ·Î ºÎÅÍ attribute µéÀ» setting Çϰųª getting ÇÏ·Á´Â ¿äûÀ» ÇÔÀ¸·Î½á ¿î¿ëµÇ¾îÁø´Ù. 2.5 The Notifier Model - XView ´Â notification-base system ÀÌ´Ù. Notifier ´Â ÇϳªÀÇ user process ¾È¿¡¼ entity ¸¦ control Çϸç OS ·ÎºÎÅÍ input À» ÀÐ°í ±×°ÍÀ» high-level events ·Î formatting ÇÑ´Ù. ±×¸®°í³ª¼ ´Ù¸¥ XView object ¿¡ »Ñ·ÁÁØ´Ù. 2.5.1 Callback Style of Programming - ÀüÇüÀûÀÎ programming¹æ¹ýÀº main control loop°¡ application¾È¿¡ Á¸ÀçÇß´Ù. ±×·¯³ª Notification-base system¿¡¼´Â main control loop °¡ application ÀÌ ¾Æ´Ï¶ó Notifier ¾È¿¡ Á¸ÀçÇÑ´Ù. Notifier ´Â events µéÀ» Àаí notify Çϸç, ¶Ç´Â Notifier ¿¡ µî·ÏµÇ¾îÀÖ´Â ÇØ´ç application ÀÇ ´Ù¾çÇÑ procedureµéÀ» ²ø¾î³½´Ù. ÀÌ·¯ÇÑ procedure °¡ ¹Ù·Î notify procs ¶Ç´Â callback procs ¶ó°í ºÎ¸¥´Ù. Application Code Notifier start register callback procs with Notifier call Notifier end read input 2.5.2 Why a Notification-based System? - ¸¸¾à, ´ç½ÅÀÌ Notification-based system ¿¡ Àͼ÷Ä¡ ¸øÇÏ´Ù¸é °ð Àͼ÷ÇØ Áö¸®¶ó !! ±×·¯¸é ¿Ö ÀÌ·¯ÇÑ °ÍÀÌ ÇÊ¿äÇÑ°¡? ±×°ÍÀº ¹Ù·Î ÀÌ°ÍÀÌ º¹ÀâÇÏ°í event-driven environment ¿¡¼ÀÇ ¹«°Å¿î ÁüÀ» µé¾îÁֱ⠶§¹®À̶ó°í³ª ÇÒ±î? Áï, XView ¿¡¼´Â ÀüÇüÀûÀ¸·Î ¸¹Àº objects µéÀ» °¡Áö°í Àֱ⶧¹®¿¡ centralized Notifier °¡ ¾ø´Ù¸é °¢ application µéÀº ±× ¼öÇà°úÁ¤¿¡¼ ¸ðµç objects ¿¡´ëÇÑ events ¸¦ Á¶»çÇÏ°í ÀûÀçÀû¼Ò¿¡ »Ñ·ÁÁÖ¾î¾ß¸¸ µÈ´Ù. centralized Notifier °¡ Á¸ÀçÇÔÀ¸·Î½á °¢ application ÀÇ component ´Â ´ÜÁö user °¡ Á¦½ÃÇÑ event ¸¸ ¹Þ¾ÆµéÀÌ¸é µÈ´Ù. 2.5.3 Relationship Among the Notifier, Objects and Application - user°¡ user ÀÇ application ¿¡¼ ¹Ýµå½Ã Notifier ¿Í Á÷Á¢ÀûÀ¸·Î interact ÇÒ ÇÊ¿ä´Â ¾ø´Ù. XView ´Â package ¾È ¿¡¼ panels, canvases,scrollbars ¿Í °°Àº ´Ù¾çÇÑ objects µéÀ» support ÇÏ´Â two-tiered scheme ¸¦ °¡Áö°í ÀÖ´Ù. Áï, ±× Notifier ¿Í Á÷Á¢ÀûÀ¸·Î interact Çϴ°Í.(±×µéÀÚ½ÅÀÇ callback procedure ¸¦ ±â·ÏÇϸé¼) ¶ÇÇÑ, ±³´ë·Î ±× application ÀÌ ±× object ¿Í °°ÀÌ ÀÚ½ÅÀÇ callback procedure ¸¦ ±â·ÏÇÑ´Ù. ÀϹÝÀûÀ¸·Î , XView application À» ¾µ¶§ user ´Â user ÀÇ interface ¸¦ ÇÏ°íÀÚÇÏ´Â ´Ù¸¥ object ¿Í ´Ù¾çÇÑ window ¸¦ ¸¸µé¾î¾ß ÇÏ°í ±× object ¿Í °ü·ÃµÈ callback procedure ¸¦ ±â·ÏÇÏ¿©¾ß ÇÑ´Ù. ±×¸®°í³ª¼ ´ç½ÅÀº ±× Notifier ¿¡°Ô control À» ³Ñ±ä´Ù. ¸¹Àº callback procedure ¾È¿¡¼ ÀÌ·¯ÇÑ ÀÏÀÌ ÀϾÙ. ±× Notifier ¿ÍÀÇ °ü°è¸¦ ¼³¸íÇغ¸¶ó. fig 2-15 ´Â ¾î¶»°Ô Notifier °¡ X server ·Î ºÎÅÍ X event ¸¦ ¹ÞÀ¸¸ç ¶ÇÇÑ file descriptor »ó¿¡¼ signals ¶Ç´Â input °°Àº OS event¸¦ receive ÇÏ´ÂÁö¸¦ ³ªÅ¸³½´Ù. user types, moves mouse, presses mouse buttons ... UNIX events; input on file descriptors NOTIFIER formats UNIX input into XView events, passes each event to the event procedure of the appropriate window XView events Control Drawing Paint Panel Canvas Canvas event procedures XView for subwindows Application notify notify event event proc proc proc proc for for for for application's item 1 item n Drawing Paint event Canvas Canvas procedures application's notify procedures for panel items fig2-15 Flow of input events in an XView application - ÇÑ°¡Áö ¾ð±ÞÇÒ °ÍÀº canvases ¿¡´ëÇÑ event procedure ¿Í panel items ¿¡ ´ëÇÑ notify procedures »çÀÌÀÇ Â÷ÀÌÁ¡ÀÌÀÖ´Ù. Áï, canvas's event procedure ´Â ¸¹Àº ÀÏÀ» ÇÏÁö¾Ê´Â´Ù. ±âº»¹÷À¸·Î ±×°ÍÀº ÇϳªÀÇ event °¡ receive µÉ¶§¸¶´Ù application ÀÇ event procedure ¿¡°Ô call out ÇÑ´Ù. ±× application Àº ¸ðµç event ¸¦ º¸¸ç ÀÚÀ¯·Ó°Ô interprete ÇÑ´Ù. panel ¿¡´ëÇÑ event procedure ´Â ÇÑÆíÀ¸·Î ²Ï ¸¹Àº ÀÏÀ» ÇÑ´Ù. Áï, ±×°ÍÀº item ÀÌ ±× event ¸¦ ¹Þ¾Æ¾ß¸¸ ÇÏ´ÂÁö¸¦ °áÁ¤ÇÏ°í event ¿¡ ÀÚ½ÅÀÌ Çص¶ÇÑ°ÍÀ» ´ëÄ¡ÇÑ´Ù. Áß°£ mouse button ÀÌ ¹«½ÃµÇ°í ÁÂÃø mouse button ÀÌ item À§¸¦ µû¶ó ³»·Á°¡´Â°ÍÀº ±× item ÀÇ ÀϽÃÀûÀÎ activation À¸·Î Çؼ®µÇ¾îÁø´Ù. ÁÂÃø mouse button ÀÌ ±× item À§¿¡ ¼±ÅõǾî Áú¶§±îÁö´Â ±× item ¿¡ ´ëÇÑ notify procedure °¡ callback µÇ¾îÁöÁö ¾Ê´Â´Ù. µû¶ó¼ panel item ÀÌ procedure ¸¦ ¾Ë¸®´Â°ÍÀº »õ·ÎÀº ¼±ÅÃÀ» ¸¸µå´Â button ÀÌ push µÇ¾úÀ» °æ¿ìÀÌ´Ù. 2.5.4 Calling the Notifier Directly - À§¿¡¼ ¾ð±ÞÇÏ¿´µíÀÌ ¸¹Àº application ¿¡´ëÇØ ´ç½Å Àº Notifier ¸¦ Á÷Á¢ È£ÃâÇÒ ÇÊ¿ä´Â ¾ø´Ù. ±×·¯³ª signal À» È£ÃâÇÒ ÇÊ¿ä°¡ Àִٰųª child process °¡ Á×¾ú´Ù´Â°ÍÀ» ¾Ë¾ÒÀ»¶§´Â ´ç½ÅÀº Á÷Á¢ Notifier ¸¦ È£ÃâÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. Notifier ´Â ¶ÇÇÑ interposition À̶ó°í ¾Ë·ÁÁø technique ¸¦ Á¦°øÇÑ´Ù. ÀÌ°ÍÀº window ÀÇ event stream ¿¡¼ user ÀÚ½ÅÀÇ routine À» »ðÀÔ ÇÒ¼öÀÖ°Ô ÇÏ´Â °ÍÀÌ´Ù. Notifier ¸¦ Á÷Á¢ call ÇÒ¼öÀÖ°Ô Çϴ°ÍÀº Chap 19, The Notifier ¸¦ ÂüÁ¶Ç϶ó. * Examples * 1.quit.c #include#include #include Frame frame; main(argc,argv) int argc; char *argv[]; { Panel panel; void lsh(); xv_init(XV_INIT_ARGS,argc ,argv,NULL); frame=(Frame)xv_create (NULL,FRAME,FRAME_LABEL,argv[0], XV_WIDTH,400, XV_HEIGHT,700,NULL); panel=(Panel)xv_create(frame,PANEL,NULL); (void) xv_create(panel,PANEL_BUTTON,PANEL_LABEL_STRING, "lee", PANEL_NOTIFY_PROC, lsh, NULL); xv_main_loop(frame); exit(0); } void lsh() { xv_destroy_safe(frame); } 2.btn_menu.c #include #include #include main(argc,argv) int argc; char *argv[]; { Frame frame; Panel panel; Menu menu; int selected(); void menu_proc(); xv_init(XV_INIT_ARGC_PTR_ARGV,&argc,argv,NULL); frame=(Frame)xv_create(NULL,FRAME,NULL); panel=(Panel)xv_create(frame,PANEL,NULL); menu=(Menu)xv_create(NULL,MENU, MENU_NOTIFY_PROC, menu_proc, MENU_STRINGS, "yes","no","Quit",NULL, NULL); (void) xv_create(panel,PANEL_BUTTON, PANEL_LABEL_STRING, "Y/N/Q", PANEL_NOTIFY_PROC, selected, PANEL_ITEM_MENU, menu, NULL); window_fit(panel); window_fit(frame); xv_main_loop(frame); } int selected(item,event) Panel_item item; Event *event; { printf("%s selected.. \n",xv_get(item,PANEL_LABEL_STRING)); return XV_OK; } void menu_proc(menu,menu_item) Menu menu; Menu_item menu_item; { printf("Menu Item: %s\n",xv_get(menu_item,MENU_STRING)); if(!strcmp((char *)xv_get(menu_item,MENU_STRING),"Quit")) exit(0); } 3.canvas_input.c include #include #include #include Canvas canvas; Frame frame; char msg[128]; void init_split(),my_event_proc(),my_repaint_proc(); main(argc,argv) int argc; char *argv[]; { xv_init(XV_INIT_ARGS,argc,argv,NULL); frame=(Frame)xv_create(NULL,FRAME, FRAME_LABEL, "Split View Windows.", FRAME_SHOW_FOOTER, TRUE, NULL); canvas=(Canvas)xv_create(frame,CANVAS, CANVAS_X_PAINT_WINDOW, TRUE, OPENWIN_SPLIT, OPENWIN_SPLIT_INIT_PROC, init_split, NULL, CANVAS_REPAINT_PROC, my_repaint_proc, NULL); (void) xv_create(canvas,SCROLLBAR, SCROLLBAR_SPLITTABLE, TRUE, SCROLLBAR_DIRECTION, SCROLLBAR_VERTICAL, NULL); (void) xv_create(canvas,SCROLLBAR, SCROLLBAR_SPLITTABLE, TRUE, SCROLLBAR_DIRECTION, SCROLLBAR_HORIZONTAL, NULL); xv_set(canvas_paint_window(canvas), WIN_CONSUME_EVENTS, WIN_NO_EVENTS, WIN_ASCII_EVENTS, KBD_USE,KBD_DONE, LOC_DRAG, LOC_WINENTER, LOC_WINEXIT, WIN_MOUSE_BUTTONS, NULL, WIN_EVENT_PROC, my_event_proc, NULL); xv_main_loop(frame); } void init_split(splitview,newview,pos) Xv_Window splitview,newview; int pos; { Xv_Window view; int i=0; OPENWIN_EACH_VIEW(canvas,view) if(view==splitview) { sprintf(msg,"Split view #%d",i+1); xv_set(frame,FRAME_LEFT_FOOTER,msg,NULL); } else if(view==newview) { xv_set(xv_get(canvas,OPENWIN_VERTICAL_SCROLLBAR,view), SCROLLBAR_VIEW_START,0, NULL); xv_set(xv_get(canvas,OPENWIN_HORIZONTAL_SCROLLBAR,view), SCROLLBAR_VIEW_START,0, NULL); } i++; OPENWIN_END_EACH sprintf(msg,"Total views: %d",i); xv_set(frame,FRAME_RIGHT_FOOTER,msg,NULL); } void my_event_proc(window,event,arg) Xv_Window window; Event *event; Notify_arg arg; { register char *p=msg; *p=0; if(event_is_key_left(event)) sprintf(p,"(L%D) ",event_id(event) - KEY_LEFTFIRST +1); else if(event_is_key_top(event)) sprintf(p,"(T%D) ",event_id(event) - KEY_LEFTFIRST +1); else if(event_is_key_right(event)) sprintf(p,"(R%D) ",event_id(event) - KEY_LEFTFIRST +1); else if(event_id(event)==KEY_BOTTOMLEFT) strcpy(p,"bottom left"); else if(event_id(event)==KEY_BOTTOMRIGHT) strcpy(p,"bottom right"); p+=strlen(p); if (event_is_ascii(event)) { sprintf(p,"Keyboard: key '%c' (%d) %s at %d,%d", event_action(event),event_action(event), event_is_down(event)? "pressed": "released", event_x(event),event_y(event)); } else switch (event_action(event)) { case ACTION_CLOSE: xv_set(frame,FRAME_CLOSED,TRUE,NULL); break; case ACTION_OPEN: strcpy(p,"frame opened up"); break; case ACTION_HELP: strcpy(p,"Help (action ignored)"); break; case ACTION_SELECT: sprintf(p,"Button: Select(Left) %s at %d,%d", event_is_down(event)? "pressed": "released", event_x(event),event_y(event)); break; case SHIFT_RIGHT: sprintf(p,"Keyboard: right shift %s", event_is_down(event)? "pressed": "released"); break; case SHIFT_LEFT: sprintf(p,"Keyboard: left shift %s", event_is_down(event)? "pressed": "released"); break; case ACTION_ADJUST: sprintf(p,"Button: Adjust(middle) %s at %d,%d", event_is_down(event)? "pressed": "released", event_x(event),event_y(event)); break; case ACTION_MENU: sprintf(p,"Button: Menu(right) %s at %d,%d", event_is_down(event)? "pressed": "released", event_x(event),event_y(event)); break; case SHIFT_LEFTCTRL: case SHIFT_RIGHTCTRL: sprintf(p,"Keyboard: control key %s", event_is_down(event)? "pressed": "released"); break; case SHIFT_META: sprintf(p,"Keyboard: meta key %s", event_is_down(event)? "pressed": "released"); break; case SHIFT_ALT: sprintf(p,"Keyboard: alt key %s", event_is_down(event)? "pressed": "released"); break; case KBD_USE: sprintf(p,"Keyboard: got keyboard focus %s", event_is_down(event)? "pressed": "released"); break; case KBD_DONE: sprintf(p,"Keyboard: lost keyboard focus %s", event_is_down(event)? "pressed": "released"); break; case LOC_MOVE: sprintf(p,"Pointer: moved to %d %d", event_x(event),event_y(event)); break; case LOC_DRAG: sprintf(p,"Pointer: dragged to %d %d", event_x(event),event_y(event)); break; case LOC_WINENTER: win_set_kbd_focus(window,xv_get(window,XV_XID)); sprintf(p,"Pointer: entered window at %d %d", event_x(event),event_y(event)); break; case LOC_WINEXIT: sprintf(p,"Pointer: exited window at %d %d", event_x(event),event_y(event)); break; case WIN_RESIZE: case WIN_REPAINT: return; default: return; } my_repaint_proc(canvas,window, xv_get(canvas,XV_DISPLAY), xv_get(window,XV_XID),NULL); } void my_repaint_proc(canvas,pw,dpy,xwin,xrects) Canvas canvas; Xv_Window pw; Display *dpy; Window xwin; Xv_xrectlist *xrects; { char win_num[16]; Xv_Window w; int i=0; GC gc=DefaultGC(dpy,DefaultScreen(dpy)); CANVAS_EACH_PAINT_WINDOW(canvas,w) if (w==pw) break; i++; CANVAS_END_EACH sprintf(win_num,"(Window #%d)",i+1); XClearWindow(dpy,xwin); XDrawString(dpy,xwin,gc,25,25,win_num,strlen(win_num)); } 4.sample_tty.c #include #include char *my_argv[]={"man","man",NULL}; main(argc,argv) char *argv[]; { Tty tty; Frame frame; xv_init(); frame=(Frame)xv_create(NULL,FRAME,NULL); tty=(Tty)xv_create(frame,TTY, WIN_ROWS, 24, WIN_COLUMNS, 80, TTY_ARGV, my_argv, NULL); window_fit(frame); xv_main_loop(frame); } ~ 5.subframe.c #include main(argc,argv) int argc; char *argv[]; { Frame frame, subframe; xv_init(XV_INIT_ARGC_PTR_ARGV,&argc,argv,NULL); frame=(Frame)xv_create(NULL,FRAME,XV_WIDTH,100,XV_HEIGHT,100,FRAME_LABEL, "Base Frame",NULL); subframe=(Frame)xv_create(frame,FRAME_CMD,XV_WIDTH,100,XV_HEIGHT,100,FRAME_LABEL,"PoPup",NULL); xv_set(subframe,XV_SHOW,TRUE,NULL); xv_main_loop(frame); } 6.textsw_to_textsw.c #include #include #include #include #include Textsw textsw; Tty ttysw; main(argc,argv) int argc; char *argv[]; { Frame frame; Panel panel; void text_to_tty(),exit(); xv_init(XV_INIT_ARGC_PTR_ARGV,&argc,argv,NULL); frame=(Frame)xv_create(XV_NULL,FRAME, FRAME_LABEL,argv[0], NULL); panel=(Panel)xv_create(frame,PANEL, PANEL_LAYOUT,PANEL_VERTICAL, NULL); (void) xv_create(panel,PANEL_BUTTON, PANEL_LABEL_STRING, "Quit", PANEL_NOTIFY_PROC, exit, NULL); (void) xv_create(panel,PANEL_BUTTON, PANEL_LABEL_STRING, "Text To Tty", PANEL_NOTIFY_PROC, text_to_tty, NULL); window_fit(panel); textsw=(Textsw)xv_create(frame,TEXTSW, WIN_ROWS, 10, WIN_COLUMNS, 80, NULL); textsw=(Textsw)xv_create(frame,TTY, WIN_BELOW, textsw, WIN_X, 0, TTY_ARGV, TTY_ARGV_DO_NOT_FORK, NULL); window_fit(frame); xv_main_loop(frame); } void text_to_tty(item,event) Panel_item item; Event *event; { char buf[BUFSIZ]; (void) xv_get(textsw, TEXTSW_CONTENTS,0,buf,sizeof buf); ttysw_output(ttysw,buf,strlen(buf)); } 7.stop_frame.c #include #include #include static short stop_bits[]={ 0x3E00,0x7f00,0xFF80,0xFF80,0xFF80,0xFF80,0xFF80,0x7F00, 0x3E00,0x0800,0x0800,0x0800,0x0800,0x0800,0x7F00,0x0000 }; main(argc,argv) char *argv[]; { Frame frame; Panel panel; Server_image stopsign; xv_init(); frame=(Frame)xv_create(NULL,FRAME, FRAME_SHOW_HEADER, FALSE, NULL); panel=(Panel)xv_create(frame,PANEL,NULL); stopsign=(Server_image)xv_create(NULL,SERVER_IMAGE, XV_WIDTH, 16, XV_HEIGHT, 16, SERVER_IMAGE_DEPTH, 1, SERVER_IMAGE_BITS, stop_bits, NULL); (void) xv_create(panel,PANEL_MESSAGE, PANEL_LABEL_IMAGE,stopsign, NULL); (void) xv_create(panel,PANEL_MESSAGE, PANEL_LABEL_STRING, "This action will cause unsaved edits to be lost.", NULL); (void) xv_create(panel,PANEL_BUTTON, PANEL_NEXT_ROW, -1, XV_X, 110, PANEL_LABEL_STRING, "OK", NULL); (void) xv_create(panel,PANEL_BUTTON, PANEL_LABEL_STRING, "Cancel", NULL); window_fit(panel); window_fit(frame); xv_main_loop(frame); } 8.line.c #include #include #include #include main(argc,argv) int argc; char *argv[]; { Frame frame; void canvas_repaint_proc(); xv_init(XV_INIT_ARGC_PTR_ARGV,&argc,argv,NULL); frame=(Frame)xv_create(NULL,FRAME,NULL); (void) xv_create(frame,CANVAS, CANVAS_REPAINT_PROC, canvas_repaint_proc, CANVAS_X_PAINT_WINDOW, TRUE, NULL); xv_main_loop(frame); } void canvas_repaint_proc(canvas,paint_window,dpy,xwin,xrects) Canvas canvas; Xv_Window paint_window; Display *dpy; Window xwin; Xv_xrectlist *xrects; { GC gc; int width,height; gc=DefaultGC(dpy,DefaultScreen(dpy)); width=(int)xv_get(paint_window,XV_WIDTH); height=(int)xv_get(paint_window,XV_HEIGHT); XDrawLine(dpy,xwin,gc,100,10,width,height); } 9.color.c #include #include #include main() { Frame frame; Panel panel; Xv_singlecolor fg,bg; fg.red=250, fg.green=230, fg.blue=20; bg.red=180, bg.green=100, bg.blue=20; frame=(Frame)xv_create(NULL,FRAME, FRAME_BACKGROUND_COLOR,&bg, FRAME_FOREGROUND_COLOR,&fg, FRAME_INHERIT_COLORS, TRUE,NULL); panel=(Panel)xv_create(frame,PANEL,NULL); (void) xv_create(panel,PANEL_BUTTON, PANEL_LABEL_STRING, "Push Me",NULL); xv_main_loop(frame); } 10.popup.c #include #include main(argc,argv) int argc; char *argv[]; { Frame frame, subframe; int done_proc(); xv_init(XV_INIT_ARGC_PTR_ARGV,&argc,argv,NULL); frame=(Frame)xv_create(NULL,FRAME,NULL); subframe=(Frame)xv_create(frame,FRAME_CMD, FRAME_DONE_PROC,done_proc, XV_SHOW, TRUE, NULL); xv_main_loop(frame); } done_proc(subframe) Frame subframe; { xv_set(subframe,XV_SHOW,FALSE,NULL); } ~ * COMPILE METHOD * hyundai# ccxv popup vi ccxv if [ -n "$3" ] then cc -g -sb -DOW_I18N $2.c -o $3 -I$OPENWINHOME/include \ -L$OPENWINHOME/lib -lxview -lolgx -lX11 -lmle else cc -g -sb -DOW_I18N $1.c -o $1 -I$OPENWINHOME/include \ -L$OPENWINHOME/lib -lxview -lolgx -lX11 -lmle fi ~ Revision History Created on Dec 12 ,1992 ~