| 1 | /* praat_logo.cpp |
| 2 | * |
| 3 | * Copyright (C) 1996-2024 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 "praatP.h"cxx . . $ `<file>/sys/praatP.h`/ |
| 20 | #include "Picture.h"cxx . . $ `<file>/sys/Picture.h`/ |
| 21 | |
| 22 | static void logo_defaultDrawcxx . . $ logo_defaultDraw(2d838ed765120c5d). (Graphicscxx . . $ Graphics# g) { |
| 23 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (g, Melder_MAGENTAcxx . . $ Melder_MAGENTA.); |
| 24 | Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (g, 0.0, 1.0, 0.0, 1.0); |
| 25 | Graphics_setGreycxx . . $ Graphics_setGrey(2514a1c07b6be5e2). (g, 0.5); |
| 26 | Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (g, 0.05, 0.95, 0.1, 0.9); |
| 27 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (g, Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 28 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (g, Melder_YELLOWcxx . . $ Melder_YELLOW.); |
| 29 | Graphics_setFontcxx . . $ Graphics_setFont(f6e617e53e6c04dc). (g, kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.); |
| 30 | Graphics_setFontSizecxx . . $ Graphics_setFontSize(2514a1c07b6be5e2). (g, 24); |
| 31 | Graphics_setFontStylecxx . . $ Graphics_setFontStyle(9abe41586e87648d). (g, Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!); |
| 32 | Graphics_setUnderscoreIsSubscriptcxx . . $ Graphics_setUnderscoreIsSubscript(b5ae742079ad918c). (g, false); // because program names may contain underscores |
| 33 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, 0.5, 0.6, Melder_upperCaseAppNamecxx . . $ Melder_upperCaseAppName(1912f6684645c851).()); |
| 34 | Graphics_setFontStylecxx . . $ Graphics_setFontStyle(9abe41586e87648d). (g, 0); |
| 35 | Graphics_setFontSizecxx . . $ Graphics_setFontSize(2514a1c07b6be5e2). (g, 12); |
| 36 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (g, 0.5, 0.25, U"\\s{Built on the} %%Praat shell%\\s{,© Paul Boersma, 1992-2024"); |
| 37 | } |
| 38 | |
| 39 | static structcxx . . $ $anonymous_type_2c60a9130c8683e0_0# { |
| 40 | double width_mmcxx . . $ $anonymous_type_2c60a9130c8683e0_0#width_mm., height_mmcxx . . $ $anonymous_type_2c60a9130c8683e0_0#height_mm.; |
| 41 | void (*drawcxx . . $ $anonymous_type_2c60a9130c8683e0_0#draw.) (Graphicscxx . . $ Graphics# g); |
| 42 | GuiDialogcxx . . $ GuiDialog# diacxx . . $ $anonymous_type_2c60a9130c8683e0_0#dia.; |
| 43 | GuiFormcxx . . $ GuiForm# formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form.; |
| 44 | GuiDrawingAreacxx . . $ GuiDrawingArea# drawingAreacxx . . $ $anonymous_type_2c60a9130c8683e0_0#drawingArea.; |
| 45 | autoGraphicscxx . . $ autoGraphics# graphicscxx . . $ $anonymous_type_2c60a9130c8683e0_0#graphics.; |
| 46 | } theLogocxx . . $ theLogo. = { 90, 40, logo_defaultDrawcxx . . $ logo_defaultDraw(2d838ed765120c5d). }; |
| 47 | |
| 48 | void praat_setLogocxx . . $ praat_setLogo(e52f01cf3c7c2f40). (double width_mm, double height_mm, void (*draw) (Graphicscxx . . $ Graphics# g)) { |
| 49 | theLogocxx . . $ theLogo..width_mmcxx . . $ $anonymous_type_2c60a9130c8683e0_0#width_mm. = width_mm; |
| 50 | theLogocxx . . $ theLogo..height_mmcxx . . $ $anonymous_type_2c60a9130c8683e0_0#height_mm. = height_mm; |
| 51 | theLogocxx . . $ theLogo..drawcxx . . $ $anonymous_type_2c60a9130c8683e0_0#draw. = draw; |
| 52 | } |
| 53 | |
| 54 | static void gui_drawingarea_cb_exposecxx . . $ gui_drawingarea_cb_expose(27f28a6e9e502c36). (Thingcxx . . $ Thing# /* me */, GuiDrawingArea_ExposeEventcxx . . $ GuiDrawingArea_ExposeEvent# /* event */) { |
| 55 | theLogocxx . . $ theLogo..drawcxx . . $ $anonymous_type_2c60a9130c8683e0_0#draw. (theLogocxx . . $ theLogo..graphicscxx . . $ $anonymous_type_2c60a9130c8683e0_0#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 56 | } |
| 57 | |
| 58 | static void gui_drawingarea_cb_mousecxx . . $ gui_drawingarea_cb_mouse(822f5f20d7269538). (Thingcxx . . $ Thing# /* me */, GuiDrawingArea_MouseEventcxx . . $ GuiDrawingArea_MouseEvent# /* event */) { |
| 59 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (theLogocxx . . $ theLogo..formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form.); |
| 60 | } |
| 61 | |
| 62 | static void gui_cb_goAwaycxx . . $ gui_cb_goAway(97cddd01752945f6). (Thingcxx . . $ Thing# /* boss */) { |
| 63 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (theLogocxx . . $ theLogo..formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form.); |
| 64 | } |
| 65 | |
| 66 | void praat_showLogocxx . . $ praat_showLogo(49f6e7a06ebc5aa8). () { |
| 67 | if (theCurrentPraatApplicationcxx . . $ theCurrentPraatApplication. -> batchcxx . . $ structPraatApplication#batch. || ! theLogocxx . . $ theLogo..drawcxx . . $ $anonymous_type_2c60a9130c8683e0_0#draw.) |
| 68 | return; |
| 69 | if (! theLogocxx . . $ theLogo..diacxx . . $ $anonymous_type_2c60a9130c8683e0_0#dia.) { |
| 70 | int width = theLogocxx . . $ theLogo..width_mmcxx . . $ $anonymous_type_2c60a9130c8683e0_0#width_mm. / 25.4 * Gui_getResolutioncxx . . $ Gui_getResolution(dedf1e9b1c614a07). (nullptr); |
| 71 | int height = theLogocxx . . $ theLogo..height_mmcxx . . $ $anonymous_type_2c60a9130c8683e0_0#height_mm. / 25.4 * Gui_getResolutioncxx . . $ Gui_getResolution(dedf1e9b1c614a07). (nullptr); |
| 72 | theLogocxx . . $ theLogo..diacxx . . $ $anonymous_type_2c60a9130c8683e0_0#dia. = GuiDialog_createcxx . . $ GuiDialog_create(9df51e4563bc0c17). (theCurrentPraatApplicationcxx . . $ theCurrentPraatApplication. -> topShellcxx . . $ structPraatApplication#topShell., 100, 100, width, height, |
| 73 | U"About", gui_cb_goAwaycxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptr, GuiDialog_Modalitycxx . . $ GuiDialog_Modality#::MODELESScxx . . $ GuiDialog_Modality#MODELESS.); |
| 74 | theLogocxx . . $ theLogo..formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form. = theLogocxx . . $ theLogo..diacxx . . $ $anonymous_type_2c60a9130c8683e0_0#dia.; |
| 75 | theLogocxx . . $ theLogo..drawingAreacxx . . $ $anonymous_type_2c60a9130c8683e0_0#drawingArea. = GuiDrawingArea_createShowncxx . . $ GuiDrawingArea_createShown(5a210e61ba6a237d). (theLogocxx . . $ theLogo..formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form., 0, width, 0, height, |
| 76 | gui_drawingarea_cb_exposecxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., gui_drawingarea_cb_mousecxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptr, 0); |
| 77 | /* |
| 78 | Note about ordering the following three statements (2021-01-20). |
| 79 | On some platforms (e.g. on macOS 10.10, but not 10.15), showing entails immediate drawing. |
| 80 | So the Graphics has to exist before that. |
| 81 | (It is possible that the *native* graphics *context* is created later.) |
| 82 | */ |
| 83 | theLogocxx . . $ theLogo..graphicscxx . . $ $anonymous_type_2c60a9130c8683e0_0#graphics. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Graphics_create_xmdrawingareacxx . . $ Graphics_create_xmdrawingarea(51b1c75797a7dddf). (theLogocxx . . $ theLogo..drawingAreacxx . . $ $anonymous_type_2c60a9130c8683e0_0#drawingArea.); |
| 84 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (theLogocxx . . $ theLogo..formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form.); |
| 85 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (theLogocxx . . $ theLogo..diacxx . . $ $anonymous_type_2c60a9130c8683e0_0#dia.); |
| 86 | } else { |
| 87 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (theLogocxx . . $ theLogo..formcxx . . $ $anonymous_type_2c60a9130c8683e0_0#form.); |
| 88 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (theLogocxx . . $ theLogo..diacxx . . $ $anonymous_type_2c60a9130c8683e0_0#dia.); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /* End of file praat_logo.cpp */ |