Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: WalterK on April 15, 2011, 05:03:00 pm

Title: Graphics not working on Mac/PowerPC
Post by: WalterK on April 15, 2011, 05:03:00 pm
I'm using version 0.9.30 on my PowerPC Mac running OS 10.5.8...

I''m trying to draw some lines in a TPanel (GraphPanel).  The below code (boiled down) has no visible output on my Mac, but does draw a line on my Windows laptop (Vista).

   maxY := GraphPanel.Height;
   maxX := GraphPanel.Width;
GraphPanel.Canvas.Pen.Color:=clBlack;
GraphPanel.Canvas.Pen.Width:=4;
   GraphPanel.Canvas.Line(0,0,maxx,maxy);
   GraphPanel.Invalidate;

Can someone tell me what I'm doing wrong?

TIA.
Title: Re: Graphics not working on Mac/PowerPC
Post by: eny on April 15, 2011, 05:10:30 pm
Maybe it's because a TPanel isn't supposed to be used as a drawing surface.
For example it doesn't have an (accessible) OnPaint method.

Maybe it works if you manually set the OnPaint method of TPanel and do all painting in there.
Title: Re: Graphics not working on Mac/PowerPC
Post by: Arbee on April 15, 2011, 05:19:19 pm
I do know there is indeed a difference in how (or when) Windows and Mac update the screen.  I haven't been able to exactly pinpoint what that difference is.

Your code does not say where it is actually invoked (in some onxxxxxx event I gather), so it is hard to tell what heppens.

Incidentally ... a TPaintbox won't work either?

Title: Re: Graphics not working on Mac/PowerPC
Post by: Arbee on April 15, 2011, 05:49:57 pm
Or ... a TImage.
Title: Re: Graphics not working on Mac/PowerPC
Post by: WalterK on April 15, 2011, 09:43:25 pm
OK.  It's working now...

I used a TPanel because it has a Canvas and I didn't know any better.  I was drawing the lines upon a button click.  Apparently this is major-ignorant.

I changed to use a TPaintBox and put the line drawing code inside an OnPaint routine and it works. (I'll suspect this will work under Windows also.)

Thanks.
Title: Re: Graphics not working on Mac/PowerPC
Post by: circular on April 15, 2011, 10:45:30 pm
If you call Invalidate after you draw, it erases everything.
TinyPortal © 2005-2018