Debian Codegraph @

sys/GraphicsScreen.cpp

raw symbols SCIP
1 /* GraphicsScreen.cpp
2 *
3 * Copyright (C) 1992-2025 Paul Boersma, 2013 Tom Naughton
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 "GraphicsP.h"cxx . . $ `<file>/sys/GraphicsP.h`/
20 #include "Printer.h"cxx . . $ `<file>/sys/Printer.h`/
21 #include "GuiP.h"cxx . . $ `<file>/sys/GuiP.h`/
22
23 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
24 #include <cairo/cairo-pdf.h>
25 static bool _GraphicsCairo_tryToInitializePangocxx . . $ _GraphicsCairo_tryToInitializePango(c9857a73d68e59ba). () {
26 return _GraphicsLin_tryToInitializeFontscxx . . $ _GraphicsLin_tryToInitializeFonts(c9857a73d68e59ba). ();
27 }
28 #elif gdi
29 //#include "winport_on.h"
30 #include <gdiplus.h>
31 //#include "winport_off.h"
32 //using namespace Gdiplus;
33 static bool _GraphicsWindows_tryToInitializeGdiPlus () {
34 Gdiplus::GdiplusStartupInput gdiplusStartupInput;
35 ULONG_PTR gdiplusToken;
36 GdiplusStartup (& gdiplusToken, & gdiplusStartupInput, nullptr);
37 return true;
38 }
39 #elif quartz
40 #include "macport_on.h"
41 static bool _GraphicsMacintosh_tryToInitializeQuartz () {
42 return _GraphicsMac_tryToInitializeFonts ();
43 }
44 #endif
45
46 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (GraphicsScreen, Graphics, 0);
47
48 void structGraphicsScreencxx . . $ structGraphicsScreen# :: v9_destroycxx . . $ structGraphicsScreen#v9_destroy(ced63f7c635d850d). () noexcept {
49 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
50 if (d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.) {
51 cairo_destroy (d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
52 d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = nullptr;
53 }
54 if (d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface.) {
55 cairo_surface_flush (d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface.);
56 if (d_isPngcxx . . $ structGraphicsScreen#d_isPng.) {
57 #if 1
58 cairo_surface_write_to_png (d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface., MelderFile_peekPath8cxx . . $ MelderFile_peekPath8(3a3888509ce82e67). (& d_filecxx . . $ structGraphicsScreen#d_file.));
59 #else
60 unsigned char *bitmap = cairo_image_surface_get_data (my d_cairoSurface); // peeking into the internal bits
61 // copy bitmap to PNG structure created with the PNG library
62 // save the PNG structure to a file
63 #endif
64 }
65 cairo_surface_destroy (d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface.);
66 }
67 #elif gdi
68 if (d_gdiGraphicsContext) {
69 SelectPen (d_gdiGraphicsContext, GetStockPen (BLACK_PEN));
70 SelectBrush (d_gdiGraphicsContext, GetStockBrush (NULL_BRUSH));
71 }
72 if (d_winPen) {
73 DeleteObject (d_winPen);
74 d_winPen = nullptr;
75 }
76 if (d_winBrush) {
77 DeleteObject (d_winBrush);
78 d_winBrush = nullptr;
79 }
80 if (d_isPng && d_gdiBitmap) {
81 trace (U"saving the filled bitmap to a PNG file");
82 /*
83 Deselect the bitmap from the device context (otherwise GetDIBits won't work).
84 */
85 //SelectBitmap (d_gdiGraphicsContext, nullptr);
86 //SelectBitmap (d_gdiGraphicsContext, CreateCompatibleBitmap (nullptr, 1, 1));
87
88 BITMAP bitmap;
89 GetObject (d_gdiBitmap, sizeof (BITMAP), & bitmap);
90 int width = bitmap. bmWidth, height = bitmap. bmHeight;
91 //int width = 3600, height = 3600;
92 trace (U"width ", width, U", height ", height);
93
94 /*
95 Get the bits from the HBITMAP;
96 */
97 struct { BITMAPINFOHEADER header; } bitmapInfo;
98 bitmapInfo. header.biSize = sizeof (BITMAPINFOHEADER);
99 bitmapInfo. header.biWidth = width;
100 bitmapInfo. header.biHeight = height;
101 bitmapInfo. header.biPlanes = 1;
102 bitmapInfo. header.biBitCount = 32;
103 bitmapInfo. header.biCompression = BI_RGB;
104 bitmapInfo. header.biSizeImage = 0;
105 bitmapInfo. header.biXPelsPerMeter = 0;
106 bitmapInfo. header.biYPelsPerMeter = 0;
107 bitmapInfo. header.biClrUsed = 0;
108 bitmapInfo. header.biClrImportant = 0;
109 unsigned char *bits = Melder_calloc (unsigned char, 4 * width * height);
110 //HANDLE handle = GlobalAlloc (GHND, 4 * width * height);
111 //unsigned char *bits = (unsigned char *) GlobalLock (handle);
112 int numberOfLinesScanned = GetDIBits (GetDC (nullptr), d_gdiBitmap, 0, height, bits, (BITMAPINFO *) & bitmapInfo, DIB_RGB_COLORS);
113 trace (numberOfLinesScanned, U" lines scanned");
114
115 trace (U"creating a savable bitmap");
116
117 //Gdiplus::Bitmap gdiplusBitmap (width, height, PixelFormat32bppARGB);
118 Gdiplus::Bitmap gdiplusBitmap ((BITMAPINFO *) & bitmapInfo, bits);
119 gdiplusBitmap. SetResolution (resolution, resolution);
120
121 trace (U"copying the device-independent bits to the savable bitmap.");
122
123 /*
124 for (integer irow = 1; irow <= height; irow ++) {
125 for (integer icol = 1; icol <= width; icol ++) {
126 unsigned char blue = *bits ++, green = *bits ++, red = *bits ++, alpha = 255 - *bits ++;
127 Gdiplus::Color gdiplusColour (alpha, red, green, blue);
128 gdiplusBitmap. SetPixel (icol - 1, height - irow, gdiplusColour);
129 }
130 }
131 */
132
133 trace (U"saving");
134
135 UINT numberOfImageEncoders, sizeOfImageEncoderArray;
136 Gdiplus::GetImageEncodersSize (& numberOfImageEncoders, & sizeOfImageEncoderArray);
137 Gdiplus::ImageCodecInfo *imageEncoderInfos = Melder_malloc (Gdiplus::ImageCodecInfo, sizeOfImageEncoderArray);
138 Gdiplus::GetImageEncoders (numberOfImageEncoders, sizeOfImageEncoderArray, imageEncoderInfos);
139 for (int iencoder = 0; iencoder < numberOfImageEncoders; iencoder ++) {
140 if (! wcscmp (imageEncoderInfos [iencoder]. MimeType, L"image/png")) {
141 gdiplusBitmap. Save (MelderFile_peekPathW (& our d_file),
142 & imageEncoderInfos [iencoder]. Clsid, nullptr);
143 }
144 }
145
146 trace (U"cleaning up");
147
148 Melder_free (imageEncoderInfos);
149 //bits -= 4 * width * height;
150 Melder_free (bits);
151 //GlobalUnlock (handle);
152 //GlobalFree (handle);
153 DeleteObject (d_gdiBitmap);
154 Melder_assert (d_gdiGraphicsContext);
155 DeleteDC (d_gdiGraphicsContext); // this was a memory leak before 5.3.83
156 }
157 /*
158 No ReleaseDC here, because we have not created it ourselves,
159 not even with GetDC. Is this a BUG?
160 */
161 d_gdiGraphicsContext = nullptr;
162 #elif quartz
163 if (! d_macView && ! d_isPng && d_macGraphicsContext) {
164 CGContextEndPage (d_macGraphicsContext);
165 CGContextRelease (d_macGraphicsContext);
166 }
167 if (d_isPng && d_macGraphicsContext) {
168 /*
169 Turn the offscreen bitmap into an image.
170 */
171 CGImageRef image = CGBitmapContextCreateImage (d_macGraphicsContext);
172 Melder_assert (image);
173 //CGContextRelease (d_macGraphicsContext);
174 /*
175 Create a dictionary with resolution properties.
176 */
177 CFTypeRef keys [2], values [2];
178 keys [0] = kCGImagePropertyDPIWidth;
179 keys [1] = kCGImagePropertyDPIHeight;
180 float resolution_float = resolution;
181 values [1] = values [0] = CFNumberCreate (nullptr, kCFNumberFloatType, & resolution_float);
182 CFDictionaryRef properties = CFDictionaryCreate (nullptr,
183 (const void **) keys, (const void **) values, 2,
184 & kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
185 Melder_assert (properties);
186
187 CFURLRef url = CFURLCreateWithFileSystemPath (nullptr,
188 (CFStringRef) MelderFile_peekPathCfstring (& d_file), kCFURLPOSIXPathStyle, false);
189 CGImageDestinationRef imageDestination = CGImageDestinationCreateWithURL (url, kUTTypePNG, 1, nullptr);
190 if (imageDestination) {
191 CGImageDestinationAddImage (imageDestination, image, properties);
192 CGImageDestinationFinalize (imageDestination);
193 CFRelease (imageDestination);
194 }
195 CGImageRelease (image);
196 CFRelease (properties);
197 CFRelease (url);
198 }
199 Melder_free (d_bits);
200 #endif
201 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"destroying parent");
202 GraphicsScreen_Parentcxx . . $ GraphicsScreen_Parent# :: v9_destroycxx . . $ structGraphics#v9_destroy(ced63f7c635d850d). ();
203 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"exit");
204 }
205
206 void structGraphicsScreencxx . . $ structGraphicsScreen# :: v_clearWscxx . . $ structGraphicsScreen#v_clearWs(49f6e7a06ebc5aa8). () {
207 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! && gtkcxx . . $ `sys/Gui.h:33:10`!
208 GdkRectangle rect;
209 if (ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. < ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC.) {
210 rect.x = ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC.;
211 rect.width = ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. - ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC.;
212 } else {
213 rect.x = ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC.;
214 rect.width = ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. - ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC.;
215 }
216 if (ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. < ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.) {
217 rect.y = ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC.;
218 rect.height = ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. - ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC.;
219 } else {
220 rect.y = ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.;
221 rect.height = ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. - ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.;
222 }
223 if (ourcxx . . $ `melder/melder.h:42:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.) {
224 cairo_set_source_rgb (ourcxx . . $ `melder/melder.h:42:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 1.0, 1.0, 1.0);
225 cairo_rectangle (ourcxx . . $ `melder/melder.h:42:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., rect.x, rect.y, rect.width, rect.height);
226 cairo_fill (ourcxx . . $ `melder/melder.h:42:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
227 cairo_set_source_rgb (ourcxx . . $ `melder/melder.h:42:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 0.0, 0.0, 0.0);
228 }
229 #elif gdi
230 RECT rect;
231 rect. left = rect. top = 0;
232 rect. right = d_x2DC - d_x1DC;
233 rect. bottom = d_y2DC - d_y1DC;
234 FillRect (our d_gdiGraphicsContext, & rect, GetStockBrush (WHITE_BRUSH));
235 /*if (our d_winWindow) SendMessage (our d_winWindow, WM_ERASEBKGND, (WPARAM) our d_gdiGraphicsContext, 0);*/
236 #elif quartz
237 if (! our d_drawingArea) {
238 Melder_assert (!! our d_macGraphicsContext);
239 CGContextSetAlpha (our d_macGraphicsContext, 1.0);
240 CGContextSetRGBFillColor (our d_macGraphicsContext, 1.0, 1.0, 1.0, 1.0);
241 CGContextFillRect (d_macGraphicsContext, CGRectMake (our d_x1DC, our d_y2DC, our d_x2DC - our d_x1DC, our d_y1DC - our d_y2DC));
242 return;
243 }
244 GuiCocoaDrawingArea *cocoaDrawingArea = (GuiCocoaDrawingArea *) our d_drawingArea -> d_widget;
245 if (cocoaDrawingArea && ! [cocoaDrawingArea isHiddenOrHasHiddenAncestor]) { // can be called at destruction time
246 Melder_assert (!! our d_macGraphicsContext);
247 CGContextSetAlpha (our d_macGraphicsContext, 1.0);
248 CGContextSetRGBFillColor (our d_macGraphicsContext, 1.0, 1.0, 1.0, 1.0);
249 CGContextFillRect (d_macGraphicsContext, CGRectMake (our d_x1DC, our d_y2DC, our d_x2DC - our d_x1DC, our d_y1DC - our d_y2DC));
250 }
251 #endif
252 }
253
254 void Graphics_clearWscxx . . $ Graphics_clearWs(2d838ed765120c5d). (Graphicscxx . . $ Graphics# me) {
255 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) {
256 opcxx . . $ `sys/GraphicsP.h:179:9`! (CLEAR_WS, 0);
257 } else
258 mycxx . . $ `melder/melder.h:44:9`! v_clearWscxx . . $ structGraphics#v_clearWs(49f6e7a06ebc5aa8). ();
259 }
260
261 void structGraphicsScreencxx . . $ structGraphicsScreen# :: v_updateWscxx . . $ structGraphicsScreen#v_updateWs(49f6e7a06ebc5aa8). () {
262 /*
263 A function that invalidates the graphics.
264 This function is typically called by the owner of the drawing area
265 whenever the data to be displayed in the drawing area has changed;
266 the idea is to generate an expose event to which the drawing area will
267 respond by redrawing its contents from the (changed) data.
268 (last checked 2020-07-12)
269 */
270 if (! ourcxx . . $ `melder/melder.h:42:9`! d_drawingAreacxx . . $ structGraphics#d_drawingArea.)
271 return;
272 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! && gtkcxx . . $ `sys/Gui.h:33:10`!
273 //GdkWindow *window = gtk_widget_get_parent_window (GTK_WIDGET (our d_drawingArea -> d_widget));
274 GdkRectangle rect;
275
276 if (ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. < ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC.) {
277 rect.x = ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC.;
278 rect.width = ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. - ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC.;
279 } else {
280 rect.x = ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC.;
281 rect.width = ourcxx . . $ `melder/melder.h:42:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. - ourcxx . . $ `melder/melder.h:42:9`! d_x2DCcxx . . $ structGraphics#d_x2DC.;
282 }
283
284 if (ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. < ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.) {
285 rect.y = ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC.;
286 rect.height = ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. - ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC.;
287 } else {
288 rect.y = ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.;
289 rect.height = ourcxx . . $ `melder/melder.h:42:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. - ourcxx . . $ `melder/melder.h:42:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.;
290 }
291 //gdk_window_invalidate_rect (our d_window, & rect, true);
292 gtk_widget_queue_draw_area (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (ourcxx . . $ `melder/melder.h:42:9`! d_drawingArea -> d_widget), rect.x, rect.y, rect.width, rect.height);
293 //gdk_window_invalidate_rect (our d_window, nullptr, true);
294 //gdk_window_process_updates (our d_window, true); // TODO: this one seems to be for draining instead
295 #elif gdi
296 //clear (this); // lll
297 if (our d_winWindow)
298 InvalidateRect (our d_winWindow, nullptr, true);
299 #elif quartz
300 NSView *view = our d_macView;
301 Melder_assert (!! view);
302 NSRect rect;
303 if (our d_x1DC < our d_x2DC) {
304 rect.origin.x = our d_x1DC;
305 rect.size.width = our d_x2DC - our d_x1DC;
306 } else {
307 rect.origin.x = our d_x2DC;
308 rect.size.width = our d_x1DC - our d_x2DC;
309 }
310 if (our d_y1DC < our d_y2DC) {
311 rect.origin.y = our d_y1DC;
312 rect.size.height = our d_y2DC - our d_y1DC;
313 } else {
314 rect.origin.y = our d_y2DC;
315 rect.size.height = our d_y1DC - our d_y2DC;
316 }
317 //[view setNeedsDisplayInRect: rect];
318 [view setNeedsDisplay: YES];
319 #endif
320 }
321
322 void Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (Graphicscxx . . $ Graphics# me) {
323 if (me)
324 mycxx . . $ `melder/melder.h:44:9`! v_updateWscxx . . $ structGraphics#v_updateWs(49f6e7a06ebc5aa8). ();
325 }
326
327 void Graphics_beginMovieFramecxx . . $ Graphics_beginMovieFrame(39e73bcf122a4f1d). (Graphicscxx . . $ Graphics# any, MelderColourcxx . . $ MelderColour# *p_colour) {
328 if (any -> classInfocxx . . $ structThing#classInfo. == classGraphicsScreencxx . . $ classGraphicsScreen.) {
329 GraphicsScreencxx . . $ GraphicsScreen# me = (GraphicsScreencxx . . $ GraphicsScreen#) any;
330 Graphics_startRecordingcxx . . $ Graphics_startRecording(ce6516af4677a324). (me);
331 if (p_colour) {
332 Graphics_clearRecordingcxx . . $ Graphics_clearRecording(2d838ed765120c5d). (me);
333 Graphics_setViewportcxx . . $ Graphics_setViewport(72bdb7937dbb13da). (me, 0.0, 1.0, 0.0, 1.0);
334 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (me, *p_colour);
335 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (me, 0.0, 1.0, 0.0, 1.0);
336 Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (me, 0.0, 1.0, 0.0, 1.0);
337 Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (me, Melder_BLACKcxx . . $ Melder_BLACK.);
338 }
339 }
340 }
341
342 void Graphics_endMovieFramecxx . . $ Graphics_endMovieFrame(2514a1c07b6be5e2). (Graphicscxx . . $ Graphics# any, double frameDuration) {
343 if (any -> classInfocxx . . $ structThing#classInfo. == classGraphicsScreencxx . . $ classGraphicsScreen.) {
344 GraphicsScreencxx . . $ GraphicsScreen# me = (GraphicsScreencxx . . $ GraphicsScreen#) any;
345 Graphics_stopRecordingcxx . . $ Graphics_stopRecording(ce6516af4677a324). (me);
346 mycxx . . $ `melder/melder.h:44:9`! v_updateWscxx . . $ structGraphicsScreen#v_updateWs(49f6e7a06ebc5aa8). ();
347 Melder_sleepcxx . . $ Melder_sleep(ba8836b59fb42830). (frameDuration);
348 GuiShell_draincxx . . $ GuiShell_drain(429b5b6a2695f0d7). (mycxx . . $ `melder/melder.h:44:9`! d_drawingAreacxx . . $ structGraphics#d_drawingArea. -> d_shellcxx . . $ structGuiThing#d_shell., false, true);
349 }
350 }
351
352 static int GraphicsScreen_initcxx . . $ GraphicsScreen_init(ab559cee0ff5f2fd). (GraphicsScreencxx . . $ GraphicsScreen# me, void *voidDisplay, void *voidWindow) {
353
354 /* Fill in new members. */
355
356 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! && gtkcxx . . $ `sys/Gui.h:33:10`!
357 mycxx . . $ `melder/melder.h:44:9`! d_displaycxx . . $ structGraphicsScreen#d_display. = (GdkDisplay *) gdk_display_get_default ();
358 _GraphicsScreen_text_initcxx . . $ _GraphicsScreen_text_init(2eab33b16e3c36be). (me);
359 if (voidDisplay)
360 mycxx . . $ `melder/melder.h:44:9`! d_windowcxx . . $ structGraphicsScreen#d_window. = gtk_widget_get_window (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (voidDisplay));
361 mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = nullptr; // will be created and destroyed at expose time or during Graphics_textWidth(); 2020-11-11
362 #elif gdi
363 if (my printer) {
364 my d_gdiGraphicsContext = (HDC) voidWindow;
365 } else if (voidDisplay) {
366 my d_gdiGraphicsContext = (HDC) voidDisplay;
367 my metafile = true;
368 } else {
369 my d_winWindow = (HWND) voidWindow;
370 my d_gdiGraphicsContext = GetDC (my d_winWindow); // window must have a constant display context; see XtInitialize ()
371 }
372 Melder_assert (my d_gdiGraphicsContext);
373 SetBkMode (my d_gdiGraphicsContext, TRANSPARENT); // not the default! text should not be drawn against a white background
374 /*
375 Create pens and brushes.
376 */
377 my d_winPen = CreatePen (PS_SOLID, 0, RGB (0, 0, 0));
378 my d_winBrush = CreateSolidBrush (RGB (0, 0, 0));
379 SelectBrush (my d_gdiGraphicsContext, GetStockBrush (NULL_BRUSH));
380 SetTextAlign (my d_gdiGraphicsContext, TA_LEFT | TA_BASELINE | TA_NOUPDATECP); // baseline is not the default!
381 _GraphicsScreen_text_init (me);
382 #elif quartz
383 (void) voidDisplay;
384 if (my printer) {
385 my d_macView = (NSView *) voidWindow; // in case we do view-based printing
386 //my d_macGraphicsContext = (CGContextRef) voidWindow; // in case we do context-based printing
387 } else {
388 my d_macView = (NSView *) voidWindow;
389 my d_macGraphicsContext = nullptr; // will be retrieved and nullified at expose time
390 }
391 my d_depth = ( my resolution > 150 ? 1 : 8 ); // BUG: replace by true depth (1=black/white)
392 _GraphicsScreen_text_init (me);
393 #endif
394 return 1;
395 }
396
397 autoGraphicscxx . . $ autoGraphics# Graphics_create_screencxx . . $ Graphics_create_screen(47f58b1ed3ae60e8). (void *display, void *window, int resolution) {
398 autoGraphicsScreencxx . . $ autoGraphicsScreen# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsScreen);
399 mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. = true;
400 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
401 _GraphicsCairo_tryToInitializePangocxx . . $ _GraphicsCairo_tryToInitializePango(c9857a73d68e59ba). ();
402 #elif gdi
403 my d_useGdiplus = _GraphicsWindows_tryToInitializeGdiPlus ();
404 #elif quartz
405 _GraphicsMacintosh_tryToInitializeQuartz ();
406 #endif
407 mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = true;
408 Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), resolution);
409 Graphics_setWsViewportcxx . . $ Graphics_setWsViewport(4ffe5bb10b2fb6bd). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 100.0, 0.0, 100.0);
410 GraphicsScreen_initcxx . . $ GraphicsScreen_init(ab559cee0ff5f2fd). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), display, window);
411 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
412 }
413
414 autoGraphicscxx . . $ autoGraphics# Graphics_create_screenPrintercxx . . $ Graphics_create_screenPrinter(5c17c7768f4d3e41). (void *display, void *window) {
415 autoGraphicsScreencxx . . $ autoGraphicsScreen# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsScreen);
416 mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. = true;
417 mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = true;
418 mycxx . . $ `melder/melder.h:44:9`! printercxx . . $ structGraphics#printer. = true;
419 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
420 _GraphicsCairo_tryToInitializePangocxx . . $ _GraphicsCairo_tryToInitializePango(c9857a73d68e59ba). ();
421 #elif gdi
422 my d_useGdiplus = _GraphicsWindows_tryToInitializeGdiPlus ();
423 #elif quartz
424 _GraphicsMacintosh_tryToInitializeQuartz ();
425 #endif
426 Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution.);
427 mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. = (double) thePrintercxx . . $ thePrinter.. paperWidthcxx . . $ Printer#paperWidth. / thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution.;
428 mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. = (double) thePrintercxx . . $ thePrinter.. paperHeightcxx . . $ Printer#paperHeight. / thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution.;
429 //NSLog (@"Graphics_create_screenPrinter: %f %f", my paperWidth, my paperHeight);
430 mycxx . . $ `melder/melder.h:44:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. = mycxx . . $ `melder/melder.h:44:9`! d_x1DCmincxx . . $ structGraphics#d_x1DCmin. = thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution. / 2;
431 mycxx . . $ `melder/melder.h:44:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. = mycxx . . $ `melder/melder.h:44:9`! d_x2DCmaxcxx . . $ structGraphics#d_x2DCmax. = (mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. - 0.5) * thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution.;
432 mycxx . . $ `melder/melder.h:44:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. = mycxx . . $ `melder/melder.h:44:9`! d_y1DCmincxx . . $ structGraphics#d_y1DCmin. = thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution. / 2;
433 mycxx . . $ `melder/melder.h:44:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. = mycxx . . $ `melder/melder.h:44:9`! d_y2DCmaxcxx . . $ structGraphics#d_y2DCmax. = (mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. - 0.5) * thePrintercxx . . $ thePrinter.. resolutioncxx . . $ Printer#resolution.;
434 #if gdicxx . . $ `sys/GraphicsP.h:55:10`!
435 /*
436 * Map page coordinates to paper coordinates.
437 */
438 my d_x1DC -= GetDeviceCaps ((HDC) window, PHYSICALOFFSETX);
439 my d_x2DC -= GetDeviceCaps ((HDC) window, PHYSICALOFFSETX);
440 my d_y1DC -= GetDeviceCaps ((HDC) window, PHYSICALOFFSETY);
441 my d_y2DC -= GetDeviceCaps ((HDC) window, PHYSICALOFFSETY);
442 #endif // gdi
443 Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, mycxx . . $ `melder/melder.h:44:9`! paperWidthcxx . . $ structGraphics#paperWidth. - 1.0, 12.000 - (mycxx . . $ `melder/melder.h:44:9`! paperHeightcxx . . $ structGraphics#paperHeight. - 1.0), 12.000);
444 GraphicsScreen_initcxx . . $ GraphicsScreen_init(ab559cee0ff5f2fd). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), display, window);
445 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
446 }
447
448 autoGraphicscxx . . $ autoGraphics# Graphics_create_xmdrawingareacxx . . $ Graphics_create_xmdrawingarea(51b1c75797a7dddf). (GuiDrawingAreacxx . . $ GuiDrawingArea# w) {
449 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"begin");
450 autoGraphicsScreencxx . . $ autoGraphicsScreen# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsScreen);
451 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! && gtkcxx . . $ `sys/Gui.h:33:10`!
452 GtkRequisition realsize;
453 GtkAllocation allocation;
454 #elif gdi
455 Dimension width, height;
456 #endif
457
458 mycxx . . $ `melder/melder.h:44:9`! d_drawingAreacxx . . $ structGraphics#d_drawingArea. = static_cast <GuiDrawingAreacxx . . $ GuiDrawingArea#> (w); /* Now !!!!!!!!!! */
459 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! d_drawingArea -> d_widget);
460 mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. = true;
461 mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = true;
462 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
463 _GraphicsCairo_tryToInitializePangocxx . . $ _GraphicsCairo_tryToInitializePango(c9857a73d68e59ba). ();
464 #elif gdi
465 my d_useGdiplus = _GraphicsWindows_tryToInitializeGdiPlus ();
466 #elif quartz
467 _GraphicsMacintosh_tryToInitializeQuartz ();
468 #endif
469 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! && gtkcxx . . $ `sys/Gui.h:33:10`!
470 Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Gui_getResolutioncxx . . $ Gui_getResolution(dedf1e9b1c614a07). (mycxx . . $ `melder/melder.h:44:9`! d_drawingAreacxx . . $ structGraphics#d_drawingArea. -> d_widgetcxx . . $ structGuiThing#d_widget.));
471 GraphicsScreen_initcxx . . $ GraphicsScreen_init(ab559cee0ff5f2fd). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_drawingArea -> d_widget), GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_drawingArea -> d_widget));
472 #elif gdi
473 Graphics_init (me.get(), Gui_getResolution (my d_drawingArea -> d_widget));
474 GraphicsScreen_init (me.get(), XtDisplay (my d_drawingArea -> d_widget), XtWindow (my d_drawingArea -> d_widget));
475 #elif quartz
476 Graphics_init (me.get(), Gui_getResolution (nullptr));
477 GraphicsScreen_init (me.get(), my d_drawingArea -> d_widget, my d_drawingArea -> d_widget);
478 #endif
479
480 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (w -> numberOfGraphicses < structGuiDrawingArea :: MAXIMUM_NUMBER_OF_GRAPHICSES);
481 w -> graphicsescxx . . $ structGuiDrawingArea#graphicses. [++ w -> numberOfGraphicsescxx . . $ structGuiDrawingArea#numberOfGraphicses.] = me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); // refer back
482
483 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! && gtkcxx . . $ `sys/Gui.h:33:10`!
484 // fb: is really the request meant or rather the actual size, aka allocation?
485 gtk_widget_size_request (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_drawingArea -> d_widget), & realsize);
486 gtk_widget_get_allocation (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_drawingArea -> d_widget), & allocation);
487 // HIER WAS IK
488 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"requested ", realsize.width, U" x ", realsize.height, U", allocated ", allocation.width, U" x ", allocation.height);
489 Graphics_setWsViewportcxx . . $ Graphics_setWsViewport(4ffe5bb10b2fb6bd). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, realsize.widthcxx . . $ _GtkRequisition#width., 0.0, realsize.heightcxx . . $ _GtkRequisition#height.);
490 #elif gdi
491 XtVaGetValues (my d_drawingArea -> d_widget, XmNwidth, & width, XmNheight, & height, nullptr);
492 Graphics_setWsViewport (me.get(), 0.0, width, 0.0, height);
493 #elif quartz
494 NSView *view = (NSView *) my d_drawingArea -> d_widget;
495 NSRect bounds = [view bounds];
496 Graphics_setWsViewport (me.get(), 0.0, bounds.size.width, 0.0, bounds.size.height);
497 #endif
498 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
499 }
500
501 autoGraphicscxx . . $ autoGraphics# Graphics_create_pngfilecxx . . $ Graphics_create_pngfile(10428f15b15d8c5f). (MelderFilecxx . . $ MelderFile# file, int resolution,
502 double x1inches, double x2inches, double y1inches, double y2inches)
503 {
504 autoGraphicsScreencxx . . $ autoGraphicsScreen# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsScreen);
505 mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. = true;
506 mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = true;
507 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
508 _GraphicsCairo_tryToInitializePangocxx . . $ _GraphicsCairo_tryToInitializePango(c9857a73d68e59ba). ();
509 #elif gdi
510 my d_useGdiplus = _GraphicsWindows_tryToInitializeGdiPlus ();
511 #elif quartz
512 _GraphicsMacintosh_tryToInitializeQuartz ();
513 #endif
514 Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), resolution);
515 mycxx . . $ `melder/melder.h:44:9`! d_isPngcxx . . $ structGraphicsScreen#d_isPng. = true;
516 mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsScreen#d_file. =cxx . . $ structMelderFile#`operator=`(4772b97eefcc5036). *file;
517 mycxx . . $ `melder/melder.h:44:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. = mycxx . . $ `melder/melder.h:44:9`! d_x1DCmincxx . . $ structGraphics#d_x1DCmin. = 0;
518 mycxx . . $ `melder/melder.h:44:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. = mycxx . . $ `melder/melder.h:44:9`! d_x2DCmaxcxx . . $ structGraphics#d_x2DCmax. = (x2inches - x1inches) * resolution;
519 mycxx . . $ `melder/melder.h:44:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. = mycxx . . $ `melder/melder.h:44:9`! d_y1DCmincxx . . $ structGraphics#d_y1DCmin. = 0;
520 mycxx . . $ `melder/melder.h:44:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. = mycxx . . $ `melder/melder.h:44:9`! d_y2DCmaxcxx . . $ structGraphics#d_y2DCmax. = (y2inches - y1inches) * resolution;
521 Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), x1inches, x2inches, y1inches, y2inches);
522 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
523 mycxx . . $ `melder/melder.h:44:9`! d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface. = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
524 (x2inches - x1inches) * resolution, (y2inches - y1inches) * resolution);
525 mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = cairo_create (mycxx . . $ `melder/melder.h:44:9`! d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface.);
526 //cairo_scale (my d_cairoGraphicsContext, 72.0 / resolution, 72.0 / resolution);
527 /*
528 Fill in the whole area with a white background.
529 */
530 cairo_set_source_rgb (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 1.0, 1.0, 1.0);
531 cairo_rectangle (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 0, 0, mycxx . . $ `melder/melder.h:44:9`! d_x2DCcxx . . $ structGraphics#d_x2DC., mycxx . . $ `melder/melder.h:44:9`! d_y2DCcxx . . $ structGraphics#d_y2DC.);
532 cairo_fill (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
533 cairo_set_source_rgb (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 0.0, 0.0, 0.0);
534 #elif gdi
535 my metafile = true;
536 HDC screenDC = GetDC (nullptr);
537 my d_gdiGraphicsContext = CreateCompatibleDC (screenDC);
538 trace (U"d_gdiGraphicsContext ", Melder_pointer (my d_gdiGraphicsContext));
539 Melder_assert (my d_gdiGraphicsContext);
540 my d_gdiBitmap = CreateCompatibleBitmap (screenDC, (x2inches - x1inches) * resolution, (y2inches - y1inches) * resolution);
541 trace (U"d_gdiBitmap ", Melder_pointer (my d_gdiBitmap));
542 Melder_assert (my d_gdiBitmap);
543 ReleaseDC (nullptr, screenDC);
544 SelectObject (my d_gdiGraphicsContext, my d_gdiBitmap);
545 trace (U"bitmap selected into device context");
546 my resolution = resolution;
547 SetBkMode (my d_gdiGraphicsContext, TRANSPARENT);
548 my d_winPen = CreatePen (PS_SOLID, 0, RGB (0, 0, 0));
549 my d_winBrush = CreateSolidBrush (RGB (0, 0, 0));
550 SetTextAlign (my d_gdiGraphicsContext, TA_LEFT | TA_BASELINE | TA_NOUPDATECP);
551 /*
552 Fill in the whole area with a white background.
553 */
554 SelectPen (my d_gdiGraphicsContext, GetStockPen (NULL_PEN));
555 SelectBrush (my d_gdiGraphicsContext, GetStockBrush (WHITE_BRUSH));
556 Rectangle (my d_gdiGraphicsContext, 0, 0, my d_x2DC + 1, my d_y2DC + 1); // plus 1, in order to prevent two black edges
557 SelectPen (my d_gdiGraphicsContext, GetStockPen (BLACK_PEN));
558 SelectBrush (my d_gdiGraphicsContext, GetStockBrush (NULL_BRUSH));
559 #elif quartz
560 integer width = (x2inches - x1inches) * resolution, height = (y2inches - y1inches) * resolution;
561 integer stride = width * 4;
562 stride = (stride + 15) & ~15; // CommonCode/AppDrawing.c: "a multiple of 16 bytes, for best performance"
563 my d_bits = Melder_malloc (uint8_t, stride * height);
564 static CGColorSpaceRef colourSpace = nullptr;
565 if (! colourSpace) {
566 colourSpace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
567 Melder_assert (colourSpace);
568 }
569 my d_macGraphicsContext = CGBitmapContextCreate (my d_bits,
570 width, height,
571 8, // bits per component
572 stride,
573 colourSpace,
574 kCGImageAlphaPremultipliedLast);
575 if (! my d_macGraphicsContext)
576 Melder_throw (U"Could not create PNG file ", file, U".");
577 CGRect rect = CGRectMake (0, 0, width, height);
578 CGContextSetAlpha (my d_macGraphicsContext, 1.0);
579 CGContextSetBlendMode (my d_macGraphicsContext, kCGBlendModeNormal);
580 CGContextSetRGBFillColor (my d_macGraphicsContext, 1.0, 1.0, 1.0, 1.0);
581 CGContextFillRect (my d_macGraphicsContext, rect);
582 CGContextTranslateCTM (my d_macGraphicsContext, 0, height);
583 CGContextScaleCTM (my d_macGraphicsContext, 1.0, -1.0);
584 #endif
585 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
586 }
587
588 autoGraphicscxx . . $ autoGraphics# Graphics_create_pdffilecxx . . $ Graphics_create_pdffile(10428f15b15d8c5f). (MelderFilecxx . . $ MelderFile# file, int resolution,
589 double x1inches, double x2inches, double y1inches, double y2inches)
590 {
591 autoGraphicsScreencxx . . $ autoGraphicsScreen# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsScreen);
592 mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. = true;
593 mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = true;
594 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
595 _GraphicsCairo_tryToInitializePangocxx . . $ _GraphicsCairo_tryToInitializePango(c9857a73d68e59ba). ();
596 #elif quartz
597 _GraphicsMacintosh_tryToInitializeQuartz ();
598 #endif
599 Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), resolution);
600 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
601 mycxx . . $ `melder/melder.h:44:9`! d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface. = cairo_pdf_surface_create (MelderFile_peekPath8cxx . . $ MelderFile_peekPath8(3a3888509ce82e67). (file),
602 ( isdefinedcxx . . $ isdefined(f8197d536af80c96). (x1inches) ? x2inches - x1inches : x2inches ) * 72.0,
603 ( isdefinedcxx . . $ isdefined(f8197d536af80c96). (y1inches) ? y2inches - y1inches : y2inches ) * 72.0);
604 mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = cairo_create (mycxx . . $ `melder/melder.h:44:9`! d_cairoSurfacecxx . . $ structGraphicsScreen#d_cairoSurface.);
605 mycxx . . $ `melder/melder.h:44:9`! d_x1DCcxx . . $ structGraphics#d_x1DC. = mycxx . . $ `melder/melder.h:44:9`! d_x1DCmincxx . . $ structGraphics#d_x1DCmin. = 0;
606 mycxx . . $ `melder/melder.h:44:9`! d_x2DCcxx . . $ structGraphics#d_x2DC. = mycxx . . $ `melder/melder.h:44:9`! d_x2DCmaxcxx . . $ structGraphics#d_x2DCmax. = ( isdefinedcxx . . $ isdefined(f8197d536af80c96). (x1inches) ? 7.5 : x2inches ) * resolution;
607 mycxx . . $ `melder/melder.h:44:9`! d_y1DCcxx . . $ structGraphics#d_y1DC. = mycxx . . $ `melder/melder.h:44:9`! d_y1DCmincxx . . $ structGraphics#d_y1DCmin. = 0;
608 mycxx . . $ `melder/melder.h:44:9`! d_y2DCcxx . . $ structGraphics#d_y2DC. = mycxx . . $ `melder/melder.h:44:9`! d_y2DCmaxcxx . . $ structGraphics#d_y2DCmax. = ( isdefinedcxx . . $ isdefined(f8197d536af80c96). (y1inches) ? 11.0 : y2inches ) * resolution;
609 Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(),
610 isdefinedcxx . . $ isdefined(f8197d536af80c96). (x1inches) ? 0.0 : 0.0, isdefinedcxx . . $ isdefined(f8197d536af80c96). (x1inches) ? 7.5 : x2inches,
611 isdefinedcxx . . $ isdefined(f8197d536af80c96). (y1inches) ? 1.0 : 0.0, isdefinedcxx . . $ isdefined(f8197d536af80c96). (y1inches) ? 12.0 : y2inches
612 );
613 cairo_scale (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 72.0 / resolution, 72.0 / resolution);
614 cairo_translate (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.,
615 ( isdefinedcxx . . $ isdefined(f8197d536af80c96). (x1inches) ? - x1inches : 0.0 ) * resolution,
616 ( isdefinedcxx . . $ isdefined(f8197d536af80c96). (y1inches) ? (y2inches - 12.0) : 0.0 ) * resolution);
617 #elif quartz
618 CFURLRef url = CFURLCreateWithFileSystemPath (nullptr, (CFStringRef) MelderFile_peekPathCfstring (file), kCFURLPOSIXPathStyle, false);
619 CGRect rect = CGRectMake (0, 0,
620 ( isdefined (x1inches) ? x2inches - x1inches : x2inches ) * 72.0,
621 ( isdefined (y1inches) ? y2inches - y1inches : y2inches ) * 72.0); // don't tire PDF viewers with funny origins
622 CFStringRef key = (CFStringRef) Melder_peek32toCfstring (U"Creator");
623 CFStringRef value = (CFStringRef) Melder_peek32toCfstring (U"Praat");
624 CFIndex numberOfValues = 1;
625 CFDictionaryRef dictionary = CFDictionaryCreate (nullptr, (const void **) & key, (const void **) & value, numberOfValues,
626 & kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
627 my d_macGraphicsContext = CGPDFContextCreateWithURL (url, & rect, dictionary);
628 CFRelease (url);
629 CFRelease (dictionary);
630 if (! my d_macGraphicsContext)
631 Melder_throw (U"Could not create PDF file ", file, U".");
632 my d_x1DC = my d_x1DCmin = 0;
633 my d_x2DC = my d_x2DCmax = ( isdefined (x1inches) ? 7.5 : x2inches ) * resolution;
634 my d_y1DC = my d_y1DCmin = 0;
635 my d_y2DC = my d_y2DCmax = ( isdefined (y1inches) ? 11.0 : y2inches ) * resolution;
636 Graphics_setWsWindow (me.get(),
637 ( isdefined (x1inches) ? 0.0 : 0.0 ), ( isdefined (x1inches) ? 7.5 : x2inches ),
638 ( isdefined (y1inches) ? 1.0 : 0.0 ), ( isdefined (y1inches) ? 12.0 : y2inches ));
639 CGContextBeginPage (my d_macGraphicsContext, & rect);
640 CGContextScaleCTM (my d_macGraphicsContext, 72.0 / resolution, 72.0 / resolution);
641 CGContextTranslateCTM (my d_macGraphicsContext,
642 ( isdefined (x1inches) ? - x1inches : 0.0 ) * resolution,
643 ( isdefined (y1inches) ? (12.0 - y1inches) : y2inches ) * resolution);
644 CGContextScaleCTM (my d_macGraphicsContext, 1.0, -1.0);
645 #endif
646 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
647 }
648 autoGraphicscxx . . $ autoGraphics# Graphics_create_pdfcxx . . $ Graphics_create_pdf(9ecb7037dfdb82a5). (void *context, int resolution,
649 double x1inches, double x2inches, double y1inches, double y2inches)
650 {
651 autoGraphicsScreencxx . . $ autoGraphicsScreen# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GraphicsScreen);
652 mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. = true;
653 mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. = true;
654 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`!
655 _GraphicsMacintosh_tryToInitializeQuartz ();
656 #endif
657 Graphics_initcxx . . $ Graphics_init(9abe41586e87648d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), resolution);
658 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`!
659 my d_macGraphicsContext = static_cast <CGContext *> (context);
660 CGRect rect = CGRectMake (0, 0, (x2inches - x1inches) * 72, (y2inches - y1inches) * 72); // don't tire PDF viewers with funny origins
661 my d_x1DC = my d_x1DCmin = 0;
662 my d_x2DC = my d_x2DCmax = 7.5 * resolution;
663 my d_y1DC = my d_y1DCmin = 0;
664 my d_y2DC = my d_y2DCmax = 11.0 * resolution;
665 Graphics_setWsWindow (me.get(), 0, 7.5, 1.0, 12.0);
666 Melder_assert (my d_macGraphicsContext);
667 CGContextBeginPage (my d_macGraphicsContext, & rect);
668 CGContextScaleCTM (my d_macGraphicsContext, 72.0 / resolution, 72.0 / resolution);
669 CGContextTranslateCTM (my d_macGraphicsContext, - x1inches * resolution, (12.0 - y1inches) * resolution);
670 CGContextScaleCTM (my d_macGraphicsContext, 1.0, -1.0);
671 #endif // quartz
672 return mecxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
673 }
674
675 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
676 void *Graphics_x_getCRcxx . . $ Graphics_x_getCR(1510a132eaf077fa). (Graphicscxx . . $ Graphics# me) {
677 return ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.;
678 }
679 void Graphics_x_setCRcxx . . $ Graphics_x_setCR(6e5fe3dceb7c0a02). (Graphicscxx . . $ Graphics# me, void *cairoGraphicsContext) {
680 ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = (cairo_t *) cairoGraphicsContext;
681 }
682 #endif // cairo
683
684 /* End of file GraphicsScreen.cpp */