home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WCANVAS.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  28KB  |  877 lines

  1.  
  2. /*************************************************************************
  3.  *
  4.  * WCanvas
  5.  *
  6.  *************************************************************************/
  7.  
  8. #ifndef _WCANVAS_HPP_INCLUDED
  9. #define _WCANVAS_HPP_INCLUDED
  10.  
  11. #ifndef _WNO_PRAGMA_PUSH
  12. #pragma pack(push,8);
  13. #pragma enum int;
  14. #endif
  15.  
  16. #ifndef _WPOINT_HPP_INCLUDED
  17. #  include "wpoint.hpp"
  18. #endif
  19. #ifndef _WRECT_HPP_INCLUDED
  20. #  include "wrect.hpp"
  21. #endif
  22. #ifndef _WREGION_HPP_INCLUDED
  23. #  include "wregion.hpp"
  24. #endif
  25.  
  26. class WFont;
  27. class WBrush;
  28. class WPalette;
  29. class WColor;
  30. class WPen;
  31. class WBitmap;
  32. class WIcon;
  33. class WCursor;
  34. class WWindow;
  35. class WPrinterData;
  36.  
  37. #ifndef _WIN16
  38. #undef TextOut
  39. #undef DrawText
  40. #undef GetTextMetrics
  41. #if defined( _UNICODE )
  42. #define TextOut         TextOutW
  43. #define DrawText        DrawTextW
  44. #define GetTextMetrics  GetTextMetricsW
  45. #else
  46. #define TextOut         TextOutA
  47. #define DrawText        DrawTextA
  48. #define GetTextMetrics  GetTextMetricsA
  49. #endif
  50. #endif
  51.  
  52. #define WROPBlackness                   ((WULong)0x00000042L)
  53. #define WROPWhiteness                   ((WULong)0x00FF0062L)
  54. #define WROPCopySource                  ((WULong)0x00CC0020L)
  55. #define WROPPaintSource                 ((WULong)0x00EE0086L)
  56. #define WROPEraseSource                 ((WULong)0x00440328L)
  57. #define WROPInvertSource                ((WULong)0x00660046L)
  58. #define WROPCombineSource               ((WULong)0x008800C6L)
  59. #define WROPCopySourceAndInvert         ((WULong)0x00330008L)
  60. #define WROPEraseSourceAndInvert        ((WULong)0x001100A6L)
  61.  
  62. #define WTextAlignBaseline              ((WULong)0x00000018L)
  63. #define WTextAlignBottom                ((WULong)0x00000008L)
  64. #define WTextAlignTop                   ((WULong)0x00000000L)
  65. #define WTextAlignCenter                ((WULong)0x00000006L)
  66. #define WTextAlignLeft                  ((WULong)0x00000000L)
  67. #define WTextAlignRight                 ((WULong)0x00000002L)
  68. #define WTextAlignRTLReading            ((WULong)0x00000100L)
  69. #define WTextAlignRightToLeftReading    ((WULong)0x00000100L)
  70. #define WTextAlignNoUpdateCP            ((WULong)0x00000000L)
  71. #define WTextAlignNoUpdateCurrentPos    ((WULong)0x00000000L)
  72. #define WTextAlignUpdateCP              ((WULong)0x00000001L)
  73. #define WTextAlignUpdateCurrentPos      ((WULong)0x00000001L)
  74.  
  75. #define WDrawOptionOpaque                   0x0002
  76. #define WDrawOptionClipped                  0x0004
  77. #define WDrawOptionGlyphIndex               0x0010
  78. #define WDrawOptionRightToLeftReading       0x0080
  79.  
  80. enum WCBackgroundMode {
  81.     WCBMTransparent = 1,
  82.     WCBMOpaque = 2,
  83. };
  84.  
  85. enum WCMappingMode {
  86.     WCMMError = 0,
  87.     WCMMText = 1,           WCMMPixels = WCMMText,
  88.     WCMMLoMetric = 2,
  89.     WCMMHiMetric = 3,
  90.     WCMMLoEnglish = 4,
  91.     WCMMHiEnglish = 5,
  92.     WCMMTwips = 6,
  93.     WCMMIsotropic = 7,
  94.     WCMMAnisotropic = 8
  95. };
  96.  
  97. enum WCanvasCapabilities {
  98.     WCCHorizontalMM = 4,          // millimeters
  99.     WCCVerticalMM = 6,          // millimeters
  100.     WCCHorizontalPixels = 8,
  101.     WCCVerticalPixels = 10,
  102.     WCCLogicalPixelsX = 88,
  103.     WCCLogicalPixelsY = 90,
  104. };
  105.  
  106. enum WFloodFillTypes {
  107.     WFFBorder = 0,
  108.     WFFSurface = 1
  109. };
  110.  
  111. enum WForeMixMode {
  112.     WFMMBlack           = 1,
  113.     WFMMNotMergePen     = 2,
  114.     WFMMMAskNotPen      = 3,
  115.     WFMMNotCopyPen      = 4,
  116.     WFMMMaskPenNot      = 5,
  117.     WFMMNot             = 6,
  118.     WFMMXorPen          = 7,
  119.     WFMMNotMaskPen      = 8,
  120.     WFMMMaskPen         = 9,
  121.     WFMMNororPen        = 10,
  122.     WFMMNop             = 11,
  123.     WFMMMergeNorPen     = 12,
  124.     WFMMCopyPen         = 13,
  125.     WFMMMergePenNot     = 14,
  126.     WFMMMergePen        = 15,
  127.     WFMMWhite           = 16,
  128.     WFMMLast            = 16,
  129. };
  130.  
  131. enum WArcDirection {
  132.     WADCounterClockWise = 1,
  133.     WADClockWise        = 2,
  134. };
  135.  
  136. #define WDrawTextTop              ((WULong)0x00000000)
  137. #define WDrawTextLeft             ((WULong)0x00000000)
  138. #define WDrawTextCenter           ((WULong)0x00000001)
  139. #define WDrawTextRight            ((WULong)0x00000002)
  140. #define WDrawTextVCenter          ((WULong)0x00000004)
  141. #define WDrawTextBottom           ((WULong)0x00000008)
  142. #define WDrawTextWordBreak        ((WULong)0x00000010)
  143. #define WDrawTextSingleLine       ((WULong)0x00000020)
  144. #define WDrawTextExpandTabs       ((WULong)0x00000040)
  145. #define WDrawTextTabStop          ((WULong)0x00000080)
  146. #define WDrawTextNoClip           ((WULong)0x00000100)
  147. #define WDrawTextExternalLeading  ((WULong)0x00000200)
  148. #define WDrawTextCalcRect         ((WULong)0x00000400)
  149. #define WDrawTextNoPrefix         ((WULong)0x00000800)
  150. #define WDrawTextEditControl      ((WULong)0x00002000)
  151. #define WDrawTextPathEllipsis     ((WULong)0x00004000)
  152. #define WDrawTextEndEllipsis      ((WULong)0x00008000)
  153. #define WDrawTextModifyString     ((WULong)0x00010000)
  154. #define WDrawTextRTLReading       ((WULong)0x00020000)
  155. #define WDrawTextWordEllipsis     ((WULong)0x00040000)
  156.  
  157. #define WDrawTextDefault          ((WULong)0x00000800)
  158.  
  159. #define WDrawIconCompat         0x0004
  160. #define WDrawIconDefaultSize    0x0008
  161. #define WDrawIconImage          0x0002
  162. #define WDrawIconMask           0x0001
  163. #define WDrawIconNormal         0x0003
  164.  
  165. #define WDrawCursorCompat       WDrawIconCompat         
  166. #define WDrawCursorDefaultSize  WDrawIconDefaultSize    
  167. #define WDrawCursorImage        WDrawIconImage          
  168. #define WDrawCursorMask         WDrawIconMask           
  169. #define WDrawCursorNormal       WDrawIconNormal
  170.  
  171. class WCanvasReference; // internal use only
  172.  
  173. //
  174. // TextMetrics -- Use to obtain information on a selected font.
  175. //
  176.  
  177. struct WTextMetrics {
  178.     WLong height;
  179.     WLong ascent;
  180.     WLong descent;
  181.     WLong internalLeading;
  182.     WLong externalLeading;
  183.     WLong averageWidth;
  184.     WLong maximumWidth;
  185. };
  186.  
  187. //
  188. // WInfoCanvas
  189. //
  190.  
  191. #pragma warning 849 9
  192.  
  193. class WCMCLASS WInfoCanvas : public WObject {
  194.     WDeclareSubclass( WInfoCanvas, WObject );
  195.  
  196.     public:
  197.  
  198.         /**********************************************************
  199.          * Constructors and Destructors
  200.          *********************************************************/
  201.  
  202.         WInfoCanvas();
  203.         WInfoCanvas( const WInfoCanvas & canvas );
  204.         WInfoCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  205.         WInfoCanvas( const WChar *driverName, const WChar *deviceName,
  206.                      const void *deviceData );
  207.         ~WInfoCanvas();
  208.  
  209.         WInfoCanvas& operator=( const WInfoCanvas & ic );
  210.  
  211.         /**********************************************************
  212.          * Properties
  213.          *********************************************************/
  214.  
  215.         // Handle
  216.         //
  217.         //    Returns the low-level HDC that corresponds to the canvas.
  218.  
  219.         WDeviceHandle GetHandle() const;
  220.  
  221.         // Size
  222.         //
  223.         //    Returns a rectangle representing the size (in pixels)
  224.         //    of the canvas, with top & left always set to 0.
  225.  
  226.         WRect GetSize() const;
  227.  
  228.         /**********************************************************
  229.          * Methods
  230.          *********************************************************/
  231.  
  232.         // Clear
  233.  
  234.         virtual void Clear();
  235.  
  236.         // Create
  237.  
  238.         virtual WBool Create( const WInfoCanvas & canvas );
  239.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  240.         virtual WBool Create( const WChar * driverName,
  241.                               const WChar * deviceName,
  242.                               const void * deviceData );
  243.  
  244.         // QueryCapability
  245.         //
  246.         //    Query the capabilities the device has.
  247.  
  248.         WInt QueryCapability( WCanvasCapabilities capability ) const;
  249.  
  250.         /**********************************************************
  251.          * Static Methods
  252.          *********************************************************/
  253.  
  254.         // IsValidHandle
  255.         //
  256.         //    Returns TRUE if the given handle is valid.
  257.  
  258.         static WBool IsValidHandle( WDeviceHandle handle,
  259.                                     WBool nullValid=FALSE );
  260.  
  261.         /**********************************************************
  262.          * Private
  263.          *********************************************************/
  264.  
  265.     protected:
  266.  
  267.         WCanvasReference *_ref;
  268. };
  269.  
  270. //
  271. // WCanvas
  272. //
  273.  
  274. class WCMCLASS WCanvas : public WInfoCanvas {
  275.     WDeclareSubclass( WCanvas, WInfoCanvas );
  276.     
  277.     public:
  278.  
  279.         /**********************************************************
  280.          * Constructors and Destructors
  281.          *********************************************************/
  282.  
  283.         WCanvas();
  284.         WCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  285.         WCanvas( const WChar *driverName, const WChar *deviceName,
  286.                  const void *deviceData );
  287.         WCanvas( const WCanvas & canvas, WBool makeMemoryDC=FALSE ); 
  288.  
  289.         ~WCanvas();
  290.  
  291.         WCanvas& operator=( const WCanvas & c );
  292.  
  293.         /**********************************************************
  294.          * Properties
  295.          *********************************************************/
  296.  
  297.         // ArcDirection
  298.         //
  299.         //     The drawing direction to be used for arc and rectangle
  300.         //     functions
  301.  
  302.         WBool SetArcDirection( WArcDirection direction );
  303.         WArcDirection GetArcDirection();
  304.  
  305.         // BackColor
  306.         //
  307.         //    Set the background color for drawing.
  308.  
  309.         WBool  SetBackColor( const WColor & color );
  310.         WColor GetBackColor() const;
  311.  
  312.         // BackMode
  313.         //
  314.         //    Set/get the background drawing mode.
  315.  
  316.         WBool            SetBackMode( WCBackgroundMode mode );
  317.         WCBackgroundMode GetBackMode() const;
  318.  
  319.         // Bitmap
  320.         //
  321.         //    Set/get the bitmap associated with a canvas.
  322.  
  323.         WBool SetBitmap( const WBitmap & newBitmap );
  324.         WBitmap GetBitmap() const;
  325.  
  326.         // Brush
  327.         //
  328.         //    Set/get the brush associated with a canvas.
  329.  
  330.         WBool SetBrush( const WBrush & newBrush );
  331.         WBrush GetBrush() const;
  332.  
  333.         // ClippingRectangle
  334.         //
  335.         //    Returns the current clipping rectangle.
  336.  
  337.         WRect GetClippingRectangle() const;
  338.         WBool SetClippingRectangle( const WRect & r );
  339.  
  340.         // DrawPosition
  341.         //
  342.         //    The current position of the pen.
  343.  
  344.         WBool  SetDrawPosition( const WPoint & point );
  345.         WPoint GetDrawPosition() const;
  346.  
  347.         // Font
  348.         //
  349.         //    Set/get the font associated with a canvas.
  350.  
  351.         WBool SetFont( const WFont & newFont );
  352.         WFont GetFont() const;
  353.  
  354.         // ForeMixMode
  355.         //
  356.         //     The current foreground mix mode
  357.  
  358.         WBool SetForeMixMode( WForeMixMode mode );
  359.         WForeMixMode GetForeMixMode();
  360.  
  361.         // MappingMode
  362.         //
  363.         //    Set/get the mapping mode for the canvas.
  364.  
  365.         WCMappingMode GetMappingMode() const;
  366.         WBool         SetMappingMode( WCMappingMode mode );
  367.  
  368.         // Palette
  369.         //
  370.         //    Set/get the palette associated with a canvas.
  371.         //    Choose forceBackground=TRUE when RealizePalette is to
  372.         //    map the logical palette to the physical palette (in the
  373.         //    best possible way).
  374.  
  375.         WBool SetPalette( const WPalette & newPalette,
  376.                           WBool forceBackground=FALSE );
  377.         WPalette GetPalette() const;
  378.  
  379.         // Pen
  380.         //
  381.         //    Set/get the pen associated with a canvas.
  382.  
  383.         WBool SetPen( const WPen & newPen );
  384.         WPen GetPen() const;
  385.  
  386.         // PolygonFillMode
  387.         //
  388.         //    Set/get the polygon fill mode
  389.  
  390.         WBool            SetPolygonFillMode( WPolygonFillMode mode );
  391.         WPolygonFillMode GetPolygonFillMode() const;
  392.  
  393.         // TextAlignment
  394.         //
  395.         //    The text alignment.
  396.  
  397.         WBool  SetTextAlignment( WULong flags );
  398.         WULong GetTextAlignment() const;
  399.  
  400.         // TextColor
  401.         //
  402.         //    The text color for drawing.
  403.  
  404.         WBool  SetTextColor( const WColor & color );
  405.         WColor GetTextColor() const;
  406.  
  407.         // TextMetrics
  408.         //
  409.         //    Returns metrics of the currently-selected font.
  410.  
  411.         WTextMetrics GetTextMetrics() const;
  412.  
  413.         /**********************************************************
  414.          * Methods
  415.          *********************************************************/
  416.  
  417.         // CalculateTextRectangle
  418.  
  419.         WBool CalculateTextRectangle( WRect & r, const WChar *text,
  420.                                       WInt numChars=-1 );
  421.  
  422.         // CalculateWrapLength
  423.         //
  424.         //    Given a width and a string, determines how many
  425.         //    characters in that string will fit in the width.
  426.         //    Also optinally fills in an array of text extents
  427.         //    for each character, up to the # of characters that
  428.         //    will fit.
  429.  
  430.         WInt CalculateWrapLength( WInt width, const WChar *text,
  431.                                   WInt numChars=-1, WInt *extents=NULL );
  432.  
  433.         // Clear
  434.         //
  435.         //    This clears (release or destroys) the HDC that
  436.         //    for the canvas.
  437.  
  438.         virtual void Clear();
  439.  
  440.         // Create
  441.  
  442.         virtual WBool Create( const WInfoCanvas & canvas );
  443.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  444.         virtual WBool Create( const WChar * driverName,
  445.                               const WChar * deviceName,
  446.                               const void * deviceData );
  447.         virtual WBool Create( const WCanvas & canvas,
  448.                               WBool makeMemoryDC=FALSE );
  449.  
  450.         // DrawArc
  451.         //
  452.         //     Draws an elliptical arc
  453.  
  454.         WBool DrawArc( const WRect & boundingRect, const WPoint & radial1end,
  455.                        const WPoint & radial2end,
  456.                        WBool useCurrentPosition=TRUE );
  457.  
  458.         // DrawBezierCurves
  459.         //
  460.         //     Draws a series of Bezier curves
  461.  
  462.         WBool DrawBezierCurves( WPoint * pointArray, WInt numPoints,
  463.                                 WBool useCurrentPosition=TRUE );
  464.  
  465.         // DrawBitmap
  466.         //
  467.         //    Draws a bitmap,
  468.  
  469.         WBool DrawBitmap( const WBitmap & bitmap, const WRect & dest,
  470.                           WBool stretch=TRUE, WULong rop=WROPCopySource );
  471.         WBool DrawBitmap( const WBitmap & bitmap, const WRect & dest,
  472.                           const WRect & src, WBool stretch=TRUE,
  473.                           WULong rop=WROPCopySource );
  474.  
  475.         // DrawChord
  476.         //
  477.         //     Draws a chord (a region bounded by the intersection of an
  478.         //                    ellipse and a line segment)
  479.  
  480.         WBool DrawChord( const WRect & boundingRect,
  481.                          const WPoint & radial1end,
  482.                          const WPoint & radial2end );
  483.  
  484.         // DrawEllipse
  485.         //
  486.         //    Draws an ellipse centered on the given rectangle.
  487.  
  488.         WBool DrawEllipse( const WRect & r, WBool fill=TRUE );
  489.  
  490.         // DrawFromCanvas
  491.         //
  492.         //    Draws the contents of another canvas into this canvas.
  493.  
  494.         WBool DrawFromCanvas( const WRect & destination,
  495.                               const WCanvas & sourceCanvas,
  496.                               WULong rop=WROPCopySource );
  497.         WBool DrawFromCanvas( const WRect & destination,
  498.                               const WPoint & source,
  499.                               const WCanvas & sourceCanvas,
  500.                               WULong rop=WROPCopySource );
  501.         WBool DrawFromCanvas( const WRect & destination,
  502.                               const WRect & source,
  503.                               const WCanvas & sourceCanvas,
  504.                               WULong rop=WROPCopySource,
  505.                               WBool stretch=FALSE );
  506.  
  507.         // DrawFocusRectangle
  508.         //
  509.         //    Draws a focus rectangle.  Call it a second time to
  510.         //    erase it.  
  511.  
  512.         WBool DrawFocusRectangle( const WRect & r );
  513.  
  514.         // DrawIcon
  515.         //
  516.         //    Draws an icon.
  517.  
  518.         WBool DrawIcon( const WIcon & icon, const WPoint & loc );
  519.         WBool DrawIcon( const WIcon & icon, const WPoint & loc,
  520.                         const WSize & size, WULong flags=WDrawIconNormal,
  521.                         const WBrush *brush=NULL, WULong index=0 );
  522.  
  523.         // DrawCursor
  524.         //
  525.         //    Draws an cursor.
  526.  
  527.         WBool DrawCursor( const WCursor & cursor, const WPoint & loc );
  528.         WBool DrawCursor( const WCursor & cursor, const WPoint & loc,
  529.                         const WSize & size, WULong flags=WDrawCursorNormal,
  530.                         const WBrush *brush=NULL, WULong index=0 );
  531.  
  532.         // DrawLine
  533.         //
  534.         //    Draws a line from the current/given position to the given
  535.         //    point.  Moves the current point.
  536.  
  537.         WBool DrawLine( const WPoint & endPoint );
  538.         WBool DrawLine( const WPoint & startPoint, const WPoint & endPoint );
  539.  
  540.         // DrawLines
  541.         //
  542.         //     Draws a series of line segments
  543.  
  544.         WBool DrawLines( WPoint * pointArray, WInt numPoints,
  545.                          WBool useCurrentPosition=TRUE );
  546.  
  547.         // DrawPolygons
  548.         //
  549.         //     Draw a series of closed polygons
  550.         
  551.         WBool DrawPolygons( WPoint * pointArray, WInt * vertexCountArray,
  552.                             WInt numPolygons );
  553.  
  554.         // DrawPie
  555.         //
  556.         //    Draws a pie piece.
  557.  
  558.         WBool DrawPie( const WRect & rect, const WPoint & firstRadial,
  559.                        const WPoint & secondRadial );
  560.     
  561.         // DrawPolygon
  562.         //
  563.         //    Draws a polygon.
  564.  
  565.         WBool DrawPolygon( WPoint * pointArray, WInt numPoints );
  566.  
  567.         // DrawRectangle
  568.         //
  569.         //    Draws a rectangle.  The outline is drawn with the current
  570.         //    pen, the inside is filled with the current brush if
  571.         //    fill is true.
  572.  
  573.         WBool DrawRectangle( const WRect & rect, WBool fill=TRUE );
  574.  
  575.         // DrawRoundRectangle
  576.         //
  577.         //    Like DrawRectangle, but draws round corners.
  578.  
  579.         WBool DrawRoundRectangle( const WRect & rect, WInt cornerWidth,
  580.                                   WInt cornerHeight, WBool fill=TRUE );
  581.  
  582.         // DrawText
  583.         //
  584.         //    Draws text.  The first form calls TextOut to draw a line
  585.         //    of text.  The second calls DrawTextEx to draw a line
  586.         //    or lines.  The third calls API DrawText. The forth call
  587.         //    ExtTextOut. In all cases if you pass an outputRect
  588.         //    as the last parameter, no drawing is done, but instead
  589.         //    the size of the drawn text is calculated.
  590.  
  591.         WBool DrawText( const WChar *string, WInt numChars=-1,
  592.                         WRect *outputRect=NULL, WInt space = 0);
  593.         WBool DrawText( const WPoint & pt, const WChar *string,
  594.                         WInt numChars=-1, 
  595.                         WRect *outputRect=NULL, WInt space = 0);
  596.         WBool DrawText( const WRect & rect, const WChar *string,
  597.                         WInt numChars=-1, WULong flags=WDrawTextDefault,
  598.                         WRect *outputRect=NULL );
  599.         WBool DrawText( const WPoint & pt, const WChar *string,
  600.                         WInt numChars, WUInt drawOptions,
  601.                         WRect clippingRect, WIntArray * spacing,
  602.                         WRect *outputRect=NULL);
  603.  
  604.         // SetPixel/GetPixel
  605.         //
  606.         // Get or set the colour of a given pixel location
  607.         //
  608.         // Note: GetPixel() will not always work for an arbitrary location,
  609.         // even if the point is within the bounds of your DC. It will only
  610.         // work if the point being retrieved is inside the clipping
  611.         // region. Also note that you can only make the clipping region
  612.         // SMALLER than the current clipping region. 
  613.         // See MS Knowledge base PSS ID #: Q119472 for more info.
  614.  
  615.         WBool SetPixel( WPoint loc, WColor &color,
  616.                         WBool useClosestColor = FALSE );
  617.         WColor GetPixel( WPoint loc );
  618.  
  619.         // FillRectangle
  620.         //
  621.         //    Fill the given rectangle.  If no brush is given, uses
  622.         //    the current brush setting.
  623.  
  624.         WBool FillRectangle( const WRect & rect,
  625.                              const WBrush * useBrush=NULL );
  626.  
  627.         // FillRegion
  628.         //
  629.         //    Fill the given region.  If no brush is given, uses
  630.         //    the current brush setting.
  631.  
  632.         WBool FillRegion( const WRegion & region,
  633.                           const WBrush * useBrush=NULL );
  634.  
  635.         // FloodFill
  636.  
  637.         WBool FloodFill( const WPoint & start, const WColor & borderColor,
  638.                          WFloodFillTypes type=WFFBorder );
  639.  
  640.         // FrameRectangle
  641.         //
  642.         //    Draws border around specified rectangle using brush, 1 unit wide
  643.  
  644.         WBool FrameRectangle( const WRect & rect, const WBrush * brush=NULL );
  645.  
  646.         // FrameRegion
  647.         //
  648.         //    Frame the given region.  If no brush is given, uses
  649.         //    the current brush setting.
  650.  
  651.         WBool FrameRegion( const WRegion & region,
  652.                            const WBrush * useBrush=NULL,
  653.                            WInt width=1, WInt height=1 );
  654.  
  655.         // InvertRectangle
  656.         //
  657.         //    Inverts a rectangle by performing a logical NOT operation
  658.  
  659.         WBool InvertRectangle( const WRect & rect );
  660.  
  661.         // InvertRegion
  662.  
  663.         WBool InvertRegion( const WRegion & region );
  664.  
  665.         // PaintRegion
  666.         //
  667.         //    Uses the current brush setting
  668.  
  669.         WBool PaintRegion( const WRegion & region );
  670.  
  671.         // RealizePalette
  672.  
  673.         WInt RealizePalette();
  674.  
  675.         // Reset
  676.         //
  677.         //    Resets the canvas to its original state, optionally
  678.         //    popping the stack of saved states.
  679.  
  680.         WBool Reset( WBool popStack=TRUE );
  681.  
  682.         // Restore
  683.         //
  684.         //    Restores the canvas to a previously-saved state.
  685.  
  686.         WBool Restore( WInt stateIndex );
  687.  
  688.         // Save
  689.         //
  690.         //    Saves the canvas state.  If return value is 0,
  691.         //    failed, otherwise it's the state index.
  692.  
  693.         WInt Save();
  694.  
  695.         // UpdateColors
  696.  
  697.         WBool UpdateColors();
  698.  
  699.         /**********************************************************
  700.          * Private
  701.          *********************************************************/
  702.  
  703.     protected:
  704. };
  705.  
  706. //
  707. // WDisplayCanvas
  708. //
  709.  
  710. class WCMCLASS WDisplayCanvas : public WCanvas {
  711.     WDeclareSubclass( WDisplayCanvas, WCanvas );
  712.  
  713.     public:
  714.  
  715.         /**********************************************************
  716.          * Constructors and Destructors
  717.          *********************************************************/
  718.  
  719.         WDisplayCanvas();
  720.         WDisplayCanvas( const WDisplayCanvas & canvas );
  721.         WDisplayCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE,
  722.                         const WWindow *window=NULL );
  723.         WDisplayCanvas( const WChar *driverName, const WChar *deviceName,
  724.                         const void *deviceData );
  725.         WDisplayCanvas( const WWindow *window, WBool inPaint=FALSE,
  726.                         WBool nonClient=FALSE );
  727.  
  728.         ~WDisplayCanvas();
  729.  
  730.         WDisplayCanvas& operator=( const WDisplayCanvas & c );
  731.  
  732.         /**********************************************************
  733.          * Methods
  734.          *********************************************************/
  735.  
  736.         // Clear
  737.  
  738.         virtual void Clear();
  739.  
  740.         // Create
  741.  
  742.         virtual WBool Create( const WDisplayCanvas & canvas );
  743.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE,
  744.                               const WWindow * window=NULL );
  745.         virtual WBool Create( const WChar * driverName,
  746.                               const WChar * deviceName,
  747.                               const void * deviceData );
  748.         virtual WBool Create( const WWindow * window, WBool inPaint=FALSE,
  749.                               WBool nonClient=FALSE );
  750.  
  751.         /**********************************************************
  752.          * Private
  753.          *********************************************************/
  754.  
  755.     protected:
  756.  
  757.         const WWindow *_window;
  758. };
  759.     
  760. //
  761. // WPrinterCanvas
  762. //
  763.  
  764. class WCMCLASS WPrinterCanvas : public WCanvas {
  765.     WDeclareSubclass( WPrinterCanvas, WCanvas );
  766.  
  767.  
  768.     public:
  769.  
  770.         /**********************************************************
  771.          * Constructors and Destructors
  772.          *********************************************************/
  773.  
  774.         WPrinterCanvas();
  775.         WPrinterCanvas( const WPrinterCanvas & canvas );
  776.         WPrinterCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  777.         WPrinterCanvas( const WChar *driverName, const WChar *deviceName,
  778.                         const void *deviceData );
  779.         WPrinterCanvas( const WPrinterData & printerData );
  780.  
  781.         ~WPrinterCanvas();
  782.  
  783.         WPrinterCanvas& operator=( const WPrinterCanvas & c );
  784.  
  785.         /**********************************************************
  786.          * Properties
  787.          *********************************************************/
  788.  
  789.         // JobID
  790.         //
  791.         //    Returns the current job ID if a document is being
  792.         //    printed.
  793.  
  794.         WInt GetJobID() const;
  795.  
  796.         // PageNumber
  797.         //
  798.         //    Returns the current page number if a document is
  799.         //    being printed.
  800.  
  801.         WInt GetPageNumber() const;
  802.  
  803.         /**********************************************************
  804.          * Methods
  805.          *********************************************************/
  806.  
  807.         // AbortDocument
  808.  
  809.         WBool AbortDocument();
  810.  
  811.         // Clear
  812.  
  813.         virtual void Clear();
  814.  
  815.         // Create
  816.  
  817.         virtual WBool Create( const WPrinterCanvas & canvas );
  818.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  819.         virtual WBool Create( const WChar * driverName,
  820.                               const WChar * deviceName,
  821.                               const void * deviceData );
  822.         virtual WBool Create( const WPrinterData & printerData );
  823.  
  824.         // EndDocument
  825.         //
  826.         //    Finish spooling the document.
  827.  
  828.         WBool EndDocument();
  829.  
  830.         // EndPage
  831.         //
  832.         //    Finish spooling a page.
  833.  
  834.         WBool EndPage();
  835.  
  836.         // StartDocument
  837.         //
  838.         //    Prepare a new document for printing.  If this is called
  839.         //    while still printing a document, the current document
  840.         //    is ended first.
  841.  
  842.         WBool StartDocument( const WChar *documentName=NULL,
  843.                              const WChar *printToFilePath=NULL );
  844.  
  845.         // StartPage
  846.         //
  847.         //    Prepare a page for printing.  If this is called while
  848.         //    still printing a page, the current page is ended first.
  849.         //    By default the canvas state is saved across pages.
  850.  
  851.         WBool StartPage( WBool saveState=TRUE );
  852.  
  853.         /**********************************************************
  854.          * Private
  855.          *********************************************************/
  856.  
  857.     private:
  858.         WBool _printingPage;
  859.         WInt  _jobID;
  860.         WInt  _pageNumber;
  861. };
  862.  
  863. #pragma warning 849 1
  864.  
  865. #ifdef _DEBUG
  866. #define W_ISCANVASHANDLE(h) CHECKGDI(WInfoCanvas::IsValidHandle((WDeviceHandle)h))
  867. #else
  868. #define W_ISCANVASHANDLE(h)
  869. #endif
  870.  
  871. #ifndef _WNO_PRAGMA_PUSH
  872. #pragma enum pop;
  873. #pragma pack(pop);
  874. #endif
  875.  
  876. #endif // _WCANVAS_HPP_INCLUDED
  877.