File: pulist.h

package info (click to toggle)
manedit 0.8.1-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,488 kB
  • ctags: 2,910
  • sloc: ansic: 49,339; cpp: 3,562; sh: 690; makefile: 80
file content (194 lines) | stat: -rw-r--r-- 4,559 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
				Popup List
 */

#ifndef PULIST_H
#define PULIST_H

#include <gtk/gtk.h>


typedef struct _pulistbox_struct	pulistbox_struct;
#define PULISTBOX(p)			((pulistbox_struct *)(p))
typedef struct _pulist_struct		pulist_struct;
#define PULIST(p)			((pulist_struct *)(p))


/*
 *	Popup Relative:
 *
 *	Indicates the type of relativity to the rel_widget.
 */
typedef enum {
	PULIST_RELATIVE_CENTER,
	PULIST_RELATIVE_UP,
	PULIST_RELATIVE_DOWN,
	PULIST_RELATIVE_ABOVE,
	PULIST_RELATIVE_BELOW
} pulist_relative;


/*
 *	Popup List:
 */
struct _pulist_struct {

	GtkWidget	*toplevel,
			*main_vbox,
			*scrolled_window,
			*vscrollbar,
			*hscrollbar,
			*clist,
			*shadow;

	GdkPixmap	*shadow_pm;

	GtkWidget	*map_widget;	/* Shared */

	/* GTK+ block loops level */
	gint		gtk_block_level;

	/* Copy of last value */
	gchar		*last_value;

	/* Marks that the first button_press_event was sent to the
	 * clist if TRUE. This member is set FALSE at the beginning of
	 * each call to PUListMapQuery()
	 */
	gboolean	initial_list_button_press_sent;

};


/*
 *	Popup List Box:
 */
struct _pulistbox_struct {

	GtkWidget       *toplevel,
			*frame,		/* GtkFrame around the drawing area */
			*da,		/* GtkDrawingArea */
			*map_btn;	/* Map GtkButton */

	pulist_struct	*pulist;	/* Popup List */

	gint		nlines_visible;

	void	(*changed_cb)(
		pulistbox_struct *,	/* Popup List Box */
		gint,			/* Item */
		gpointer		/* Data */
	);
	gpointer	changed_data;

};


/* Popup List */
extern gint PUListFindItemFromValue(
	pulist_struct *list, const gchar *value
);
extern gpointer PUListGetDataFromValue(
	pulist_struct *list, const gchar *value
);
extern GtkWidget *PUListGetToplevel(pulist_struct *list);
extern GtkWidget *PUListGetCList(pulist_struct *list);

extern gint PUListAddItem(
	pulist_struct *list, const gchar *value
);
extern gint PUListAddItemPixText(
	pulist_struct *list, const gchar *value,
	GdkPixmap *pixmap, GdkBitmap *mask
);
extern void PUListClear(pulist_struct *list);

extern void PUListSetItemText(
	pulist_struct *list, const gint i,
	const gchar *value  
);
extern void PUListSetItemPixText(
	pulist_struct *list, const gint i,
	const gchar *value,
	GdkPixmap *pixmap, GdkBitmap *mask
);
extern void PUListSetItemData(
	pulist_struct *list, const gint i,
	gpointer data
);
extern void PUListSetItemDataFull(
	pulist_struct *list, const gint i,
	gpointer data, GtkDestroyNotify destroy_cb
);

extern gint PUListGetTotalItems(pulist_struct *list);
extern void PUListGetItemText(
	pulist_struct *list, const gint i,
	gchar **value
);
extern void PUListGetItemPixText(
	pulist_struct *list, const gint i,
	gchar **value,
	GdkPixmap **pixmap, GdkBitmap **mask
);
extern gpointer PUListGetItemData(pulist_struct *list, const gint i);

extern gint PUListGetSelectedLast(pulist_struct *list);
extern void PUListSelect(pulist_struct *list, const gint i);
extern void PUListUnselectAll(pulist_struct *list);

extern gboolean PUListIsQuery(pulist_struct *list);
extern void PUListBreakQuery(pulist_struct *list);
extern const gchar *PUListMapQuery(
	pulist_struct *list,
	const gchar *value,		/* Initial value */
	const gint lines_visible,	/* Can be -1 for default */
	const pulist_relative relative,	/* One of PULIST_RELATIVE_* */
	GtkWidget *rel_widget,		/* Map relative to this widget */
	GtkWidget *map_widget		/* Widget that mapped this list */
);

extern pulist_struct *PUListNew(void);
extern void PUListDelete(pulist_struct *list);


/* Map Button */
extern GtkWidget *PUListNewMapButton(
	void (*map_cb)(GtkWidget *, gpointer),
	gpointer client_data
);
extern GtkWidget *PUListNewMapButtonArrow(
	GtkArrowType arrow_type, GtkShadowType shadow_type,
	void (*map_cb)(GtkWidget *, gpointer),
	gpointer client_data
);


/* Popup List Box */
extern GtkWidget *PUListBoxGetToplevel(pulistbox_struct *box);
extern pulist_struct *PUListBoxGetPUList(pulistbox_struct *box);

extern pulistbox_struct *PUListBoxNew(
	GtkWidget *parent,
	const gint width, const gint height
);
extern void PUListBoxSetLinesVisible(
	pulistbox_struct *box, const gint nlines_visible
);
extern void PUListBoxSetChangedCB(
	pulistbox_struct *box,
	void (*func)(
		pulistbox_struct *,	/* Popup List Box */
		gint,			/* Item */         
		gpointer		/* Data */ 
	),
	gpointer data
);
extern void PUListBoxSelect(pulistbox_struct *box, const gint i);
extern gint PUListBoxGetSelected(pulistbox_struct *box);
extern void PUListBoxMap(pulistbox_struct *box);
extern void PUListBoxUnmap(pulistbox_struct *box);
extern void PUListBoxDelete(pulistbox_struct *box);


#endif	/* PULIST_H */