| 1 | #cxx . . $ `<file>/sys/Picture.h`/ifndef _Picture_h_ |
| 2 | #define _Picture_h_cxx . . $ `sys/Picture.h:2:9`! |
| 3 | /* Picture.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2005,2007-2016,2018,2020,2022,2025 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* A self-recording picture inside a DrawingArea widget. |
| 22 | All drawing is kept in a Graphics. |
| 23 | If the picture is sensitive, |
| 24 | the user can select the viewport by dragging the mouse across the drawing area. |
| 25 | If the viewport is smaller than the entire drawing area, it is highlighted. |
| 26 | Usage: |
| 27 | Do not use the workstation Graphics routines, |
| 28 | like clearWs, flushWs, closeWs, updateWs, setWsViewport. |
| 29 | Example: |
| 30 | autoPicture p = Picture_create (myDrawingArea); |
| 31 | Graphics g = Picture_peekGraphics (p.get()); |
| 32 | Graphics_setTextAlignment (g, Graphics_CENTRE, Graphics_HALF); |
| 33 | Graphics_text (g, 0.5, 0.7, U"Hello"); |
| 34 | Graphics_text (g, 0.5, 0.6, U"there"); |
| 35 | Graphics_text (g, 0.5, 0.3, U"Goodbye"); |
| 36 | Picture_writeToPngFile_300 (p, U"HelloGoodbye.png"); |
| 37 | Picture_print (p.get()); |
| 38 | */ |
| 39 | |
| 40 | #include "Gui.h"cxx . . $ `<file>/sys/Gui.h`/ |
| 41 | |
| 42 | Thing_definecxx . . $ `sys/Thing.h:60:9`! (Picture, Thing) { |
| 43 | GuiDrawingAreacxx . . $ GuiDrawingArea# drawingAreacxx . . $ structPicture#drawingArea.; |
| 44 | autoGraphicscxx . . $ autoGraphics# graphicscxx . . $ structPicture#graphics., selectionGraphicscxx . . $ structPicture#selectionGraphics.; |
| 45 | bool sensitivecxx . . $ structPicture#sensitive.; |
| 46 | double selx1cxx . . $ structPicture#selx1., selx2cxx . . $ structPicture#selx2., sely1cxx . . $ structPicture#sely1., sely2cxx . . $ structPicture#sely2.; // selection in NDC co-ordinates |
| 47 | void (*selectionChangedCallbackcxx . . $ structPicture#selectionChangedCallback.) (Picturecxx . . $ Picture#, void *, double, double, double, double); |
| 48 | void *selectionChangedClosurecxx . . $ structPicture#selectionChangedClosure.; |
| 49 | bool mouseSelectsInnerViewportcxx . . $ structPicture#mouseSelectsInnerViewport.; |
| 50 | }; |
| 51 | |
| 52 | /* |
| 53 | The drawing area is a rectangle measuring 60x60 inches. |
| 54 | */ |
| 55 | constexpr double Picture_WIDTHcxx . . $ Picture_WIDTH. = 60.0; |
| 56 | constexpr double Picture_HEIGHTcxx . . $ Picture_HEIGHT. = 60.0; |
| 57 | |
| 58 | autoPicturecxx . . $ autoPicture# Picture_createcxx . . $ Picture_create(536635984768e764). (GuiDrawingAreacxx . . $ GuiDrawingArea# drawingArea, bool sensitive); |
| 59 | /* |
| 60 | Function: |
| 61 | create an empty self-recording picture inside 'drawingArea'. |
| 62 | Precondition: |
| 63 | 'drawingArea' must have been realized. |
| 64 | Postconditions: |
| 65 | a Graphics has been created from Graphics_create_macintosh or Graphics_create_xwindow; |
| 66 | the workstation viewport of this Graphics is [0, 1] x [0, 1]; |
| 67 | selection is [0, 1] x [0, 1] (NDC), which is invisible; |
| 68 | */ |
| 69 | |
| 70 | Graphicscxx . . $ Graphics# Picture_peekGraphicscxx . . $ Picture_peekGraphics(ef69ca22fe2c9ea5). (Picturecxx . . $ Picture# me); |
| 71 | /* |
| 72 | Function: |
| 73 | return the Graphics object. |
| 74 | Usage: |
| 75 | send the graphics output that you want to be in the picture to this Graphics, |
| 76 | bracketed by calls to Picture_startRecording and Picture_stopRecording. |
| 77 | */ |
| 78 | |
| 79 | void Picture_setSelectionChangedCallbackcxx . . $ Picture_setSelectionChangedCallback(aeaca41c654adde8). (Picturecxx . . $ Picture# me, |
| 80 | void (*selectionChangedCallback) (Picturecxx . . $ Picture#, void *closure, |
| 81 | double x1NDC, double x2NDC, double y1NDC, double y2NDC), |
| 82 | void *selectionChangedClosure); |
| 83 | |
| 84 | void Picture_setMouseSelectsInnerViewportcxx . . $ Picture_setMouseSelectsInnerViewport(70425a64acc38f07). (Picturecxx . . $ Picture# me, int mouseSelectsInnerViewport); |
| 85 | |
| 86 | void Picture_erasecxx . . $ Picture_erase(7c67b8e8e5971dca). (Picturecxx . . $ Picture# me); // clears the screen |
| 87 | |
| 88 | void Picture_writeToPraatPictureFilecxx . . $ Picture_writeToPraatPictureFile(1b125f360715d06e). (Picturecxx . . $ Picture# me, MelderFilecxx . . $ MelderFile# file); |
| 89 | void Picture_readFromPraatPictureFilecxx . . $ Picture_readFromPraatPictureFile(1b125f360715d06e). (Picturecxx . . $ Picture# me, MelderFilecxx . . $ MelderFile# file); |
| 90 | |
| 91 | void Picture_writeToEpsFilecxx . . $ Picture_writeToEpsFile(c33c9fc5ccd3eeb5). (Picturecxx . . $ Picture# me, MelderFilecxx . . $ MelderFile# file, bool includeFonts, bool useSilipaPS); |
| 92 | void Picture_writeToPdfFilecxx . . $ Picture_writeToPdfFile(1b125f360715d06e). (Picturecxx . . $ Picture# me, MelderFilecxx . . $ MelderFile# file); |
| 93 | void Picture_writeToPngFile_300cxx . . $ Picture_writeToPngFile_300(1b125f360715d06e). (Picturecxx . . $ Picture# me, MelderFilecxx . . $ MelderFile# file); |
| 94 | void Picture_writeToPngFile_600cxx . . $ Picture_writeToPngFile_600(1b125f360715d06e). (Picturecxx . . $ Picture# me, MelderFilecxx . . $ MelderFile# file); |
| 95 | |
| 96 | void Picture_printcxx . . $ Picture_print(7c67b8e8e5971dca). (Picturecxx . . $ Picture# me); |
| 97 | void Picture_printToPostScriptPrintercxx . . $ Picture_printToPostScriptPrinter(b9cb923ccc6f6360). (Picturecxx . . $ Picture# me, int spots, int paperSize, int rotation, double magnification); |
| 98 | #ifdef macintosh |
| 99 | void Picture_copyToClipboard (Picture me); |
| 100 | #endif |
| 101 | #ifdef _WIN32 |
| 102 | void Picture_copyToClipboard (Picture me); |
| 103 | void Picture_writeToWindowsMetafile (Picture me, MelderFile file); |
| 104 | #endif |
| 105 | |
| 106 | void Picture_setSelectioncxx . . $ Picture_setSelection(c185511737db1298). |
| 107 | (Picturecxx . . $ Picture# me, double x1NDC, double x2NDC, double y1NDC, double y2NDC); |
| 108 | /* |
| 109 | Preconditions: |
| 110 | 0.0 <= x1NDC < x2NDC <= 1.0; |
| 111 | 0.0 <= y1NDC < y2NDC <= 1.0; |
| 112 | */ |
| 113 | |
| 114 | /* End of file Picture.h */ |
| 115 | #endif // !_Picture_h_ |