Difference between revisions of "Accessing the Interfaces directly"

From Free Pascal wiki
Line 11: Line 11:
 
* 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 Qt object. For example, the Handle of a TCustomButton is a pointer to a QPushButton object.
  
Be aware, that you should avoid relying on any widgetset specials.
+
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.
 +
 
 +
==List of Handles on various widgetsets==
 +
 
 +
===TBitmap===
 +
 
 +
On Win32: HBITMAP
 +
On Gtk: PGDIObject
 +
 
 +
You can access this on Gtk using:
 +
 
 +
<pre>
 +
var
 +
  GDIObject: PGDIObject;
 +
  Bitmap: TBitmap;
 +
begin
 +
  ...
 +
 
 +
  GDIObject := PgdiObject(Bitmap.Handle);
 +
 
 +
  gtk_image_set_from_pixmap(MyGtkImage, GDIObject^.GDIPixmapObject,
 +
                  GDIObject^.GDIBitmapMaskObject);
 +
end;
 +
</pre>

Revision as of 14:46, 6 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 Qt object. For example, the Handle of a TCustomButton is a pointer to a QPushButton object.

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.

List of Handles on various widgetsets

TBitmap

On Win32: HBITMAP On Gtk: PGDIObject

You can access this on Gtk using:

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

  GDIObject := PgdiObject(Bitmap.Handle);

  gtk_image_set_from_pixmap(MyGtkImage, GDIObject^.GDIPixmapObject,
                   GDIObject^.GDIBitmapMaskObject);
end;