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

Function BooleanCommandType

src/JournalEvents.cpp:211–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209
210template<typename Event = wxCommandEvent, typename EventType >
211static 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
249template<typename Event = wxCommandEvent, typename EventType >
250static Type NumericalCommandType( 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