Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-03

How does TFPImageCanvas draw TextOut?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

David Emerson

I've started with the fontdraw example at the bottom of http://wiki.freepascal.org/Developing_with_Graphics

Somewhere in the middle, there's a call to ImgCanvas.TextOut, which seems to work just fine -- the png file has the text, and if I create a cracker class I can call TFPImageCanvasCracker.GetColor and find where the text has been drawn, without the writer, memory stream, or file stream. I don't understand how it works, though.

In the fontdraw program,
  var ImgCanvas: TFPImageCanvas;

In unit fpimgcanv,
type TFPImageCanvas = class (TFPPixelCanvas)
but it doesn't have a TextOut method.

In unit fppixlcanv,
type TFPPixelCanvas = class (TFPCustomCanvas)
and it doesn't have a TextOut method, either.

and in unit fpcanvas,
type TFPCustomCanvas = class(TPersistent)

    public procedure TextOut (x,y:integer;text:string);

Okay, so I see that in the fontdraw example program, ImgCanvas inherits TextOut from TFPCustomCanvas; and it's not overridden in TFPPixelCanvas or TFPImageCanvas.

TFPCustomCanvas.TextOut simply calls DoTextOut, however
TFPCustomCanvas.DoTextOut is virtual; abstract;
In TFPPixelCanvas, I see protected procedure DoTextOut
(x,y:integer;text:string); override;

However, the procedure only makes a call to "NotImplemented;"

And TFPImageCanvas does not override DoTextOut, either.

So what on earth is going on here? I don't see any place where a procedure is being called that actually draws the text.

I do see that in ftfont, a DrawText procedure exists -- and it seems pretty clear that that's the procedure that's actually drawing the text. But how is it being called?

Puzzled,
~David.

David Emerson
to leledumbo

Thanks! I haven't gotten lazarus running yet, but I took another look and figured it out.

TFPCustomCanvas.TextOut checks if Font is TFPCustomDrawFont then TFPCustomDrawFont(Font).DrawText(x,y, text)
...and it turns out that it is; I didn't look at the fontdraw program closely enough. I've got to get lazarus working, though, that sounds very handy -- I have spent a long time poking around and I could just press a key and get an answer to my question.

Cheers,
David.

leledumbo wrote
Try holding ctrl and click TextOut on that line using Lazarus, it will

bring

you to the correct place where (in which class) the method is

implemented /

overridden (in interface section). Then, use Ctrl+Shfit+Down to go to

the

implementation. -- View this message in context:

http://www.nabble.com/How-does-TFPImageCanvas-draw-TextOut--tp22268842p22281629.html

Sent from the Free Pascal - General mailing list archive at

Nabble.com.

Show quoted text 5 lines
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal