Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

combo.h

00001 /* 00002 * =========================== 00003 * VDK Visual Development Kit 00004 * Version 0.4 00005 * October 1998 00006 * =========================== 00007 * 00008 * Copyright (C) 1998, Mario Motta 00009 * Developed by Mario Motta <mmotta@guest.net> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Library General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00024 * 02111-130 00025 */ 00026 /* This is a wrapper for GtkCombo. 00027 Author: Eric T. Wienke <eric@liquidsilver.com> 00028 ===================================================================== 00029 Limitations: Listitems only setable via SetPopdownStrings which gets 00030 mapped to gtk_list_item_new_with_label. There is no high-level 00031 interface to GtkList and GtkListItem which would allow to insert 00032 any object to the List. Probably not really needed for a Combobox 00033 anyway. 00034 One problem is that the GetPopdownStrings won't work if Gtk functions 00035 are used to add anything else to the ListItems. 00036 Possible solution: Write wrappers for GtkList and GtkListItem and and 00037 provide a interface for them in the VDKCombo class. (too much work for 00038 this widget alone, would GtkList be of any other use?) 00039 ====================================================================== 00040 */ 00041 00042 #ifndef COMBO_H 00043 #define COMBO_H 00044 00045 #include <vdk/vdkobj.h> 00046 #include <vdk/value_sem_list.h> 00047 00048 typedef VDKValueList<VDKString> StringList; 00049 typedef VDKValueListIterator<VDKString> StringListIterator; 00050 00065 class VDKCombo: public VDKObject 00066 { 00067 static int FocusOutEvent(GtkWidget *w, 00068 GdkEventFocus *event, 00069 gpointer wid); 00070 static int FocusInEvent(GtkWidget *w, 00071 GdkEventFocus *event, 00072 gpointer wid); 00073 protected: 00074 int changeConnect; 00075 VDKObjectSignal s_activated, s_changed, s_selected; 00076 GList *popdownlist; 00077 StringList popdownstr; 00078 void SortList(); 00079 VDKString buffer; 00080 public: 00081 // properties 00085 VDKReadWriteValueProp<VDKCombo,char*> Text; 00091 VDKReadWriteValueProp<VDKCombo,bool> Editable; 00097 VDKReadWriteValueProp<VDKCombo,bool> Sorted; 00101 VDKReadWriteValueProp<VDKCombo,bool> Hidden; 00106 VDKReadWriteValueProp<VDKCombo,bool> CaseSensitive; 00137 VDKReadWriteValueProp<VDKCombo,StringList> PopdownStrings; 00143 VDKReadOnlyValueProp<VDKCombo,int> Selected; 00149 VDKCombo(VDKForm* owner, char* def = (char*) NULL, 00150 GtkWidget* combo = NULL); 00153 virtual ~VDKCombo(); 00154 00155 void SetText(char* text); 00156 char* GetText(); 00157 void SetEditable(bool flag) 00158 { gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(widget)->entry),flag); } 00159 bool GetEditable() 00160 { return Editable; } 00161 void SetSorted(bool flag) 00162 { if(flag && !Sorted) SortList(); } 00163 bool GetSorted() 00164 { return Sorted; } 00165 void SetBackground(VDKRgb rgb, 00166 GtkStateType state); 00167 void SetHidden(bool flag) 00168 { gtk_entry_set_visibility(GTK_ENTRY(GTK_COMBO(widget)->entry), ! flag) ; } 00169 bool GetHidden() 00170 { return ! Hidden; } 00171 void SetPopdownStrings(StringList); 00172 StringList GetPopdownStrings(); 00173 void SetCaseSensitive(bool flag) 00174 { gtk_combo_set_case_sensitive(GTK_COMBO(widget),flag); } 00175 bool GetCaseSensitive() 00176 { return (bool)(GTK_COMBO(widget)->case_sensitive); } 00177 void UseArrows(bool flag) 00178 { gtk_combo_set_use_arrows(GTK_COMBO(widget),flag); } 00179 void UseArrowsAlways(bool flag) 00180 { gtk_combo_set_use_arrows_always(GTK_COMBO(widget),flag); } 00181 void SetValueInList(int val, bool ok_if_empty) 00182 { gtk_combo_set_value_in_list(GTK_COMBO(widget),val,ok_if_empty); } 00183 void ClearList(); 00184 void SelectItem(int item) 00185 { gtk_list_select_item(GTK_LIST(GTK_COMBO(widget)->list), item); } 00186 void UnselectItem(int item) 00187 { gtk_list_unselect_item(GTK_LIST(GTK_COMBO(widget)->list), item); } 00188 int GetSelected(); 00189 #ifdef USE_SIGCPLUSPLUS 00190 public: 00196 VDKSignal1<void,int> OnItemSelect; 00202 VDKSignal1<void,int> OnItemUnselect; 00209 VDKSignal2<void,int, const char*> OnItemTextChanged; 00215 VDKSignal1<void, int> OnItemActivate; 00216 00217 protected: 00218 static void make_gtksigc_connection(VDKCombo*); 00219 00220 private: 00221 static void _handle_item_select(GtkWidget* list, 00222 GtkWidget* item, 00223 gpointer obj); 00224 static void _handle_item_unselect(GtkWidget* list, 00225 GtkWidget* item, 00226 gpointer obj); 00227 static void _handle_item_text_changed(GtkWidget*, gpointer obj); 00228 static void _handle_item_activate(GtkWidget*, gpointer obj); 00229 #endif /* USE_SIGCPLUSPLUS */ 00230 }; 00231 #endif 00232 /* 00233 not implemented: 00234 void gtk_combo_set_item_string (GtkCombo *combo, GtkItem *item, gchar *item_value) 00235 Probably useless until GtkList and GtkListItem are implemented. 00236 */

Generated on Wed Jul 28 17:23:53 2004 for vdk 2.0.3 by doxygen 1.3.7