vdk 2.4.0
combo.h
1/*
2 * ===========================
3 * VDK Visual Development Kit
4 * Version 0.4
5 * October 1998
6 * ===========================
7 *
8 * Copyright (C) 1998, Mario Motta
9 * Developed by Mario Motta <mmotta@guest.net>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 * 02111-130
25 */
26/* This is a wrapper for GtkCombo.
27 Author: Eric T. Wienke <eric@liquidsilver.com>
28 =====================================================================
29 Limitations: Listitems only setable via SetPopdownStrings which gets
30 mapped to gtk_list_item_new_with_label. There is no high-level
31 interface to GtkList and GtkListItem which would allow to insert
32 any object to the List. Probably not really needed for a Combobox
33 anyway.
34 One problem is that the GetPopdownStrings won't work if Gtk functions
35 are used to add anything else to the ListItems.
36 Possible solution: Write wrappers for GtkList and GtkListItem and and
37 provide a interface for them in the VDKCombo class. (too much work for
38 this widget alone, would GtkList be of any other use?)
39 ======================================================================
40*/
41
42#ifndef COMBO_H
43#define COMBO_H
44
45#include <vdk/vdkobj.h>
46#include <vdk/value_sem_list.h>
47
50
65class VDKCombo: public VDKObject
66{
67 static int FocusOutEvent(GtkWidget *w,
68 GdkEventFocus *event,
69 gpointer wid);
70 static int FocusInEvent(GtkWidget *w,
71 GdkEventFocus *event,
72 gpointer wid);
73 protected:
74 int changeConnect;
75 VDKObjectSignal s_activated, s_changed, s_selected;
76 GList *popdownlist;
77 StringList popdownstr;
78 void SortList();
79 VDKString buffer;
80public:
81 // properties
85 VDKReadWriteValueProp<VDKCombo,char*> Text;
91 VDKReadWriteValueProp<VDKCombo,bool> Editable;
97 VDKReadWriteValueProp<VDKCombo,bool> Sorted;
101 VDKReadWriteValueProp<VDKCombo,bool> Hidden;
106 VDKReadWriteValueProp<VDKCombo,bool> CaseSensitive;
137 VDKReadWriteValueProp<VDKCombo,StringList> PopdownStrings;
143 VDKReadOnlyValueProp<VDKCombo,int> Selected;
149 VDKCombo(VDKForm* owner, char* def = (char*) NULL,
150 GtkWidget* combo = NULL);
153 virtual ~VDKCombo();
154
155 void SetText(char* text);
156 char* GetText();
157 void SetEditable(bool flag)
158 { gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(widget)->entry),flag); }
159 bool GetEditable()
160 { return Editable; }
161 void SetSorted(bool flag)
162 { if(flag && !Sorted) SortList(); }
163 bool GetSorted()
164 { return Sorted; }
165 void SetBackground(VDKRgb rgb,
166 GtkStateType state);
167 void SetHidden(bool flag)
168 { gtk_entry_set_visibility(GTK_ENTRY(GTK_COMBO(widget)->entry), ! flag) ; }
169 bool GetHidden()
170 { return ! Hidden; }
171 void SetPopdownStrings(StringList);
172 StringList GetPopdownStrings();
173 void SetCaseSensitive(bool flag)
174 { gtk_combo_set_case_sensitive(GTK_COMBO(widget),flag); }
175 bool GetCaseSensitive()
176 { return (bool)(GTK_COMBO(widget)->case_sensitive); }
177 void UseArrows(bool flag)
178 { gtk_combo_set_use_arrows(GTK_COMBO(widget),flag); }
179 void UseArrowsAlways(bool flag)
180 { gtk_combo_set_use_arrows_always(GTK_COMBO(widget),flag); }
181 void SetValueInList(int val, bool ok_if_empty)
182 { gtk_combo_set_value_in_list(GTK_COMBO(widget),val,ok_if_empty); }
183 void ClearList();
184 void SelectItem(int item)
185 { gtk_list_select_item(GTK_LIST(GTK_COMBO(widget)->list), item); }
186 void UnselectItem(int item)
187 { gtk_list_unselect_item(GTK_LIST(GTK_COMBO(widget)->list), item); }
188 int GetSelected();
189#ifdef USE_SIGCPLUSPLUS
190 public:
196 VDKSignal1<void,int> OnItemSelect;
202 VDKSignal1<void,int> OnItemUnselect;
209 VDKSignal2<void,int, const char*> OnItemTextChanged;
215 VDKSignal1<void, int> OnItemActivate;
216
217 protected:
218 static void make_gtksigc_connection(VDKCombo*);
219
220 private:
221 static void _handle_item_select(GtkWidget* list,
222 GtkWidget* item,
223 gpointer obj);
224 static void _handle_item_unselect(GtkWidget* list,
225 GtkWidget* item,
226 gpointer obj);
227 static void _handle_item_text_changed(GtkWidget*, gpointer obj);
228 static void _handle_item_activate(GtkWidget*, gpointer obj);
229#endif /* USE_SIGCPLUSPLUS */
230};
231#endif
232/*
233not implemented:
234void gtk_combo_set_item_string (GtkCombo *combo, GtkItem *item, gchar *item_value)
235Probably useless until GtkList and GtkListItem are implemented.
236*/
Provides a simplified wrapper for gtkcombo.
Definition: combo.h:66
VDKCombo(VDKForm *owner, char *def=(char *) NULL, GtkWidget *combo=NULL)
Definition: combo.cc:66
void SetBackground(VDKRgb rgb, GtkStateType state)
Definition: combo.cc:153
VDKReadOnlyValueProp< VDKCombo, int > Selected
Definition: combo.h:143
VDKReadWriteValueProp< VDKCombo, StringList > PopdownStrings
Definition: combo.h:137
VDKReadWriteValueProp< VDKCombo, bool > Editable
Definition: combo.h:91
VDKReadWriteValueProp< VDKCombo, bool > CaseSensitive
Definition: combo.h:106
VDKReadWriteValueProp< VDKCombo, bool > Sorted
Definition: combo.h:97
VDKReadWriteValueProp< VDKCombo, bool > Hidden
Definition: combo.h:101
VDKReadWriteValueProp< VDKCombo, char * > Text
Definition: combo.h:85
VDKForm widgets, generally the outermost widget container.
Definition: forms.h:69
Definition: vdkobj.h:141
GtkWidget * widget
Definition: vdkobj.h:241
Provides a simple RGB color structure.
Definition: vdkutils.h:38
Implements famous cont referenced string objects.
Definition: vdkstring.h:46
provides a VDKValueList iterator
Definition: value_sem_list.h:180
Definition: vdkobj.h:62