Jump to content

VDC: Difference between revisions

From EDM2
Ak120 (talk | contribs)
m Ak120 moved page The V C++ GUI Framework:vDC to VDC
Ak120 (talk | contribs)
mNo edit summary
 
Line 2: Line 2:


==Synopsis==
==Synopsis==
; '''Header:'''
;Header:<tt><v/vdc.h></tt>
: <tt><v/vdc.h></tt>
;Class name: vDC
; '''Class name:'''
: vDC


==Description==
==Description==
Line 13: Line 11:


==Utility Methods==
==Utility Methods==
 
;virtual void BeginPage():Supported by printer canvases. Call to specify a page is beginning. Bracket pages with <tt>BeginPage</tt> and <tt>EndPage</tt> calls.
====virtual void BeginPage()====
;virtual void BeginPrinting():Required by printer canvases. Call to specify a document is beginning. You ''must'' bracket documents with <tt>BeginPrinting</tt> and <tt>EndPrinting</tt> calls. <tt>BeginPrinting</tt> includes an implicit call to <tt>BeginPage</tt>.
Supported by printer canvases. Call to specify a page is beginning. Bracket pages with <tt>BeginPage</tt> and <tt>EndPage</tt> calls.
;virtual void Clear():Clear the canvas to the background color. No op on printers.
 
;virtual void ClearRect(int x, int y, int width, int height):Clear a rectangular area starting at x,y of height and width. No op on printers.
====virtual void BeginPrinting()====
;void CopyFromMemoryDC(vMemoryDC* memDC, int destX, int destY, int srcX = 0, int srcY = 0, int srcW = 0, int srcH = 0):This method is used to copy the image contained in a <tt>vMemoryDC</tt> to another drawing canvas. The parameter <tt>memDC</tt> specifies the <tt>vMemoryDC</tt> object, and <tt>destX</tt> and <tt>destY</tt> specify where the image is to be copied into <tt>this</tt> drawing canvas (which will usually be 0,0). If you use the default values for <tt>srcX=0</tt>, <tt>srcY=0</tt>, <tt>srcW=0</tt>, and <tt>srcH=0</tt>, the entire source canvas will be copied.
Required by printer canvases. Call to specify a document is beginning. You ''must'' bracket documents with <tt>BeginPrinting</tt> and <tt>EndPrinting</tt> calls. <tt>BeginPrinting</tt> includes an implicit call to <tt>BeginPage</tt>.
:Beginning with '''''V'''''release 1.13, <tt>CopyFromMemoryDC</tt> provides the extra parameters to specify an area of the source to copy. You can specify the source origin, and its width and height. The default values for these allow backward call and behavior compatibility.
 
:One of the most useful uses of this is to draw both the canvas pane drawing canvas, and to a memory drawing canvas, and then use <tt>CopyFromMemoryDC</tt> to copy the memory canvas to the canvas pane for <tt>Redraw</tt> events.
====virtual void Clear()====
;virtual void DrawAttrText(int x, int y, char* text, const ChrAttr attr):Draw text using the current font with specified attributes at given x, y.
Clear the canvas to the background color. No op on printers.
:<tt>ChrAttr attr</tt> is used to specify attributes to override some of the text drawing characteristics normally determined by the pen and font. Specifying <tt>ChNormal</tt> means the current pen and font will be used. <tt>ChReverse</tt> is used to specify the text should be drawn reversed or highlighted, using the current font and pen. You can also specify 16 different standard colors to override the pen color. You use <tt>ORed</tt> combinations the basic color attributes <tt>ChRed</tt>, <tt>ChBlue</tt>, and <tt>ChGreen</tt>. Most combinations are also provided as <tt>ChYellow</tt>, <tt>ChCyan</tt>, <tt>ChMagenta</tt>, <tt>ChWhite</tt>, and <tt>ChGray</tt>. These colors can be combined with <tt>ChDimColor</tt> can be used for half bright color combinations (or you can use <tt>ChDimRed</tt>, etc.). You can combine color attributes with <tt>ChReverse</tt>. Attributes such as boldface, size, and underlining are attributes of the font.
 
;virtual void DrawColorPoints(int x, int y, int nPts, vColor* pts):Draw an array of <tt>nPts</tt> <tt>vColors</tt> as points starting at x,y. This method is useful for drawing graphical images, and bypasses the need to set the pen or brush for each point. Typically, <tt>DrawColorPoints</tt> will be significantly faster than separate calls to <tt>DrawPoint</tt>.
====virtual void ClearRect(int x, int y, int width, int height)====
;virtual void DrawEllipse(int x, int y, int width, int height):Draw an ellipse inside the bounding box specified by x, y, width, and height. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
Clear a rectangular area starting at x,y of height and width. No op on printers.
;virtual void DrawIcon(int x, int y, vIcon& icon):A <tt>vIcon</tt> is drawn at x,y using the current Pen. Note that only the location of an icon is scaled. The icon will retain its original size.
 
;virtual void DrawLine(int x, int y, int xend, int yend):Draw a line from x,y to xend,yend. The current Pen will be used to draw the line.
====void CopyFromMemoryDC(vMemoryDC* memDC, int destX, int destY, int srcX = 0, int srcY = 0, int srcW = 0, int srcH = 0)====
;virtual void DrawLines(vLine* lineList, int count):Draws the <tt>count</tt> lines contained in the list <tt>lineList</tt>.
 
:The current Pen will be used to draw the lines.
This method is used to copy the image contained in a <tt>vMemoryDC</tt> to another drawing canvas. The parameter <tt>memDC</tt> specifies the <tt>vMemoryDC</tt> object, and <tt>destX</tt> and <tt>destY</tt> specify where the image is to be copied into <tt>this</tt> drawing canvas (which will usually be 0,0). If you use the default values for <tt>srcX=0</tt>, <tt>srcY=0</tt>, <tt>srcW=0</tt>, and <tt>srcH=0</tt>, the entire source canvas will be copied.
:The type <tt>vLine</tt> is defined in <tt>v_defs.h</tt> as:
 
Beginning with '''''V'''''release 1.13, <tt>CopyFromMemoryDC</tt> provides the extra parameters to specify an area of the source to copy. You can specify the source origin, and its width and height. The default values for these allow backward call and behavior compatibility.
 
One of the most useful uses of this is to draw both the canvas pane drawing canvas, and to a memory drawing canvas, and then use <tt>CopyFromMemoryDC</tt> to copy the memory canvas to the canvas pane for <tt>Redraw</tt> events.
 
====virtual void DrawAttrText(int x, int y, char* text, const ChrAttr attr)====
Draw text using the current font with specified attributes at given x, y.
 
<tt>ChrAttr attr</tt> is used to specify attributes to override some of the text drawing characteristics normally determined by the pen and font. Specifying <tt>ChNormal</tt> means the current pen and font will be used. <tt>ChReverse</tt> is used to specify the text should be drawn reversed or highlighted, using the current font and pen. You can also specify 16 different standard colors to override the pen color. You use <tt>ORed</tt> combinations the basic color attributes <tt>ChRed</tt>, <tt>ChBlue</tt>, and <tt>ChGreen</tt>. Most combinations are also provided as <tt>ChYellow</tt>, <tt>ChCyan</tt>, <tt>ChMagenta</tt>, <tt>ChWhite</tt>, and <tt>ChGray</tt>. These colors can be combined with <tt>ChDimColor</tt> can be used for half bright color combinations (or you can use <tt>ChDimRed</tt>, etc.). You can combine color attributes with <tt>ChReverse</tt>. Attributes such as boldface, size, and underlining are attributes of the font.
 
====virtual void DrawColorPoints(int x, int y, int nPts, vColor* pts)====
Draw an array of <tt>nPts</tt> <tt>vColors</tt> as points starting at x,y. This method is useful for drawing graphical images, and bypasses the need to set the pen or brush for each point. Typically, <tt>DrawColorPoints</tt> will be significantly faster than separate calls to <tt>DrawPoint</tt>.
 
====virtual void DrawEllipse(int x, int y, int width, int height)====
Draw an ellipse inside the bounding box specified by x, y, width, and height. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
 
====virtual void DrawIcon(int x, int y, vIcon& icon)====
A <tt>vIcon</tt> is drawn at x,y using the current Pen. Note that only the location of an icon is scaled. The icon will retain its original size.
 
====virtual void DrawLine(int x, int y, int xend, int yend)====
Draw a line from x,y to xend,yend. The current Pen will be used to draw the line.
 
====virtual void DrawLines(vLine* lineList, int count)====
Draws the <tt>count</tt> lines contained in the list <tt>lineList</tt>.
 
The current Pen will be used to draw the lines.
 
The type <tt>vLine</tt> is defined in <tt>v_defs.h</tt> as:
 
     typedef struct vLine
     typedef struct vLine
       {
       {
Line 63: Line 32:
       } vLine;
       } vLine;


====virtual void DrawLines(vPoint* points, int count)====
;virtual void DrawLines(vPoint* points, int count):Draws the <tt>count</tt> lines defined by the list of endpoints <tt>points</tt>. This is similar to drawing with a line list. The value of <tt>count</tt> must be 2 or greater. (New in version 1.19)
 
:The current Pen will be used to draw the lines.
Draws the <tt>count</tt> lines defined by the list of endpoints <tt>points</tt>. This is similar to drawing with a line list. The value of <tt>count</tt> must be 2 or greater. (New in version 1.19)
;virtual void DrawPoint(int x, int y):Draw a point at x,y using the current Pen.
 
;virtual void DrawPoints(vPoint* pointList, int count):Draws the <tt>count</tt> points contained in the list <tt>pointList</tt>.
The current Pen will be used to draw the lines.
:The current Pen will be used to draw the points.
 
:The type <tt>vPoint</tt> is defined in <tt>v_defs.h</tt> as:
====virtual void DrawPoint(int x, int y)====
 
Draw a point at x,y using the current Pen.
 
====virtual void DrawPoints(vPoint* pointList, int count)====
 
Draws the <tt>count</tt> points contained in the list <tt>pointList</tt>.
 
The current Pen will be used to draw the points.
 
The type <tt>vPoint</tt> is defined in <tt>v_defs.h</tt> as:
     typedef struct vPoint
     typedef struct vPoint
       {
       {
Line 85: Line 43:
       } vPoint;
       } vPoint;


====virtual void DrawPolygon(int n, vPoint points[], int fillMode = vAlternate)====
;virtual void DrawPolygon(int n, vPoint points[], int fillMode = vAlternate):A closed polygon of n points is drawn. Note that the first and last element of the point list must specify the same point. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
A closed polygon of n points is drawn. Note that the first and last element of the point list must specify the same point. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
:The fillMode parameter specifies one of two alternative filling algorithms, <tt>vAlternate</tt> or <tt>vWinding</tt>. These algorithms correspond to the equivalent algorithms on the native platforms.
 
:The type <tt>vPoint</tt> is defined in <tt>v_defs.h</tt> as:  
The fillMode parameter specifies one of two alternative filling algorithms, <tt>vAlternate</tt> or <tt>vWinding</tt>. These algorithms correspond to the equivalent algorithms on the native platforms.
 
The type <tt>vPoint</tt> is defined in <tt>v_defs.h</tt> as:  
     typedef struct vPoint      // a point
     typedef struct vPoint      // a point
       {
       {
Line 96: Line 51:
       } vPoint;
       } vPoint;


====virtual void DrawRoundedRectangle(int x, int y, int width, int height, int radius = 10)====
;virtual void DrawRoundedRectangle(int x, int y, int width, int height, int radius = 10):Draw a rectangle with rounded corners at x,y of size width and height. The radius specifies the radius of the circle used to draw the corners. If a radius of less than 0 is specified, the radius of the corners will be ((width+height)/-2*radius) which gives a more or less reasonable look for various sized rectangles. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
Draw a rectangle with rounded corners at x,y of size width and height. The radius specifies the radius of the circle used to draw the corners. If a radius of less than 0 is specified, the radius of the corners will be ((width+height)/-2*radius) which gives a more or less reasonable look for various sized rectangles. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
;virtual void DrawRectangle(int x, int y, int width, int height):Draw a rectangle with square corners at x,y of size width and height. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
 
;virtual void DrawRectangles(vRect* rectList, int count):Draw a list of <tt>count</tt> <tt>vRect</tt> rectangles pointed to by the list <tt>rectList</tt>. The current Pen will be used to draw the rectangles, and the current Brush will be used to fill the rectangles.
====virtual void DrawRectangle(int x, int y, int width, int height)====
:The type <tt>vRect</tt> is defined in <tt>v_defs.h</tt> as:
Draw a rectangle with square corners at x,y of size width and height. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
 
====virtual void DrawRectangles(vRect* rectList, int count)====
Draw a list of <tt>count</tt> <tt>vRect</tt> rectangles pointed to by the list <tt>rectList</tt>. The current Pen will be used to draw the rectangles, and the current Brush will be used to fill the rectangles.
 
The type <tt>vRect</tt> is defined in <tt>v_defs.h</tt> as:
     typedef struct vRect
     typedef struct vRect
       {
       {
Line 111: Line 60:
       } vRect;
       } vRect;


====virtual void DrawRubberLine(int x, int y, int xend, int yend)====
;virtual void DrawRubberLine(int x, int y, int xend, int yend):Draw a rubber-band line from x, y to xend, yend. This method is most useful for showing lines while the mouse is down. By first drawing a rubber line, and then redrawing over the same line with <tt>DrawRubberLine</tt> causes the line to be erased. Thus, pairs of rubber lines can track mouse movement. The current Pen is used to determine line style.
Draw a rubber-band line from x, y to xend, yend. This method is most useful for showing lines while the mouse is down. By first drawing a rubber line, and then redrawing over the same line with <tt>DrawRubberLine</tt> causes the line to be erased. Thus, pairs of rubber lines can track mouse movement. The current Pen is used to determine line style.
;virtual void DrawRubberEllipse(int x, int y, int width, int height):Draw a rubber-band Ellipse. See DrawRubberLine.
 
;virtual void DrawRubberPoint(int x, int y):Draw a rubber-band point. See DrawRubberLine.
====virtual void DrawRubberEllipse(int x, int y, int width, int height)====
;virtual void DrawRubberRectangle(int x, int y, int width, int height):Draw a rubber-band rectangle. See DrawRubberLine.
Draw a rubber-band Ellipse. See DrawRubberLine.
;virtual void DrawText(int x, int y, char* text):Simple draw text at given x, y using the current font and current pen. Unlike icons and other '''''V''''' drawing objects, <tt>x</tt> and <tt>y</tt> represent the lower left corner of the first letter of the text. Using a <tt>vSolid</tt> pen results in the text being drawn in with the pen's color using the current background color. Using a <tt>vTransparent</tt> pen results in text in the current color, but just drawing the text over the current canvas colors. (See <tt>vPen::SetStyle</tt>.)
 
;virtual void EndPage():Supported by printer canvases. Call to specify a page is ending. Bracket pages with <tt>BeginPage</tt> and <tt>EndPage</tt> calls.
====virtual void DrawRubberPoint(int x, int y)====
;virtual void EndPrinting():Supported by printer canvases. Call to specify a document is ending. Bracket documents with <tt>BeginPrinting</tt> and <tt>EndPrinting</tt> calls. <tt>EndPrinting</tt> includes an implicit call to <tt>EndPage</tt>.
Draw a rubber-band point. See DrawRubberLine.
;virtual vBrush GetBrush():Returns a copy of the current brush being used by the canvas.
 
;virtual vFont GetFont():Returns a copy of the current font of the drawing canvas.
====virtual void DrawRubberRectangle(int x, int y, int width, int height)====
;virtual vBrush GetPen():Returns a copy of the current pen being used by the canvas.
Draw a rubber-band rectangle. See DrawRubberLine.
;virtual int GetPhysHeight():Returns the maximum physical y value supported by the drawing canvas. Especially useful for determining scaling for printers.
 
;virtual int GetPhysWidth():Returns the maximum physical x value supported by the drawing canvas. Especially useful for determining scaling for printers.
====virtual void DrawText(int x, int y, char* text)====
;virtual void GetScale(int& mult, int& div):Returns the scaling factors for the canvas. See <tt>SetScale</tt>.
Simple draw text at given x, y using the current font and current pen. Unlike icons and other '''''V''''' drawing objects, <tt>x</tt> and <tt>y</tt> represent the lower left corner of the first letter of the text. Using a <tt>vSolid</tt> pen results in the text being drawn in with the pen's color using the current background color. Using a <tt>vTransparent</tt> pen results in text in the current color, but just drawing the text over the current canvas colors. (See <tt>vPen::SetStyle</tt>.)
;void GetTranslate(int& x, int& y)
 
;int GetTransX()
====virtual void EndPage()====
;int GetTransY():Returns the current x and y translation values.
Supported by printer canvases. Call to specify a page is ending. Bracket pages with <tt>BeginPage</tt> and <tt>EndPage</tt> calls.
;virtual void SetBackground(vColor& color):This sets the background of the drawing canvas to the specified color.
 
;virtual void SetBrush(vBrush& brush):This sets the brush used by the drawing canvas. Brushes are used for the filling methods such as <tt>vDrawPolygon</tt>. It is important to call <tt>SetBrush</tt> whenever you change any attributes of a brush used by a drawing canvas.
====virtual void EndPrinting()====
;virtual void SetFont(vFont& vf):Change the font associated with this canvas. The default method handles changing the font and calls the FontChanged method for the canvas pane.
Supported by printer canvases. Call to specify a document is ending. Bracket documents with <tt>BeginPrinting</tt> and <tt>EndPrinting</tt> calls. <tt>EndPrinting</tt> includes an implicit call to <tt>EndPage</tt>.
;virtual void SetPen(vPen& pen):Sets the current pen of the canvas to pen. Pens are used to draw lines and the outlines of shapes. It is important to call <tt>SetPen</tt> whenever you change any attributes of a pen used by a drawing canvas.
 
;virtual void SetScale(int mult, int div):Sets the scaling factor. Each coordinate passed to the drawing canvas is first multiplied by mult and then divided by div. Thus, to scale by one third, set mult to 1 and div to 3. Many applications will never have to worry about scaling. Note that scaling applies to output only. The mouse events will provide unscaled coordinates, and it is up to your code to scale mouse coordinates appropriately.
====virtual vBrush GetBrush()====
;void SetTranslate(int x, int y)
Returns a copy of the current brush being used by the canvas.
;void SetTransX(int x)
 
;void SetTransY(int y):These methods set the internal translation used by the drawing canvas. Each coordinate sent to the various drawing methods (e.g., <tt>DrawRectangle</tt>) will be translated by these coordinates. This can be most useful when using the scroll bars to change which part of a drawing is visible on the canvas. Your application will have to handle proper mapping of mouse coordinates.
====virtual vFont GetFont()====
;int TextHeight(int& ascent, int& descent):This function returns the total height of the font <tt>fontId</tt>. The total height of the font is the sum of the <tt>ascent</tt> and <tt>descent</tt> heights of the font <tt>fontId</tt>. Each character ascends <tt>ascent</tt> pixels above the Y coordinate where it is being drawn, and <tt>descent</tt> pixels below the Y coordinate.
Returns a copy of the current font of the drawing canvas.
;int TextWidth(char* str):Returns the width in pixels or drawing points of the string <tt>str</tt> using the currently set font of the canvas.
 
====virtual vBrush GetPen()====
Returns a copy of the current pen being used by the canvas.
 
====virtual int GetPhysHeight()====
Returns the maximum physical y value supported by the drawing canvas. Especially useful for determining scaling for printers.
 
====virtual int GetPhysWidth()====
Returns the maximum physical x value supported by the drawing canvas. Especially useful for determining scaling for printers.
 
====virtual void GetScale(int& mult, int& div)====
Returns the scaling factors for the canvas. See <tt>SetScale</tt>.
 
====void GetTranslate(int& x, int& y)====
 
====int GetTransX()====
 
====int GetTransY()====
Returns the current x and y translation values.
 
====virtual void SetBackground(vColor& color)====
This sets the background of the drawing canvas to the specified color.
 
====virtual void SetBrush(vBrush& brush)====
This sets the brush used by the drawing canvas. Brushes are used for the filling methods such as <tt>vDrawPolygon</tt>. It is important to call <tt>SetBrush</tt> whenever you change any attributes of a brush used by a drawing canvas.
 
====virtual void SetFont(vFont& vf)====
Change the font associated with this canvas. The default method handles changing the font and calls the FontChanged method for the canvas pane.
 
====virtual void SetPen(vPen& pen)====
Sets the current pen of the canvas to pen. Pens are used to draw lines and the outlines of shapes. It is important to call <tt>SetPen</tt> whenever you change any attributes of a pen used by a drawing canvas.
 
====virtual void SetScale(int mult, int div)====
Sets the scaling factor. Each coordinate passed to the drawing canvas is first multiplied by mult and then divided by div. Thus, to scale by one third, set mult to 1 and div to 3. Many applications will never have to worry about scaling. Note that scaling applies to output only. The mouse events will provide unscaled coordinates, and it is up to your code to scale mouse coordinates appropriately.
 
====void SetTranslate(int x, int y)====
 
====void SetTransX(int x)====
 
====void SetTransY(int y)====
These methods set the internal translation used by the drawing canvas. Each coordinate sent to the various drawing methods (e.g., <tt>DrawRectangle</tt>) will be translated by these coordinates. This can be most useful when using the scroll bars to change which part of a drawing is visible on the canvas. Your application will have to handle proper mapping of mouse coordinates.
 
====int TextHeight(int& ascent, int& descent)====
This function returns the total height of the font <tt>fontId</tt>. The total height of the font is the sum of the <tt>ascent</tt> and <tt>descent</tt> heights of the font <tt>fontId</tt>. Each character ascends <tt>ascent</tt> pixels above the Y coordinate where it is being drawn, and <tt>descent</tt> pixels below the Y coordinate.
 
====int TextWidth(char* str)====
Returns the width in pixels or drawing points of the string <tt>str</tt> using the currently set font of the canvas.


[[Category:V C++ GUI Framework]]
[[Category:V C++ GUI Framework]]

Latest revision as of 00:51, 8 April 2020

This is the base class that defines all the drawing methods provided by the various drawing canvases.

Synopsis

Header
<v/vdc.h>
Class name
vDC

Description

All drawing classes such as vCanvasPaneDC and vPostScriptDC are derived from this class. Each drawing class will support these methods as needed. Not all drawing classes have the same scale, and printer drawing canvases provide extra support for paging. Your code will not normally need to include vdc.h.

See the specific sections for details of drawing classes: vCanvasPaneDC, vMemoryDC, vPrintDC, and Drawing.

Utility Methods

virtual void BeginPage()
Supported by printer canvases. Call to specify a page is beginning. Bracket pages with BeginPage and EndPage calls.
virtual void BeginPrinting()
Required by printer canvases. Call to specify a document is beginning. You must bracket documents with BeginPrinting and EndPrinting calls. BeginPrinting includes an implicit call to BeginPage.
virtual void Clear()
Clear the canvas to the background color. No op on printers.
virtual void ClearRect(int x, int y, int width, int height)
Clear a rectangular area starting at x,y of height and width. No op on printers.
void CopyFromMemoryDC(vMemoryDC* memDC, int destX, int destY, int srcX = 0, int srcY = 0, int srcW = 0, int srcH = 0)
This method is used to copy the image contained in a vMemoryDC to another drawing canvas. The parameter memDC specifies the vMemoryDC object, and destX and destY specify where the image is to be copied into this drawing canvas (which will usually be 0,0). If you use the default values for srcX=0, srcY=0, srcW=0, and srcH=0, the entire source canvas will be copied.
Beginning with Vrelease 1.13, CopyFromMemoryDC provides the extra parameters to specify an area of the source to copy. You can specify the source origin, and its width and height. The default values for these allow backward call and behavior compatibility.
One of the most useful uses of this is to draw both the canvas pane drawing canvas, and to a memory drawing canvas, and then use CopyFromMemoryDC to copy the memory canvas to the canvas pane for Redraw events.
virtual void DrawAttrText(int x, int y, char* text, const ChrAttr attr)
Draw text using the current font with specified attributes at given x, y.
ChrAttr attr is used to specify attributes to override some of the text drawing characteristics normally determined by the pen and font. Specifying ChNormal means the current pen and font will be used. ChReverse is used to specify the text should be drawn reversed or highlighted, using the current font and pen. You can also specify 16 different standard colors to override the pen color. You use ORed combinations the basic color attributes ChRed, ChBlue, and ChGreen. Most combinations are also provided as ChYellow, ChCyan, ChMagenta, ChWhite, and ChGray. These colors can be combined with ChDimColor can be used for half bright color combinations (or you can use ChDimRed, etc.). You can combine color attributes with ChReverse. Attributes such as boldface, size, and underlining are attributes of the font.
virtual void DrawColorPoints(int x, int y, int nPts, vColor* pts)
Draw an array of nPts vColors as points starting at x,y. This method is useful for drawing graphical images, and bypasses the need to set the pen or brush for each point. Typically, DrawColorPoints will be significantly faster than separate calls to DrawPoint.
virtual void DrawEllipse(int x, int y, int width, int height)
Draw an ellipse inside the bounding box specified by x, y, width, and height. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
virtual void DrawIcon(int x, int y, vIcon& icon)
A vIcon is drawn at x,y using the current Pen. Note that only the location of an icon is scaled. The icon will retain its original size.
virtual void DrawLine(int x, int y, int xend, int yend)
Draw a line from x,y to xend,yend. The current Pen will be used to draw the line.
virtual void DrawLines(vLine* lineList, int count)
Draws the count lines contained in the list lineList.
The current Pen will be used to draw the lines.
The type vLine is defined in v_defs.h as:
    typedef struct vLine
      {
        short x, y, xend, yend;
      } vLine;
virtual void DrawLines(vPoint* points, int count)
Draws the count lines defined by the list of endpoints points. This is similar to drawing with a line list. The value of count must be 2 or greater. (New in version 1.19)
The current Pen will be used to draw the lines.
virtual void DrawPoint(int x, int y)
Draw a point at x,y using the current Pen.
virtual void DrawPoints(vPoint* pointList, int count)
Draws the count points contained in the list pointList.
The current Pen will be used to draw the points.
The type vPoint is defined in v_defs.h as:
    typedef struct vPoint
      {
        short x, y;
      } vPoint;
virtual void DrawPolygon(int n, vPoint points[], int fillMode = vAlternate)
A closed polygon of n points is drawn. Note that the first and last element of the point list must specify the same point. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
The fillMode parameter specifies one of two alternative filling algorithms, vAlternate or vWinding. These algorithms correspond to the equivalent algorithms on the native platforms.
The type vPoint is defined in v_defs.h as:
    typedef struct vPoint       // a point
      {
        short x, y;             // X version
      } vPoint;
virtual void DrawRoundedRectangle(int x, int y, int width, int height, int radius = 10)
Draw a rectangle with rounded corners at x,y of size width and height. The radius specifies the radius of the circle used to draw the corners. If a radius of less than 0 is specified, the radius of the corners will be ((width+height)/-2*radius) which gives a more or less reasonable look for various sized rectangles. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
virtual void DrawRectangle(int x, int y, int width, int height)
Draw a rectangle with square corners at x,y of size width and height. The current Pen will be used to draw the shape, and the current Brush will be used to fill the shape.
virtual void DrawRectangles(vRect* rectList, int count)
Draw a list of count vRect rectangles pointed to by the list rectList. The current Pen will be used to draw the rectangles, and the current Brush will be used to fill the rectangles.
The type vRect is defined in v_defs.h as:
    typedef struct vRect
      {
        short x, y, w, h;
      } vRect;
virtual void DrawRubberLine(int x, int y, int xend, int yend)
Draw a rubber-band line from x, y to xend, yend. This method is most useful for showing lines while the mouse is down. By first drawing a rubber line, and then redrawing over the same line with DrawRubberLine causes the line to be erased. Thus, pairs of rubber lines can track mouse movement. The current Pen is used to determine line style.
virtual void DrawRubberEllipse(int x, int y, int width, int height)
Draw a rubber-band Ellipse. See DrawRubberLine.
virtual void DrawRubberPoint(int x, int y)
Draw a rubber-band point. See DrawRubberLine.
virtual void DrawRubberRectangle(int x, int y, int width, int height)
Draw a rubber-band rectangle. See DrawRubberLine.
virtual void DrawText(int x, int y, char* text)
Simple draw text at given x, y using the current font and current pen. Unlike icons and other V drawing objects, x and y represent the lower left corner of the first letter of the text. Using a vSolid pen results in the text being drawn in with the pen's color using the current background color. Using a vTransparent pen results in text in the current color, but just drawing the text over the current canvas colors. (See vPen::SetStyle.)
virtual void EndPage()
Supported by printer canvases. Call to specify a page is ending. Bracket pages with BeginPage and EndPage calls.
virtual void EndPrinting()
Supported by printer canvases. Call to specify a document is ending. Bracket documents with BeginPrinting and EndPrinting calls. EndPrinting includes an implicit call to EndPage.
virtual vBrush GetBrush()
Returns a copy of the current brush being used by the canvas.
virtual vFont GetFont()
Returns a copy of the current font of the drawing canvas.
virtual vBrush GetPen()
Returns a copy of the current pen being used by the canvas.
virtual int GetPhysHeight()
Returns the maximum physical y value supported by the drawing canvas. Especially useful for determining scaling for printers.
virtual int GetPhysWidth()
Returns the maximum physical x value supported by the drawing canvas. Especially useful for determining scaling for printers.
virtual void GetScale(int& mult, int& div)
Returns the scaling factors for the canvas. See SetScale.
void GetTranslate(int& x, int& y)
int GetTransX()
int GetTransY()
Returns the current x and y translation values.
virtual void SetBackground(vColor& color)
This sets the background of the drawing canvas to the specified color.
virtual void SetBrush(vBrush& brush)
This sets the brush used by the drawing canvas. Brushes are used for the filling methods such as vDrawPolygon. It is important to call SetBrush whenever you change any attributes of a brush used by a drawing canvas.
virtual void SetFont(vFont& vf)
Change the font associated with this canvas. The default method handles changing the font and calls the FontChanged method for the canvas pane.
virtual void SetPen(vPen& pen)
Sets the current pen of the canvas to pen. Pens are used to draw lines and the outlines of shapes. It is important to call SetPen whenever you change any attributes of a pen used by a drawing canvas.
virtual void SetScale(int mult, int div)
Sets the scaling factor. Each coordinate passed to the drawing canvas is first multiplied by mult and then divided by div. Thus, to scale by one third, set mult to 1 and div to 3. Many applications will never have to worry about scaling. Note that scaling applies to output only. The mouse events will provide unscaled coordinates, and it is up to your code to scale mouse coordinates appropriately.
void SetTranslate(int x, int y)
void SetTransX(int x)
void SetTransY(int y)
These methods set the internal translation used by the drawing canvas. Each coordinate sent to the various drawing methods (e.g., DrawRectangle) will be translated by these coordinates. This can be most useful when using the scroll bars to change which part of a drawing is visible on the canvas. Your application will have to handle proper mapping of mouse coordinates.
int TextHeight(int& ascent, int& descent)
This function returns the total height of the font fontId. The total height of the font is the sum of the ascent and descent heights of the font fontId. Each character ascends ascent pixels above the Y coordinate where it is being drawn, and descent pixels below the Y coordinate.
int TextWidth(char* str)
Returns the width in pixels or drawing points of the string str using the currently set font of the canvas.