00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MAGICKCORE_XWINDOW_PRIVATE_H
00019 #define MAGICKCORE_XWINDOW_PRIVATE_H
00020
00021 #include "MagickCore/draw.h"
00022 #include "MagickCore/exception.h"
00023 #include "MagickCore/geometry.h"
00024 #include "MagickCore/nt-base-private.h"
00025 #include "MagickCore/pixel-accessor.h"
00026 #include "MagickCore/quantize.h"
00027
00028 #if defined(__cplusplus) || defined(c_plusplus)
00029 extern "C" {
00030 #endif
00031
00032 #if defined(MAGICKCORE_X11_DELEGATE)
00033
00034 #include <X11/Xos.h>
00035 #include <X11/Xlib.h>
00036 #include <X11/Xatom.h>
00037 #include <X11/cursorfont.h>
00038 #include <X11/keysym.h>
00039 #include <X11/Xresource.h>
00040 #include <X11/Xutil.h>
00041
00042 #if defined(__cplusplus) || defined(c_plusplus)
00043 # define klass c_class
00044 #else
00045 # define klass class
00046 #endif
00047
00048 #define MaxIconSize 96
00049 #define MaxNumberPens 11
00050 #define MaxNumberFonts 11
00051 #define MaxXWindows 12
00052 #undef index
00053
00054 #define ThrowXWindowException(severity,tag,context) \
00055 { \
00056 ExceptionInfo \
00057 *exception; \
00058 \
00059 exception=AcquireExceptionInfo(); \
00060 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
00061 tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context, \
00062 strerror(errno)); \
00063 CatchException(exception); \
00064 (void) DestroyExceptionInfo(exception); \
00065 }
00066 #define ThrowXWindowFatalException(severity,tag,context) \
00067 { \
00068 ThrowXWindowException(severity,tag,context); \
00069 _exit(1); \
00070 }
00071
00072 typedef enum
00073 {
00074 ForegroundStencil,
00075 BackgroundStencil,
00076 OpaqueStencil,
00077 TransparentStencil
00078 } AnnotationStencil;
00079
00080 typedef enum
00081 {
00082 UndefinedElement,
00083 PointElement,
00084 LineElement,
00085 RectangleElement,
00086 FillRectangleElement,
00087 CircleElement,
00088 FillCircleElement,
00089 EllipseElement,
00090 FillEllipseElement,
00091 PolygonElement,
00092 FillPolygonElement,
00093 ColorElement,
00094 MatteElement,
00095 TextElement,
00096 ImageElement
00097 } ElementType;
00098
00099 typedef enum
00100 {
00101 UndefinedColormap,
00102 PrivateColormap,
00103 SharedColormap
00104 } XColormapType;
00105
00106 typedef struct _XDrawInfo
00107 {
00108 int
00109 x,
00110 y;
00111
00112 unsigned int
00113 width,
00114 height;
00115
00116 double
00117 degrees;
00118
00119 AnnotationStencil
00120 stencil;
00121
00122 ElementType
00123 element;
00124
00125 Pixmap
00126 stipple;
00127
00128 unsigned int
00129 line_width;
00130
00131 XSegment
00132 line_info;
00133
00134 unsigned int
00135 number_coordinates;
00136
00137 RectangleInfo
00138 rectangle_info;
00139
00140 XPoint
00141 *coordinate_info;
00142
00143 char
00144 geometry[MagickPathExtent];
00145 } XDrawInfo;
00146
00147 typedef enum
00148 {
00149 DefaultState = 0x0000,
00150 EscapeState = 0x0001,
00151 ExitState = 0x0002,
00152 FormerImageState = 0x0004,
00153 ModifierState = 0x0008,
00154 MontageImageState = 0x0010,
00155 NextImageState = 0x0020,
00156 RetainColorsState = 0x0040,
00157 SuspendTime = 50,
00158 UpdateConfigurationState = 0x0080,
00159 UpdateRegionState = 0x0100
00160 } XState;
00161
00162 typedef struct _XAnnotateInfo
00163 {
00164 int
00165 x,
00166 y;
00167
00168 unsigned int
00169 width,
00170 height;
00171
00172 double
00173 degrees;
00174
00175 XFontStruct
00176 *font_info;
00177
00178 char
00179 *text;
00180
00181 AnnotationStencil
00182 stencil;
00183
00184 char
00185 geometry[MagickPathExtent];
00186
00187 struct _XAnnotateInfo
00188 *next,
00189 *previous;
00190 } XAnnotateInfo;
00191
00192 typedef struct _XPixelInfo
00193 {
00194 ssize_t
00195 colors;
00196
00197 unsigned long
00198 *pixels;
00199
00200 XColor
00201 alpha_color,
00202 foreground_color,
00203 background_color,
00204 border_color,
00205 highlight_color,
00206 shadow_color,
00207 depth_color,
00208 trough_color,
00209 box_color,
00210 pen_color,
00211 pen_colors[MaxNumberPens];
00212
00213 GC
00214 annotate_context,
00215 highlight_context,
00216 widget_context;
00217
00218 unsigned short
00219 box_index,
00220 pen_index;
00221
00222 XColor
00223 matte_color;
00224 } XPixelInfo;
00225
00226 typedef struct _XResourceInfo
00227 {
00228 XrmDatabase
00229 resource_database;
00230
00231 ImageInfo
00232 *image_info;
00233
00234 QuantizeInfo
00235 *quantize_info;
00236
00237 size_t
00238 colors;
00239
00240 MagickBooleanType
00241 close_server,
00242 backdrop;
00243
00244 char
00245 *background_color,
00246 *border_color;
00247
00248 char
00249 *client_name;
00250
00251 XColormapType
00252 colormap;
00253
00254 unsigned int
00255 border_width;
00256
00257 size_t
00258 delay;
00259
00260 MagickBooleanType
00261 color_recovery,
00262 confirm_exit,
00263 confirm_edit;
00264
00265 char
00266 *display_gamma;
00267
00268 char
00269 *font,
00270 *font_name[MaxNumberFonts],
00271 *foreground_color;
00272
00273 MagickBooleanType
00274 display_warnings,
00275 gamma_correct;
00276
00277 char
00278 *icon_geometry;
00279
00280 MagickBooleanType
00281 iconic,
00282 immutable;
00283
00284 char
00285 *image_geometry;
00286
00287 char
00288 *alpha_color,
00289 *map_type,
00290 *name;
00291
00292 unsigned int
00293 magnify,
00294 pause;
00295
00296 char
00297 *pen_colors[MaxNumberPens];
00298
00299 char
00300 *text_font,
00301 *title;
00302
00303 int
00304 quantum;
00305
00306 unsigned int
00307 update;
00308
00309 MagickBooleanType
00310 use_pixmap,
00311 use_shared_memory;
00312
00313 size_t
00314 undo_cache;
00315
00316 char
00317 *visual_type,
00318 *window_group,
00319 *window_id,
00320 *write_filename;
00321
00322 Image
00323 *copy_image;
00324
00325 int
00326 gravity;
00327
00328 char
00329 home_directory[MagickPathExtent];
00330
00331 char
00332 *matte_color;
00333 } XResourceInfo;
00334
00335 typedef struct _XWindowInfo
00336 {
00337 Window
00338 id;
00339
00340 Window
00341 root;
00342
00343 Visual
00344 *visual;
00345
00346 unsigned int
00347 storage_class,
00348 depth;
00349
00350 XVisualInfo
00351 *visual_info;
00352
00353 XStandardColormap
00354 *map_info;
00355
00356 XPixelInfo
00357 *pixel_info;
00358
00359 XFontStruct
00360 *font_info;
00361
00362 GC
00363 annotate_context,
00364 highlight_context,
00365 widget_context;
00366
00367 Cursor
00368 cursor,
00369 busy_cursor;
00370
00371 char
00372 *name,
00373 *geometry,
00374 *icon_name,
00375 *icon_geometry,
00376 *crop_geometry;
00377
00378 size_t
00379 data,
00380 flags;
00381
00382 int
00383 x,
00384 y;
00385
00386 unsigned int
00387 width,
00388 height,
00389 min_width,
00390 min_height,
00391 width_inc,
00392 height_inc,
00393 border_width;
00394
00395 MagickBooleanType
00396 use_pixmap,
00397 immutable,
00398 shape,
00399 shared_memory;
00400
00401 int
00402 screen;
00403
00404 XImage
00405 *ximage,
00406 *matte_image;
00407
00408 Pixmap
00409 highlight_stipple,
00410 shadow_stipple,
00411 pixmap,
00412 *pixmaps,
00413 matte_pixmap,
00414 *matte_pixmaps;
00415
00416 XSetWindowAttributes
00417 attributes;
00418
00419 XWindowChanges
00420 window_changes;
00421
00422 void
00423 *segment_info;
00424
00425 long
00426 mask;
00427
00428 MagickBooleanType
00429 orphan,
00430 mapped,
00431 stasis;
00432
00433 Image
00434 *image;
00435
00436 MagickBooleanType
00437 destroy;
00438 } XWindowInfo;
00439
00440 typedef struct _XWindows
00441 {
00442 Display
00443 *display;
00444
00445 XStandardColormap
00446 *map_info,
00447 *icon_map;
00448
00449 XVisualInfo
00450 *visual_info,
00451 *icon_visual;
00452
00453 XPixelInfo
00454 *pixel_info,
00455 *icon_pixel;
00456
00457 XFontStruct
00458 *font_info;
00459
00460 XResourceInfo
00461 *icon_resources;
00462
00463 XClassHint
00464 *class_hints;
00465
00466 XWMHints
00467 *manager_hints;
00468
00469 XWindowInfo
00470 context,
00471 group_leader,
00472 backdrop,
00473 icon,
00474 image,
00475 info,
00476 magnify,
00477 pan,
00478 command,
00479 widget,
00480 popup;
00481
00482 Atom
00483 wm_protocols,
00484 wm_delete_window,
00485 wm_take_focus,
00486 im_protocols,
00487 im_remote_command,
00488 im_update_widget,
00489 im_update_colormap,
00490 im_former_image,
00491 im_retain_colors,
00492 im_next_image,
00493 im_exit,
00494 dnd_protocols;
00495 } XWindows;
00496
00497 extern MagickPrivate Cursor
00498 XMakeCursor(Display *,Window,Colormap,char *,char *);
00499
00500 extern MagickPrivate int
00501 XCheckDefineCursor(Display *,Window,Cursor);
00502
00503 extern MagickPrivate MagickBooleanType
00504 XAnnotateImage(Display *,const XPixelInfo *,XAnnotateInfo *,Image *,
00505 ExceptionInfo *),
00506 XComponentGenesis(void),
00507 XDrawImage(Display *,const XPixelInfo *,XDrawInfo *,Image *,ExceptionInfo *),
00508 XGetWindowColor(Display *,XWindows *,char *,ExceptionInfo *),
00509 XMagickProgressMonitor(const char *,const MagickOffsetType,
00510 const MagickSizeType,void *),
00511 XMakeImage(Display *,const XResourceInfo *,XWindowInfo *,Image *,unsigned int,
00512 unsigned int,ExceptionInfo *),
00513 XQueryColorCompliance(const char *,XColor *);
00514
00515 extern MagickPrivate void
00516 XBestIconSize(Display *,XWindowInfo *,Image *),
00517 XBestPixel(Display *,const Colormap,XColor *,unsigned int,XColor *),
00518 XCheckRefreshWindows(Display *,XWindows *),
00519 XClientMessage(Display *,const Window,const Atom,const Atom,const Time),
00520 XComponentTerminus(void),
00521 XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *,
00522 ExceptionInfo *),
00523 XConstrainWindowPosition(Display *,XWindowInfo *),
00524 XDelay(Display *,const size_t),
00525 XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *,
00526 ExceptionInfo *),
00527 XDestroyWindowColors(Display *,Window),
00528 XFreeResources(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
00529 XFontStruct *,XResourceInfo *,XWindowInfo *),
00530 XFreeStandardColormap(Display *,const XVisualInfo *,XStandardColormap *,
00531 XPixelInfo *),
00532 XHighlightEllipse(Display *,Window,GC,const RectangleInfo *),
00533 XHighlightLine(Display *,Window,GC,const XSegment *),
00534 XHighlightRectangle(Display *,Window,GC,const RectangleInfo *),
00535 XGetAnnotateInfo(XAnnotateInfo *),
00536 XGetPixelInfo(Display *,const XVisualInfo *,const XStandardColormap *,
00537 const XResourceInfo *,Image *,XPixelInfo *),
00538 XGetMapInfo(const XVisualInfo *,const Colormap,XStandardColormap *),
00539 XGetWindowInfo(Display *,XVisualInfo *,XStandardColormap *,XPixelInfo *,
00540 XFontStruct *,XResourceInfo *,XWindowInfo *),
00541 XMakeMagnifyImage(Display *,XWindows *,ExceptionInfo *),
00542 XMakeStandardColormap(Display *,XVisualInfo *,XResourceInfo *,Image *,
00543 XStandardColormap *,XPixelInfo *,ExceptionInfo *),
00544 XMakeWindow(Display *,Window,char **,int,XClassHint *,XWMHints *,
00545 XWindowInfo *),
00546 XQueryPosition(Display *,const Window,int *,int *),
00547 XRefreshWindow(Display *,const XWindowInfo *,const XEvent *),
00548 XSetCursorState(Display *,XWindows *,const MagickStatusType),
00549 XUserPreferences(XResourceInfo *),
00550 XWarning(const ExceptionType,const char *,const char *);
00551
00552 extern MagickPrivate Window
00553 XWindowByID(Display *,const Window,const size_t),
00554 XWindowByName(Display *,const Window,const char *),
00555 XWindowByProperty(Display *,const Window,const Atom);
00556
00557 extern MagickPrivate XFontStruct
00558 *XBestFont(Display *,const XResourceInfo *,const MagickBooleanType);
00559
00560 extern MagickPrivate XVisualInfo
00561 *XBestVisualInfo(Display *,XStandardColormap *,XResourceInfo *);
00562
00563 extern MagickPrivate XWindows
00564 *XInitializeWindows(Display *,XResourceInfo *),
00565 *XSetWindows(XWindows *);
00566
00567 extern MagickExport char
00568 *XGetResourceClass(XrmDatabase,const char *,const char *,char *),
00569 *XGetResourceInstance(XrmDatabase,const char *,const char *,const char *),
00570 *XGetScreenDensity(Display *);
00571
00572 extern MagickExport int
00573 XError(Display *,XErrorEvent *);
00574
00575 extern MagickExport MagickBooleanType
00576 XRemoteCommand(Display *,const char *,const char *);
00577
00578 extern MagickExport void
00579 DestroyXResources(void),
00580 XDestroyResourceInfo(XResourceInfo *),
00581 XGetResourceInfo(const ImageInfo *,XrmDatabase,const char *,XResourceInfo *),
00582 XRetainWindowColors(Display *,const Window);
00583
00584 extern MagickExport XrmDatabase
00585 XGetResourceDatabase(Display *,const char *);
00586
00587 static inline double XPixelIntensity(const XColor *pixel)
00588 {
00589 double
00590 intensity;
00591
00592 if ((pixel->red == pixel->green) && (pixel->green == pixel->blue))
00593 return((double) pixel->red);
00594 intensity=0.212656*pixel->red+0.715158*pixel->green+0.072186*pixel->blue;
00595 return(intensity);
00596 }
00597
00598 #endif
00599
00600 extern MagickPrivate MagickBooleanType
00601 XRenderImage(Image *,const DrawInfo *,const PointInfo *,TypeMetric *,
00602 ExceptionInfo *);
00603
00604 #if defined(__cplusplus) || defined(c_plusplus)
00605 }
00606 #endif
00607
00608 #endif