Difference between revisions of "Accessing the Interfaces directly"

From Free Pascal wiki
Jump to navigationJump to search
m
Line 9: Line 9:
 
* under windows a Handle is often a HWnd.
 
* under windows a Handle is often a HWnd.
 
* under carbon a Handle is often a ControlRef
 
* under carbon a Handle is often a ControlRef
* under Qt, a Handle is often a pointer to a Qt object. For example, the Handle of a TCustomButton is a pointer to a QPushButton object.
+
* under Qt, a Handle is often a pointer to a object descendent of TQtWidget.
  
 
Be aware that you should avoid relying on any widgetset specials. This page is for people improving the widgetsets and for people writting components that need to access the widgets directly.
 
Be aware that you should avoid relying on any widgetset specials. This page is for people improving the widgetsets and for people writting components that need to access the widgets directly.
 +
 +
==Per-Widgetset Details==
 +
 +
===Qt===
 +
 +
Handles on Qt are mostly pointers to objects. Every time a control is created, a helper object is also created and both are connected. The helper object is necessary to receive events from Qt. After receiving a event it will send it to the LCL.
 +
 +
Most of those objects are descendents from TQtWidget as declared bellow:
 +
 +
<pre>
 +
{ TQtWidget }
 +
 +
TQtWidget = class(QWidgetH)
 +
private
 +
public
 +
  Widget: QWidgetH;
 +
  LCLObject: TWinControl;
 +
end;
 +
</pre>
 +
 +
Notice the two variables they all contain:
 +
 +
* Widget - This is a connect to the Qt object for this Widget
 +
* LCLObject - Is a bridge with the LCL object it is linked to.
  
 
==List of Handles on various LCL classes==
 
==List of Handles on various LCL classes==
Line 19: Line 43:
 
* On Win32: HBITMAP
 
* On Win32: HBITMAP
 
* On Gtk: PGDIObject (defined on unit GtkDef)
 
* On Gtk: PGDIObject (defined on unit GtkDef)
 +
* On Qt: Not yet implemented
  
 
You can access this on Gtk using:
 
You can access this on Gtk using:
Line 43: Line 68:
 
===TCustomForm===
 
===TCustomForm===
  
*
+
* On Windows: it´s a HWND
*
+
* On Gtk:
* On Qt it is a QMainWindow
+
* On Qt: It´ss a TQtMainWindow. It´s Widget variable points to a QMainWindow Qt object.

Revision as of 02:49, 12 February 2006

This page describes, how to write a new LCL control, using the various LCL interfaces for the platform dependent implementations.

OpenGL is a platform independent language for 3D graphics. The platform dependent part is to get a OpenGL context. Under linux/freebsd/X you use glx for that, under windows you use WGL and under MacOSX you can use AGL.

Every TWinControl has a Handle, and the LCL does not need to know, what a Handle is. The meaning of the Handle is totally up to the LCL interface:

  • under gtk a Handle is often a PGtkWidget
  • under windows a Handle is often a HWnd.
  • under carbon a Handle is often a ControlRef
  • under Qt, a Handle is often a pointer to a object descendent of TQtWidget.

Be aware that you should avoid relying on any widgetset specials. This page is for people improving the widgetsets and for people writting components that need to access the widgets directly.

Per-Widgetset Details

Qt

Handles on Qt are mostly pointers to objects. Every time a control is created, a helper object is also created and both are connected. The helper object is necessary to receive events from Qt. After receiving a event it will send it to the LCL.

Most of those objects are descendents from TQtWidget as declared bellow:

 { TQtWidget }

 TQtWidget = class(QWidgetH)
 private
 public
   Widget: QWidgetH;
   LCLObject: TWinControl;
 end;

Notice the two variables they all contain:

  • Widget - This is a connect to the Qt object for this Widget
  • LCLObject - Is a bridge with the LCL object it is linked to.

List of Handles on various LCL classes

TBitmap

  • On Win32: HBITMAP
  • On Gtk: PGDIObject (defined on unit GtkDef)
  • On Qt: Not yet implemented

You can access this on Gtk using:

var
  GDIObject: PGDIObject;
  Bitmap: TBitmap;
  AImage: PGtkWidget;
begin
  ...

  GDIObject := PgdiObject(Bitmap.Handle);

  AImage := gtk_image_new_from_pixmap(GDIObject^.GDIPixmapObject,
   GDIObject^.GDIBitmapMaskObject);

  gtk_widget_show(AImage);

  gtk_container_add(GTK_CONTAINER(MyForm.Handle), AImage);
end;

TCustomForm

  • On Windows: it´s a HWND
  • On Gtk:
  • On Qt: It´ss a TQtMainWindow. It´s Widget variable points to a QMainWindow Qt object.