在gtk_drawing_area中画条线

jackxiang 2009-8-5 17:22 | |

#include "gtk/gtk.h"

gboolean draw_some( GtkWidget *widget, GdkEventExpose *event,
         gpointer data )
{
    gdk_draw_line( widget->window,
       widget->style->fg_gc[GTK_WIDGET_STATE( widget )],
       10, 10, 100, 100 );
    return TRUE;
}


int main( int argc, char *argv[] )
{
    GtkWidget* window;
    GtkWidget* draw_area;
    
    gtk_init( &argc, &argv );
    
    window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    gtk_widget_set_usize( window, 400, 300 );
    g_signal_connect( G_OBJECT( window ), "destroy",
          G_CALLBACK( gtk_main_quit ), NULL );

    draw_area = gtk_drawing_area_new( );
    gtk_widget_set_size_request( draw_area, 100, 100 );
    g_signal_connect( G_OBJECT( draw_area ), "expose_event",
          G_CALLBACK( draw_some ), NULL );

    gtk_container_add( GTK_CONTAINER( window ), draw_area );

    gtk_widget_show( draw_area );
    gtk_widget_show( window );
    
    gtk_main( );
    
    return 0;
}

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1896/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]