Recent

Author Topic: Graphics not working on Mac/PowerPC  (Read 4923 times)

WalterK

  • New Member
  • *
  • Posts: 48
Graphics not working on Mac/PowerPC
« 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.

eny

  • Hero Member
  • *****
  • Posts: 1609
Re: Graphics not working on Mac/PowerPC
« Reply #1 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.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: Graphics not working on Mac/PowerPC
« Reply #2 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?

1.0/2.6.0  XP SP3 & OS X 10.6.8

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: Graphics not working on Mac/PowerPC
« Reply #3 on: April 15, 2011, 05:49:57 pm »
Or ... a TImage.
1.0/2.6.0  XP SP3 & OS X 10.6.8

WalterK

  • New Member
  • *
  • Posts: 48
Re: Graphics not working on Mac/PowerPC
« Reply #4 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.

circular

  • Hero Member
  • *****
  • Posts: 3442
    • Personal webpage
Re: Graphics not working on Mac/PowerPC
« Reply #5 on: April 15, 2011, 10:45:30 pm »
If you call Invalidate after you draw, it erases everything.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018