MCPcopy Create free account
hub / github.com/audacity/audacity / NumericalCommandType

Function NumericalCommandType

src/JournalEvents.cpp:250–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248
249template<typename Event = wxCommandEvent, typename EventType >
250static 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
289template<typename Event = wxCommandEvent, typename EventType >
290static Type TextualCommandType( EventType type, const wxString &code ){

Callers 1

JournalEvents.cppFile · 0.85

Calls 7

WindowEventSerializationFunction · 0.85
FindByPathFunction · 0.85
GetIdMethod · 0.80
SetWindowMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
TransferToWindowMethod · 0.45

Tested by

no test coverage detected