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