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