void praat_addAction4 (ClassInfo class1, int n1, ClassInfo class2, int n2, ClassInfo class3, int n3, ClassInfo class4, int n4, const wchar_t *title, const wchar_t *after, unsigned long flags, void (*callback) (UiForm, int, Stackel, const wchar_t *, Interpreter, const wchar_t *, bool, void *)) { try { int depth = flags, unhidable = FALSE, hidden = FALSE, key = 0, attractive = 0; unsigned long motifFlags = 0; if (flags > 7) { depth = ((flags & praat_DEPTH_7) >> 16); unhidable = (flags & praat_UNHIDABLE) != 0; hidden = (flags & praat_HIDDEN) != 0 && ! unhidable; key = flags & 0x000000FF; motifFlags = key ? flags & (0x002000FF | GuiMenu_BUTTON_STATE_MASK) : flags & GuiMenu_BUTTON_STATE_MASK; attractive = (motifFlags & praat_ATTRACTIVE) != 0; } fixSelectionSpecification (& class1, & n1, & class2, & n2, & class3, & n3); if (callback && ! title) Melder_throw ("An action command with callback has no title. Classes: ", class1 ? class1 -> className : L"", L" ", class2 ? class2 -> className : L"", L" ", class3 ? class3 -> className : L"", L" ", class4 ? class4 -> className : L"", L"."); if (! class1) Melder_throw ("The action command \"", title, "\" has no first class."); /* * Determine the position of the new command. */ long position; if (after) { // search for existing command with same selection long found = lookUpMatchingAction (class1, class2, class3, class4, after); if (found == 0) Melder_throw ("The action command \"", title, "\" cannot be put after \"", after, "\",\n" "because the latter command does not exist."); position = found + 1; // after 'after' } else { position = theNumberOfActions + 1; // at end } /* * Increment the command area. */ if (theNumberOfActions >= praat_MAXNUM_LOOSE_COMMANDS) Melder_throw ("Too many action commands (maximum ", praat_MAXNUM_LOOSE_COMMANDS, ")."); theNumberOfActions += 1; /* * Make room for insertion. */ for (long i = theNumberOfActions; i > position; i --) theActions [i] = theActions [i - 1]; memset (& theActions [position], 0, sizeof (struct structPraat_Command)); /* * Insert new command. */ theActions [position]. class1 = class1; theActions [position]. n1 = n1; theActions [position]. class2 = class2; theActions [position]. n2 = n2; theActions [position]. class3 = class3; theActions [position]. n3 = n3; theActions [position]. class4 = class4; theActions [position]. n4 = n4; theActions [position]. title = Melder_wcsdup_f (title); theActions [position]. depth = depth; theActions [position]. callback = callback; /* NULL for a separator. */ theActions [position]. button = NULL; theActions [position]. script = NULL; theActions [position]. hidden = hidden; theActions [position]. unhidable = unhidable; theActions [position]. attractive = attractive; } catch (MelderError) {
void praat_addAction4 (ClassInfo class1, int n1, ClassInfo class2, int n2, ClassInfo class3, int n3, ClassInfo class4, int n4, const char32 *title, const char32 *after, unsigned long flags, UiCallback callback) { try { int depth = flags, key = 0; bool unhidable = false, hidden = false, attractive = false; unsigned long motifFlags = 0; if (flags > 7) { depth = ((flags & praat_DEPTH_7) >> 16); unhidable = (flags & praat_UNHIDABLE) != 0; hidden = (flags & praat_HIDDEN) != 0 && ! unhidable; key = flags & 0x000000FF; motifFlags = key ? flags & (0x002000FF | GuiMenu_BUTTON_STATE_MASK) : flags & GuiMenu_BUTTON_STATE_MASK; attractive = (motifFlags & praat_ATTRACTIVE) != 0; } fixSelectionSpecification (& class1, & n1, & class2, & n2, & class3, & n3); if (callback && ! title) Melder_throw (U"An action command with callback has no title. Classes: ", class1 ? class1 -> className : U"", U" ", class2 ? class2 -> className : U"", U" ", class3 ? class3 -> className : U"", U" ", class4 ? class4 -> className : U"", U"."); if (! class1) Melder_throw (U"The action command \"", title, U"\" has no first class."); /* * Determine the position of the new command. */ long position; if (after) { // search for existing command with same selection long found = lookUpMatchingAction (class1, class2, class3, class4, after); if (found == 0) Melder_throw (U"The action command \"", title, U"\" cannot be put after \"", after, U"\",\n" U"because the latter command does not exist."); position = found + 1; // after 'after' } else { position = theActions -> size + 1; // at end } /* * Make new command. */ autoPraat_Command action = Thing_new (Praat_Command); action -> class1 = class1; action -> n1 = n1; action -> class2 = class2; action -> n2 = n2; action -> class3 = class3; action -> n3 = n3; action -> class4 = class4; action -> n4 = n4; action -> title = Melder_dup_f (title); action -> depth = depth; action -> callback = callback; // null for a separator action -> button = nullptr; action -> script = nullptr; action -> hidden = hidden; action -> unhidable = unhidable; action -> attractive = attractive; /* * Insert new command. */ Ordered_addItemAtPosition_move (theActions, action.move(), position); } catch (MelderError) {