// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "combobox.h"
#endif
-#include "wx/combobox.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#include "wx/setup.h"
#if wxUSE_COMBOBOX
+#include "wx/combobox.h"
+#include "wx/arrstr.h"
+
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#ifdef __VMS__
#pragma message enable nosimpint
#endif
+
+// use the old, GPL'd combobox
+#if (XmVersion < 2000)
+
#include "xmcombo/xmcombo.h"
#include "wx/motif/private.h"
XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
- SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
+bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+{
+ wxCArrayString chs(choices);
+ return Create(parent, id, value, pos, size, chs.GetCount(),
+ chs.GetStrings(), style, validator, name);
+}
+
wxComboBox::~wxComboBox()
{
DetachWidget((Widget) m_mainWidget); // Removes event handlers
{
m_inSetValue = TRUE;
if( !value.empty() )
- XmComboBoxSetString( (Widget)m_mainWidget, (char*)value.c_str() );
+ XmComboBoxSetString( (Widget)m_mainWidget,
+ wxConstCast(value.c_str(), char) );
m_inSetValue = FALSE;
}
+void wxComboBox::SetString(int n, const wxString& s)
+{
+ wxFAIL_MSG( wxT("wxComboBox::SetString only implemented for Motif 2.0") );
+}
+
int wxComboBox::DoAppend(const wxString& item)
{
wxXmString str( item.c_str() );
return GetCount() - 1;
}
+int wxComboBox::DoInsert(const wxString& item, int pos)
+{
+ wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
+ wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+
+ if (pos == GetCount())
+ return DoAppend(item);
+
+ wxXmString str( item.c_str() );
+ XmComboBoxAddItem((Widget) m_mainWidget, str(), pos+1);
+ wxChar* copy = wxStrcpy(new wxChar[item.length() + 1], item.c_str());
+ m_stringList.Insert(pos, copy);
+ m_noStrings ++;
+
+ return pos;
+}
+
void wxComboBox::Delete(int n)
{
XmComboBoxDeletePos((Widget) m_mainWidget, n+1);
void wxComboBox::Replace(long from, long to, const wxString& value)
{
- XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
- (char*) (const char*) value);
+ XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from,
+ (XmTextPosition) to,
+ wxConstCast(value.c_str(), char));
}
void wxComboBox::Remove(long from, long to)
case XmCR_SINGLE_SELECT:
case XmCR_BROWSE_SELECT:
{
- wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId());
+ wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED,
+ item->GetId());
event.m_commandInt = cbs->index - 1;
event.m_commandString = item->GetString (event.m_commandInt);
if ( item->HasClientObjectData() )
return wxWindow::DoGetBestSize();
}
-#endif
+#endif // XmVersion < 2000
+#endif // wxUSE_COMBOBOX