// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "combobox.h"
#endif
-#include "wx/combobox.h"
+#include "wx/setup.h"
#if wxUSE_COMBOBOX
+#include "wx/combobox.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();
{
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);
- wxNode *node = m_stringList.Nth(n);
+ wxStringList::Node *node = m_stringList.Item(n);
if (node)
{
- delete[] (char *)node->Data();
+ delete[] node->GetData();
delete node;
}
m_clientDataDict.Delete(n, HasClientObjectData());
wxString wxComboBox::GetString(int n) const
{
- wxNode *node = m_stringList.Nth(n);
+ wxStringList::Node *node = m_stringList.Item(n);
if (node)
- return wxString((char *) node->Data ());
+ return wxString(node->GetData ());
else
return wxEmptyString;
}
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