home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / xpaint-247 / paintp.h < prev    next >
C/C++ Source or Header  |  1996-06-25  |  5KB  |  187 lines

  1. #ifndef _PaintP_h
  2. #define _PaintP_h
  3.  
  4. /* +-------------------------------------------------------------------+ */
  5. /* | Copyright 1992, 1993, David Koblas (koblas@netcom.com)           | */
  6. /* | Copyright 1995, 1996 Torsten Martinsen (bullestock@dk-online.dk)  | */
  7. /* |                                       | */
  8. /* | Permission to use, copy, modify, and to distribute this software  | */
  9. /* | and its documentation for any purpose is hereby granted without   | */
  10. /* | fee, provided that the above copyright notice appear in all       | */
  11. /* | copies and that both that copyright notice and this permission    | */
  12. /* | notice appear in supporting documentation.     There is no           | */
  13. /* | representations about the suitability of this software for           | */
  14. /* | any purpose.  this software is provided "as is" without express   | */
  15. /* | or implied warranty.                           | */
  16. /* |                                       | */
  17. /* +-------------------------------------------------------------------+ */
  18.  
  19. /* $Id: PaintP.h,v 1.8 1996/04/19 09:03:59 torsten Exp $ */
  20.  
  21. #include "Paint.h"
  22.  
  23. #include <X11/IntrinsicP.h>    /* necessary for CoreP.h */
  24. /* include superclass private header file */
  25. #include <X11/CoreP.h>
  26. #include <X11/CompositeP.h>
  27. #include <X11/Xutil.h>
  28.  
  29. /* define unique representation types not found in <X11/StringDefs.h> */
  30.  
  31. #define XtRPaintResource "PaintResource"
  32.  
  33. typedef struct {
  34.     int empty;
  35. } PaintClassPart;
  36.  
  37. typedef struct _PaintClassRec {
  38.     CoreClassPart core_class;
  39.     CompositeClassPart composite_class;
  40.     PaintClassPart paint_class;
  41. } PaintClassRec;
  42.  
  43. extern PaintClassRec paintClassRec;
  44.  
  45. typedef struct s_undoStack {
  46.     XRectangle box;
  47.     Pixmap pixmap;
  48.     Boolean pushed;
  49.     struct s_undoStack *next;
  50. } UndoStack;
  51.  
  52. typedef struct {
  53.     int drawWidth, drawHeight;
  54.     int fillRule, lineFillRule;
  55.     GC gc, igc, fgc, sgc;
  56.     Pixmap sourcePixmap;
  57.     Pixmap pattern, linePattern;
  58.     int lineWidth;
  59.     XFontStruct *fontInfo;
  60.     Pixel foreground, background, lineForeground;
  61.     int undoSize;        /* number of undo stacks */
  62.  
  63.     /*
  64.     **    The undo system
  65.      */
  66.     Pixmap current;        /* The currently displayed pixmap */
  67.     UndoStack * undo, * head;
  68.     Boolean dirty;
  69.     /* The undo/redo stacks: */
  70.     int nlevels;        /* Maximum stack depth */
  71.     Pixmap * undostack, * redostack;
  72.     int undobot, undoitems, redobot, redoitems;
  73.  
  74.     Boolean snapOn, grid;
  75.     int snap;
  76.     void *eventList;
  77.     XtCallbackList fatcalls;
  78.     XtCallbackList sizecalls;
  79.     XtCallbackList regionCalls;
  80.     int zoomX, zoomY;
  81.     int zoom;
  82.     GC tgc;            /* scratch GC, for stuffing clip masks into */
  83.     GC mgc;            /* region mask GC, 1 bit deep */
  84.     GC xgc;            /* XOR (invert) GC */
  85.     Widget paint;
  86.     int paintChildrenSize;
  87.     Widget *paintChildren;
  88.     Pixel linePixel;
  89.     Boolean compress;
  90.     Cursor cursor;
  91.  
  92.     /*
  93.     **    Region info
  94.      */
  95.     struct {
  96.     Widget child;
  97.     Widget grip[9];
  98.     Position offX, offY;
  99.     Position baseX, baseY;
  100.     XRectangle rect, orig;
  101.     GC fg_gc, bg_gc;
  102.  
  103.     Boolean isTracking, isDrawn, isRotate;
  104.     float lastAngle;
  105.     Position lastX, lastY;
  106.     int fixedPoint;
  107.     float lineDelta[4], lineBase[2];
  108.     float startScaleX, startScaleY;
  109.  
  110.     Pixmap source, mask, notMask;
  111.     XImage *sourceImg, *maskImg, *notMaskImg;
  112.  
  113.     Boolean isAttached, isVisible, needResize;
  114.     Pixmap undoPixmap;
  115.     /*
  116.     **  The scale{X,Y} are combined with the rotMat
  117.     **    to produce mat.
  118.      */
  119.     float centerX, centerY;
  120.     float scaleX, scaleY;
  121.     pwMatrix rotMat, mat;
  122.  
  123.     int curZoom;
  124.     pwRegionDoneProc *proc;
  125.     } region;
  126.  
  127.     Boolean invalidateRegion;
  128.     Region imageRegion;
  129.     XImage *image;
  130.  
  131.     Position downX, downY;    /* Last button down X & Y pos */
  132.  
  133.     /*
  134.     **    Taken from our parent shell
  135.      */
  136.     Visual *visual;
  137.  
  138.     /*
  139.      * Used by the revert function
  140.      */
  141.     char *filename;
  142.  
  143.     WidgetList menuwidgets;
  144. } PaintPart;
  145.  
  146. #define PwPixmap(w)    ((w)->paint.active->pixmap)
  147.  
  148. typedef struct _PaintRec {
  149.     CorePart core;
  150.     CompositePart composite;
  151.     PaintPart paint;
  152. } PaintRec;
  153.  
  154.  
  155. #define _GET_PIXMAP(pw) ((pw)->paint.current)
  156. #define GET_PIXMAP(pw) (pw->paint.paint ? \
  157.         _GET_PIXMAP((PaintWidget)pw->paint.paint) : _GET_PIXMAP(pw))
  158.  
  159. #define _GET_ZOOM(pw)    pw->paint.zoom
  160. #define GET_ZOOM(pw) ((pw->paint.zoom == PwZoomParent) ? \
  161.         _GET_ZOOM(((PaintWidget)pw->paint.paint)) : _GET_ZOOM(pw))
  162.  
  163. #define GET_MGC(pw, msk)    ((pw)->paint.mgc == None ? \
  164.     (pw->paint.mgc = XCreateGC(XtDisplay(pw), msk, 0, 0)) : pw->paint.mgc)
  165.  
  166. void pwRegionZoomPosChanged(PaintWidget);
  167. void _PwZoomDraw(PaintWidget, Widget, GC, XImage *, XImage *,
  168.          Boolean, int, int, int, XRectangle *);
  169.  
  170. /*
  171. **  Try to optimize XGetPixel and XPutPixel
  172. **
  173.  */
  174. #define ZINDEX8(x, y, img)  ((y) * img->bytes_per_line) + (x)
  175. #define xxGetPixel(img, x, y)                    \
  176.         ((img->bits_per_pixel == 8) ?            \
  177.             img->data[ZINDEX8(x, y, img)] :        \
  178.             XGetPixel(img, x, y))
  179. #define xxPutPixel(img, x, y, p) do {                \
  180.         if (img->bits_per_pixel == 8)            \
  181.             img->data[ZINDEX8(x, y, img)] = p;    \
  182.         else                        \
  183.             XPutPixel(img, x, y, p);        \
  184.     } while (0)
  185.  
  186. #endif                /* _PaintP_h */
  187.