gtkobject.inc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. // included by gtk2.pas
  2. {$IFDEF read_forward_definitions}
  3. PGtkObject = ^TGtkObject;
  4. PPGtkObject = ^PGtkObject;
  5. {$ENDIF read_forward_definitions}
  6. //------------------------------------------------------------------------------
  7. {$IFDEF read_interface_types}
  8. { GtkObject only uses the first 4 bits of the flags field.
  9. Derived objects may use the remaining bits. Though this
  10. is a kinda nasty break up, it does make the size of
  11. derived objects smaller.
  12. }
  13. { Used internally during dispose }
  14. PGtkObjectFlags = ^TGtkObjectFlags;
  15. TGtkObjectFlags = longint;
  16. { The GtkObject structure is the base of the Gtk+ objects hierarchy,
  17. it ``inherits'' from the GtkTypeObject by mirroring its fields,
  18. which must always be kept in sync completely. The GtkObject defines
  19. the few basic items that all derived classes contain.
  20. }
  21. { 32 bits of flags. GtkObject only uses 4 of these bits and
  22. GtkWidget uses the rest. This is done because structs are
  23. aligned on 4 or 8 byte boundaries. If a new bitfield were
  24. used in GtkWidget much space would be wasted.
  25. }
  26. TGtkObject = record
  27. parent_instance : TGObject;
  28. flags : guint32;
  29. end;
  30. { The GtkObjectClass is the base of the Gtk+ objects classes hierarchy,
  31. it ``inherits'' from the GtkTypeClass by mirroring its fields, which
  32. must always be kept in sync completely. The GtkObjectClass defines
  33. the basic necessities for the anObject inheritance mechanism to work.
  34. }
  35. { Non overridable class methods to set and get per class arguments }
  36. { The function that will theEnd an objects life time. In one way ore
  37. another all three of them are defined for all objects. If an
  38. anObject class overrides one of the methods in order to perform class
  39. specific destruction then it must still invoke its superclass'
  40. implementation of the method after it is finished with its
  41. own cleanup. (See the destroy function for GtkWidget for
  42. an example of how to do this).
  43. }
  44. PGtkObjectClass = ^TGtkObjectClass;
  45. TGtkObjectClass = record
  46. parent_class : TGObjectClass;
  47. set_arg : procedure (anObject:PGtkObject; arg:PGtkArg; arg_id:guint); cdecl;
  48. get_arg : procedure (anObject:PGtkObject; arg:PGtkArg; arg_id:guint); cdecl;
  49. destroy : procedure (anObject:PGtkObject); cdecl;
  50. end;
  51. {$ifndef GTK_DISABLE_DEPRECATED }
  52. { GtkArg flag bits for gtk_object_add_arg_type
  53. }
  54. PGtkArgFlags = ^TGtkArgFlags;
  55. TGtkArgFlags = longint;
  56. {$endif}
  57. { GTK_DISABLE_DEPRECATED }
  58. {$ENDIF read_interface_types}
  59. //------------------------------------------------------------------------------
  60. {$IFDEF read_interface_rest}
  61. const
  62. GTK_IN_DESTRUCTION = 1 shl 0;
  63. GTK_FLOATING = 1 shl 1;
  64. GTK_RESERVED_1 = 1 shl 2;
  65. GTK_RESERVED_2 = 1 shl 3;
  66. GTK_ARG_READABLE = G_PARAM_READABLE;
  67. GTK_ARG_WRITABLE = G_PARAM_WRITABLE;
  68. GTK_ARG_CONSTRUCT = G_PARAM_CONSTRUCT;
  69. GTK_ARG_CONSTRUCT_ONLY = G_PARAM_CONSTRUCT_ONLY;
  70. GTK_ARG_CHILD_ARG = 1 shl 4;
  71. { macros for casting a pointer to a GtkObject or GtkObjectClass pointer,
  72. and to test whether `anObject' and `klass' are of type GTK_TYPE_OBJECT.
  73. these are the standard macros for all GtkObject-derived classes.
  74. }
  75. function GTK_TYPE_OBJECT : GType;
  76. function GTK_OBJECT(anObject: pointer) : PGtkObject;
  77. function GTK_OBJECT_CLASS(klass: pointer) : PGtkObjectClass;
  78. function GTK_IS_OBJECT(anObject: pointer) : boolean;
  79. function GTK_IS_OBJECT_CLASS(klass: pointer) : boolean;
  80. function GTK_OBJECT_GET_CLASS(anObject: pointer) : PGtkObjectClass;
  81. { Macros for extracting various fields from GtkObject and GtkObjectClass.
  82. }
  83. function GTK_OBJECT_TYPE(anObject: pointer) : GType;
  84. function GTK_OBJECT_TYPE_NAME(anObject: pointer) : PGChar;
  85. { Macros for extracting the object_flags from GtkObject.
  86. }
  87. function GTK_OBJECT_FLAGS(obj: pointer) : guint32;
  88. function GTK_OBJECT_FLOATING(obj: pointer) : gboolean;
  89. { Macros for setting and clearing bits in the object_flags field of GtkObject.
  90. }
  91. procedure GTK_OBJECT_SET_FLAGS(obj: pointer; flag: guint32);
  92. procedure GTK_OBJECT_UNSET_FLAGS(obj: pointer; flag: guint32);
  93. { Application-level methods }
  94. function gtk_object_get_type:TGtkType; cdecl; external gtklib;
  95. function gtk_object_new(_type:TGtkType; first_property_name:Pgchar; args:array of const):PGtkObject; cdecl; overload; external gtklib;
  96. function gtk_object_new(_type:TGtkType; first_property_name:Pgchar):PGtkObject; cdecl; overload; external gtklib;
  97. procedure gtk_object_sink(anObject:PGtkObject); cdecl; external gtklib;
  98. procedure gtk_object_destroy(anObject:PGtkObject); cdecl; external gtklib;
  99. { }
  100. {$ifndef GTK_DISABLE_DEPRECATED }
  101. function gtk_object_ref(anObject:PGtkObject):PGtkObject; cdecl; external gtklib;
  102. procedure gtk_object_unref(anObject:PGtkObject); cdecl; external gtklib;
  103. procedure gtk_object_weakref(anObject:PGtkObject; notify:TGtkDestroyNotify; data:gpointer); cdecl; external gtklib;
  104. procedure gtk_object_weakunref(anObject:PGtkObject; notify:TGtkDestroyNotify; data:gpointer); cdecl; external gtklib;
  105. { Set 'data' to the "object_data" field of the anObject. The
  106. data is indexed by the "key". If there is already data
  107. associated with "key" then the new data will replace it.
  108. If 'data' is NULL then this call is equivalent to
  109. 'gtk_object_remove_data'.
  110. The gtk_object_set_data_full variant acts just the same,
  111. but takes an additional argument which is a function to
  112. be called when the data is removed.
  113. `gtk_object_remove_data' is equivalent to the above,
  114. where 'data' is NULL
  115. `gtk_object_get_data' gets the data associated with "key".
  116. }
  117. procedure gtk_object_set_data(anObject:PGtkObject; key:Pgchar; data:gpointer); cdecl; external gtklib;
  118. procedure gtk_object_set_data_full(anObject:PGtkObject; key:Pgchar; data:gpointer; destroy:TGtkDestroyNotify); cdecl; external gtklib;
  119. procedure gtk_object_remove_data(anObject:PGtkObject; key:Pgchar); cdecl; external gtklib;
  120. function gtk_object_get_data(anObject:PGtkObject; key:Pgchar):gpointer; cdecl; external gtklib;
  121. procedure gtk_object_remove_no_notify(anObject:PGtkObject; key:Pgchar); cdecl; external gtklib;
  122. { Set/get the "user_data" anObject data field of "anObject". It should
  123. be noted that these functions are no different than calling
  124. `gtk_object_set_data'/`gtk_object_get_data' with a key of "user_data".
  125. They are merely provided as a convenience.
  126. }
  127. procedure gtk_object_set_user_data(anObject:PGtkObject; data:gpointer); cdecl; external gtklib;
  128. function gtk_object_get_user_data(anObject:PGtkObject):gpointer; cdecl; external gtklib;
  129. { Object-level methods }
  130. { Object data method variants that operate on key ids. }
  131. procedure gtk_object_set_data_by_id(anObject:PGtkObject; data_id:TGQuark; data:gpointer); cdecl; external gtklib;
  132. procedure gtk_object_set_data_by_id_full(anObject:PGtkObject; data_id:TGQuark; data:gpointer; destroy:TGtkDestroyNotify); cdecl; external gtklib;
  133. function gtk_object_get_data_by_id(anObject:PGtkObject; data_id:TGQuark):gpointer; cdecl; external gtklib;
  134. procedure gtk_object_remove_data_by_id(anObject:PGtkObject; data_id:TGQuark); cdecl; external gtklib;
  135. procedure gtk_object_remove_no_notify_by_id(anObject:PGtkObject; key_id:TGQuark); cdecl; external gtklib;
  136. function gtk_object_data_try_key(_string:Pgchar):TGQuark;
  137. function gtk_object_data_force_id(_string:Pgchar):TGQuark;
  138. const
  139. GTK_ARG_READWRITE = GTK_ARG_READABLE or GTK_ARG_WRITABLE;
  140. procedure gtk_object_get(anObject:PGtkObject; first_property_name:Pgchar; args:array of const); cdecl; overload; external gtklib;
  141. procedure gtk_object_get(anObject:PGtkObject; first_property_name:Pgchar); cdecl; overload; external gtklib;
  142. procedure gtk_object_set(anObject:PGtkObject; first_property_name:Pgchar; args:array of const); cdecl; overload; external gtklib;
  143. procedure gtk_object_set(anObject:PGtkObject; first_property_name:Pgchar); cdecl; overload; external gtklib;
  144. procedure gtk_object_add_arg_type(arg_name:Pgchar; arg_type:TGtkType; arg_flags:guint; arg_id:guint); cdecl; external gtklib;
  145. {$endif}
  146. { GTK_DISABLE_DEPRECATED }
  147. {$ENDIF read_interface_rest}
  148. //------------------------------------------------------------------------------
  149. {$IFDEF read_implementation}
  150. function GTK_TYPE_OBJECT : GType;
  151. begin
  152. GTK_TYPE_OBJECT:=gtk_object_get_type;
  153. end;
  154. function GTK_OBJECT(anObject: pointer) : PGtkObject;
  155. begin
  156. GTK_OBJECT:=PGtkObject(GTK_CHECK_CAST(anObject,GTK_TYPE_OBJECT));
  157. end;
  158. function GTK_OBJECT_CLASS(klass: pointer) : PGtkObjectClass;
  159. begin
  160. GTK_OBJECT_CLASS:=PGtkObjectClass(GTK_CHECK_CLASS_CAST(klass,GTK_TYPE_OBJECT));
  161. end;
  162. function GTK_IS_OBJECT(anObject: pointer) : boolean;
  163. begin
  164. GTK_IS_OBJECT:=GTK_CHECK_TYPE(anObject,GTK_TYPE_OBJECT);
  165. end;
  166. function GTK_IS_OBJECT_CLASS(klass: pointer) : boolean;
  167. begin
  168. GTK_IS_OBJECT_CLASS:=GTK_CHECK_CLASS_TYPE(klass,GTK_TYPE_OBJECT);
  169. end;
  170. function GTK_OBJECT_GET_CLASS(anObject: pointer) : PGtkObjectClass;
  171. begin
  172. GTK_OBJECT_GET_CLASS:=PGtkObjectClass(GTK_CHECK_GET_CLASS(anObject,GTK_TYPE_OBJECT));
  173. end;
  174. function GTK_OBJECT_TYPE(anObject: pointer) : GType;
  175. begin
  176. GTK_OBJECT_TYPE:=G_TYPE_FROM_INSTANCE(anObject);
  177. end;
  178. function GTK_OBJECT_TYPE_NAME(anObject: pointer) : PGChar;
  179. begin
  180. GTK_OBJECT_TYPE_NAME:=g_type_name(GTK_OBJECT_TYPE(anObject));
  181. end;
  182. function GTK_OBJECT_FLAGS(obj: pointer) : guint32;
  183. begin
  184. GTK_OBJECT_FLAGS:=(GTK_OBJECT(obj))^.flags;
  185. end;
  186. function GTK_OBJECT_FLOATING(obj: pointer) : gboolean;
  187. begin
  188. GTK_OBJECT_FLOATING:=((GTK_OBJECT_FLAGS(obj)) and GTK_FLOATING) <> 0;
  189. end;
  190. procedure GTK_OBJECT_SET_FLAGS(obj: pointer; flag: guint32);
  191. begin
  192. GTK_OBJECT(obj)^.flags:=GTK_OBJECT(obj)^.flags or flag;
  193. end;
  194. procedure GTK_OBJECT_UNSET_FLAGS(obj: pointer; flag: guint32);
  195. begin
  196. GTK_OBJECT(obj)^.flags:=GTK_OBJECT(obj)^.flags and not flag;
  197. end;
  198. function gtk_object_data_try_key(_string:Pgchar):TGQuark;
  199. begin
  200. gtk_object_data_try_key:=g_quark_try_string(_string);
  201. end;
  202. function gtk_object_data_force_id(_string:Pgchar):TGQuark;
  203. begin
  204. gtk_object_data_force_id:=g_quark_from_string(_string);
  205. end;
  206. {$ENDIF read_implementation}
  207. // included by gtk2.pas