www.pudn.com > 95659637.rar > Breference.htm, change:1999-02-12,size:43823b


<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> 
<html> 
<head> 
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
   <meta name="Generator" content="Microsoft Word 97"> 
   <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win95; I) [Netscape]"> 
   <title>Printer library documentation</title> 
</head> 
<body link="#0000FF" vlink="#800080"> 
  
<center> 
<h1> 
<b><font color="#000099">CPage Class Reference</font></b></h1></center> 
 
<hr WIDTH="100%"> 
<br>In order to use the printing functions in your project you need to 
include the files: 
<br><b><font color="#000099">CPage.cpp</font></b> 
<br><b><font color="#000099">CPage.h</font></b> 
<br><b><font color="#000099">CPrinter.cpp</font></b> 
<br><b><font color="#000099">CPrinter.h</font></b> 
<br><b><font color="#000099">Dib.cpp</font></b> 
<br><b><font color="#000099">Dib.h</font></b> 
<br>In any file where reference to the printing functions is needed include 
the header file: 
<br><b><font color="#000099">CPage.h</font></b> 
<br>Thatís all that is needed to incorporate the printing functions. 
<br>If you find this library useful let me know. 
<p><font size=-1><a href="mailto::kdtexas@onramp.net">kdtexas@onramp.net</a></font> 
<p> 
<hr WIDTH="100%"> 
<center> 
<h1> 
<a NAME="toc"></a>Table of Contents</h1></center> 
 
<menu> 
<li> 
<a href="#CPrinter">CPrinter Class</a></li> 
 
<li> 
<a href="#prttype">Prttype Structure Definition</a></li> 
 
<li> 
<a href="#cpage">CPage Class Definition</a></li> 
</menu> 
 
<center> 
<h1> 
Functions</h1></center> 
 
<center><font color="#000099"><font size=-1>Not all functions are located 
here. Consult the demo program or CPage.h for a complete list</font></font></center> 
 
<p>         <a href="#SetUserFunction">SetUserFunction</a> 
<br>         <a href="#SetPrinterMode">SetPrinterMode</a> 
<br>         <a href="#GetPrinterName">GetPrinterName</a> 
<br>        <a href="#CpageConstruct"> 
CPage Constructor</a> 
<br>         <a href="#Print">Print</a> 
<br>         <a href="#PrintColumn">PrintColumn</a> 
<br>         <a href="#SetLineSpacing">SetLineSpacing</a> 
<br>         <a href="#SetFont">SetFont</a> 
<br>         <a href="#SetFontSize">SetFontSize</a> 
<br>         <a href="#SetColor">SetColor</a> 
<br>         <a href="#SetRightmargin">SetRightMargin</a> 
<br>         <a href="#SetBottomMargin">SetBottomMargin</a> 
<br>         <a href="#GetDisplayContext">GetDisplayContext</a> 
<br>         <a href="#PrintBitMap">PrintBitmap</a> 
<br>         <a href="#GetNextLogCol">GetNextLogicalColumn</a> 
<br>         <a href="#Line">Line</a> 
<br>         <a href="#Line">Box</a> 
<br>        <a href="#CheckBox"> 
CheckBox</a> 
<br>         <a href="#Tables">Tables</a> 
<br>         <a href="#RotateText">Rotated 
Text</a> 
<br>  
<p>                    
 
<font size=-1><a href="#Printtable">Print(TABLEHEADER* )</a></font> 
<br>         <a href="#Regions">Regions</a> 
<br>                      
<a href="#CreateRegion">Create</a> 
<br>                     
 
<a href="#Regions">SubRegions</a> 
<p> 
<hr WIDTH="100%"> 
<center> 
<h1> 
<a NAME="CPrinter"></a><b><font size=-1>Printer Class Documentation</font></b></h1></center> 
<font size=-1>Class definitions located in CPrinter.h</font> 
<p><font size=-1>Functions in CPrinter.cpp: This is a low-level printer 
function class. All calls from the higher-level functions will eventually 
get here to one of the printer primitives. To add functionality to the 
high level class(s) it is best to let the high level classes handle all 
formatting etc and call simple primitive output functions. This will make 
porting to a different output device or operating system a little easier. 
Below is the class definition of the low-level class CPrinter.</font> 
<p><tt>class CPrinter{</tt> 
<br><tt>public:</tt> 
<br><tt>    CPrinter();</tt> 
<br><tt>    virtual ~CPrinter();</tt> 
<br><tt>    virtual int GetPrintInfo(PRTTYPE *ps,double 
LineSpacing);</tt> 
<br><tt>    virtual int PrintText(PRTTYPE *ps,double LineSpacing);</tt> 
<br><tt>    virtual void DrawLine(PRTTYPE *ps,int LineSize);</tt> 
<br><tt>    virtual void DrawRect(PRTTYPE *ps,int LineSize);</tt> 
<br><tt>};</tt> 
<p><font size=-1>int GetPrintInfo: This function will set internal variables 
without actually printing the output string. It is mainly used internally.</font> 
<p><font size=-1>int PrintText: The workhorse. Just about every call gets 
routed here eventually. This function creates a font each time it is called 
and calculates print parameters and changes internal variables. If the 
class is to slow this is where it can be sped up considerably. The return 
value is the next logical print line. It is calculated using the current 
map mode, font size, and spacing factor.</font> 
<p><font size=-1>void DrawLine: Line drawing primitive. Very basic.</font> 
<p><font size=-1>void DrawRect: Rectangle drawing function. Very basic.</font> 
<p><font size=-1>The class user should call none of these functions. Use 
the higher level calls. However, if minimal print functionality is all 
that is needed this can be a standalone library and does have quite a bit 
of functionality</font> 
<center> 
<p><a href="#toc">Back</a> 
<p> 
<hr WIDTH="100%"> 
<p><a NAME="prttype"></a><b><u><font size=-1>PRTTYPE structure definition</font></u></b></center> 
 
<p><font size=-1>The PRTTYPE structure is used to hold information about 
the current print page and the current output string. It also retains information 
across printer calls that can be used in determining future output selections. 
It is defined below:</font> 
<p><tt>typedef struct tagPrinter{</tt> 
<br><tt>    CDC *pDC;</tt> 
<br><tt>    RECT rc;</tt> 
<br><tt>    int PointSize;</tt> 
<br><tt>    CString Text;</tt> 
<br><tt>    UINT uTextFlags;</tt> 
<br><tt>    UINT uFillFlags;</tt> 
<br><tt>    UINT uPenFlags;</tt> 
<br><tt>    CString FontName;</tt> 
<br><tt>    UINT n_maxWidth; // max width of formatting 
rect</tt> 
<br><tt>    UINT n_maxLength; // ditto len</tt> 
<br><tt>    UINT n_minNextLine; // next posiible legible 
line</tt> 
<br><tt>    int m_NextCharPos; // pos in line of next char</tt> 
<br><tt>    int m_MinDisplacement;</tt> 
<br><tt>    RECT LastPrintArea; // printing rect last used</tt> 
<br><tt>    TEXTMETRIC* tm;</tt> 
<br><tt>}PRTTYPE;</tt> 
<p><font size=-1>This structure is a member of the Cpage class and is maintained 
internally. It is initialized in the Cpage constructor using information 
passed. The TEXTMETRIC field ,LastPrintArea, and m_NextCharPos are calculated 
and changed by each call to PrintText(). The print behavior is modified 
by changing the uTextFlags and uPenFlags variable ( see definitions in 
CPrinter.h ) .The current output string is contained in the variable Text 
( isnít that remarkable ). The parameters are set using information passed 
to the various output routines.</font> 
<center><a href="#toc">Back</a> 
<p> 
<hr WIDTH="100%"><a NAME="cpage"></a><b><u><font size=-1>CPage Class Definitions</font></u></b></center> 
 
<p><font size=-1>CPage contains most of the class functionality. CPage.H 
and CPage.Cpp contain the class headers and class definition.</font> 
<p><font size=-1>All of the print routines have a new override added that 
takes a user supplied integer indentifier and passes it to a user suppled 
function that will return the text to be printed. This function must be 
in the form of: <b>LPCSTR (*PF_REMOTE)(int)</b> which is defined in CPage.h. 
This function is set by a call to CPage::SetUserFunction(UserFunctionAddress). 
If this function is not called all the output routines called form the 
functions calling the user defined function will do no output and those 
that return a value will return 0. All of the Print and PrintColumn functions, 
including those that print to regions, have this over ride. The demo program 
has been updated to show these functions in a working example. These functions 
are included to make it easier to design a data independant form and to 
facilitate using the library as a portion of a report generator, form generator, 
etc. See <b>PrintForm5(CPage* ps)</b> located in PrintForm1.cpp. A sample 
user defined function is shown below:</font> 
<p><tt>LPCSTR MyFunction(int ID)</tt> 
<br><tt>{</tt> 
<br><tt>    static CString S;</tt> 
<br><tt>    switch(ID)</tt> 
<br><tt>    {</tt> 
<br><tt>        case ID_1:</tt> 
<br><tt>            
return "Called From User Function ID 1";</tt> 
<br><tt>        case ID_2:</tt> 
<br><tt>            
return "Called From User Function ID 2";</tt> 
<br><tt>        case ID_3:</tt> 
<br><tt>            
return "Called From User Function ID 3";</tt> 
<br><tt>        case ID_4:</tt> 
<br><tt>            
return "Called From User Function ID 4";</tt> 
<br><tt>        case ID_5:</tt> 
<br><tt>            
return "Called From User Function ID 5";</tt> 
<br><tt>        case ID_6:</tt> 
<br><tt>            
S.Format("%.2f",120.90);</tt> 
<br><tt>            
return S;</tt> 
<br><tt>}</tt> 
<p><tt>    return "*****unknown ID Passed*****";</tt> 
<p><b><tt>}</tt></b> 
<p><font size=-1>This is a very simple version of a user function but demonstrates 
how it is used. In real life it would be more complex and probably call 
other functions, do calculations, and other data manipulation tasks. Just 
as long as it returns a pointer to a output string all is well. The string 
is used immediatly and need not be persistant. Static buffers can be re-used 
between calls. However if CStrings or other variables are used as buffers 
be certain that they are either static or created on the heap and not destroyed 
until after use. Variables set on the stack frame will not be accessable 
to the output routines because they will go out of scope on he user function 
return. In order to set the call up you will call:</font> 
<center><a href="#toc">Back</a></center> 
 
<hr SIZE=3 WIDTH="100%"> 
<p><a NAME="SetUserFunction"></a><b><font size=-1>CPage::SetUserFunction(MyFunction);</font></b> 
<p><font size=-1>This can be called more than once thereby replacing the 
active function making it possible to have several output functions for 
the same page. The effect of this technique is a lot like subclassing the 
CPage object but without the overhead. The user defined function should 
be prototyped as  <b>typedef LPCSTR (*PF_REMOTE)(int).</b> An example 
is :</font> 
<p><tt>LPCSTR MyFunction(int ID)</tt> 
<br><tt>{</tt> 
<br><tt>     switch(ID)</tt> 
<br><tt>     {</tt> 
<br><tt>         case ID_1:</tt> 
<br><tt>              
S="Called From User Function ID 1";</tt> 
<br><tt>               
return S;</tt> 
<br><tt>         case ID_2:</tt> 
<br><tt>              
return "Called From User Function ID 2";</tt> 
<br><tt>    }</tt> 
<br><tt>    return "";</tt> 
<br><tt>}</tt> 
<p><font size=-1>There is a special over ride of the Print function:</font> 
<p><b><font size=-1>virtual double Print(double row,double col,UINT TextFlags,int 
PointSize,int ID);</font></b> 
<p><font size=-1>This function works in conjunction with the SeUserFunction 
in that the user defined function is called to supply the prit text. See 
the demo program for details.</font> 
<p><font size=-1>Example:</font> 
<p><tt>void PrintStuff(CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>     ps->SetUserFunction(MyFunction);</tt> 
<br><tt>     double row=ps->Print(0.0,0.0,TEXT_NORMAL|TEXT_CENTER,24,"User 
Demo");</tt> 
<br><tt>     row=ps->Print(row,0.0,TEXT_BOLD|TEXT_ITALIC|TEXT_CENTER,24,ID_1);</tt> 
<br><tt>}</tt> 
<p><a NAME="SetPrinterMode"></a><b><font size=-1>static void SetPrinterMode(CDC* 
pDC,int Mode=DMORIENT_PORTRAIT);</font></b> 
<p>This function will change the printer orientation of the printer. <b><font color="#000099">IT 
CANNOT BE CALLED AFTER THE CONSTRUCTOR</font></b> for Cpage is called and 
as such is a static member function. It must be called by a function in 
the function chain somewhere before the OnPrint() or OnDraw() function 
is called and after access to the CDC for the print job is available. The 
recommended place to call the static member function is your CView::OnPrepareDC() 
override. The CDC passed to this function will be changed by this function 
call. The mode parameter must be either DMORIENT_PORTRAIT ( default ) or 
DMORIENT_LANDSCAPE. 
<p><b>Example</b> 
<p><tt>void CMainView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)</tt> 
<br><tt>{</tt> 
<br><tt>    CView::OnPrepareDC(pDC, pInfo); // always call 
base class first</tt> 
<br><tt>    switch(pInfo->m_nCurPage) // switch modes based 
on page number</tt> 
<br><tt>    {</tt> 
<br><tt>        case 1:CPage::SetPrinterMode(pDC);break;</tt> 
<br><tt>        case 2:CPage::SetPrinterMode(pDC,DMORIENT_LANDSCAPE);break;</tt> 
<br><tt>    }</tt> 
<br><tt>}</tt> 
<center> 
<p><b><font color="#000099"><font size=-2>DO NOT CALL THIS FUNCTION ONCE 
THE CONSTRUCTOR FOR CPAGE HAS EXECUTED.</font></font></b></center> 
 
<p><font color="#000099"><font size=-1>For users not familiar with static 
member functions. The above code creates a CPage object on the stack and 
executes the member function. The function does not depend on or alter 
any data in the class so it needs no virtual table entry or a this pointer. 
( as a matter of fact in CANNOT read or write and class data at all) There 
will be one and only one copy of the function created no matter how many 
CPage objects that there are. This is a poor explanation of static member 
functions; please consult the MS documentation for details. HA!</font></font> 
<center><a href="#toc">Back</a></center> 
 
<p> 
<hr WIDTH="100%"> 
<br><a NAME="GetPrinterName"></a><b><font size=-1>static LPCSTR GetPrinterName(CDC* 
pDC);</font></b> 
<p><font size=-1>This function will return the name of the selected printer 
driver in use for this CDC. The driver cannot be changed but can be used 
to switch between options. This function and the above function also demonstrates 
the method of get data from and changing data in a DEVMODE structure. This 
method can be used to change paper size DPI etc for all supported printers,</font> 
<center> 
<p><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><a NAME="CpageConstruct"></a><b><font size=-1>CPage(RECT rectDraw, 
CDC* p_Dc, int MapMode=MM_ANISOTROPIC)</font></b> 
<p><font size=-1>This is the class constructor. There is no private constructor 
override. This class is designed to be used in conjunction with MFC and 
makes use of the Cview class printing architecture. The parameters are:</font> 
<p><font size=-1>RECT rectDraw The drawing rectangle to be used by this 
output device. ( see example )</font> 
<br><font size=-1>CDC* The display context object passed by MFC to the 
print function</font> 
<br><font size=-1>Int mapMode The supported mapping modes are MM_TEXT and 
MM_ANISOTROPIC</font> 
<p><font size=-1>Example of use:</font> 
<p><tt>void CMainView::OnPrint(CDC* pDC, CPrintInfo* pInfo)</tt> 
<br><tt>{</tt> 
<br><tt>    double Row,Col;</tt> 
<br><tt>    CPage* ps= new CPage(pInfo->m_rectDraw,pDC,MM_TEXT);</tt> 
<br><tt>    Row=ps->Print(6.5,4.0,TEXT_NORMAL,10,"This is 
a test");</tt> 
<br><tt>    delete ps;</tt> 
<br><tt>}</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="Print"></a><font size=-1><b>int Print(int row,int col,char* 
fmt,...); // </b>use cpage default parameteres for flags pt size etc..</font> 
<br><b><font size=-1>int Print(int row,int col,UINT TextFlags,int PointSize,char* 
fmt,...);</font></b> 
<p><font size=-1>The workhorse. This function has many different <a href="#note1">overloads</a>*. 
All class functions are designed to use several different units of measurement. 
In MM_TEXT map mode the native unit is pixels, which can vary from output 
device to output device. In MM_ANISOTROPIC the units are user defined in 
both axis. The default for this class is 1000 by 1000. The library can 
also function in terms of inches. The passed parameters are converted to 
native units before being passed to lower level functions. Inches present 
the problem of being fractional in value and not integral. To facilitate 
the ease of use the library makes the following assumptions to all calls 
to the Print functions (With one exception noted below). <font color="#000099">If 
the value is a double it is treated as a inch measurement. If one of the 
location variables (Row and Col) is a double the other must be a double 
also</font>. The parameters are:</font> 
<p><font size=-1>Int row the vertical displacement for the print line. 
Displacement is relative to the top of the page.</font> 
<br><font size=-1>Int col the horizontal displacement for the print line. 
Displacement is relative to the left side</font> 
<br><font size=-1>( both of these parameters can be doubles and if so are 
treated as inches )</font> 
<br><font size=-1>UINT Textflags Modify the appearance of the output string. 
See CPrinter.h</font> 
<br><font size=-1>Int PointSize The number of points to use for the font.</font> 
<br><font size=-1>Char* fmt a printf type format string.</font> 
<br><font size=-1>Example of use:</font> 
<p><tt>Void PrintStuff (CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>    Row=ps->Print(6.5,4.0,TEXT_NORMAL,10,"This is 
a test");</tt> 
<br><tt>    Row=ps->Print(Row,4.0,TEXT_NORMAL,10,"This is 
a test Also");</tt> 
<br><tt>    Row=ps->Print(Row,4.0,TEXT_NORMAL,10,"This is 
a test Also as is this");</tt> 
<br><tt>    Col=1.0;</tt> 
<br><tt>    ps->Print(Row,&Col,TEXT_NORMAL,10,"This 
is a test Also as is this");</tt> 
<br><tt>    ps->Print(Row,&Col,TEXT_BOLD|TEXT_ITALIC,10,"This 
");</tt> 
<br><tt>    ps->Print(Row,&Col,TEXT_BOLD,10,"is Italic 
");</tt> 
<br><tt>}</tt> 
<p><a NAME="note1"></a><font color="#000099"><font size=-1>*note</font></font> 
<br><font color="#000099">Consult CPage.h for details on all the various 
overloads. There are many.</font> 
<p><font color="#000099"><font size=-1>int Print(int row,int *col,UINT 
TextFlags,int PointSize,char* fmt,...) is a special override that takes 
a pointer to the column variable. (See example above). On execution the 
column variable is updated to the next column position. Subsequent calls 
to Print using the variable will result in the output being a continuos 
line allowing different attributes to be assigned within a line of text. 
It is useful when printing a series of question/answer type forms also 
as the variable will point to the next logical horizontal print area at 
all times. There are also two overrides of this function that take only 
Row,Column, Text parameters and get the rest of the information from the 
defaults set into the CPage object.</font></font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="PrintColumn"></a><b><font size=-1>void PrintColumn(int Top,int 
Left,int Bottom,int Right,UINT flags,int PointSize,LPCSTR Text);</font></b> 
<p><font size=-1>Print function to allow for newspaper style print columns. 
The location variables function in the same manner as in Print() above 
but have two extra dimensions to describe a bounding rectangle. All text 
will be printed in the rectangle. If the flags variable includes TEXT_RECT 
the bounding rectangle will be drawn on the output device. See Print() 
for variable usage.</font> 
<p><font size=-1>``</font> 
<p><font size=-1>Example of use:</font> 
<p><tt>Void PrintStuff (CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>    ps->PrintColumn(1.0,1.0,3.0,4.0,TEXT_BOLD|TEXT_RECT,8,</tt> 
<br><tt>    "This is a test of the column wrap feature");</tt> 
<br><tt>    ps->PrintColumn(1.00,4.1,3.0,7.0,TEXT_BOLD,8,</tt> 
<br><tt>    "This is a test of the column wrap feature ");</tt> 
<br><tt>}</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="SetLineSpacing"></a><b><font size=-1>double SetLineSpacing(double 
Spacing);</font></b> 
<p><font size=-1>Set the constant used in calculating the next logical 
print line.. The amount needed to get the affect you want will vary so 
experiment. Should be no smaller than 1.0</font> 
<center> 
<p><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="SetFont"></a><b><font size=-1>LPCSTR SetFont(LPCSTR FontName);</font></b> 
<p><font size=-1>Set the default font name. The constructor sets it to 
"Times New Roman". Spelling does count. The old font name is returned from 
this function. If all you want is the font name use SetFont(NULL) to return 
the current font name.</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><a NAME="SetFontSize"></a><b><font size=-1>int SetFontSize(int sz);</font></b> 
<br><font size=-1>Set default font pointsize.</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><a NAME="SetColor"></a><b><font size=-1>COLORREF SetColor(COLORREF 
Color);</font></b> 
<br><font size=-1>If the output device supports color set the current color 
here. Returns the old color.</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><a NAME="SetRightmargin"></a><b><font size=-1>virtual int SetRightMargin(int 
width)</font></b> 
<br><font size=-1>Change the size of the default printing rectangle right 
margin. A value of -1 will reset it to MaxWidth. A value of 0 will just 
return the current value.Returns the previous width.</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><a NAME="SetBottomMargin"></a><b><font size=-1>int SetBottomMargin(int 
length);</font></b> 
<br><font size=-1>Same as above except the margin affected is the bottom</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><b><font size=-1>double SetRightMargin(double width);</font></b> 
<br><font size=-1>See above</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><b><font size=-1>double SetBottomMargin(double length);</font></b> 
<br><font size=-1>See Above</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br><a NAME="GetDisplayContext"></a><b><font size=-1>CDC* GetDisplayContext();</font></b> 
<br><font size=-1>Return the display context used for this page. Can be 
used for direct manipulation of the context</font> 
<p><font size=-1>Example of use:</font> 
<p><tt>Void PrintStuff (CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>    CDC* pDc</tt> 
<br><tt>    pDc=ps->GetDisplayContext();</tt> 
<br><tt>}</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="PrintBitMap"></a><b><font size=-1>void PrintBitMap(int top,int 
left,int bottom,int right,LPCSTR name);</font></b> 
<br><b><font size=-1>void PrintBitMap(double top,double left,double bottom,double 
right,LPCSTR name);</font></b> 
<p><font size=-1>Prints a bitmap from a disk file into a region of the 
page. The numeric parameteres are location vectors for the bounding rectangle 
and the LPCSTR param is the name of the file to print. Disk based bitmaps 
are directly supported as there are many ways to print a resource bitmap.</font> 
<p><font size=-1>Example of use:</font> 
<p><tt>Void PrintStuff (CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>    ps->PrintBitMap(1.0,1.0,4.0,5.0,"MyBitMap.bmp");</tt> 
<br><tt>}</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="GetNextLogCol"></a><b><font size=-1>double GetNextLogicalColumn(BOOL 
Convert=TRUE,BOOL AddOffset=FALSE);</font></b> 
<p><font size=-1>Returns the next logical print column based on the last 
call to Print(). This must not be used prior to a call to Print() as garbage 
will be returned. Parameters are:</font> 
<p><font size=-1>BOOL Convert if true will return result in inches</font> 
<br><font size=-1>BOOL AddOffset if true will add extra space to column 
to give separation.</font> 
<br><font size=-1>Example of use:</font> 
<p><tt>Void PrintStuff (CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>    double Col;</tt> 
<br><tt>    ps->Print(6.5,4.0,TEXT_NORMAL,10,"This is a 
test");</tt> 
<br><tt>    Col=ps->GetNextLogicalColumn(TRUE);</tt> 
<br><tt>    ps->Print(6.5,Col,TEXT_NORMAL|TEXT_ITALIC,10,"This 
is a test Also");</tt> 
<br><tt>}</tt> 
<br><tt>Output will be "This is a test.<i>This is a test also</i>" starting 
4 inches over and 6.5 inches down. The common usage is to apply special 
formatting to indivivual words in a sentence.</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="Line"></a><b><font size=-1>void Line(int top,int left,int bottom,int 
right,int LineSize=1,UINT flag=PEN_SOLID);</font></b> 
<br><b><font size=-1>void Box(int top,int left,int bottom,int right,int 
LineSize=1,UINT Fillflags=FILL_NONE,UINT PenFlags=PEN_SOLID);</font></b> 
<p><font size=-1>Drawing primitives exposed to user. Parameters can also 
be doubles. If so they represent inches.Parameters are:</font> 
<br><font size=-1>Int top,left,bottom,right: top/left define the position 
of the left starting point</font> 
<br><font size=-1>Bottom/right the right.</font> 
<p><font size=-1>In the case of a rectangle the points describe the bounding 
area to draw the rectangle around</font> 
<br><font size=-1>Int Linesize Determines thickness of the line used to 
draw the shape 1 is smallest</font> 
<br><font size=-1>Int Fillflags determines if area is filled with color 
see CPrinter.h for definitions</font> 
<br><font size=-1>Int Penflags Pen type used to draw See CPrinter.h for 
definitions</font> 
<p><font size=-1>Example of use:</font> 
<p><tt>Void PrintStuff (CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>    ps->Line(5.0,0.0,5.0,8.0);</tt> 
<br><tt>    ps->Line(0.0,4.0,10.0,4.0);</tt> 
<br><tt>    ps->Box(4.0,3.0,6.0,5.0);</tt> 
<br><tt>}</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="CheckBox"></a><b><font size=-1>void CheckBox(LPSTR Caption,BOOL 
Data,int top,int left,int FontSize,int Direction=LABEL_RIGHT,int LineSize=2,UINT 
Fillflags=FILL_NONE,UINT TextFlags=TEXT_NORMAL|TEXT_NOCLIP|TEXT_SINGLELINE);</font></b> 
<p><font size=-1>Draws a Checkbox on the output device. Parameters are 
:</font> 
<br><font size=-1>LPSTR Caption The text accompanying the checkbox</font> 
<br><font size=-1>BOOL Data The true/false expression to be shown</font> 
<br><font size=-1>Int top,left The starting position to print the Checkbox. 
Can be doubles.If so units are inches.</font> 
<br><font size=-1>Int Direction either LABLE_RIGHT or LABEL_LEFT</font> 
<br><font size=-1>Int Linesize Thickness of pen used to draw the boxUINT 
Fillflags If set to any value other than FILL_NONE the checkbox will use 
the fill color to fill the box rather than Xing the box</font> 
<br><font size=-1>UINT TextFlags Define text attributes (See CPrinter.h)</font> 
<p><font size=-1>Example of use:</font> 
<p><b><tt><font size=-1>Void PrintStuff (CPage* ps)</font></tt></b> 
<br><b><tt><font size=-1>{</font></tt></b> 
<br><b><tt><font size=-1>    ps->CheckBox("A Test",TRUE,1000,1000,12,LABEL_LEFT,2,FILL_BLACK,TEXT_BOLD);</font></tt></b> 
<br><b><tt><font size=-1>    ps->CheckBox("A Test again",TRUE,1100,1000,6,LABEL_RIGHT,2,FILL_NONE,TEXT_BOLD);</font></tt></b> 
<br><b><tt><font size=-1>    ps->CheckBox("A Test",TRUE,8.0,1.0,12,LABEL_LEFT,2,FILL_BLACK,TEXT_BOLD);</font></tt></b> 
<br><b><tt><font size=-1>    ps->CheckBox("A Test again",TRUE,9.0,1.0,6,LABEL_RIGHT,2,FILL_NONE,TEXT_BOLD);</font></tt></b> 
<br><b><tt><font size=-1>}</font></tt></b> 
<center><a href="#toc">Back</a> 
<br> 
<hr WIDTH="100%"> 
<br><a NAME="Tables"></a><b><u><font size=-1>Tables</font></u></b></center> 
 
<p><font size=-1>Tables are a method of showing tabular data. They are 
similar to a grid control, only printed. Many business forms are simply 
a series of tables. The table metaphor has been implemented by use of three 
helper classes:</font> 
<p><b><font size=-1>class CPrintTable;</font></b> 
<br><b><font size=-1>class COLUMNDATA;</font></b> 
<br><b><font size=-1>class TABLEHEADER;</font></b> 
<br><font size=-1>TABLEHEADER is a very simple class that describes a table 
of data. It is described below.</font> 
<p><tt><font size=-1>class TABLEHEADER{</font></tt> 
<br><tt><font size=-1>public:</font></tt> 
<br><tt><font size=-1>    ~TABLEHEADER();</font></tt> 
<br><tt><font size=-1>    TABLEHEADER();</font></tt> 
<br><tt><font size=-1>    BOOL UseInches; // if set to true 
all points passed are considered to be in inches</font></tt> 
<br><tt><font size=-1>    BOOL AutoSize; // if set true 
will make all columns the same size</font></tt> 
<br><tt><font size=-1>    UINT FillFlag; // see fillflags 
in CPrinter.h default FILL_NONE</font></tt> 
<br><tt><font size=-1>    Int PointSize; // Pointsize for 
header</font></tt> 
<br><tt><font size=-1>    Int LineSize; // line size</font></tt> 
<br><tt><font size=-1>    Int NumColumns; // number of columns 
in the table</font></tt> 
<br><tt><font size=-1>    Int NumRows; // number of rows 
in the table</font></tt> 
<br><tt><font size=-1>    BOOL Border; // if true draw aborder 
around table default TRUE</font></tt> 
<br><tt><font size=-1>    BOOL Vlines ; // if true separate 
items with vertical lines default TRUE</font></tt> 
<br><tt><font size=-1>    BOOL HLines; // if true separate 
items with horizontal lines default TRUE;</font></tt> 
<br><tt><font size=-1>    BOOL HeaderOnly; // if true display 
header only (virtual table)</font></tt> 
<br><tt><font size=-1>    BOOL NoHeader; // if true only 
draw the boxes no headers</font></tt> 
<br><tt><font size=-1>    Int HeaderLines; // number of 
lines in header default 1</font></tt> 
<br><tt><font size=-1>    int NumPrintLines;    
// logical number of visable print lines per cell default 1</font></tt> 
<br><tt><font size=-1>    Double StartRow; // starting row 
position ( seeUseInches above )</font></tt> 
<br><tt><font size=-1>    Double StartCol; // stating column 
position ( see UseInches above)</font></tt> 
<br><tt><font size=-1>    Double EndCol; // ending column 
position ( see UseInches)</font></tt> 
<br><tt><font size=-1>    Double EndRow; // This is determined 
by the class and is available to the end user</font></tt> 
<br><tt><font size=-1>    COLUMNDATA ColDesc[20]; // see 
COLUMNDATA class description</font></tt> 
<p><tt><font size=-1>    CprintTable* pClsTable; // ptr 
to object ownibg this header</font></tt> 
<p><tt><font size=-1>};</font></tt> 
<p><font size=-1>Example of use:</font> 
<p><tt>TABLEHEADER* pTable=new TABLEHEADER;</tt> 
<br><tt>pTable->PointSize=10;</tt> 
<br><tt>pTable->UseInches=TRUE;</tt> 
<br><tt>pTable->AutoSize=FALSE;</tt> 
<br><tt>pTable->Border=TRUE;</tt> 
<br><tt>pTable->FillFlag=FILL_NONE;</tt> 
<br><tt>pTable->NumColumns=3;</tt> 
<br><tt>pTable->NumRows=6;</tt> 
<br><tt>pTable->StartRow=3.5;</tt> 
<br><tt>pTable->StartCol=.1;</tt> 
<br><tt>pTable->EndCol=8.0;</tt> 
<br><tt>pTable->ColDesc[0].Init(4.0,"Coverages");</tt> 
<br><tt>pTable->ColDesc[1].Init(3.0,"Limits of Liability");</tt> 
<br><tt>pTable->ColDesc[2].Init(1.0,"Premium");</tt> 
<br><tt>ps->Table(pTable);</tt> 
<br><tt>ps->Print(pTable,0,0,8,TEXT_LEFT,"Section I - Coverage A: Dwelling");</tt> 
<br><tt>ps->Print(pTable,1,0,8,TEXT_LEFT,"Section I - Coverage A: Other 
Structures");</tt> 
<br><tt>delete pTable;</tt> 
<p><font size=-1>Class COLUMNDATA is also a very simple class. Its total 
functionality is demonstrated above. It is a member of class TABLEHEADER 
and is created when it is and destroyed with it. Just use it to describe 
the columns width and caption. The width unit of measurement is determined 
by the TABLEHEADER UseInches variable.</font> 
<p><tt>class COLUMNDATA</tt> 
<br><tt>{</tt> 
<br><tt>    public:</tt> 
<br><tt>    double Width;</tt> 
<br><tt>    CString Text;</tt> 
<br><tt>    COLUMNDATA() {Width=0;Text.Empty();};</tt> 
<br><tt>    Void Init(double nWidth,LPCSTR lpzText) {Width=nWidth;Text=lpzText;};</tt> 
<br><tt>};</tt> 
<p><font size=-1>Class CPrintTable is used internally and should not be 
exposed. It actually draws and fills the table with data. It is called 
and used by CPage . See the source code for details.</font> 
<p><font size=-1>Tables are attached to the page by using the function 
CPage::Table(pValidTableHeader). Once the TABLEHEADER has been created 
and filled in pass it to the CPage class using this function. The Table 
is drawn on the output device at this point. The variable LastRow is filled 
in at this time and is available for use.If you are stacking tables this 
variable will tell you where to start the next table. See example below.</font> 
<p><font size=-1>There is an overloaded Print() function in CPage that 
allows data to be inserted into the table:</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="Printtable"></a><b><font size=-1>virtual void Print(TABLEHEADER* 
TheTable,int row,int col,int PointSize,UINT TextFlags,char* fmt,...);</font></b> 
<p><font size=-1>In creating a table if the data element NumPrintLines 
is greater than 1 each cell will be made large enough to contain multiple 
print lines. The size will be determined from the font size used to create 
the table. If you use a smaller font in printing there may be more visible 
print lines than you specified. The standard Print(TABLEHEADER,...) overide 
of the Print function will operate in a different manner if the value is 
set to more than 1. See CTable::InsertItem for details. Word wrap and text 
clipping is in affect unless overridden.</font> 
<p><font size=-1>The Row and Col parameters that usually show position 
indicate the table row and column in this overload. Other than that it 
operates just like the CPage::Print() statement</font> 
<p><font size=-1>Example of use:</font> 
<p><font size=-1>ps->Table(pTable);</font> 
<br><font size=-1>double lastRow=pTable->EndRow;</font> 
<br><font size=-1>ps->Print(pTable,0,0,8,TEXT_LEFT,"Section I - Coverage 
A: Dwelling");</font> 
<br><font size=-1>ps->Print(pTable,1,0,8,TEXT_LEFT,"Section I - Coverage 
A: Other Structures");</font> 
<p><font size=-1>Thatís all there is to using tables. They are used a lot 
in business forms and insurance applications.</font> 
<p><b><font color="#000099"><font size=-1>REMEMBER IF YOU CREATE A TABLEHEADER 
USING NEW THAT YOU HAVE TO DELETE IT.THE CLASS WILL NOT AUTOMATICALLY DELETE 
THESE POINTERS.</font></font></b> 
<center> 
<p><a href="#toc">Back</a> 
<br> 
<hr WIDTH="100%"> 
<br><a NAME="Regions"></a><b><u><font size=-1>Regions</font></u></b></center> 
 
<p><font size=-1>Regions are a lot harder to describe than to use. A Region 
is a area of the page that you wish to treat as a single item. It may contain 
Text or checkboxes or columns. It may have a title and a border. If the 
location of the region moves then all of the data contained in the region 
moves with it. Many forms have areas that contain data on specific topics. 
Many times youíll get everything finished and someone will say "Boy it 
would be neat if that section was here and that one here". Regions are 
the cure for that. The class CPrintRegion implements regions. It is really 
a very simple class. Data is put into Regions using, of course, overloaded 
versions of the <i><u>CPage::Print</u></i>() <i><u>CPage::PrintColumn</u></i>() 
and <i><u>CPage::CheckBox</u></i>() functions already described. The functions 
all take one extra parameter. A pointer to a CPrintRegion. You obtain a 
pointer to a CPrintRegion by calling one of these two functions defines 
in CPage:</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="CreateRegion"></a><b><font size=-1>virtual CPrintRegion* CPage::CreateRegion(double 
ptop,double pleft,double pbottom, double pright);</font></b> 
<br><b><font size=-1>virtual CPrintRegion* CPage::CreateRegion(int ptop,int 
pleft,int pbottom, int pright);</font></b> 
<br><b><font size=-2> </font><font size=-1>CPrintRegion* CreateSubRegion(CPrintRegion* 
pParent,int ptop,int pleft,int pbottom, int pright);</font></b> 
<br><b><font size=-1> CPrintRegion* CreateSubRegion(CPrintRegion* 
pParent,double ptop,double pleft,double pbottom, double pright);</font></b> 
<p><font size=-1>As usual if the position is passed as a double we assume 
that all measurements are in inches.</font> 
<br><font size=-1>The only callable functions from CPrintRegion are DrawBorder() 
and DrawTitle(). See the header file in CPage.H for details. Subregions 
are simply regions that are referenced to another region. A Subregion is 
completly contained in the parent region and all offsets are based on the 
parent region at creation. If the parent region is moved the subregion 
moves with it.Usage of these functions are shown below.</font> 
<p><font size=-1>Example of use:</font> 
<p><tt><font size=-1>Void PrintStuff (CPage* ps)</font></tt> 
<br><tt><font size=-1>{</font></tt> 
<br><tt><font size=-1>    double Row;</font></tt> 
<br><tt><font size=-1>    CPrintRegion *Region1=ps->CreateRegion(1.0,1.0,2.0,4.0);</font></tt> 
<br><tt><font size=-1>    CPrintRegion *SubRegion1=ps->CreateSubRegion(Region1,0.0,1.0,2.0,2.0);</font></tt> 
<p><tt><font size=-1>    Region1->DrawBorder();</font></tt> 
<br><tt><font size=-1>    SubRegion1->DrawBorder();</font></tt> 
<br><tt><font size=-1>    Region1->DrawTitle("The Title",8,TEXT_BOLD|TEXT_CENTER|TEXT_RECT,FILL_NONE);</font></tt> 
<br><tt><font size=-1>    ps->CheckBox(Region1,"A Test",TRUE,.2,0.0,12,LABEL_LEFT,1,FILL_NONE,TEXT_BOLD);</font></tt> 
<br><tt><font size=-1>    Row=ps->Print(Region1,1.0,0.0,TEXT_NORMAL,14,"This 
is a test");</font></tt> 
<br><tt><font size=-1>    ps->Print(SubRegion1,0.0,0.0,TEXT_BOLD,"In 
subregion");</font></tt> 
<br><tt><font size=-1>}</font></tt> 
<p><b><font color="#000099"><font size=-1>DO NOT DELETE THE CPrintRegion 
POINTER RETURNED TO YOU. THE CPage CLASS MAINTAINS A LIST OF THESE AND 
FREES THEM WHEN THE DESTRUCTOR RUNS. DELETEING A CPrintRegion POINTER WILL 
RESULT IN A PAGE FAULT WHEN THE CLASS TRIES TO ACCESS THE ITEM.</font></font></b> 
<p><font size=-1>There are overrides for all the line and box drawing routines. 
They work just like CPage::Line() and CPage::Box() with he exception of 
the first parameter which is a pointer to a CPrintRegion. They are not 
documented here but see the source code for details. They do provide some 
checking for parameter validity and assure that drawing only takes place 
within the region passed.. As usual all offsets are relative to the region 
not the page. A offset of 0,0 refers to the first printable spot in the 
region, whereever it is located. If offsets are outside the region they 
are adjusted back to fit within the region.</font> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<p><a NAME="RotateText"></a><b><font size=-2>void PrintRotatedText(double 
Top,double Left,double Bottom,double Right,UINT flags,int PointSize,LPCSTR 
Text,int angle);</font></b> 
<p><font size=-1>This function allows one to print text rotated thru 360 
degrees. The angle of orientation is expressed in 1/10 of a degree and 
represented as an integer for 0 to 3600. Parameters are</font> 
<br><font size=-1>double Top,Left,Bottom,Right. Boundries of text clipping 
area. TEXT_NOCLIP should be used to rotate text thru non region areas.</font> 
<br><font size=-1>UINT Flags are the standard text flags</font> 
<br><font size=-1>int Point size is the font size</font> 
<br><font size=-1>LPCSTR Text is , of course, the text</font> 
<br><font size=-1>int angle is the rotation angle expressed in 1/10 of 
a degree. Valid range is 0-3600.</font> 
<br><font size=-1>Example of use:</font> 
<p><tt>void PrintForm6(CPage* ps)</tt> 
<br><tt>{</tt> 
<br><tt>     CString s;</tt> 
<br><tt>     double row=0.0;</tt> 
<br><tt>     for(int y=0; y < 3600;y+=300)</tt> 
<br><tt>     {</tt> 
<br><tt>          s.Format("Rotated 
Text Demo:Factor %d",y);</tt> 
<br><tt>          ps->PrintRotatedText(5.5,4.0,9.0,8.0,TEXT_BOLD|TEXT_NOCLIP,16,s,y);</tt> 
<br><tt>     }</tt> 
<br><tt>}</tt> 
<center><a href="#toc">Back</a></center> 
 
<hr WIDTH="100%"> 
<br>  
<br>  
<br>  
<br>  
<br>  
</body> 
</html>