Debian Codegraph @

foned/TextGridEditor.cpp

raw symbols SCIP
1 /* TextGridEditor.cpp
2 *
3 * Copyright (C) 1992-2022 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
19 #include "TextGridEditor.h"
20 #include "EditorM.h"
21
22 Thing_implement (TextGridEditor, FunctionEditor, 0);
23
24 #include "Prefs_define.h"
25 #include "TextGridEditor_prefs.h"
26 #include "Prefs_install.h"
27 #include "TextGridEditor_prefs.h"
28 #include "Prefs_copyToInstance.h"
29 #include "TextGridEditor_prefs.h"
30
31 static void menu_cb_TextGridEditorHelp (TextGridEditor, EDITOR_ARGS) { HELP (U"TextGridEditor") }
32 static void menu_cb_AboutSpecialSymbols (TextGridEditor, EDITOR_ARGS) { HELP (U"Special symbols") }
33 static void menu_cb_PhoneticSymbols (TextGridEditor, EDITOR_ARGS) { HELP (U"Phonetic symbols") }
34 static void menu_cb_AboutTextStyles (TextGridEditor, EDITOR_ARGS) { HELP (U"Text styles") }
35
36 void structTextGridEditor :: v_createMenuItems_help (EditorMenu menu) {
37 TextGridEditor_Parent :: v_createMenuItems_help (menu);
38 EditorMenu_addCommand (menu, U"TextGridEditor help", '?', menu_cb_TextGridEditorHelp);
39 EditorMenu_addCommand (menu, U"About special symbols", 0, menu_cb_AboutSpecialSymbols);
40 EditorMenu_addCommand (menu, U"Phonetic symbols", 0, menu_cb_PhoneticSymbols);
41 EditorMenu_addCommand (menu, U"About text styles", 0, menu_cb_AboutTextStyles);
42 }
43
44 autoTextGridEditor TextGridEditor_create (conststring32 title, TextGrid textGrid,
45 SampledXY optionalSoundOrLongSound, SpellingChecker spellingChecker, conststring32 callbackSocket)
46 {
47 try {
48 autoTextGridEditor me = Thing_new (TextGridEditor);
49 my textGridArea() = TextGridArea_create (true, nullptr, me.get());
50 if (optionalSoundOrLongSound) {
51 Melder_assert (optionalSoundOrLongSound -> ny > 0);
52 if (Thing_isa (optionalSoundOrLongSound, classSound))
53 my soundArea() = SoundArea_create (false, static_cast <Sound> (optionalSoundOrLongSound), me.get());
54 else
55 my soundArea() = LongSoundArea_create (false, static_cast <LongSound> (optionalSoundOrLongSound), me.get());
56 my soundAnalysisArea() = SoundAnalysisArea_create (false, nullptr, me.get());
57 my textGridArea() -> borrowedSoundArea = my soundArea().get();
58 my textGridArea() -> borrowedSoundAnalysisArea = my soundAnalysisArea().get();
59 }
60 my textGridArea() -> spellingChecker = spellingChecker;
61 my callbackSocket = Melder_dup (callbackSocket);
62 FunctionEditor_init (me.get(), title, textGrid);
63
64 Melder_assert (isdefined (my startSelection)); // precondition of v_updateText()
65 my v_updateText (); // to reflect changed tier selection AND to get first text; BUG: should not be needed
66 if (spellingChecker)
67 GuiText_setSelection (my textArea, 0, 0);
68 if (optionalSoundOrLongSound &&
69 optionalSoundOrLongSound -> xmin == 0.0 &&
70 my textGrid() -> xmin != 0.0 &&
71 my textGrid() -> xmax > optionalSoundOrLongSound -> xmax
72 )
73 Melder_warning (U"The time domain of the TextGrid (starting at ",
74 Melder_fixed (my textGrid() -> xmin, 6), U" seconds) does not overlap with that of the sound "
75 U"(which starts at 0 seconds).\nIf you want to repair this, you can select the TextGrid "
76 U"and choose “Shift times to...” from the Modify menu "
77 U"to shift the starting time of the TextGrid to zero.");
78 return me;
79 } catch (MelderError) {
80 Melder_throw (U"TextGrid window not created.");
81 }
82 }
83
84 /* End of file TextGridEditor.cpp */