Re: Re:Background of Drawarea (in Viewport)



On Thu, 2005-12-29 at 21:29 +0100, olivier_martin wrote:
> I reply to myself ... I found the mistake, I forgot to put
> area.show(); ...
> 
> And i can have now a result, but i have still an error ... I
> want to draw on my widget an arc, but with this new code a
> SEGFAULT is thrown ...
> 
> MyComponent::MyComponent() {
> 	set_events(Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK |
> Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK);
> 	area.set_size_request(600,400);
> 	add(area);
> 	area.show();
> 	area.modify_bg(Gtk::STATE_NORMAL,Gdk::Color("white"));
> 
> 	Glib::RefPtr<Gdk::GC> blackgc = area.get_style()->get_black_gc();
> 	area.get_window()->draw_arc(blackgc,false,100,100,20,20,0,23040);
> }

lets repeat the mantra again:

	Users of X Window based toolkits: draw only in response to 
        expose events. Draw *only* in response to expose events.

You have two specific problems in the code above:

	a) the area has no Gdk::Window until it has been realized,
	   which occurs at a point in time that you have no
	   control over.

	b) you should draw into an on-screen drawable (like the 
           Gdk::Window) only from an expose event handler.

--p





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