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