2 * @file gntwidget.h Widget API
6 * GNT - The GLib Ncurses Toolkit
8 * GNT is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
34 #include "gntbindable.h"
36 #define GNT_TYPE_WIDGET (gnt_widget_get_gtype())
37 #define GNT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_WIDGET, GntWidget))
38 #define GNT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_WIDGET, GntWidgetClass))
39 #define GNT_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_WIDGET))
40 #define GNT_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_WIDGET))
41 #define GNT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_WIDGET, GntWidgetClass))
43 #define GNT_WIDGET_FLAGS(obj) (GNT_WIDGET(obj)->priv.flags)
44 #define GNT_WIDGET_SET_FLAGS(obj, flags) (GNT_WIDGET_FLAGS(obj) |= flags)
45 #define GNT_WIDGET_UNSET_FLAGS(obj, flags) (GNT_WIDGET_FLAGS(obj) &= ~(flags))
46 #define GNT_WIDGET_IS_FLAG_SET(obj, flags) (GNT_WIDGET_FLAGS(obj) & (flags))
48 typedef struct _GntWidget GntWidget
;
49 typedef struct _GntWidgetPriv GntWidgetPriv
;
50 typedef struct _GntWidgetClass GntWidgetClass
;
52 typedef enum _GntWidgetFlags
54 GNT_WIDGET_DESTROYING
= 1 << 0,
55 GNT_WIDGET_CAN_TAKE_FOCUS
= 1 << 1,
56 GNT_WIDGET_MAPPED
= 1 << 2,
57 /* XXX: Need to set the following two as properties, and setup a callback whenever these
59 GNT_WIDGET_NO_BORDER
= 1 << 3,
60 GNT_WIDGET_NO_SHADOW
= 1 << 4,
61 GNT_WIDGET_HAS_FOCUS
= 1 << 5,
62 GNT_WIDGET_DRAWING
= 1 << 6,
63 GNT_WIDGET_URGENT
= 1 << 7,
64 GNT_WIDGET_GROW_X
= 1 << 8,
65 GNT_WIDGET_GROW_Y
= 1 << 9,
66 GNT_WIDGET_INVISIBLE
= 1 << 10,
67 GNT_WIDGET_TRANSIENT
= 1 << 11,
68 GNT_WIDGET_DISABLE_ACTIONS
= 1 << 12,
71 /* XXX: This will probably move elsewhere */
72 typedef enum _GntMouseEvent
74 GNT_LEFT_MOUSE_DOWN
= 1,
76 GNT_MIDDLE_MOUSE_DOWN
,
82 /* XXX: I'll have to ask grim what he's using this for in guifications. */
83 typedef enum _GntParamFlags
85 GNT_PARAM_SERIALIZABLE
= 1 << G_PARAM_USER_SHIFT
95 int minw
, minh
; /* Minimum size for the widget */
107 void (*gnt_reserved1
)(void);
108 void (*gnt_reserved2
)(void);
109 void (*gnt_reserved3
)(void);
110 void (*gnt_reserved4
)(void);
113 struct _GntWidgetClass
115 GntBindableClass parent
;
117 void (*map
)(GntWidget
*obj
);
118 void (*show
)(GntWidget
*obj
); /* This will call draw() and take focus (if it can take focus) */
119 void (*destroy
)(GntWidget
*obj
);
120 void (*draw
)(GntWidget
*obj
); /* This will draw the widget */
121 void (*hide
)(GntWidget
*obj
);
122 void (*expose
)(GntWidget
*widget
, int x
, int y
, int width
, int height
);
123 void (*gained_focus
)(GntWidget
*widget
);
124 void (*lost_focus
)(GntWidget
*widget
);
126 void (*size_request
)(GntWidget
*widget
);
127 gboolean (*confirm_size
)(GntWidget
*widget
, int x
, int y
);
128 void (*size_changed
)(GntWidget
*widget
, int w
, int h
);
129 void (*set_position
)(GntWidget
*widget
, int x
, int y
);
130 gboolean (*key_pressed
)(GntWidget
*widget
, const char *key
);
131 void (*activate
)(GntWidget
*widget
);
132 gboolean (*clicked
)(GntWidget
*widget
, GntMouseEvent event
, int x
, int y
);
134 void (*gnt_reserved1
)(void);
135 void (*gnt_reserved2
)(void);
136 void (*gnt_reserved3
)(void);
137 void (*gnt_reserved4
)(void);
147 GType
gnt_widget_get_gtype(void);
153 void gnt_widget_destroy(GntWidget
*widget
);
159 void gnt_widget_show(GntWidget
*widget
);
165 void gnt_widget_draw(GntWidget
*widget
);
175 void gnt_widget_expose(GntWidget
*widget
, int x
, int y
, int width
, int height
);
181 void gnt_widget_hide(GntWidget
*widget
);
189 void gnt_widget_get_position(GntWidget
*widget
, int *x
, int *y
);
197 void gnt_widget_set_position(GntWidget
*widget
, int x
, int y
);
203 void gnt_widget_size_request(GntWidget
*widget
);
211 void gnt_widget_get_size(GntWidget
*widget
, int *width
, int *height
);
221 gboolean
gnt_widget_set_size(GntWidget
*widget
, int width
, int height
);
231 gboolean
gnt_widget_confirm_size(GntWidget
*widget
, int width
, int height
);
240 gboolean
gnt_widget_key_pressed(GntWidget
*widget
, const char *keys
);
251 gboolean
gnt_widget_clicked(GntWidget
*widget
, GntMouseEvent event
, int x
, int y
);
260 gboolean
gnt_widget_set_focus(GntWidget
*widget
, gboolean set
);
266 void gnt_widget_activate(GntWidget
*widget
);
273 void gnt_widget_set_name(GntWidget
*widget
, const char *name
);
275 const char *gnt_widget_get_name(GntWidget
*widget
);
277 /* Widget-subclasses should call this from the draw-callback.
278 * Applications should just call gnt_widget_draw instead of this. */
283 void gnt_widget_queue_update(GntWidget
*widget
);
290 void gnt_widget_set_take_focus(GntWidget
*widget
, gboolean set
);
297 void gnt_widget_set_visible(GntWidget
*widget
, gboolean set
);
305 gboolean
gnt_widget_has_shadow(GntWidget
*widget
);
309 #endif /* GNT_WIDGET_H */