Please help: how to call xilb drawing functions to draw on GTK drawing areas?
- From: Ke Jin <jinkea gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Please help: how to call xilb drawing functions to draw on GTK drawing areas?
- Date: Wed, 5 Mar 2008 11:08:59 -0500
Dear All,
I am trying to use xlib function XDrawArc() to draw on a GTK drawing
area but it doesn't work, while the GDK function gdk_draw_arc() works
perfect. Does anyone know why? Below are my code:
#include <string.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
void destroy (GtkWidget *widget, gpointer *data)
{
printf("in destory\n");
gtk_main_quit ();
}
gboolean expose_event_callback (GtkWidget *widget, GdkEventExpose
*event, gpointer data)
{
//this function works fine
/*gdk_draw_arc (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
TRUE,
0, 0, widget->allocation.width, widget-
>allocation.height,
0, 64 * 360);*/
/*below xlib drawing function doesn't work*/
GdkGC *gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
XDrawArc(GDK_DRAWABLE_XDISPLAY(widget->window),
GDK_DRAWABLE_XID(widget->window), GDK_GC_XGC(gc), 0, 0, widget-
>allocation.width, widget->allocation.height,0, 64 * 360);
return TRUE;
}
int main(int argc, char* argv[])
{
GtkWidget *gtkWin;
GtkWidget *drawArea;
GtkWidget *button;
GtkWidget *mybox;
XEvent e;
pid_t pid;
Bool child = FALSE;
gtk_init (&argc, &argv);
//initialize
gtkWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
drawArea = gtk_drawing_area_new();
button = gtk_button_new_with_label("Button");
mybox = gtk_hbox_new(FALSE,10);
//attributes setup
gtk_widget_set_size_request(drawArea,100,100);
//layout
gtk_box_pack_start(GTK_BOX(mybox),button,TRUE,FALSE,0);
gtk_box_pack_start(GTK_BOX(mybox),drawArea,TRUE,FALSE,0);
gtk_container_add (GTK_CONTAINER (gtkWin), mybox);
/*Events and Signals connect*/
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (destroy),NULL);
g_signal_connect (G_OBJECT (drawArea), "expose_event",
G_CALLBACK (expose_event_callback),NULL);
/*show widgets*/
gtk_widget_show(button);
gtk_widget_show(drawArea);
gtk_widget_show(mybox);
gtk_widget_show(gtkWin);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]