- GetSize (&width1, &height1);
- Bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
-
- int n;
- XtVaGetValues (listBox, XmNitemCount, &n, NULL);
- XmString text = XmStringCreateSimple ((char*) (const char*) item);
-// XmListAddItem(listBox, text, n + 1);
- XmListAddItemUnselected (listBox, text, 0);
- XmStringFree (text);
-
- // It seems that if the list is cleared, we must re-ask for
- // selection policy!!
- Arg args[3];
- XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
- if (m_windowStyle & wxLB_MULTIPLE)
- XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
- else if (m_windowStyle & wxLB_EXTENDED)
- XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
- else
- XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
- XtSetValues (listBox, args, 2);
-
- m_clientDataList.Append ((long) n, (wxObject *) clientData);
-
- if (managed)
- XtManageChild (listBox);
-
- GetSize (&width2, &height2);
-
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
-
- m_noItems ++;
-}
-
-void wxListBox::Set(int n, const wxString *choices, char** clientData)
-{
- m_clientDataList.Clear();
- int width1, height1;
- int width2, height2;
-
- Widget listBox = (Widget) m_mainWidget;
- GetSize (&width1, &height1);
-
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
-/***
- for (int i=0; i<n; i++)
- {
- XmString text = XmStringCreateSimple(choices[i]);
- XmListAddItemUnselected(listBox, text, 0);
- XmStringFree(text);
- }
-***/
- XmString *text = new XmString[n];
- int i;
- for (i = 0; i < n; i++)
- text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
-
- if ( clientData )
- for (i = 0; i < n; i++)
- m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
-
- XmListAddItems (listBox, text, n, 0);
- for (i = 0; i < n; i++)
- XmStringFree (text[i]);
- delete[]text;
-
- // It seems that if the list is cleared, we must re-ask for
- // selection policy!!
- Arg args[3];
- XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
- if (m_windowStyle & wxLB_MULTIPLE)
- XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
- else if (m_windowStyle & wxLB_EXTENDED)
- XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
- else
- XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
- XtSetValues (listBox, args, 2);
-
- if (managed)
- XtManageChild (listBox);
-
- GetSize (&width2, &height2);
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
-
- m_noItems = n;
-}
-
-int wxListBox::FindString(const wxString& s) const
-{
- XmString str = XmStringCreateSimple ((char*) (const char*) s);
- int *positions = NULL;
- int no_positions = 0;
- bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
- XmStringFree (str);
- if (success)
+ return GetCount() - 1;
+}
+
+void wxListBox::DoSetItems(const wxArrayString& items, void** clientData)
+{
+ wxSizeKeeper sk( this );
+ Widget listBox = (Widget) m_mainWidget;
+
+ if( HasClientObjectData() )
+ m_clientDataDict.DestroyData();
+
+ bool managed = XtIsManaged(listBox);
+
+ if (managed)
+ XtUnmanageChild (listBox);
+ XmString *text = new XmString[items.GetCount()];
+ size_t i;
+ for (i = 0; i < items.GetCount(); ++i)
+ text[i] = wxStringToXmString (items[i]);
+
+ if ( clientData )
+ for (i = 0; i < items.GetCount(); ++i)
+ m_clientDataDict.Set(i, (wxClientData*)clientData[i], false);
+
+ XmListAddItems (listBox, text, items.GetCount(), 0);
+ for (i = 0; i < items.GetCount(); i++)
+ XmStringFree (text[i]);
+ delete[] text;
+
+ // It seems that if the list is cleared, we must re-ask for
+ // selection policy!!
+ SetSelectionPolicy();
+
+ if (managed)
+ XtManageChild (listBox);
+
+ sk.Restore();
+
+ m_noItems = items.GetCount();
+}
+
+int wxDoFindStringInList(Widget w, const wxString& s)
+{
+ wxXmString str( s );
+ int *positions = NULL;
+ int no_positions = 0;
+ bool success = XmListGetMatchPos (w, str(),
+ &positions, &no_positions);
+
+ if (success)