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