]> git.saurik.com Git - wxWidgets.git/blob - src/common/uiactioncmn.cpp
Allow absent checkbox when transferring dimension data
[wxWidgets.git] / src / common / uiactioncmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/uiactioncmn.cpp
3 // Purpose: wxUIActionSimulator common implementation
4 // Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
5 // Modified by:
6 // Created: 2010-03-06
7 // Copyright: (c) Kevin Ollivier
8 // (c) 2010 Steven Lamerton
9 // (c) 2010 Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #include "wx/wxprec.h"
14
15 #if wxUSE_UIACTIONSIMULATOR
16
17 #include "wx/uiaction.h"
18
19 bool wxUIActionSimulator::MouseClick(int button)
20 {
21 MouseDown(button);
22 MouseUp(button);
23
24 return true;
25 }
26
27 #ifndef __WXOSX__
28
29 bool wxUIActionSimulator::MouseDblClick(int button)
30 {
31 MouseDown(button);
32 MouseUp(button);
33 MouseDown(button);
34 MouseUp(button);
35
36 return true;
37 }
38
39 bool wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
40 int button)
41 {
42 MouseMove(x1, y1);
43 MouseDown(button);
44 MouseMove(x2, y2);
45 MouseUp(button);
46
47 return true;
48 }
49
50 #endif
51
52 bool
53 wxUIActionSimulator::Key(int keycode, int modifiers, bool isDown)
54 {
55 wxASSERT_MSG( (modifiers & wxMOD_ALTGR) != wxMOD_ALTGR,
56 "wxMOD_ALTGR is not implemented" );
57 wxASSERT_MSG( !(modifiers & wxMOD_META ),
58 "wxMOD_META is not implemented" );
59 wxASSERT_MSG( !(modifiers & wxMOD_WIN ),
60 "wxMOD_WIN is not implemented" );
61
62 if ( isDown )
63 SimulateModifiers(modifiers, true);
64
65 bool rc = DoKey(keycode, modifiers, isDown);
66
67 if ( !isDown )
68 SimulateModifiers(modifiers, false);
69
70 return rc;
71 }
72
73 void wxUIActionSimulator::SimulateModifiers(int modifiers, bool isDown)
74 {
75 if ( modifiers & wxMOD_SHIFT )
76 DoKey(WXK_SHIFT, modifiers, isDown);
77 if ( modifiers & wxMOD_ALT )
78 DoKey(WXK_ALT, modifiers, isDown);
79 if ( modifiers & wxMOD_CONTROL )
80 DoKey(WXK_CONTROL, modifiers, isDown);
81 }
82
83 bool wxUIActionSimulator::Char(int keycode, int modifiers)
84 {
85 switch(keycode)
86 {
87 case '0':
88 keycode = '0';
89 break;
90 case '1':
91 keycode = '1';
92 break;
93 case '2':
94 keycode = '2';
95 break;
96 case '3':
97 keycode = '3';
98 break;
99 case '4':
100 keycode = '4';
101 break;
102 case '5':
103 keycode = '5';
104 break;
105 case '6':
106 keycode = '6';
107 break;
108 case '7':
109 keycode = '7';
110 break;
111 case '8':
112 keycode = '8';
113 break;
114 case '9':
115 keycode = '9';
116 break;
117 case '+':
118 keycode = '+';
119 break;
120 case '-':
121 keycode = '-';
122 break;
123 case '.':
124 keycode = '.';
125 break;
126 default:
127 break;
128 };
129
130 Key(keycode, modifiers, true);
131 Key(keycode, modifiers, false);
132
133 return true;
134 }
135
136 bool wxUIActionSimulator::Text(const char *s)
137 {
138 while ( *s != '\0' )
139 {
140 const char ch = *s++;
141 if ( !Char(ch, isupper(ch) ? wxMOD_SHIFT : 0) )
142 return false;
143 }
144
145 return true;
146 }
147
148 #endif // wxUSE_UIACTIONSIMULATOR