Add possibility to create "Close" bitmap button from XRC

This requires refactoring NewCloseButton() in order to extract
CreateCloseButton() from it, as XRC relies on being able to use two-step
creation which was previously impossible for this kind of buttons.

CreateCloseButton() is rather unusual, as it has to be declared in the
derived, platform-specific class, in order to be able to call its
Create(), but is defined only once in common, platform-independent,
code. However the only alternative seems to be to have a static
function, e.g. InitCloseButton(), which wouldn't be very pretty neither.

Closes https://github.com/wxWidgets/wxWidgets/pull/2118
This commit is contained in:
Vadim Zeitlin
2020-11-16 19:33:57 +01:00
parent b4338a30e1
commit 712c2d4004
13 changed files with 112 additions and 26 deletions

View File

@@ -99,6 +99,24 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
/**
Creation function for two-step creation of "Close" button.
It is usually not necessary to use this function directly as
NewCloseButton() is more convenient, but, if required, it can be called
on a default-constructed wxBitmapButton object to achieve the same
effect.
@param parent The button parent window, must be non-@NULL.
@param winid The identifier for the new button.
@param name The name for the new button.
@since 3.1.5
*/
bool CreateCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
/**
Helper function creating a standard-looking "Close" button.
@@ -109,10 +127,13 @@ public:
@param parent The button parent window, must be non-@NULL.
@param winid The identifier for the new button.
@param name The name for the new button (available since wxWidgets 3.1.5)
@return The new button.
@since 2.9.5
*/
static wxBitmapButton* NewCloseButton(wxWindow* parent, wxWindowID winid);
static wxBitmapButton* NewCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
};