¸®´ª½º ±âŸ ÀÚ·á |
---|
Á¦¸ñ | gtk °Á #13 1998/07/10 (17:35) |
À̸§ | ±èÈ¿¿ø |
¹øÈ£ | 97 |
Á¶È¸ | 345 |
º»¹® |
¡º¸®´ª½º Çдç-¹ø¿ª¹° (go LINUX)¡» 206¹ø Á¦ ¸ñ:[¹ø¿ª] gtk Tutorial, Chap21~24ÀÔ´Ï´Ù. ¿Ã¸°ÀÌ:Áß¾ÓÀÚ´ë(ÀÌÈÆ ) 98/03/11 16:30 ÀÐÀ½:171 °ü·ÃÀÚ·á ¾øÀ½ ----------------------------------------------------------------------------- ****************************** *** 21. GTK ¾îÇÃÀ» °³¹ßÇÏ´Â ÆÁ ****************************** ÀÌ ºÎºÐÀº ´ÜÁö ÁÁÀº GTK ¾îÇÃÀ» °³¹ßÇÒ ¼ö ÀÖµµ·Ï ÀϹÝÀûÀÎ ½ºÅ¸ÀÏÀÇ Á¶¾ð°ú ÈùÆ® µîÀ» ´Ù·ç°í ÀÖ´Ù. ÀÌ°ÍÀº Áö±ÝÀ¸·Î¼± Á¦¸ñ¸¸ ±×·¸´Ù´Â °ÍÀÌ°í, µû¶ó¼ ÀüÇô ÇÊ¿ä¾øÀ» °ÍÀÌ´Ù. :) GNU autoconf¿Í automake¸¦ ÀÌ¿ëÇ϶ó! ±×µéÀº ¿ì¸® Ä£±¸´Ù. :) ³ª´Â À̵鿡 ´ëÇÑ °£´ÜÇÑ ¼Ò°³¸¦ ÇØÁÙ °èȹÀÌ ÀÖ´Ù. ******************** *** 22. Contributing ******************** ÀÌ ¹®¼´Â, ´Ù¸¥ ¼ö¸¹Àº ¼ÒÇÁÆ®¿þ¾îµé°ú ¸¶Âù°¡Áö·Î, ÀÚÀ¯·Î¿î ÀÌ¿ëÀ» À§Çؼ ÀÚ¹ßÀûÀ¸·Î ¸¸µé¾îÁø °ÍÀÌ´Ù. ¸¸¾à ¿©·¯ºÐÀÌ ¾ÆÁ÷ ¹®¼ÈµÇÁö ¾ÊÀº GTKÀÇ ¾î¶² ±â´É¿¡ ´ëÇØ È®½ÇÈ÷ Áö½ÄÀ» °¡Áö°Ô µÈ´Ù¸é, ¿©·¯ºÐ Àڽŵµ ÀÌ ¹®¼¿¡ ±â¿©ÇØ º¼ °ÍÀ» °í·ÁÇØ º¸ÀÚ. ¸¸¾à ±â¿©ÇÏ°Ú´Ù°í ¸¶À½¸Ô¾ú´Ù¸é, ¿©·¯ºÐÀÇ ±ÛÀ» slow@intergate.bc.ca, Áï ³ª Ian Main¿¡°Ô º¸³»Áֱ⠹ٶõ´Ù. ¶ÇÇÑ, ÀÌ ¹®¼´Â ¿ÏÀüÈ÷ ÀÚÀ¯·Î¿î °ÍÀÌ¸ç ¿©·¯ºÐ¿¡ ÀÇÇÑ ¾î¶² Ãß°¡»çÇ× ¿ª½Ã ÀÚÀ¯´Ù. Áï »ç¶÷µéÀº ±×µéÀÇ ÇÁ·Î±×·¥À» À§ÇØ ¿©·¯ºÐÀÇ ±ÛÀÇ ¾î¶² ºÎºÐÀÌ¶óµµ ÀÌ¿ëÇÒ °ÍÀÌ°í, ¶Ç ¹®¼ÀÇ º¹Á¦Ç°Àº ¿øÇÏ´Â ´ë·Î ¹èÆ÷µÉ °ÍÀÌ´Ù. THANK YOU *************** *** 23. Credits *************** ÀÌ ¹®¼¿¡ °øÇåÇÑ ´ÙÀ½ »ç¶÷µé¿¡°Ô °¨»çÇÑ´Ù. *** Bawer Dagdeviren, chamele0n@geocities.com FOR the menus tutorial. *** Raph Levien, raph@acm.org FOR hello world ala GTK, widget packing, and general all around wisdom. He's also generously donated a home for this tutorial. *** Peter Mattis, petm@xcf.berkeley.edu FOR the simplest GTK program.. and the ability to make it :) *** Werner Koch werner.koch@guug.de FOR converting the original plain text to SGML, and the widget class hierarchy. *** Mark Crichton crichton@expert.cc.purdue.edu FOR the menu factory code, and the table packing tutorial. *** Owen Taylor owt1@cornell.edu FOR the EventBox widget section (and the patch to the distro). He's also responsible for the selections code and tutorial, as well as the sections on writing your own GTK widgets, and the example application. Thanks a lot Owen for all you help! *** Mark VanderBoom mvboom42@calvin.edu FOR his wonderful work on the Notebook, Progress Bar, Dialogs, and File selection widgets. Thanks a lot Mark! You've been a great help. *** Tim Janik timj@psynet.net FOR his great job on the Lists Widget. Thanks Tim :) *** Rajat Datta rajat@ix.netcom.com FOR the excellent job on the Pixmap tutorial. *** Michael K. Johnson johnsonm@redhat.com FOR info and code for popup menus. ±×¸®°í µµ¿òÀ» ÁÖ°í ´õ ¼¼·ÃµÈ ¹®¼°¡ µÇµµ·Ï ÇØÁØ ¸ðµç À̵鿡°Ôµµ °¨»çÇÑ´Ù. Thanks. *************** *** 24. Copying *************** This tutorial is Copyright (C) 1997 Ian Main This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Ê°í ±×µéÀÇ parent À©µµ ¾È¿¡ ±×·Á³Ö´Â´Ù. ÀÌ·± widgetÀº ´ÙÀ½°ú °°Àº °ÍµéÀÌ´Ù. GtkAlignment GtkArrow GtkBin GtkBox GtkImage GtkItem GtkLabel GtkPaned GtkPixmap GtkScrolledWindow GtkSeparator GtkTable GtkViewport GtkAspectFrame GtkFrame GtkVPaned GtkHPaned GtkVBox GtkHBox GtkVSeparator GtkHSeparator ÀÌ·± À̺¥Æ®µéÀ» ŽÁöÇϱâ À§ÇØ ¿ì¸®´Â EventBox widgetÀ» ÇÊ¿ä·Î ÇÑ´Ù. ÀÚ¼¼ ÇÑ °ÍÀº EventBox widget¿¡ ´ëÇÑ ºÎºÐÀ» ÂüÁ¶Ç϶ó. ¿ì¸®ÀÇ ±×¸®±â ÇÁ·Î±×·¥¿¡¼ ´Â ¸¶¿ì½º ¹öÆ°ÀÌ ´·¯Áö´Â °Í°ú ¿òÁ÷ÀÌ´Â °ÍÀ» ŽÁöÇÏ°í ½Í¾îÇϹǷÎ, GDK_ POINTER_MOTION_MASK¿Í GDK_BUTTON_PRESS_MASK¸¦ ¼³Á¤ÇÑ´Ù. ¿ì¸®´Â ¶ÇÇÑ À©µµ°¡ ´Ù½Ã ±×·ÁÁ®¾ß ÇÒ ¶§¸¦ ¾Ë¾Æ¾ß ÇϹǷΠGDK_EXPOSURE_MASKµµ ¼³Á¤ÇÑ´Ù. ºñ·Ï ¿ì¸®´Â À©µµÀÇ Å©±â°¡ º¯ÇßÀ» ¶§¸¦ Configure event·Î½á ŽÁöÇØ¾ß ÇÏÁö¸¸, ¿ì¸®´Â À̸¦ À§ÇØ GDK_STRUCTURE_MASK flag¸¦ ¼³Á¤ÇÒ ÇÊ¿ä°¡ ¾ø´Ù. ÀÌ°ÍÀº ¸ðµç À©µµ¿¡ ´ëÇØ ÀÚµ¿ÀûÀ¸·Î ¼³Á¤µÇ±â ¶§¹®ÀÌ´Ù. ±×·±µ¥ GDK_POINTER_MOTION_MASK¸¦ ¼³Á¤ ÇÏ´Â µ¥ ÀÖ¾î ¹®Á¦Á¡ÀÌ ÀÖ´Ù´Â °ÍÀÌ ¹àÇôÁú °ÍÀÌ´Ù. ÀÌ°ÍÀº »ç¿ëÀÚ°¡ ¸¶¿ì½º¸¦ ¿òÁ÷ÀÏ ¶§¸¶´Ù ¼¹ö°¡ event queue¿¡ motion event¸¦ °è¼Ó ´õÇÒ °ÍÀÌ´Ù. ¾î¶² motion event¸¦ ´Ù·ç±â À§ÇØ 0.1ÃÊ°¡ °É¸°´Ù°í »ý°¢ÇØ º¸ÀÚ. ±×·¯³ª X ¼¹ö´Â ¸Å 0.05Ãʸ¶´Ù »õ·Î¿î motionÀ» queue¿¡ ÀúÀåÇÑ´Ù. ¿ì¸®´Â °ð »ç¿ëÀÚ°¡ ±×¸®´Â µ¥ ´ëÇÑ ¹æ¹ýÀ» °¡Áö°Ô µÉ °ÍÀÌ´Ù. ¸¸¾à »ç¿ëÀÚ°¡ 5Ãʵ¿¾È ±×¸²À» ±×¸®¸é, ±×µéÀÌ ¸¶¿ì½º ¹öÆ°À» ³õ°í ³ ÈÄ ¶Ç´Ù¸¥ 5ÃÊ°¡, ±×°ÍÀ» Àâ¾Æ³»±â À§ÇØ ÇÊ¿äÇÏ°Ô µÉ °ÍÀÌ´Ù. ¿ì¸®°¡ ¿øÇÏ´Â °ÍÀº ÁøÇàµÇ´Â °¢°¢ÀÇ À̺¥Æ®¿¡ ´ëÇØ ´Ü ÇϳªÀÇ motion event¸¦ ŽÁöÇÏ´Â °ÍÀÌ´Ù. ÀÌ·¸°Ô Çϱâ À§Çؼ ¿ì¸®´Â GDK_POINTER_MOTION_HINT_ MASK¸¦ ¼³Á¤ÇÑ´Ù. ¿ì¸®°¡ GDK_POINTER_MOTION_HINT_MASK¸¦ ¼³Á¤Çϸé, ¼¹ö´Â ¸¶¿ì½º Æ÷ÀÎÅÍ°¡ ¿ì¸®ÀÇ À©µµ¿¡ µé¾î¿À°í ³ª¼ ¶Ç´Â ¹öÆ°ÀÇ press³ª release À̺¥Æ®°¡ ¹ß»ýÇÏ°í ³ª¼ óÀ½À¸·Î ¿òÁ÷ÀÏ ¶§ motion event¸¦ º¸³»ÁØ´Ù. µÚµû¸£´Â motion event´Â ¿ì¸®°¡ ¾Æ·¡ÀÇ ÇÔ¼ö·Î½á ºÐ¸íÇÏ°Ô ¸¶¿ì½º Æ÷ÀÎÅÍÀÇ À§Ä¡¸¦ ¹°¾îº¼ ¶§±îÁö ¾ïÁ¦µÉ °ÍÀÌ´Ù. GdkWindow* gdk_window_get_pointer (GdkWindow *window, gint *x, gint *y, GdkModifierType *mask); (´õ °£´ÜÇÑ ¾²ÀÓ»õ¸¦ °¡Áø gtk_widget_get_pointer()¶ó´Â ÇÔ¼öµµ ÀÖÁö¸¸, ±×´ÙÁö À¯¿ëÇÏÁö´Â ¾ÊÀ½ÀÌ µå·¯³¯ °ÍÀÌ´Ù. ¿Ö³ÄÇÏ¸é ±×°ÍÀº ¸¶¿ì½º ¹öÆ°ÀÇ »óÅ¿¡ °ü°è ¾øÀÌ Æ÷ÀÎÅÍÀÇ À§Ä¡¸¸À» ¸»ÇØÁֱ⠶§¹®ÀÌ´Ù.) ¿ì¸®ÀÇ À©µµ¿¡ À̺¥Æ®¸¦ ¼¼ÆÃÇÏ´Â ÄÚµå´Â ±×·¯¹Ç·Î ÀÌ·± ½ÄÀ¸·Î µÉ °ÍÀÌ´Ù. gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", (GtkSignalFunc) expose_event, NULL); gtk_signal_connect (GTK_OBJECT(drawing_area),"configure_event", (GtkSignalFunc) configure_event, NULL); gtk_signal_connect (GTK_OBJECT (drawing_area), "motion_notify_event", (GtkSignalFunc) motion_notify_event, NULL); gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", (GtkSignalFunc) button_press_event, NULL); gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); "expose_event"¿Í "configure_event"´Â ´ÙÀ½À» À§Çؼ ³²°ÜµÐ´Ù. "motion_ notify_event"¿Í "button_press_event"ÀÇ Çڵ鷯´Â ²Ï °£´ÜÇÏ´Ù. static gint button_press_event (GtkWidget *widget, GdkEventButton *event) { if (event->button == 1 && pixmap != NULL) draw_brush (widget, event->x, event->y); return TRUE; } static gint motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { int x, y; GdkModifierType state; if (event->is_hint) gdk_window_get_pointer (event->window, &x, &y, &state); else { x = event->x; y = event->y; state = event->state; } if (state & GDK_BUTTON1_MASK && pixmap != NULL) draw_brush (widget, x, y); return TRUE; } *** *** 20-3. DrawingArea widget, ±×¸®°í ±×¸®±â *** ÀÌÁ¦ ½ºÅ©¸°¿¡ ±×¸²À» ±×¸®´Â °úÁ¤¿¡ ´ëÇØ ¾Ë¾Æº¸ÀÚ. À̶§ ÇÊ¿äÇÑ °ÍÀº DrawingArea widgetÀÌ´Ù. ±×¸²À» ±×¸®´Â ¿µ¿ªÀÇ widgetÀ̶õ º»ÁúÀûÀ¸·Î ´Ù¸§ ¾Æ´Ñ XÀ©µµ´Ù. ÀÌ°ÍÀº ¿ì¸®°¡ ¿øÇÏ´Â °ÍÀ» ¹«¾ùÀÌµç ±×·Á³ÖÀ» ¼ö ÀÖ´Â ºó ĵ¹ö½º´Ù. Drawing area´Â ÀÌ ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ ¸¸µé¾îÁø´Ù. GtkWidget* gtk_drawing_area_new (void); ÀÌ widgetÀÇ µðÆúÆ® Å©±â´Â ÀÌ ÇÔ¼ö·Î½á ¼³Á¤ÇÑ´Ù. void gtk_drawing_area_size (GtkDrawingArea *darea, gint width, gint height); ¸ðµç widget¿¡ ´ëÇØ ¿øÇÑ´Ù¸é ÀÌ µðÆúÆ® Å©±â´Â gtk_widget_set_usize()·Î½á ¿À¹ö·ÎµåµÉ ¼ö ÀÖ´Ù. ±×¸®°í »ç¿ëÀÚ°¡ Á÷Á¢ ±× drawing area¸¦ Æ÷ÇÔÇÑ À©µµÀÇ Å©±â¸¦ º¯°æÇÏ¸é ¿ª½Ã ¿À¹ö·ÎµåµÈ´Ù. ¿ì¸®°¡ DrawingArea widgetÀ» ¸¸µé ¶§, ±×¸± ´ë»óÀÌ ¹«¾ùÀΰ¡¿¡ ÀüÀûÀ¸·Î ÁÖÀǸ¦ ±â¿ï¿©¾ß ÇÑ´Ù. ¸¸¾à ¿ì¸®ÀÇ À©µµ°¡ °¨Ãß¾îÁ³´Ù°¡ ´Ù½Ã µå·¯³µ´Ù¸é, ¿ì¸®´Â exposure ¸¶½ºÅ©¸¦ ¼³Á¤ÇÏ°í ±×¸®°í ¿ø·¡ °¨Ãß¾îÁ³¾ú´ø ³»¿ëÀÌ ¹«¾ùÀ̾ú´ÂÁö ²À ´Ù½Ã ±×·ÁÁà¾ß ÇÑ´Ù. µ¡ºÙ¿©¼, À©µµÀÇ ÀϺκÐÀÌ Áö¿öÁ³´Ù°¡ ´Ü°èÀûÀ¸·Î ´Ù½Ã ±×·ÁÁö´Â °ÍÀº ½Ã°¢ÀûÀ¸·Î »ê¸¸ÇØÁú ¼ö ÀÖ´Ù. ÀÌ·± ¹®Á¦¿¡ ´ëÇÑ ÇعýÀº offscreen backing pixmapÀ» ÀÌ¿ëÇÏ´Â °ÍÀÌ´Ù. ½ºÅ©¸° À§·Î ¹Ù·Î ±×¸®´Â ´ë½Å, º¸ÀÌÁö ¾Ê´Â ¼¹ö ¸Þ¸ð¸®¿¡ ÀúÀåµÈ ¾î¶² À̹ÌÁö À§¿¡ ±×·Á³õ°í, À̹ÌÁö°¡ º¯Ç߰ųª ¶Ç´Â À̹ÌÁöÀÇ »õ·Î¿î ¿µ¿ªÀÌ º¸¿©Áö°Ô µÇ¸é ÇØ´çÇÏ´Â ¿µ¿ªÀ» ½ºÅ©¸°¿¡ º¹»çÇØ ÁÖ´Â °ÍÀÌ´Ù. ¾î¶² offscreen pixmapÀ» ¸¸µé±â À§ÇØ, ¿ì¸®´Â ÀÌ ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù. GdkPixmap* gdk_pixmap_new (GdkWindow *window, gint width, gint height, gint depth); ÀÎÀÚ window´Â ÀÌ ÇȽº¸ÊÀÌ Æ¯¼ºÀ» À̾î¹ÞÀ» GDK À©µµ¸¦ ¼³Á¤ÇÑ´Ù. width¿Í height´Â ÇȽº¸ÊÀÇ Å©±â¸¦ Á¤ÇÑ´Ù. depth´Â color depth·Î¼, ÀÌ »õ·Î¿î À©µµ ¿¡¼ÀÇ ÇÑ Çȼ¿´ç ºñÆ®ÀÇ ¼ö´Ù. ¸¸¾à depth°¡ -1·Î ¼³Á¤µÇ¸é, ±×°ÍÀº À©µµÀÇ depth¿Í ¶È°°¾ÆÁø´Ù. ¿ì¸®´Â ÇȽº¸ÊÀ» "configure_event" handler ¾È¿¡ ¸¸µç´Ù. ÀÌ À̺¥Æ®´Â À©µµ°¡ óÀ½ »ý¼ºµÉ ¶§¸¦ Æ÷ÇÔÇؼ, À©µµÀÇ Å©±â°¡ º¯ÇÒ ¶§¸¶´Ù ¹ß»ýÇÑ´Ù. /* ±×¸± ¿µ¿ª¿¡ ´ëÇÑ backing pixmap */ static GdkPixmap *pixmap = NULL; /* Àû´çÇÑ Å©±âÀÇ backing pixmapÀ» Çϳª ¸¸µç´Ù. */ static gint configure_event (GtkWidget *widget, GdkEventConfigure *event) { if (pixmap) { gdk_pixmap_destroy(pixmap); } pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1); gdk_draw_rectangle (pixmap, widget->style->white_gc, TRUE, 0, 0, widget->allocation.width, widget->allocation.height); return TRUE; } gdk_draw_rectangle()À» ºÎ¸£¸ç ÇȽº¸ÊÀ» white·Î ÃʱâÈÇÑ´Ù. ¿©±â¿¡ ´ëÇØ Àá±ñ ´õ ¾ê±âÇÒ °ÍÀÌ´Ù. ±×·¯¸é ¿ì¸®ÀÇ exposure event handler´Â ´Ü¼øÈ÷ ±× ÇȽº¸ÊÀÇ °ü°èµÈ portionÀ» ½ºÅ©¸° À§·Î º¹»çÇÑ´Ù(¿ì¸®´Â exposure eventÀÇ event->area Çʵå·Î½á redrawÇÒ ¿µ¿ªÀ» °áÁ¤ÇÑ´Ù). /* Backing pixmapÀ¸·ÎºÎÅÍ ½ºÅ©¸°À» º¹±¸ÇÑ´Ù. */ static gint expose_event (GtkWidget *widget, GdkEventExpose *event) { gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pixmap, event->area.x, event->area.y, event->area.x, event->area.y, event->area.width, event->area.height); return FALSE; } ¿ì¸®´Â ÀÌÁ¦ ÇȽº¸Ê¿¡ ´ëÇØ ¾î¶»°Ô ½ºÅ©¸°À» º¸Á¸ÇÏ´ÂÁö º¸¾Ò´Ù. ±×·±µ¥ ¿ì¸®ÀÇ ÇȽº¸Ê¿¡ ½ÇÁ¦·Î Àç¹ÌÀÖ´Â °ÍµéÀ» ¾î¶»°Ô ±×·Á³ÖÀ»±î? GTKÀÇ GDK ¶óÀ̺귯¸®¿¡´Â drawablesµéÀ» ±×¸®´Â µ¥ ÇÊ¿äÇÑ ¸¹Àº ¼öÀÇ ÇÔ¼öµéÀÌ ÀÖ´Ù. DrawableÀ̶õ °£´ÜÈ÷ ¾îµò°¡¿¡ ±×·ÁÁú ¼ö ÀÖ´Â ±× ¹«¾ùÀÌ´Ù. ¿©±â¼ ¾îµð¶õ ÇϳªÀÇ window, pixmap, ¶Ç´Â bitmap(Èæ¹éÀÇ À̹ÌÁö)ÀÌ µÉ ¼ö ÀÖ´Ù. ¿ì¸®´Â ÀÌ¹Ì ÀÌ·± ÇÔ¼ö µÎ°¡Áö¸¦ º¸¾Ò´Ù. gdk_draw_rectangle()°ú gdk_draw_pixmap() ÀÌ ±×°ÍÀÌ´Ù. ÀÌ ÇÔ¼öµéÀÇ ¿ÏÀüÇÑ ¸®½ºÆ®´Â ÀÌ·¸´Ù. gdk_draw_line () gdk_draw_rectangle () gdk_draw_arc () gdk_draw_polygon () gdk_draw_string () gdk_draw_text () gdk_draw_pixmap () gdk_draw_bitmap () gdk_draw_image () gdk_draw_points () gdk_draw_segments () ÀÌ ÇÔ¼öµé¿¡ ´ëÇØ ´õ ÀÚ¼¼È÷ ¾Ë·Á¸é Âü°í ¹®¼¸¦ º¸°Å³ª <gdk/gdk.h> ÆÄÀÏÀ» º¸¶ó. ÀÌ ÇÔ¼öµéÀº óÀ½ µÎ °³ÀÇ ÀÎÀÚ¸¦ °øÅëÀûÀ¸·Î °¡Áø´Ù. ù ¹ø°´Â ±×·Á ³ÖÀ» drawable, ±×¸®°í µÎ¹ø°´Â graphics context(GC)ÀÌ´Ù. GC´Â foreground/ background color³ª line width°°Àº, ±×·ÁÁú °Í¿¡ ´ëÇÑ Á¤º¸µéÀ» ĸ½¶ÈÇÑ °ÍÀÌ´Ù. GDK´Â GC¸¦ »õ·Î ¸¸µé°í º¯ÇüÇϴµ¥ ÇÊ¿äÇÑ ¸ðµç ÇÔ¼öµéÀ» °¡Áö°í ÀÖÁö¸¸, ¹¹µçÁö °£´ÜÈ÷ À¯ÁöÇϱâ À§Çؼ(Keep things simple) ¿ì¸®´Â ÀÌ¹Ì Á¤ÀǵǾî ÀÖ´Â GC¸¸À» ¾µ °ÍÀÌ´Ù. °¢ widgetÀº ¿¬°üµÈ ½ºÅ¸ÀÏÀÌ ÀÖ´Ù(À̵éÀº rc ÆÄÀÏÀ» ÆíÁýÇÔÀ¸·Î½á º¯Çü°¡´ÉÇÏ´Ù. GTKÀÇ rc ÆÄÀÏ¿¡ ´ëÇÑ ºÎºÐÀ» ÂüÁ¶). ÀÌ°ÍÀº ´Ù¸¥ °Íµé »çÀÌ¿¡¼ GCÀÇ °³¼ö¸¦ ÀúÀåÇÑ´Ù. ÀÌ·± GC¿¡ Á¢±ÙÇÏ´Â ¸î°¡Áö ¿¹¸¦ º¸ÀÌ°Ú´Ù. widget->style->white_gc widget->style->black_gc widget->style->fg_gc[GTK_STATE_NORMAL] widget->style->bg_gc[GTK_WIDGET_STATE(widget)] Çʵå fg_gc, bg_gc, dark_gc, light_gc µîÀº ¾Æ·¡ °ªµéÀ» °¡Áú ¼ö ÀÖ´Â Gtk StateTypeÀ̶ó´Â ÀÎÀÚ·Î ³ªÅ¸³»¾îÁø´Ù. GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE ¿¹¸¦µé¾î, GTK_STATE_SELECTED¿¡ ´ëÇØ µðÆúÆ® foreground »ö±òÀº whiteÀÌ°í background »ö±òÀº dark blueÀÌ´Ù. ½ÇÁ¦·Î ½ºÅ©¸° À§·Î ±×¸®´Â ÇÔ¼öÀÎ draw_ brush()´Â ±×·¯¹Ç·Î ÀÌ·¸°Ô µÈ´Ù. /* ½ºÅ©¸°¿¡ »ç°¢ÇüÀ» Çϳª ±×¸°´Ù. */ static void draw_brush (GtkWidget *widget, gdouble x, gdouble y) { GdkRectangle update_rect; update_rect.x = x - 5; update_rect.y = y - 5; update_rect.width = 10; update_rect.height = 10; gdk_draw_rectangle (pixmap, widget->style->black_gc, TRUE, update_rect.x, update_rect.y, update_rect.width, update_rect.height); gtk_widget_draw (widget, &update_rect); } ¿ì¸®°¡ ÇȽº¸Ê À§·Î ºê·¯½¬¸¦ Ç¥½ÃÇÏ´Â »ç°¢ÇüÀ» ±×¸®°í ³ª¼, ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù. void gtk_widget_draw (GtkWidget *widget, GdkRectangle *area); ÀÌ°ÍÀº area¶ó´Â ÀÎÀÚ·Î ÁÖ¾îÁø ¿µ¿ªÀÌ ¾÷µ¥ÀÌÆ®µÇ¾î¾ß ÇÔÀ» X¿¡°Ô ¾Ë·ÁÁØ´Ù. °á±¹ X´Â expose À̺¥Æ®¸¦ ¹ß»ýÇÏ°í, ÀÌ°ÍÀº ¿ì¸®ÀÇ expose À̺¥Æ® Çڵ鷯°¡ °ü°èµÈ ¿µ¿ªÀ» ½ºÅ©¸° À§·Î º¹»çÇÏ°Ô²û ÇÒ °ÍÀÌ´Ù. ÀÌÁ¦ ¿ì¸®´Â main À©µµ¸¦ ¸¸µå´Â °Í °°ÀÌ ÀϺΠÈçÇÑ Ç׸ñµéÀ» Á¦¿ÜÇÏ°í ÀÌ ±×¸®±â ÇÁ·Î±×·¥À» ¸ðµÎ »ìÆ캸¾Ò´Ù. |