由 aprotoss » 週五 1月 04, 2008 12:31 am
- 代碼: 選擇全部
1 #include <gtk/gtk.h>
2
3 gboolean redraw(GtkWidget *widget, GdkEvent *event, gpointer data)
4 {
5 gdk_draw_line (widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
6 0, 0, 120, 120);
7
8 return TRUE;
9 }
10
11 int main(int argc, char *argv[])
12 {
13 GtkWidget *window;
14 GtkWidget *drawing_area;
15
16 gtk_init( &argc, &argv);
17
18 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
19
20 g_signal_connect(GTK_OBJECT(window), "destroy",
21 G_CALLBACK(gtk_main_quit), NULL);
22
23 drawing_area = gtk_drawing_area_new ();
24 gtk_drawing_area_size ( GTK_DRAWING_AREA(drawing_area) , 100, 100);
25 g_signal_connect (G_OBJECT (drawing_area), "expose-event",
26 G_CALLBACK (redraw), NULL);
27
28 gtk_container_add (GTK_CONTAINER (window), drawing_area);
29
30 gtk_widget_show_all(window);
31
32 gtk_main();
33
34 return 0;
35 }
請參考:
http://library.gnome.org/devel/gtk/unst ... gArea.html
外面的世界很精彩,我出去一定會失敗!
Orz....
-jac