]> 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
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
89 typedef enum
90 {
91   ForegroundStencil,
92   BackgroundStencil,
93   OpaqueStencil,
94   TransparentStencil
95 } AnnotationStencil;
96
97 typedef 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
116 typedef enum
117 {
118   UndefinedColormap,
119   PrivateColormap,
120   SharedColormap
121 } XColormapType;
122
123 typedef 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
164 struct _XImportInfo
165 {
166   MagickBooleanType
167     frame,
168     borders,
169     screen,
170     descend,
171     silent;
172 };
173
174 typedef enum
175 {
176   DefaultState = 0x0000,
177   EscapeState = 0x0001,
178   ExitState = 0x0002,
179   FormerImageState = 0x0004,
180   ModifierState = 0x0008,
181   MontageImageState = 0x0010,
182   NextImageState = 0x0020,
183   RetainColorsState = 0x0040,
184   SuspendTime = 50,
185   UpdateConfigurationState = 0x0080,
186   UpdateRegionState = 0x0100
187 } XState;
188
189 typedef struct _XAnnotateInfo
190 {
191   int
192     x,
193     y;
194
195   unsigned int
196     width,
197     height;
198
199   double
200     degrees;
201
202   XFontStruct
203     *font_info;
204
205   char
206     *text;
207
208   AnnotationStencil
209     stencil;
210
211   char
212     geometry[MaxTextExtent];
213
214   struct _XAnnotateInfo
215     *next,
216     *previous;
217 } XAnnotateInfo;
218
219 typedef struct _XPixelInfo
220 {
221   ssize_t
222     colors;
223
224   unsigned long
225     *pixels;
226
227   XColor
228     foreground_color,
229     background_color,
230     border_color,
231     matte_color,
232     highlight_color,
233     shadow_color,
234     depth_color,
235     trough_color,
236     box_color,
237     pen_color,
238     pen_colors[MaxNumberPens];
239
240   GC
241     annotate_context,
242     highlight_context,
243     widget_context;
244
245   unsigned short
246     box_index,
247     pen_index;
248 } XPixelInfo;
249
250 struct _XResourceInfo
251 {
252   XrmDatabase
253     resource_database;
254
255   ImageInfo
256     *image_info;
257
258   QuantizeInfo
259     *quantize_info;
260
261   size_t
262     colors;
263
264   MagickBooleanType
265     close_server,
266     backdrop;
267
268   char
269     *background_color,
270     *border_color;
271
272   char
273     *client_name;
274
275   XColormapType
276     colormap;
277
278   unsigned int
279     border_width;
280
281   size_t
282     delay;
283
284   MagickBooleanType
285     color_recovery,
286     confirm_exit,
287     confirm_edit;
288
289   char
290     *display_gamma;
291
292   char
293     *font,
294     *font_name[MaxNumberFonts],
295     *foreground_color;
296
297   MagickBooleanType
298     display_warnings,
299     gamma_correct;
300
301   char
302     *icon_geometry;
303
304   MagickBooleanType
305     iconic,
306     immutable;
307
308   char
309     *image_geometry;
310
311   char
312     *map_type,
313     *matte_color,
314     *name;
315
316   unsigned int
317     magnify,
318     pause;
319
320   char
321     *pen_colors[MaxNumberPens];
322
323   char
324     *text_font,
325     *title;
326
327   int
328     quantum;
329
330   unsigned int
331     update;
332
333   MagickBooleanType
334     use_pixmap,
335     use_shared_memory;
336
337   size_t
338     undo_cache;
339
340   char
341     *visual_type,
342     *window_group,
343     *window_id,
344     *write_filename;
345
346   Image
347     *copy_image;
348
349   int
350     gravity;
351
352   char
353     home_directory[MaxTextExtent];
354 };
355
356 typedef struct _XWindowInfo
357 {
358   Window
359     id;
360
361   Window
362     root;
363
364   Visual
365     *visual;
366
367   unsigned int
368     storage_class,
369     depth;
370
371   XVisualInfo
372     *visual_info;
373
374   XStandardColormap
375     *map_info;
376
377   XPixelInfo
378     *pixel_info;
379
380   XFontStruct
381     *font_info;
382
383   GC
384     annotate_context,
385     highlight_context,
386     widget_context;
387
388   Cursor
389     cursor,
390     busy_cursor;
391
392   char
393     *name,
394     *geometry,
395     *icon_name,
396     *icon_geometry,
397     *crop_geometry;
398
399   size_t
400     data,
401     flags;
402
403   int
404     x,
405     y;
406
407   unsigned int
408     width,
409     height,
410     min_width,
411     min_height,
412     width_inc,
413     height_inc,
414     border_width;
415
416   MagickBooleanType
417     use_pixmap,
418     immutable,
419     shape,
420     shared_memory;
421
422   int
423     screen;
424
425   XImage
426     *ximage,
427     *matte_image;
428
429   Pixmap
430     highlight_stipple,
431     shadow_stipple,
432     pixmap,
433     *pixmaps,
434     matte_pixmap,
435     *matte_pixmaps;
436
437   XSetWindowAttributes
438     attributes;
439
440   XWindowChanges
441     window_changes;
442
443   void
444     *segment_info;
445
446   long
447     mask;
448
449   MagickBooleanType
450     orphan,
451     mapped,
452     stasis;
453
454   Image
455     *image;
456
457   MagickBooleanType
458     destroy;
459 } XWindowInfo;
460
461 typedef struct _XWindows
462 {
463   Display
464     *display;
465
466   XStandardColormap
467     *map_info,
468     *icon_map;
469
470   XVisualInfo
471     *visual_info,
472     *icon_visual;
473
474   XPixelInfo
475     *pixel_info,
476     *icon_pixel;
477
478   XFontStruct
479     *font_info;
480
481   XResourceInfo
482     *icon_resources;
483
484   XClassHint
485     *class_hints;
486
487   XWMHints
488     *manager_hints;
489
490   XWindowInfo
491     context,
492     group_leader,
493     backdrop,
494     icon,
495     image,
496     info,
497     magnify,
498     pan,
499     command,
500     widget,
501     popup;
502
503   Atom
504     wm_protocols,
505     wm_delete_window,
506     wm_take_focus,
507     im_protocols,
508     im_remote_command,
509     im_update_widget,
510     im_update_colormap,
511     im_former_image,
512     im_retain_colors,
513     im_next_image,
514     im_exit,
515     dnd_protocols;
516 } XWindows;
517
518 extern MagickPrivate Cursor
519   XMakeCursor(Display *,Window,Colormap,char *,char *);
520
521 extern MagickPrivate int
522   XCheckDefineCursor(Display *,Window,Cursor);
523
524 extern MagickPrivate MagickBooleanType
525   XAnnotateImage(Display *,const XPixelInfo *,XAnnotateInfo *,Image *),
526   XComponentGenesis(void),
527   XDrawImage(Display *,const XPixelInfo *,XDrawInfo *,Image *),
528   XGetWindowColor(Display *,XWindows *,char *),
529   XMagickProgressMonitor(const char *,const MagickOffsetType,
530     const MagickSizeType,void *),
531   XMakeImage(Display *,const XResourceInfo *,XWindowInfo *,Image *,unsigned int,
532     unsigned int,ExceptionInfo *),
533   XQueryColorDatabase(const char *,XColor *);
534
535 extern MagickPrivate void
536   XBestIconSize(Display *,XWindowInfo *,Image *),
537   XBestPixel(Display *,const Colormap,XColor *,unsigned int,XColor *),
538   XCheckRefreshWindows(Display *,XWindows *),
539   XClientMessage(Display *,const Window,const Atom,const Atom,const Time),
540   XComponentTerminus(void),
541   XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *),
542   XConstrainWindowPosition(Display *,XWindowInfo *),
543   XDelay(Display *,const size_t),
544   XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *),
545   XDestroyWindowColors(Display *,Window),
546   XFreeResources(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
547     XFontStruct *,XResourceInfo *,XWindowInfo *),
548   XFreeStandardColormap(Display *,const XVisualInfo *,XStandardColormap *,
549     XPixelInfo *),
550   XHighlightEllipse(Display *,Window,GC,const RectangleInfo *),
551   XHighlightLine(Display *,Window,GC,const XSegment *),
552   XHighlightRectangle(Display *,Window,GC,const RectangleInfo *),
553   XGetAnnotateInfo(XAnnotateInfo *),
554   XGetPixelInfo(Display *,const XVisualInfo *,const XStandardColormap *,
555     const XResourceInfo *,Image *,XPixelInfo *),
556   XGetMapInfo(const XVisualInfo *,const Colormap,XStandardColormap *),
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   XSetCursorState(Display *,XWindows *,const MagickStatusType),
567   XUserPreferences(XResourceInfo *),
568   XWarning(const ExceptionType,const char *,const char *);
569
570 extern MagickPrivate Window
571   XWindowByID(Display *,const Window,const size_t),
572   XWindowByName(Display *,const Window,const char *),
573   XWindowByProperty(Display *,const Window,const Atom);
574
575 extern MagickPrivate XFontStruct
576   *XBestFont(Display *,const XResourceInfo *,const MagickBooleanType);
577
578 extern MagickPrivate XVisualInfo
579   *XBestVisualInfo(Display *,XStandardColormap *,XResourceInfo *);
580
581 extern MagickPrivate XWindows
582   *XInitializeWindows(Display *,XResourceInfo *),
583   *XSetWindows(XWindows *);
584
585 static inline MagickRealType XPixelIntensity(const XColor *pixel)
586 {
587   MagickRealType
588     intensity;
589
590   intensity=0.299*pixel->red+0.587*pixel->green+0.114*pixel->blue;
591   return(intensity);
592 }
593
594 #endif
595
596 #if defined(__cplusplus) || defined(c_plusplus)
597 }
598 #endif
599
600 #endif