| 1 |
/* praatP.h |
| 2 |
* |
| 3 |
* Copyright (C) 1992-2007,2009-2025 Paul Boersma |
| 4 |
* |
| 5 |
* This code is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This code is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
* See the GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "praat.h" |
| 20 |
|
| 21 |
void praat_addActionScript (conststring32 className1, integer n1, conststring32 className2, integer n2, conststring32 className3, integer n3, |
| 22 |
conststring32 title, conststring32 after, integer depth, conststring32 script); |
| 23 |
/* No strings may be null; unspecify them by giving an empty string. 'title' and 'script' are deep-copied. */ |
| 24 |
|
| 25 |
void praat_removeAction_classNames (conststring32 className1, conststring32 className2, |
| 26 |
conststring32 className3, conststring32 title); |
| 27 |
/* No arguments may be null; unspecify them by giving an empty string. */ |
| 28 |
|
| 29 |
void praat_hideAction (ClassInfo class1, ClassInfo class2, ClassInfo class3, conststring32 title); |
| 30 |
void praat_hideAction_classNames (conststring32 className1, conststring32 className2, |
| 31 |
conststring32 className3, conststring32 title); |
| 32 |
void praat_showAction (ClassInfo class1, ClassInfo class2, ClassInfo class3, conststring32 title); |
| 33 |
void praat_showAction_classNames (conststring32 className1, conststring32 className2, |
| 34 |
conststring32 className3, conststring32 title); |
| 35 |
void praat_sortActions (); |
| 36 |
|
| 37 |
void praat_addMenuCommandScript (conststring32 window, conststring32 menu, conststring32 title, |
| 38 |
conststring32 after, integer depth, conststring32 script); |
| 39 |
/* All strings are deep-copied and may not be null; unspecify them by giving an empty string. */ |
| 40 |
|
| 41 |
/* |
| 42 |
For the Praat objects window: |
| 43 |
'window' is "Objects", 'menu' is "Praat", "New", "Open", "Help", "Settings", "Goodies", or "Technical". |
| 44 |
For the Praat picture window: |
| 45 |
'window' is "Picture", 'menu' is "File", "Edit", "Margins", "World", "Select", "Pen", "Font", or "Help". |
| 46 |
*/ |
| 47 |
void praat_hideMenuCommand (conststring32 window, conststring32 menu, conststring32 title); |
| 48 |
void praat_showMenuCommand (conststring32 window, conststring32 menu, conststring32 title); |
| 49 |
void praat_saveAddedMenuCommands (MelderString *buffer); |
| 50 |
void praat_saveToggledMenuCommands (MelderString *buffer); |
| 51 |
#define praat_addFixedButtonCommand(p,t,c,x,y) praat_addFixedButtonCommand_ (p, t, c, U"" #c, x, y) |
| 52 |
void praat_addFixedButtonCommand_ (GuiForm parent, conststring32 title, UiCallback callback, conststring32 nameOfCallback, int x, int y); |
| 53 |
void praat_sensitivizeFixedButtonCommand (conststring32 title, bool sensitive); |
| 54 |
void praat_sortMenuCommands (); |
| 55 |
|
| 56 |
#define praat_MAXNUM_MENUS 20 /* Maximum number of added New, Open, Save, or Help menus. */ |
| 57 |
#define praat_MAXNUM_FILE_TYPE_RECOGNIZERS 50 /* File types recognizable by 'Read from file...'. */ |
| 58 |
|
| 59 |
Thing_define (Praat_Command, Thing) { |
| 60 |
ClassInfo class1, class2, class3, class4; // selected classes |
| 61 |
integer n1, n2, n3, n4; // number of selected objects of each class; 0 means "any number" |
| 62 |
autostring32 title; // button text = command text |
| 63 |
UiCallback callback; // multi-purpose |
| 64 |
/* If both UiCallback::sendingForm and sendingString are null, this routine is an activate callback; |
| 65 |
you should directly execute the command, or call UiForm_do(dialog) if you need arguments; |
| 66 |
UiForm_do will call this routine again with sendingForm = dialog. */ |
| 67 |
/* If sendingForm exists, this routine is an ok callback, |
| 68 |
and you should execute the command. */ |
| 69 |
/* If sendingString exists (apparently from a command file), |
| 70 |
UiForm_parseString should be called, which will call this routine again with sendingForm. */ |
| 71 |
/* All of these things are normally taken care of by the macros defined in praatM.h. */ |
| 72 |
conststring32 nameOfCallback; |
| 73 |
signed char |
| 74 |
visible, // do the selected classes match class1, class2, class3 and class4? |
| 75 |
executable, // is the command actually executable? I.e. isn't the button greyed out? |
| 76 |
depth, // 0 = command in main menu, 1 = command in submenu, 2 = command in submenu of submenu |
| 77 |
hidden, // this can change when Praat is running, even from the start-up file |
| 78 |
toggled, // did the hiddenness change when Praat was running? The factory value for "hidden" is (hidden != toggled) |
| 79 |
phase, |
| 80 |
unhidable, |
| 81 |
attractive, |
| 82 |
noApi, // do not include in a library API ("View & Edit", help commands...) |
| 83 |
forceApi, // include in a library API even if this button is hidden by default ("Record Sound (fixed time)...") |
| 84 |
added; // added by a script |
| 85 |
integer deprecationYear; |
| 86 |
GuiThing button; |
| 87 |
autostring32 window, menu; |
| 88 |
autostring32 script; // if 'callback' equals DO_RunTheScriptFromAnyAddedMenuCommand |
| 89 |
autostring32 after; // title of previous command, often null; if starting with an asterisk (deprecation), then a reference to the replacement |
| 90 |
integer uniqueID; // for sorting the added commands |
| 91 |
integer sortingTail; |
| 92 |
}; |
| 93 |
|
| 94 |
#define praat_STARTING_UP 1 |
| 95 |
#define praat_READING_BUTTONS 2 |
| 96 |
#define praat_HANDLING_EVENTS 3 |
| 97 |
|
| 98 |
integer praat_numberOfSelected (ClassInfo klas); |
| 99 |
integer praat_idOfSelected (ClassInfo klas, integer inplace); |
| 100 |
autoVEC praat_idsOfAllSelected (ClassInfo klas); |
| 101 |
char32 * praat_nameOfSelected (ClassInfo klas, integer inplace); |
| 102 |
autoSTRVEC praat_namesOfAllSelected (ClassInfo klas); |
| 103 |
|
| 104 |
/* Used by praat.cpp; defined in praat_picture.cpp. |
| 105 |
*/ |
| 106 |
void praat_picture_init (bool showPictureWindowAtStartUp); |
| 107 |
void praat_picture_exit (); |
| 108 |
|
| 109 |
void praat_picture_prefs (); |
| 110 |
void praat_picture_prefsChanged (); |
| 111 |
/* Praat shell tells Picture window that preferences have been changed |
| 112 |
(after reading the prefs file). |
| 113 |
Picture window will update the font menu. |
| 114 |
*/ |
| 115 |
GuiMenu praat_picture_resolveMenu (conststring32 menu); |
| 116 |
|
| 117 |
/* The following routines are a bit private (used by praat_script.cpp). */ |
| 118 |
/* If you must call them, follow them by praat_show (). */ |
| 119 |
void praat_deselect (integer i); |
| 120 |
void praat_deselectAll (); |
| 121 |
void praat_select (integer i); |
| 122 |
void praat_selectAll (); |
| 123 |
|
| 124 |
void praat_list_background (); |
| 125 |
void praat_list_foreground (); // updates the list of objects after backgrounding |
| 126 |
void praat_background (); |
| 127 |
void praat_foreground (); |
| 128 |
Editor praat_findEditorFromString (conststring32 string); |
| 129 |
Editor praat_findEditorById (integer id); |
| 130 |
|
| 131 |
void praat_showLogo (); |
| 132 |
|
| 133 |
/* Communication with praat_menuCommands.cpp: */ |
| 134 |
void praat_menuCommands_exit_optimizeByLeaking (); |
| 135 |
int praat_doMenuCommand (conststring32 command, conststring32 arguments, Interpreter interpreter); // 0 = not found |
| 136 |
int praat_doMenuCommand (conststring32 command, integer narg, Stackel args, Interpreter interpreter); // 0 = not found |
| 137 |
integer praat_getNumberOfMenuCommands (); |
| 138 |
Praat_Command praat_getMenuCommand (integer i); |
| 139 |
|
| 140 |
/* Communication with praat_actions.cpp: */ |
| 141 |
void praat_actions_show (); |
| 142 |
void praat_actions_createWriteMenu (GuiWindow window); |
| 143 |
void praat_actions_exit_optimizeByLeaking (); |
| 144 |
void praat_actions_createDynamicMenu (GuiWindow window); |
| 145 |
void praat_saveAddedActions (MelderString *buffer); |
| 146 |
void praat_saveToggledActions (MelderString *buffer); |
| 147 |
int praat_doAction (conststring32 command, conststring32 arguments, Interpreter interpreter); // 0 = not found |
| 148 |
int praat_doAction (conststring32 command, integer narg, Stackel args, Interpreter interpreter); // 0 = not found |
| 149 |
integer praat_getNumberOfActions (); // for ButtonEditor |
| 150 |
Praat_Command praat_getAction (integer i); // for ButtonEditor |
| 151 |
|
| 152 |
/* Communication with praat_statistics.cpp: */ |
| 153 |
void praat_statistics_prefs (); // at init time |
| 154 |
void praat_statistics_prefsChanged (); // after reading prefs file |
| 155 |
void praat_statistics_exit (); // at exit time |
| 156 |
void praat_reportMemoryUse (); |
| 157 |
void praat_reportSystemProperties (); |
| 158 |
void praat_reportAppProperties (); |
| 159 |
void praat_reportGraphicalProperties (); |
| 160 |
void praat_reportIntegerProperties (); |
| 161 |
void praat_reportFloatingPointProperties (); |
| 162 |
void praat_reportTextProperties (); |
| 163 |
void praat_reportFontProperties (); |
| 164 |
|
| 165 |
/* Communication with praat_objectMenus.cpp: */ |
| 166 |
GuiMenu praat_objects_resolveMenu (conststring32 menu); |
| 167 |
void praat_addFixedButtons (GuiWindow window); |
| 168 |
void praat_addMenus (GuiWindow window); |
| 169 |
void praat_addMenus2 (); |
| 170 |
|
| 171 |
/* API creation: */ |
| 172 |
void praat_library_createC (bool isInHeaderFile, bool includeCreateAPI, bool includeReadAPI, bool includeSaveAPI, |
| 173 |
bool includeQueryAPI, bool includeModifyAPI, bool includeToAPI, |
| 174 |
bool includeRecordAPI, bool includePlayAPI, |
| 175 |
bool includeDrawAPI, bool includeHelpAPI, bool includeWindowAPI, |
| 176 |
bool includeDemoAPI); |
| 177 |
void praat_menuCommands_writeC (bool isInHeaderFile, bool includeCreateAPI, bool includeReadAPI, |
| 178 |
bool includeRecordAPI, bool includePlayAPI, bool includeDrawAPI, bool includeHelpAPI, bool includeWindowAPI); |
| 179 |
void praat_actions_writeC (bool isInHeaderFile, bool includeSaveAPI, |
| 180 |
bool includeQueryAPI, bool includeModifyAPI, bool includeToAPI, |
| 181 |
bool includePlayAPI, bool includeDrawAPI, bool includeHelpAPI, bool includeWindowAPI); |
| 182 |
|
| 183 |
void praat_cleanUpName (char32 *name); |
| 184 |
void praat_list_renameAndSelect (integer position, conststring32 name); |
| 185 |
|
| 186 |
inline struct PraatP { |
| 187 |
int argc; |
| 188 |
char **argv; |
| 189 |
int argumentNumber; |
| 190 |
struct { |
| 191 |
bool hidePicture; // hide the Picture window at start-up |
| 192 |
} commandLineOptions; |
| 193 |
bool fileNamesCameInByDropping, foundTheOpenSwitch, foundTheRunSwitch, foundTheSendSwitch, foundTheSendOrFormSwitch, foundTheNewSwitch; |
| 194 |
bool userWantsToOpen, userWantsToSend, userWantsToSendOrForm, userWantsExistingInstance, hasFinishedLaunching; |
| 195 |
bool fullTrust; |
| 196 |
bool dontUsePictureWindow; // see praat_dontUsePictureWindow () |
| 197 |
bool ignorePreferenceFiles, ignorePlugins; |
| 198 |
bool hasCommandLineInput; |
| 199 |
GuiWindow menuBar; |
| 200 |
int phase; |
| 201 |
} praatP; |
| 202 |
|
| 203 |
struct autoPraatBackground { |
| 204 |
autoPraatBackground () { praat_background (); } |
| 205 |
~autoPraatBackground () { try { praat_foreground (); } catch (...) { Melder_clearError (); } } // BUG if called during error time |
| 206 |
}; |
| 207 |
|
| 208 |
/* End of file praatP.h */ |