1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
31 #ifndef __GTK_OBJECT_H__
32 #define __GTK_OBJECT_H__
35 #include <gdkconfig.h>
36 #include <gtk/gtkenums.h>
37 #include <gtk/gtktypeutils.h>
38 #include <gtk/gtkdebug.h>
43 /* macros for casting a pointer to a GtkObject or GtkObjectClass pointer,
44 * and to test whether `object' and `klass' are of type GTK_TYPE_OBJECT.
45 * these are the standard macros for all GtkObject-derived classes.
47 #define GTK_TYPE_OBJECT (gtk_object_get_type ())
48 #define GTK_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_OBJECT, GtkObject))
49 #define GTK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_OBJECT, GtkObjectClass))
50 #define GTK_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_OBJECT))
51 #define GTK_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_OBJECT))
52 #define GTK_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GTK_TYPE_OBJECT, GtkObjectClass))
54 /* GtkObject only uses the first 4 bits of the flags field.
55 * Derived objects may use the remaining bits. Though this
56 * is a kinda nasty break up, it does make the size of
57 * derived objects smaller.
61 * @GTK_IN_DESTRUCTION: the object is currently being destroyed. This is used
62 * internally by GTK+ to prevent reinvokations during destruction.
63 * @GTK_RESERVED_1: reserved for future use
64 * @GTK_RESERVED_2: reserved for future use
66 * Tells about the state of the object.
70 GTK_IN_DESTRUCTION = 1 << 0, /* Used internally during dispose */
71 GTK_RESERVED_1 = 1 << 2,
72 GTK_RESERVED_2 = 1 << 3
77 * @obj: the object whose flags are returned.
79 * Gets the #GtkObjectFlags for an object without directly
80 * accessing its members.
82 #define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT (obj)->flags)
84 /* Macros for setting and clearing bits in the object_flags field of GtkObject.
86 #define GTK_OBJECT_SET_FLAGS(obj,flag) G_STMT_START{ (GTK_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
87 #define GTK_OBJECT_UNSET_FLAGS(obj,flag) G_STMT_START{ (GTK_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
89 typedef struct _GtkObjectClass GtkObjectClass;
94 GInitiallyUnowned parent_instance;
96 /* 32 bits of flags. GtkObject only uses 4 of these bits and
97 * GtkWidget uses the rest. This is done because structs are
98 * aligned on 4 or 8 byte boundaries. If a new bitfield were
99 * used in GtkWidget much space would be wasted.
101 guint32 GSEAL (flags);
104 struct _GtkObjectClass
106 GInitiallyUnownedClass parent_class;
108 /* Default signal handler for the ::destroy signal, which is
109 * invoked to request that references to the widget be dropped.
110 * If an object class overrides destroy() in order to perform class
111 * specific destruction then it must still invoke its superclass'
112 * implementation of the method after it is finished with its
113 * own cleanup. (See gtk_widget_real_destroy() for an example of
116 void (*destroy) (GtkObject *object);
119 /* Application-level methods */
121 GType gtk_object_get_type (void) G_GNUC_CONST;
123 void gtk_object_destroy (GtkObject *object);
127 #endif /* __GTK_OBJECT_H__ */