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