From 3d72c009be9c062a4e828a1f50ed8240bab295fa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Sep 2020 16:08:16 +0200 Subject: [PATCH] Add wxRadioButtonBase::{Set,Get}Value() Now that we do have wxRadioButtonBase class, declare wxRadioButton API methods as pure virtual in it, to force the derived classes to implement them. Also remove the outdated comment saying that there is no base class for wxRadioButtons in different ports, this is not true any longer. --- include/wx/gtk/radiobut.h | 4 ++-- include/wx/msw/radiobut.h | 4 ++-- include/wx/osx/radiobut.h | 4 ++-- include/wx/qt/radiobut.h | 4 ++-- include/wx/radiobut.h | 23 ++++++++--------------- include/wx/univ/radiobut.h | 4 ++++ 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/include/wx/gtk/radiobut.h b/include/wx/gtk/radiobut.h index b85f8ea723..785530a98e 100644 --- a/include/wx/gtk/radiobut.h +++ b/include/wx/gtk/radiobut.h @@ -39,8 +39,8 @@ public: const wxString& name = wxASCII_STR(wxRadioButtonNameStr) ); virtual void SetLabel(const wxString& label) wxOVERRIDE; - virtual void SetValue(bool val); - virtual bool GetValue() const; + virtual void SetValue(bool val) wxOVERRIDE; + virtual bool GetValue() const wxOVERRIDE; static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); diff --git a/include/wx/msw/radiobut.h b/include/wx/msw/radiobut.h index fc6d2a8949..41103ed3b9 100644 --- a/include/wx/msw/radiobut.h +++ b/include/wx/msw/radiobut.h @@ -43,8 +43,8 @@ public: const wxString& name = wxASCII_STR(wxRadioButtonNameStr)); // implement the radio button interface - virtual void SetValue(bool value); - virtual bool GetValue() const; + virtual void SetValue(bool value) wxOVERRIDE; + virtual bool GetValue() const wxOVERRIDE; // implementation only from now on virtual bool MSWCommand(WXUINT param, WXWORD id) wxOVERRIDE; diff --git a/include/wx/osx/radiobut.h b/include/wx/osx/radiobut.h index cf74f14d89..b6bcb8ada3 100644 --- a/include/wx/osx/radiobut.h +++ b/include/wx/osx/radiobut.h @@ -35,8 +35,8 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxASCII_STR(wxRadioButtonNameStr)); - virtual void SetValue(bool val); - virtual bool GetValue() const ; + virtual void SetValue(bool val) wxOVERRIDE; + virtual bool GetValue() const wxOVERRIDE; // implementation diff --git a/include/wx/qt/radiobut.h b/include/wx/qt/radiobut.h index 1502173105..da00d190cf 100644 --- a/include/wx/qt/radiobut.h +++ b/include/wx/qt/radiobut.h @@ -32,8 +32,8 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxASCII_STR(wxRadioButtonNameStr) ); - virtual void SetValue(bool value); - virtual bool GetValue() const; + virtual void SetValue(bool value) wxOVERRIDE; + virtual bool GetValue() const wxOVERRIDE; virtual QWidget *GetHandle() const wxOVERRIDE; diff --git a/include/wx/radiobut.h b/include/wx/radiobut.h index d999800efb..a4d78656bc 100644 --- a/include/wx/radiobut.h +++ b/include/wx/radiobut.h @@ -15,21 +15,6 @@ #if wxUSE_RADIOBTN -/* - There is no wxRadioButtonBase class as wxRadioButton interface is the same - as wxCheckBox(Base), but under some platforms wxRadioButton really - derives from wxCheckBox and on the others it doesn't. - - The pseudo-declaration of wxRadioButtonBase would look like this: - - class wxRadioButtonBase : public ... - { - public: - virtual void SetValue(bool value); - virtual bool GetValue() const; - }; - */ - #include "wx/control.h" class WXDLLIMPEXP_FWD_CORE wxRadioButton; @@ -42,6 +27,8 @@ namespace wxPrivate WXDLLIMPEXP_CORE wxRadioButton* wxGetLastButtonInGroup(const wxRadioButton *btn); } // namespace wxPrivate +// Unlike most of the other wxXXXBase classes, this one needs to be a template +// as wxRadioButton derives from different classes in different ports. template class wxRadioButtonBase : public W { @@ -50,6 +37,12 @@ public: wxRadioButtonBase() { } + // Methods to be implemented by the derived classes: + virtual void SetValue(bool value) = 0; + virtual bool GetValue() const = 0; + + + // Methods implemented by this class itself. wxRadioButton* GetFirstInGroup() const { return wxPrivate::wxGetFirstButtonInGroup(static_cast(this)); diff --git a/include/wx/univ/radiobut.h b/include/wx/univ/radiobut.h index 0b6580a2ab..ab81a71c5a 100644 --- a/include/wx/univ/radiobut.h +++ b/include/wx/univ/radiobut.h @@ -46,6 +46,10 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxASCII_STR(wxRadioButtonNameStr)); + // (re)implement pure virtuals from wxRadioButtonBase + virtual void SetValue(bool value) wxOVERRIDE { return wxCheckBox::SetValue(value); } + virtual bool GetValue() const wxOVERRIDE { return wxCheckBox::GetValue(); } + // override some base class methods virtual void ChangeValue(bool value) wxOVERRIDE;