GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems with drawing in a DrawingArea

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
ichbinsnur



Joined: 16 Mar 2008
Posts: 4

PostPosted: Sun Mar 16, 2008 4:58 pm    Post subject: Problems with drawing in a DrawingArea Reply with quote

Hi,
i have a very hard problem with a drawing area and i couldn't find a solution for that problem.
I created 2 (dialog) windows.
The first one contains a drawing area. Inside of the drawing area i want to draw some circles. This circles are showing the state of some lamps (light on=red filled circle, or light off=black filled circle).
The state of the lamps should be updated every 100ms.
The second window contains some dialog items like buttons, sliders and so on for configuration.
I'm calling the function:
gtk_widget_queue_draw_area( drawingArea,
0,0,
drawingArea->allocation.width,
drawingArea->allocation.height);
every 100ms.

inside of the expose event function i'm drawing the images with:

if( light == ON )
gdk_draw_pixbuf(widget->window,
drawGc,
imageRed,
0,0,
xpos,ypos,
-1,-1,
GDK_RGB_DITHER_NONE,
0,0);
else
gdk_draw_pixbuf(widget->window,
drawGc,
imageBlack,
0,0,
xpos,ypos,
-1,-1,
GDK_RGB_DITHER_NONE,
0,0);

this works fine, but after some minutes the drawed circles and the dialog items (buttons a.s.o.) disapears. So i have 2 Windows containing nothing.
Is there anybody who can help me?
Back to top
ichbinsnur



Joined: 16 Mar 2008
Posts: 4

PostPosted: Tue Mar 18, 2008 9:40 pm    Post subject: Reply with quote

Seems, that it is not possible to draw items in a frequently way..
Is there nobody, who knows, how to draw in a drawing area?
nothing of the examples i found works.
Back to top
mhydra



Joined: 05 Mar 2008
Posts: 3

PostPosted: Wed Mar 19, 2008 8:11 am    Post subject: Reply with quote

It is very easy. Just place all your draw functions in the "expose" event for the GtkDrawing area and everything will be fine.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP