Lazarus

Free Pascal => Beginners => Topic started by: Birger52 on July 11, 2020, 12:55:56 pm

Title: TBrush.Style .. who? where? what?
Post by: Birger52 on July 11, 2020, 12:55:56 pm
Wanting to draw text on a two-colored background.
Canvas.TextOut() uses current brush as background, so the result is not really what I want.
So figured Brush might have a transparent color - tried clNone, which does not do the trick.
So wanted to try a Brush.style, that does not draw anything.
Tried bsNone - which gives a compile error: found TFormBorderStyle expected TFPBrushStyle.
So tried to find a list of defined values for TFPBorder style ...

There doesn't seem to be any?
Not in SourceForge online, not in build in "documentation".
Title: Re: TBrush.Style .. who? where? what?
Post by: Blaazen on July 11, 2020, 01:10:13 pm
You should use
Code: Pascal  [Select][+][-]
  1. Brush.Style:=bsClear;
which draw transparent text.
Title: Re: TBrush.Style .. who? where? what?
Post by: Birger52 on July 11, 2020, 04:00:34 pm
Thx - figured it out by listing all constants in Graphics.

Still think TFormBorderStyle and/or TFPBrushStyle should be documented somewhere...
Title: Re: TBrush.Style .. who? where? what?
Post by: dsiders on July 11, 2020, 04:58:22 pm
Thx - figured it out by listing all constants in Graphics.

Still think TFormBorderStyle and/or TFPBrushStyle should be documented somewhere...

I'm no sure how TFormBorderStyle applies here, but TBrushStyle in LCL is an alias to TFPBrushStyle in FCL. And nothing in the fcl-image package is documented. I suppose the alias could be documented in LCL.

In any case, I would file a missing docs bug report. Otherwise, it'll get the same amount of attention as any other old forum post.
Title: Re: TBrush.Style .. who? where? what?
Post by: jamie on July 11, 2020, 05:26:16 pm

https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.html
 (https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tcanvas.html)

If you scroll down you will see TBrush.. click on that and it gives you a little more details

Also, you can visit Delphi web site and check out the Docs they have for Tbrush.

These are suppose to behave the same, not saying they do but what ever  :D

btw, I did  report some time ago that various items in the canvas was more or less undocumented..

  Like the Pen.Mode etc..
you can find this documentation looking at windows graphics help files because they have the same meaning.
Title: Re: TBrush.Style .. who? where? what?
Post by: wp on July 11, 2020, 05:41:35 pm
So tried to find a list of defined values for TFPBorder style ...

There doesn't seem to be any?
Not in SourceForge online, not in build in "documentation".

It is much more helpful to learn how to navigate in the sources of Lazarus or FPC (or any other third-party code). So, in any LCL-graphics related code the unit "graphics" should be listed in "uses", and an identifier like "Brush.Style" should be understandable for the IDE. Hold the CTRL key down and left-click on the "Style" in "Brush.Style" --> the IDE opens the unit in which Brush.Style is declared (graphics, of course), in my case, the cursor is in the line "property Style default bsSolid". Since "bsSolid" is one allowed Brush.Style, repeat the same procedure: CTRL-click on "bsSolid" and the IDE will jump to the position where "bsSolid" is declared: "bsSolid = FPCanvas.bsSolid;" - this mean that "bsSolid is an alias for the "bsSolid" of "FPCanvas". So. you repeat with CTRL-clicking on the bsSolid of "FPCanvas.bsSolid" - and this finally brings you to the declaration of TFPBrushStyle in unit FPCanvas:

Code: Pascal  [Select][+][-]
  1. type
  2.   TFPBrushStyle = (bsSolid, bsClear, bsHorizontal, bsVertical, bsFDiagonal,
  3.                    bsBDiagonal, bsCross, bsDiagCross, bsImage, bsPattern);

As you can see, to "no-fill" brush style is called "bsClear".

To learn about these brushes you could open the demo project in the folder examples/canvas_test in your Lazarus installation.
Title: Re: TBrush.Style .. who? where? what?
Post by: Birger52 on July 11, 2020, 08:39:59 pm
wp - that's helpful and good advice.
Thx.
TinyPortal © 2005-2018