+ if (event.m_extraLong)
+ SetSelection (event.m_commandInt);
+ else
+ {
+ Deselect (event.m_commandInt);
+ return;
+ }
+ ProcessCommand (event);
+}
+
+void wxListBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
+ XmListCallbackStruct * cbs)
+{
+ /*
+ if (cbs->reason == XmCR_EXTENDED_SELECT)
+ cout << "*** Extend select\n";
+ else if (cbs->reason == XmCR_SINGLE_SELECT)
+ cout << "*** Single select\n";
+ else if (cbs->reason == XmCR_MULTIPLE_SELECT)
+ cout << "*** Multiple select\n";
+ else if (cbs->reason == XmCR_BROWSE_SELECT)
+ cout << "*** Browse select\n";
+
+ if (cbs->selection_type == XmMODIFICATION)
+ cout << "*** Modification\n";
+ else if (cbs->selection_type == XmINITIAL)
+ cout << "*** Initial\n";
+ else if (cbs->selection_type == XmADDITION)
+ cout << "*** Addition\n";
+ */
+
+ wxListBox *item = (wxListBox *) clientData;
+
+ if (item->InSetValue())
+ return;
+
+ wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED, item->GetId());
+ switch (cbs->reason)
+ {
+ case XmCR_MULTIPLE_SELECT:
+ case XmCR_BROWSE_SELECT:
+ {
+ event.m_clientData = item->GetClientData (cbs->item_position - 1);
+ event.m_commandInt = cbs->item_position - 1;
+ event.m_extraLong = TRUE;
+ event.SetEventObject(item);
+ item->ProcessCommand (event);
+ break;
+ }
+ case XmCR_EXTENDED_SELECT:
+ {
+ switch (cbs->selection_type)
+ {
+ case XmINITIAL:
+ case XmADDITION:
+ case XmMODIFICATION:
+ {
+ event.m_clientData = item->GetClientData (cbs->item_position - 1);
+ event.m_commandInt = cbs->item_position - 1;
+ event.m_extraLong = TRUE;
+ event.SetEventObject(item);
+ item->ProcessCommand (event);
+ break;
+ }
+ }
+ break;
+ }
+ }
+}
+
+/* Respond by getting the
+* designated "default button" in the action area and activate it
+* as if the user had selected it.
+*/
+void wxListBoxDefaultActionProc (Widget WXUNUSED(list_w), XtPointer client_data, XmListCallbackStruct * WXUNUSED(cbs))
+{
+ wxListBox *lbox = (wxListBox *) client_data;
+
+ wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, lbox->GetId());
+ event.SetEventObject( lbox );
+ lbox->GetEventHandler()->ProcessEvent(event) ;
+}
+
+WXWidget wxListBox::GetTopWidget() const
+{
+ return (WXWidget) XtParent( (Widget) m_mainWidget );
+}
+
+void wxListBox::ChangeFont(bool keepOriginalSize)
+{
+ wxWindow::ChangeFont(keepOriginalSize);
+}
+
+void wxListBox::ChangeBackgroundColour()
+{
+ wxWindow::ChangeBackgroundColour();
+
+ Widget parent = XtParent ((Widget) m_mainWidget);
+ Widget hsb, vsb;
+
+ XtVaGetValues (parent,
+ XmNhorizontalScrollBar, &hsb,
+ XmNverticalScrollBar, &vsb,
+ NULL);
+
+ /* TODO: should scrollbars be affected? Should probably have separate
+ * function to change them (by default, taken from wxSystemSettings)
+ */
+ wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
+ DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
+
+ XtVaSetValues (hsb,
+ XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)),
+ NULL);
+ XtVaSetValues (vsb,
+ XmNtroughColor, backgroundColour.AllocColour(XtDisplay(vsb)),
+ NULL);
+
+ DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
+}
+
+void wxListBox::ChangeForegroundColour()
+{
+ wxWindow::ChangeForegroundColour();
+
+ Widget parent = XtParent ((Widget) m_mainWidget);
+ Widget hsb, vsb;
+
+ XtVaGetValues(parent,
+ XmNhorizontalScrollBar, &hsb,
+ XmNverticalScrollBar, &vsb,
+ NULL);
+
+ /* TODO: should scrollbars be affected? Should probably have separate
+ function to change them (by default, taken from wxSystemSettings)
+
+ DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
+ DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
+ DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
+ */
+}
+
+// These implement functions needed by wxControlWithItems.
+// Unfortunately, they're not all implemented yet.
+
+int wxListBox::GetCount() const
+{
+ return Number();
+}
+
+int wxListBox::DoAppend(const wxString& item)
+{
+ Append(item, (void*) NULL);
+ return GetCount() - 1;
+}
+
+// Just appends, doesn't yet insert
+void wxListBox::DoInsertItems(const wxArrayString& items, int WXUNUSED(pos))
+{
+ size_t nItems = items.GetCount();
+
+ for ( size_t n = 0; n < nItems; n++ )
+ {
+ Append( items[n], (void*) NULL);
+ }
+}
+
+void wxListBox::DoSetItems(const wxArrayString& items, void **clientData)
+{
+ size_t nItems = items.GetCount();
+ wxString* strings = new wxString[nItems];
+
+ for ( size_t n = 0; n < nItems; n++ )