M2GtkShim.def 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. M2LayoutManager, M2LayoutMeasureFunc, M2LayoutAllocateFunc,
  26. M2SnapshotPaintable, M2SnapshotDrawFunc,
  27. m2_gtk_widget_new, m2_paintable_new,
  28. m2_snapshot_paintable_new,
  29. m2_list_model_new, m2_list_model_items_changed,
  30. m2_layout_manager_new, m2_layout_allocate_child;
  31. TYPE
  32. M2Widget = ADDRESS;
  33. M2WidgetDrawFunc = ADDRESS;
  34. M2Paintable = ADDRESS;
  35. M2PaintableDrawFunc = ADDRESS;
  36. M2ListModel = ADDRESS;
  37. (* PROCEDURE (user: ADDRESS) : CARDINAL *)
  38. M2ListModelGetNItemsFunc = ADDRESS;
  39. (* PROCEDURE (position: CARDINAL; user: ADDRESS) : ADDRESS
  40. Must return a new reference (transfer full). *)
  41. M2ListModelGetItemFunc = ADDRESS;
  42. M2LayoutManager = ADDRESS;
  43. (* PROCEDURE (widget: ADDRESS; orientation: INTEGER; for_size: INTEGER;
  44. VAR minimum, natural: INTEGER; user: ADDRESS) *)
  45. M2LayoutMeasureFunc = ADDRESS;
  46. (* PROCEDURE (widget: ADDRESS; width, height, baseline: INTEGER;
  47. user: ADDRESS) *)
  48. M2LayoutAllocateFunc = ADDRESS;
  49. M2SnapshotPaintable = ADDRESS;
  50. (* PROCEDURE (snapshot: ADDRESS; width, height: INTEGER; user: ADDRESS) *)
  51. M2SnapshotDrawFunc = ADDRESS;
  52. (* GtkWidget *m2_gtk_widget_new(M2WidgetDrawFunc draw, gpointer user_data,
  53. GDestroyNotify destroy) *)
  54. PROCEDURE m2_gtk_widget_new (draw: M2WidgetDrawFunc; user_data: ADDRESS;
  55. destroy: ADDRESS) : M2Widget;
  56. (* GdkPaintable *m2_paintable_new(M2PaintableDrawFunc draw, int width,
  57. int height, gpointer user_data,
  58. GDestroyNotify destroy) *)
  59. PROCEDURE m2_paintable_new (draw: M2PaintableDrawFunc; width, height: INTEGER;
  60. user_data: ADDRESS; destroy: ADDRESS) : M2Paintable;
  61. (* GdkPaintable *m2_snapshot_paintable_new(M2SnapshotDrawFunc draw, int width,
  62. int height, gpointer user_data,
  63. GDestroyNotify destroy) *)
  64. PROCEDURE m2_snapshot_paintable_new (draw: M2SnapshotDrawFunc;
  65. width, height: INTEGER;
  66. user_data: ADDRESS;
  67. destroy: ADDRESS) : M2SnapshotPaintable;
  68. (* GListModel *m2_list_model_new(M2ListModelGetNItemsFunc get_n_items,
  69. M2ListModelGetItemFunc get_item,
  70. GType item_type, gpointer user_data,
  71. GDestroyNotify destroy) *)
  72. PROCEDURE m2_list_model_new (get_n_items: M2ListModelGetNItemsFunc;
  73. get_item: M2ListModelGetItemFunc;
  74. item_type: LONGCARD; user_data: ADDRESS;
  75. destroy: ADDRESS) : M2ListModel;
  76. (* void m2_list_model_items_changed(GListModel *model, guint position,
  77. guint removed, guint added) *)
  78. PROCEDURE m2_list_model_items_changed (model: M2ListModel;
  79. position, removed, added: CARDINAL);
  80. (* GtkLayoutManager *m2_layout_manager_new(M2LayoutMeasureFunc measure,
  81. M2LayoutAllocateFunc allocate,
  82. gpointer user_data,
  83. GDestroyNotify destroy) *)
  84. PROCEDURE m2_layout_manager_new (measure: M2LayoutMeasureFunc;
  85. allocate: M2LayoutAllocateFunc;
  86. user_data: ADDRESS;
  87. destroy: ADDRESS) : M2LayoutManager;
  88. (* void m2_layout_allocate_child(GtkWidget *child, int x, int y,
  89. int width, int height) *)
  90. PROCEDURE m2_layout_allocate_child (child: ADDRESS; x, y, width, height: INTEGER);
  91. END M2GtkShim.