[Lazarus] Nice Lazarus ScrabbleControl, also a Gtk2 Bug

Marc Weustink marc at dommelstein.nl
Fri Aug 9 15:57:04 CEST 2019


Anthony Walter via lazarus wrote:
> Marc,
> 
> I can completely understand how it evolved, and early on the features of 
> both the Free Pascal language, and the way the LCL library were to be 
> adapted to multiple platforms became more clear. Thanks for your hard work.
> 
> I've thought about the way the LCL is structured to handle many 
> platforms for quite some time now, and if it were remade I'd strongly 
> prefer it if every platform and native control were implemented through 
> a set of well defined platform agnostic interfaces. Then each platform 
> would adhere to that interface in order to implement it in classes such 
> as TGtk2Canvas, TGtk2Window, and TGtk2WindowManager. Of course this 
> would never happen, as it would mean a complete rewrite of everything, 
> but perhaps someday someone might want to remake a new non Delphi 
> compatible library from scratch for FPC and carry forward with this idea.
> 
> For example:
> 
> ICanvas = interface
>    function MoveTo(X, Y: Integer): Boolean;
>    function LineTo(X, Y: Integer): Boolean;
>    ...
> end;
> 
> IWindow = interface
>    function Show: Boolean;
>    function Hide: Boolean;
>    function GetBounds(out Rect: TRect): Boolean;
>    function SetBounds(const Rect: TRect): Boolean;
>    function GetText(out S: string): Boolean;
>    function SetText(out S: string): Boolean;
>    ...
> end;
> 
> IWindowManager = interface
>    function WindowCreate(const Params: TWindowParams; out W: IWindow): 
> Boolean;
>    function WindowDestroy(W: IWindow): Boolean;
>    function BringToFront(Window: IWindow): Boolean;
>    function SendToBack(Window: IWindow): Boolean;
>    function GetCursorPos(out P: TPoint): Boolean;
>    function SetCursorPos(const P: TPoint): Boolean;
>    ...
> end;
> 
> 


Thats what the WSWidgetClasses more or less tried to do. But even with 
this approach you may encounter cases that for a given widgetset one 
interface has to implemented partly in one class and partly in another.

Another problem with interfaces I fear is is code size. My feeling says 
that you need all implementation classes in your exe. I've not 
experimented with it.

Marc



More information about the lazarus mailing list