1 /////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/spinctrl.cpp
3 // Purpose: wxSpinCtrl class implementation for Palm OS
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17 #pragma implementation "spinctrlbase.h"
18 #pragma implementation "spinctrl.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 // for compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
38 #if defined(__WIN95__)
40 #include "wx/spinctrl.h"
41 #include "wx/palmos/private.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 #if wxUSE_EXTENDED_RTTI
48 WX_DEFINE_FLAGS( wxSpinCtrlStyle
)
50 wxBEGIN_FLAGS( wxSpinCtrlStyle
)
51 // new style border flags, we put them first to
52 // use them for streaming out
53 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
54 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
55 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
56 wxFLAGS_MEMBER(wxBORDER_RAISED
)
57 wxFLAGS_MEMBER(wxBORDER_STATIC
)
58 wxFLAGS_MEMBER(wxBORDER_NONE
)
60 // old style border flags
61 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
62 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
63 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
64 wxFLAGS_MEMBER(wxRAISED_BORDER
)
65 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
66 wxFLAGS_MEMBER(wxBORDER
)
68 // standard window styles
69 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
70 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
71 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
72 wxFLAGS_MEMBER(wxWANTS_CHARS
)
73 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
74 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
75 wxFLAGS_MEMBER(wxVSCROLL
)
76 wxFLAGS_MEMBER(wxHSCROLL
)
78 wxFLAGS_MEMBER(wxSP_HORIZONTAL
)
79 wxFLAGS_MEMBER(wxSP_VERTICAL
)
80 wxFLAGS_MEMBER(wxSP_ARROW_KEYS
)
81 wxFLAGS_MEMBER(wxSP_WRAP
)
83 wxEND_FLAGS( wxSpinCtrlStyle
)
85 IMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinCtrl
, wxControl
,"wx/spinbut.h")
87 wxBEGIN_PROPERTIES_TABLE(wxSpinCtrl
)
88 wxEVENT_RANGE_PROPERTY( Spin
, wxEVT_SCROLL_TOP
, wxEVT_SCROLL_ENDSCROLL
, wxSpinEvent
)
89 wxEVENT_PROPERTY( Updated
, wxEVT_COMMAND_SPINCTRL_UPDATED
, wxCommandEvent
)
90 wxEVENT_PROPERTY( TextUpdated
, wxEVT_COMMAND_TEXT_UPDATED
, wxCommandEvent
)
91 wxEVENT_PROPERTY( TextEnter
, wxEVT_COMMAND_TEXT_ENTER
, wxCommandEvent
)
93 wxPROPERTY( ValueString
, wxString
, SetValue
, GetValue
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) ;
94 wxPROPERTY( Value
, int , SetValue
, GetValue
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
95 wxPROPERTY( Min
, int , SetMin
, GetMin
, 0, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
96 wxPROPERTY( Max
, int , SetMax
, GetMax
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
97 wxPROPERTY_FLAGS( WindowStyle
, wxSpinCtrlStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
100 style wxSP_ARROW_KEYS
102 wxEND_PROPERTIES_TABLE()
104 wxBEGIN_HANDLERS_TABLE(wxSpinCtrl
)
105 wxEND_HANDLERS_TABLE()
107 wxCONSTRUCTOR_6( wxSpinCtrl
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, ValueString
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
109 IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl
, wxControl
)
112 BEGIN_EVENT_TABLE(wxSpinCtrl
, wxSpinButton
)
113 EVT_CHAR(wxSpinCtrl::OnChar
)
115 EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus
)
117 EVT_SPIN(-1, wxSpinCtrl::OnSpinChange
)
120 #define GetBuddyHwnd() (HWND)(m_hwndBuddy)
122 // ----------------------------------------------------------------------------
124 // ----------------------------------------------------------------------------
126 // the margin between the up-down control and its buddy (can be arbitrary,
127 // choose what you like - or may be decide during run-time depending on the
129 static const int MARGIN_BETWEEN
= 1;
131 // ============================================================================
133 // ============================================================================
135 wxArraySpins
wxSpinCtrl::ms_allSpins
;
138 wxSpinCtrl
*wxSpinCtrl::GetSpinForTextCtrl(WXHWND hwndBuddy
)
143 // process a WM_COMMAND generated by the buddy text control
144 bool wxSpinCtrl::ProcessTextCommand(WXWORD cmd
, WXWORD
WXUNUSED(id
))
149 void wxSpinCtrl::OnChar(wxKeyEvent
& event
)
153 void wxSpinCtrl::OnSetFocus(wxFocusEvent
& event
)
157 // ----------------------------------------------------------------------------
159 // ----------------------------------------------------------------------------
161 bool wxSpinCtrl::Create(wxWindow
*parent
,
163 const wxString
& value
,
167 int min
, int max
, int initial
,
168 const wxString
& name
)
173 wxSpinCtrl::~wxSpinCtrl()
177 // ----------------------------------------------------------------------------
178 // wxTextCtrl-like methods
179 // ----------------------------------------------------------------------------
181 void wxSpinCtrl::SetValue(const wxString
& text
)
185 int wxSpinCtrl::GetValue() const
190 void wxSpinCtrl::SetSelection(long from
, long to
)
194 // ----------------------------------------------------------------------------
195 // forward some methods to subcontrols
196 // ----------------------------------------------------------------------------
198 bool wxSpinCtrl::SetFont(const wxFont
& font
)
203 bool wxSpinCtrl::Show(bool show
)
208 bool wxSpinCtrl::Enable(bool enable
)
213 void wxSpinCtrl::SetFocus()
217 // ----------------------------------------------------------------------------
219 // ----------------------------------------------------------------------------
221 void wxSpinCtrl::OnSpinChange(wxSpinEvent
& eventSpin
)
225 // ----------------------------------------------------------------------------
227 // ----------------------------------------------------------------------------
229 wxSize
wxSpinCtrl::DoGetBestSize() const
234 void wxSpinCtrl::DoMoveWindow(int x
, int y
, int width
, int height
)
238 // get total size of the control
239 void wxSpinCtrl::DoGetSize(int *x
, int *y
) const
243 void wxSpinCtrl::DoGetPosition(int *x
, int *y
) const