Re: drawing a line
- From: John Cupitt ng-london org uk
- To: shiraz_baig yahoo com
- Cc: gtk-list gnome org
- Subject: Re: drawing a line
- Date: Fri, 1 Feb 2002 12:06:19 -0000
Hiya, try the page for the drawing area widget:
http://gtk.org/tutorial/sec-thedrawingareawidget.html
I think this explains the problem. With a window system, you don't just
draw on the screen. What happens when your window is covered or
uncovered? You need to be able to recreate any part of your display when
it is exposed.
The rule is: do all drawing in the expose handler. If you want to draw
in respose to an event, set some hints somewhere and trigger an expose.
As Sven said, you also have a bug in your button callback.
John
Shiraz Baig wrote:
> Hi,
> Thanks for the reply. But I have not really
> understood the answer. My doubt is that if Drawing the
> line with the timer function does not need any
> "expose" event. Then why is pushing_button needing it?
> Why can't pushing_button also draw the line without
> expose_event?
> Thanks.
> Shiraz
>
> --- John Cupitt ng-london org uk wrote:
>
>>Shiraz Baig wrote:
>>
>> > Hi,
>> > I want to draw a line when I push a button. I
>>have
>> > written the following code. It draws line thru
>>two
>> > alternative signal commands.
>> > a. Thru the timer function.
>> > b. Thru the push button.
>> >
>> > It works with the timer function. But it does not
>>work
>> > with the push button.
>> >
>> > Question:
>> > Can anyone suggest how can it draw the line when
>>I
>> > click the button?
>> >
>>
>>
>>Hi, you need to connect to "expose_event" and do
>>your repaint there.
>>
>>Don't paint on button click. Instead, change your
>>model (your internal
>>representation of what it is you are showing on the
>>screen), and ask for
>>a repaint to be queued for your window with
>>gtk_widget_draw().
>>
>>Also, you have a problem with your button callback.
>>
>>The scribble example covers some of this stuff:
>>
==========================================================
Coming soon:
Aelbert Cuyp 13 February - 12 May 2002
For information and tickets:
http://www.nationalgallery.org.uk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]