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