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

  1. #ifndef _Paint_h
  2. #define _Paint_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: Paint.h,v 1.8 1996/04/19 08:52:40 torsten Exp $ */
  20.  
  21. /****************************************************************
  22.  *
  23.  * Paint widget
  24.  *
  25.  ****************************************************************/
  26.  
  27. /* Resources:
  28.  
  29.    Name              Class              RepType         Default Value
  30.    ----              -----              -------         -------------
  31.    background        Background         Pixel           XtDefaultBackground
  32.    border            BorderColor        Pixel           XtDefaultForeground
  33.    borderWidth       BorderWidth        Dimension       1
  34.    destroyCallback   Callback           Pointer         NULL
  35.    height            Height             Dimension       0
  36.    mappedWhenManaged MappedWhenManaged  Boolean         True
  37.    sensitive         Sensitive          Boolean         True
  38.    width             Width              Dimension       0
  39.    x                 Position           Position        0
  40.    y                 Position           Position        0
  41.  
  42.  */
  43.  
  44. /* define any special resource names here that are not in <X11/StringDefs.h> */
  45.  
  46. #define XtNpaintResource "paintResource"
  47. #define XtNpattern     "pattern"
  48. #define XtNgrid          "grid"
  49. #define XtNsnap          "snap"
  50. #define XtNsnapOn      "snapOn"
  51. #define XtNlineWidth     "lineWidth"
  52. #define XtNfatBack     "fatBack"
  53. #define XtNsizeChanged     "sizeChanged"
  54. #define XtNundoSize     "undoSize"
  55. #define XtNzoom          "zoom"
  56. #define XtNpaint     "paint"
  57. #define XtNzoomX     "zoomX"
  58. #define XtNzoomY     "zoomY"
  59. #define XtNdrawWidth     "drawWidth"
  60. #define XtNdrawHeight     "drawHeight"
  61. #define XtNcompress     "compress"
  62. #define XtNdirty     "dirty"
  63. #define XtNfillRule     "fillRule"
  64. #define XtNregionCallback    "regionSetCallback"
  65. #define XtNdownX        "downX"
  66. #define XtNdownY        "downY"
  67. #define XtNlineForeground    "lineForeground"
  68. #define XtNlinePattern        "linePattern"
  69. #define XtNlineFillRule        "lineFillRule"
  70. #ifndef XtNreadOnly
  71. #define XtNreadOnly        "readOnly"
  72. #endif
  73. #ifndef XtNcursor
  74. #define XtNcursor        "cursor"
  75. #endif
  76. #define XtNfilename        "filename"
  77. #define XtNmenuwidgets        "menuwidgets"
  78.  
  79. #define XtCPaintResource "PaintResource"
  80. #define XtCPattern     "Pattern"
  81. #define XtCGrid         "Grid"
  82. #define XtCSnap         "Snap"
  83. #define XtCSnapOn     "SnapOn"
  84. #define XtCLineWidth     "LineWidth"
  85. #define XtCFatBack     "FatBack"
  86. #define XtCSizeChanged     "SizeChanged"
  87. #define XtCUndoSize     "UndoSize"
  88. #define XtCZoom           "Zoom"
  89. #define XtCPaint     "Paint"
  90. #define XtCZoomX     "ZoomX"
  91. #define XtCZoomY     "ZoomY"
  92. #define XtCDrawWidth     "DrawWidth"
  93. #define XtCDrawHeight     "DrawHeight"
  94. #define XtCCompress     "Compress"
  95. #define XtCDirty     "Dirty"
  96. #define XtCFillRule     "FillRule"
  97. #define XtCRegionCallback    "RegionSetCallback"
  98. #define XtCDownX        "DownX"
  99. #define XtCDownY        "DownY"
  100. #define XtCLineForeground    "LineForeground"
  101. #define XtCLinePattern        "LinePattern"
  102. #define XtCLineFillRule        "LineFillRule"
  103. #ifndef XtCReadOnly
  104. #define XtCReadOnly        "ReadOnly"
  105. #endif
  106. #define XtCfilename        "Filename"
  107. #define XtCmenuwidgets        "Menuwidgets"
  108.  
  109. #define NMENUWIDGETS    3
  110.  
  111. /* declare specific PaintWidget class and instance datatypes */
  112.  
  113. typedef struct _PaintClassRec *PaintClass;
  114. typedef struct _PaintRec *PaintWidget;
  115.  
  116. /* declare the class constant */
  117.  
  118. extern WidgetClass paintWidgetClass;
  119.  
  120. /*
  121. **  Operation callback information
  122.  */
  123. typedef enum {
  124.     opPixmap = 0x01, opWindow = 0x02
  125. } OpSurface;
  126.  
  127. typedef struct {
  128.     int refCount;
  129.     OpSurface surface;
  130.     Drawable drawable;
  131.     GC first_gc, second_gc, base_gc;
  132.     void *data;
  133.     int isFat;
  134.     int x, y;
  135.     int realX, realY;
  136.     int zoom;
  137.     Pixmap base;
  138. } OpInfo;
  139.  
  140. typedef float pwMatrix[2][2];
  141.  
  142. typedef void (*OpEventProc) (Widget, void *, XEvent *, OpInfo *);
  143. void OpRemoveEventHandler(Widget, int, int, Boolean, OpEventProc, void *);
  144. void OpAddEventHandler(Widget, int, int, Boolean, OpEventProc, void *);
  145. void UndoStart(Widget, OpInfo *);
  146. void UndoStartRectangle(Widget, OpInfo *, XRectangle *);
  147. void UndoStartPoint(Widget, OpInfo *, int, int);
  148. void UndoSetRectangle(Widget, XRectangle *);
  149. void UndoGrow(Widget, int, int);
  150.  
  151. Pixmap PwUndoStart(Widget, XRectangle *);
  152. void PwUndoSetRectangle(Widget, XRectangle *);
  153. void PwUndoAddRectangle(Widget, XRectangle *);
  154. void Undo(Widget);
  155. void Redo(Widget);
  156. void UndoInitialize(PaintWidget pw, int n);
  157.  
  158. #define PwZoomParent    ((int) -10000)
  159.  
  160. /*
  161. **  Public functions
  162.  */
  163.  
  164. void PwUpdateFromLast(Widget, XRectangle *);
  165. void PwUpdate(Widget, XRectangle *, Boolean);
  166. void PwUpdateDrawable(Widget, Drawable, XRectangle *);
  167. void PwSetDrawn(Widget, Boolean);
  168. void PwGetPixmap(Widget, Pixmap *, int *, int *);
  169. void PwPutPixmap(Widget w, Pixmap pix);
  170. XRectangle *PwScaleRectangle(Widget, XRectangle *);
  171. XImage *PwGetImage(Widget, XRectangle *);
  172.  
  173. /*
  174. **  Region routines
  175.  */
  176. void PwRegionSet(Widget, XRectangle *, Pixmap, Pixmap);
  177. void PwRegionSetRawPixmap(Widget, Pixmap);
  178. void PwRegionTear(Widget);
  179. Boolean PwRegionGet(Widget, Pixmap *, Pixmap *);
  180. Pixmap PwGetRawPixmap(Widget);
  181. void PwRegionSetMatrix(Widget, pwMatrix);
  182. void PwRegionAppendMatrix(Widget, pwMatrix);
  183. void PwRegionAddScale(Widget, float *, float *);
  184. void PwRegionSetScale(Widget, float *, float *);
  185. void PwRegionReset(Widget, Boolean);
  186. void PwRegionClear(Widget);
  187. void PwRegionFinish(Widget, Boolean);
  188. Boolean PwRegionOff(Widget w, Boolean flag);
  189.  
  190. typedef Pixmap(*pwRegionDoneProc) (Widget, XImage *, pwMatrix);
  191.  
  192. void PwRegionSetDone(Widget, pwRegionDoneProc);
  193.  
  194. void RegionCrop(PaintWidget paint);
  195. void RegionMove(PaintWidget pw, int dx, int dy);
  196.  
  197. #endif                /* _Paint_h */
  198.