Merge branch 'expose-radiogroup'

Add public functions for navigating in radio button groups.

Also introduce wxRadioButtonBase defining wxRadioButton API for all
ports.

See https://github.com/wxWidgets/wxWidgets/pull/2052
This commit is contained in:
Vadim Zeitlin
2020-09-24 00:11:15 +02:00
13 changed files with 321 additions and 201 deletions

View File

@@ -13,7 +13,7 @@
// wxRadioButton
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRadioButton: public wxControl
class WXDLLIMPEXP_CORE wxRadioButton: public wxRadioButtonBase
{
public:
wxRadioButton() { }
@@ -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);

View File

@@ -13,7 +13,7 @@
// wxRadioButton
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRadioButton: public wxControl
class WXDLLIMPEXP_CORE wxRadioButton: public wxRadioButtonBase
{
public:
wxRadioButton() { }

View File

@@ -11,7 +11,7 @@
#ifndef _WX_RADIOBUT_H_
#define _WX_RADIOBUT_H_
class WXDLLIMPEXP_CORE wxRadioButton: public wxControl
class WXDLLIMPEXP_CORE wxRadioButton: public wxRadioButtonBase
{
wxDECLARE_DYNAMIC_CLASS(wxRadioButton);
public:

View File

@@ -13,7 +13,7 @@
#include "wx/msw/ownerdrawnbutton.h"
class WXDLLIMPEXP_CORE wxRadioButton : public wxMSWOwnerDrawnButton<wxControl>
class WXDLLIMPEXP_CORE wxRadioButton : public wxMSWOwnerDrawnButton<wxRadioButtonBase>
{
public:
// ctors and creation functions
@@ -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;

View File

@@ -11,7 +11,7 @@
#ifndef _WX_RADIOBUT_H_
#define _WX_RADIOBUT_H_
class WXDLLIMPEXP_CORE wxRadioButton: public wxControl
class WXDLLIMPEXP_CORE wxRadioButton: public wxRadioButtonBase
{
wxDECLARE_DYNAMIC_CLASS(wxRadioButton);
@@ -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

View File

@@ -10,7 +10,7 @@
class QRadioButton;
class WXDLLIMPEXP_CORE wxRadioButton : public wxControl
class WXDLLIMPEXP_CORE wxRadioButton : public wxRadioButtonBase
{
public:
wxRadioButton();
@@ -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;

View File

@@ -15,23 +15,42 @@
#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;
// TODO: In wxUniv, wxRadioButton must derive from wxCheckBox as it reuses
// much of its code. This should be fixed by refactoring wxCheckBox to allow
// this class to reuse its functionality without inheriting from it, but for
// now use this hack to allow the existing code to compile.
#ifdef __WXUNIVERSAL__
#include "wx/checkbox.h"
typedef wxCheckBox wxRadioButtonBaseBase;
#else
typedef wxControl wxRadioButtonBaseBase;
#endif
class WXDLLIMPEXP_CORE wxRadioButtonBase : public wxRadioButtonBaseBase
{
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;
wxRadioButton* GetLastInGroup() const;
wxRadioButton* GetPreviousInGroup() const;
wxRadioButton* GetNextInGroup() const;
private:
wxDECLARE_NO_COPY_CLASS(wxRadioButtonBase);
};
extern WXDLLIMPEXP_DATA_CORE(const char) wxRadioButtonNameStr[];
#if defined(__WXUNIVERSAL__)

View File

@@ -11,13 +11,11 @@
#ifndef _WX_UNIV_RADIOBUT_H_
#define _WX_UNIV_RADIOBUT_H_
#include "wx/checkbox.h"
// ----------------------------------------------------------------------------
// wxRadioButton
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRadioButton : public wxCheckBox
class WXDLLIMPEXP_CORE wxRadioButton : public wxRadioButtonBase
{
public:
// constructors
@@ -46,6 +44,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;