#include
static gboolean my_expose(GtkWidget *da,GdkEventExpose *event,gpointer data)
{
GdkGC *gc1, *gc2, *gc;
GdkColor color;
gc1 = gdk_gc_new(da->window);
color.red = 30000;
color.green = 0;
color.blue = 30000;
gdk_gc_set_rgb_fg_color(gc1, &color );
gc2 = gdk_gc_new( da->window );
color.red = 65535;
color.green = 0;
color.blue = 65535;
gdk_gc_set_rgb_fg_color( gc2, &color );
gc = gc1;
gdk_draw_rectangle( da->window,gc,TRUE,5, 5, 100, 100 );
gc = gc2;
gdk_draw_arc( da->window,gc,FALSE, 105, 5, 100, 100, 0, 60 * 64 );
//PangoLayout *layout = gtk_widget_create_pango_layout( da, "I'm a demon!" );
//PangoFontDescription *fontdesc = pango_font_description_from_string( "Luxi Mono 12" );
//pango_layout_set_font_description( layout, fontdesc );
//gdk_draw_layout( da->window,gc1,5, 105, layout );
//pango_font_description_free( fontdesc );
//g_object_unref( layout );
g_object_unref( G_OBJECT(gc1) );
g_object_unref( G_OBJECT(gc2) );
return TRUE;
}
int main(int argc,char *argv[])
{
GtkWidget *window;
GtkWidget *da;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Center");
gtk_window_set_default_size(GTK_WINDOW(window), 230, 150);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
da = gtk_drawing_area_new();
gtk_widget_set_size_request(da, 30, 30);
gtk_container_add(GTK_CONTAINER(window), da);
g_signal_connect(da, "expose_event",G_CALLBACK(my_expose), NULL);
gtk_widget_show_all(window);
g_signal_connect_swapped(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL);
gtk_main();
return 0;
}
阅读(1003) | 评论(0) | 转发(0) |