]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/choicdgg.cpp
Split this out from other changes to keep things sane..
[wxWidgets.git] / src / generic / choicdgg.cpp
index c56105fb18b1ef0e1f4c410b2a97339f6dd3c17b..db7973f6addf3bfbf0fd8bf08cf93a028c10c85e 100644 (file)
@@ -28,6 +28,8 @@
     #pragma hdrstop
 #endif
 
+#if wxUSE_CHOICEDLG
+
 #ifndef WX_PRECOMP
     #include <stdio.h>
     #include "wx/utils.h"
@@ -84,7 +86,7 @@ int ConvertWXArrayToC(const wxArrayString& aChoices, wxString **choices)
 
     for ( int i = 0; i < n; i++ )
     {
-        (*choices)[i] = aChoices[i];   
+        (*choices)[i] = aChoices[i];
     }
 
     return n;
@@ -127,7 +129,7 @@ wxString wxGetSingleChoice( const wxString& message,
     return res;
 }
 
-#ifdef WXWIN_COMPATIBILITY_2
+#if WXWIN_COMPATIBILITY_2
 // Overloaded for backward compatibility
 wxString wxGetSingleChoice( const wxString& message,
                             const wxString& caption,
@@ -167,7 +169,24 @@ int wxGetSingleChoiceIndex( const wxString& message,
     return choice;
 }
 
-#ifdef WXWIN_COMPATIBILITY_2
+int wxGetSingleChoiceIndex( const wxString& message,
+                            const wxString& caption,
+                            const wxArrayString& aChoices,
+                            wxWindow *parent,
+                            int x, int y,
+                            bool centre,
+                            int width, int height)
+{
+    wxString *choices;
+    int n = ConvertWXArrayToC(aChoices, &choices);
+    int res = wxGetSingleChoiceIndex(message, caption, n, choices, parent,
+                                     x, y, centre, width, height);
+    delete [] choices;
+
+    return res;
+}
+
+#if WXWIN_COMPATIBILITY_2
 // Overloaded for backward compatibility
 int wxGetSingleChoiceIndex( const wxString& message,
                             const wxString& caption,
@@ -225,7 +244,7 @@ void *wxGetSingleChoiceData( const wxString& message,
     return res;
 }
 
-#ifdef WXWIN_COMPATIBILITY_2
+#if WXWIN_COMPATIBILITY_2
 // Overloaded for backward compatibility
 void *wxGetSingleChoiceData( const wxString& message,
                              const wxString& caption,
@@ -259,6 +278,10 @@ size_t wxGetMultipleChoices(wxArrayInt& selections,
                             int WXUNUSED(width), int WXUNUSED(height))
 {
     wxMultiChoiceDialog dialog(parent, message, caption, n, choices);
+
+    if ( !selections.IsEmpty() )
+        dialog.SetSelections(selections);
+
     if ( dialog.ShowModal() == wxID_OK )
         selections = dialog.GetSelections();
     else
@@ -294,7 +317,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
                                const wxString& message,
                                const wxString& caption,
                                int n, const wxString *choices,
-                               long WXUNUSED(styleDlg), // FIXME: why unused?
+                               long styleDlg,
                                const wxPoint& pos,
                                long styleLbox)
 {
@@ -323,7 +346,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
 #endif
 
     // 4) buttons
-    topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxCENTRE | wxALL, 10 );
+    topsizer->Add( CreateButtonSizer( styleDlg & (wxOK|wxCANCEL) ), 0, wxCENTRE | wxALL, 10 );
 
     SetAutoLayout( TRUE );
     SetSizer( topsizer );
@@ -361,7 +384,7 @@ wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
     Create(parent, message, caption, n, choices, clientData, style);
 }
 
-#ifdef WXWIN_COMPATIBILITY_2
+#if WXWIN_COMPATIBILITY_2
 
 wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
                                            const wxString& message,
@@ -431,11 +454,8 @@ void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
 {
     m_selection = m_listbox->GetSelection();
     m_stringSelection = m_listbox->GetStringSelection();
-    // TODO!
-#ifndef __WXMOTIF__
     if ( m_listbox->HasClientUntypedData() )
         SetClientData(m_listbox->GetClientData(m_selection));
-#endif
     EndModal(wxID_OK);
 }
 
@@ -444,11 +464,8 @@ void wxSingleChoiceDialog::OnListBoxDClick(wxCommandEvent& WXUNUSED(event))
     m_selection = m_listbox->GetSelection();
     m_stringSelection = m_listbox->GetStringSelection();
 
-    // TODO!
-#ifndef __WXMOTIF__
     if ( m_listbox->HasClientUntypedData() )
         SetClientData(m_listbox->GetClientData(m_selection));
-#endif
 
     EndModal(wxID_OK);
 }
@@ -487,11 +504,6 @@ void wxMultiChoiceDialog::SetSelections(const wxArrayInt& selections)
 
 bool wxMultiChoiceDialog::TransferDataFromWindow()
 {
-    // VZ: I hate to do it but I can't fix wxMotif right now (FIXME)
-#ifdef __WXMOTIF__
-    #define IsSelected Selected
-#endif
-
     m_selections.Empty();
     size_t count = m_listbox->GetCount();
     for ( size_t n = 0; n < count; n++ )
@@ -502,3 +514,5 @@ bool wxMultiChoiceDialog::TransferDataFromWindow()
 
     return TRUE;
 }
+
+#endif // wxUSE_CHOICEDLG