[Lazarus] More Gtk3 Status

Anthony Walter sysrpl at gmail.com
Fri Jul 15 20:38:01 CEST 2022


Kostas,

We already have an object oriented layer to interact with controls. That
layer is the LCL. What you are saying is it makes sense for each widgetset
to create their own separate and independent class hierarchy, or to use
TWidgetInfo, or have something akin to:

  LCL-> WSClasses -> TSomePlatformWidgets (ie TGtk3Widget class and
derivitatives) -> Flat C API

What would make more sense to me would be:

  LCL Object -> IWidget -> Flat C API

Where any control would need to fill implement the requirements of IWidget
to be complete. In this way we could have a contract between the LCL and
what is expected of a control (IWidget), a button (IButton), a listbox
(IListBox), a page control (IPageControl), and so on.

You might ask how does this fix anything? Well first it nails down three
layers instead of four of five. Second, it creates a contact between the
LCL and someone writing the part to go between the LCL and flat C APIs.
Third, it provides a consistent model for  ANYONE wanting to implement a
widgetset, thus making it MUCH easier for people to understand what is
going on. Forth, implementors can look at other widgetsets to understand
how to create a new or fix a malfunctioning part of the widgetset they are
working on.

Again, I would support the idea of using Handles on platform specific
objects, like a Canvas (DC on Windows, CairoRed of gtk3), a WinControl
(HWND on Windows, PGtkObject on gtk2/Gtk3)

IN ADDITION TO

A well described non reference counted interface model for platform
specific objects (IWidget, ICanvas, IButton, IListBox) which the LCL would
depend on to automatically take care of the platform and widget specific
glue.

uses
  { This unit would defines the contract between the LCL and all Widgetset
be defining all relevant
  interfaces  that must be implemented to make a LCL widgetset }
  Widgets,
    ...
  ;

type
  TWinControl = class(TControl, IWidget)
  private
    FWidget: IWidget;
  protected
    property Widget: IWidget read FWidget  implements IWidget;
    ....
  end;

...

  TCustomListBox = class(TWinControl, IListBox)
  private
    function GetListBox: IListBox;
  protected
    property ListBox: IListBox read GetListBox implements IListBox;
    ....
  end;

...

function TCustomListBox.GetListBox: IListBox;
begin
  Result := Widget as IListBox;
end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20220715/468daeb3/attachment.htm>


More information about the lazarus mailing list