<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 95 (Thu Jan 19 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE> Drawing</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Drawing">
<meta name="keywords" value="vwebref">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
 <BR> <HR><A NAME=tex2html1433 HREF="node9.html"><IMG ALIGN=BOTTOM ALT="next" SRC="../icons/next.gif"></A>   <A NAME=tex2html1431 HREF="vwebref.html"><IMG ALIGN=BOTTOM ALT="up" SRC="../icons/up.gif"></A>   <A NAME=tex2html1425 HREF="node7.html"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/prev.gif"></A>   <A NAME=tex2html1435 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="../icons/contents.gif"></A>      <BR>
<B> Next:</B> <A NAME=tex2html1434 HREF="node9.html"> Standard V Values</A>
<B>Up:</B> <A NAME=tex2html1432 HREF="vwebref.html">V Reference Manual</A>
<B> Previous:</B> <A NAME=tex2html1426 HREF="node7.html"> Dialogs</A>
<BR> <HR> <P>
<H1><A NAME=SECTION00800000000000000000> Drawing</A></H1>
<P>
This chapter covers classes and utility functions needed to draw
text and graphics.
<P>
The classes and objects covered in this chapter include:
<P>
<DL ><DT>Introduction to Drawing
<DD> Basic V
  drawing model.
	<DT>Fonts
<DD> Various screen fonts are available in V
 .
	<DT>vBrush
<DD> A brush for filling areas.
	<DT>vCanvasPaneDC
<DD> The canvas pane drawing canvas.
	<DT>vCanvasPane
<DD> A base class to build graphical and text canvas panes.
	<DT>vBaseGLCanvasPane
<DD> A specialized class to support OpenGL.
	<DT>vColor
<DD> A class for specifying colors.
	<DT>vDC
<DD> A base class describing drawing canvas methods.
	<DT>vMemoryDC
<DD> A memory drawing canvas.
	<DT>vPen
<DD> A drawing pen.
	<DT>vPrintDC
<DD> A printer drawing canvas.
	<DT>vPrinter
<DD> A printer setup dialog.
	<DT>vTextCanvasPane
<DD> A class for drawing text on a canvas. 
	<DT>vTextEditor
<DD> A class for editing text.
	<DT>vBaseGLCanvasPane
<DD> A class to support OpenGL.
<P>
 </DL>
<P>

<H1><A NAME=SECTION00810000000000000000> Introduction to Drawing</A></H1>
<P>
<A NAME=4479>&#160;</A>
<P>
The basic V
  model of drawing is a canvas. V
  supports several kinds
of drawing canvases. The most obvious canvas is the screen drawing canvas.
This will often be the main or even only canvas you use. V
  also
supports printing canvases. Each kind of canvas has identical drawing
methods, so you can write code to draw that is mostly independent of
which kind of canvas is being used.
<P>
There is also a specialized drawing canvas to support OpenGL. This
class differs somewhat from the other drawing canvases.
<A NAME=4480>&#160;</A>
<P>
<H2><A NAME=SECTION00811000000000000000> Drawing with the vDC Class</A></H2>
<P>
<A NAME=5503>&#160;</A>
<P>
You draw to the various canvases using a <tt>
 vDC</tt> class, the
general V
  Drawing Canvas Class (the OpenGL canvas does not use
the codevDC class). The <tt>
 vDC</tt> class for drawing to the
screen is <tt>
 vCanvasPaneDC</tt>. The class <tt>
 vPrintDC</tt> is the
platform independent class to draw to a printer. For X, <tt>
 vPrintDC</tt>
supports PostScript printing. The Windows version supports
standard Windows printers. (You can also use the PostScript DC
independently on Windows.) If you write your drawing code to use
a <tt>
 vDC</tt> pointer, you will be able to draw to several
canvases just by changing the value of the pointer.
<P>
Each <tt>
 vDC</tt> supports the methods described in the <tt>
 vDC</tt> section.
Because the <tt>
 vCanvasPane</tt> class is so central to most
applications, it duplicates
all the <tt>
 vDC</tt> methods so you can call them directly from your
<tt>
 vCanvasPane</tt> object. In fact, all the methods in <tt>
 vCanvasPane</tt>
are just calls to the corresponding <tt>
 vDC</tt> using the <tt>
 vCanvasPaneDC</tt>
of the canvas pane. You can get the <tt>
 vCanvasPaneDC</tt> pointer with
the <tt>
 GetDC</tt> method.
<P>
There are three kinds of drawing methods supported by V
 . The simplest
methods draw lines of various widths and colors using the current
<tt>
 vPen</tt>. You change the color and width of the lines being drawn
by setting the current <tt>
 vPen</tt> with the <tt>
 SetPen</tt> method.
<P>
The second type of drawing includes filling the space surrounded
by a shape such as a polygon. The edges of the shape are drawn using
the current <tt>
 vPen</tt>. The filled area is drawn using the current
<tt>
 vBrush</tt>. You can set various attributes of the brush, and use
<tt>
 SetBrush</tt> to change how the shapes will be filled, as well as
changing the attributes of the <tt>
 vPen</tt> used to draw the surrounding
line. Both the pen and the brush can be transparent, allowing you to
draw unfilled outline shaped, or to fill a shape without an outline.
<P>
Finally, V
  supports drawing of text on a canvas using various
<tt>
 vFonts</tt> and text attributes. The canvas pane will start out
using the default system font (<tt>
 vfSystemDefault</tt>). If you need
a different initial font, use <tt>
 vFont::SetFontValues</tt> to
select the font you want, then <tt>
 vCanvasPane::SetFont</tt> to set
the new font.
<P>
<H2><A NAME=SECTION00812000000000000000> Coordinates</A></H2>
<P>
All V
  drawing canvas classes use integer physical coordinates
appropriate to the canvas. All devices call the upper left corner
x,y coordinate of the drawing canvas 0,0. The x values increase
to the right, and y values increase down.
<P>
It it up to each application to provide appropriate mapping
from the coordinates used for the particular model being used
(often called the world coordinate system) to the physical
mapping used by each V
  drawing canvas. Each drawing canvas
will have a physical limit for the maximum x and maximum y,
usually imposed by the particular canvas (a screen or a paper
size, for example). You can set a scale factor for each drawing
canvas which can be helpful for using different kinds of drawing
canvases. V
  also supports setting an x,y translation. This will
allow you to more easily use the scroll bars and set margins
on printers. Your application can usually use the messages
received from the scroll bars to set the translation coordinates
to map your the canvas to a different drawing area. The system
will handle clipping.
<P>
However, the application is for the most part responsible
for determining all coordinate mapping -- translations of
a viewport of the drawing, determining the scaling for
various drawing canvases, and any mapping from the world
to the physical coordinates. The application will have to
map the mouse input accordingly, too.
<P>

<P>
<H1><A NAME=SECTION00820000000000000000> Fonts</A></H1>
<P>
<A NAME=4513>&#160;</A>
<A NAME=5506>&#160;</A>
<P>
Various screen fonts are available in V
 .
<P>
<H2><A NAME=SECTION00821000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Class:
<DD> <tt>
 vFont</tt>
	<DT>Header:
<DD> <tt>
 &lt;v/vfont.h&gt;</tt>
<P>
 </DL><H2><A NAME=SECTION00822000000000000000> Description</A></H2>
<P>
Fonts are difficult to make portable. V
  has adopted a font
model that is somewhat portable, yet allows you to take advantage
of various fonts available on different platforms. In fact, it
is possible to write your programs to use the <tt>
 vFontSelect</tt>
dialog class, and pretty much ignore many of the details of
selecting fonts. The main characteristics of fonts your program
will have to deal with are the height and width of text displayed
on a canvas. These values are provided by 
<tt>
 vDC::TextHeight</tt> and <tt>
 vDC::TextWidth</tt>.
<P>
Fonts are associated with drawing canvases. For example, the
<tt>
 vCanvasPane::SetFont</tt> method is used to set the font used
by the canvas pane. The sizes of the actual fonts will probably
differ on different kinds of canvases. Specifically, your program
should not depend on getting the same <tt>
 TextWidth</tt> value
for screen and printer canvases for the same font.
<P>
The class <tt>
 vFont</tt> is used to define font objects, and the
characteristics of the font are set either by the class
constructor when the font is instantiated, or by using the  
<tt>
 vFont :: SetFontValues</tt> method. The utility class <tt>
 vFontSelect</tt>
can be used to interactively set font characteristics.  The
characteristics associated with a font are described in the
following sections. Remember, however, that <tt>
 vFontSelect::FontSelect</tt>
can be used to set these attributes.
<P>
<H3><A NAME=SECTION00822100000000000000> Font Family</A></H3>
<P>
Each font belongs to a font family. There are eight font families
defined by V
 with the <tt>
 vFontID</tt> attribute of the font object.
Font families typically correspond to some typeface name such
as <em>Helvetica</em> or <em>Times Roman</em>, but use more generic names.
There are three system fonts, <tt>
 vfDefaultSystem</tt>, <tt>
 vfDefaultFixed</tt>,
and <tt>
 vfDefaultVariable</tt>. These default fonts are defined by
the specific platform. <tt>
 vfDefaultSystem</tt> will usually be a
fixed space font, and is often settable by the user. On X, for
example, the default system font can be changed by using a
<tt>
 -fn fontname</tt> switch when starting the application. The
<tt>
 vfDefaultSystem</tt> font will have fixed attributes, and will
not be changeable by the program. The <tt>
 vfDefaultFixed</tt>
(fixed spacing) and  <tt>
 vfDefaultVariable</tt> (variable spacing)
fonts are also system specified, but can usually have their
attributes, such as size and weight changed.
<P>
V
  also supports five other font families. The <tt>
 vfSerif</tt> font
is a seriffed font such as <tt>
 Times Roman</tt>. The <tt>
 vfSanSerif</tt>
is a serifless font such as <tt>
 Swiss</tt> or <tt>
 Lucidia</tt>. Both
of these are variable spaced fonts. The <tt>
 vfFixed</tt> is a fixed
space font, often called <tt>
 Courier</tt> on the host platform.
The <tt>
 vfDecorative</tt> font usually contains symbols or other drawing
characters. It is not very portable across platforms. Finally,
V
  supports a font family called <tt>
 vfOther</tt>. This is used when
the system supports other fonts that are selectable via the
<tt>
 vFontSelect</tt> dialog class. Windows supports a wide variety of fonts,
while X does not support any additional fonts.
<P>
<H3><A NAME=SECTION00822200000000000000> Font Style</A></H3>
<P>
V
  supports two kinds of font styles: <tt>
 vfNormal</tt> for normal
fonts, and <tt>
 vfItalic</tt> for italic fonts.
<P>
<H3><A NAME=SECTION00822300000000000000> Font Weight</A></H3>
<P>
V
  supports two kinds of font weights: <tt>
 vfNormal</tt> for
normal weight fonts, and <tt>
 vfBold</tt> for boldface fonts.
<P>
<H3><A NAME=SECTION00822400000000000000> Point Size</A></H3>
<P>
V
  supports a wide range of point size, usually ranging from 8 point
to 40 or 72 point fonts. Not all point sizes are supported on each
platform. How each point size maps to space on the screen or page
also vary from platform to platform.
<P>
<H3><A NAME=SECTION00822500000000000000> Underlining</A></H3>
<P>
You can also specify that a font is underlined. Currently, underlining
does not work for X screens.
<P>
<H2><A NAME=SECTION00823000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION00823100000000000000> vFont(vFontID fam = vfDefaultFixed, int size = 10,
vFontID sty = vfNormal, vFontID wt = vfNormal, int und = 0)</A></H3>
<P>
<A NAME=5509>&#160;</A>
<P>
The constructor is used to declare a font with the specified
family, size, style, weight, and underline.
<P>
<H3><A NAME=SECTION00823200000000000000> vFontID GetFamily()</A></H3>
<P>
<A NAME=5512>&#160;</A>
<P>
Returns the family of the font object.
<P>
<H3><A NAME=SECTION00823300000000000000> int GetPointSize()</A></H3>
<P>
<A NAME=5515>&#160;</A>
<P>
Returns the point size of the font object.
<P>
<H3><A NAME=SECTION00823400000000000000> vFontID GetStyle()</A></H3>
<P>
<A NAME=5518>&#160;</A>
<P>
Returns the style of the font object.
<P>
<H3><A NAME=SECTION00823500000000000000> vFontID GetWeight()</A></H3>
<P>
<A NAME=5521>&#160;</A>
<P>
Returns the weight of the font object.
<P>
<H3><A NAME=SECTION00823600000000000000> int GetUnderlined()</A></H3>
<P>
<A NAME=5524>&#160;</A>
<P>
Returns the underline setting of the font object.
<P>
<H3><A NAME=SECTION00823700000000000000> void SetFontValues(vFontID fam = vfDefaultFixed, int size =
10, vFontID sty = vfNormal, vFontID wt = vfNormal, int und = 0)</A></H3>
<P>
<A NAME=5527>&#160;</A>
<P>
Changes the attributes of the font object. For example, the font
selection dialog uses this method to change the font attributes.
<P>

<P>
<H1><A NAME=SECTION00830000000000000000> vBrush</A></H1>
<P>
<A NAME=5530>&#160;</A>
<A NAME=4577>&#160;</A>
<P>
A class to specify the brush used to fill shapes.
<P>
<H2><A NAME=SECTION00831000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vbrush.h&gt;</tt>
	<DT>Class name:
<DD> vBrush
<P>
 </DL><H2><A NAME=SECTION00832000000000000000> Description</A></H2>
<P>
Brushes are used to fill shapes. Brushes have
two attributes, including color and style.
<P>
<H2><A NAME=SECTION00833000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION00833100000000000000> vBrush(unsigned int r = 0, unsigned int g = 0, unsigned
int b = 0, int style = vSolid)</A></H3>
<P>
<A NAME=5533>&#160;</A>
<P>
The brush constructor allows you to set the initial color and
style of the brush. The default constructs a solid black brush.
<P>
<H3><A NAME=SECTION00833200000000000000> int operator == , !=</A></H3>
<P>
You can use the operators <tt>
 ==</tt> and <tt>
 !=</tt> for comparisons.
<P>
<H3><A NAME=SECTION00833300000000000000> vColor GetColor()</A></H3>
<P>
<A NAME=5537>&#160;</A>
<P>
This method returns the current color of the brush as a <tt>
 vColor</tt> object.
<P>
<H3><A NAME=SECTION00833400000000000000> int GetFillMode()</A></H3>
<P>
<A NAME=5540>&#160;</A>
<P>
This method returns the fill mode of the brush (either <tt>
 vAlternate</tt>
or <tt>
 vWinding</tt>).
<P>
<H3><A NAME=SECTION00833500000000000000> int GetStyle()</A></H3>
<P>
<A NAME=5543>&#160;</A>
<P>
This method returns the current style of the brush.
<P>
<H3><A NAME=SECTION00833600000000000000> void SetColor(vColor&amp; c)</A></H3>
<P>
<A NAME=5546>&#160;</A>
<P>
<A NAME=4600>&#160;</A>
<P>
You can use this method to set the brush color by passing
in a <tt>
 vColor</tt> object.
<P>
<H3><A NAME=SECTION00833700000000000000> int SetFillMode(int fillMode)</A></H3>
<P>
<A NAME=5549>&#160;</A>
<P>
This method sets the fill mode of the brush.
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.
<P>
<H3><A NAME=SECTION00833800000000000000> void SetStyle(int style)</A></H3>
<P>
<A NAME=5552>&#160;</A>
<P>
This method is used to set the style of the brush. Brush styles
include:
<P>
<DL ><DT>vSolid
<DD> The brush fills with a solid color.
	<DT>vTransparent
<DD> The brush is transparent, which allows
you to draw unfilled shapes.
	<DT>vHorizontalHatch
<DD> The brush fills with a horizontal hatch pattern
in the current color.
	<DT>vVerticleHatch
<DD> The brush fills with a vertical hatch pattern.
	<DT>vLeftDiagonalHatch
<DD> The brush fills with a left leaning
diagonal hatch pattern.
	<DT>vRightDiagonalHatch
<DD> The brush fills with a right
leaning diagonal hatch pattern.
	<DT>vCrossHatch
<DD> The brush fills with a vertical and horizontal cross hatch
pattern.
	<DT>vDiagonalCrossHatch
<DD> The brush fills with a diagonal
cross hatch pattern.
<P>
 </DL>
<P>

<P>
<H1><A NAME=SECTION00840000000000000000> vCanvasPaneDC</A></H1>
<P>
<A NAME=5555>&#160;</A>
<P>
The drawing canvas class for CanvasPanes.
<P>
<H2><A NAME=SECTION00841000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vcpdc.h&gt;</tt>
	<DT>Class name:
<DD> vCanvasPaneDC
 	<DT>Hierarchy:
<DD> vDC -&gt;
  vCanvasPaneDC
<P>
 </DL><H2><A NAME=SECTION00842000000000000000> Description</A></H2>
<P>
This class is normally automatically used by the <tt>
 vCanvasPane</tt>
class. It provides the actual implementation of the screen drawing
canvas class.
<P>

<P>
<H1><A NAME=SECTION00850000000000000000> vCanvasPane</A></H1>
<P>
<A NAME=5558>&#160;</A>
<P>
A base class to build graphical and text canvas panes.
<P>
<H2><A NAME=SECTION00851000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vcanvas.h&gt;</tt>
	<DT>Class name:
<DD> vCanvasPane
 	<DT>Hierarchy:
<DD> vPane -&gt;
  vCanvasPane
<P>
 </DL><H2><A NAME=SECTION00852000000000000000> Description</A></H2>
<P>
This is the base drawing class. You use it to build more complicated
drawing canvases, either for graphical drawing or text drawing.
The <tt>
 vCanvasPane</tt> class has all the basic methods needed to
interact with the drawing canvas. It does not, however, know
how to handle repainting the screen on <tt>
 Redraw</tt> or <tt>
 Resize</tt>
events. It provides utility methods for drawing on the canvas,
and several other methods that are normally overridden by your
application.
<P>
See the section <tt>
 vPane</tt> for a general description of panes.
<P>
<H2><A NAME=SECTION00853000000000000000> Utility Methods</A></H2>
<P>
The following methods provide useful service without modification. Sometimes
you will want to override some of these, but you will then usually
call these methods from your derived class.
<P>

<H3><A NAME=SECTION00853100000000000000> Drawing</A></H3>
<P>
<A NAME=4631>&#160;</A>
<P>
The <tt>
 vCanvasPane</tt> normally creates a <tt>
 vCanvasPaneDC</tt> to
use for drawing, and class provides direct support by including
direct calls for the drawing methods described in the <tt>
 vDC</tt>
section. If your drawing will only be to the screen, then you
can use the methods of the <tt>
 vCanvasPane</tt> class directly.
Each of these methods is really an inline function that expands
to <tt>
 _cpDC-&gt;DrawWhatever()</tt>.
<P>
If your drawing code might want to draw to both a screen and
a printer, you might want to use a parameter to the appropriate
drawing canvas. You can get the <tt>
 vDC</tt> used by the <tt>
 vCanvasPane</tt>
by calling <tt>
 GetDC()</tt>.
<P>

<H3><A NAME=SECTION00853200000000000000> virtual void CreateDC(void)</A></H3>
<P>
<A NAME=5562>&#160;</A>
<P>
This method is called when the <tt>
 vCanvasPane</tt> is initialized.
The default is to create a drawing canvas using <tt>
 _cpDC = new
vCanvasPaneDC(this);</tt>. If you want to derive a different canvas
pane class from <tt>
 vCanvasPane</tt> perhaps using a more
sophisticated drawing canvas derived from the <tt>
 vCanvasPaneDC</tt>
class, you can override the <tt>
 CreateDC</tt> method and set the
protected <tt>
 vDC* _cpDC</tt> pointer to an instance of your new
drawing canvas (e.g., <tt>
 _cpDC = new myCanvasPaneDC(this)</tt>
instead.
<P>

<H3><A NAME=SECTION00853300000000000000> vDC* GetDC()</A></H3>
<P>
<A NAME=5565>&#160;</A>
<P>
Returns a pointer to the <tt>
 vDC</tt> of the current drawing canvas. The
<tt>
 vDC</tt> can be used for most of the drawing methods to achieve
drawing canvas independence. If your code draws via a <tt>
 vDC</tt> pointer,
then the same code can draw to the screen canvas or the printer canvas
depending on what the <tt>
 vDC</tt> points to.
<P>

<H3><A NAME=SECTION00853400000000000000> VCursor GetCursor()</A></H3>
<P>
<A NAME=5568>&#160;</A>
<P>
Returns the id of the current cursor being used in the canvas.
See <tt>
 SetCursor</tt>.
<P>

<H3><A NAME=SECTION00853500000000000000> virtual int GetHeight()</A></H3>
<P>
<A NAME=5571>&#160;</A>
<P>
Returns the height of the current drawing canvas in pixels.
<P>

<H3><A NAME=SECTION00853600000000000000> virtual int GetHScroll(int&amp; Shown, int&amp; Top)</A></H3>
<P>
<A NAME=5574>&#160;</A>
<P>
Get the status of the Horizontal Scroll bar. Returns 1 if the
scroll bar is displayed, 0 if not. Returns in <tt>
 Shown</tt> and
<tt>
 Top</tt> the current values of the scroll bar. See <tt>
 SetVScroll</tt>
for a description of the meanings of parameters.
<P>

<H3><A NAME=SECTION00853700000000000000> virtual int GetVScroll(int&amp; Shown, int&amp; Top)</A></H3>
<P>
<A NAME=5577>&#160;</A>
<P>
Get the status of the Vertical Scroll bar. See
<tt>
 GetHScroll</tt> for details.
<P>

<H3><A NAME=SECTION00853800000000000000> virtual int GetWidth()</A></H3>
<P>
<A NAME=5580>&#160;</A>
<P>
Returns the width of the current drawing canvas in pixels.
This is either the initial size of the window, or the size
after the user has resized the window.
<P>

<H3><A NAME=SECTION00853900000000000000> void SetCursor(VCursor id)</A></H3>
<P>
<A NAME=5583>&#160;</A>
<P>
This method sets the cursor displayed while the mouse in
in the current canvas area. The default cursor is the
standard arrow cursor used on most host platforms. You
can change the cursor displayed within the canvas area
only by calling this method.
<P>
The cursors currently supported include:
<P>
<DL ><DT>VC_Arrow
<DD> The standard arrow cursor.
<DT>VC_CenterArrow
<DD> An upward point arrow.
<DT>VC_CrossHair
<DD> A cross hair cursor.
<DT>VC_EWArrows
<DD> Double ended horizontal arrows (EastWest).
<DT>VC_Hand
<DD> A hand with a pointing finger (NOT ON WINDOWS).
<DT>VC_IBar
<DD> An I bar cursor.
<DT>VC_Icon
<DD> A cursor representing an icon.
<DT>VC_NSArrows
<DD> Double ended vertical arrows (NorthSouth).
<DT>VC_Pencil
<DD> A pencil (NOT ON WINDOWS).
<DT>VC_Question
<DD> A question mark cursor (NOT ON WINDOWS).
<DT>VC_Sizer
<DD> The cursor used for sizing windows.
<DT>VC_Wait
<DD> A cursor that symbolizes waiting, usually an hour glass.
<DT>VC_X
<DD> An X shaped cursor (NOT ON WINDOWS).
<P>
 </DL>
<P>

<H3><A NAME=SECTION008531000000000000000> void SetWidthHeight(int width, int height)</A></H3>
<P>
<A NAME=5586>&#160;</A>
<P>
This will set the size of the drawing canvas to <tt>
 height</tt>
and <tt>
 width</tt> in pixels. It will also cause a <tt>
 Resize</tt>
event message to be sent to the window.
<P>

<H3><A NAME=SECTION008531100000000000000> virtual void SetHScroll(int Shown, int Top)</A></H3>
<P>
<A NAME=5589>&#160;</A>
<P>
Set the horizontal scroll bar. See <tt>
 SetVScroll</tt> for
a description of the parameters.
<P>

<H3><A NAME=SECTION008531200000000000000> virtual void SetVScroll(int Shown, int Top)</A></H3>
<P>
<A NAME=5592>&#160;</A>
<A NAME=4684>&#160;</A>
<P>
Set the vertical scroll bar. The <tt>
 Shown</tt> parameter
is a value from 0 to 100, and represents the percent
of the scroll bar shows of the view in the canvas. For
example, the canvas might be displaying text from a file.
If the file was 100 lines long, and the window could show
20 lines, then the value of <tt>
 Shown</tt> would be 20,
meaning that the canvas is showing 20 percent of the file.
As the size of the data viewed in the canvas changes, your
program should change the scroll bar to corresponding values.
<P>
The <tt>
 Top</tt> parameter represents where the top of
the scroll indicator should be placed.  For example,
if the first line displayed in the canvas of a 100 line file
was line 40, then  <tt>
 Top</tt> should be 40, representing
40 percent.
<P>
This model of a scroll bar can be mapped to all the underlying
windowing systems supported by V
 , but the visual appearance
of the scroll bar will vary.
<P>

<H3><A NAME=SECTION008531300000000000000> virtual void ShowHScroll(int OnOrOff)</A></H3>
<P>
<A NAME=5595>&#160;</A>
<P>
<H3><A NAME=SECTION008531400000000000000> virtual void ShowVScroll(int OnOrOff)</A></H3>
<P>
<A NAME=5598>&#160;</A>
<A NAME=4693>&#160;</A>
<P>
When a canvas is first displayed, it will begin with both
horizontal and scroll bars not shown by default. <tt>
 ShowHScroll</tt>
and <tt>
 ShowVScroll</tt> can be used to selectively turn on and off
the canvas scroll bars. When a scroll bar is turned off or on, the size
of the canvas may changes, so you should also call <tt>
 Resize</tt> after
you have set the scroll bars.
<P>
You must not call either of these methods until the canvas has
actually been instantiated on the screen. This means if your
application needs to start with scroll bars, you should have
the calls to <tt>
 ShowVScroll</tt> and <tt>
 ShowHScroll</tt> in
the code of your <tt>
 vCmdWindow</tt> class constructor
(or other initialization code) <em>after</em> calling
<tt>
 vWindow::ShowWindow</tt> in your class constructor.
<P>
<H2><A NAME=SECTION00854000000000000000> Methods to Override</A></H2>
 
<P>

<H3><A NAME=SECTION00854100000000000000> virtual void FontChanged(int vf)</A></H3>
<P>
<A NAME=5601>&#160;</A>
<P>
Called when the font is changed. This usually means your
application needs to resize the window and recalculate
the number of rows and columns of text that can be displayed.
<P>

<H3><A NAME=SECTION00854200000000000000> virtual void HPage(int Shown, int Top)</A></H3>
<P>
<A NAME=5604>&#160;</A>
<P>
When the user moves the horizontal scroll bar, it generates an
<tt>
 HPage</tt> event. It is up to your program to intercept (override)
this method, and provide proper interpretation. This event usually
is used for large movements. The meaning of <tt>
 Shown</tt> and
<tt>
 Top</tt> represent the state of the scroll bar as set by
the user.  It is then up to your program to display the
correct portion of the data shown in the canvas to correspond
to these values.  Your program uses <tt>
 SetHScroll</tt> to
set appropriate values, and they are explained there.
The <tt>
 Shown</tt> value supplied here
will correspond to the value you program set for the scroll bar.
The <tt>
 Top</tt> value should indicate the meaningful change as input
by the user.
<P>

<H3><A NAME=SECTION00854300000000000000> virtual void HScroll(int step)</A></H3>
<P>
<A NAME=5607>&#160;</A>
<P>
This method is called when the user enters a single step command
to the scroll bar. The value of <tt>
 step</tt> will be positive for right or
negative for left scroll.  These scrolls
are usually interpreted as discreet steps - either a line or
screenful at a time. It is up to your application to give
an appropriate interpretation.
<P>

<H3><A NAME=SECTION00854400000000000000> virtual void MouseDown(int x, int y, int button)</A></H3>
<P>
<A NAME=5610>&#160;</A>
<P>
This is called when the user clicks a button on the mouse. The
<tt>
 x</tt> and <tt>
 y</tt> indicates the position of the mouse in the
canvas when the button was clicked. Mouse events in vCanvasPane
are no-ops, and your subclass of <tt>
 vCanvasPane</tt> will need to
handle proper interpretation of mouse clicks.
<P>
Sorry, but thanks to the Macintosh, handling of buttons is a bit
nonportable. The <tt>
 button</tt> parameter will have a value of 1,
2, or 3. On X based systems, 1 is the left button, 2 is the
middle button, and 3 is the right button. On Windows, 1 is the
left button, and 3 is the right button. Thus, applications using
the left and right buttons are portable from X to Windows. The
single Macintosh button will return a value of 1.
<P>
If you intend your applications to port to all three platforms,
you will have to account for the single Macintosh button. If you
ignore X's middle button, then your applications can be directly
portable from X to Windows.
<P>

<H3><A NAME=SECTION00854500000000000000> virtual void MouseMotion(int x, int y)</A></H3>
<P>
<A NAME=5613>&#160;</A>
<P>
This is called when the mouse moves while a button is <em>not</em>
pressed, and gives the current <tt>
 x</tt> and <tt>
 y</tt> of the
mouse. Most applications will ignore this information.
<P>

<H3><A NAME=SECTION00854600000000000000> virtual void MouseMove(int x, int y, int button)</A></H3>
<P>
<A NAME=5616>&#160;</A>
<P>
This is called when the mouse moves while a button is pressed,
and gives the new <tt>
 x</tt>, <tt>
 y</tt>, and <tt>
 button</tt> of the
mouse. Mouse events in vCanvasPane are no-ops, and your subclass
needs to interpret them.
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.
Mouse coordinate <em>do</em> have the translation added.
<P>

<H3><A NAME=SECTION00854700000000000000> virtual void MouseUp(int x, int y, int button)</A></H3>
<P>
<A NAME=5619>&#160;</A>
<P>
This is called when the user releases the mouse button, and
gives the final location of the mouse.
Mouse events in vCanvasPane are no-ops, and your subclass
needs to interpret them.
<P>

<H3><A NAME=SECTION00854800000000000000> virtual void Redraw(int x, int y, int width, int height)</A></H3>
<P>
<A NAME=5622>&#160;</A>
<P>
<tt>
 Redraw</tt> is called when the canvas needs to be redrawn.
The first redraw is generated when the canvas is first created.
Other redraws are generated when the canvas is covered or uncovered
by another window, and means the contents of the canvas must
be repainted.  The <tt>
 vCanvasPane</tt> does not know how to repaint
the contents of the canvas, so you must override this method to
be able to keep the canvas painted.
<P>
The parameters of <tt>
 Redraw</tt> represent the rectangular area
that needs to be repainted. This areas is not always the whole
canvas, and it is possible that many <tt>
 Redraw</tt> events will
be generated in a row as the user drags a covering window off
the canvas.
<P>
The default <tt>
 Redraw</tt> in <tt>
 vCanvasPane</tt> is a
no-op, and your subclass needs to override <tt>
 Redraw</tt>.
<P>

<H3><A NAME=SECTION00854900000000000000> virtual void Resize(int newW, int newH)</A></H3>
<P>
<A NAME=5625>&#160;</A>
<P>
A <tt>
 Resize</tt> event is generated when the user changes the
size of the canvas using the resize window command provided
by the host windowing system.
<P>
The default <tt>
 Resize</tt> in <tt>
 vBaseGLCanvasPane</tt> is a
no-op, and your subclass needs to override <tt>
 Redraw</tt>.
<P>

<H3><A NAME=SECTION008541000000000000000> virtual void VPage(int Shown, int Top)</A></H3>
<P>
<A NAME=5628>&#160;</A>
<P>
See <tt>
 HPage</tt>.
<P>

<H3><A NAME=SECTION008541100000000000000> virtual void VScroll(int step)</A></H3>
<P>
<A NAME=5631>&#160;</A>
<P>
This method is called when the user enters a single step command
to the vertical scroll bar. The value of <tt>
 step</tt> will be
positive for down or negative for up scroll.  These scrolls are
usually interpreted as discreet steps - either a line or
screenful at a time. It is up to your application to give an
appropriate interpretation.
<P>
<H2><A NAME=SECTION00855000000000000000> See Also</A></H2>
<P>
vTextCanvasPane
<P>

<H1><A NAME=SECTION00860000000000000000> vTextEditor</A></H1>
<P>
<A NAME=5634>&#160;</A>
<A NAME=4759>&#160;</A>
<P>
A complete text editing canvas pane.
<P>
<H2><A NAME=SECTION00861000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vtexted.h&gt;</tt>
	<DT>Class name:
<DD> vTextEditor
 	<DT>Hierarchy:
<DD> vCanvasPane -&gt;
  vTextCanvasPane -&gt;
  vTextEditor
<P>
 </DL><H2><A NAME=SECTION00862000000000000000> Description</A></H2>
<P>
This class is a completely functional line oriented text editor.
It can edit any file with lines less than 300 characters wide that
use a linefeed, carriage return, or combination of those to mark
the end of each line.
<P>
While you need to create your own class derived from <tt>
 vTextEditor</tt>,
your class can be very minimal. You will need to provide some
service methods for the parent <tt>
 vCmdWindow</tt>, such as methods
to open, read, save, and close files. Other than actually working
with the real text source and providing that source to <tt>
 vTextEditor</tt>,
you can get a fully functional text editor with no additional work.
<P>
However, <tt>
 vTextEditor</tt> has been designed to allow you to extend
and add functionality to the editor if you need to. The <tt>
 vTextEditor</tt>
also sends messages that will allow you to place various status
messages on a status bar if you wish. The hard stuff is done for you.
You don't need to worry about mouse movements, scroll bars or scroll
messages, updating the screen, handling keystrokes, or anything else
associated with actual editing. The <tt>
 vTextEditor</tt> class takes
care of all those details, and provides a standard editing interface.
<P>
The following steps are required to use <tt>
 vTextEditor</tt>. First,
you create an instance of your derived class from your <tt>
 vCmdWindow</tt>
class, something like this:
<P>
<PRE>   ...

   // The Text Editor Canvas
    vedCanvas = new vedTextEditor(this);
    AddPane(vedCanvas);
   ...

   // Show Window

    ShowWindow();
    vedCanvas-&gt;ShowVScroll(1);  // Show Vert Scroll for vTextEditor

    ...
</PRE>
<P>
Your derived <tt>
 vTextEditor</tt> class should provide the methods
needed for opening and reading the text file you want to edit.
(Actually, you can edit any text source you wish.) <tt>
 VTextEditor</tt>
doesn't actually read or write any text itself. It maintains an
internal line buffer. (The default version of the internal buffer
is essentially limited by the amount of memory your system can
provide. The buffer methods can be overridden to provide totally
unlimited file size, if you wish.) The idea is to have your
application control where the text comes from, and then
add it a line at a time to the <tt>
 vTextEditor</tt> buffer.
You retrieve the text a line at a time when you want to save
the edited text. Thus, your if your code is working with
disk files, it can read the text a line at a time, and let
<tt>
 vTextEditor</tt> worry about the buffering.
<P>
The following code shows how to add the contents of a text file
to the <tt>
 vTextEditor</tt> buffer, and display it in the canvas
for the first time. Calls to <tt>
 vTextEditor</tt> methods are
marked with **.
<P>
<PRE>//===================&gt;&gt;&gt; vedTextEditor::ReadFile &lt;&lt;&lt;====================
  int vedTextEditor::ReadFile(char* name)
  {
    const int maxBuff = 300;    // Line length
    char buff[maxBuff];

    if (!name || !*name)
        return 0;
    ifstream inFile(name);      // Open the file

    if (!inFile)
        return 0;               // file not there

    resetBuff();                // ** Tell vTextEditor to init buffer

    while (inFile.getline(buff,maxBuff))  // read file
      {
        if (!addLine(buff))     // ** Add the line to the buffer
          {
            ERROR_MESSAGE(&quot;File too big -- only partially read.&quot;);
            break;
          }
      }
    inFile.close();             // Close the file
    displayBuff();              // ** Now, display the buffer
    return 1;
  }
</PRE>
<P>
To load text into the editor buffer,
you first call <tt>
 resetBuff</tt> to initialize the
buffer, then add a line at a time with calls to <tt>
 addLine</tt>,
and finally display the text by calling <tt>
 displayBuff</tt>.
<P>
When your are editing (e.g., the user enters a Close command),
you retrieve the text from the <tt>
 vTextEditor</tt> buffer
with calls to <tt>
 getLine</tt>.
<P>
Then, to use the editor, you pass keystrokes from the
<tt>
 KeyIn</tt> method of your <tt>
 vCmdWindow</tt> to the <tt>
 EditKeyIn</tt>
method of the <tt>
 vTextEditor</tt>. <tt>
 EditKeyIn</tt> interprets
the conventional meanings of the arrow keys, etc., and lets
you edit the text in the buffer. You will also probably implement
other commands, such as Find, by using the <tt>
 EditCommand</tt>
method.
<P>
<tt>
 VTextEditor</tt> also calls several methods to notify of
text state changes, such as current line, insert or overtype,
etc. You can receive these messages by overriding the default
methods, and display appropriate information on a status bar.
<P>
While <tt>
 vTextEditor</tt> is very complete, there are some
things missing. The major hole is cut and paste support. This
will be added when cut and paste support is added to V
 . There
is also no real undo support. Maybe someday.
<P>
<H2><A NAME=SECTION00863000000000000000> Constructor</A></H2>
 
<P>
<H3><A NAME=SECTION00863100000000000000> vTextEditor(vBaseWindow* parent)</A></H3>
<P>
<A NAME=5637>&#160;</A>
<P>
The <tt>
 vTextEditor</tt> constructor requires that you specify
the parent <tt>
 vCmdWindow</tt>. Since you usually create the text editor object
in your <tt>
 vCmdWindow</tt> object, this is easy. You will probably need
to cast the <tt>
 this</tt> to a <tt>
 vBaseWindow*</tt>.
<P>
<H2><A NAME=SECTION00864000000000000000> Utility Methods</A></H2>
 
<P>
<H3><A NAME=SECTION00864100000000000000> resetBuff()</A></H3>
<P>
<A NAME=5640>&#160;</A>
<P>
Before you load new text into the buffer, you must first
call this method. It initializes the internal state of
the text buffer.
<P>
<H3><A NAME=SECTION00864200000000000000> virtual int addLine(char* line)</A></H3>
<P>
<A NAME=5643>&#160;</A>
<P>
This method is called repeatedly to add lines to the
text buffer. The default method is limited by the amount
of memory available on the system, and this method
return 0 when it runs out of memory.
<P>
Note that the entire text buffer package can be overridden
if you need to provide unlimited file size handling. You
should examine the source code for <tt>
 vTextEditor</tt> to
determine the specifications of the methods you'd need
to override.
<P>
<H3><A NAME=SECTION00864300000000000000> virtual void displayBuff()</A></H3>
<P>
<A NAME=5646>&#160;</A>
<P>
After you have added the complete file, call <tt>
 displayBuff</tt>
to display the text in the window.
<P>
<H3><A NAME=SECTION00864400000000000000> virtual int getLine(char* line, int maxChars, long
lineNum)</A></H3>
<P>
<H3><A NAME=SECTION00864500000000000000> virtual int getFirstLine(char* line, int maxChars)</A></H3>
<P>
<A NAME=5650>&#160;</A>
<P>
<H3><A NAME=SECTION00864600000000000000> virtual int getNextLine(char* line, int maxChars)</A></H3>
<P>
<A NAME=5653>&#160;</A>
<P>
These are used to retrieve the edited text from the buffer.
You can use <tt>
 getFirstLine</tt> with <tt>
 getNextLine</tt> for
easy sequential retrieval, or <tt>
 getLine</tt> for specific
lines. These methods return -1 when all lines have been
recovered.
<P>
<H3><A NAME=SECTION00864700000000000000> virtual int EditCommand(int id, long val)</A></H3>
<P>
<A NAME=5656>&#160;</A>
<P>
This method provides a complete interface to the functions
provided by <tt>
 vTextEditor</tt>. While the basic
editing functions are also handled by <tt>
 EditKeyIn</tt>,
<tt>
 EditCommand</tt> gives access to functions that typically
are either usually invoked from a menu command (such as
Find), or don't have a standard mapping to a functions
key (such as lineGoto). If you want the functionality of
these commands in your application, you will have to
provide an appropriate menu or command pane item to
support them.
<P>
Each function supported by <tt>
 vTextEditor</tt> has an
associated id (symbolically defined in <tt>
 v/vtexted.h</tt>), each
beginning with <tt>
 ed</tt>. Many of
the functions also take an associated value. Many editors
allow a repetition count to be specified with many commands.
For example, it is sometimes useful to be able to specify
a command to move right some specific number of characters.
The <tt>
 val</tt> parameter can be used to specify a value
as desired. The only function that really need a value
other than 1 (or -1 in the case of directional movement
commands) is <tt>
 edLineGoto</tt>.
<P>
<tt>
 EditCommand</tt> returns 1 if the command was executed
successfully, 0 if the command was recognized, but not
successful (the find fails, for example), and -1 if
the command was not recognized as valid.
<P>
At the time this manual was written, the following commands
are supported. Because <tt>
 vTextEditor</tt> is evolving,
it is likely more commands will be added. Check the
<tt>
 v/vtexted.h</tt> file for specification of new editor
commands. In the following descriptions, the note
``no val'' means that the <tt>
 val</tt> parameter is not
used. A notation of ``+/-'' means the sign of <tt>
 val</tt>
indicates direction.
<P>
<DL ><DT>edBalMatch
<DD> find matching paren (if val &gt; 1, up to val
lines away, otherwise within a reasonable range)
<DT>edBufferBottom
<DD> move to bottom of file (no val)
<DT>edCharDelete
<DD> delete +/- val chars
<DT>edCharFoldCase
<DD> swap case of +/- val letters
<DT>edCharInsert
<DD> insert char val
<DT>edCharRight
<DD> move +/- val chars right
<DT>edFind
<DD> invoke TextEd's find dialog (no val)
<DT>edFindNext
<DD> find next occurrence of prev (no val)
<DT>edLineBeginning
<DD> move to line beginning (no val)
<DT>edLineDown
<DD> move down +/- val lines in column
<DT>edLineDownBeg
<DD> move down +/- val lines
<DT>edLineDelete
<DD> delete +/- val lines
<DT>edLineDeleteFront
<DD> delete to beginning of line (no val)
<DT>edLineDeleteToEnd
<DD> delete to end of line (no val)
<DT>edLineEnd
<DD> move to end of line (no val)
<DT>edLineGoto
<DD> move cursor to line val
<DT>edLineOpen
<DD> open val new blank lines
<DT>edScrollDown
<DD> scroll +/- val lines without changing cursor
<DT>edVerify
<DD> force repaint of screen (no val)
<DT>edWordRight
<DD> move cursor +/- val words right
<P>
 </DL>
<P>
For a basic editor, the simplest way to use <tt>
 EditCommand</tt>
is to use the <tt>
 ed*</tt> id's to define the associated menu
items and controls, and then call <tt>
 EditCommand</tt> as the
default case of the <tt>
 switch</tt> in the <tt>
 WindowCommand</tt>
method of your <tt>
 vCmdWindow</tt>. Thus, you might have
code that looks like this:
<P>
<PRE>   ...
  static vMenu EditMenu[] = {
  ...
    {&quot;Find&quot;, edFind, isSens,notChk,noKeyLbl,noKey,noSub},
    {&quot;Find Next&quot;, edFindNext, isSens,notChk,noKeyLbl,noKey,noSub},
    {&quot;Find Matching Paren&quot;, edBalMatch, isSens,notChk,
      noKeyLbl,noKey,noSub},
  ...
  };

   ...

//===========&gt;&gt;&gt; vedCmdWindow::WindowCommand &lt;&lt;&lt;====================
 void vedCmdWindow::WindowCommand(ItemVal id, ItemVal val,
      CmdType cType)
 {
   switch (id)
    {
     ...

      default:  // route unhandled commands through editor
       {
         if (vedCanvas-&gt;EditCommand(id, 1) &lt; 0)
            vCmdWindow::WindowCommand(id, val, cType);
        break;
       }

    }
   ...
 }

//====================&gt;&gt;&gt; vedCmdWindow::KeyIn &lt;&lt;&lt;====================
  void vedCmdWindow::KeyIn(vKey keysym, unsigned int shift)
  {
    if (vedCanvas-&gt;EditKeyIn(keysym, shift) &lt; 0)
        vCmdWindow::KeyIn(keysym, shift);
  }
</PRE>
<P>
<H3><A NAME=SECTION00864800000000000000> virtual int EditKeyIn(vKey key, unsigned int shift)</A></H3>
<P>
<A NAME=5659>&#160;</A>
<P>
This method is usually called from the <tt>
 KeyIn</tt> method
of your derived <tt>
 vCmdWindow</tt> class. See the above code
example.
<P>
The default implementation of <tt>
 EditKeyIn</tt> handles
most of the standard keys, such as
the arrow keys, the page keys, backspace, home, delete,
insert, and end keys. It will also insert regular
character keys into the text. It ignores function keys
and non-printing control key values except tab and newline.
<P>
You can override this method to provide your own look and feel
to the editor.
<P>
<H3><A NAME=SECTION00864900000000000000> edState GetEdState()</A></H3>
<P>
<A NAME=5662>&#160;</A>
<P>
<H3><A NAME=SECTION008641000000000000000> void SetEdState()</A></H3>
<P>
<A NAME=5665>&#160;</A>
<P>
<tt>
 VTextEditor</tt> maintains a state structure with relevant state
information associated with various operating options of <tt>
 vTextEditor</tt>. It is
defined in <tt>
 v/vtexted.h</tt>, and has the following fields:
<P>
<PRE>    typedef struct edState
      {
        long changes,           // count of changes
             cmdCount;          // how many times to repeat command
        int
            findAtBeginning,    // leave find at beginning of pattern
            fixed_scroll,       // flag if using fixed scroll
            ins_mode,           // true if insert mode
            counter,            // counter for + insert
            echof,              // whether or not to echo action
            tabspc,             // tab spacing
            wraplm;             // right limit
      } edState;
</PRE>
<P>
You can query and set the state with <tt>
 GetEdState</tt> and
<tt>
 SetEdState</tt>.
<P>
<H3><A NAME=SECTION008641100000000000000> long GetLines()</A></H3>
<P>
<A NAME=5668>&#160;</A>
<P>
Returns the number of lines in the current buffer.
<P>
<H2><A NAME=SECTION00865000000000000000> Methods to Override</A></H2>
 
<P>
<H3><A NAME=SECTION00865100000000000000> virtual void ChangeLoc(long line, int col)</A></H3>
<P>
<A NAME=5671>&#160;</A>
<P>
This method is called by <tt>
 vTextEditor</tt> whenever the current line
or current column is changed. This information could be displayed
on a status bar, for example.
<P>
<H3><A NAME=SECTION00865200000000000000> virtual void ChangeInsMode(int IsInsMode)</A></H3>
<P>
<A NAME=5674>&#160;</A>
<P>
This method is called by <tt>
 vTextEditor</tt> whenever the
insert mode is changed. If <tt>
 IsInsMode</tt> is true, then
the editor is in insert mode. Otherwise, it is in overtype
mode. The editor starts in insert mode. This information could be displayed
on a status bar, for example.
<P>
<H3><A NAME=SECTION00865300000000000000> virtual void StatusMessage(char* Msg)</A></H3>
<P>
<A NAME=5677>&#160;</A>
<P>
The editor will call this message with a non-critical message
such as ``Pattern Not Found'' for certain operations.
This information could be displayed on a status bar, for example.
<P>
<H3><A NAME=SECTION00865400000000000000> virtual void ErrorMessage(char* Msg)</A></H3>
<P>
<A NAME=5680>&#160;</A>
<P>
The editor will call this message with a critical error message
such as ``Bad parameter value'' for certain operations.
This information could be displayed in a warning dialog, for example.
<P>
<H2><A NAME=SECTION00866000000000000000> See Also</A></H2>
 
<P>
vTextCanvasPane

<P>
<H1><A NAME=SECTION00870000000000000000> vBaseGLCanvasPane</A></H1>
<P>
<A NAME=5683>&#160;</A>
<A NAME=4871>&#160;</A>
<P>
A specialized base class to support OpenGL graphics.
<P>
<H2><A NAME=SECTION00871000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vbglcnv.h&gt;</tt>
	<DT>Class name:
<DD> vBaseGLCanvasPane
 	<DT>Hierarchy:
<DD> vPane -&gt;
  vBaseGLCanvasPane
<P>
 </DL><H2><A NAME=SECTION00872000000000000000> Description</A></H2>
<P>
This is a specialized class to provide very basic support
for the OpenGL graphics package. Unlike other V
  canvas
panes, this class does not use a <tt>
 vDC</tt> class. Instead,
it has a few features designed to support OpenGL.
<P>
This is a basic class. It does not provide many convenience
methods to support OpenGL at a high level, but it does hide
all the messy details of interfacing with the host GUI
environment, and provides the first really easy way to
generate sophisticated interfaces for OpenGL applications.
A more sophisticated class
called <tt>
 vGLCanvasPane</tt> that will provide a number
of convenience operations is under development, but the
base class is still very useful.
<P>
By following a standard convention to structure V/OpenGL
code, it is relatively easy to generate applications.
The details of this convention are explained in the tutorial
section of this description.
<P>
See the section <tt>
 vPane</tt> for a general description of panes.
<P>
<H2><A NAME=SECTION00873000000000000000> Constructor</A></H2>
 
<H3><A NAME=SECTION00873100000000000000> vBaseGLCanvasPane(unsigned int vGLmode)</A></H3>
<P>
<A NAME=5686>&#160;</A>
<P>
The <tt>
 vBaseGLCanvasPane</tt> constructor allows you to specify
certain attributes of the visual used by OpenGL. The options,
which can be ORed together, include:
<P>
<DL ><DT>vGL_Default
<DD> Use the default visual, which includes
<tt>
 vGL_RGB</tt> and <tt>
 vGL_DoubleBuffer</tt>. V
  will
use this default if you don't provide a value to the constructor.
<P>
<DT>vGL_RGB
<DD> This is the standard RGBA mode used by
most OpenGL programs. The size of the RED, GREEN, and
BLUE planes are maximized according to the capabilities
of the host machine. An ALPHA plane is not included
unless the <tt>
 vGL_Alpha</tt> property is also specified.
<P>
<DT>vGL_Alpha
<DD> Used to include an APLHA plane. Not all
machines support ALPHA planes.
<P>
<DT>vGL_Indexed
<DD> Use indexed rather than RGB mode. V
 \
will attempt to maximize the usefulness of the palette.
You should not specify both RGB and Indexed.
<P>
<DT>vGL_DoubleBuffer
<DD> Use Double buffering if available.
Single buffering is assumed if <tt>
 vGL_DoubleBuffer</tt> is not
specified.
<P>
<DT>vGL_Stereo
<DD> Use a Stereo buffer if available.
<P>
<DT>vGL_Stencil
<DD> Use Stencil mode if available.
<P>
<DT>vGL_Accum
<DD> Use accumulation buffers if available.
<P>
<DT>vGL_Depth
<DD> Use Depth mode if available.
<P>
 </DL>
<P>
Not all of these attributes are available on all OpenGL implementations,
and V
  will attempt to get a reasonable visual based on your
specifications. For now, the <tt>
 vGL_Default</tt> mode works well
for many OpenGL applications.
<P>
V
  supports only one visual per application, and the first
<tt>
 vBaseGLCanvasPane</tt> created determines the attributes of
the visual used.
<P>
<H2><A NAME=SECTION00874000000000000000> Utility Methods</A></H2>
 
<P>
The following methods provide useful service without modification. Sometimes
you will want to override some of these, but you will then usually
call these methods from your derived class. Most of these methods
are the equivalent of the normal V
  <tt>
 vCanvasPane</tt> class.
<P>

<H3><A NAME=SECTION00874100000000000000> VCursor GetCursor()</A></H3>
<P>
<A NAME=5689>&#160;</A>
<P>
Returns the id of the current cursor being used in the canvas.
See <tt>
 SetCursor</tt>.
<P>

<H3><A NAME=SECTION00874200000000000000> virtual int GetHeight()</A></H3>
<P>
<A NAME=5692>&#160;</A>
<P>
Returns the height of the current drawing canvas in pixels.
<P>

<H3><A NAME=SECTION00874300000000000000> virtual int GetHScroll(int&amp; Shown, int&amp; Top)</A></H3>
<P>
<A NAME=5695>&#160;</A>
<P>
Get the status of the Horizontal Scroll bar. Returns 1 if the
scroll bar is displayed, 0 if not. Returns in <tt>
 Shown</tt> and
<tt>
 Top</tt> the current values of the scroll bar. See <tt>
 SetVScroll</tt>
for a description of the meanings of parameters.
<P>

<H3><A NAME=SECTION00874400000000000000> virtual int GetVScroll(int&amp; Shown, int&amp; Top)</A></H3>
<P>
<A NAME=5698>&#160;</A>
<P>
Get the status of the Vertical Scroll bar. See
<tt>
 GetHScroll</tt> for details.
<P>

<H3><A NAME=SECTION00874500000000000000> virtual int GetWidth()</A></H3>
<P>
<A NAME=5701>&#160;</A>
<P>
Returns the width of the current drawing canvas in pixels.
This is either the initial size of the window, or the size
after the user has resized the window.
<P>

<H3><A NAME=SECTION00874600000000000000> void SetCursor(VCursor id)</A></H3>
<P>
<A NAME=5704>&#160;</A>
<P>
This method sets the cursor displayed while the mouse in
in the current canvas area.
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00874700000000000000> void SetWidthHeight(int width, int height)</A></H3>
<P>
<A NAME=5707>&#160;</A>
<P>
This will set the size of the drawing canvas to <tt>
 height</tt>
and <tt>
 width</tt> in pixels. It will also cause a <tt>
 Resize</tt>
event message to be sent to the window.
<P>

<H3><A NAME=SECTION00874800000000000000> virtual void SetHScroll(int Shown, int Top)</A></H3>
<P>
<A NAME=5710>&#160;</A>
<P>
Set the horizontal scroll bar
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00874900000000000000> virtual void SetVScroll(int Shown, int Top)</A></H3>
<P>
<A NAME=5713>&#160;</A>
<A NAME=4922>&#160;</A>
<P>
Set the vertical scroll bar. 
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION008741000000000000000> virtual void ShowHScroll(int OnOrOff)</A></H3>
<P>
<A NAME=5716>&#160;</A>
<P>
<H3><A NAME=SECTION008741100000000000000> virtual void ShowVScroll(int OnOrOff)</A></H3>
<P>
<A NAME=5719>&#160;</A>
<A NAME=4928>&#160;</A>
<P>
See the description of <tt>
 vCanvasPane</tt> for details.
<P>
<H2><A NAME=SECTION00875000000000000000> Methods to Override</A></H2>
 
<P>

<H3><A NAME=SECTION00875100000000000000> virtual void HPage(int Shown, int Top)</A></H3>
<P>
<A NAME=5722>&#160;</A>
<P>
When the user moves the horizontal scroll bar, it generates an
<tt>
 HPage</tt> event. 
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00875200000000000000> virtual void HScroll(int step)</A></H3>
<P>
<A NAME=5725>&#160;</A>
<P>
This method is called when the user enters a single step command
to the scroll bar. 
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00875300000000000000> virtual void MouseDown(int x, int y, int button)</A></H3>
<P>
<A NAME=5728>&#160;</A>
<P>
This is called when the user clicks a button on the mouse.
<P>
It is important to remember that all mouse coordinates are
in screen pixels, and use 0,0 as the upper left corner.
You will probably have to map them to the actual coordinates
in use by your OpenGL graphic.
<P>
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00875400000000000000> virtual void MouseMotion(int x, int y)</A></H3>
<P>
<A NAME=5731>&#160;</A>
<P>
This is called when the mouse moves while a button is <em>not</em>
pressed.
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00875500000000000000> virtual void MouseMove(int x, int y, int button)</A></H3>
<P>
<A NAME=5734>&#160;</A>
<P>
This is called when the mouse moves while a button is pressed.
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00875600000000000000> virtual void MouseUp(int x, int y, int button)</A></H3>
<P>
<A NAME=5737>&#160;</A>
<P>
This is called when the user releases the mouse button.
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION00875700000000000000> virtual void Redraw(int x, int y, int width, int height)</A></H3>
<P>
<A NAME=5740>&#160;</A>
<P>
<tt>
 Redraw</tt> is called when the canvas needs to be redrawn.
The first redraw is generated when the canvas is first created.
Other redraws are generated when the canvas is covered or uncovered
by another window, and means the contents of the canvas must
be repainted. Normally, you will put a call to the code that
redraws your OpenGl picture here.
<P>
The parameters of <tt>
 Redraw</tt> represent the rectangular area
that needs to be repainted. This areas is not always the whole
canvas, and it is possible that many <tt>
 Redraw</tt> events will
be generated in a row as the user drags a covering window off
the canvas.
<P>
The default <tt>
 Redraw</tt> in <tt>
 vBaseGLCanvasPane</tt> is a
no-op, and your subclass needs to override <tt>
 Redraw</tt>.
<P>

<H3><A NAME=SECTION00875800000000000000> virtual void Resize(int newW, int newH)</A></H3>
<P>
<A NAME=5743>&#160;</A>
<P>
A <tt>
 Resize</tt> event is generated when the user changes the
size of the canvas using the resize window command provided
by the host windowing system.
<P>
The default <tt>
 Resize</tt> in <tt>
 vBaseGLCanvasPane</tt> is a
no-op, and your subclass needs to override <tt>
 Redraw</tt>.
<P>

<H3><A NAME=SECTION00875900000000000000> virtual void VPage(int Shown, int Top)</A></H3>
<P>
<A NAME=5746>&#160;</A>
<P>
See the description of <tt>
 vCanvasPane</tt> for details.
<P>

<H3><A NAME=SECTION008751000000000000000> virtual void VScroll(int step)</A></H3>
<P>
<A NAME=5749>&#160;</A>
<P>
See the description of <tt>
 vCanvasPane</tt> for details.
<P>
<H2><A NAME=SECTION00876000000000000000> Specific OpenGL methods</A></H2>
 
<P>

<H3><A NAME=SECTION00876100000000000000> virtual void graphicsInit(void)</A></H3>
<P>
<A NAME=5752>&#160;</A>
<P>
This method is called after the OpenGL drawing canvas has
been created, and <em>must</em> be overridden by your code.
You use this method to set up whatever you would usually do
to initialize OpenGL. In practice, this is a very convenient
way to get things started.
<P>
It is critical that you call the <tt>
 graphicsInit</tt> method
in the base <tt>
 vBaseGLCanvasPane</tt> class <em>first</em>,
then whatever OpenGL calls you need.
See the example in the OpenGL tutorial section for more details.
<P>

<H3><A NAME=SECTION00876200000000000000> void vglMakeCurrent(void)</A></H3>
<P>
<A NAME=5755>&#160;</A>
<P>
This method should be called by your program before you
call any OpenGL drawing code. Normally, this is called
first thing in <tt>
 Redraw</tt>, or whatever code you use
to draw with. It is essential to call this, and since
it is cheap to call this for an already current drawing
canvas, it is better to be safe.
<P>

<H3><A NAME=SECTION00876300000000000000> virtual void vglFlush(void)</A></H3>
<P>
<A NAME=5758>&#160;</A>
<P>
Call this method after you are finished calling OpenGL to
draw a picture. It automatically handles the details of
displaying your picture in the window, including double
buffering and synchronization. It is normally found in your
<tt>
 Redraw</tt> method.
<P>

<H3><A NAME=SECTION00876400000000000000> virtual XVisualInfo* GetXVisualInfo()</A></H3>
<P>
<A NAME=5761>&#160;</A>
<P>
This method is specific to X, and will return a pointer to the
<tt>
 XVisualInfo</tt> structure currently being used. There will
be an equivalent method available for MS-Windows.
<P>
<H2><A NAME=SECTION00877000000000000000> Tutorial</A></H2>
 
<P>
A minimal V/OpenGL application will consist of a class derived
from <tt>
 vApp</tt>, a class derived from <tt>
 vCmdWindow</tt>, and
a canvas pane class derived from <tt>
 vBaseGLCanvasPane</tt>.
Most of your drawing code will be in or called from your derived
canvas pane.
<P>
Within that class, you will minimally need to override the
<tt>
 graphicsInit</tt> method, and the <tt>
 Redraw</tt> method. The
following code fragment, adapted directly from the example code
in Mark J. Kilgard's book, <em>OpenGL, Programming for the X
Window System</em>, shows how simple it can be to draw a picture.
The full code can be found in the <tt>
 opengl/shapes</tt> directory
in the V
  distribution.
<P>
<PRE>  static int initDone = 0;

  ......

//==========&gt;&gt;&gt; testGLCanvasPane::graphicsInit &lt;&lt;&lt;=================
  void testGLCanvasPane::graphicsInit(void)
  {
    // Always call the superclass first!
    vBaseGLCanvasPane::graphicsInit();

    // Example from Mark Kilgard
    glEnable(GL_DEPTH_TEST);
    glClearDepth(1.0);
    glClearColor(0.0, 0.0, 0.0, 0.0);  /* clear to black */
    glMatrixMode(GL_PROJECTION);
    gluPerspective(40.0, 1.0, 10.0, 200.0);
    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0.0, 0.0, -50.0);
    glRotatef(-58.0, 0.0, 1.0, 0.0);

    initDone = 1;
  }

//============&gt;&gt;&gt; testGLCanvasPane::Spin &lt;&lt;&lt;=======================
  void testGLCanvasPane::Spin()
  {
    // Called from the parent CmdWindow for animation
    vglMakeCurrent();              // Call this FIRST!
    glRotatef(2.5, 1.0, 0.0, 0.0);
    Redraw(0,0,0,0);
  }

//============&gt;&gt;&gt; testGLCanvasPane::Redraw &lt;&lt;&lt;=====================
  void testGLCanvasPane::Redraw(int x, int y, int w, int h)
  {
    static int inRedraw = 0;

    if (inRedraw || !initDone)  // Don't draw until initialized
 	return;

    inRedraw = 1;               // Don't allow recursive redraws.

    vglMakeCurrent();           // Call this to make current

    // Code taken directly from Mark J. Kilgard's example
    // Draws 3 intersecting triangular planes
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_POLYGON);
    glColor3f(0.0, 0.0, 0.0); glVertex3f(-10.0, -10.0, 0.0);
    glColor3f(0.7, 0.7, 0.7); glVertex3f(10.0, -10.0, 0.0);
    glColor3f(1.0, 1.0, 1.0); glVertex3f(-10.0, 10.0, 0.0);
    glEnd();

    glBegin(GL_POLYGON);
    glColor3f(1.0, 1.0, 0.0); glVertex3f(0.0, -10.0, -10.0);
    glColor3f(0.0, 1.0, 0.7); glVertex3f(0.0, -10.0, 10.0);
    glColor3f(0.0, 0.0, 1.0); glVertex3f(0.0, 5.0, -10.0);
    glEnd();

    glBegin(GL_POLYGON);
    glColor3f(1.0, 1.0, 0.0); glVertex3f(-10.0, 6.0, 4.0);
    glColor3f(1.0, 0.0, 1.0); glVertex3f(-10.0, 3.0, 4.0);
    glColor3f(0.0, 0.0, 1.0); glVertex3f(4.0, -9.0, -10.0);
    glColor3f(1.0, 0.0, 1.0); glVertex3f(4.0, -6.0, -10.0);
    glEnd();

    vglFlush();    // Call when done drawing to display

    inRedraw = 0;  // Not in here any more
  }

  ....
</PRE>
<P>
Note that this example includes a method called <tt>
 Spin</tt>.
It is used to animate the intersecting planes. In a V
 \
OpenGL application, the easiest way to implement animation
is with the timer. Create a timer in the Command Window
class, and then call the animation code in the canvas
in response to timer events. You should keep code to
prevent recursive redraws if the timer events end up
occurring faster than the picture can be rendered, which
might happen for complex pictures or heavily loaded systems.
See the example code in the <tt>
 v/opengl</tt> directory for
a complete example of animation using the timer.
<P>
<H2><A NAME=SECTION00878000000000000000> See Also</A></H2>
 
<P>
vCanvasPane
<P>

<P>
<H1><A NAME=SECTION00880000000000000000> vColor</A></H1>
<P>
<A NAME=5764>&#160;</A>
<P>
<A NAME=5000>&#160;</A>
<P>
A class for handling and specifying colors.
<P>
<H2><A NAME=SECTION00881000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vcolor.h&gt;</tt>
	<DT>Class name:
<DD> vColor
<P>
 </DL><H2><A NAME=SECTION00882000000000000000> Description</A></H2>
<P>
The V
  color model allows you to specify colors as an RGB value.
<A NAME=5006>&#160;</A>
The intensity of each primary color, red, green, and blue are
specified as a value between 0 and 255. This allows you to
specify up to <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img12.gif"> colors. Just how many of all these
colors you can see and how they will look on your display will
depend on that display. Even so, you can probably count  on
(255,0,0) being something close to red on most displays. Given
this 24 bit model, the <tt>
 vColor</tt> class allows you to define
colors easily.
<P>
In order to make using colors somewhat easier, V
  has defined
<A NAME=5009>&#160;</A>
a standard array of 16 basic colors that you can
access by including <tt>
 v/vcolor.h&gt;</tt>. This array is called
<tt>
 vStdColors</tt>. You index the array using the symbols <tt>
 vC_Black</tt>,
<tt>
 vC_Red</tt>, <tt>
 vC_DimRed</tt>, <tt>
 vC_Green</tt>, <tt>
 vC_DimGreen</tt>,
<tt>
 vC_Blue</tt>, <tt>
 vC_DimBlue</tt>, <tt>
 vC_Yellow</tt>,
<tt>
 vC_DimYellow</tt>, <tt>
 vC_Magenta</tt>, <tt>
 vC_DimMagenta</tt>,
<tt>
 vC_Cyan</tt>, <tt>
 vC_DimCyan</tt>, <tt>
 vC_DarkGray</tt>,
<tt>
 vC_MedGray</tt>, and <tt>
 vC_White</tt>. For example, use the standard color
<tt>
 vStdColors[vC_Green]</tt> to represent green. You can also get a
<tt>
 char</tt> for the color by using the symbol to index the
<tt>
 char* vColorName[16]</tt> array.
<P>
The file <tt>
 &lt;v/vcb2x4.h&gt;</tt> contains definitions for
<A NAME=5032>&#160;</A>
8 color buttons in a 2 high by 4 wide frame. The file
<tt>
 &lt;v/vcb2x8.h&gt;</tt> has a 2 by 8 frame of all 16 standard colors.
You can specify the size of each button in the frame by
defining <tt>
 vC_Size</tt>. The default is 8. You can also specify
the location in a dialog of the color button frame by defining
the symbols <tt>
 vC_Frame, vC_RightOf,</tt> and <tt>
 vC_Below</tt>.
The ids of each button in the frame correspond to the color
indexes, but with a <tt>
 M</tt> prefix (e.g., <tt>
 M_Red</tt> for
<tt>
 vC_Red</tt>). See the example in <tt>
 v/examp</tt> for and example
of using the standard color button frames.
<P>
Also note that unlike most other V
  objects, it makes perfect
sense to assign and copy <tt>
 vColor</tt> values. Thus, assignment,
copy constructor, and equality comparison operators are provided.
<P>
<H2><A NAME=SECTION00883000000000000000> Constructor</A></H2>
 
<P>
<H3><A NAME=SECTION00883100000000000000> vColor(unsigned int rd 0, unsigned int gr = 0, unsigned int
bl = 0)</A></H3>
<P>
<A NAME=5767>&#160;</A>
<P>
The class has been defined so you can easily initialize a color
either by using its constructor directly, or indirectly via an
array declaration. Each color has a red, green, and blue value in
the range of 0 to 255.
<P>
<PRE>  // Declare Red via constructor
  vColor btncolor(255, 0 , 0);   // Red

  // Declare array with green and blue
  vColor GreenAndBlue[2] =
    {
      (0, 255, 0),              // Green
      (0, 0, 255)               // Blue
    };
</PRE>
<P>
<H2><A NAME=SECTION00884000000000000000> Utility Methods</A></H2>
 
<P>
<H3><A NAME=SECTION00884100000000000000> BitsOfColor()</A></H3>
<P>
This method returns the number of bits used by the machine
to display to represent color. A value of 8, for example,
means the computer is using 8 bits to show the color.
<P>
<H3><A NAME=SECTION00884200000000000000> ResetColor(unsigned int rd = 0, unsigned int gr = 0,
unsigned int bl = 0)</A></H3>
<P>
<H3><A NAME=SECTION00884300000000000000> ResetColor(vColor&amp; c)</A></H3>
<P>
<A NAME=5772>&#160;</A>
<P>
Like the <tt>
 Set</tt> method, this method will set all three values
of the color at once. However, V
  tries to preserve entries in
the system color palette or color map with <tt>
 ResetColor</tt>.
You can also pass a <tt>
 vColor</tt> object.
<P>
Consider the following code excerpt:
<P>
<PRE>    vColor aColor;        // A V Color
    vBrush aBrush;
    int iy;

    ...

    for (iy = 0 ; iy &lt; 128 ; ++iy)
      {
        aColor.Set(iy,iy,iy);     // Set to shade of gray
        aBrush.SetColor(aColor);  // Set brush
        canvas.DrawLine(10,iy+100,200,iy+100);  // Draw line
      }
    ...
</PRE>
<P>
This example will use up 128 color map entries on some systems
(X, for example). Once a system has run out of entries, V
  will
draw in black or white. When these systems run out of new color
map entries, the color drawn for new colors will be black or
white.
<P>
<PRE>    vColor aColor;        // A V Color
    vBrush aBrush;
    int iy;

    ...

    for (iy = 0 ; iy &lt; 128 ; ++iy)
      {
        aColor.ResetColor(iy,iy,iy);     // Set to shade of gray
        aBrush.SetColor(aColor);  // Set brush
        canvas.DrawLine(10,iy+100,200,iy+100);  // Draw line
      }
    ...
</PRE>
<P>
This example accomplishes the same as the first, but does not use
up color map entries. Instead, the entry used for <tt>
 aColor</tt>
is reused to get better use of the color map. If your application
will be working with a large number of colors that will vary,
using <tt>
 ResetColor</tt> will minimize the number of color map accesses.
<P>
On some systems, and systems with a full 24 bits of color,
<tt>
 ResetColor</tt> and <tt>
 Set</tt> work identically.
<P>
<em>WARNING</em>: If you intend to use <tt>
 ResetColor</tt> on a
<tt>
 vColor</tt> object, then <tt>
 ResetColor</tt> is the only way
you should change the color of that object. You should not
use the color assignment operator, or <tt>
 Set</tt>. <tt>
 ResetColor</tt>
needs to do some unconventional things internally to
preserve color palette entries, and these can be incompatible
with regular assignment or <tt>
 Set</tt>. You can, however,
safely use such a <tt>
 vColor</tt> object with any other <tt>
 vColor</tt>
object. For example:
<P>
<PRE>    vColor c1, c2;

    c1.ResetColor(100,100,100);    // You can use c1 with others.
    c2 = c1;                       // OK, but this = now makes c2
                                   // incompatible with ResetColor.
    c2.ResetColor(200,200,200);    // DON'T DO THIS
</PRE>
<P>
<H3><A NAME=SECTION00884400000000000000> Set(unsigned int rd = 0, unsigned int gr = 0, unsigned int bl = 0)</A></H3>
<P>
Set all three values of the color at once.
<P>
<H3><A NAME=SECTION00884500000000000000> void SetR(unsigned int rd = 0)</A></H3>
<P>
<A NAME=5776>&#160;</A>
<P>
Set the Red value.
<P>
<H3><A NAME=SECTION00884600000000000000> void SetG(unsigned int gr = 0)</A></H3>
<P>
<A NAME=5779>&#160;</A>
<P>
Set the Green value.
<P>
<H3><A NAME=SECTION00884700000000000000> void SetB(unsigned int bl = 0)</A></H3>
<P>
<A NAME=5782>&#160;</A>
<P>
Set the Blue value.
<P>
<H3><A NAME=SECTION00884800000000000000> unsigned int r()</A></H3>
<P>
Get the Red value.
<P>
<H3><A NAME=SECTION00884900000000000000> unsigned int g()</A></H3>
<P>
Get the Green value.
<P>
<H3><A NAME=SECTION008841000000000000000> unsigned int b()</A></H3>
<P>
Get the Blue value.
<P>
<H3><A NAME=SECTION008841100000000000000> int operator ==</A></H3>
<P>
Compare two color objects for equality.
<P>
<H3><A NAME=SECTION008841200000000000000> int operator !=</A></H3>
<P>
Compare two color objects for inequality.
<P>
<H2><A NAME=SECTION00885000000000000000> Notes about color</A></H2>
<P>
The color model used by V
  attempts to hide most of the
details for using color. However, for some applications
you may end up confronting some of the sticky issues of
color.
<P>
Most machines in use in 1996 will not support all <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img13.gif">
colors that can be represented by the RGB color specification.
Typically, they devote 8 or 16 bits to each pixel. This
means that the 24-bit RGB colors must be mapped to the
smaller 8-bit or 16-bit range. This mapping is usually
accomplished by using a palette or colormap.
<P>
V
  tries to use the default system color palette provided by the
machine it is running on. On some systems, such as X, it is
possible to run out of entries in the color map. Others, like
Windows, map colors not in the color palette to dithered colors.
V
  provides two methods to help with this problem. First,
<tt>
 vColor::BitsOfColor()</tt> tells you how many bits are used by
the running system to represent color. The method  
<tt>
 vColor::ResetColor(r,g,b)</tt> can be used to change the value
of a color without using up another entry in the system color
map. For now, these methods should allow you to work with color
with pretty good flexibility. Eventually, V
  may include more
direct support for color palettes.
<P>
<H2><A NAME=SECTION00886000000000000000> See Also</A></H2>
<P>
C_ColorButton, vCanvas
<P>

<P>
<H1><A NAME=SECTION00890000000000000000> vDC</A></H1>
<P>
<A NAME=5790>&#160;</A>
<P>
This is the base class that defines all the drawing methods provided
by the various drawing canvases.
<P>
<H2><A NAME=SECTION00891000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vdc.h&gt;</tt>
	<DT>Class name:
<DD> vDC
<P>
 </DL><H2><A NAME=SECTION00892000000000000000> Description</A></H2>
<P>
All drawing classes such as <tt>
 vCanvasPaneDC</tt> and <tt>
 vPostScriptDC</tt>
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 <tt>
 vdc.h</tt>.
<P>
See the specific sections for details of drawing classes.
<P>
<H2><A NAME=SECTION00893000000000000000> Utility Methods</A></H2>
<P>

<H3><A NAME=SECTION00893100000000000000> virtual void BeginPage()</A></H3>
<P>
<A NAME=5793>&#160;</A>
<P>
Supported by printer canvases. Call to specify a page is
beginning. Bracket pages with <tt>
 BeginPage</tt> and <tt>
 EndPage</tt>
calls.
<P>

<H3><A NAME=SECTION00893200000000000000> virtual void BeginPrinting()</A></H3>
<P>
<A NAME=5796>&#160;</A>
<P>
Required by printer canvases. Call to specify a document is
beginning. You <em>must</em> bracket documents with <tt>
 BeginPrinting</tt>
and <tt>
 EndPrinting</tt> calls. <tt>
 BeginPrinting</tt> includes an
implicit call to <tt>
 BeginPage</tt>.
<P>

<H3><A NAME=SECTION00893300000000000000> virtual void Clear()</A></H3>
<P>
<A NAME=5799>&#160;</A>
<P>
Clear the canvas to the background color. No op on printers.
<P>

<H3><A NAME=SECTION00893400000000000000> virtual void ClearRect(int x, int y, int width, int height)</A></H3>
<P>
<A NAME=5802>&#160;</A>
<P>
Clear a rectangular area starting at x,y of height and width. No
op on printers.
<P>

<H3><A NAME=SECTION00893500000000000000> void CopyFromMemoryDC(vMemoryDC* memDC, int destX, int
destY, int srcX = 0, int srcY = 0, int srcW = 0, int srcH = 0)</A></H3>
<P>
<A NAME=5805>&#160;</A>
<P>
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.
<P>
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.
<P>
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.
<P>

<H3><A NAME=SECTION00893600000000000000> virtual void DrawAttrText(int x, int y, char* text, const
ChrAttr attr)</A></H3>
<P>
<A NAME=5808>&#160;</A>
<P>
Draw text using the current font with specified attributes at
given x, y.
<P>
<A NAME=5126>&#160;</A>
<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.
<P>

<H3><A NAME=SECTION00893700000000000000> virtual void DrawColorPoints(int x, int y, int nPts, vColor*
pts)</A></H3>
<P>
<A NAME=5811>&#160;</A>
<P>
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>.
<P>

<H3><A NAME=SECTION00893800000000000000> virtual void DrawEllipse(int x, int y, int width, int
height)</A></H3>
<P>
<A NAME=5814>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION00893900000000000000> virtual void DrawIcon(int x, int y, vIcon&amp; icon)</A></H3>
<P>
<A NAME=5817>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008931000000000000000> virtual void DrawLine(int x, int y, int xend, int yend)</A></H3>
<P>
<A NAME=5820>&#160;</A>
<P>
Draw a line from x,y to xend,yend.
The current Pen will be used to draw the line.
<P>

<H3><A NAME=SECTION008931100000000000000> virtual void DrawLines(vLine* lineList, int count)</A></H3>
<P>
<A NAME=5823>&#160;</A>
<P>
Draws the <tt>
 count</tt> lines contained in the list <tt>
 lineList</tt>.
<P>
The current Pen will be used to draw the lines.
<P>
The type <tt>
 vLine</tt> is defined in <tt>
 v_defs.h</tt> as:
<A NAME=5825>&#160;</A>
<P>
<PRE>    typedef struct vLine
      {
        short x, y, xend, yend;
      } vLine;
</PRE>
<P>

<H3><A NAME=SECTION008931200000000000000> virtual void DrawPoint(int x, int y)</A></H3>
<P>
<A NAME=5828>&#160;</A>
<P>
Draw a point at x,y using the current Pen.
<P>

<H3><A NAME=SECTION008931300000000000000> virtual void DrawPoints(vPoint* pointList, int count)</A></H3>
<P>
<A NAME=5831>&#160;</A>
<P>
Draws the <tt>
 count</tt> points contained in the list <tt>
 pointList</tt>.
<P>
The current Pen will be used to draw the points.
<P>
The type <tt>
 vPoint</tt> is defined in <tt>
 v_defs.h</tt> as:
<A NAME=5833>&#160;</A>
<P>
<PRE>    typedef struct vPoint
      {
        short x, y;
      } vPoint;
</PRE>
<P>

<H3><A NAME=SECTION008931400000000000000> virtual void DrawPolygon(int n, vPoint points[],
int fillMode = vAlternate)</A></H3>
<P>
<A NAME=5836>&#160;</A>
<P>
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.
<P>
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.
<P>
The type <tt>
 vPoint</tt> is defined in <tt>
 v_defs.h</tt> as:
<A NAME=5838>&#160;</A>
<P>
<PRE>    typedef struct vPoint       // a point
      {
        short x, y;             // X version
      } vPoint;
</PRE>
<P>

<H3><A NAME=SECTION008931500000000000000> virtual void DrawRoundedRectangle(int x, int y, int width,
int height, int radius = 10)</A></H3>
<P>
<A NAME=5841>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008931600000000000000> virtual void DrawRectangle(int x, int y, int width,
int height)</A></H3>
<P>
<A NAME=5844>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008931700000000000000> virtual void DrawRectangles(vRect* rectList, int count)</A></H3>
<P>
<A NAME=5847>&#160;</A>
<P>
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.
<P>
The type <tt>
 vRect</tt> is defined in <tt>
 v_defs.h</tt> as:
<A NAME=5849>&#160;</A>
<P>
<PRE>    typedef struct vRect
      {
        short x, y, w, h;
      } vRect;
</PRE>
<P>

<H3><A NAME=SECTION008931800000000000000> virtual void DrawRubberLine(int x, int y, int xend, int yend)</A></H3>
<P>
<A NAME=5852>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008931900000000000000> virtual void DrawRubberEllipse(int x, int y, int width,
int height)</A></H3>
<P>
<A NAME=5855>&#160;</A>
<P>
Draw a rubber-band Ellipse. See DrawRubberLine.
<P>

<H3><A NAME=SECTION008932000000000000000> virtual void DrawRubberPoint(int x, int y)</A></H3>
<P>
<A NAME=5858>&#160;</A>
<P>
Draw a rubber-band point. See DrawRubberLine.
<P>

<H3><A NAME=SECTION008932100000000000000> virtual void DrawRubberRectangle(int x, int y, int width,
int height)</A></H3>
<P>
<A NAME=5861>&#160;</A>
<P>
Draw a rubber-band rectangle. See DrawRubberLine.
<P>

<H3><A NAME=SECTION008932200000000000000> virtual void DrawText(int x, int y, char* text)</A></H3>
<P>
<A NAME=5864>&#160;</A>
<P>
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>.)
<P>

<P>
<H3><A NAME=SECTION008932300000000000000> virtual void EndPage()</A></H3>
<P>
<A NAME=5867>&#160;</A>
<P>
Supported by printer canvases. Call to specify a page is
ending. Bracket pages with <tt>
 BeginPage</tt> and <tt>
 EndPage</tt>
calls.
<P>

<H3><A NAME=SECTION008932400000000000000> virtual void EndPrinting()</A></H3>
<P>
<A NAME=5870>&#160;</A>
<P>
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>.
<P>

<H3><A NAME=SECTION008932500000000000000> virtual vBrush GetBrush()</A></H3>
<P>
<A NAME=5873>&#160;</A>
<P>
Returns a copy of the current brush being used by the canvas.
<P>

<H3><A NAME=SECTION008932600000000000000> virtual vFont GetFont()</A></H3>
<P>
<A NAME=5876>&#160;</A>
<P>
Returns a copy of the current font of the drawing canvas.
<P>

<H3><A NAME=SECTION008932700000000000000> virtual vBrush GetPen()</A></H3>
<P>
<A NAME=5879>&#160;</A>
<P>
Returns a copy of the current pen being used by the canvas.
<P>

<H3><A NAME=SECTION008932800000000000000> virtual int GetPhysHeight()</A></H3>
<P>
<A NAME=5882>&#160;</A>
<P>
Returns the maximum physical y value supported by the
drawing canvas. Especially useful for determining scaling
for printers.
<P>

<H3><A NAME=SECTION008932900000000000000> virtual int GetPhysWidth()</A></H3>
<P>
<A NAME=5885>&#160;</A>
<P>
Returns the maximum physical x value supported by the
drawing canvas. Especially useful for determining scaling
for printers.
<P>

<H3><A NAME=SECTION008933000000000000000> virtual void GetScale(int&amp; mult, int&amp; div)</A></H3>
<P>
<A NAME=5888>&#160;</A>
<P>
Returns the scaling factors for the
canvas. See <tt>
 SetScale</tt>.
<P>

<H3><A NAME=SECTION008933100000000000000> void GetTranslate(int&amp; x, int&amp; y)</A></H3>
<P>
<A NAME=5891>&#160;</A>
<P>
<H3><A NAME=SECTION008933200000000000000> int GetTransX()</A></H3>
<P>
<A NAME=5894>&#160;</A>
<P>
<H3><A NAME=SECTION008933300000000000000> int GetTransY()</A></H3>
<P>
<A NAME=5897>&#160;</A>
<P>
Returns the current x and y translation values.
<P>

<H3><A NAME=SECTION008933400000000000000> virtual void SetBackground(vColor&amp; color)</A></H3>
<P>
<A NAME=5900>&#160;</A>
<P>
<A NAME=5237>&#160;</A>
<P>
This sets the background of the drawing canvas to the
specified color.
<P>

<H3><A NAME=SECTION008933500000000000000> virtual void SetBrush(vBrush&amp; brush)</A></H3>
<P>
<A NAME=5903>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008933600000000000000> virtual void SetFont(vFont&amp; vf)</A></H3>
<P>
<A NAME=5906>&#160;</A>
<P>
Change the font associated with this canvas. The default method
handles changing the font and calls the FontChanged method for
the canvas pane.
<P>

<H3><A NAME=SECTION008933700000000000000> virtual void SetPen(vPen&amp; pen)</A></H3>
<P>
<A NAME=5909>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008933800000000000000> virtual void SetScale(int mult, int div)</A></H3>
<P>
<A NAME=5912>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008933900000000000000> void SetTranslate(int x, int y)</A></H3>
<P>
<A NAME=5915>&#160;</A>
<P>
<H3><A NAME=SECTION008934000000000000000> void SetTransX(int x)</A></H3>
<P>
<A NAME=5918>&#160;</A>
<P>
<H3><A NAME=SECTION008934100000000000000> void SetTransY(int y)</A></H3>
<P>
<A NAME=5921>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008934200000000000000> int TextHeight(int&amp; ascent, int&amp; descent)</A></H3>
<P>
<A NAME=5924>&#160;</A>
<P>
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.
<P>

<H3><A NAME=SECTION008934300000000000000> int TextWidth(char* str)</A></H3>
<P>
<A NAME=5927>&#160;</A>
<P>
Returns the width in pixels or drawing points of the string
<tt>
 str</tt> using the currently set font of the canvas.
<P>

<H1><A NAME=SECTION008100000000000000000> vMemoryDC</A></H1>
<P>
<A NAME=5930>&#160;</A>
<P>
A memory drawing canvas.
<P>
<H2><A NAME=SECTION008101000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vmemdc.h&gt;</tt>
	<DT>Class name:
<DD> vMemoryDC
<P>
 </DL><H2><A NAME=SECTION008102000000000000000> Description</A></H2>
<P>
This drawing canvas can be used to draw to memory. Like
all drawing canvases, the available methods are described
in <tt>
 vDC</tt>. A very effective technique for using a memory
canvas is to draw to both the screen canvas pane and a memory
canvas during interactive drawing, and use the memory canvas to
update the screen for <tt>
 Redraw</tt> events. This is especially
useful if your application requires extensive computation to
draw a screen.
<P>
<H2><A NAME=SECTION008103000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION008103100000000000000> vMemoryDC(int width, int height)</A></H3>
<P>
<A NAME=5933>&#160;</A>
<P>
The constructor is used to construct a memory DC of the
specified width and height. This can be anything you need.
If you are using the memory DC to update the screen for
<tt>
 Redraw</tt> events, then it should be initialized to be
big enough to repaint whatever you will be drawing on the
physical screen. The methods  <tt>
 vApp::ScreenWidth()</tt> and
<tt>
 vApp::ScreenHeight()</tt> can be used to obtain the maximum
size of the physical screen.
<P>
The method <tt>
 CopyFromMemoryDC</tt> is used to copy the contents
of a memory DC to another DC. This can be another memory DC, but
will usually be a canvas pane DC.
<P>

<H1><A NAME=SECTION008110000000000000000> vPen</A></H1>
<P>
<A NAME=5936>&#160;</A>
<A NAME=5285>&#160;</A>
<P>
A class to specify the pen used to draw lines and shapes.
<P>
<H2><A NAME=SECTION008111000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vpen.h&gt;</tt>
	<DT>Class name:
<DD> vPen
<P>
 </DL><H2><A NAME=SECTION008112000000000000000> Description</A></H2>
<P>
Pens are used to draw lines and the outlines of shapes. Pens have
several attributes, including color, width, and style.
<P>
<H2><A NAME=SECTION008113000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION008113100000000000000> vPen(unsigned int r = 0, unsigned int g = 0, unsigned int b = 0, 
int width = 1, int style = vSolid)</A></H3>
<P>
<A NAME=5939>&#160;</A>
<P>
The constructor for a pen allows you to specify the pen's color,
width, and style. The default will construct a solid black pen of
width 1.
<P>
<H3><A NAME=SECTION008113200000000000000> int operator ==, !=</A></H3>
<P>
You can use the operators <tt>
 ==</tt> and <tt>
 !=</tt> for comparisons.
<P>
<H3><A NAME=SECTION008113300000000000000> vColor GetColor()</A></H3>
<P>
<A NAME=5943>&#160;</A>
<P>
This method returns the current color of the pen as a <tt>
 vColor</tt> object.
<P>
<H3><A NAME=SECTION008113400000000000000> int GetStyle()</A></H3>
<P>
<A NAME=5946>&#160;</A>
<P>
This method returns the current style of the pen.
<P>
<H3><A NAME=SECTION008113500000000000000> void GetWidth()</A></H3>
<P>
<A NAME=5949>&#160;</A>
<P>
This gets the width of the line the pen will draw.
<P>
<H3><A NAME=SECTION008113600000000000000> void SetColor(vColor&amp; c)</A></H3>
<P>
<A NAME=5952>&#160;</A>
<P>
<A NAME=5306>&#160;</A>
<P>
You can use this method to set the pen color by passing
in a <tt>
 vColor</tt> object.
<P>
<H3><A NAME=SECTION008113700000000000000> void SetStyle(int style)</A></H3>
<P>
<A NAME=5955>&#160;</A>
<P>
This method is used to change the style of a pen. Styles include:
<P>
<DL ><DT>vSolid
<DD> The pen draws a solid line.
	<DT>vTransparent
<DD> The pen is transparent. A transparent
pen can be used to avoid drawing borders around shapes. When drawing
text, a transparent pen draws the text over the existing background.
	<DT>vDash
<DD> The pen draws a dashed line.
	<DT>vDot
<DD> The pen draws a dotted line.
	<DT>vDashDot
<DD> The pen draws an alternating dash and dotted line.
<P>
 </DL><H3><A NAME=SECTION008113800000000000000> void SetWidth(int width)</A></H3>
<P>
<A NAME=5958>&#160;</A>
<P>
This sets the width of the line the pen will draw.
<P>

<H1><A NAME=SECTION008120000000000000000> vPrintDC</A></H1>
<P>
<A NAME=5961>&#160;</A>
<A NAME=5316>&#160;</A>
<P>
A printer drawing canvas.
<P>
<H2><A NAME=SECTION008121000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vprintdc.h&gt;</tt>
	<DT>Class name:
<DD> vPrintDC
<P>
 </DL><H2><A NAME=SECTION008122000000000000000> Description</A></H2>
<P>
This drawing canvas can be used to draw to a printer. Like
all drawing canvases, the available methods are described
in <tt>
 vDC</tt>. A very effective technique for combining a printer
DC and a screen DC is to pass a pointer to either a <tt>
 vCanvasPaneDC</tt>
or a <tt>
 vPrintDC</tt> to the code that draws the screen. The same
code can then be used to draw or print.
<P>
To successfully use a <tt>
 vPrintDC</tt>, your code must
obtain the physical size of the page in units using
<tt>
 GetPhysWidth</tt> and <tt>
 GetPhysHeight</tt>. On
paper, these represent 1/72 inch points, and correspond
very closely, but not exactly, to a pixel on the screen.
<P>
You must bracket the printing with calls to <tt>
 BeginPrinting</tt>
and <tt>
 EndPrinting</tt>. Use <tt>
 BeginPage</tt> and <tt>
 EndPage</tt>
to control paging. Note that the width of text will not
necessarily be the same on a <tt>
 vCanvasPaneDC</tt> and a <tt>
 vPrintDC</tt>,
even for the same fonts. Also, the size of the paper represents
the entire page. Most printers cannot actually print all the way
to the edges of the paper, so you will usually use <tt>
 vDC:SetTranslate</tt>
to leave some margins. (Don't forget to account for margins when
you calculate what can fit on a page.)
<P>
The implementation of <tt>
 vPrintDC</tt> is somewhat platform
dependent. For X, <tt>
 vPrintDC</tt> represents a PostScript
printer, and is derived from the class <tt>
 vPSPrintDC</tt>. For
Windows, <tt>
 vPrintDC</tt> is derived from the <tt>
 vWinPrintDC</tt>
class. To get platform independent operation for your
application, use <tt>
 vPrintDC</tt>. On Windows, you can also use
the PostScript version directly if you want by using the <tt>
 vPSPrintDC</tt>
class, but the program will not conform to standard Windows
behavior.
<P>
<H2><A NAME=SECTION008123000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION008123100000000000000> void SetPrinter(vPrinter&amp; printer)</A></H3>
<P>
<A NAME=5964>&#160;</A>
<P>
This method is used to associate a <tt>
 vPrinter</tt> with
a <tt>
 vPrintDC</tt>.
By default, a <tt>
 vPrintDC</tt> represents standard
8.5x11 inch Letter paper printed in black and white in
portrait orientation. You can use <tt>
 vPrinter::Setup</tt> to allow
the user to change the attributes of the printer, then use
<tt>
 SetPrinter</tt> to associate those attributes with the <tt>
 vPrintDC</tt>.
Note: If you change the default printer attributes, you <em>must</em>
call <tt>
 SetPrinter</tt> before doing any drawing to the DC.
<P>
<H2><A NAME=SECTION008124000000000000000> Example</A></H2>
<P>
This is a simple example taken from the <tt>
 VDraw</tt> demo program.
<tt>
 Print</tt> is called to print the current drawing. <tt>
 Print</tt>
calls <tt>
 vPrinter::Setup</tt> to set the printer characteristics,
and then calls <tt>
 DrawShapes</tt> with a pointer to the <tt>
 vPrintDC</tt>.
<tt>
 DrawShapes</tt> is also called to repaint the screen using the
<tt>
 vCanvasPaneDC</tt>. By carefully planning for both screen and
printer drawing, your program can often share drawing code in
this fashion.
<P>
<PRE>//===================&gt;&gt;&gt; myCanvasPane::Print &lt;&lt;&lt;=================
  void myCanvasPane::Print()
  {
    // Print current picture

    vPrintDC pdc;               // create a vPrintDC object
    vPrinter printer;           // and a printer to set attributes

    printer.Setup(&quot;test.ps&quot;);   // setup the printer
    pdc.SetPrinter(printer);    // change to the printer we setup

    if (!pdc.BeginPrinting())   // call BeginPrinting first
        return;

    pdc.SetTranslate(36,36);    // Add 1/2&quot; (36 * 1/72&quot;) margins

    DrawShapes(&amp;pdc);           // Now, call shared drawing method

    pdc.EndPrinting();          // Finish printing
  }

//===================&gt;&gt;&gt; myCanvasPane::DrawShapes &lt;&lt;&lt;=================
  void myCanvasPane::DrawShapes(vDC* cp)
  {
    // Common code for drawing both on Screen and Printer
    ...
  }
</PRE>
<P>

<H1><A NAME=SECTION008130000000000000000> vPrinter</A></H1>
<P>
<A NAME=5967>&#160;</A>
<A NAME=5364>&#160;</A>
<P>
A printer object, with a dialog to interactively set printer
attributes.
<P>
<H2><A NAME=SECTION008131000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vprinter.h&gt;</tt>
	<DT>Class name:
<DD> vPrinter
<P>
 </DL><H2><A NAME=SECTION008132000000000000000> Description</A></H2>
<P>
The <tt>
 vPrintDC</tt> class prints to a printer (or a file that
will eventually be printed). Printers have such attributes as
size of paper, page orientation, color capability, etc. By
calling the <tt>
 vPrinter::Setup</tt> dialog before printing, the
user will be given the option of setting various printer
attributes.
<P>
The exact functionality of the <tt>
 Setup</tt> dialog will be
platform dependent. By using the <tt>
 vPrinter</tt> class, you will
get the behavior appropriate for the platform. If you want to use
the <tt>
 vPSPrintDC</tt> class for PostScript support on Windows,
you can use <tt>
 vPSPrinter</tt> directly.
<P>
You can use the various methods associated with a <tt>
 vPrinter</tt>
to get printer attributes as needed to during drawing to
the <tt>
 vPrintDC</tt>.
<P>
<H2><A NAME=SECTION008133000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION008133100000000000000> int GetCopies()</A></H3>
<P>
<A NAME=5970>&#160;</A>
<P>
<H3><A NAME=SECTION008133200000000000000> void SetCopies(int s)</A></H3>
<P>
<A NAME=5973>&#160;</A>
<P>
Many printers support printing multiple copies of the same
document. This attributes controls the number of copies printed.
The <tt>
 Setup</tt> dialog will provide control of this <em>if</em> it
is supported.
<P>
<H3><A NAME=SECTION008133300000000000000> char* GetDocName()</A></H3>
<P>
<A NAME=5976>&#160;</A>
<P>
Printer output may be directed to a file rather than the printer.
If it is, this will return the name of the file the output will
be sent to.
<P>
<H3><A NAME=SECTION008133400000000000000> int GetPaper()</A></H3>
<P>
<A NAME=5979>&#160;</A>
<P>
<H3><A NAME=SECTION008133500000000000000> char* GetPaperName()</A></H3>
<P>
<A NAME=5982>&#160;</A>
<P>
Printers can print a variety of papers. The user may be
able to select which paper from the <tt>
 Setup</tt> dialog.
The printers supported are defined in the <tt>
 vprinter.h</tt>
header file (or the base class used by <tt>
 vPrinter</tt>).
<P>
<H3><A NAME=SECTION008133600000000000000> int GetPortrait()</A></H3>
<P>
<A NAME=5985>&#160;</A>
<P>
<H3><A NAME=SECTION008133700000000000000> void SetPortrait(int p)</A></H3>
<P>
<A NAME=5988>&#160;</A>
<P>
Many printers can print in either Portrait or Landscape orientation.
This returns true if the printer will print in portrait.
<P>
<H3><A NAME=SECTION008133800000000000000> int GetToFile()</A></H3>
<P>
<A NAME=5991>&#160;</A>
<P>
<H3><A NAME=SECTION008133900000000000000> void SetToFile(int f)</A></H3>
<P>
Printer output may be directed to a file rather than the printer.
This returns true if the user selected the option to send output
to a file.
<P>
<H3><A NAME=SECTION0081331000000000000000> int GetUseColors()</A></H3>
<P>
<A NAME=5995>&#160;</A>
<P>
<H3><A NAME=SECTION0081331100000000000000> void SetUseColors(int c)</A></H3>
<P>
<A NAME=5998>&#160;</A>
<P>
Printers can be either black and white, or color. This
returns true if the printer supports colors. You can
make a color printer print black and white by setting
this to false.
<P>
<H3><A NAME=SECTION0081331200000000000000> int Setup(char* fn = 0)</A></H3>
<P>
<A NAME=6001>&#160;</A>
<P>
This displays a modal dialog for the user to select desired
printer characteristics. If a filename is supplied, that
name will be used if the user selects print to file.
If <tt>
 Setup</tt> returns false, you should abandon the
print job. After you call <tt>
 Setup</tt>, you can then
call <tt>
 vPrintDC::SetPrinter</tt> to associate the printer
with the <tt>
 vPrintDC</tt>.
<P>
<H2><A NAME=SECTION008134000000000000000> Example</A></H2>
<P>
See <tt>
 vPrintDC</tt> for an example of using <tt>
 vPrinter::Setup</tt>.
<P>

<H1><A NAME=SECTION008140000000000000000> vTextCanvasPane</A></H1>
<P>
<A NAME=6004>&#160;</A>
<P>
A class for drawing text on a canvas.
<P>
<H2><A NAME=SECTION008141000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vtextcnv.h&gt;</tt>
	<DT>Class name:
<DD> vTextCanvasPane
 	<DT>Hierarchy:
<DD> vPane -&gt;
  vCanvasPane -&gt;
  vTextCanvasPane
<P>
 </DL><H2><A NAME=SECTION008142000000000000000> Description</A></H2>
<P>
This class provides a complete scrolling text window. You
can send text line by line to the window, and it will scroll the
text up the screen in response to linefeed characters. You can
also position the cursor, and selectively clear areas of the text
screen or display text at specific locations. This class handles
repainting the screen on <tt>
 Redraw</tt> events. In essence, the
<tt>
 vTextCanvasPane</tt> class provides the functionality of a
typical simple-minded text terminal.
<P>
<H2><A NAME=SECTION008143000000000000000> New Methods</A></H2>
<P>

<H3><A NAME=SECTION008143100000000000000> void ClearRow(const int row, const int col)</A></H3>
<P>
<A NAME=6007>&#160;</A>
<P>
This clears to blanks row <tt>
 row</tt> of the screen from
column <tt>
 col</tt> to the end of the line.
<P>

<H3><A NAME=SECTION008143200000000000000> void ClearToEnd(const int row, const int col)</A></H3>
<P>
<A NAME=6010>&#160;</A>
<P>
This clears to blanks from row <tt>
 row</tt> and column <tt>
 col</tt>
to the end of the screen.
<P>

<H3><A NAME=SECTION008143300000000000000> int GetCols()</A></H3>
<P>
<A NAME=6013>&#160;</A>
<P>
Returns number of columns in current text canvas.
<P>

<H3><A NAME=SECTION008143400000000000000> int GetRows()</A></H3>
<P>
<A NAME=6016>&#160;</A>
<P>
Returns number of rows in current text canvas.
<P>

<H3><A NAME=SECTION008143500000000000000> void GetRC(int&amp; row, int&amp; col)</A></H3>
<P>
<A NAME=6019>&#160;</A>
<P>
Returns in <tt>
 row</tt> and <tt>
 col</tt> the current row and
column of the text cursor.
<P>

<H3><A NAME=SECTION008143600000000000000> void GotoRC(const int row ,const int row)</A></H3>
<P>
<A NAME=6022>&#160;</A>
<P>
Moves the text cursor to <tt>
 row,col</tt>.
<P>

<H3><A NAME=SECTION008143700000000000000> void DrawAttrText(const char* text, const ChrAttr attr)</A></H3>
<P>
<A NAME=6025>&#160;</A>
<P>
Draws <tt>
 text</tt> starting at the current cursor location using
text attribute <tt>
 attr</tt>. For more details, see <tt>
 vDC::DrawAttrText</tt>.
<P>

<H3><A NAME=SECTION008143800000000000000> void DrawChar(const char chr, const ChrAttr attr)</A></H3>
<P>
<A NAME=6028>&#160;</A>
<P>
Draws a single character <tt>
 chr</tt> at the current
cursor location using text attribute <tt>
 attr</tt>. See
<tt>
 DrawAttrText</tt> for more details.
<P>

<H3><A NAME=SECTION008143900000000000000> void DrawText(const char* text)</A></H3>
<P>
<A NAME=6031>&#160;</A>
<P>
Draws <tt>
 text</tt> starting at the current cursor location.
The newline character <tt>
 '<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img14.gif">n'</tt> will
cause the cursor to move to the beginning of the next line,
and the text to scroll if the cursor was on the last line.
<P>

<H3><A NAME=SECTION0081431000000000000000> void HideTextCursor(void)</A></H3>
<P>
<A NAME=6034>&#160;</A>
<P>
This method will hide the text cursor.
<P>

<H3><A NAME=SECTION0081431100000000000000> void ShowTextCursor(void)</A></H3>
<P>
<A NAME=6037>&#160;</A>
<P>
This method will redisplay the text cursor at the current
row and column.
<P>

<H3><A NAME=SECTION0081431200000000000000> void ScrollText(const int count)</A></H3>
<P>
<A NAME=6040>&#160;</A>
<P>
This will scroll the text in the text canvas up or down by
<tt>
 count</tt> lines.  There will be <tt>
 count</tt> blank lines
created at the bottom or top of the screen.
<P>

<H3><A NAME=SECTION0081431300000000000000> void ResizeText(const int rows, const int cols)</A></H3>
<P>
<A NAME=6043>&#160;</A>
<P>
This method handles resize events. You will want to override
this to track the new number of rows and columns.
<P>

<H3><A NAME=SECTION0081431400000000000000> void TextMouseDown(int row, int col, int button)</A></H3>
<P>
<A NAME=6046>&#160;</A>
<P>
This is called when the user clicks the mouse button down.
It is called with the text row and column, and the button number.
<P>

<H3><A NAME=SECTION0081431500000000000000> void TextMouseUp(int row, int col, int button)</A></H3>
<P>
<A NAME=6049>&#160;</A>
<P>
This is called when the user releases the mouse button.
It is called with the text row and column, and the button number.
<P>

<H3><A NAME=SECTION0081431600000000000000> void TextMouseMove(int row, int col, int button)</A></H3>
<P>
<A NAME=6052>&#160;</A>
<P>
This is called when the mouse moves.
It is called with the text row and column, and the button number.
<P>
<H2><A NAME=SECTION008144000000000000000> Derived Methods</A></H2>
<P>

<H3><A NAME=SECTION008144100000000000000> virtual void Clear()</A></H3>
<P>
<A NAME=6055>&#160;</A>
<P>
This clears the text canvas and resets the row and column
to 0,0.
<P>

<H3><A NAME=SECTION008144200000000000000> void FontChanged(int)</A></H3>
<P>
<A NAME=6058>&#160;</A>
<P>
This is called when the font of the canvas changes.
<tt>
 FontChanged</tt> calls <tt>
 ResizeText</tt>, so you probably
won't have to deal with this event.
<P>

<H3><A NAME=SECTION008144300000000000000> void Redraw(int x, int y, int width, int height)</A></H3>
<P>
<A NAME=6061>&#160;</A>
<P>
Called when the screen needs to be redrawn. Normally, you won't
have to override this class since the <tt>
 vTextCanvasPane</tt>
superclass will handle redrawing what is in the window. Instead,
you will usually just have to respond to the <tt>
 FontChanged</tt>
and <tt>
 ResizeText</tt> events when the contents of the canvas will
actually change.
<P>
<H2><A NAME=SECTION008145000000000000000> Inherited Methods</A></H2>
	
<P>
<H3><A NAME=SECTION008145100000000000000> virtual void HPage(int Shown, int Top)</A></H3>
<P>
<A NAME=6064>&#160;</A>
<P>
<H3><A NAME=SECTION008145200000000000000> virtual void HScroll(int step)</A></H3>
<P>
<A NAME=6067>&#160;</A>
<P>
<H3><A NAME=SECTION008145300000000000000> virtual void SetFont(int vf)</A></H3>
<P>
<A NAME=6070>&#160;</A>
<P>
<H3><A NAME=SECTION008145400000000000000> virtual void SetHScroll(int Shown, int Top)</A></H3>
<P>
<A NAME=6073>&#160;</A>
<P>
<H3><A NAME=SECTION008145500000000000000> virtual void SetVScroll(int Shown, int Top)</A></H3>
<P>
<A NAME=6076>&#160;</A>
<P>
<H3><A NAME=SECTION008145600000000000000> virtual void VPage(int Shown, int Top)</A></H3>
<P>
<A NAME=6079>&#160;</A>
<P>
<H3><A NAME=SECTION008145700000000000000> virtual void VScroll(int step)</A></H3>
<P>
<A NAME=6082>&#160;</A>
<P>
<H2><A NAME=SECTION008146000000000000000> See Also</A></H2>
<P>
vCanvasPane, vWindow
<P>

<P>
<BR> <HR><A NAME=tex2html1433 HREF="node9.html"><IMG ALIGN=BOTTOM ALT="next" SRC="../icons/next.gif"></A>   <A NAME=tex2html1431 HREF="vwebref.html"><IMG ALIGN=BOTTOM ALT="up" SRC="../icons/up.gif"></A>   <A NAME=tex2html1425 HREF="node7.html"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/prev.gif"></A>   <A NAME=tex2html1435 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="../icons/contents.gif"></A>      <BR>
<B> Next:</B> <A NAME=tex2html1434 HREF="node9.html"> Standard V Values</A>
<B>Up:</B> <A NAME=tex2html1432 HREF="vwebref.html">V Reference Manual</A>
<B> Previous:</B> <A NAME=tex2html1426 HREF="node7.html"> Dialogs</A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Bruce Wampler <BR>
Thu Nov 14 09:25:45 MST 1996</I>
</ADDRESS>
</BODY>
