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