Drawing a line
- From: Rayne Olivetti <rayneolivetti yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: Drawing a line
- Date: Fri, 1 Apr 2005 15:02:19 -0800 (PST)
Hi,
I'm trying to draw a line to the screen with gtk+, but
it seems I'm doing something wrong :( Can someone
please help me? Thanks in advance,
Rayne
===========================
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include <gtk/gtk.h>
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify)
gtk_widget_unref)
#define BORDER_WIDTH 4
#define TITLE_MAIN_WIN PACKAGE VERSION
GtkWidget *main_window, *tileset_window,
*layer_window;
GtkWidget *status_bar, *vbox, *drawing_area;
GdkGC *gc;
GdkColormap *colormap;
GdkPixmap *test_pxm;
static gboolean quit_gtk(GtkWidget *widget, GdkEvent
*event, gpointer data)
{
gtk_main_quit();
return FALSE;
}
static GtkWidget * create_window(char *title, char
*ref_str)
{
GtkWidget *window;
assert( (window =
gtk_window_new(GTK_WINDOW_TOPLEVEL)) != NULL );
gtk_window_set_title(GTK_WINDOW (window), title);
gtk_container_set_border_width (GTK_CONTAINER
(window), BORDER_WIDTH);
GLADE_HOOKUP_OBJECT (window, window, ref_str);
return window;
}
int main(int argc, char *argv[])
{
GdkColor cl;
gtk_init (&argc, &argv);
main_window = create_window(TITLE_MAIN_WIN,
"main_window");
g_signal_connect(G_OBJECT (main_window),
"delete_event", G_CALLBACK (quit_gtk), NULL);
gtk_widget_show(main_window);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add (GTK_CONTAINER (main_window),
vbox);
GLADE_HOOKUP_OBJECT (main_window, vbox, "vbox");
gtk_widget_show(vbox);
assert( (drawing_area = gtk_drawing_area_new()) !=
NULL );
gtk_widget_show(drawing_area);
gtk_box_pack_start(GTK_BOX (vbox), drawing_area,
TRUE, TRUE, 0);
GLADE_HOOKUP_OBJECT (main_window, drawing_area,
"drawing_area");
gtk_drawing_area_size( GTK_DRAWING_AREA( drawing_area
), 200, 200);
gtk_widget_set_usize(drawing_area, 200, 200);
assert( (gc = gdk_gc_new(drawing_area->window)) !=
NULL );
colormap = gdk_colormap_get_system();
assert( (gc = gdk_gc_new(drawing_area->window)) !=
NULL );
gtk_widget_show(main_window);
gdk_draw_rectangle(drawing_area->window,
drawing_area->style->black_gc, TRUE, 2, 3, 40, 45 );
gtk_widget_queue_draw(drawing_area);
gtk_main();
return 0;
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]