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

@@ -33,6 +33,9 @@ enum wxScrollbarVisibility
so doesn't handle children specially. This is suitable e.g. for
implementing scrollable controls such as tree or list controls.
@note
See wxScrolled::Create() if you want to use wxScrolled with a custom class.
Starting from version 2.4 of wxWidgets, there are several ways to use a
::wxScrolledWindow (and now wxScrolled). In particular, there are
three ways to set the size of the scrolling area:
@@ -231,8 +234,13 @@ public:
/**
Creates the window for two-step construction. Derived classes
should call or replace this function. See wxScrolled::wxScrolled()
for details.
should call or replace this function. If it is not replaced,
bear in mind that it calls T::Create() through the global function
wxCreateScrolled() so if T::Create() has a different signature
than wxScrolled::Create() you should implement overloaded
wxCreateScrolled() which would call T::Create() in the correct manner.
@see wxScrolled::wxScrolled() and wxCreateScrolled() for details.
*/
bool Create(wxWindow* parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
@@ -590,6 +598,32 @@ protected:
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size);
};
/**
Helper function which is called from wxScrolled::Create() to actually create
a scrolled window. By default it just passes the call to the base class Create():
@code
self->Create(parent, winid, pos, size, style, name);
@endcode
You should provide overloaded implementation of this function for the custom
base class if this class is created in a different manner, like it is e.g.
done for wxControl:
@code
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);
}
@endcode
@since 3.1.3
*/
bool wxCreateScrolled(T* self,
wxWindow *parent, wxWindowID winid,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name);
/**
Scrolled window derived from wxPanel.