]> Pileus Git - ~andy/gtk/blob - gtk/gtkobject.h
GtkWindow: Add gtk_window_has_group()
[~andy/gtk] / gtk / gtkobject.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /*
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/.
25  */
26
27 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_OBJECT_H__
32 #define __GTK_OBJECT_H__
33
34
35 #include <gdkconfig.h>
36 #include <gtk/gtkenums.h>
37 #include <gtk/gtktypeutils.h>
38 #include <gtk/gtkdebug.h>
39
40
41 G_BEGIN_DECLS
42
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.
46  */
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))
53
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.
58  */
59 /**
60  * GtkObjectFlags:
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
65  *
66  * Tells about the state of the object.
67  */
68 typedef enum
69 {
70   GTK_IN_DESTRUCTION    = 1 << 0, /* Used internally during dispose */
71   GTK_RESERVED_1        = 1 << 2,
72   GTK_RESERVED_2        = 1 << 3
73 } GtkObjectFlags;
74
75 /**
76  * GTK_OBJECT_FLAGS:
77  * @obj: the object whose flags are returned.
78  *
79  * Gets the #GtkObjectFlags for an object without directly
80  * accessing its members.
81  */
82 #define GTK_OBJECT_FLAGS(obj)             (GTK_OBJECT (obj)->flags)
83
84 /* Macros for setting and clearing bits in the object_flags field of GtkObject.
85  */
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
88
89 typedef struct _GtkObjectClass  GtkObjectClass;
90
91
92 struct _GtkObject
93 {
94   GInitiallyUnowned parent_instance;
95
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.
100    */
101   guint32 GSEAL (flags);
102 };
103
104 struct _GtkObjectClass
105 {
106   GInitiallyUnownedClass parent_class;
107
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
114    *  how to do this).
115    */
116   void (*destroy)  (GtkObject *object);
117 };
118
119 /* Application-level methods */
120
121 GType gtk_object_get_type (void) G_GNUC_CONST;
122
123 void gtk_object_destroy   (GtkObject *object);
124
125 G_END_DECLS
126
127 #endif /* __GTK_OBJECT_H__ */