mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-20 22:06:25 +08:00
wxWheelsCtrl wxiOS implementation + some tests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WXIOS@68778 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -563,6 +563,14 @@ public :
|
||||
long style,
|
||||
long extraStyle) ;
|
||||
|
||||
static wxWidgetImplType* CreateWheelsCtrl( wxWindowMac* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
long extraStyle) ;
|
||||
|
||||
static wxWidgetImplType* CreateSegmentedCtrl( wxWindowMac* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
|
||||
@@ -43,8 +43,6 @@ public:
|
||||
|
||||
virtual ~wxWheelsCtrl();
|
||||
|
||||
virtual void ClearComponents();
|
||||
|
||||
/// Reloads and displays all components.
|
||||
virtual bool ReloadAllComponents();
|
||||
|
||||
@@ -63,21 +61,9 @@ public:
|
||||
/// Returns the number of components.
|
||||
virtual int GetComponentCount() const;
|
||||
|
||||
/// Returns the size required to display the largest view in the given component.
|
||||
virtual wxSize GetRowSizeForComponent(int component) const;
|
||||
|
||||
/// Sets the data source object, recreating the components.
|
||||
void SetDataSource(wxWheelsDataSource* dataSource, bool ownsDataSource = false);
|
||||
|
||||
/// Initializes the components from the current data source. You do not usually
|
||||
/// need to call this function since it is called from SetDataSource.
|
||||
virtual bool InitializeComponents();
|
||||
|
||||
virtual bool SetBackgroundColour(const wxColour &colour);
|
||||
virtual bool SetForegroundColour(const wxColour &colour);
|
||||
virtual bool SetFont(const wxFont& font);
|
||||
virtual bool Enable(bool enable);
|
||||
|
||||
protected:
|
||||
|
||||
void Init();
|
||||
|
||||
+121
-115
@@ -21,7 +21,6 @@ extern WXDLLEXPORT_DATA(const wxChar) wxWheelsCtrlNameStr[];
|
||||
|
||||
class WXDLLEXPORT wxWheelsCtrl;
|
||||
class WXDLLEXPORT wxWheelsDataSource;
|
||||
class WXDLLEXPORT wxWheelsListBox;
|
||||
|
||||
|
||||
#pragma mark wxWheelComponent
|
||||
@@ -33,17 +32,14 @@ public:
|
||||
|
||||
// Constructor.
|
||||
wxWheelComponent(wxWheelsCtrl* wheelsCtrl,
|
||||
wxWheelsListBox* listBox,
|
||||
int n)
|
||||
{
|
||||
Init();
|
||||
|
||||
m_wheelsCtrl = wheelsCtrl;
|
||||
m_listBox = listBox;
|
||||
m_componentNumber = n;
|
||||
}
|
||||
|
||||
wxWheelsListBox* GetListBox() const { return m_listBox; }
|
||||
void SetListBox(wxWheelsListBox* listBox) { m_listBox = listBox; }
|
||||
int GetComponentNumber() const { return m_componentNumber; }
|
||||
const wxRect& GetRect() const { return m_rect; }
|
||||
void SetRect(const wxRect& rect) { m_rect = rect; }
|
||||
@@ -52,15 +48,13 @@ public:
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
m_listBox = NULL;
|
||||
m_componentNumber = 0;
|
||||
m_wheelsCtrl = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
wxWheelsListBox* m_listBox;
|
||||
int m_componentNumber;
|
||||
wxRect m_rect;
|
||||
int m_componentNumber;
|
||||
wxRect m_rect;
|
||||
wxWheelsCtrl* m_wheelsCtrl;
|
||||
};
|
||||
|
||||
@@ -89,17 +83,15 @@ public:
|
||||
|
||||
/// Constructor.
|
||||
wxWheelsCtrlBase(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxWheelsCtrlNameStr) { }
|
||||
wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxWheelsCtrlNameStr) { }
|
||||
|
||||
virtual ~wxWheelsCtrlBase() { }
|
||||
|
||||
virtual void ClearComponents() = 0;
|
||||
|
||||
/// Reloads and displays all components.
|
||||
virtual bool ReloadAllComponents() = 0;
|
||||
|
||||
@@ -121,9 +113,6 @@ public:
|
||||
/// Returns the number of components.
|
||||
virtual int GetComponentCount() const = 0;
|
||||
|
||||
/// Returns the size required to display the largest view in the given component.
|
||||
virtual wxSize GetRowSizeForComponent(int component) const = 0;
|
||||
|
||||
/// Sets the row selection indicator flag
|
||||
virtual void SetRowSelectionIndicator(bool showRowSelection) { m_showRowSelection = showRowSelection; }
|
||||
|
||||
@@ -136,27 +125,14 @@ public:
|
||||
/// Sets the data source object, recreating the components.
|
||||
virtual void SetDataSource(wxWheelsDataSource* dataSource, bool ownsDataSource = false) = 0;
|
||||
|
||||
/// Initializes the components from the current data source. You do not usually
|
||||
/// need to call this function since it is called from SetDataSource.
|
||||
virtual bool InitializeComponents() = 0;
|
||||
|
||||
// Returns the array of components.
|
||||
virtual const wxWheelComponentArray& GetComponents() const { return m_components; }
|
||||
|
||||
// Returns the given component. Implementation only.
|
||||
virtual wxWheelComponent* GetComponent(int component) const { return m_components[component]; }
|
||||
|
||||
/*
|
||||
virtual bool SetBackgroundColour(const wxColour &colour);
|
||||
virtual bool SetForegroundColour(const wxColour &colour);
|
||||
virtual bool SetFont(const wxFont& font);
|
||||
virtual bool Enable(bool enable);
|
||||
*/
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWheelsCtrlBase);
|
||||
|
||||
bool m_showRowSelection;
|
||||
wxWheelsDataSource* m_dataSource;
|
||||
bool m_ownDataSource;
|
||||
@@ -167,6 +143,8 @@ private:
|
||||
int m_topMargin;
|
||||
int m_bottomMargin;
|
||||
int m_interWheelSpacing;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWheelsCtrlBase);
|
||||
};
|
||||
|
||||
|
||||
@@ -250,48 +228,45 @@ public:
|
||||
void Init() {}
|
||||
|
||||
/// Override to provide the number of components.
|
||||
virtual int GetNumberOfComponents(wxWheelsCtrl* ctrl) = 0;
|
||||
virtual int GetNumberOfComponents(wxWheelsCtrl* ctrl) { return 0; }
|
||||
|
||||
/// Override to provide the number of rows in a component.
|
||||
virtual int GetNumberOfRowsForComponent(wxWheelsCtrl* ctrl,
|
||||
int component) = 0;
|
||||
int component) { return 0; }
|
||||
|
||||
/// Override to provide the row height for a component. Should returns a height in pixels.
|
||||
virtual int GetRowHeightForComponent(wxWheelsCtrl* ctrl,
|
||||
int component) = 0;
|
||||
int component) { return 0; }
|
||||
|
||||
/// Override to provide the row width for a component. Should returns a width in pixels.
|
||||
virtual int GetRowWidthForComponent(wxWheelsCtrl* ctrl,
|
||||
int component) = 0;
|
||||
int component) { return 0; }
|
||||
|
||||
/// Override to provide the title for a component's row. If you override GetRowWindow instead,
|
||||
/// this method is optional.
|
||||
virtual wxString GetRowTitle(wxWheelsCtrl* WXUNUSED(ctrl),
|
||||
int WXUNUSED(component),
|
||||
int WXUNUSED(row))
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
int WXUNUSED(row)) { return wxEmptyString; }
|
||||
|
||||
/// Override to provide a control for a component's row. This is optional.
|
||||
virtual wxWindow* GetRowWindow(wxWheelsCtrl* WXUNUSED(ctrl),
|
||||
int WXUNUSED(component),
|
||||
int WXUNUSED(row),
|
||||
wxWindow* WXUNUSED(reusingWindow))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
wxWindow* WXUNUSED(reusingWindow)) { return NULL; }
|
||||
|
||||
/// Override to intercept row click; by default, sends an event to itself and then to control.
|
||||
virtual bool OnSelectRow(wxWheelsCtrl* ctrl,
|
||||
int component,
|
||||
int row);
|
||||
int row) { }
|
||||
|
||||
protected:
|
||||
|
||||
DECLARE_CLASS(wxWheelsDataSource)
|
||||
};
|
||||
|
||||
WX_DECLARE_OBJARRAY(wxArrayString, wxArrayOfStringArrays);
|
||||
WX_DECLARE_OBJARRAY(wxSize, wxSizeArray);
|
||||
|
||||
|
||||
#pragma mark wxWheelsTextDataSource
|
||||
|
||||
@@ -304,20 +279,17 @@ protected:
|
||||
@category{wxbile}
|
||||
*/
|
||||
|
||||
WX_DECLARE_OBJARRAY(wxArrayString, wxArrayOfStringArrays);
|
||||
WX_DECLARE_OBJARRAY(wxSize, wxSizeArray);
|
||||
|
||||
class WXDLLEXPORT wxWheelsTextDataSource: public wxWheelsDataSource
|
||||
{
|
||||
public:
|
||||
/// Constructor.
|
||||
wxWheelsTextDataSource(int componentCount = 1,
|
||||
const wxSize& rowSize = wxDefaultSize);
|
||||
const wxSize& rowSize = wxDefaultSize);
|
||||
|
||||
void Init();
|
||||
|
||||
/// Override to provide the number of components.
|
||||
virtual int GetNumberOfComponents(wxWheelsCtrl* WXUNUSED(ctrl)) { return m_componentCount; }
|
||||
virtual int GetNumberOfComponents(wxWheelsCtrl* WXUNUSED(ctrl));
|
||||
|
||||
/// Override to provide the number of rows in a component.
|
||||
virtual int GetNumberOfRowsForComponent(wxWheelsCtrl* ctrl,
|
||||
@@ -337,7 +309,7 @@ public:
|
||||
int component,
|
||||
int row);
|
||||
|
||||
// New methods
|
||||
// New methods
|
||||
|
||||
wxArrayString GetStrings(int component = 0) const;
|
||||
void SetStrings(const wxArrayString& strings, int component = 0);
|
||||
@@ -346,98 +318,132 @@ public:
|
||||
void SetRowSize(const wxSize& sz, int component = 0);
|
||||
|
||||
void SetComponentCount(int count);
|
||||
int GetComponentCount() const { return m_componentCount; }
|
||||
int GetComponentCount() const;
|
||||
|
||||
protected:
|
||||
|
||||
wxArrayOfStringArrays m_stringArrays;
|
||||
wxSizeArray m_rowSizes;
|
||||
int m_componentCount;
|
||||
int m_componentCount;
|
||||
|
||||
DECLARE_CLASS(wxWheelsDataSource)
|
||||
};
|
||||
|
||||
|
||||
#pragma mark wxWheelsListBox
|
||||
#pragma mark wxWheelsDateTimeDataSource
|
||||
|
||||
// wxWheelsDateTimeDataSource modes
|
||||
enum {
|
||||
wxWHEELS_DT_TIME = 0x00000000,
|
||||
wxWHEELS_DT_DATE = 0x00010000,
|
||||
wxWHEELS_DT_DATE_TIME = 0x00020000,
|
||||
wxWHEELS_DT_COUNTDOWN = 0x00040000,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@class wxWheelsListBox
|
||||
@class wxWheelsDateTimeDataSource
|
||||
|
||||
A listbox to implement a single component in a wheels control.
|
||||
Currently this works for text strings only.
|
||||
A class for creating a wheel control for choosing date and/or time.
|
||||
|
||||
@category{wxbileImplementation}
|
||||
*/
|
||||
@category{wxbile}
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxWheelsListBox: public wxVListBox
|
||||
class WXDLLEXPORT wxWheelsDateTimeDataSource: public wxWheelsDataSource
|
||||
{
|
||||
public:
|
||||
/// Default constructor.
|
||||
wxWheelsListBox();
|
||||
|
||||
/// Constructor.
|
||||
wxWheelsListBox(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxLB_SINGLE,
|
||||
const wxString& name = wxVListBoxNameStr);
|
||||
wxWheelsDateTimeDataSource()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
/// Creation function.
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxLB_SINGLE,
|
||||
const wxString& name = wxVListBoxNameStr);
|
||||
void Init()
|
||||
{
|
||||
m_pickerMode = wxWHEELS_DT_DATE_TIME;
|
||||
m_initialDate = NULL;
|
||||
m_minimumDate = NULL;
|
||||
m_maximumDate = NULL;
|
||||
m_minuteInterval = 1;
|
||||
m_countDownDuration = 0.0;
|
||||
}
|
||||
|
||||
virtual ~wxWheelsListBox();
|
||||
// Not used.
|
||||
virtual int GetNumberOfComponents(wxWheelsCtrl* WXUNUSED(ctrl)) { return 0; }
|
||||
|
||||
/// Sets the wheels control implementing this control.
|
||||
void SetWheelsCtrl(wxWheelsCtrl* ctrl) { m_wheelsCtrl = ctrl; }
|
||||
// Not used.
|
||||
virtual int GetNumberOfRowsForComponent(wxWheelsCtrl* ctrl,
|
||||
int component) { return 0; }
|
||||
|
||||
/// Gets the wheels control implementing this control.
|
||||
wxWheelsCtrl* GetWheelsCtrl() const { return m_wheelsCtrl; }
|
||||
// Not used.
|
||||
virtual int GetRowHeightForComponent(wxWheelsCtrl* ctrl,
|
||||
int component) { return 0; }
|
||||
|
||||
/// Sets the component number that this list represents.
|
||||
void SetComponentNumber(int n) { m_componentNumber = n; }
|
||||
// Not used.
|
||||
virtual int GetRowWidthForComponent(wxWheelsCtrl* ctrl,
|
||||
int component) { return 0; }
|
||||
|
||||
/// Gets the component number that this list represents.
|
||||
int GetComponentNumber() const { return m_componentNumber; }
|
||||
// Not used.
|
||||
virtual wxString GetRowTitle(wxWheelsCtrl* ctrl,
|
||||
int component,
|
||||
int row) { return wxEmptyString; }
|
||||
|
||||
/// Gets the component for this listbox.
|
||||
wxWheelComponent* GetComponent() const;
|
||||
// New methods
|
||||
|
||||
/// Get date picker mode.
|
||||
int GetPickerMode() { return m_pickerMode; }
|
||||
|
||||
/// Set date picker mode.
|
||||
void SetPickerMode(int pickerMode) { m_pickerMode = pickerMode; }
|
||||
|
||||
/// Get initial picker date.
|
||||
wxDateTime* GetInitialDate() { return m_initialDate; }
|
||||
|
||||
/// Set initial picker date.
|
||||
void SetInitialDate(wxDateTime* initialDate) { m_initialDate = initialDate; }
|
||||
|
||||
/// Get minumum picker date.
|
||||
wxDateTime* GetMinimumPickerDate() { return m_minimumDate; }
|
||||
|
||||
/// Set minumum picker date.
|
||||
void SetMinimumPickerDate(wxDateTime* minimumDate) { m_minimumDate = minimumDate; }
|
||||
|
||||
/// Get maximum picker date.
|
||||
wxDateTime* GetMaximumPickerDate() { return m_maximumDate; }
|
||||
|
||||
/// Set maximum picker date.
|
||||
void SetMaximumPickerDate(wxDateTime* maximumDate) { m_maximumDate = maximumDate; }
|
||||
|
||||
/// Get minute interval.
|
||||
int GetMinuteInterval() { return m_minuteInterval; }
|
||||
|
||||
/// Set minute interval.
|
||||
void SetMinuteInterval(int minuteInterval) { m_minuteInterval = minuteInterval; }
|
||||
|
||||
/// Get count down duration (timer mode only).
|
||||
double GetCountDownDuration() { return m_countDownDuration; }
|
||||
|
||||
/// Set count down duration (timer mode only).
|
||||
void SetCountDownDuration(double countDownDuration ) { m_countDownDuration = countDownDuration; }
|
||||
|
||||
/// Override to intercept date select; by default, sends an event to itself and then to control.
|
||||
virtual bool OnSelectDate(wxWheelsCtrl *ctrl, wxDateTime *date) { }
|
||||
|
||||
protected:
|
||||
virtual void OnDrawBackground(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
size_t n) const;
|
||||
virtual void DrawBackground(wxDC& dc);
|
||||
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
void OnSelect(wxCommandEvent& event);
|
||||
|
||||
// the derived class must implement this function to actually draw the item
|
||||
// with the given index on the provided DC
|
||||
virtual void OnDrawItem(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
size_t n) const;
|
||||
|
||||
// the derived class must implement this method to return the height of the
|
||||
// specified item
|
||||
virtual wxCoord OnMeasureItem(size_t n) const ;
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
wxWheelsCtrl* m_wheelsCtrl;
|
||||
int m_componentNumber;
|
||||
|
||||
DECLARE_CLASS(wxWheelsListBox)
|
||||
|
||||
DECLARE_CLASS(wxWheelsDataSource)
|
||||
|
||||
private:
|
||||
int m_pickerMode;
|
||||
wxDateTime* m_initialDate;
|
||||
wxDateTime* m_minimumDate;
|
||||
wxDateTime* m_maximumDate;
|
||||
int m_minuteInterval;
|
||||
double m_countDownDuration;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWheelsCtrl class itself
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/generic/wheelsctrl.cpp
|
||||
// Purpose: Common wxWheelsCtrl parts
|
||||
// Author: Julian Smart, Linas Valiukas
|
||||
// Created: 2011-08-19
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2011 Julian Smart, Linas Valiukas
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
#include "wx/sizer.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wheelsctrl.h"
|
||||
#include "wx/arrimpl.cpp"
|
||||
|
||||
|
||||
#pragma mark wxWheelsCtrlEvent
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWheelsCtrlEvent, wxNotifyEvent)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_WHEEL_SELECTED)
|
||||
|
||||
|
||||
WX_DEFINE_EXPORTED_OBJARRAY(wxArrayOfStringArrays);
|
||||
WX_DEFINE_EXPORTED_OBJARRAY(wxSizeArray);
|
||||
|
||||
|
||||
#pragma mark wxWheelsDataSource
|
||||
|
||||
IMPLEMENT_CLASS(wxWheelsDataSource, wxEvtHandler)
|
||||
|
||||
|
||||
#pragma mark wxWheelsTextDataSource
|
||||
|
||||
IMPLEMENT_CLASS(wxWheelsTextDataSource, wxWheelsDataSource)
|
||||
|
||||
wxWheelsTextDataSource::wxWheelsTextDataSource(int componentCount,
|
||||
const wxSize& rowSize)
|
||||
{
|
||||
Init();
|
||||
|
||||
SetComponentCount(componentCount);
|
||||
|
||||
for (int i = 0; i < componentCount; i++) {
|
||||
SetRowSize(rowSize, i);
|
||||
}
|
||||
}
|
||||
|
||||
void wxWheelsTextDataSource::Init()
|
||||
{
|
||||
m_componentCount = 1;
|
||||
m_stringArrays.Add(wxArrayString());
|
||||
m_rowSizes.Add(wxSize(-1, -1));
|
||||
}
|
||||
|
||||
int wxWheelsTextDataSource::GetNumberOfComponents(wxWheelsCtrl* WXUNUSED(ctrl))
|
||||
{
|
||||
return m_componentCount;
|
||||
}
|
||||
|
||||
void wxWheelsTextDataSource::SetComponentCount(int count)
|
||||
{
|
||||
int i;
|
||||
int arrayCount = m_stringArrays.GetCount();
|
||||
|
||||
if (count > arrayCount) {
|
||||
int toAdd = count - arrayCount;
|
||||
for (i = 0; i < toAdd; i++) {
|
||||
m_stringArrays.Add(wxArrayString());
|
||||
m_rowSizes.Add(wxSize(-1, -1));
|
||||
}
|
||||
} else if (count < arrayCount) {
|
||||
int toDelete = arrayCount - count;
|
||||
for (i = 0; i < toDelete; i++) {
|
||||
m_stringArrays.RemoveAt(0);
|
||||
m_rowSizes.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
m_componentCount = count;
|
||||
}
|
||||
|
||||
int wxWheelsTextDataSource::GetComponentCount() const
|
||||
{
|
||||
return m_componentCount;
|
||||
}
|
||||
|
||||
wxArrayString wxWheelsTextDataSource::GetStrings(int component) const
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
return m_stringArrays[component];
|
||||
} else {
|
||||
return wxArrayString();
|
||||
}
|
||||
}
|
||||
|
||||
void wxWheelsTextDataSource::SetStrings(const wxArrayString& strings,
|
||||
int component)
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
m_stringArrays[component] = strings;
|
||||
}
|
||||
}
|
||||
|
||||
wxSize wxWheelsTextDataSource::GetRowSize(int component) const
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
return m_rowSizes[component];
|
||||
} else {
|
||||
return wxSize(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void wxWheelsTextDataSource::SetRowSize(const wxSize& sz,
|
||||
int component)
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
m_rowSizes[component] = sz;
|
||||
}
|
||||
}
|
||||
|
||||
// Override to provide the number of rows in a component.
|
||||
int wxWheelsTextDataSource::GetNumberOfRowsForComponent(wxWheelsCtrl* WXUNUSED(ctrl),
|
||||
int component)
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
return (int) m_stringArrays[component].GetCount();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Override to provide the title for a component's row. If you override GetRowWindow instead,
|
||||
// this method is optional.
|
||||
wxString wxWheelsTextDataSource::GetRowTitle(wxWheelsCtrl* WXUNUSED(ctrl),
|
||||
int component,
|
||||
int row)
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
wxASSERT(row < (int) m_stringArrays[component].GetCount());
|
||||
if (row < (int) m_stringArrays[component].GetCount()) {
|
||||
return m_stringArrays[component][row];
|
||||
}
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
// Override to provide the row height for a component. Should returns a height in pixels.
|
||||
int wxWheelsTextDataSource::GetRowHeightForComponent(wxWheelsCtrl* ctrl,
|
||||
int component)
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
if (GetRowSize(component).y > 0) {
|
||||
return GetRowSize(component).y;
|
||||
} else {
|
||||
wxScreenDC dc;
|
||||
dc.SetFont(ctrl->GetFont());
|
||||
int w, h;
|
||||
dc.GetTextExtent(wxT("Xy"), & w, & h);
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Override to provide the row width for a component. Should returns a width in pixels.
|
||||
int wxWheelsTextDataSource::GetRowWidthForComponent(wxWheelsCtrl* ctrl,
|
||||
int component)
|
||||
{
|
||||
wxASSERT(component < GetComponentCount());
|
||||
if (component < GetComponentCount()) {
|
||||
if (GetRowSize(component).y > 0) {
|
||||
return GetRowSize(component).y;
|
||||
} else {
|
||||
// Find the longest width
|
||||
int rowWidth = 0;
|
||||
int margin = 2;
|
||||
int i;
|
||||
int rowCount = GetNumberOfRowsForComponent(ctrl, component);
|
||||
wxScreenDC dc;
|
||||
dc.SetFont(ctrl->GetFont());
|
||||
for (i = 0; i < rowCount; i++) {
|
||||
wxString str = GetRowTitle(ctrl, component, i);
|
||||
|
||||
int w, h;
|
||||
dc.GetTextExtent(str, & w, & h);
|
||||
|
||||
if (w > rowWidth) {
|
||||
rowWidth = w;
|
||||
}
|
||||
}
|
||||
|
||||
rowWidth += margin*2;
|
||||
return rowWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark wxWheelsDateTimeDataSource
|
||||
|
||||
IMPLEMENT_CLASS(wxWheelsDateTimeDataSource, wxWheelsDataSource)
|
||||
|
||||
|
||||
#pragma mark wxWheelComponent
|
||||
|
||||
IMPLEMENT_CLASS(wxWheelComponent, wxEvtHandler)
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
class wxListWidgetIPhoneImpl;
|
||||
|
||||
@interface wxUIPickerView : UIPickerView <UIPickerViewDataSource, UIPickerViewDelegate>
|
||||
@interface wxUIPickerView : UIPickerView <UIPickerViewDataSource, UIPickerViewDelegate>
|
||||
{
|
||||
@private
|
||||
wxListWidgetIPhoneImpl* implementation;
|
||||
|
||||
+452
-353
File diff suppressed because it is too large
Load Diff
@@ -59,6 +59,8 @@
|
||||
B9ED401113CA6A12007570A4 /* window.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9ED3FF913CA6A12007570A4 /* window.mm */; };
|
||||
B9F3295913CE0763007E7023 /* actionsheetdlg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9F3295813CE0763007E7023 /* actionsheetdlg.mm */; };
|
||||
B9F32A9513CE7ACE007E7023 /* alertsheetdlg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9F32A9413CE7ACE007E7023 /* alertsheetdlg.mm */; };
|
||||
B9F4169D13FDB45600688F55 /* tests_wheelsctrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B9F4169C13FDB45600688F55 /* tests_wheelsctrl.cpp */; };
|
||||
B9F416E013FDBDAB00688F55 /* wheelsctrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B9F416DF13FDBDAB00688F55 /* wheelsctrl.cpp */; };
|
||||
B9FE823A13CB441B009182C3 /* viewcontroller.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9FE823913CB441B009182C3 /* viewcontroller.mm */; };
|
||||
B9FE836713CBA872009182C3 /* navitem.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9FE836613CBA872009182C3 /* navitem.mm */; };
|
||||
B9FE838113CBA9F2009182C3 /* tabctrl.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9FE838013CBA9F2009182C3 /* tabctrl.mm */; };
|
||||
@@ -155,6 +157,9 @@
|
||||
B9ED3FF913CA6A12007570A4 /* window.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = window.mm; path = ../../src/osx/iphone/window.mm; sourceTree = SOURCE_ROOT; };
|
||||
B9F3295813CE0763007E7023 /* actionsheetdlg.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = actionsheetdlg.mm; path = ../../src/osx/iphone/actionsheetdlg.mm; sourceTree = SOURCE_ROOT; };
|
||||
B9F32A9413CE7ACE007E7023 /* alertsheetdlg.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = alertsheetdlg.mm; path = ../../src/osx/iphone/alertsheetdlg.mm; sourceTree = SOURCE_ROOT; };
|
||||
B9F4169B13FDB45600688F55 /* tests_wheelsctrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tests_wheelsctrl.h; sourceTree = "<group>"; };
|
||||
B9F4169C13FDB45600688F55 /* tests_wheelsctrl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tests_wheelsctrl.cpp; sourceTree = "<group>"; };
|
||||
B9F416DF13FDBDAB00688F55 /* wheelsctrl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = wheelsctrl.cpp; path = ../../src/generic/wheelsctrl.cpp; sourceTree = SOURCE_ROOT; };
|
||||
B9FE823913CB441B009182C3 /* viewcontroller.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = viewcontroller.mm; path = ../../src/osx/iphone/viewcontroller.mm; sourceTree = SOURCE_ROOT; };
|
||||
B9FE836613CBA872009182C3 /* navitem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = navitem.mm; path = ../../src/osx/iphone/navitem.mm; sourceTree = SOURCE_ROOT; };
|
||||
B9FE838013CBA9F2009182C3 /* tabctrl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = tabctrl.mm; path = ../../src/osx/iphone/tabctrl.mm; sourceTree = SOURCE_ROOT; };
|
||||
@@ -269,6 +274,7 @@
|
||||
B9FE823913CB441B009182C3 /* viewcontroller.mm */,
|
||||
B9ED3FF813CA6A12007570A4 /* webkit.mm */,
|
||||
B9FE83FF13CBB4A5009182C3 /* wheelsctrl.mm */,
|
||||
B9F416DF13FDBDAB00688F55 /* wheelsctrl.cpp */,
|
||||
B9ED3FF913CA6A12007570A4 /* window.mm */,
|
||||
);
|
||||
name = "src-osx-iphone";
|
||||
@@ -315,6 +321,8 @@
|
||||
B9BE54A113F8F15E007AF138 /* tests_viewcontroller.cpp */,
|
||||
B9BE54AF13F8F29D007AF138 /* tests_viewcontroller_vc.h */,
|
||||
B9BE54B013F8F29D007AF138 /* tests_viewcontroller_vc.cpp */,
|
||||
B9F4169B13FDB45600688F55 /* tests_wheelsctrl.h */,
|
||||
B9F4169C13FDB45600688F55 /* tests_wheelsctrl.cpp */,
|
||||
);
|
||||
path = tests;
|
||||
sourceTree = "<group>";
|
||||
@@ -445,6 +453,8 @@
|
||||
B9BE54A213F8F15E007AF138 /* tests_viewcontroller.cpp in Sources */,
|
||||
B9BE54B113F8F29D007AF138 /* tests_viewcontroller_vc.cpp in Sources */,
|
||||
B9BE54E413F8F964007AF138 /* navbar.mm in Sources */,
|
||||
B9F4169D13FDB45600688F55 /* tests_wheelsctrl.cpp in Sources */,
|
||||
B9F416E013FDBDAB00688F55 /* wheelsctrl.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "tests_searchctrl.h"
|
||||
#include "tests_listbox.h"
|
||||
#include "tests_viewcontroller.h"
|
||||
#include "tests_wheelsctrl.h"
|
||||
|
||||
|
||||
#pragma mark -
|
||||
@@ -127,9 +128,14 @@ MobileTestsDataSource::MobileTestsDataSource(wxNavigationCtrl* ctrl)
|
||||
|
||||
// wxListBox
|
||||
m_testNames.Add(_("wxListBox"));
|
||||
m_testDescriptions.Add(_("A control consisting of a number of components that can be spun."));
|
||||
m_testDescriptions.Add(_("A listbox is used to select one or more of a list of strings."));
|
||||
m_testPanels.Add(new MobileTestsWxListBoxPanel());
|
||||
|
||||
// wxWheelsCtrl
|
||||
m_testNames.Add(_("wxWheelsCtrl"));
|
||||
m_testDescriptions.Add(_("A control consisting of a number of components that can be spun."));
|
||||
m_testPanels.Add(new MobileTestsWxWheelsCtrlPanel());
|
||||
|
||||
// wxViewController
|
||||
//m_testNames.Add(_("wxViewController"));
|
||||
//m_testDescriptions.Add(_("The view controller manages a window, usually in conjunction with the wxNavigationCtrl class."));
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* tests_wheelsctrl.cpp
|
||||
* testios
|
||||
*
|
||||
* Created by Linas Valiukas on 2011-08-18.
|
||||
* Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tests_wheelsctrl.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(MobileTestsWxWheelsCtrlPanel, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
bool MobileTestsWxWheelsCtrlPanel::CreateWithControls(wxWindow* parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxPanel::Create(parent, id, pos, size, style, name)) {
|
||||
wxFAIL_MSG("Unable to create parent wxPanel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !CreateControls()) {
|
||||
wxFAIL_MSG("Unable to create controls for this test panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MobileTestsWxWheelsCtrlPanel::CreateControls()
|
||||
{
|
||||
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
SetSizer(sizer);
|
||||
|
||||
|
||||
//
|
||||
// Wheels control with text (string) data source, 2 components
|
||||
//
|
||||
|
||||
wxWheelsTextDataSource* stringDataSource = new wxWheelsTextDataSource(2);
|
||||
wxArrayString textDataStrings;
|
||||
textDataStrings.Add(_("First string"));
|
||||
textDataStrings.Add(_("A second string"));
|
||||
textDataStrings.Add(_("And here's another string"));
|
||||
textDataStrings.Add(_("Fourth string at your service"));
|
||||
textDataStrings.Add(_("Five strings are not quite enough"));
|
||||
textDataStrings.Add(_("So here's a sixth string"));
|
||||
stringDataSource->SetStrings(textDataStrings, 0);
|
||||
|
||||
wxArrayString textDataStrings2;
|
||||
for (int i = 0; i < 50; i++) {
|
||||
textDataStrings2.Add(wxString::Format(wxT("%d"), i));
|
||||
}
|
||||
stringDataSource->SetStrings(textDataStrings2, 1);
|
||||
|
||||
m_textWheelsCtrl = new wxWheelsCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
|
||||
sizer->Add(m_textWheelsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
m_textWheelsCtrl->SetDataSource(stringDataSource, true /* control owns the data source */);
|
||||
m_textWheelsCtrl->Connect(wxEVT_COMMAND_WHEEL_SELECTED, wxWheelsCtrlEventHandler(MobileTestsWxWheelsCtrlPanel::OnTextChange), NULL, this);
|
||||
|
||||
|
||||
//
|
||||
// Wheels control with date-time data source
|
||||
//
|
||||
|
||||
// FIXME fix default frame
|
||||
wxWheelsDateTimeDataSource* dateTimeDataSource = new wxWheelsDateTimeDataSource();
|
||||
|
||||
m_dateTimeWheelsCtrl = new wxWheelsCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
|
||||
sizer->Add(m_dateTimeWheelsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
m_dateTimeWheelsCtrl->SetDataSource(dateTimeDataSource, true /* control owns the data source */);
|
||||
m_dateTimeWheelsCtrl->Connect(wxEVT_COMMAND_WHEEL_SELECTED, wxWheelsCtrlEventHandler(MobileTestsWxWheelsCtrlPanel::OnDateTimeChange), NULL, this);
|
||||
|
||||
|
||||
//
|
||||
// Wheels control with count down data source
|
||||
//
|
||||
|
||||
wxWheelsDateTimeDataSource* countDownDataSource = new wxWheelsDateTimeDataSource();
|
||||
countDownDataSource->SetPickerMode(wxWHEELS_DT_COUNTDOWN);
|
||||
|
||||
m_countDownWheelsCtrl = new wxWheelsCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
|
||||
sizer->Add(m_countDownWheelsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
m_countDownWheelsCtrl->SetDataSource(countDownDataSource, true /* control owns the data source */);
|
||||
m_countDownWheelsCtrl->Connect(wxEVT_COMMAND_WHEEL_SELECTED, wxWheelsCtrlEventHandler(MobileTestsWxWheelsCtrlPanel::OnCountDownChange), NULL, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MobileTestsWxWheelsCtrlPanel::OnTextChange(wxWheelsCtrlEvent& WXUNUSED(event))
|
||||
{
|
||||
wxLogMessage("wxEVT_COMMAND_WHEEL_SELECTED (text wheel control)");
|
||||
}
|
||||
|
||||
void MobileTestsWxWheelsCtrlPanel::OnDateTimeChange(wxWheelsCtrlEvent& WXUNUSED(event))
|
||||
{
|
||||
wxLogMessage("wxEVT_COMMAND_WHEEL_SELECTED (date-time wheel control");
|
||||
}
|
||||
|
||||
void MobileTestsWxWheelsCtrlPanel::OnCountDownChange(wxWheelsCtrlEvent& WXUNUSED(event))
|
||||
{
|
||||
wxLogMessage("wxEVT_COMMAND_WHEEL_SELECTED (count down wheel control)");
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* tests_wheelsctrl.h
|
||||
* testios
|
||||
*
|
||||
* Created by Linas Valiukas on 2011-08-18.
|
||||
* Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// TESTS:
|
||||
//
|
||||
|
||||
#ifndef testios_tests_wheelsctrl_h
|
||||
#define testios_tests_wheelsctrl_h
|
||||
|
||||
#include "testpanel.h"
|
||||
#include "wx/wheelsctrl.h"
|
||||
|
||||
class MobileTestsWxWheelsCtrlPanel : public MobileTestsWxPanel {
|
||||
|
||||
public:
|
||||
bool CreateWithControls(wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL,
|
||||
const wxString& name = _("wxWheelsCtrl Mobile"));
|
||||
|
||||
// Event tests
|
||||
void OnTextChange(wxWheelsCtrlEvent& WXUNUSED(event));
|
||||
void OnDateTimeChange(wxWheelsCtrlEvent& WXUNUSED(event));
|
||||
void OnCountDownChange(wxWheelsCtrlEvent& WXUNUSED(event));
|
||||
|
||||
protected:
|
||||
bool CreateControls();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
wxWheelsCtrl* m_textWheelsCtrl;
|
||||
wxWheelsCtrl* m_dateTimeWheelsCtrl;
|
||||
wxWheelsCtrl* m_countDownWheelsCtrl;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user