Xojo Conferences
XDCMay2019MiamiUSA

Re: cocoa drawing question (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: WebListbox.SelectionChanged does not fire after DeleteAllRows when row(s) are selected before Delete
Next thread: Adding help command to top of Help menu


Re: Functions Library   -   Garth Hjelte
  Re: cocoa drawing question   -   Aaron Andrew Hunt
   Re: cocoa drawing question   -   John Kouraklis
    Re: cocoa drawing question   -   Jon Ogden
     Re: cocoa drawing question   -   John Kouraklis
      Re: cocoa drawing question   -   Arnaud Nicolet
       Re: cocoa drawing question   -   John Kouraklis
        Re: cocoa drawing question   -   Serge Louvet
        Re: cocoa drawing question   -   Arnaud Nicolet
      Re: cocoa drawing question   -   Stéphane Mons <
      Re: cocoa drawing question   -   Jon Ogden
       Re: cocoa drawing question   -   John Kouraklis
    Re: cocoa drawing question   -   Phil Smith
    cocoa drawing question   -   Phil Smith
     Re: cocoa drawing question   -   Eric Williams
     Re: cocoa drawing question   -   Joe Ranieri
     Re: cocoa drawing question   -   Roger Clary
      Re: cocoa drawing question   -   Eric de La Rochette
     Re: cocoa drawing question   -   Eric de La Rochette
     Re: cocoa drawing question   -   Norman Palardy
     Re: cocoa drawing question   -   Eric Williams
     Re: cocoa drawing question   -   Charles Yeomans

Re: cocoa drawing question
Date: 05.08.11 21:06 (Fri, 5 Aug 2011 16:06:30 -0400)
From: Aaron Andrew Hunt
> One way is as follows. You have a Canvas subclass with a property DrawSquare
> as Boolean, and code in its Paint event handler that checks this property to
> decide whether it should draw a square, and draws it if it should. Then the
> code in your button's Action event handler would look like
>
> Sub Action()
> widget.DrawSquare = true
> widget.Refresh
> End Sub
>
> This is arguably better design because the code that draws the square lives in
> the Canvas subclass.
>
> Charles Yeomans

But if you are coding cross-platform, don't use .Refresh, or you are making code that gives poor results on Windows, unless something has changed I don't know about. Using .Refresh is a no no on Windows as it always makes controls flicker.

Aaron
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 21:15 (Tue, 18 Oct 2011 21:15:13 +0100)
From: John Kouraklis
Aaron,

You write "Using .Refresh is a no no on Windows as it always makes
controls flicker."

How should this be done in windows?

Thanks

John

On 05/08/2011 23:06 , "Aaron Andrew Hunt" <<email address removed>>
wrote:

>> One way is as follows. You have a Canvas subclass with a property
>>DrawSquare
>> as Boolean, and code in its Paint event handler that checks this
>>property to
>> decide whether it should draw a square, and draws it if it should. Then
>>the
>> code in your button's Action event handler would look like
>>
>> Sub Action()
>> widget.DrawSquare = true
>> widget.Refresh
>> End Sub
>>
>> This is arguably better design because the code that draws the square
>>lives in
>> the Canvas subclass.
>>
>> Charles Yeomans
>
>But if you are coding cross-platform, don't use .Refresh, or you are
>making code that gives poor results on Windows, unless something has
>changed I don't know about. Using .Refresh is a no no on Windows as it
>always makes controls flicker.
>
>Aaron
>_______________________________________________
>Unsubscribe or switch delivery mode:
><http://www.realsoftware.com/support/listmanager/>
>Search the archives:
><http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 21:20 (Tue, 18 Oct 2011 15:20:37 -0500)
From: Jon Ogden
Use invalidate:

Sub Action()

Widget.DrawSquare = true
Widget.Invalidate

End Sub

Invalidate is what will force the paint event to fire.

Jon

On Oct 18, 2011, at 3:15 PM, John Kouraklis wrote:

> Aaron,
>
> You write "Using .Refresh is a no no on Windows as it always makes
> controls flicker."
>
> How should this be done in windows?
>
> Thanks
>
> John
>
> On 05/08/2011 23:06 , "Aaron Andrew Hunt" <<email address removed>>
> wrote:
>
>>> One way is as follows. You have a Canvas subclass with a property
>>> DrawSquare
>>> as Boolean, and code in its Paint event handler that checks this
>>> property to
>>> decide whether it should draw a square, and draws it if it should. Then
>>> the
>>> code in your button's Action event handler would look like
>>>
>>> Sub Action()
>>> widget.DrawSquare = true
>>> widget.Refresh
>>> End Sub
>>>
>>> This is arguably better design because the code that draws the square
>>> lives in
>>> the Canvas subclass.
>>>
>>>
>>> Charles Yeomans
>>
>> But if you are coding cross-platform, don't use .Refresh, or you are
>> making code that gives poor results on Windows, unless something has
>> changed I don't know about. Using .Refresh is a no no on Windows as it
>> always makes controls flicker.
>>
>> Aaron
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 21:30 (Tue, 18 Oct 2011 21:30:33 +0100)
From: John Kouraklis
Is it correct to use it on Mac too?

JK

On 18/10/2011 21:20 , "Jon Ogden" <<email address removed>> wrote:

>Use invalidate:
>
>Sub Action()
>
> Widget.DrawSquare = true
> Widget.Invalidate
>
>End Sub
>
>Invalidate is what will force the paint event to fire.
>
>Jon
>
>On Oct 18, 2011, at 3:15 PM, John Kouraklis wrote:
>
>> Aaron,
>>
>> You write "Using .Refresh is a no no on Windows as it always makes
>> controls flicker."
>>
>> How should this be done in windows?
>>
>> Thanks
>>
>> John
>>
>> On 05/08/2011 23:06 , "Aaron Andrew Hunt" <<email address removed>>
>> wrote:
>>
>>>> One way is as follows. You have a Canvas subclass with a property
>>>> DrawSquare
>>>> as Boolean, and code in its Paint event handler that checks this
>>>> property to
>>>> decide whether it should draw a square, and draws it if it should.
>>>>Then
>>>> the
>>>> code in your button's Action event handler would look like
>>>>
>>>> Sub Action()
>>>> widget.DrawSquare = true
>>>> widget.Refresh
>>>> End Sub
>>>>
>>>> This is arguably better design because the code that draws the square
>>>> lives in
>>>> the Canvas subclass.
>>>>
>>>>
>>>> Charles Yeomans
>>>
>>>
>>> But if you are coding cross-platform, don't use .Refresh, or you are
>>> making code that gives poor results on Windows, unless something has
>>> changed I don't know about. Using .Refresh is a no no on Windows as it
>>> always makes controls flicker.
>>>
>>> Aaron
>>> _______________________________________________
>>> Unsubscribe or switch delivery mode:
>>> <http://www.realsoftware.com/support/listmanager/>
>>>
>>> Search the archives:
>>> <http://support.realsoftware.com/listarchives/lists.html>
>>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>_______________________________________________
>Unsubscribe or switch delivery mode:
><http://www.realsoftware.com/support/listmanager/>
>Search the archives:
><http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 22:40 (Tue, 18 Oct 2011 23:40:15 +0200)
From: Arnaud Nicolet
Le 18 oct. 11 à 22:28, Jon Ogden a écrit:

> On Oct 18, 2011, at 3:30 PM, John Kouraklis <<email address removed>>
> wrote:
>
>> Is it correct to use it on Mac too?
> Yes.

However, it's only correct if you want to update after the MouseDrag
(i.e. you're not drawing in the MouseDrag). I'm curious as to why no
one consider this before responding.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 22:53 (Tue, 18 Oct 2011 22:53:37 +0100)
From: John Kouraklis
My question was if I should use invalidate instead of refresh and before I
got the impression that this is what I should do for both platforms
(win&mac)

And I am asking for the case that I update a canvas in general, not with
the mousedrag you're referring.

Can I use invalidate for every control, like progressbar?


On 18/10/2011 22:40 , "Arnaud Nicolet" <<email address removed>> wrote:

>Le 18 oct. 11 à 22:28, Jon Ogden a écrit:
>
>> On Oct 18, 2011, at 3:30 PM, John Kouraklis <<email address removed>>
>> wrote:
>>
>>> Is it correct to use it on Mac too?
>> Yes.
>
>However, it's only correct if you want to update after the MouseDrag
>(i.e. you're not drawing in the MouseDrag). I'm curious as to why no
>one consider this before responding.
>_______________________________________________
>Unsubscribe or switch delivery mode:
><http://www.realsoftware.com/support/listmanager/>
>Search the archives:
><http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 19.10.11 00:24 (Wed, 19 Oct 2011 01:24:43 +0200)
From: Serge Louvet
Note that .invalidate and .refresh does not work consistently across platforms.

<feedback://showreport?report_id=11741>

Serge

On 19 Oct 2011, at 01:00, Arnaud Nicolet wrote:

> Le 18 oct. 11 à 23:53, John Kouraklis a écrit:
>
>> My question was if I should use invalidate instead of refresh and before I
>> got the impression that this is what I should do for both platforms
>> (win&mac)
>>
>> And I am asking for the case that I update a canvas in general, not with
>> the mousedrag you're referring.
>
> Yes, I know, but the whole thread can be seen as a multiple-points question. Well, it doesn't matter.
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 19.10.11 00:00 (Wed, 19 Oct 2011 01:00:08 +0200)
From: Arnaud Nicolet
Le 18 oct. 11 à 23:53, John Kouraklis a écrit:

> My question was if I should use invalidate instead of refresh and
> before I
> got the impression that this is what I should do for both platforms
> (win&mac)
>
> And I am asking for the case that I update a canvas in general, not
> with
> the mousedrag you're referring.

Yes, I know, but the whole thread can be seen as a multiple-points
question. Well, it doesn't matter.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 21:35 (Tue, 18 Oct 2011 22:35:23 +0200)
From: Stéphane Mons <

Le 18 oct. 2011 à 22:30, John Kouraklis a écrit :

> Is it correct to use it on Mac too?
>
> JK

Yes. Invalidate just mark the object or window as needed to be redrawn on next screen refreshing, while .Refresh forces the image to be redrawn immediately (no matter if it is the right time to do it, considering screen refreshing).

> On 18/10/2011 21:20 , "Jon Ogden" <<email address removed>> wrote:
>
>> Use invalidate:
>>
>> Sub Action()
>>
>> Widget.DrawSquare = true
>> Widget.Invalidate
>>
>> End Sub
>>
>> Invalidate is what will force the paint event to fire.
>>
>> Jon
>>
>> On Oct 18, 2011, at 3:15 PM, John Kouraklis wrote:
>>
>>> Aaron,
>>>
>>> You write "Using .Refresh is a no no on Windows as it always makes
>>> controls flicker."
>>>
>>> How should this be done in windows?
>>>
>>> Thanks
>>>
>>> John
>>>
>>>
>>> On 05/08/2011 23:06 , "Aaron Andrew Hunt" <<email address removed>>
>>> wrote:
>>>
>>>>> One way is as follows. You have a Canvas subclass with a property
>>>>> DrawSquare
>>>>> as Boolean, and code in its Paint event handler that checks this
>>>>> property to
>>>>> decide whether it should draw a square, and draws it if it should.
>>>>> Then
>>>>> the
>>>>> code in your button's Action event handler would look like
>>>>>
>>>>> Sub Action()
>>>>> widget.DrawSquare = true
>>>>> widget.Refresh
>>>>> End Sub
>>>>>
>>>>> This is arguably better design because the code that draws the square
>>>>> lives in
>>>>> the Canvas subclass.
>>>>>
>>>>>
>>>>> Charles Yeomans
>>>>
>>>>
>>>> But if you are coding cross-platform, don't use .Refresh, or you are
>>>> making code that gives poor results on Windows, unless something has
>>>> changed I don't know about. Using .Refresh is a no no on Windows as it
>>>> always makes controls flicker.
>>>>
>>>> Aaron
>>>> _______________________________________________
>>>> Unsubscribe or switch delivery mode:
>>>> <http://www.realsoftware.com/support/listmanager/>
>>>>
>>>> Search the archives:
>>>> <http://support.realsoftware.com/listarchives/lists.html>
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Unsubscribe or switch delivery mode:
>>> <http://www.realsoftware.com/support/listmanager/>
>>>
>>> Search the archives:
>>> <http://support.realsoftware.com/listarchives/lists.html>
>>
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
>
>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

5 REM My Signature
10 PRINT "Stéphane"
20 GOTO 10



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 21:28 (Tue, 18 Oct 2011 15:28:07 -0500)
From: Jon Ogden
Yes.

Sent from my iPhone

On Oct 18, 2011, at 3:30 PM, John Kouraklis <<email address removed>> wrote:

> Is it correct to use it on Mac too?
>
> JK
>
> On 18/10/2011 21:20 , "Jon Ogden" <<email address removed>> wrote:
>
>> Use invalidate:
>>
>> Sub Action()
>>
>> Widget.DrawSquare = true
>> Widget.Invalidate
>>
>> End Sub
>>
>> Invalidate is what will force the paint event to fire.
>>
>> Jon
>>
>> On Oct 18, 2011, at 3:15 PM, John Kouraklis wrote:
>>
>>> Aaron,
>>>
>>> You write "Using .Refresh is a no no on Windows as it always makes
>>> controls flicker."
>>>
>>> How should this be done in windows?
>>>
>>> Thanks
>>>
>>> John
>>>
>>>
>>> On 05/08/2011 23:06 , "Aaron Andrew Hunt" <<email address removed>>
>>> wrote:
>>>
>>>>> One way is as follows. You have a Canvas subclass with a property
>>>>> DrawSquare
>>>>> as Boolean, and code in its Paint event handler that checks this
>>>>> property to
>>>>> decide whether it should draw a square, and draws it if it should.
>>>>> Then
>>>>> the
>>>>> code in your button's Action event handler would look like
>>>>>
>>>>> Sub Action()
>>>>> widget.DrawSquare = true
>>>>> widget.Refresh
>>>>> End Sub
>>>>>
>>>>> This is arguably better design because the code that draws the square
>>>>> lives in
>>>>> the Canvas subclass.
>>>>>
>>>>>
>>>>> Charles Yeomans
>>>>
>>>>
>>>> But if you are coding cross-platform, don't use .Refresh, or you are
>>>> making code that gives poor results on Windows, unless something has
>>>> changed I don't know about. Using .Refresh is a no no on Windows as it
>>>> always makes controls flicker.
>>>>
>>>> Aaron
>>>> _______________________________________________
>>>> Unsubscribe or switch delivery mode:
>>>> <http://www.realsoftware.com/support/listmanager/>
>>>>
>>>> Search the archives:
>>>> <http://support.realsoftware.com/listarchives/lists.html>
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Unsubscribe or switch delivery mode:
>>> <http://www.realsoftware.com/support/listmanager/>
>>>
>>> Search the archives:
>>> <http://support.realsoftware.com/listarchives/lists.html>
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 18.10.11 21:40 (Tue, 18 Oct 2011 21:40:30 +0100)
From: John Kouraklis
Thank u

JK

On 18/10/2011 21:28 , "Jon Ogden" <<email address removed>> wrote:

>Yes.
>
>Sent from my iPhone
>
>On Oct 18, 2011, at 3:30 PM, John Kouraklis <<email address removed>> wrote:
>
>> Is it correct to use it on Mac too?
>>
>> JK
>>
>> On 18/10/2011 21:20 , "Jon Ogden" <<email address removed>> wrote:
>>
>>> Use invalidate:
>>>
>>> Sub Action()
>>>
>>> Widget.DrawSquare = true
>>> Widget.Invalidate
>>>
>>> End Sub
>>>
>>> Invalidate is what will force the paint event to fire.
>>>
>>> Jon
>>>
>>> On Oct 18, 2011, at 3:15 PM, John Kouraklis wrote:
>>>
>>>> Aaron,
>>>>
>>>> You write "Using .Refresh is a no no on Windows as it always makes
>>>> controls flicker."
>>>>
>>>> How should this be done in windows?
>>>>
>>>> Thanks
>>>>
>>>> John
>>>>
>>>>
>>>> On 05/08/2011 23:06 , "Aaron Andrew Hunt" <<email address removed>>
>>>> wrote:
>>>>
>>>>>> One way is as follows. You have a Canvas subclass with a property
>>>>>> DrawSquare
>>>>>> as Boolean, and code in its Paint event handler that checks this
>>>>>> property to
>>>>>> decide whether it should draw a square, and draws it if it should.
>>>>>> Then
>>>>>> the
>>>>>> code in your button's Action event handler would look like
>>>>>>
>>>>>> Sub Action()
>>>>>> widget.DrawSquare = true
>>>>>> widget.Refresh
>>>>>> End Sub
>>>>>>
>>>>>> This is arguably better design because the code that draws the
>>>>>>square
>>>>>> lives in
>>>>>> the Canvas subclass.
>>>>>>
>>>>>>
>>>>>> Charles Yeomans
>>>>>
>>>>>
>>>>> But if you are coding cross-platform, don't use .Refresh, or you are
>>>>> making code that gives poor results on Windows, unless something has
>>>>> changed I don't know about. Using .Refresh is a no no on Windows as
>>>>>it
>>>>> always makes controls flicker.
>>>>>
>>>>> Aaron
>>>>> _______________________________________________
>>>>> Unsubscribe or switch delivery mode:
>>>>> <http://www.realsoftware.com/support/listmanager/>
>>>>>
>>>>> Search the archives:
>>>>> <http://support.realsoftware.com/listarchives/lists.html>
>>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Unsubscribe or switch delivery mode:
>>>> <http://www.realsoftware.com/support/listmanager/>
>>>>
>>>> Search the archives:
>>>> <http://support.realsoftware.com/listarchives/lists.html>
>>>
>>>
>>> _______________________________________________
>>> Unsubscribe or switch delivery mode:
>>> <http://www.realsoftware.com/support/listmanager/>
>>>
>>> Search the archives:
>>> <http://support.realsoftware.com/listarchives/lists.html>
>>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>_______________________________________________
>Unsubscribe or switch delivery mode:
><http://www.realsoftware.com/support/listmanager/>
>Search the archives:
><http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 05.08.11 19:55 (Fri, 5 Aug 2011 11:55:52 -0700)
From: Phil Smith
Good idea, but my concern would be if it was fast enough. Guess I'll just have to try it and see.

Thanks!

Phil

-------- Original Message --------
> From: "Eric de La Rochette" <<email address removed>>
> Sent: Friday, August 05, 2011 12:37 PM
> To: "Realbasic NUG" <<email address removed>>
> Subject: Re: cocoa drawing question
>
> Le 5 août 2011 à 15:31, Phil Smith a écrit :
>
> >
> > Ok, I know we are not supposed to draw outside of the Canvas paint event in
> > Cocoa. My question is how do I initiate a draw command from outside the
> > paint event? For example, when a user clicks on a button to draw a square
> > on a canvas, the old way was to simply call the Canvas.Graphics methods to
> > draw the square. But, if I understand things correctly, I shouldn't do
> > that now. How do I tell the canvas to draw the square from within the
> > paint event when the command to do it came from outside?
> >
> > My initial idea is to use some sort of queue system that contains drawing
> > commands and have the Canvas paint event scan through that but that seems
> > like it would be messy.
>
> What about about drawing into a 'buffer' picture that is stored within a property of the canvas and then call 'Invalidate' the canvas.
>
> And in the paint event just put this:
>
> g.DrawPicture Me.myBufferPicture, 0, 0
>
> HTH,
>
> --
> Eric.
>
>
>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

cocoa drawing question
Date: 05.08.11 16:31 (Fri, 5 Aug 2011 08:31:44 -0700)
From: Phil Smith

Ok, I know we are not supposed to draw outside of the Canvas paint event in
Cocoa. My question is how do I initiate a draw command from outside the
paint event? For example, when a user clicks on a button to draw a square
on a canvas, the old way was to simply call the Canvas.Graphics methods to
draw the square. But, if I understand things correctly, I shouldn't do
that now. How do I tell the canvas to draw the square from within the
paint event when the command to do it came from outside?

My initial idea is to use some sort of queue system that contains drawing
commands and have the Canvas paint event scan through that but that seems
like it would be messy.

Thanks,

Phil Smith


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 05.08.11 21:59 (Fri, 5 Aug 2011 13:59:51 -0700)
From: Eric Williams

On Aug 5, 2011, at 1:44 PM, Roger Clary wrote:

> Drawing to a buffer and then blitting that buffer pic to your canvas _should_ be the fastest way.

Not necessarily. On OS X and Linux/GTK, drawing is already buffered, so you don't need to add another layer of buffering for performance reasons. Similar results can be achieved on Windows by setting Canvas.DoubleBuffer to true.

Eric M. Williams
Oxalyn
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 05.08.11 21:53 (Fri, 5 Aug 2011 16:53:28 -0400)
From: Joe Ranieri
On Fri, Aug 5, 2011 at 16:44, Roger Clary <<email address removed>> wrote:
>
> On Aug 5, 2011, at 11:31 AM, Phil Smith wrote:
>
>> the old way was to simply call the Canvas.Graphics methods to
>> draw the square.
>
> The old "incorrect" way. I have been following this list for 10+ years and I can't remember a time when I have been advised by the most knowledgable gurus to draw in other than the paint event. It's just that now under Cocoa it's gonna crash your program if you don't.

It won't crash, it's just going to be quite a bit slower.

Re: cocoa drawing question
Date: 05.08.11 21:44 (Fri, 5 Aug 2011 16:44:32 -0400)
From: Roger Clary

On Aug 5, 2011, at 11:31 AM, Phil Smith wrote:

> the old way was to simply call the Canvas.Graphics methods to
> draw the square.

The old "incorrect" way. I have been following this list for 10+ years and I can't remember a time when I have been advised by the most knowledgable gurus to draw in other than the paint event. It's just that now under Cocoa it's gonna crash your program if you don't.

> Good idea, but my concern would be if it was fast enough.

Drawing to a buffer and then blitting that buffer pic to your canvas _should_ be the fastest way.

Roger Clary
Class One Software
http://www.classonesoftware.com
Educational Software for Lifelong Learning



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 05.08.11 21:55 (Fri, 5 Aug 2011 20:55:56 +0000)
From: Eric de La Rochette

Le 5 août 2011 à 20:44, Roger Clary a écrit :

> Drawing to a buffer and then blitting that buffer pic to your canvas _should_ be the fastest way.

Besides, if you want to implement a zoom or a scrolling functionality, drawing with Canvas.Graphics doesn't actually store the drawing. And buffered drawing eases the implementing of a undo/redo stack.

--

Re: cocoa drawing question
Date: 05.08.11 18:33 (Fri, 5 Aug 2011 17:33:52 +0000)
From: Eric de La Rochette

Le 5 août 2011 à 15:31, Phil Smith a écrit :

>
> Ok, I know we are not supposed to draw outside of the Canvas paint event in
> Cocoa. My question is how do I initiate a draw command from outside the
> paint event? For example, when a user clicks on a button to draw a square
> on a canvas, the old way was to simply call the Canvas.Graphics methods to
> draw the square. But, if I understand things correctly, I shouldn't do
> that now. How do I tell the canvas to draw the square from within the
> paint event when the command to do it came from outside?
>
> My initial idea is to use some sort of queue system that contains drawing
> commands and have the Canvas paint event scan through that but that seems
> like it would be messy.

What about about drawing into a 'buffer' picture that is stored within a property of the canvas and then call 'Invalidate' the canvas.

And in the paint event just put this:

g.DrawPicture Me.myBufferPicture, 0, 0

HTH,

--

Re: cocoa drawing question
Date: 05.08.11 17:28 (Fri, 5 Aug 2011 10:28:19 -0600)
From: Norman Palardy

On Aug 5, 2011, at 9:37 AM, Eric Williams wrote:

>
> On Aug 5, 2011, at 8:31 AM, Phil Smith wrote:
>
>>
>> Ok, I know we are not supposed to draw outside of the Canvas paint
>> event in
>> Cocoa. My question is how do I initiate a draw command from
>> outside the
>> paint event? For example, when a user clicks on a button to draw a
>> square
>> on a canvas, the old way was to simply call the Canvas.Graphics
>> methods to
>> draw the square. But, if I understand things correctly, I
>> shouldn't do
>> that now. How do I tell the canvas to draw the square from within
>> the
>> paint event when the command to do it came from outside?
>
> In theory, RectControl.Invalidate will trigger the Paint event. In
> reality, this hasn't always been the case.
>

Invalidate says "next time thing need to draw I should be redrawn"

Refresh forces a redraw

Norman Palardy

Real World 2012, THE Real Studio Event of the year!
http://realsoftware.com/community/realworld.php

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 05.08.11 16:37 (Fri, 5 Aug 2011 08:37:51 -0700)
From: Eric Williams

On Aug 5, 2011, at 8:31 AM, Phil Smith wrote:

>
> Ok, I know we are not supposed to draw outside of the Canvas paint event in
> Cocoa. My question is how do I initiate a draw command from outside the
> paint event? For example, when a user clicks on a button to draw a square
> on a canvas, the old way was to simply call the Canvas.Graphics methods to
> draw the square. But, if I understand things correctly, I shouldn't do
> that now. How do I tell the canvas to draw the square from within the
> paint event when the command to do it came from outside?

In theory, RectControl.Invalidate will trigger the Paint event. In reality, this hasn't always been the case.

Eric M. Williams
Oxalyn
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: cocoa drawing question
Date: 05.08.11 16:57 (Fri, 5 Aug 2011 11:57:24 -0400)
From: Charles Yeomans

On Aug 5, 2011, at 11:31 AM, Phil Smith wrote:

>
> Ok, I know we are not supposed to draw outside of the Canvas paint event in
> Cocoa. My question is how do I initiate a draw command from outside the
> paint event? For example, when a user clicks on a button to draw a square
> on a canvas, the old way was to simply call the Canvas.Graphics methods to
> draw the square. But, if I understand things correctly, I shouldn't do
> that now. How do I tell the canvas to draw the square from within the
> paint event when the command to do it came from outside?

One way is as follows. You have a Canvas subclass with a property DrawSquare as Boolean, and code in its Paint event handler that checks this property to decide whether it should draw a square, and draws it if it should. Then the code in your button's Action event handler would look like

Sub Action()
widget.DrawSquare = true
widget.Refresh
End Sub

This is arguably better design because the code that draws the square lives in the Canvas subclass.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>