home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WCANVAS.HPP < prev    next >
C/C++ Source or Header  |  1997-01-24  |  28KB  |  881 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.         // FillRectangle
  605.         //
  606.         //    Fill the given rectangle.  If no brush is given, uses
  607.         //    the current brush setting.
  608.  
  609.         WBool FillRectangle( const WRect & rect,
  610.                              const WBrush * useBrush=NULL );
  611.  
  612.         // FillRegion
  613.         //
  614.         //    Fill the given region.  If no brush is given, uses
  615.         //    the current brush setting.
  616.  
  617.         WBool FillRegion( const WRegion & region,
  618.                           const WBrush * useBrush=NULL );
  619.  
  620.         // FloodFill
  621.  
  622.         WBool FloodFill( const WPoint & start, const WColor & borderColor,
  623.                          WFloodFillTypes type=WFFBorder );
  624.  
  625.         // FrameRectangle
  626.         //
  627.         //    Draws border around specified rectangle using brush, 1 unit wide
  628.  
  629.         WBool FrameRectangle( const WRect & rect, const WBrush * brush=NULL );
  630.  
  631.         // FrameRegion
  632.         //
  633.         //    Frame the given region.  If no brush is given, uses
  634.         //    the current brush setting.
  635.  
  636.         WBool FrameRegion( const WRegion & region,
  637.                            const WBrush * useBrush=NULL,
  638.                            WInt width=1, WInt height=1 );
  639.  
  640.         // InvertRectangle
  641.         //
  642.         //    Inverts a rectangle by performing a logical NOT operation
  643.  
  644.         WBool InvertRectangle( const WRect & rect );
  645.  
  646.         // InvertRegion
  647.  
  648.         WBool InvertRegion( const WRegion & region );
  649.  
  650.         // PaintRegion
  651.         //
  652.         //    Uses the current brush setting
  653.  
  654.         WBool PaintRegion( const WRegion & region );
  655.  
  656.         // RealizePalette
  657.  
  658.         WInt RealizePalette();
  659.  
  660.         // Reset
  661.         //
  662.         //    Resets the canvas to its original state, optionally
  663.         //    popping the stack of saved states.
  664.  
  665.         WBool Reset( WBool popStack=TRUE );
  666.  
  667.         // Restore
  668.         //
  669.         //    Restores the canvas to a previously-saved state.
  670.  
  671.         WBool Restore( WInt stateIndex );
  672.  
  673.         // Save
  674.         //
  675.         //    Saves the canvas state.  If return value is 0,
  676.         //    failed, otherwise it's the state index.
  677.  
  678.         WInt Save();
  679.  
  680.         // UpdateColors
  681.  
  682.         WBool UpdateColors();
  683.  
  684.         /**********************************************************
  685.          * Item Properties
  686.          *********************************************************/
  687.  
  688.         // SetPixel/GetPixel
  689.         //
  690.         // Get or set the colour of a given pixel location
  691.         //
  692.         // Note: GetPixel() will not always work for an arbitrary location,
  693.         // even if the point is within the bounds of your DC. It will only
  694.         // work if the point being retrieved is inside the clipping
  695.         // region. Also note that you can only make the clipping region
  696.         // SMALLER than the current clipping region. 
  697.         // See MS Knowledge base PSS ID #: Q119472 for more info.
  698.  
  699.         WBool SetPixel( WPoint loc, WColor &color,
  700.                         WBool useClosestColor = FALSE );
  701.         WColor GetPixel( WPoint loc );
  702.  
  703.         /**********************************************************
  704.          * Private
  705.          *********************************************************/
  706.  
  707.     protected:
  708. };
  709.  
  710. //
  711. // WDisplayCanvas
  712. //
  713.  
  714. class WCMCLASS WDisplayCanvas : public WCanvas {
  715.     WDeclareSubclass( WDisplayCanvas, WCanvas );
  716.  
  717.     public:
  718.  
  719.         /**********************************************************
  720.          * Constructors and Destructors
  721.          *********************************************************/
  722.  
  723.         WDisplayCanvas();
  724.         WDisplayCanvas( const WDisplayCanvas & canvas );
  725.         WDisplayCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE,
  726.                         const WWindow *window=NULL );
  727.         WDisplayCanvas( const WChar *driverName, const WChar *deviceName,
  728.                         const void *deviceData );
  729.         WDisplayCanvas( const WWindow *window, WBool inPaint=FALSE,
  730.                         WBool nonClient=FALSE );
  731.  
  732.         ~WDisplayCanvas();
  733.  
  734.         WDisplayCanvas& operator=( const WDisplayCanvas & c );
  735.  
  736.         /**********************************************************
  737.          * Methods
  738.          *********************************************************/
  739.  
  740.         // Clear
  741.  
  742.         virtual void Clear();
  743.  
  744.         // Create
  745.  
  746.         virtual WBool Create( const WDisplayCanvas & canvas );
  747.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE,
  748.                               const WWindow * window=NULL );
  749.         virtual WBool Create( const WChar * driverName,
  750.                               const WChar * deviceName,
  751.                               const void * deviceData );
  752.         virtual WBool Create( const WWindow * window, WBool inPaint=FALSE,
  753.                               WBool nonClient=FALSE );
  754.  
  755.         /**********************************************************
  756.          * Private
  757.          *********************************************************/
  758.  
  759.     protected:
  760.  
  761.         const WWindow *_window;
  762. };
  763.     
  764. //
  765. // WPrinterCanvas
  766. //
  767.  
  768. class WCMCLASS WPrinterCanvas : public WCanvas {
  769.     WDeclareSubclass( WPrinterCanvas, WCanvas );
  770.  
  771.  
  772.     public:
  773.  
  774.         /**********************************************************
  775.          * Constructors and Destructors
  776.          *********************************************************/
  777.  
  778.         WPrinterCanvas();
  779.         WPrinterCanvas( const WPrinterCanvas & canvas );
  780.         WPrinterCanvas( WDeviceHandle dev, WBool deleteHandle=FALSE );
  781.         WPrinterCanvas( const WChar *driverName, const WChar *deviceName,
  782.                         const void *deviceData );
  783.         WPrinterCanvas( const WPrinterData & printerData );
  784.  
  785.         ~WPrinterCanvas();
  786.  
  787.         WPrinterCanvas& operator=( const WPrinterCanvas & c );
  788.  
  789.         /**********************************************************
  790.          * Properties
  791.          *********************************************************/
  792.  
  793.         // JobID
  794.         //
  795.         //    Returns the current job ID if a document is being
  796.         //    printed.
  797.  
  798.         WInt GetJobID() const;
  799.  
  800.         // PageNumber
  801.         //
  802.         //    Returns the current page number if a document is
  803.         //    being printed.
  804.  
  805.         WInt GetPageNumber() const;
  806.  
  807.         /**********************************************************
  808.          * Methods
  809.          *********************************************************/
  810.  
  811.         // AbortDocument
  812.  
  813.         WBool AbortDocument();
  814.  
  815.         // Clear
  816.  
  817.         virtual void Clear();
  818.  
  819.         // Create
  820.  
  821.         virtual WBool Create( const WPrinterCanvas & canvas );
  822.         virtual WBool Create( WDeviceHandle dev, WBool deleteHandle=FALSE );
  823.         virtual WBool Create( const WChar * driverName,
  824.                               const WChar * deviceName,
  825.                               const void * deviceData );
  826.         virtual WBool Create( const WPrinterData & printerData );
  827.  
  828.         // EndDocument
  829.         //
  830.         //    Finish spooling the document.
  831.  
  832.         WBool EndDocument();
  833.  
  834.         // EndPage
  835.         //
  836.         //    Finish spooling a page.
  837.  
  838.         WBool EndPage();
  839.  
  840.         // StartDocument
  841.         //
  842.         //    Prepare a new document for printing.  If this is called
  843.         //    while still printing a document, the current document
  844.         //    is ended first.
  845.  
  846.         WBool StartDocument( const WChar *documentName=NULL,
  847.                              const WChar *printToFilePath=NULL );
  848.  
  849.         // StartPage
  850.         //
  851.         //    Prepare a page for printing.  If this is called while
  852.         //    still printing a page, the current page is ended first.
  853.         //    By default the canvas state is saved across pages.
  854.  
  855.         WBool StartPage( WBool saveState=TRUE );
  856.  
  857.         /**********************************************************
  858.          * Private
  859.          *********************************************************/
  860.  
  861.     private:
  862.         WBool _printingPage;
  863.         WInt  _jobID;
  864.         WInt  _pageNumber;
  865. };
  866.  
  867. #pragma warning 849 1
  868.  
  869. #ifdef _DEBUG
  870. #define W_ISCANVASHANDLE(h) CHECKGDI(WInfoCanvas::IsValidHandle((WDeviceHandle)h))
  871. #else
  872. #define W_ISCANVASHANDLE(h)
  873. #endif
  874.  
  875. #ifndef _WNO_PRAGMA_PUSH
  876. #pragma enum pop;
  877. #pragma pack(pop);
  878. #endif
  879.  
  880. #endif // _WCANVAS_HPP_INCLUDED
  881.