int wxComboBox::DoAppend(const wxString& item) { wxXmString str( item.c_str() ); XmComboBoxAddItem((Widget) m_mainWidget, str(), 0); m_stringList.Add(item); m_noStrings ++; return GetCount() - 1; }
static void motListAddItem(Ihandle* ih, int pos, const char* value) { XmString str = iupmotStringCreate(value); /* The utility functions use 0=last 1=first */ if (ih->data->is_dropdown || ih->data->has_editbox) XmComboBoxAddItem(ih->handle, str, pos+1, False); else XmListAddItem(ih->handle, str, pos+1); XmStringFree(str); }
bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; m_noStrings = n; Widget parentWidget = (Widget) parent->GetClientWidget(); Widget buttonWidget = XtVaCreateManagedWidget(name.c_str(), xmComboBoxWidgetClass, parentWidget, XmNmarginHeight, 0, XmNmarginWidth, 0, XmNshowLabel, False, XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY), XmNsorted, ((style & wxCB_SORT) == wxCB_SORT), XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE), NULL); int i; for (i = 0; i < n; i++) { wxXmString str( choices[i] ); XmComboBoxAddItem(buttonWidget, str(), 0); m_stringList.Add(choices[i]); } m_mainWidget = (Widget) buttonWidget; XtManageChild (buttonWidget); SetValue(value); ChangeFont(false); XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, (XtPointer) this); XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, (XtPointer) this); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); ChangeBackgroundColour(); return true; }
int wxComboBox::DoInsert(const wxString& item, unsigned int pos) { wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); wxCHECK_MSG(IsValidInsert(pos), -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; }
int main(int argc, String argv[]) { XmString str; Boolean Trav; XtAppContext AppContext; #if (XmREVISION > 1) XtSetLanguageProc(NULL,NULL,NULL); #endif TopLevel = XtAppInitialize(&AppContext, "XFontSelDemo", NULL, 0, #if (XmREVISION > 1) &argc, #else (Cardinal *) &argc, #endif argv, NULL, NULL, 0); Form = XtVaCreateManagedWidget("form", xmFormWidgetClass, TopLevel, NULL); str = XmStringCreateLtoR("Click to quit", XmSTRING_DEFAULT_CHARSET); Button = XtVaCreateManagedWidget("quit", xmPushButtonWidgetClass, Form, XmNlabelString, str, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 8, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 8, NULL); XmStringFree(str); XtAddCallback(Button, XmNactivateCallback, (XtCallbackProc) QuitCB, NULL); Sepp = XtVaCreateManagedWidget("separator1", xmSeparatorWidgetClass, Form, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopOffset, 8, XmNtopWidget, Button, NULL); str = XmStringCreateLtoR("Choose one:", XmSTRING_DEFAULT_CHARSET); ComboBox1 = XtVaCreateManagedWidget("combobox1", xmComboBoxWidgetClass, Form, XmNeditable, False, XmNsorted, True, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 8, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 8, XmNtopAttachment, XmATTACH_WIDGET, XmNtopOffset, 8, XmNtopWidget, Sepp, XmNshowLabel, True, XmNlabelString, str, NULL); XmStringFree(str); /* Put string unordered into the combo box! They'll get sorted * by the box. */ str = XmStringCreateLtoR("William the conquerior", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Karl der Gro\337e", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Henry VIII & his chicken band", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Louis XIV", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Louis de Funes", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Helmut Kohl", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("James Major", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("James Bond", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Billy Boy (M$ Windoze)", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Francois Mitterand", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox1, str, 0); XmComboBoxSelectItem(ComboBox1, str, False); XmStringFree(str); str = XmStringCreateLtoR("Choose/edit:", XmSTRING_DEFAULT_CHARSET); ComboBox2 = XtVaCreateManagedWidget("combobox2", xmComboBoxWidgetClass, Form, XmNeditable, True, XmNsorted, True, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 8, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 8, XmNtopAttachment, XmATTACH_WIDGET, XmNtopOffset, 8, XmNtopWidget, ComboBox1, XmNshowLabel, True, XmNlabelString, str, NULL); str = XmStringCreateLtoR("item can be edited after choosing it", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str); str = XmStringCreateLtoR("just to fill the list", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str); str = XmStringCreateLtoR("so it contains more entries", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Static ComboBox:", XmSTRING_DEFAULT_CHARSET); ComboBox3 = XtVaCreateManagedWidget("combobox3", xmComboBoxWidgetClass, Form, XmNeditable, True, XmNstaticList, True, XmNsorted, False, XmNcolumns, 30, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 8, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 8, XmNtopAttachment, XmATTACH_WIDGET, XmNtopOffset, 8, XmNtopWidget, ComboBox2, XmNshowLabel, True, XmNlabelString, str, NULL); XmStringFree(str); str = XmStringCreateLtoR("ComboBox (noneditable)", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str); str = XmStringCreateLtoR("ComboBox (editable)", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str); str = XmStringCreateLtoR("ComboBox (editable & static List)", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str); str = XmStringCreateLtoR("Center widget", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str); str = XmStringCreateLtoR("The ButtonFace Library", XmSTRING_DEFAULT_CHARSET); XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str); Sepp = XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass, Form, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopOffset, 8, XmNtopWidget, ComboBox3, NULL); str = XmStringCreateLtoR( "xmComboBoxWidgetClass Demo\n\nby Harald Albrecht\n\n\ [email protected]", XmSTRING_DEFAULT_CHARSET); Label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, Form, XmNlabelString, str, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 80, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 80, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 24, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, Sepp, XmNtopOffset, 24, NULL); XmStringFree(str); XtRealizeWidget(TopLevel); XtAppMainLoop(AppContext); return 0; /* Never will reach this */ } /* main */