const wxString& label,
const wxPoint& pos,
const wxSize& size,
- int groupID = 0);
+ uint8_t groupID = 0);
inline bool IsPalmControl() const { return m_palmControl; }
bool PalmCreateField(const wxString& label,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 0,
- long style = wxRA_HORIZONTAL,
+ long style = wxRA_SPECIFY_COLS,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
{
const wxSize& size,
const wxArrayString& choices,
int majorDim = 0,
- long style = wxRA_HORIZONTAL,
+ long style = wxRA_SPECIFY_COLS,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
{
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 0,
- long style = wxRA_HORIZONTAL,
+ long style = wxRA_SPECIFY_COLS,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
const wxSize& size,
const wxArrayString& choices,
int majorDim = 0,
- long style = wxRA_HORIZONTAL,
+ long style = wxRA_SPECIFY_COLS,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
// implementation only from now on
virtual void Command(wxCommandEvent& event);
+ void SetGroup(uint8_t group);
// send a notification event, return true if processed
bool SendClickEvent();
// common part of all ctors
void Init();
+ uint8_t m_groupID;
+
// pushButtonCtl or checkboxCtl
ControlStyleType m_radioStyle;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxRadioButton)
private:
void Init();
- int m_oldPos;
- int m_lineSize;
+ int m_oldPos; // needed for tracing thumb position during scrolling
+ int m_oldValue; // needed for comparing thumb position before and after scrolling
+ int m_lineSize; // imitate line size
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider)
};
const wxString& label,
const wxPoint& pos,
const wxSize& size,
- int groupID)
+ uint8_t groupID)
{
FormType* form = GetParentForm();
if(form==NULL)
#include "wx/tooltip.h"
#endif // wxUSE_TOOLTIPS
+#include "wx/radiobut.h"
+
// TODO: wxCONSTRUCTOR
#if 0 // wxUSE_EXTENDED_RTTI
WX_DEFINE_FLAGS( wxRadioBoxStyle )
const wxValidator& val,
const wxString& name)
{
- return false;
+ // initialize members
+ m_majorDim = majorDim == 0 ? n : majorDim;
+
+ if(!wxControl::Create(parent, id, pos, size, style, val, name))
+ return false;
+
+ for(int i=0; i<n; i++)
+ {
+ wxRadioButton* rb = new wxRadioButton();
+ rb->SetGroup( id );
+ rb->Create(
+ this,
+ wxID_ANY,
+ choices[n],
+ pos,
+ size,
+ ( n == 0 ? wxRB_GROUP : 0 ) |
+ ( style & wxRA_USE_CHECKBOX ) ? wxRB_USE_CHECKBOX : 0
+ );
+ }
+
+ SetSize(size);
}
bool wxRadioBox::Create(wxWindow *parent,
const wxValidator& val,
const wxString& name)
{
- return false;
+ wxCArrayString chs(choices);
+
+ return Create( parent, id, title, pos, size, chs.GetCount(),
+ chs.GetStrings(), majorDim, style, val, name );
}
wxRadioBox::~wxRadioBox()
void wxRadioButton::Init()
{
m_radioStyle = pushButtonCtl;
+ m_groupID = 0;
}
bool wxRadioButton::Create(wxWindow *parent,
m_radioStyle == checkboxCtl ? checkboxCtl : pushButtonCtl,
label,
pos,
- size
+ size,
+ m_groupID
);
}
+void wxRadioButton::SetGroup(uint8_t group)
+{
+ m_groupID = group;
+}
+
// ----------------------------------------------------------------------------
// wxRadioButton functions
// ----------------------------------------------------------------------------
// Slider
void wxSlider::Init()
{
- m_oldPos = 0;
+ m_oldValue = m_oldPos = 0;
m_lineSize = 1;
}
// wxSL_INVERSE is ignored - always off
// wxSL_VERTICAL is impossible in native form
wxCHECK_MSG(!(style & wxSL_VERTICAL), false, _T("non vertical slider on PalmOS"));
-
+
if(!wxControl::Create(parent, id, pos, size, style, validator, name))
return false;
if(form==NULL)
return false;
- m_oldPos = value;
+ m_oldValue = m_oldPos = value;
SliderControlType *slider = CtlNewSliderControl (
(void **)&form,
void wxSlider::SetValue(int value)
{
SetIntValue(value);
- m_oldPos = value;
+ m_oldValue = m_oldPos = value;
}
wxSize wxSlider::DoGetBestSize() const
{
m_oldPos = GetValue();
- // first track event
+ // first thumb event
wxScrollEvent eventWxTrack(wxEVT_SCROLL_THUMBRELEASE, GetId());
eventWxTrack.SetPosition(m_oldPos);
eventWxTrack.SetEventObject(this);
- GetEventHandler()->ProcessEvent(eventWxTrack);
+ bool handled = GetEventHandler()->ProcessEvent(eventWxTrack);
+
+ // then slider event if position changed
+ if( m_oldValue != m_oldPos )
+ {
+ m_oldValue = m_oldPos;
+ wxCommandEvent event(wxEVT_COMMAND_SLIDER_UPDATED, GetId());
+ event.SetEventObject(this);
+ event.SetInt(m_oldPos);
+ return ProcessCommand(event);
+ }
- // then scroll event
- wxCommandEvent event(wxEVT_COMMAND_SLIDER_UPDATED, GetId());
- event.SetEventObject(this);
- event.SetInt(m_oldPos);
- return ProcessCommand(event);
+ return handled;
}
bool wxSlider::SendScrollEvent(EventType* event)
{
wxEventType scrollEvent;
int newPos = event->data.ctlRepeat.value;
- if ( newPos == GetMax() )
- {
- scrollEvent = wxEVT_SCROLL_TOP;
- }
- else if ( newPos == GetMin() )
- {
- scrollEvent = wxEVT_SCROLL_BOTTOM;
- }
- else if ( newPos == ( m_oldPos + GetLineSize() ) )
- {
- scrollEvent = wxEVT_SCROLL_LINEUP;
- }
- else if ( newPos == ( m_oldPos - GetLineSize() ) )
- {
- scrollEvent = wxEVT_SCROLL_LINEDOWN;
- }
- else if ( newPos == ( m_oldPos + GetPageSize() ) )
- {
- scrollEvent = wxEVT_SCROLL_PAGEUP;
- }
- else if ( newPos == ( m_oldPos - GetPageSize() ) )
- {
- scrollEvent = wxEVT_SCROLL_PAGEDOWN;
- }
- else
+ if ( newPos == m_oldPos )
{
+ // nothing changed since last event
return false;
}
m_oldPos = newPos;
// first track event
- wxScrollEvent eventWxTrack(wxEVT_SCROLL_THUMBTRACK, GetId());
- eventWxTrack.SetPosition(newPos);
- eventWxTrack.SetEventObject(this);
- GetEventHandler()->ProcessEvent(eventWxTrack);
-
- // then scroll event
- wxScrollEvent eventWxScroll(scrollEvent, GetId());
- eventWxScroll.SetPosition(newPos);
- eventWxScroll.SetEventObject(this);
- return GetEventHandler()->ProcessEvent(eventWxScroll);
+ wxScrollEvent eventWx(wxEVT_SCROLL_THUMBTRACK, GetId());
+ eventWx.SetPosition(newPos);
+ eventWx.SetEventObject(this);
+ return GetEventHandler()->ProcessEvent(eventWx);
}
void wxSlider::Command (wxCommandEvent & event)