M2GtkShim.def 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. M2ListModel, M2ListModelGetNItemsFunc, M2ListModelGetItemFunc,
  25. m2_gtk_widget_new, m2_paintable_new,
  26. m2_list_model_new, m2_list_model_items_changed;
  27. TYPE
  28. M2Widget = ADDRESS;
  29. M2WidgetDrawFunc = ADDRESS;
  30. M2Paintable = ADDRESS;
  31. M2PaintableDrawFunc = ADDRESS;
  32. M2ListModel = ADDRESS;
  33. (* PROCEDURE (user: ADDRESS) : CARDINAL *)
  34. M2ListModelGetNItemsFunc = ADDRESS;
  35. (* PROCEDURE (position: CARDINAL; user: ADDRESS) : ADDRESS
  36. Must return a new reference (transfer full). *)
  37. M2ListModelGetItemFunc = ADDRESS;
  38. (* GtkWidget *m2_gtk_widget_new(M2WidgetDrawFunc draw, gpointer user_data,
  39. GDestroyNotify destroy) *)
  40. PROCEDURE m2_gtk_widget_new (draw: M2WidgetDrawFunc; user_data: ADDRESS;
  41. destroy: ADDRESS) : M2Widget;
  42. (* GdkPaintable *m2_paintable_new(M2PaintableDrawFunc draw, int width,
  43. int height, gpointer user_data,
  44. GDestroyNotify destroy) *)
  45. PROCEDURE m2_paintable_new (draw: M2PaintableDrawFunc; width, height: INTEGER;
  46. user_data: ADDRESS; destroy: ADDRESS) : M2Paintable;
  47. (* GListModel *m2_list_model_new(M2ListModelGetNItemsFunc get_n_items,
  48. M2ListModelGetItemFunc get_item,
  49. GType item_type, gpointer user_data,
  50. GDestroyNotify destroy) *)
  51. PROCEDURE m2_list_model_new (get_n_items: M2ListModelGetNItemsFunc;
  52. get_item: M2ListModelGetItemFunc;
  53. item_type: LONGCARD; user_data: ADDRESS;
  54. destroy: ADDRESS) : M2ListModel;
  55. (* void m2_list_model_items_changed(GListModel *model, guint position,
  56. guint removed, guint added) *)
  57. PROCEDURE m2_list_model_items_changed (model: M2ListModel;
  58. position, removed, added: CARDINAL);
  59. END M2GtkShim.