]> git.saurik.com Git - wxWidgets.git/blob - src/common/spinctrlcmn.cpp
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / common / spinctrlcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/spinctrlcmn.cpp
3 // Purpose: define wxSpinCtrl event types
4 // Author: Peter Most
5 // Created: 01.11.08
6 // Copyright: (c) 2008-2009 wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // ============================================================================
11 // declarations
12 // ============================================================================
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25 #include "wx/spinbutt.h"
26 #include "wx/spinctrl.h"
27
28 #if wxUSE_SPINCTRL
29
30 wxDEFINE_EVENT(wxEVT_SPINCTRL, wxSpinEvent);
31 wxDEFINE_EVENT(wxEVT_SPINCTRLDOUBLE, wxSpinDoubleEvent);
32
33 // ----------------------------------------------------------------------------
34 // XTI
35 // ----------------------------------------------------------------------------
36
37 wxDEFINE_FLAGS( wxSpinCtrlStyle )
38 wxBEGIN_FLAGS( wxSpinCtrlStyle )
39 // new style border flags, we put them first to
40 // use them for streaming out
41 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
42 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
43 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
44 wxFLAGS_MEMBER(wxBORDER_RAISED)
45 wxFLAGS_MEMBER(wxBORDER_STATIC)
46 wxFLAGS_MEMBER(wxBORDER_NONE)
47
48 // old style border flags
49 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
50 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
51 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
52 wxFLAGS_MEMBER(wxRAISED_BORDER)
53 wxFLAGS_MEMBER(wxSTATIC_BORDER)
54 wxFLAGS_MEMBER(wxBORDER)
55
56 // standard window styles
57 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
58 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
59 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
60 wxFLAGS_MEMBER(wxWANTS_CHARS)
61 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
62 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
63 wxFLAGS_MEMBER(wxVSCROLL)
64 wxFLAGS_MEMBER(wxHSCROLL)
65
66 wxFLAGS_MEMBER(wxSP_HORIZONTAL)
67 wxFLAGS_MEMBER(wxSP_VERTICAL)
68 wxFLAGS_MEMBER(wxSP_ARROW_KEYS)
69 wxFLAGS_MEMBER(wxSP_WRAP)
70 wxEND_FLAGS( wxSpinCtrlStyle )
71
72 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxSpinCtrl, wxControl, "wx/spinctrl.h")
73
74 wxBEGIN_PROPERTIES_TABLE(wxSpinCtrl)
75 wxEVENT_RANGE_PROPERTY( Spin, wxEVT_SCROLL_TOP, wxEVT_SCROLL_CHANGED, wxSpinEvent )
76
77 wxEVENT_PROPERTY( Updated, wxEVT_SPINCTRL, wxCommandEvent )
78 wxEVENT_PROPERTY( TextUpdated, wxEVT_TEXT, wxCommandEvent )
79 wxEVENT_PROPERTY( TextEnter, wxEVT_TEXT_ENTER, wxCommandEvent )
80
81 wxPROPERTY( ValueString, wxString, SetValue, GetValue, \
82 wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, wxT("Helpstring"), wxT("group")) ;
83 wxPROPERTY( Value, int, SetValue, GetValue, 0, 0 /*flags*/, \
84 wxT("Helpstring"), wxT("group"))
85 #if 0
86 wxPROPERTY( Min, int, SetMin, GetMin, 0, 0 /*flags*/, wxT("Helpstring"), wxT("group") )
87 wxPROPERTY( Max, int, SetMax, GetMax, 0, 0 /*flags*/, wxT("Helpstring"), wxT("group"))
88 #endif
89 wxPROPERTY_FLAGS( WindowStyle, wxSpinCtrlStyle, long, SetWindowStyleFlag, \
90 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
91 wxT("Helpstring"), wxT("group")) // style
92 /*
93 TODO PROPERTIES
94 style wxSP_ARROW_KEYS
95 */
96 wxEND_PROPERTIES_TABLE()
97
98 wxEMPTY_HANDLERS_TABLE(wxSpinCtrl)
99
100 wxCONSTRUCTOR_6( wxSpinCtrl, wxWindow*, Parent, wxWindowID, Id, \
101 wxString, ValueString, wxPoint, Position, \
102 wxSize, Size, long, WindowStyle )
103
104
105 wxString wxPrivate::wxSpinCtrlFormatAsHex(long val, long maxVal)
106 {
107 // We format the value like this is for compatibility with (native
108 // behaviour of) wxMSW
109 wxString text;
110 if ( maxVal < 0x10000 )
111 text.Printf(wxS("0x%04lx"), val);
112 else
113 text.Printf(wxS("0x%08lx"), val);
114
115 return text;
116 }
117
118 #endif // wxUSE_SPINCTRL