[Lazarus] Cross Codebot surface drawing examples

Anthony Walter sysrpl at gmail.com
Thu Mar 26 20:27:22 CET 2015


Leonardo,

You can absolutely use Cross Codebot to make controls, in any shape you
want. These types of controls should be graphic controls, and I provide a
bass class name TRenderGraphicControl in the Codebot.Controls unit to help
in this endeavor.

The key to making a control any shape with TRenderGraphicControl is to
override the "protected procedure Render" method, and draw using the
"protected property Surface: ISurface". Just doing your drawing in a non
rectangular manner, for example:

procedure TYourControl.Renderl
begin
  Surface.Ellipse(ClientRect);
  Surface.Fill(NewBrush(clRed));
end;

And you control now appears as a nice anti-aliased red ellipse bound within
the client area of your control. Obviously this is a trivial drawing
example, but if you go to the Codebot Cross forums you can find examples of
more complicated drawing. I regularly add new stock drawing functions to
the Codebot.Graphics unit, along with control theming, so if you're
interested you can reuse my some of stock routines to draw your custom
controls, or reuse the theme drawing routines.

I hope this helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150326/dc6e8e96/attachment-0003.html>


More information about the Lazarus mailing list