[Customdrawn] Replace some widgets

Giuliano Colla giuliano.colla at fastwebnet.it
Tue Apr 3 12:28:05 CEST 2012

Il 03/04/2012 11:40, Michael Schnell ha scritto:
> I understand that CustomDrawn provides code for rendering the visual 
> "Components" (Widgets) used by the user code to pixel-images. Same are 
> then sent to one of the attachable backends to have them displayed.
> Now these Components not only need to be visualized, but they also 
> provide information to the user code (events, readable properties, ...) .
> I understand that there are "basic" Components (supposedly something 
> similar to Panel and Label) that in fact need to be rendered and 
> "higher level" Components that use the basic ones to have themselves 
> be displayed.
> If I decide that some or all of these "basic" components should not be 
> rendered to pixels but still the user code needs the functionality it 
> sees: does the CustomDrawn code provide a "hook" that allows for 
> replacing the pixel-rendering code by something provided by a 
> "3rd-party" ? (E.g. to create a "remote" GUI or to switch off the 
> visibility altogether.)
> This of course not only asks for appropriately intercepting the 
> information flow direction towards the visualization, but also needs 
> allowing to implement the appropriate events (such as those generated 
> by Timers and Threads and - if doing a remote GUI - the remote user).

CustomDrawn is actually divided in a common section, and one dedicated 
section for each backend supported.
The common section performs only abstract operations, such as painting 
the widget image in the widget's canvas, dispatching messages, etc.

Then each backend takes care of implementing the actual physical 
drawing, detecting mouse and keyboard actions, implementing Timers, etc.

Splitting at backend level is, in principle straightforward: you insert 
a new backend, which does whatever you have in mind and it takes the 
place of existing backends. Instead of {$define CD_cocoa} you'll put 
{$define CD_Michael} in the main defines (customdrawndefines.inc),
and you'll have to write your own version of all _Something files (such 
as customdrawnwinapi_Michael.inc).

Splitting at widget level on the contrary is very difficult, because 
they follow the inheritance rules.

Almost all visible LCL components are descendants of TControl, and 
therefore on Widgetset side you find in customdrawn a TCDWSControl 
class, which implements the basic methods, common to all controls.

So if you create your own backend, you may decide that if the control 
it's supposed to deal with is a TEdit, you'll send it via TCP/IP to a 
remote server, if it's a TButton you'll paint it on screen 1, if it's a 
TLabel you'll output the text to a console, if it's a TTimer you'll ask 
a CallBack from your Time Server, etc.

I don't know if this answers to your question.


More information about the Customdrawn mailing list