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:
Włodzimierz Skiba 2005-02-01 09:58:58 +00:00
parent 7712a6a5ff
commit 9a727a3bb8
10 changed files with 50 additions and 65 deletions

View File

@ -1546,13 +1546,19 @@
#endif
#if wxUSE_RADIOBOX
# if !wxUSE_RADIOBTN || !wxUSE_STATBOX
# if !wxUSE_RADIOBTN
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_RADIOBOX requires wxUSE_RADIOBTN and wxUSE_STATBOX"
# error "wxUSE_RADIOBOX requires wxUSE_RADIOBTN"
# else
# undef wxUSE_RADIOBTN
# undef wxUSE_STATBOX
# 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
# endif
# endif

View File

@ -1419,11 +1419,16 @@ enum wxBorder
#define wxRA_HORIZONTAL wxHORIZONTAL
#define wxRA_VERTICAL wxVERTICAL
/* Use alternative object for single control */
#define wxRA_USE_SUBSTITUTE 0x0010
/*
* wxRadioButton style flag
*/
#define wxRB_GROUP 0x0004
#define wxRB_SINGLE 0x0008
#define wxRB_USE_SUBSTITUTE 0x0010
/*
* wxSlider flags

View File

@ -68,6 +68,7 @@ public:
long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
@ -104,17 +105,8 @@ public:
// 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 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();
// 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
virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
// subclass one radio button
void SubclassRadioButton(WXHWND hWndBtn);
// get the max size of radio buttons
wxSize GetMaxButtonSize() const;
// get the total size occupied by the radio box buttons
wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
WXHWND * m_radioButtons;
int m_majorDim;
int * m_radioWidth; // for bitmaps
int * m_radioHeight;

View File

@ -520,7 +520,7 @@
#define wxUSE_GAUGE 0 // wxGauge
#define wxUSE_LISTBOX 0 // wxListBox
#define wxUSE_LISTCTRL 0 // wxListCtrl
#define wxUSE_RADIOBOX 0 // wxRadioBox
#define wxUSE_RADIOBOX 1 // wxRadioBox
#define wxUSE_RADIOBTN 1 // wxRadioButton
#define wxUSE_SCROLLBAR 0 // wxScrollBar
#define wxUSE_SLIDER 1 // wxSlider

View File

@ -70,6 +70,9 @@ public:
// implementation
void Command(wxCommandEvent& event);
// send a notification event, return true if processed
bool SendUpdatedEvent();
protected:
virtual wxSize DoGetBestSize() const;

View File

@ -72,6 +72,7 @@ void wxControl::Init()
wxControl::~wxControl()
{
SetLabel(wxEmptyString);
m_isBeingDeleted = true;
}
@ -107,13 +108,11 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
if(form==NULL)
return false;
m_label = label;
ControlType *control = CtlNewControl(
(void **)&form,
GetId(),
style,
m_label.c_str(),
wxEmptyString,
( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x,
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y,
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x,
@ -128,6 +127,7 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
m_palmControl = true;
SetLabel(label);
Show();
return true;
}
@ -350,6 +350,13 @@ void wxControl::SetFieldLabel(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)

View File

@ -38,8 +38,6 @@
#include "wx/log.h"
#endif
#include "wx/palmos/private.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#endif // wxUSE_TOOLTIPS
@ -102,19 +100,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
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
// ===========================================================================
@ -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()
{
}
@ -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::SubclassRadioButton(WXHWND hWndBtn)
{
}
void wxRadioBox::SendNotificationEvent()
{
}
@ -289,17 +257,4 @@ bool wxRadioBox::SetFont(const wxFont& font)
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

View File

@ -114,6 +114,10 @@ bool wxRadioButton::Create(wxWindow *parent,
const wxValidator& validator,
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))
return false;

View File

@ -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)
{
}

View File

@ -47,6 +47,7 @@
#include "wx/checkbox.h"
#include "wx/radiobut.h"
#include "wx/tglbtn.h"
#include "wx/slider.h"
// ----------------------------------------------------------------------------
// globals
@ -268,6 +269,10 @@ bool wxTopLevelWindowPalm::HandleControlSelect(EventType* event)
if(radio)
return radio->SendClickEvent();
wxSlider* slider = wxDynamicCast(win,wxSlider);
if(slider)
return slider->SendUpdatedEvent();
return false;
}