Further cleaning of the wxPalmOS radiobox code. Sending update event from slider. New styles for wxRadioBox and wxRadioButton for using alternative appearance of the control.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31690 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7712a6a5ff
commit
9a727a3bb8
@ -1546,13 +1546,19 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_RADIOBOX
|
#if wxUSE_RADIOBOX
|
||||||
# if !wxUSE_RADIOBTN || !wxUSE_STATBOX
|
# if !wxUSE_RADIOBTN
|
||||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||||
# error "wxUSE_RADIOBOX requires wxUSE_RADIOBTN and wxUSE_STATBOX"
|
# error "wxUSE_RADIOBOX requires wxUSE_RADIOBTN"
|
||||||
# else
|
# else
|
||||||
# undef wxUSE_RADIOBTN
|
# undef wxUSE_RADIOBTN
|
||||||
# undef wxUSE_STATBOX
|
|
||||||
# define wxUSE_RADIOBTN 1
|
# define wxUSE_RADIOBTN 1
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if !wxUSE_STATBOX && !defined(__WXPALMOS__)
|
||||||
|
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||||
|
# error "wxUSE_RADIOBOX requires wxUSE_STATBOX"
|
||||||
|
# else
|
||||||
|
# undef wxUSE_STATBOX
|
||||||
# define wxUSE_STATBOX 1
|
# define wxUSE_STATBOX 1
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
@ -1419,11 +1419,16 @@ enum wxBorder
|
|||||||
#define wxRA_HORIZONTAL wxHORIZONTAL
|
#define wxRA_HORIZONTAL wxHORIZONTAL
|
||||||
#define wxRA_VERTICAL wxVERTICAL
|
#define wxRA_VERTICAL wxVERTICAL
|
||||||
|
|
||||||
|
/* Use alternative object for single control */
|
||||||
|
|
||||||
|
#define wxRA_USE_SUBSTITUTE 0x0010
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxRadioButton style flag
|
* wxRadioButton style flag
|
||||||
*/
|
*/
|
||||||
#define wxRB_GROUP 0x0004
|
#define wxRB_GROUP 0x0004
|
||||||
#define wxRB_SINGLE 0x0008
|
#define wxRB_SINGLE 0x0008
|
||||||
|
#define wxRB_USE_SUBSTITUTE 0x0010
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxSlider flags
|
* wxSlider flags
|
||||||
|
@ -68,6 +68,7 @@ public:
|
|||||||
long style = wxRA_HORIZONTAL,
|
long style = wxRA_HORIZONTAL,
|
||||||
const wxValidator& val = wxDefaultValidator,
|
const wxValidator& val = wxDefaultValidator,
|
||||||
const wxString& name = wxRadioBoxNameStr);
|
const wxString& name = wxRadioBoxNameStr);
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& title,
|
const wxString& title,
|
||||||
@ -104,17 +105,8 @@ public:
|
|||||||
// implementation only from now on
|
// implementation only from now on
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
// FIXME: are they used? missing "Do" prefix?
|
|
||||||
void GetSize(int *x, int *y) const;
|
|
||||||
void GetPosition(int *x, int *y) const;
|
|
||||||
|
|
||||||
virtual bool SetFont(const wxFont& font);
|
virtual bool SetFont(const wxFont& font);
|
||||||
|
|
||||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
|
||||||
WXUINT message,
|
|
||||||
WXWPARAM wParam, WXLPARAM lParam);
|
|
||||||
WXHWND *GetRadioButtons() const { return m_radioButtons; }
|
|
||||||
bool ContainsHWND(WXHWND hWnd) const;
|
|
||||||
void SendNotificationEvent();
|
void SendNotificationEvent();
|
||||||
|
|
||||||
// get the number of buttons per column/row
|
// get the number of buttons per column/row
|
||||||
@ -128,16 +120,12 @@ protected:
|
|||||||
// we can't compute our best size before the items are added to the control
|
// we can't compute our best size before the items are added to the control
|
||||||
virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
|
virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
|
||||||
|
|
||||||
// subclass one radio button
|
|
||||||
void SubclassRadioButton(WXHWND hWndBtn);
|
|
||||||
|
|
||||||
// get the max size of radio buttons
|
// get the max size of radio buttons
|
||||||
wxSize GetMaxButtonSize() const;
|
wxSize GetMaxButtonSize() const;
|
||||||
|
|
||||||
// get the total size occupied by the radio box buttons
|
// get the total size occupied by the radio box buttons
|
||||||
wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
|
wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
|
||||||
|
|
||||||
WXHWND * m_radioButtons;
|
|
||||||
int m_majorDim;
|
int m_majorDim;
|
||||||
int * m_radioWidth; // for bitmaps
|
int * m_radioWidth; // for bitmaps
|
||||||
int * m_radioHeight;
|
int * m_radioHeight;
|
||||||
|
@ -520,7 +520,7 @@
|
|||||||
#define wxUSE_GAUGE 0 // wxGauge
|
#define wxUSE_GAUGE 0 // wxGauge
|
||||||
#define wxUSE_LISTBOX 0 // wxListBox
|
#define wxUSE_LISTBOX 0 // wxListBox
|
||||||
#define wxUSE_LISTCTRL 0 // wxListCtrl
|
#define wxUSE_LISTCTRL 0 // wxListCtrl
|
||||||
#define wxUSE_RADIOBOX 0 // wxRadioBox
|
#define wxUSE_RADIOBOX 1 // wxRadioBox
|
||||||
#define wxUSE_RADIOBTN 1 // wxRadioButton
|
#define wxUSE_RADIOBTN 1 // wxRadioButton
|
||||||
#define wxUSE_SCROLLBAR 0 // wxScrollBar
|
#define wxUSE_SCROLLBAR 0 // wxScrollBar
|
||||||
#define wxUSE_SLIDER 1 // wxSlider
|
#define wxUSE_SLIDER 1 // wxSlider
|
||||||
|
@ -70,6 +70,9 @@ public:
|
|||||||
// implementation
|
// implementation
|
||||||
void Command(wxCommandEvent& event);
|
void Command(wxCommandEvent& event);
|
||||||
|
|
||||||
|
// send a notification event, return true if processed
|
||||||
|
bool SendUpdatedEvent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ void wxControl::Init()
|
|||||||
|
|
||||||
wxControl::~wxControl()
|
wxControl::~wxControl()
|
||||||
{
|
{
|
||||||
|
SetLabel(wxEmptyString);
|
||||||
m_isBeingDeleted = true;
|
m_isBeingDeleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,13 +108,11 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
|
|||||||
if(form==NULL)
|
if(form==NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_label = label;
|
|
||||||
|
|
||||||
ControlType *control = CtlNewControl(
|
ControlType *control = CtlNewControl(
|
||||||
(void **)&form,
|
(void **)&form,
|
||||||
GetId(),
|
GetId(),
|
||||||
style,
|
style,
|
||||||
m_label.c_str(),
|
wxEmptyString,
|
||||||
( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x,
|
( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x,
|
||||||
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y,
|
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y,
|
||||||
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x,
|
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x,
|
||||||
@ -128,6 +127,7 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
|
|||||||
|
|
||||||
m_palmControl = true;
|
m_palmControl = true;
|
||||||
|
|
||||||
|
SetLabel(label);
|
||||||
Show();
|
Show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -350,6 +350,13 @@ void wxControl::SetFieldLabel(const wxString& label)
|
|||||||
|
|
||||||
void wxControl::SetControlLabel(const wxString& label)
|
void wxControl::SetControlLabel(const wxString& label)
|
||||||
{
|
{
|
||||||
|
ControlType* control = (ControlType*)GetObjectPtr();
|
||||||
|
if(control==NULL)
|
||||||
|
return;
|
||||||
|
CtlSetLabel(control,wxEmptyString);
|
||||||
|
m_label = label;
|
||||||
|
if(!m_label.empty())
|
||||||
|
CtlSetLabel(control,m_label.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::SetLabel(const wxString& label)
|
void wxControl::SetLabel(const wxString& label)
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/palmos/private.h"
|
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
#include "wx/tooltip.h"
|
#include "wx/tooltip.h"
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
@ -102,19 +100,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
|||||||
item
|
item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define RADIOBTN_PARENT_IS_RADIOBOX 0
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// private functions
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// global vars
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// the pointer to standard radio button wnd proc
|
|
||||||
static WXFARPROC s_wndprocRadioBtn = (WXFARPROC)NULL;
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@ -234,14 +219,6 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::GetSize(int *width, int *height) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRadioBox::GetPosition(int *x, int *y) const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRadioBox::SetFocus()
|
void wxRadioBox::SetFocus()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -267,19 +244,10 @@ void wxRadioBox::Show(int item, bool show)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRadioBox::Command(wxCommandEvent & event)
|
void wxRadioBox::Command(wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRadioBox::SendNotificationEvent()
|
void wxRadioBox::SendNotificationEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -289,17 +257,4 @@ bool wxRadioBox::SetFont(const wxFont& font)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// our window proc
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
|
|
||||||
WXUINT WXUNUSED(message),
|
|
||||||
WXWPARAM WXUNUSED(wParam),
|
|
||||||
WXLPARAM WXUNUSED(lParam)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return (WXHBRUSH)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_RADIOBOX
|
#endif // wxUSE_RADIOBOX
|
||||||
|
@ -114,6 +114,10 @@ bool wxRadioButton::Create(wxWindow *parent,
|
|||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
|
// replace native push button with native checkbox
|
||||||
|
if ( style & wxRB_USE_SUBSTITUTE )
|
||||||
|
m_radioStyle = checkboxCtl;
|
||||||
|
|
||||||
if(!wxControl::Create(parent, id, pos, size, style, validator, name))
|
if(!wxControl::Create(parent, id, pos, size, style, validator, name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -251,6 +251,18 @@ void wxSlider::SetTick(int tickPos)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// helpers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxSlider::SendUpdatedEvent()
|
||||||
|
{
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_SLIDER_UPDATED, GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
event.SetInt(GetValue());
|
||||||
|
return ProcessCommand(event);
|
||||||
|
}
|
||||||
|
|
||||||
void wxSlider::Command (wxCommandEvent & event)
|
void wxSlider::Command (wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "wx/checkbox.h"
|
#include "wx/checkbox.h"
|
||||||
#include "wx/radiobut.h"
|
#include "wx/radiobut.h"
|
||||||
#include "wx/tglbtn.h"
|
#include "wx/tglbtn.h"
|
||||||
|
#include "wx/slider.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// globals
|
// globals
|
||||||
@ -268,6 +269,10 @@ bool wxTopLevelWindowPalm::HandleControlSelect(EventType* event)
|
|||||||
if(radio)
|
if(radio)
|
||||||
return radio->SendClickEvent();
|
return radio->SendClickEvent();
|
||||||
|
|
||||||
|
wxSlider* slider = wxDynamicCast(win,wxSlider);
|
||||||
|
if(slider)
|
||||||
|
return slider->SendUpdatedEvent();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user