void structButtonEditor :: v_draw () { Graphics_clearWs (our graphics.get()); switch (show) { case 1: for (long i = 1, n = praat_getNumberOfMenuCommands (); i <= n; i ++) { Praat_Command cmd = praat_getMenuCommand (i); if (str32equ (cmd -> window, U"Objects")) drawMenuCommand (this, praat_getMenuCommand (i), i); } break; case 2: for (long i = 1, n = praat_getNumberOfMenuCommands (); i <= n; i ++) { Praat_Command cmd = praat_getMenuCommand (i); if (str32equ (cmd -> window, U"Picture")) drawMenuCommand (this, praat_getMenuCommand (i), i); } break; case 3: for (long i = 1, n = praat_getNumberOfMenuCommands (); i <= n; i ++) { Praat_Command cmd = praat_getMenuCommand (i); if (! str32equ (cmd -> window, U"Objects") && ! str32equ (cmd -> window, U"Picture")) drawMenuCommand (this, praat_getMenuCommand (i), i); } break; case 4: for (long i = 1, n = praat_getNumberOfActions (); i <= n; i ++) { Praat_Command cmd = praat_getAction (i); const char32 *klas = cmd -> class1 -> className; if (str32cmp (klas, U"N") < 0) drawAction (this, praat_getAction (i), i); } break; case 5: for (long i = 1, n = praat_getNumberOfActions (); i <= n; i ++) { Praat_Command cmd = praat_getAction (i); const char32 *klas = cmd -> class1 -> className; if (str32cmp (klas, U"N") >= 0) drawAction (this, praat_getAction (i), i); } break; } }
void ButtonEditor::draw () { Graphics_clearWs (_g); switch (_show) { case 1: for (long i = 1, n = praat_getNumberOfMenuCommands (); i <= n; i ++) { praat_Command cmd = praat_getMenuCommand (i); if (wcsequ (cmd -> window, L"Objects")) drawMenuCommand (praat_getMenuCommand (i), i); } break; case 2: for (long i = 1, n = praat_getNumberOfMenuCommands (); i <= n; i ++) { praat_Command cmd = praat_getMenuCommand (i); if (wcsequ (cmd -> window, L"Picture")) drawMenuCommand (praat_getMenuCommand (i), i); } break; case 3: for (long i = 1, n = praat_getNumberOfMenuCommands (); i <= n; i ++) { praat_Command cmd = praat_getMenuCommand (i); if (! wcsequ (cmd -> window, L"Objects") && ! wcsequ (cmd -> window, L"Picture")) drawMenuCommand (praat_getMenuCommand (i), i); } break; case 4: for (long i = 1, n = praat_getNumberOfActions (); i <= n; i ++) { praat_Command cmd = praat_getAction (i); const wchar_t *klas = ((Data_Table) cmd -> class1) -> _className; if (wcscmp (klas, L"N") < 0) drawAction (praat_getAction (i), i); } break; case 5: for (long i = 1, n = praat_getNumberOfActions (); i <= n; i ++) { praat_Command cmd = praat_getAction (i); const wchar_t *klas = ((Data_Table) cmd -> class1) -> _className; if (wcscmp (klas, L"N") >= 0) drawAction (praat_getAction (i), i); } break; } }
int structButtonEditor :: v_goToPage (const char32 *title) { if (! title || ! title [0]) return 0; if (str32equ (title, U"Buttons")) return 1; switch (title [0]) { case 'a': { // toggle visibility of action long i = Melder_atoi (& title [1]); Praat_Command action = praat_getAction (i); if (! action) return 0; if (action -> hidden) praat_showAction (action -> class1, action -> class2, action -> class3, action -> title); else praat_hideAction (action -> class1, action -> class2, action -> class3, action -> title); } break; case 'm': { // toggle visibility of menu command long i = Melder_atoi (& title [1]); Praat_Command menuCommand = praat_getMenuCommand (i); if (! menuCommand) return 0; if (menuCommand -> hidden) praat_showMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title); else praat_hideMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title); } break; case 'e': { // execute action long i = Melder_atoi (& title [1]); Praat_Command action = praat_getAction (i); if (! action || ! action -> callback) return 0; if (action -> title) { UiHistory_write (U"\n"); UiHistory_write_colonize (action -> title); } if (action -> script) { try { DO_RunTheScriptFromAnyAddedMenuCommand (nullptr, 0, nullptr, action -> script, nullptr, nullptr, false, nullptr); } catch (MelderError) { Melder_flushError (U"Command not executed."); } } else { try { action -> callback (nullptr, 0, nullptr, nullptr, nullptr, nullptr, false, nullptr); } catch (MelderError) { Melder_flushError (U"Command not executed."); } } praat_updateSelection (); } break; case 'p': { // perform menu command long i = Melder_atoi (& title [1]); Praat_Command menuCommand = praat_getMenuCommand (i); if (! menuCommand || ! menuCommand -> callback) return 0; if (menuCommand -> title) { UiHistory_write (U"\n"); UiHistory_write_colonize (menuCommand -> title); } if (menuCommand -> script) { try { DO_RunTheScriptFromAnyAddedMenuCommand (nullptr, 0, nullptr, menuCommand -> script, nullptr, nullptr, false, nullptr); } catch (MelderError) { Melder_flushError (U"Command not executed."); } } else { try { menuCommand -> callback (nullptr, 0, nullptr, nullptr, nullptr, nullptr, false, nullptr); } catch (MelderError) { Melder_flushError (U"Command not executed."); } } praat_updateSelection (); } break; default: break; } return 0; }
int ButtonEditor::goToPage (const wchar_t *title) { if (! title || ! title [0]) return 0; if (wcsequ (title, L"Buttons")) return 1; switch (title [0]) { case 'a': { /* Toggle visibility of action.*/ long i = wcstol (& title [1], NULL, 10); praat_Command action = praat_getAction (i); if (! action) return 0; if (action -> hidden) praat_showAction (action -> class1, action -> class2, action -> class3, action -> title); else praat_hideAction (action -> class1, action -> class2, action -> class3, action -> title); } break; case 'm': { /* Toggle visibility of menu command. */ long i = wcstol (& title [1], NULL, 10); praat_Command menuCommand = praat_getMenuCommand (i); if (! menuCommand) return 0; if (menuCommand -> hidden) praat_showMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title); else praat_hideMenuCommand (menuCommand -> window, menuCommand -> menu, menuCommand -> title); } break; case 'e': { /* Execute action. */ long i = wcstol (& title [1], NULL, 10); praat_Command action = praat_getAction (i); if (! action || ! action -> callback) return 0; if (action -> title) { UiForm::history.write (L"\n"); UiForm::history.write (action -> title); } if (action -> script) { if (! DO_RunTheScriptFromAnyAddedMenuCommand (NULL, action -> script, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed."); } else { if (! action -> callback (NULL, NULL, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed."); } praat_updateSelection (); } break; case 'p': { /* Perform menu command. */ long i = wcstol (& title [1], NULL, 10); praat_Command menuCommand = praat_getMenuCommand (i); if (! menuCommand || ! menuCommand -> callback) return 0; if (menuCommand -> title) { UiForm::history.write (L"\n"); UiForm::history.write (menuCommand -> title); } if (menuCommand -> script) { if (! DO_RunTheScriptFromAnyAddedMenuCommand (NULL, menuCommand -> script, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed."); } else { if (! menuCommand -> callback (NULL, NULL, NULL, NULL, false, NULL)) Melder_flushError ("Command not executed."); } praat_updateSelection (); } break; default: break; } return 0; }