Index: Makefile.am =================================================================== RCS file: /projects/pgadmin3/src/Makefile.am,v retrieving revision 1.80 retrieving revision 1.81 diff -Lsrc/Makefile.am -Lsrc/Makefile.am -u -w -r1.80 -r1.81 --- src/Makefile.am +++ src/Makefile.am @@ -32,7 +32,7 @@ agent/pgaStep.cpp agent/pgaSchedule.cpp \ agent/dlgJob.cpp agent/dlgSchedule.cpp agent/dlgStep.cpp \ ui/xh_sqlbox.cpp ui/xh_calb.cpp ui/xh_timespin.cpp \ -ui/ctlSecurityPanel.cpp ui/dlgClasses.cpp \ +ui/ctlSecurityPanel.cpp ui/dlgClasses.cpp ui/ctlComboBox.cpp \ ui/frmGrantWizard.cpp \ ui/calbox.cpp ui/timespin.cpp ui/ctlListView.cpp \ ui/ctlSQLBox.cpp ui/ctlSQLResult.cpp ui/frmExport.cpp \ @@ -89,7 +89,7 @@ include/pgServer.h include/pgSet.h include/pgTable.h \ include/pgTrigger.h include/pgType.h include/pgUser.h \ include/pgView.h include/sysLogger.h include/utffile.h \ -include/calbox.h include/timespin.h \ +include/calbox.h include/timespin.h include/ctlComboBox.h \ include/xh_timespin.h include/xh_calb.h include/xh_sqlbox.h \ include/sysSettings.h include/wxgridsel.h include/menu.h\ agent/include/pgaAgent.h agent/include/pgaJob.h \ --- /dev/null +++ src/include/ctlComboBox.h @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id: ctlComboBox.h,v 1.1 2004/06/17 18:12:25 andreas Exp $ +// Copyright (C) 2002 - 2004, The pgAdmin Development Team +// This software is released under the Artistic Licence +// +// ctlComboBox.h - enhanced combobox control +// +////////////////////////////////////////////////////////////////////////// + + +#ifndef __COMBOBOX_H +#define __COMBOBOX_H + +// wxWindows headers +#include + + +class ctlComboBox : public wxComboBox +{ +public: + ctlComboBox(wxWindow *wnd, int id, wxPoint pos, wxSize siz, long attr=0); + int GuessSelection(); + int GetSelection() const; + wxString GetStringSelection() const; +}; + +#endif --- /dev/null +++ src/ui/ctlComboBox.cpp @@ -0,0 +1,65 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id: ctlComboBox.cpp,v 1.1 2004/06/17 18:12:25 andreas Exp $ +// Copyright (C) 2002 - 2004, The pgAdmin Development Team +// This software is released under the Artistic Licence +// +// ctlComboBox.cpp - enhanced combobox control +// +////////////////////////////////////////////////////////////////////////// + + + +// App headers +#include "pgAdmin3.h" +#include "ctlComboBox.h" + + +ctlComboBox::ctlComboBox(wxWindow *wnd, int id, wxPoint pos, wxSize siz, long attr) +: wxComboBox(wnd, id, wxEmptyString, pos, siz, attr) +{ +} + + +int ctlComboBox::GuessSelection() +{ + wxString str=GetValue(); + if (str.Length()) + { + long pos=GetInsertionPoint(); + + long sel, count=GetCount(); + int len=str.Length(); + for (sel = 0 ; sel < count ; sel++) + { + if (str == GetString(sel).Left(len)) + { + SetSelection(sel); + wxString current = GetString(sel); + SetSelection(pos, current.Length()); + return sel; + } + } + } + return -1; +} + + +int ctlComboBox::GetSelection() const +{ + int sel=wxComboBox::GetSelection(); + if (sel < 0) + sel = FindString(GetValue()); + return sel; +} + + +wxString ctlComboBox::GetStringSelection() const +{ + int sel=GetSelection(); + if (sel < 0) + return wxEmptyString; + else + return GetString(sel); +}