M2GtkShim.def 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. DEFINITION MODULE FOR "C" M2GtkShim ;
  2. (*
  3. m2-GTK4 - C shim for GObject subclassing.
  4. GNU Modula-2 cannot register a GObject subclass or override vfuncs.
  5. This module exposes two C-implemented helper types whose snapshot
  6. vfunc hands a Cairo context to a Modula-2 callback, so custom drawing
  7. is possible without leaving Modula-2 (and reusing the Cairo binding).
  8. Provided by lib/m2gtkshim.c:
  9. M2Widget a GtkWidget subclass. The draw callback is
  10. PROCEDURE (widget: ADDRESS; cr: ADDRESS;
  11. width, height: INTEGER; user: ADDRESS);
  12. Set its size with GtkWidget.gtk_widget_set_size_request.
  13. M2Paintable a GdkPaintable implementation. The draw callback is
  14. PROCEDURE (cr: ADDRESS; width, height: INTEGER;
  15. user: ADDRESS);
  16. Give it to a GtkPicture or GtkImage.
  17. user_data is passed through; the optional destroy procedure runs when
  18. the object is finalized.
  19. *)
  20. FROM SYSTEM IMPORT ADDRESS;
  21. EXPORT UNQUALIFIED
  22. M2Widget, M2WidgetDrawFunc,
  23. M2Paintable, M2PaintableDrawFunc,
  24. m2_gtk_widget_new, m2_paintable_new;
  25. TYPE
  26. M2Widget = ADDRESS;
  27. M2WidgetDrawFunc = ADDRESS;
  28. M2Paintable = ADDRESS;
  29. M2PaintableDrawFunc = ADDRESS;
  30. (* GtkWidget *m2_gtk_widget_new(M2WidgetDrawFunc draw, gpointer user_data,
  31. GDestroyNotify destroy) *)
  32. PROCEDURE m2_gtk_widget_new (draw: M2WidgetDrawFunc; user_data: ADDRESS;
  33. destroy: ADDRESS) : M2Widget;
  34. (* GdkPaintable *m2_paintable_new(M2PaintableDrawFunc draw, int width,
  35. int height, gpointer user_data,
  36. GDestroyNotify destroy) *)
  37. PROCEDURE m2_paintable_new (draw: M2PaintableDrawFunc; width, height: INTEGER;
  38. user_data: ADDRESS; destroy: ADDRESS) : M2Paintable;
  39. END M2GtkShim.