]> git.saurik.com Git - wxWidgets.git/commitdiff
Take void** client data in wxSingleChoiceDialog ctor and not char**.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Feb 2012 14:18:33 +0000 (14:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 5 Feb 2012 14:18:33 +0000 (14:18 +0000)
The client data is supposed to be untyped, there is really no reason (other
than compatibility with C conventions of 40 years ago) to use char** here.
So don't do it and provide the versions taking "void**" keeping "char**" ones
for backwards compatibility only.

Also deprecate GetSelectionClientData() that returned char* and add a new
GetSelectionData() returning void* instead.

Closes #13876.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/generic/choicdgg.h
interface/wx/choicdlg.h
src/generic/choicdgg.cpp
src/html/helpwnd.cpp

index c723c17e1d2b2b432522f13613b48f64ed9ab02f..efa010c1f41327b883095180c3d14dba09d32ad3 100644 (file)
@@ -344,6 +344,11 @@ Changes in behaviour which may result in compilation errors
 - wxComboBox::IsEmpty(), which was previously available in some ports (but not
   wxMSW), doesn't exist any more, use either IsListEmpty() or IsTextEmpty().
 
 - wxComboBox::IsEmpty(), which was previously available in some ports (but not
   wxMSW), doesn't exist any more, use either IsListEmpty() or IsTextEmpty().
 
+- wxSingleChoiceDialog ctors and Create() now have 2 overloaded versions: one
+  taking void** client data and the deprecated one taking char**. This can
+  result in compilation errors due to an ambiguity between them if you pass
+  NULL as client data. To fix this, cast NULL explicitly to "void**".
+
 
 Deprecated methods and their replacements
 -----------------------------------------
 
 Deprecated methods and their replacements
 -----------------------------------------
@@ -412,6 +417,11 @@ Deprecated methods and their replacements
 - Second parameter of wxSlider::SetTickFreq(int n, int pos) is deprecated,
   simply remove it from your code and use wxSlider::SetTickFreq(int n) as it
   was never used anyhow.
 - Second parameter of wxSlider::SetTickFreq(int n, int pos) is deprecated,
   simply remove it from your code and use wxSlider::SetTickFreq(int n) as it
   was never used anyhow.
+- wxSingleChoiceDialog ctor and Create() take "void**" client data pointer
+  instead of "char**". As the client data is typically untyped, you should
+  simply remove the casts to "char**" which you probably have in your code if
+  you use these functions.
+
 
 Major new features in this release
 ----------------------------------
 
 Major new features in this release
 ----------------------------------
index 306c3df287f8261a4eecda3b891dc2257f214efa..230757b01f432465531120bd63eafc9dbc803b6b 100644 (file)
@@ -106,39 +106,112 @@ public:
                          const wxString& caption,
                          int n,
                          const wxString *choices,
                          const wxString& caption,
                          int n,
                          const wxString *choices,
-                         char **clientData = (char **)NULL,
+                         void **clientData = NULL,
                          long style = wxCHOICEDLG_STYLE,
                          long style = wxCHOICEDLG_STYLE,
-                         const wxPoint& pos = wxDefaultPosition);
+                         const wxPoint& pos = wxDefaultPosition)
+    {
+        Create(parent, message, caption, n, choices, clientData, style, pos);
+    }
+
     wxSingleChoiceDialog(wxWindow *parent,
                          const wxString& message,
                          const wxString& caption,
                          const wxArrayString& choices,
     wxSingleChoiceDialog(wxWindow *parent,
                          const wxString& message,
                          const wxString& caption,
                          const wxArrayString& choices,
-                         char **clientData = (char **)NULL,
+                         void **clientData = NULL,
                          long style = wxCHOICEDLG_STYLE,
                          long style = wxCHOICEDLG_STYLE,
-                         const wxPoint& pos = wxDefaultPosition);
+                         const wxPoint& pos = wxDefaultPosition)
+    {
+        Create(parent, message, caption, choices, clientData, style, pos);
+    }
 
     bool Create(wxWindow *parent,
                 const wxString& message,
                 const wxString& caption,
                 int n,
                 const wxString *choices,
 
     bool Create(wxWindow *parent,
                 const wxString& message,
                 const wxString& caption,
                 int n,
                 const wxString *choices,
-                char **clientData = (char **)NULL,
+                void **clientData = NULL,
                 long style = wxCHOICEDLG_STYLE,
                 const wxPoint& pos = wxDefaultPosition);
     bool Create(wxWindow *parent,
                 const wxString& message,
                 const wxString& caption,
                 const wxArrayString& choices,
                 long style = wxCHOICEDLG_STYLE,
                 const wxPoint& pos = wxDefaultPosition);
     bool Create(wxWindow *parent,
                 const wxString& message,
                 const wxString& caption,
                 const wxArrayString& choices,
-                char **clientData = (char **)NULL,
+                void **clientData = NULL,
                 long style = wxCHOICEDLG_STYLE,
                 const wxPoint& pos = wxDefaultPosition);
 
     void SetSelection(int sel);
     int GetSelection() const { return m_selection; }
     wxString GetStringSelection() const { return m_stringSelection; }
                 long style = wxCHOICEDLG_STYLE,
                 const wxPoint& pos = wxDefaultPosition);
 
     void SetSelection(int sel);
     int GetSelection() const { return m_selection; }
     wxString GetStringSelection() const { return m_stringSelection; }
+    void* GetSelectionData() { return m_clientData; }
 
 
-    // obsolete function (NB: no need to make it return wxChar, it's untyped)
-    char *GetSelectionClientData() const { return (char *)m_clientData; }
+#if WXWIN_COMPATIBILITY_2_8
+    // Deprecated overloads taking "char**" client data.
+    wxDEPRECATED_CONSTRUCTOR
+    (
+        wxSingleChoiceDialog(wxWindow *parent,
+                             const wxString& message,
+                             const wxString& caption,
+                             int n,
+                             const wxString *choices,
+                             char **clientData,
+                             long style = wxCHOICEDLG_STYLE,
+                             const wxPoint& pos = wxDefaultPosition)
+    )
+    {
+        Create(parent, message, caption, n, choices,
+               (void**)clientData, style, pos);
+    }
+
+    wxDEPRECATED_CONSTRUCTOR
+    (
+        wxSingleChoiceDialog(wxWindow *parent,
+                             const wxString& message,
+                             const wxString& caption,
+                             const wxArrayString& choices,
+                             char **clientData,
+                             long style = wxCHOICEDLG_STYLE,
+                             const wxPoint& pos = wxDefaultPosition)
+    )
+    {
+        Create(parent, message, caption, choices,
+               (void**)clientData, style, pos);
+    }
+
+    wxDEPRECATED_INLINE
+    (
+        bool Create(wxWindow *parent,
+                    const wxString& message,
+                    const wxString& caption,
+                    int n,
+                    const wxString *choices,
+                    char **clientData,
+                    long style = wxCHOICEDLG_STYLE,
+                    const wxPoint& pos = wxDefaultPosition),
+        return Create(parent, message, caption, n, choices,
+                      (void**)clientData, style, pos);
+    )
+
+    wxDEPRECATED_INLINE
+    (
+        bool Create(wxWindow *parent,
+                    const wxString& message,
+                    const wxString& caption,
+                    const wxArrayString& choices,
+                    char **clientData,
+                    long style = wxCHOICEDLG_STYLE,
+                    const wxPoint& pos = wxDefaultPosition),
+        return Create(parent, message, caption, choices,
+                      (void**)clientData, style, pos);
+    )
+
+    // NB: no need to make it return wxChar, it's untyped
+    wxDEPRECATED_ACCESSOR
+    (
+        char* GetSelectionClientData(),
+        (char*)GetClientData()
+    )
+#endif // WXWIN_COMPATIBILITY_2_8
 
     // implementation from now on
     void OnOK(wxCommandEvent& event);
 
     // implementation from now on
     void OnOK(wxCommandEvent& event);
index c10074aad91a9ae1b11dbb448d50c19327d234b6..70ff5d444b84a08786f95f42cc1a564dc933db0c 100644 (file)
@@ -170,7 +170,7 @@ public:
             An array of strings, or a string list, containing the choices.
         @param clientData
             An array of client data to be associated with the items. See
             An array of strings, or a string list, containing the choices.
         @param clientData
             An array of client data to be associated with the items. See
-            GetSelectionClientData().
+            GetSelectionData().
         @param style
             A dialog style (bitlist) containing flags chosen from standard
             dialog styles and the ones listed below. The default value is
         @param style
             A dialog style (bitlist) containing flags chosen from standard
             dialog styles and the ones listed below. The default value is
@@ -222,7 +222,7 @@ public:
             An array of strings, or a string list, containing the choices.
         @param clientData
             An array of client data to be associated with the items. See
             An array of strings, or a string list, containing the choices.
         @param clientData
             An array of client data to be associated with the items. See
-            GetSelectionClientData().
+            GetSelectionData().
         @param style
             A dialog style (bitlist) containing flags chosen from standard
             dialog styles and the ones listed below. The default value is
         @param style
             A dialog style (bitlist) containing flags chosen from standard
             dialog styles and the ones listed below. The default value is
@@ -270,8 +270,10 @@ public:
 
     /**
         Returns the client data associated with the selection.
 
     /**
         Returns the client data associated with the selection.
+
+        @since 2.9.4
     */
     */
-    char* GetSelectionClientData() const;
+    void* GetSelectionData() const;
 
     /**
         Returns the selected string.
 
     /**
         Returns the selected string.
index 79f7019d0d5a8fe5fb2ab223aba82cc52993d0da..612b285ba4659b2bbee88875ee5c0b7db82838b7 100644 (file)
@@ -222,13 +222,13 @@ void *wxGetSingleChoiceData( const wxString& message,
                              int initialSelection)
 {
     wxSingleChoiceDialog dialog(parent, message, caption, n, choices,
                              int initialSelection)
 {
     wxSingleChoiceDialog dialog(parent, message, caption, n, choices,
-                                (char **)client_data);
+                                client_data);
 
     dialog.SetSelection(initialSelection);
 
     void *data;
     if ( dialog.ShowModal() == wxID_OK )
 
     dialog.SetSelection(initialSelection);
 
     void *data;
     if ( dialog.ShowModal() == wxID_OK )
-        data = dialog.GetSelectionClientData();
+        data = dialog.GetSelectionData();
     else
         data = NULL;
 
     else
         data = NULL;
 
@@ -467,35 +467,12 @@ END_EVENT_TABLE()
 
 IMPLEMENT_DYNAMIC_CLASS(wxSingleChoiceDialog, wxDialog)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxSingleChoiceDialog, wxDialog)
 
-wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
-                                           const wxString& message,
-                                           const wxString& caption,
-                                           int n,
-                                           const wxString *choices,
-                                           char **clientData,
-                                           long style,
-                                           const wxPoint& WXUNUSED(pos))
-{
-    Create(parent, message, caption, n, choices, clientData, style);
-}
-
-wxSingleChoiceDialog::wxSingleChoiceDialog(wxWindow *parent,
-                                           const wxString& message,
-                                           const wxString& caption,
-                                           const wxArrayString& choices,
-                                           char **clientData,
-                                           long style,
-                                           const wxPoint& WXUNUSED(pos))
-{
-    Create(parent, message, caption, choices, clientData, style);
-}
-
 bool wxSingleChoiceDialog::Create( wxWindow *parent,
                                    const wxString& message,
                                    const wxString& caption,
                                    int n,
                                    const wxString *choices,
 bool wxSingleChoiceDialog::Create( wxWindow *parent,
                                    const wxString& message,
                                    const wxString& caption,
                                    int n,
                                    const wxString *choices,
-                                   char **clientData,
+                                   void **clientData,
                                    long style,
                                    const wxPoint& pos )
 {
                                    long style,
                                    const wxPoint& pos )
 {
@@ -519,7 +496,7 @@ bool wxSingleChoiceDialog::Create( wxWindow *parent,
                                    const wxString& message,
                                    const wxString& caption,
                                    const wxArrayString& choices,
                                    const wxString& message,
                                    const wxString& caption,
                                    const wxArrayString& choices,
-                                   char **clientData,
+                                   void **clientData,
                                    long style,
                                    const wxPoint& pos )
 {
                                    long style,
                                    const wxPoint& pos )
 {
index dcd41a55bd10b52e43d3a682477d6924b849e68d..3518cb3b2dfd3e9a3b5163e13baf3d63d8cce77b 100644 (file)
@@ -813,7 +813,9 @@ void wxHtmlHelpWindow::DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it)
         wxSingleChoiceDialog dlg(this,
                                  _("Please choose the page to display:"),
                                  _("Help Topics"),
         wxSingleChoiceDialog dlg(this,
                                  _("Please choose the page to display:"),
                                  _("Help Topics"),
-                                 arr, NULL, wxCHOICEDLG_STYLE & ~wxCENTRE);
+                                 arr,
+                                 (void**)NULL, // No client data
+                                 wxCHOICEDLG_STYLE & ~wxCENTRE);
         if (dlg.ShowModal() == wxID_OK)
         {
             m_HtmlWin->LoadPage(it->items[dlg.GetSelection()]->GetFullPath());
         if (dlg.ShowModal() == wxID_OK)
         {
             m_HtmlWin->LoadPage(it->items[dlg.GetSelection()]->GetFullPath());