blob: b56a32ecfc8746ace4dc38a24dadb676a21147b9 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy7e41fe82010-12-04 23:12:08 +00002 Copyright 1999-2011 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>
cristy4c08aed2011-07-01 19:47:50 +000034#include "MagickCore/exception.h"
35#include "MagickCore/geometry.h"
36#include "MagickCore/quantize.h"
cristy3ed852e2009-09-05 21:47:34 +000037
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{
cristyf2faecf2010-05-28 19:19:36 +0000211 ssize_t
212 colors;
213
214 unsigned long
cristy3ed852e2009-09-05 21:47:34 +0000215 *pixels;
216
217 XColor
218 foreground_color,
219 background_color,
220 border_color,
221 matte_color,
222 highlight_color,
223 shadow_color,
224 depth_color,
225 trough_color,
226 box_color,
227 pen_color,
228 pen_colors[MaxNumberPens];
229
230 GC
231 annotate_context,
232 highlight_context,
233 widget_context;
234
235 unsigned short
236 box_index,
237 pen_index;
238} XPixelInfo;
239
240typedef struct _XResourceInfo
241{
242 XrmDatabase
243 resource_database;
244
245 ImageInfo
246 *image_info;
247
248 QuantizeInfo
249 *quantize_info;
250
cristybb503372010-05-27 20:51:26 +0000251 size_t
cristy3ed852e2009-09-05 21:47:34 +0000252 colors;
253
254 MagickBooleanType
255 close_server,
256 backdrop;
257
258 char
259 *background_color,
260 *border_color;
261
262 char
263 *client_name;
264
265 XColormapType
266 colormap;
267
268 unsigned int
269 border_width;
270
cristybb503372010-05-27 20:51:26 +0000271 size_t
cristy3ed852e2009-09-05 21:47:34 +0000272 delay;
273
274 MagickBooleanType
275 color_recovery,
276 confirm_exit,
277 confirm_edit;
278
279 char
280 *display_gamma;
281
282 char
283 *font,
284 *font_name[MaxNumberFonts],
285 *foreground_color;
286
287 MagickBooleanType
288 display_warnings,
289 gamma_correct;
290
291 char
292 *icon_geometry;
293
294 MagickBooleanType
295 iconic,
296 immutable;
297
298 char
299 *image_geometry;
300
301 char
302 *map_type,
303 *matte_color,
304 *name;
305
306 unsigned int
307 magnify,
308 pause;
309
310 char
311 *pen_colors[MaxNumberPens];
312
313 char
314 *text_font,
315 *title;
316
317 int
318 quantum;
319
320 unsigned int
321 update;
322
323 MagickBooleanType
324 use_pixmap,
325 use_shared_memory;
326
cristybb503372010-05-27 20:51:26 +0000327 size_t
cristy3ed852e2009-09-05 21:47:34 +0000328 undo_cache;
329
330 char
331 *visual_type,
332 *window_group,
333 *window_id,
334 *write_filename;
335
336 Image
337 *copy_image;
338
339 int
340 gravity;
341
342 char
343 home_directory[MaxTextExtent];
344} XResourceInfo;
345
346typedef struct _XWindowInfo
347{
348 Window
349 id;
350
351 Window
352 root;
353
354 Visual
355 *visual;
356
357 unsigned int
358 storage_class,
359 depth;
360
361 XVisualInfo
362 *visual_info;
363
364 XStandardColormap
365 *map_info;
366
367 XPixelInfo
368 *pixel_info;
369
370 XFontStruct
371 *font_info;
372
373 GC
374 annotate_context,
375 highlight_context,
376 widget_context;
377
378 Cursor
379 cursor,
380 busy_cursor;
381
382 char
383 *name,
384 *geometry,
385 *icon_name,
386 *icon_geometry,
387 *crop_geometry;
388
cristybb503372010-05-27 20:51:26 +0000389 size_t
cristy3ed852e2009-09-05 21:47:34 +0000390 data,
391 flags;
392
393 int
394 x,
395 y;
396
397 unsigned int
398 width,
399 height,
400 min_width,
401 min_height,
402 width_inc,
403 height_inc,
404 border_width;
405
406 MagickBooleanType
407 use_pixmap,
408 immutable,
409 shape,
410 shared_memory;
411
412 int
413 screen;
414
415 XImage
416 *ximage,
417 *matte_image;
418
419 Pixmap
420 highlight_stipple,
421 shadow_stipple,
422 pixmap,
423 *pixmaps,
424 matte_pixmap,
425 *matte_pixmaps;
426
427 XSetWindowAttributes
428 attributes;
429
430 XWindowChanges
431 window_changes;
432
433 void
434 *segment_info;
435
cristy8891f9c2010-06-04 23:32:17 +0000436 long
cristy3ed852e2009-09-05 21:47:34 +0000437 mask;
438
439 MagickBooleanType
440 orphan,
441 mapped,
442 stasis;
443
444 Image
445 *image;
446
447 MagickBooleanType
448 destroy;
449} XWindowInfo;
450
451typedef struct _XWindows
452{
453 Display
454 *display;
455
456 XStandardColormap
457 *map_info,
458 *icon_map;
459
460 XVisualInfo
461 *visual_info,
462 *icon_visual;
463
464 XPixelInfo
465 *pixel_info,
466 *icon_pixel;
467
468 XFontStruct
469 *font_info;
470
471 XResourceInfo
472 *icon_resources;
473
474 XClassHint
475 *class_hints;
476
477 XWMHints
478 *manager_hints;
479
480 XWindowInfo
481 context,
482 group_leader,
483 backdrop,
484 icon,
485 image,
486 info,
487 magnify,
488 pan,
489 command,
490 widget,
491 popup;
492
493 Atom
494 wm_protocols,
495 wm_delete_window,
496 wm_take_focus,
497 im_protocols,
498 im_remote_command,
499 im_update_widget,
500 im_update_colormap,
501 im_former_image,
502 im_retain_colors,
503 im_next_image,
504 im_exit,
505 dnd_protocols;
506} XWindows;
507
508extern MagickExport char
509 *XGetResourceClass(XrmDatabase,const char *,const char *,char *),
510 *XGetResourceInstance(XrmDatabase,const char *,const char *,const char *),
511 *XGetScreenDensity(Display *);
512
513extern MagickExport Cursor
514 XMakeCursor(Display *,Window,Colormap,char *,char *);
515
516extern MagickExport int
517 XCheckDefineCursor(Display *,Window,Cursor),
518 XError(Display *,XErrorEvent *);
519
520extern MagickExport MagickBooleanType
521 XAnnotateImage(Display *,const XPixelInfo *,XAnnotateInfo *,Image *),
cristyf34a1452009-10-24 22:29:27 +0000522 XComponentGenesis(void),
cristy3ed852e2009-09-05 21:47:34 +0000523 XDrawImage(Display *,const XPixelInfo *,XDrawInfo *,Image *),
524 XGetWindowColor(Display *,XWindows *,char *),
525 XMagickProgressMonitor(const char *,const MagickOffsetType,
526 const MagickSizeType,void *),
527 XMakeImage(Display *,const XResourceInfo *,XWindowInfo *,Image *,unsigned int,
528 unsigned int),
529 XQueryColorDatabase(const char *,XColor *),
530 XRemoteCommand(Display *,const char *,const char *);
531
532extern MagickExport void
533 DestroyXResources(void),
534 XBestIconSize(Display *,XWindowInfo *,Image *),
535 XBestPixel(Display *,const Colormap,XColor *,unsigned int,XColor *),
536 XCheckRefreshWindows(Display *,XWindows *),
537 XClientMessage(Display *,const Window,const Atom,const Atom,const Time),
cristyf34a1452009-10-24 22:29:27 +0000538 XComponentTerminus(void),
cristy3ed852e2009-09-05 21:47:34 +0000539 XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *),
540 XConstrainWindowPosition(Display *,XWindowInfo *),
cristybb503372010-05-27 20:51:26 +0000541 XDelay(Display *,const size_t),
cristyaf8b5cd2009-10-24 00:29:23 +0000542 XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *),
cristy3ed852e2009-09-05 21:47:34 +0000543 XDestroyResourceInfo(XResourceInfo *),
544 XDestroyWindowColors(Display *,Window),
cristy3ed852e2009-09-05 21:47:34 +0000545 XFreeResources(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
546 XFontStruct *,XResourceInfo *,XWindowInfo *),
547 XFreeStandardColormap(Display *,const XVisualInfo *,XStandardColormap *,
548 XPixelInfo *),
549 XHighlightEllipse(Display *,Window,GC,const RectangleInfo *),
550 XHighlightLine(Display *,Window,GC,const XSegment *),
551 XHighlightRectangle(Display *,Window,GC,const RectangleInfo *),
552 XGetAnnotateInfo(XAnnotateInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000553 XGetPixelInfo(Display *,const XVisualInfo *,const XStandardColormap *,
cristy3ed852e2009-09-05 21:47:34 +0000554 const XResourceInfo *,Image *,XPixelInfo *),
555 XGetMapInfo(const XVisualInfo *,const Colormap,XStandardColormap *),
556 XGetResourceInfo(const ImageInfo *,XrmDatabase,const char *,XResourceInfo *),
557 XGetWindowInfo(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
558 XFontStruct *,XResourceInfo *,XWindowInfo *),
559 XMakeMagnifyImage(Display *,XWindows *),
560 XMakeStandardColormap(Display *,XVisualInfo *,XResourceInfo *,Image *,
561 XStandardColormap *,XPixelInfo *),
562 XMakeWindow(Display *,Window,char **,int,XClassHint *,XWMHints *,
563 XWindowInfo *),
564 XQueryPosition(Display *,const Window,int *,int *),
565 XRefreshWindow(Display *,const XWindowInfo *,const XEvent *),
566 XRetainWindowColors(Display *,const Window),
567 XSetCursorState(Display *,XWindows *,const MagickStatusType),
568 XUserPreferences(XResourceInfo *),
569 XWarning(const ExceptionType,const char *,const char *);
570
571extern MagickExport Window
cristybb503372010-05-27 20:51:26 +0000572 XWindowByID(Display *,const Window,const size_t),
cristy3ed852e2009-09-05 21:47:34 +0000573 XWindowByName(Display *,const Window,const char *),
574 XWindowByProperty(Display *,const Window,const Atom);
575
576extern MagickExport XFontStruct
577 *XBestFont(Display *,const XResourceInfo *,const MagickBooleanType);
578
579extern MagickExport XrmDatabase
580 XGetResourceDatabase(Display *,const char *);
581
582extern MagickExport XVisualInfo
583 *XBestVisualInfo(Display *,XStandardColormap *,XResourceInfo *);
584
585extern MagickExport XWindows
586 *XInitializeWindows(Display *,XResourceInfo *),
587 *XSetWindows(XWindows *);
588
589static inline MagickRealType XPixelIntensity(const XColor *pixel)
590{
591 MagickRealType
592 intensity;
593
594 intensity=0.299*pixel->red+0.587*pixel->green+0.114*pixel->blue;
595 return(intensity);
596}
597
598#endif
599
600#if defined(__cplusplus) || defined(c_plusplus)
601}
602#endif
603
604#endif