Fix implementation of wxScrolled<wxControl>

wxControl::Create() has a different signature than wxWindow::Create()
(its 6-th parameter is of const wxValidator& type instead of
const wxString&) so it cannot be invoked from the the general template of
wxScrolled<T>::Create() method. We need to move a call to T::Create()
function to a dedicated template function wxCreateScrolled() responsible
for actual creation of the scrolled window and overload it for custom
classes if necessary.
This has to be done for wxControl and from this overloaded function
wxControl::Create() can be called with rearranged parameters.
This commit is contained in:
Artur Wieczorek
2019-05-30 19:34:09 +02:00
parent 8caa379490
commit b309868930
2 changed files with 60 additions and 3 deletions

View File

@@ -11,6 +11,7 @@
#ifndef _WX_SCROLWIN_H_BASE_
#define _WX_SCROLWIN_H_BASE_
#include "wx/control.h"
#include "wx/panel.h"
class WXDLLIMPEXP_FWD_CORE wxScrollHelperEvtHandler;
@@ -378,6 +379,28 @@ struct WXDLLIMPEXP_CORE wxScrolledT_Helper
// Scrollable window base on window type T. This used to be wxScrolledWindow,
// but wxScrolledWindow includes wxControlContainer functionality and that's
// not always desirable.
template<class T>
bool wxCreateScrolled(T* self,
wxWindow *parent, wxWindowID winid,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
return self->Create(parent, winid, pos, size, style, name);
}
#if wxUSE_CONTROLS
// For wxControl we have to provide overloaded wxCreateScrolled()
// because wxControl::Create() has 7 parameters and therefore base
// template expecting 6-parameter T::Create() cannot be used.
inline bool wxCreateScrolled(wxControl* self,
wxWindow *parent, wxWindowID winid,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
return self->Create(parent, winid, pos, size, style, wxDefaultValidator, name);
}
#endif // wxUSE_CONTROLS
template<class T>
class wxScrolled : public T,
public wxScrollHelper,
@@ -415,7 +438,7 @@ public:
if ( !(style & (wxHSCROLL | wxVSCROLL)) )
style |= wxHSCROLL | wxVSCROLL;
return T::Create(parent, winid, pos, size, style, name);
return wxCreateScrolled((T*)this, parent, winid, pos, size, style, name);
}
#ifdef __WXMSW__