| 209 | |
| 210 | template<typename Event = wxCommandEvent, typename EventType > |
| 211 | static Type BooleanCommandType( EventType type, const wxString &code ){ |
| 212 | // Writes a window identifier to the journal and a bool |
| 213 | const auto serialize = |
| 214 | []( const Event &event ) { |
| 215 | auto result = WindowEventSerialization( event ); |
| 216 | if ( result ) |
| 217 | result->push_back( |
| 218 | wxString::Format( L"%d", event.GetInt() ? 1 : 0 ) ); |
| 219 | return result; |
| 220 | }; |
| 221 | |
| 222 | const auto deserialize = |
| 223 | []( wxEventType type, const wxArrayStringEx &components ) { |
| 224 | std::unique_ptr< Event > result; |
| 225 | int value; |
| 226 | if ( components.size() == 2 ) { |
| 227 | if ( auto pWindow = WindowPaths::FindByPath( components[0] ) ) { |
| 228 | if ( long longValue; components[1].ToLong( &longValue ) ) { |
| 229 | bool value = (longValue != 0); |
| 230 | result = std::make_unique< Event >( |
| 231 | type, pWindow->GetId() ); |
| 232 | result->SetEventObject( pWindow ); |
| 233 | result->SetInt( value ); |
| 234 | // Also change the state of the control before the event is |
| 235 | // processed. This class handles the most common control |
| 236 | // types. |
| 237 | wxGenericValidator validator( &value ); |
| 238 | validator.SetWindow( pWindow ); |
| 239 | validator.TransferToWindow(); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | return result; |
| 244 | }; |
| 245 | |
| 246 | return Type{ type, code, serialize, deserialize }; |
| 247 | } |
| 248 | |
| 249 | template<typename Event = wxCommandEvent, typename EventType > |
| 250 | static Type NumericalCommandType( EventType type, const wxString &code ){ |
no test coverage detected