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