| 248 | |
| 249 | template<typename Event = wxCommandEvent, typename EventType > |
| 250 | static Type NumericalCommandType( EventType type, const wxString &code ){ |
| 251 | // Writes a window identifier to the journal and an int |
| 252 | const auto serialize = |
| 253 | []( const Event &event ) { |
| 254 | auto result = WindowEventSerialization( event ); |
| 255 | if ( result ) |
| 256 | result->push_back( wxString::Format( L"%d", event.GetInt() ) ); |
| 257 | return result; |
| 258 | }; |
| 259 | |
| 260 | const auto deserialize = |
| 261 | []( wxEventType type, const wxArrayStringEx &components ) { |
| 262 | std::unique_ptr< Event > result; |
| 263 | int value; |
| 264 | if ( components.size() == 2 ) { |
| 265 | if ( auto pWindow = WindowPaths::FindByPath( components[0] ) ) { |
| 266 | if ( long longValue; |
| 267 | components[1].ToLong( &longValue ) && |
| 268 | longValue == (value = static_cast<int>(longValue) ) |
| 269 | ) { |
| 270 | result = std::make_unique< Event >( |
| 271 | type, pWindow->GetId() ); |
| 272 | result->SetEventObject( pWindow ); |
| 273 | result->SetInt( value ); |
| 274 | // Also change the state of the control before the event is |
| 275 | // processed. This class handles the most common control |
| 276 | // types. |
| 277 | wxGenericValidator validator( &value ); |
| 278 | validator.SetWindow( pWindow ); |
| 279 | validator.TransferToWindow(); |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | return result; |
| 284 | }; |
| 285 | |
| 286 | return Type{ type, code, serialize, deserialize }; |
| 287 | } |
| 288 | |
| 289 | template<typename Event = wxCommandEvent, typename EventType > |
| 290 | static Type TextualCommandType( EventType type, const wxString &code ){ |
no test coverage detected