why i can't draw the graphic??



hi,
i am using the GDK to draw graphic,the compilation is ok.but it still can't draw

the graphic.here is my code:

#include <gtk/gtk.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>

GtkWidget *NewButton(GtkWidget *box,char *szLabel)
{
	GtkWidget *Button;

	Button=gtk_button_new_with_label(szLabel);

	gtk_box_pack_start(GTK_BOX(box),Button,TRUE,TRUE,10);

	gtk_widget_show(Button);

	return(Button);
	
}

gint OpenEntry(GtkWidget *widget,gpointer datum)
{
	return(TRUE);
}

gint ZoomInEntry(GtkWidget *widget,gpointer datum)
{
	return(TRUE);
}

gint ZoomOutEntry(GtkWidget *widget,gpointer datum)
{
	return(TRUE);
}

gint CloseEntry(GtkWidget *widget,gpointer datum)
{
	g_print("quit----------\n");
	gtk_main_quit();
	return(TRUE);
}

gint RotateEntry(GtkWidget *widget,gpointer datum)
{
	return(TRUE);
}

gint ShiftEntry(GtkWidget *widget,gpointer datum)
{
	return(TRUE);
}


int main(int argc,char *argv[])
{
       GtkWidget *Mainwindow;

	GtkWidget *Vbox,*Hbox,*Drawing_area;

GtkWidget *ope_button,*zi_button,*zo_button,*clo_button,*shi_button,*rot_button;

	
	/*gtk initialization*/
	gtk_init (&argc, &argv);

	/*Mainwindown initiation*/
	Mainwindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(Mainwindow,640,480);
	gtk_window_set_title(GTK_WINDOW(Mainwindow),"vector map viewer");

	
gtk_signal_connect(GTK_OBJECT(Mainwindow),"destroy",GTK_SIGNAL_FUNC(CloseEntry),NULL);

	gtk_container_border_width(GTK_CONTAINER(Mainwindow),10);
       /*widget  initiation */
	Vbox=gtk_vbox_new(FALSE,0);

	Hbox=gtk_hbox_new(FALSE,0);

	Drawing_area=gtk_drawing_area_new ();
	gtk_drawing_area_size (GTK_DRAWING_AREA (Drawing_area),640,300);

	ope_button=NewButton(Hbox,"Open");
	
gtk_signal_connect(GTK_OBJECT(ope_button),"clicked",GTK_SIGNAL_FUNC(OpenEntry),NULL);


	zi_button=NewButton(Hbox,"Zoom in");
	
gtk_signal_connect(GTK_OBJECT(zi_button),"clicked",GTK_SIGNAL_FUNC(ZoomInEntry),NULL);

	
	zo_button=NewButton(Hbox,"Zoom out");
	
gtk_signal_connect(GTK_OBJECT(zo_button),"clicked",GTK_SIGNAL_FUNC(ZoomOutEntry),NULL);


	clo_button=NewButton(Hbox,"Close");
	
gtk_signal_connect(GTK_OBJECT(clo_button),"clicked",GTK_SIGNAL_FUNC(CloseEntry),NULL);


	shi_button=NewButton(Hbox,"Shift");
	
gtk_signal_connect(GTK_OBJECT(shi_button),"clicked",GTK_SIGNAL_FUNC(ShiftEntry),NULL);


	rot_button=NewButton(Hbox,"Rotate");
	
gtk_signal_connect(GTK_OBJECT(rot_button),"clicked",GTK_SIGNAL_FUNC(RotateEntry),NULL);


	/*widget allagement*/
	gtk_container_add(GTK_CONTAINER(Mainwindow),Vbox);

       gtk_box_pack_start(GTK_BOX(Vbox),Drawing_area,TRUE,TRUE,0);
       gtk_box_pack_start(GTK_BOX(Vbox),Hbox,FALSE,TRUE,0);

	/*show widgets */
	gtk_widget_show(Vbox);
	gtk_widget_show(Drawing_area);
	gtk_widget_show(Hbox);
	gtk_widget_show(Mainwindow);

	/* draw the graphic */
	gdk_draw_rectangle(Drawing_area->window,
			   Drawing_area->style->white_gc,
			   TRUE,
			   0,0,
			   Drawing_area->allocation.width,
			   Drawing_area->allocation.height);

	/*gdk_draw_line(Drawing_area->window,
		      Drawing_area->style->black_gc,0,0,100,100);
       */

      	/*loop*/
        gtk_main();
        return 0;

}

Where is the bug?
Thanks for any help.


_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.microsoft.com/cn




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]