Take void** client data in wxSingleChoiceDialog ctor and not char**.

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
This commit is contained in:
Vadim Zeitlin
2012-02-05 14:18:33 +00:00
parent 0c6dff0370
commit fc12b1f12a
5 changed files with 103 additions and 39 deletions

View 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 - wxComboBox::IsEmpty(), which was previously available in some ports (but not
wxMSW), doesn't exist any more, use either IsListEmpty() or IsTextEmpty(). 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, - 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 simply remove it from your code and use wxSlider::SetTickFreq(int n) as it
was never used anyhow. 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
---------------------------------- ----------------------------------

View File

@@ -106,39 +106,112 @@ public:
const wxString& caption, const wxString& caption,
int n, int n,
const wxString *choices, 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, wxSingleChoiceDialog(wxWindow *parent,
const wxString& message, const wxString& message,
const wxString& caption, const wxString& caption,
const wxArrayString& choices, 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, bool Create(wxWindow *parent,
const wxString& message, const wxString& message,
const wxString& caption, const wxString& caption,
int n, int n,
const wxString *choices, 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);
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
const wxString& message, const wxString& message,
const wxString& caption, const wxString& caption,
const wxArrayString& choices, 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);
void SetSelection(int sel); void SetSelection(int sel);
int GetSelection() const { return m_selection; } int GetSelection() const { return m_selection; }
wxString GetStringSelection() const { return m_stringSelection; } wxString GetStringSelection() const { return m_stringSelection; }
void* GetSelectionData() { return m_clientData; }
// obsolete function (NB: no need to make it return wxChar, it's untyped) #if WXWIN_COMPATIBILITY_2_8
char *GetSelectionClientData() const { return (char *)m_clientData; } // 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 // implementation from now on
void OnOK(wxCommandEvent& event); void OnOK(wxCommandEvent& event);

View File

@@ -170,7 +170,7 @@ public:
An array of strings, or a string list, containing the choices. An array of strings, or a string list, containing the choices.
@param clientData @param clientData
An array of client data to be associated with the items. See An array of client data to be associated with the items. See
GetSelectionClientData(). GetSelectionData().
@param style @param style
A dialog style (bitlist) containing flags chosen from standard A dialog style (bitlist) containing flags chosen from standard
dialog styles and the ones listed below. The default value is 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. An array of strings, or a string list, containing the choices.
@param clientData @param clientData
An array of client data to be associated with the items. See An array of client data to be associated with the items. See
GetSelectionClientData(). GetSelectionData().
@param style @param style
A dialog style (bitlist) containing flags chosen from standard A dialog style (bitlist) containing flags chosen from standard
dialog styles and the ones listed below. The default value is 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.

View File

@@ -222,13 +222,13 @@ void *wxGetSingleChoiceData( const wxString& message,
int initialSelection) int initialSelection)
{ {
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, wxSingleChoiceDialog dialog(parent, message, caption, n, choices,
(char **)client_data); client_data);
dialog.SetSelection(initialSelection); dialog.SetSelection(initialSelection);
void *data; void *data;
if ( dialog.ShowModal() == wxID_OK ) if ( dialog.ShowModal() == wxID_OK )
data = dialog.GetSelectionClientData(); data = dialog.GetSelectionData();
else else
data = NULL; 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, bool wxSingleChoiceDialog::Create( wxWindow *parent,
const wxString& message, const wxString& message,
const wxString& caption, const wxString& caption,
int n, int n,
const wxString *choices, const wxString *choices,
char **clientData, void **clientData,
long style, long style,
const wxPoint& pos ) const wxPoint& pos )
{ {
@@ -519,7 +496,7 @@ bool wxSingleChoiceDialog::Create( wxWindow *parent,
const wxString& message, const wxString& message,
const wxString& caption, const wxString& caption,
const wxArrayString& choices, const wxArrayString& choices,
char **clientData, void **clientData,
long style, long style,
const wxPoint& pos ) const wxPoint& pos )
{ {

View File

@@ -813,7 +813,9 @@ void wxHtmlHelpWindow::DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it)
wxSingleChoiceDialog dlg(this, wxSingleChoiceDialog dlg(this,
_("Please choose the page to display:"), _("Please choose the page to display:"),
_("Help Topics"), _("Help Topics"),
arr, NULL, wxCHOICEDLG_STYLE & ~wxCENTRE); arr,
(void**)NULL, // No client data
wxCHOICEDLG_STYLE & ~wxCENTRE);
if (dlg.ShowModal() == wxID_OK) if (dlg.ShowModal() == wxID_OK)
{ {
m_HtmlWin->LoadPage(it->items[dlg.GetSelection()]->GetFullPath()); m_HtmlWin->LoadPage(it->items[dlg.GetSelection()]->GetFullPath());