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