1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/palmos/spinctrl.cpp 
   3 // Purpose:     wxSpinCtrl class implementation for Palm OS 
   4 // Author:      William Osborne - minimal working wxPalmOS port 
   8 // Copyright:   (c) William Osborne 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  20 // for compilers that support precompilation, includes "wx.h". 
  21 #include "wx/wxprec.h" 
  33 #if defined(__WIN95__) 
  35 #include "wx/spinctrl.h" 
  36 #include "wx/palmos/private.h" 
  38 // ---------------------------------------------------------------------------- 
  40 // ---------------------------------------------------------------------------- 
  42 #if wxUSE_EXTENDED_RTTI 
  43 WX_DEFINE_FLAGS( wxSpinCtrlStyle 
) 
  45 wxBEGIN_FLAGS( wxSpinCtrlStyle 
) 
  46     // new style border flags, we put them first to 
  47     // use them for streaming out 
  48     wxFLAGS_MEMBER(wxBORDER_SIMPLE
) 
  49     wxFLAGS_MEMBER(wxBORDER_SUNKEN
) 
  50     wxFLAGS_MEMBER(wxBORDER_DOUBLE
) 
  51     wxFLAGS_MEMBER(wxBORDER_RAISED
) 
  52     wxFLAGS_MEMBER(wxBORDER_STATIC
) 
  53     wxFLAGS_MEMBER(wxBORDER_NONE
) 
  55     // old style border flags 
  56     wxFLAGS_MEMBER(wxSIMPLE_BORDER
) 
  57     wxFLAGS_MEMBER(wxSUNKEN_BORDER
) 
  58     wxFLAGS_MEMBER(wxDOUBLE_BORDER
) 
  59     wxFLAGS_MEMBER(wxRAISED_BORDER
) 
  60     wxFLAGS_MEMBER(wxSTATIC_BORDER
) 
  61     wxFLAGS_MEMBER(wxBORDER
) 
  63     // standard window styles 
  64     wxFLAGS_MEMBER(wxTAB_TRAVERSAL
) 
  65     wxFLAGS_MEMBER(wxCLIP_CHILDREN
) 
  66     wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
) 
  67     wxFLAGS_MEMBER(wxWANTS_CHARS
) 
  68     wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
) 
  69     wxFLAGS_MEMBER(wxALWAYS_SHOW_SB 
) 
  70     wxFLAGS_MEMBER(wxVSCROLL
) 
  71     wxFLAGS_MEMBER(wxHSCROLL
) 
  73     wxFLAGS_MEMBER(wxSP_HORIZONTAL
) 
  74     wxFLAGS_MEMBER(wxSP_VERTICAL
) 
  75     wxFLAGS_MEMBER(wxSP_ARROW_KEYS
) 
  76     wxFLAGS_MEMBER(wxSP_WRAP
) 
  78 wxEND_FLAGS( wxSpinCtrlStyle 
) 
  80 IMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinCtrl
, wxControl
,"wx/spinbut.h") 
  82 wxBEGIN_PROPERTIES_TABLE(wxSpinCtrl
) 
  83     wxEVENT_RANGE_PROPERTY( Spin 
, wxEVT_SCROLL_TOP 
, wxEVT_SCROLL_ENDSCROLL 
, wxSpinEvent 
) 
  84     wxEVENT_PROPERTY( Updated 
, wxEVT_COMMAND_SPINCTRL_UPDATED 
, wxCommandEvent 
) 
  85     wxEVENT_PROPERTY( TextUpdated 
, wxEVT_COMMAND_TEXT_UPDATED 
, wxCommandEvent 
) 
  86     wxEVENT_PROPERTY( TextEnter 
, wxEVT_COMMAND_TEXT_ENTER 
, wxCommandEvent 
) 
  88     wxPROPERTY( ValueString 
, wxString 
, SetValue 
, GetValue 
, EMPTY_MACROVALUE 
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) ; 
  89     wxPROPERTY( Value 
, int , SetValue
, GetValue
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) 
  90     wxPROPERTY( Min 
, int , SetMin
, GetMin
, 0, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) 
  91     wxPROPERTY( Max 
, int , SetMax
, GetMax
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) 
  92     wxPROPERTY_FLAGS( WindowStyle 
, wxSpinCtrlStyle 
, long , SetWindowStyleFlag 
, GetWindowStyleFlag 
, EMPTY_MACROVALUE 
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style 
  97 wxEND_PROPERTIES_TABLE() 
  99 wxBEGIN_HANDLERS_TABLE(wxSpinCtrl
) 
 100 wxEND_HANDLERS_TABLE() 
 102 wxCONSTRUCTOR_6( wxSpinCtrl 
, wxWindow
* , Parent 
, wxWindowID 
, Id 
, wxString 
, ValueString 
, wxPoint 
, Position 
, wxSize 
, Size 
, long , WindowStyle 
) 
 104 IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl
, wxControl
) 
 107 BEGIN_EVENT_TABLE(wxSpinCtrl
, wxSpinButton
) 
 108     EVT_CHAR(wxSpinCtrl::OnChar
) 
 110     EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus
) 
 112     EVT_SPIN(-1, wxSpinCtrl::OnSpinChange
) 
 115 #define GetBuddyHwnd()      (HWND)(m_hwndBuddy) 
 117 // ---------------------------------------------------------------------------- 
 119 // ---------------------------------------------------------------------------- 
 121 // the margin between the up-down control and its buddy (can be arbitrary, 
 122 // choose what you like - or may be decide during run-time depending on the 
 124 static const int MARGIN_BETWEEN 
= 1; 
 126 // ============================================================================ 
 128 // ============================================================================ 
 130 wxArraySpins 
wxSpinCtrl::ms_allSpins
; 
 133 wxSpinCtrl 
*wxSpinCtrl::GetSpinForTextCtrl(WXHWND hwndBuddy
) 
 138 // process a WM_COMMAND generated by the buddy text control 
 139 bool wxSpinCtrl::ProcessTextCommand(WXWORD cmd
, WXWORD 
WXUNUSED(id
)) 
 144 void wxSpinCtrl::OnChar(wxKeyEvent
& event
) 
 148 void wxSpinCtrl::OnSetFocus(wxFocusEvent
& event
) 
 152 // ---------------------------------------------------------------------------- 
 154 // ---------------------------------------------------------------------------- 
 156 bool wxSpinCtrl::Create(wxWindow 
*parent
, 
 158                         const wxString
& value
, 
 162                         int min
, int max
, int initial
, 
 163                         const wxString
& name
) 
 168 wxSpinCtrl::~wxSpinCtrl() 
 172 // ---------------------------------------------------------------------------- 
 173 // wxTextCtrl-like methods 
 174 // ---------------------------------------------------------------------------- 
 176 void wxSpinCtrl::SetValue(const wxString
& text
) 
 180 int wxSpinCtrl::GetValue() const 
 185 void wxSpinCtrl::SetSelection(long from
, long to
) 
 189 // ---------------------------------------------------------------------------- 
 190 // forward some methods to subcontrols 
 191 // ---------------------------------------------------------------------------- 
 193 bool wxSpinCtrl::SetFont(const wxFont
& font
) 
 198 bool wxSpinCtrl::Show(bool show
) 
 203 bool wxSpinCtrl::Enable(bool enable
) 
 208 void wxSpinCtrl::SetFocus() 
 212 // ---------------------------------------------------------------------------- 
 214 // ---------------------------------------------------------------------------- 
 216 void wxSpinCtrl::OnSpinChange(wxSpinEvent
& eventSpin
) 
 220 // ---------------------------------------------------------------------------- 
 222 // ---------------------------------------------------------------------------- 
 224 wxSize 
wxSpinCtrl::DoGetBestSize() const 
 229 void wxSpinCtrl::DoMoveWindow(int x
, int y
, int width
, int height
) 
 233 // get total size of the control 
 234 void wxSpinCtrl::DoGetSize(int *x
, int *y
) const 
 238 void wxSpinCtrl::DoGetPosition(int *x
, int *y
) const