+void wxChoiceCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
+{
+ wxChoice *item = (wxChoice *) clientData;
+ if (item)
+ {
+ if (item->InSetValue())
+ return;
+
+ int n = item->GetWidgets().Index(w);
+ if (n != wxNOT_FOUND)
+ {
+ wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, item->GetId());
+ event.SetEventObject(item);
+ event.SetInt(n);
+ event.SetString( item->GetStrings().Item(n) );
+ if ( item->HasClientObjectData() )
+ event.SetClientObject( item->GetClientObject(n) );
+ else if ( item->HasClientUntypedData() )
+ event.SetClientData( item->GetClientData(n) );
+ item->ProcessCommand (event);
+ }
+ }
+}
+
+void wxChoice::ChangeFont(bool keepOriginalSize)
+{
+ // Note that this causes the widget to be resized back
+ // to its original size! We therefore have to set the size
+ // back again. TODO: a better way in Motif?
+ if (m_mainWidget && m_font.IsOk())
+ {
+ Display* dpy = XtDisplay((Widget) m_mainWidget);
+ int width, height, width1, height1;
+ GetSize(& width, & height);
+
+ WXString fontTag = wxFont::GetFontTag();
+
+ XtVaSetValues ((Widget) m_formWidget,
+ fontTag, m_font.GetFontTypeC(dpy),
+ NULL);
+ XtVaSetValues ((Widget) m_buttonWidget,
+ fontTag, m_font.GetFontTypeC(dpy),
+ NULL);
+
+ for( unsigned int i = 0; i < m_stringArray.GetCount(); ++i )
+ XtVaSetValues( (Widget)m_widgetArray[i],
+ fontTag, m_font.GetFontTypeC(dpy),
+ NULL );
+
+ GetSize(& width1, & height1);
+ if (keepOriginalSize && (width != width1 || height != height1))
+ {
+ SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
+ }
+ }
+}
+
+void wxChoice::ChangeBackgroundColour()
+{
+ wxDoChangeBackgroundColour(m_formWidget, m_backgroundColour);
+ wxDoChangeBackgroundColour(m_buttonWidget, m_backgroundColour);
+ wxDoChangeBackgroundColour(m_menuWidget, m_backgroundColour);
+ unsigned int i;
+ for (i = 0; i < m_stringArray.GetCount(); i++)
+ wxDoChangeBackgroundColour(m_widgetArray[i], m_backgroundColour);
+}
+
+void wxChoice::ChangeForegroundColour()
+{
+ wxDoChangeForegroundColour(m_formWidget, m_foregroundColour);
+ wxDoChangeForegroundColour(m_buttonWidget, m_foregroundColour);
+ wxDoChangeForegroundColour(m_menuWidget, m_foregroundColour);
+ unsigned int i;
+ for (i = 0; i < m_stringArray.GetCount(); i++)
+ wxDoChangeForegroundColour(m_widgetArray[i], m_foregroundColour);
+}
+
+unsigned int wxChoice::GetCount() const
+{
+ return m_stringArray.GetCount();
+}
+
+void wxChoice::SetString(unsigned int WXUNUSED(n), const wxString& WXUNUSED(s))
+{
+ wxFAIL_MSG( wxT("wxChoice::SetString not implemented") );
+}
+
+wxSize wxChoice::GetItemsSize() const
+{
+ int x, y, mx = 0, my = 0;
+
+ // get my
+ GetTextExtent( "|", &x, &my );
+
+ for (size_t i=0; i<m_stringArray.GetCount(); i++)
+ {
+ GetTextExtent( m_stringArray[i], &x, &y );
+ mx = wxMax( mx, x );
+ my = wxMax( my, y );
+ }
+
+ return wxSize( mx, my );
+}
+
+wxSize wxChoice::DoGetBestSize() const
+{
+ wxSize items = GetItemsSize();
+ // FIXME arbitrary constants
+ return wxSize( ( items.x ? items.x + WIDTH_OVERHEAD : 120 ),
+ items.y + HEIGHT_OVERHEAD );
+}
+
+#endif // wxUSE_CHOICE