MagickCore 7.1.1
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
xwindow-private.h
1/*
2 Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
4
5 You may not use this file except in compliance with the License. You may
6 obtain a copy of the License at
7
8 https://imagemagick.org/script/license.php
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 MagickCore X11 window methods.
17*/
18#ifndef MAGICKCORE_XWINDOW_PRIVATE_H
19#define MAGICKCORE_XWINDOW_PRIVATE_H
20
21#include "MagickCore/draw.h"
22#include "MagickCore/exception.h"
23#include "MagickCore/geometry.h"
24#include "MagickCore/nt-base-private.h"
25#include "MagickCore/pixel-accessor.h"
26#include "MagickCore/quantize.h"
27
28#if defined(__cplusplus) || defined(c_plusplus)
29extern "C" {
30#endif
31
32#if defined(MAGICKCORE_X11_DELEGATE)
33
34#include <X11/Xos.h>
35#include <X11/Xlib.h>
36#include <X11/Xatom.h>
37#include <X11/cursorfont.h>
38#include <X11/keysym.h>
39#include <X11/Xresource.h>
40#include <X11/Xutil.h>
41
42#if defined(__cplusplus) || defined(c_plusplus)
43# define klass c_class
44#else
45# define klass class
46#endif
47
48#define MaxIconSize 96
49#define MaxNumberPens 11
50#define MaxNumberFonts 11
51#define MaxXWindows 12
52#undef index
53
54#define ThrowXWindowException(severity,tag,context) \
55{ \
56 ExceptionInfo \
57 *exception; \
58 \
59 exception=AcquireExceptionInfo(); \
60 (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \
61 "'%s': %s",context,strerror(errno)); \
62 CatchException(exception); \
63 (void) DestroyExceptionInfo(exception); \
64}
65#define ThrowXWindowFatalException(severity,tag,context) \
66{ \
67 ThrowXWindowException(severity,tag,context); \
68 _exit(1); \
69}
70
71typedef enum
72{
73 ForegroundStencil,
74 BackgroundStencil,
75 OpaqueStencil,
76 TransparentStencil
77} AnnotationStencil;
78
79typedef enum
80{
81 UndefinedElement,
82 PointElement,
83 LineElement,
84 RectangleElement,
85 FillRectangleElement,
86 CircleElement,
87 FillCircleElement,
88 EllipseElement,
89 FillEllipseElement,
90 PolygonElement,
91 FillPolygonElement,
92 ColorElement,
93 MatteElement,
94 TextElement,
95 ImageElement
96} ElementType;
97
98typedef enum
99{
100 UndefinedColormap,
101 PrivateColormap,
102 SharedColormap
103} XColormapType;
104
105typedef struct _XDrawInfo
106{
107 int
108 x,
109 y;
110
111 unsigned int
112 width,
113 height;
114
115 double
116 degrees;
117
118 AnnotationStencil
119 stencil;
120
121 ElementType
122 element;
123
124 Pixmap
125 stipple;
126
127 unsigned int
128 line_width;
129
130 XSegment
131 line_info;
132
133 unsigned int
134 number_coordinates;
135
137 rectangle_info;
138
139 XPoint
140 *coordinate_info;
141
142 char
143 geometry[MagickPathExtent];
144} XDrawInfo;
145
146typedef enum
147{
148 DefaultState = 0x0000U,
149 EscapeState = 0x0001U,
150 ExitState = 0x0002U,
151 FormerImageState = 0x0004U,
152 ModifierState = 0x0008U,
153 MontageImageState = 0x0010U,
154 NextImageState = 0x0020U,
155 RetainColorsState = 0x0040U,
156 SuspendTime = 50U,
157 UpdateConfigurationState = 0x0080U,
158 UpdateRegionState = 0x0100U
159} XState;
160
161typedef struct _XAnnotateInfo
162{
163 int
164 x,
165 y;
166
167 unsigned int
168 width,
169 height;
170
171 double
172 degrees;
173
174 XFontStruct
175 *font_info;
176
177 char
178 *text;
179
180 AnnotationStencil
181 stencil;
182
183 char
184 geometry[MagickPathExtent];
185
186 struct _XAnnotateInfo
187 *next,
188 *previous;
189} XAnnotateInfo;
190
191typedef struct _XPixelInfo
192{
193 ssize_t
194 colors;
195
196 unsigned long
197 *pixels;
198
199 XColor
200 alpha_color, /* deprecated */
201 foreground_color,
202 background_color,
203 border_color,
204 highlight_color,
205 shadow_color,
206 depth_color,
207 trough_color,
208 box_color,
209 pen_color,
210 pen_colors[MaxNumberPens];
211
212 GC
213 annotate_context,
214 highlight_context,
215 widget_context;
216
217 unsigned short
218 box_index,
219 pen_index;
220
221 XColor
222 matte_color;
223} XPixelInfo;
224
225typedef struct _XResourceInfo
226{
227 XrmDatabase
228 resource_database;
229
231 *image_info;
232
234 *quantize_info;
235
236 size_t
237 colors;
238
239 MagickBooleanType
240 close_server,
241 backdrop;
242
243 char
244 *background_color,
245 *border_color;
246
247 char
248 *client_name;
249
250 XColormapType
251 colormap;
252
253 unsigned int
254 border_width;
255
256 size_t
257 delay;
258
259 MagickBooleanType
260 color_recovery,
261 confirm_exit,
262 confirm_edit;
263
264 char
265 *display_gamma;
266
267 char
268 *font,
269 *font_name[MaxNumberFonts],
270 *foreground_color;
271
272 MagickBooleanType
273 display_warnings,
274 gamma_correct;
275
276 char
277 *icon_geometry;
278
279 MagickBooleanType
280 iconic,
281 immutable;
282
283 char
284 *image_geometry;
285
286 char
287 *alpha_color, /* deprecated */
288 *map_type,
289 *name;
290
291 unsigned int
292 magnify,
293 pause;
294
295 char
296 *pen_colors[MaxNumberPens];
297
298 char
299 *text_font,
300 *title;
301
302 int
303 quantum;
304
305 unsigned int
306 update;
307
308 MagickBooleanType
309 use_pixmap,
310 use_shared_memory;
311
312 size_t
313 undo_cache;
314
315 char
316 *visual_type,
317 *window_group,
318 *window_id,
319 *write_filename;
320
321 Image
322 *copy_image;
323
324 int
325 gravity;
326
327 char
328 home_directory[MagickPathExtent],
329 *matte_color;
330
331 MagickBooleanType
332 debug;
333} XResourceInfo;
334
335typedef struct _XWindowInfo
336{
337 Window
338 id;
339
340 Window
341 root;
342
343 Visual
344 *visual;
345
346 unsigned int
347 storage_class,
348 depth;
349
350 XVisualInfo
351 *visual_info;
352
353 XStandardColormap
354 *map_info;
355
356 XPixelInfo
357 *pixel_info;
358
359 XFontStruct
360 *font_info;
361
362 GC
363 annotate_context,
364 highlight_context,
365 widget_context;
366
367 Cursor
368 cursor,
369 busy_cursor;
370
371 char
372 *name,
373 *geometry,
374 *icon_name,
375 *icon_geometry,
376 *crop_geometry;
377
378 size_t
379 data,
380 flags;
381
382 int
383 x,
384 y;
385
386 unsigned int
387 width,
388 height,
389 min_width,
390 min_height,
391 width_inc,
392 height_inc,
393 border_width;
394
395 MagickBooleanType
396 use_pixmap,
397 immutable,
398 shape,
399 shared_memory;
400
401 int
402 screen;
403
404 XImage
405 *ximage,
406 *matte_image;
407
408 Pixmap
409 highlight_stipple,
410 shadow_stipple,
411 pixmap,
412 *pixmaps,
413 matte_pixmap,
414 *matte_pixmaps;
415
416 XSetWindowAttributes
417 attributes;
418
419 XWindowChanges
420 window_changes;
421
422 void
423 *segment_info;
424
425 long
426 mask;
427
428 MagickBooleanType
429 orphan,
430 mapped,
431 stasis;
432
433 Image
434 *image;
435
436 MagickBooleanType
437 destroy;
438} XWindowInfo;
439
440typedef struct _XWindows
441{
442 Display
443 *display;
444
445 XStandardColormap
446 *map_info,
447 *icon_map;
448
449 XVisualInfo
450 *visual_info,
451 *icon_visual;
452
453 XPixelInfo
454 *pixel_info,
455 *icon_pixel;
456
457 XFontStruct
458 *font_info;
459
460 XResourceInfo
461 *icon_resources;
462
463 XClassHint
464 *class_hints;
465
466 XWMHints
467 *manager_hints;
468
469 XWindowInfo
470 context,
471 group_leader,
472 backdrop,
473 icon,
474 image,
475 info,
476 magnify,
477 pan,
478 command,
479 widget,
480 popup;
481
482 Atom
483 wm_protocols,
484 wm_delete_window,
485 wm_take_focus,
486 im_protocols,
487 im_remote_command,
488 im_update_widget,
489 im_update_colormap,
490 im_former_image,
491 im_retain_colors,
492 im_next_image,
493 im_exit,
494 dnd_protocols;
495} XWindows;
496
497extern MagickPrivate Cursor
498 XMakeCursor(Display *,Window,Colormap,char *,char *);
499
500extern MagickPrivate int
501 XCheckDefineCursor(Display *,Window,Cursor);
502
503extern MagickPrivate MagickBooleanType
504 XAnnotateImage(Display *,const XPixelInfo *,XAnnotateInfo *,Image *,
505 ExceptionInfo *),
506 XComponentGenesis(void),
507 XDrawImage(Display *,const XPixelInfo *,XDrawInfo *,Image *,ExceptionInfo *),
508 XGetWindowColor(Display *,XWindows *,char *,ExceptionInfo *),
509 XMagickProgressMonitor(const char *,const MagickOffsetType,
510 const MagickSizeType,void *),
511 XMakeImage(Display *,const XResourceInfo *,XWindowInfo *,Image *,unsigned int,
512 unsigned int,ExceptionInfo *),
513 XQueryColorCompliance(const char *,XColor *);
514
515extern MagickPrivate void
516 XBestIconSize(Display *,XWindowInfo *,Image *),
517 XBestPixel(Display *,const Colormap,XColor *,unsigned int,XColor *),
518 XCheckRefreshWindows(Display *,XWindows *),
519 XClientMessage(Display *,const Window,const Atom,const Atom,const Time),
520 XComponentTerminus(void),
521 XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *,
522 ExceptionInfo *),
523 XConstrainWindowPosition(Display *,XWindowInfo *),
524 XDelay(Display *,const size_t),
525 XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *,
526 ExceptionInfo *),
527 XDestroyWindowColors(Display *,Window),
528 XFreeResources(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
529 XFontStruct *,XResourceInfo *,XWindowInfo *),
530 XFreeStandardColormap(Display *,const XVisualInfo *,XStandardColormap *,
531 XPixelInfo *),
532 XHighlightEllipse(Display *,Window,GC,const RectangleInfo *),
533 XHighlightLine(Display *,Window,GC,const XSegment *),
534 XHighlightRectangle(Display *,Window,GC,const RectangleInfo *),
535 XGetAnnotateInfo(XAnnotateInfo *),
536 XGetPixelInfo(Display *,const XVisualInfo *,const XStandardColormap *,
537 const XResourceInfo *,Image *,XPixelInfo *),
538 XGetMapInfo(const XVisualInfo *,const Colormap,XStandardColormap *),
539 XGetWindowInfo(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
540 XFontStruct *,XResourceInfo *,XWindowInfo *),
541 XMakeMagnifyImage(Display *,XWindows *,ExceptionInfo *),
542 XMakeStandardColormap(Display *,XVisualInfo *,XResourceInfo *,Image *,
543 XStandardColormap *,XPixelInfo *,ExceptionInfo *),
544 XMakeWindow(Display *,Window,char **,int,XClassHint *,XWMHints *,
545 XWindowInfo *),
546 XQueryPosition(Display *,const Window,int *,int *),
547 XRefreshWindow(Display *,const XWindowInfo *,const XEvent *),
548 XSetCursorState(Display *,XWindows *,const MagickStatusType),
549 XUserPreferences(XResourceInfo *),
550 XWarning(const ExceptionType,const char *,const char *);
551
552extern MagickPrivate Window
553 XWindowByID(Display *,const Window,const size_t),
554 XWindowByName(Display *,const Window,const char *),
555 XWindowByProperty(Display *,const Window,const Atom);
556
557extern MagickPrivate XFontStruct
558 *XBestFont(Display *,const XResourceInfo *,const MagickBooleanType);
559
560extern MagickPrivate XVisualInfo
561 *XBestVisualInfo(Display *,XStandardColormap *,XResourceInfo *);
562
563extern MagickPrivate XWindows
564 *XInitializeWindows(Display *,XResourceInfo *),
565 *XSetWindows(XWindows *);
566
567extern MagickExport char
568 *XGetResourceClass(XrmDatabase,const char *,const char *,char *),
569 *XGetResourceInstance(XrmDatabase,const char *,const char *,const char *),
570 *XGetScreenDensity(Display *);
571
572extern MagickExport int
573 XError(Display *,XErrorEvent *);
574
575extern MagickExport MagickBooleanType
576 XRemoteCommand(Display *,const char *,const char *);
577
578extern MagickExport void
579 DestroyXResources(void),
580 XDestroyResourceInfo(XResourceInfo *),
581 XGetResourceInfo(const ImageInfo *,XrmDatabase,const char *,XResourceInfo *),
582 XRetainWindowColors(Display *,const Window);
583
584extern MagickExport XrmDatabase
585 XGetResourceDatabase(Display *,const char *);
586
587static inline double XPixelIntensity(const XColor *pixel)
588{
589 double
590 intensity;
591
592 if ((pixel->red == pixel->green) && (pixel->green == pixel->blue))
593 return((double) pixel->red);
594 intensity=0.212656*pixel->red+0.715158*pixel->green+0.072186*pixel->blue;
595 return(intensity);
596}
597
598#endif
599
600extern MagickPrivate MagickBooleanType
601 XRenderImage(Image *,const DrawInfo *,const PointInfo *,TypeMetric *,
602 ExceptionInfo *);
603
604#if defined(__cplusplus) || defined(c_plusplus)
605}
606#endif
607
608#endif