praatP.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* praatP.h
  2. *
  3. * Copyright (C) 1992-2007,2009-2018 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 2 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. #include "praat.h"
  19. void praat_addActionScript (conststring32 className1, integer n1, conststring32 className2, integer n2, conststring32 className3, integer n3,
  20. conststring32 title, conststring32 after, integer depth, conststring32 script);
  21. /* No strings may be null; unspecify them by giving an empty string. 'title' and 'script' are deep-copied. */
  22. void praat_removeAction_classNames (conststring32 className1, conststring32 className2,
  23. conststring32 className3, conststring32 title);
  24. /* No arguments may be null; unspecify them by giving an empty string. */
  25. /* 'title' is deep-copied. */
  26. void praat_hideAction (ClassInfo class1, ClassInfo class2, ClassInfo class3, conststring32 title);
  27. void praat_hideAction_classNames (conststring32 className1, conststring32 className2,
  28. conststring32 className3, conststring32 title);
  29. void praat_showAction (ClassInfo class1, ClassInfo class2, ClassInfo class3, conststring32 title);
  30. void praat_showAction_classNames (conststring32 className1, conststring32 className2,
  31. conststring32 className3, conststring32 title);
  32. void praat_sortActions ();
  33. void praat_addMenuCommandScript (conststring32 window, conststring32 menu, conststring32 title,
  34. conststring32 after, integer depth, conststring32 script);
  35. /* All strings are deep-copied and may not be null; unspecify them by giving an empty string. */
  36. /*
  37. For the Praat objects window:
  38. 'window' is "Objects", 'menu' is "Praat", "New", "Open", "Help", "Preferences", "Goodies", or "Technical".
  39. For the Praat picture window:
  40. 'window' is "Picture", 'menu' is "File", "Edit", "Margins", "World", "Select", "Pen", "Font", or "Help".
  41. */
  42. void praat_hideMenuCommand (conststring32 window, conststring32 menu, conststring32 title);
  43. void praat_showMenuCommand (conststring32 window, conststring32 menu, conststring32 title);
  44. void praat_saveAddedMenuCommands (MelderString *buffer);
  45. void praat_saveToggledMenuCommands (MelderString *buffer);
  46. #define praat_addFixedButtonCommand(p,t,c,x,y) praat_addFixedButtonCommand_ (p, t, c, U"" #c, x, y)
  47. void praat_addFixedButtonCommand_ (GuiForm parent, conststring32 title, UiCallback callback, conststring32 nameOfCallback, int x, int y);
  48. void praat_sensitivizeFixedButtonCommand (conststring32 title, bool sensitive);
  49. void praat_sortMenuCommands ();
  50. #define praat_MAXNUM_MENUS 20 /* Maximum number of added New, Open, Save, or Help menus. */
  51. #define praat_MAXNUM_FILE_TYPE_RECOGNIZERS 50 /* File types recognizable by 'Read from file...'. */
  52. Thing_define (Praat_Command, Thing) {
  53. ClassInfo class1, class2, class3, class4; // selected classes
  54. integer n1, n2, n3, n4; // number of selected objects of each class; 0 means "any number"
  55. autostring32 title; // button text = command text
  56. UiCallback callback; // multi-purpose
  57. /* If both UiCallback::sendingForm and sendingString are null, this routine is an activate callback;
  58. you should directly execute the command, or call UiForm_do(dialog) if you need arguments;
  59. UiForm_do will call this routine again with sendingForm = dialog. */
  60. /* If sendingForm exists, this routine is an ok callback,
  61. and you should execute the command. */
  62. /* If sendingString exists (apparently from a command file),
  63. UiForm_parseString should be called, which will call this routine again with sendingForm. */
  64. /* All of these things are normally taken care of by the macros defined in praat.h. */
  65. conststring32 nameOfCallback;
  66. signed char
  67. visible, // do the selected classes match class1, class2, class3 and class4?
  68. executable, // is the command actually executable? I.e. isn't the button greyed out?
  69. depth, // 0 = command in main menu, 1 = command in submenu, 2 = command in submenu of submenu
  70. hidden, // this can change when Praat is running, even from the start-up file
  71. toggled, // did the hiddenness change when Praat was running? The factory value for "hidden" is (hidden != toggled)
  72. phase,
  73. unhidable,
  74. attractive,
  75. noApi, // do not include in a library API ("View & Edit", help commands...)
  76. forceApi; // include in a library API even if this button is hidden by default ("Record Sound (fixed time)...")
  77. integer deprecationYear;
  78. GuiThing button;
  79. autostring32 window, menu;
  80. autostring32 script; // if 'callback' equals DO_RunTheScriptFromAnyAddedMenuCommand
  81. autostring32 after; // title of previous command, often null; if starting with an asterisk (deprecation), then a reference to the replacement
  82. integer uniqueID; // for sorting the added commands
  83. integer sortingTail;
  84. };
  85. #define praat_STARTING_UP 1
  86. #define praat_READING_BUTTONS 2
  87. #define praat_HANDLING_EVENTS 3
  88. integer praat_numberOfSelected (ClassInfo klas);
  89. integer praat_idOfSelected (ClassInfo klas, integer inplace);
  90. autoVEC praat_idsOfAllSelected (ClassInfo klas);
  91. char32 * praat_nameOfSelected (ClassInfo klas, integer inplace);
  92. /* Used by praat.cpp; defined in praat_picture.cpp.
  93. */
  94. void praat_picture_init ();
  95. void praat_picture_exit ();
  96. void praat_picture_prefs ();
  97. void praat_picture_prefsChanged ();
  98. /* Praat shell tells Picture window that preferences have been changed
  99. (after reading the prefs file).
  100. Picture window will update the font menu.
  101. */
  102. GuiMenu praat_picture_resolveMenu (conststring32 menu);
  103. void praat_picture_background ();
  104. void praat_picture_foreground ();
  105. /* The following routines are a bit private (used by praat_script.cpp). */
  106. /* If you must call them, follow them by praat_show (). */
  107. void praat_deselect (int i);
  108. void praat_deselectAll ();
  109. void praat_select (int i);
  110. void praat_selectAll ();
  111. void praat_list_background ();
  112. void praat_list_foreground (); // updates the list of objects after backgrounding
  113. void praat_background ();
  114. void praat_foreground ();
  115. Editor praat_findEditorFromString (conststring32 string);
  116. Editor praat_findEditorById (integer id);
  117. void praat_showLogo (bool autoPopDown);
  118. /* Communication with praat_menuCommands.cpp: */
  119. void praat_menuCommands_init ();
  120. void praat_menuCommands_exit_optimizeByLeaking ();
  121. int praat_doMenuCommand (conststring32 command, conststring32 arguments, Interpreter interpreter); // 0 = not found
  122. int praat_doMenuCommand (conststring32 command, integer narg, Stackel args, Interpreter interpreter); // 0 = not found
  123. integer praat_getNumberOfMenuCommands ();
  124. Praat_Command praat_getMenuCommand (integer i);
  125. /* Communication with praat_actions.cpp: */
  126. void praat_actions_show ();
  127. void praat_actions_createWriteMenu (GuiWindow window);
  128. void praat_actions_init (); // creates space for action commands
  129. void praat_actions_exit_optimizeByLeaking ();
  130. void praat_actions_createDynamicMenu (GuiWindow window);
  131. void praat_saveAddedActions (MelderString *buffer);
  132. void praat_saveToggledActions (MelderString *buffer);
  133. int praat_doAction (conststring32 command, conststring32 arguments, Interpreter interpreter); // 0 = not found
  134. int praat_doAction (conststring32 command, integer narg, Stackel args, Interpreter interpreter); // 0 = not found
  135. integer praat_getNumberOfActions (); // for ButtonEditor
  136. Praat_Command praat_getAction (integer i); // for ButtonEditor
  137. /* Communication with praat_statistics.cpp: */
  138. void praat_statistics_prefs (); // at init time
  139. void praat_statistics_prefsChanged (); // after reading prefs file
  140. void praat_statistics_exit (); // at exit time
  141. void praat_reportMemoryUse ();
  142. void praat_reportSystemProperties ();
  143. void praat_reportGraphicalProperties ();
  144. void praat_reportIntegerProperties ();
  145. void praat_reportTextProperties ();
  146. /* Communication with praat_objectMenus.cpp: */
  147. GuiMenu praat_objects_resolveMenu (conststring32 menu);
  148. void praat_addFixedButtons (GuiWindow window);
  149. void praat_addMenus (GuiWindow window);
  150. void praat_addMenus2 ();
  151. /* API creation: */
  152. void praat_library_createC (bool isInHeaderFile, bool includeCreateAPI, bool includeReadAPI, bool includeSaveAPI,
  153. bool includeQueryAPI, bool includeModifyAPI, bool includeToAPI,
  154. bool includeRecordAPI, bool includePlayAPI,
  155. bool includeDrawAPI, bool includeHelpAPI, bool includeWindowAPI,
  156. bool includeDemoAPI);
  157. void praat_menuCommands_writeC (bool isInHeaderFile, bool includeCreateAPI, bool includeReadAPI,
  158. bool includeRecordAPI, bool includePlayAPI, bool includeDrawAPI, bool includeHelpAPI, bool includeWindowAPI);
  159. void praat_actions_writeC (bool isInHeaderFile, bool includeSaveAPI,
  160. bool includeQueryAPI, bool includeModifyAPI, bool includeToAPI,
  161. bool includePlayAPI, bool includeDrawAPI, bool includeHelpAPI, bool includeWindowAPI);
  162. void praat_cleanUpName (char32 *name);
  163. void praat_list_renameAndSelect (int position, conststring32 name);
  164. extern struct PraatP {
  165. int argc;
  166. char **argv;
  167. int argumentNumber;
  168. bool userWantsToOpen;
  169. bool dontUsePictureWindow; // see praat_dontUsePictureWindow ()
  170. bool ignorePreferenceFiles, ignorePlugins;
  171. bool hasCommandLineInput;
  172. autostring32 title;
  173. GuiWindow menuBar;
  174. int phase;
  175. Editor editor; // scripting environment
  176. } praatP;
  177. struct autoPraatBackground {
  178. autoPraatBackground () { praat_background (); }
  179. ~autoPraatBackground () { try { praat_foreground (); } catch (...) { Melder_clearError (); } }
  180. };
  181. /* End of file praatP.h */