comparison console/libgnt/gntwidget.h @ 13850:0e1e59770cb0

[gaim-migrate @ 16308] This is my first commit here. So don't yell at me if things get borked. Also, I haven't looked at the auto-thingies yet. So don't puke at the Makefiles. Files in console/libgnt/ are for the 'Gaim/GObjectified Ncurses Toolkit' library. Files in console/ uses libgaim and libgnt. Currently, only the buddylist-ui is 'functional', ie. the buddy-list updates when someone logs on or logs off. It still needs a lot of work. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 22 Jun 2006 08:33:54 +0000
parents
children 0d0ab1e39d0a
comparison
equal deleted inserted replaced
13849:8d1c55309e3c 13850:0e1e59770cb0
1 #ifndef GNT_WIDGET_H
2 #define GNT_WIDGET_H
3
4 #include <stdio.h>
5 #include <glib.h>
6 #include <glib-object.h>
7 #include <ncursesw/curses.h>
8
9 #define GNT_TYPE_WIDGET (gnt_widget_get_gtype())
10 #define GNT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_WIDGET, GntWidget))
11 #define GNT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_WIDGET, GntWidgetClass))
12 #define GNT_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_WIDGET))
13 #define GNT_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_WIDGET))
14 #define GNT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_WIDGET, GntWidgetClass))
15
16 #define GNT_WIDGET_FLAGS(obj) (GNT_WIDGET(obj)->priv.flags)
17 #define GNT_WIDGET_SET_FLAGS(obj, flags) (GNT_WIDGET_FLAGS(obj) |= flags)
18 #define GNT_WIDGET_UNSET_FLAGS(obj, flags) (GNT_WIDGET_FLAGS(obj) &= ~(flags))
19 #define GNT_WIDGET_IS_FLAG_SET(obj, flags) (GNT_WIDGET_FLAGS(obj) & (flags))
20 #define DEBUG
21 //#define DEBUG printf("%s\n", __FUNCTION__)
22
23 typedef struct _GnWidget GntWidget;
24 typedef struct _GnWidgetPriv GntWidgetPriv;
25 typedef struct _GnWidgetClass GntWidgetClass;
26
27 #define N_(X) X
28
29 typedef enum _GnWidgetFlags
30 {
31 GNT_WIDGET_DESTROYING = 1 << 0,
32 GNT_WIDGET_CAN_TAKE_FOCUS= 1 << 1,
33 GNT_WIDGET_MAPPED = 1 << 2,
34 /* XXX: Need to set the following two as properties, and setup a callback whenever these
35 * get chnaged. */
36 GNT_WIDGET_NO_BORDER = 1 << 3,
37 GNT_WIDGET_NO_SHADOW = 1 << 4,
38 GNT_WIDGET_HAS_FOCUS = 1 << 5
39 } GntWidgetFlags;
40
41 typedef enum _GnParamFlags
42 {
43 GNT_PARAM_SERIALIZABLE = 1 << G_PARAM_USER_SHIFT
44 } GntParamFlags;
45
46 struct _GnWidgetPriv
47 {
48 int x, y;
49 int width, height;
50 GntWidgetFlags flags;
51 char *name;
52 };
53
54 struct _GnWidget
55 {
56 GObject inherit;
57
58 GntWidget *parent;
59
60 GntWidgetPriv priv;
61 WINDOW *window;
62 WINDOW *back;
63
64 void (*gnt_reserved1)(void);
65 void (*gnt_reserved2)(void);
66 void (*gnt_reserved3)(void);
67 void (*gnt_reserved4)(void);
68 };
69
70 struct _GnWidgetClass
71 {
72 GObjectClass parent;
73
74 void (*map)(GntWidget *obj);
75 void (*show)(GntWidget *obj); /* This will call draw() and take focus (if it can take focus) */
76 void (*destroy)(GntWidget *obj);
77 void (*draw)(GntWidget *obj); /* This will draw the widget */
78 void (*expose)(GntWidget *widget, int x, int y, int width, int height);
79 void (*gained_focus)(GntWidget *widget);
80 void (*lost_focus)(GntWidget *widget);
81
82 void (*size_request)(GntWidget *widget);
83 void (*set_position)(GntWidget *widget, int x, int y);
84 gboolean (*key_pressed)(GntWidget *widget, const char *key);
85 void (*activate)(GntWidget *widget);
86
87 void (*gnt_reserved1)(void);
88 void (*gnt_reserved2)(void);
89 void (*gnt_reserved3)(void);
90 void (*gnt_reserved4)(void);
91 };
92
93 G_BEGIN_DECLS
94
95 GType gnt_widget_get_gtype(void);
96 void gnt_widget_destroy(GntWidget *widget);
97 void gnt_widget_show(GntWidget *widget);
98 void gnt_widget_draw(GntWidget *widget);
99 void gnt_widget_expose(GntWidget *widget, int x, int y, int width, int height);
100 void gnt_widget_hide(GntWidget *widget);
101
102 void gnt_widget_get_position(GntWidget *widget, int *x, int *y);
103 void gnt_widget_set_position(GntWidget *widget, int x, int y);
104 void gnt_widget_size_request(GntWidget *widget);
105 void gnt_widget_get_size(GntWidget *widget, int *width, int *height);
106 void gnt_widget_set_size(GntWidget *widget, int width, int height);
107
108 gboolean gnt_widget_key_pressed(GntWidget *widget, const char *keys);
109
110 gboolean gnt_widget_set_focus(GntWidget *widget, gboolean set);
111 void gnt_widget_activate(GntWidget *widget);
112
113 void gnt_widget_set_name(GntWidget *widget, const char *name);
114
115 G_END_DECLS
116
117 #endif /* GNT_WIDGET_H */