OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
printout.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5//----------------------------------------------------------------------------
6#include <owl/pch.h>
7#include <owl/printer.h>
8
9namespace owl {
10
12
13//
14/// Constructs an instance of TPrintout with the given title.
15/// If the given title is a null-pointer, an empty string is assigned.
16//
18 : Title(title ? tstring(title) : tstring()),
19 Banding(false),
20 ForceAllBands(true),
21 DC(nullptr),
22 PageSize(0)
23{}
24
25//
26/// Constructs an instance of TPrintout with the given title.
27//
29:
30 Title(title),
31 Banding(false),
32 ForceAllBands(true),
33 DC(nullptr),
34 PageSize(0)
35{}
36
37//
38/// Place-holder
39//
42
43//
44/// Returns the title of the current printout.
45//
47{
48 return Title.c_str();
49}
50
51//
52/// Returns true if banding is desired.
53//
55{
56 return Banding;
57}
58
59//
60/// Returns true if the force all bands.
61//
63{
64 return ForceAllBands;
65}
66
67//
68/// Returns the DC associated with the printout.
69//
71{
72 return DC;
73}
74
75//
76/// Sets the banding flag for the printout.
77//
79{
80 Banding = banding;
81}
82
83//
84/// Sets the force banding flag.
85//
87{
88 ForceAllBands = force;
89}
90
91//
92/// Sets the associated DC.
93//
95{
96 DC = dc;
97}
98
99//
100/// Retrieves the size of the page.
101//
103{
104 return PageSize;
105}
106
107//
108/// Sets the size of the page.
109//
111{
112 PageSize = pagesize;
113}
114
115//
116/// SetPrintParams sets DC to dc and PageSize to pageSize. The printer object's
117/// Print function calls SetPrintParams to obtain the information it needs to
118/// determine pagination and page count. Derived objects that override
119/// SetPrintParams must call the inherited function.
120//
121void
127
128//
129/// Retrieves information needed to allow the printing of selected pages of the
130/// document and returns true if page selection is possible. Use of page ranges is
131/// optional, but if the page count is easy to determine, GetDialogInfo sets the
132/// number of pages in the document. Otherwise, it sets the number of pages to 0 and
133/// printing will continue until HasPage returns false.
134//
135void
137{
138 minPage = 1;
141}
142
143//
144/// The printer object's Print function calls BeginPrinting once at the beginning of
145/// a print job, regardless of how many copies of the document are to be printed.
146/// Derived objects can override BeginPrinting to perform any initialization needed
147/// before printing.
148//
149void
153
154//
155/// The printer object's Print function calls BeginDocument once before printing
156/// each copy of a document. The flags field indicates if the current print band
157/// accepts graphics, text, or both.
158/// The default BeginDocument does nothing. Derived objects can override
159/// BeginDocument to perform any initialization needed at the beginning of each copy
160/// of the document.
161//
162void
164{
165}
166
167//
168/// HasPage is called after every page is printed. By default, it returns false,
169/// indicating that only one page is to be printed. If the document contains more
170/// than one page, this function must be overridden to return true while there are
171/// more pages to print.
172//
173bool
175{
176 return page == 1;
177}
178
179//
180/// PrintPage is called for every page (or band, if Banding is true) and must be
181/// overridden to print the contents of the given page. The rect and flags
182/// parameters are used during banding to indicate the extent and type of band
183/// currently requested from the driver (and should be ignored if Banding is false).
184/// page is the number of the current page.
185void
189
190//
191/// The printer object's Print function calls EndDocument after each copy of the
192/// document finishes printing. Derived objects can override EndDocument to perform
193/// any needed actions at the end of each document.
194//
195void
199
200//
201/// The printer object's Print function calls EndPrinting after all copies of the
202/// document finish printing. Derived objects can override EndPrinting to perform
203/// any needed actions at the end of each document.
204//
205void
209
210//
211/// Sets a new title for this printout. The passed title string is copied.
212/// If the given title is a null-pointer, an empty string is assigned.
213//
215{
216 Title = title ? tstring(title) : tstring();
217}
218
219//
220/// Sets a new title for this printout. The passed title string is copied.
221//
222void
224{
225 Title = title;
226}
227
228
230
231#if OWL_PERSISTENT_STREAMS
232
233//
234// Deserialization from stream
235//
236void*
237TPrintout::Streamer::Read(ipstream& is, uint32) const
238{
239#if defined(UNICODE)
241 char* title = is.freadString();
242 GetObject()->Title = _A2W(title);
243 delete[] title;
244#else
245 GetObject()->Title = is.freadString();
246#endif
247 is >> GetObject()->Banding;
248 is >> GetObject()->ForceAllBands;
249 return GetObject();
250}
251
252//
253// Serialization to stream
254//
255void
256TPrintout::Streamer::Write(opstream& os) const
257{
259 os.fwriteString(_W2A(GetObject()->Title.c_str()));
260 os << GetObject()->Banding;
261 os << GetObject()->ForceAllBands;
262}
263
264#endif
265
266} // OWL namespace
267/* ========================================================================== */
268
A DC class that provides access to a printer.
Definition dc.h:874
TPrintout represents the physical printed document that is to sent to a printer to be printed.
Definition printer.h:76
virtual void BeginDocument(int startPage, int endPage, uint flags)
The printer object's Print function calls BeginDocument once before printing each copy of a document.
Definition printout.cpp:163
bool WantForceAllBands() const
Returns true if the force all bands.
Definition printout.cpp:62
LPCTSTR GetTitle() const
Returns the title of the current printout.
Definition printout.cpp:46
virtual bool HasPage(int pageNumber)
HasPage is called after every page is printed.
Definition printout.cpp:174
TPrintDC * GetPrintDC()
Returns the DC associated with the printout.
Definition printout.cpp:70
void SetBanding(bool banding=true)
Sets the banding flag for the printout.
Definition printout.cpp:78
virtual void EndPrinting()
The printer object's Print function calls EndPrinting after all copies of the document finish printin...
Definition printout.cpp:206
TPrintout(LPCTSTR title)
Constructs an instance of TPrintout with the given title.
Definition printout.cpp:17
virtual void EndDocument()
The printer object's Print function calls EndDocument after each copy of the document finishes printi...
Definition printout.cpp:196
virtual void SetPrintParams(TPrintDC *dc, TSize pageSize)
SetPrintParams sets DC to dc and PageSize to pageSize.
Definition printout.cpp:122
virtual void PrintPage(int page, TRect &rect, uint flags)
PrintPage is called for every page (or band, if Banding is true) and must be overridden to print the ...
Definition printout.cpp:186
void SetPageSize(const TSize &pagesize)
Sets the size of the page.
Definition printout.cpp:110
void SetForceAllBands(bool force=true)
Sets the force banding flag.
Definition printout.cpp:86
TSize GetPageSize() const
Retrieves the size of the page.
Definition printout.cpp:102
bool WantBanding() const
Returns true if banding is desired.
Definition printout.cpp:54
void SetTitle(LPCTSTR title)
Sets a new title for this printout.
Definition printout.cpp:214
virtual void GetDialogInfo(int &minPage, int &maxPage, int &selFromPage, int &selToPage)
Retrieves information needed to allow the printing of selected pages of the document and returns true...
Definition printout.cpp:136
virtual void BeginPrinting()
The printer object's Print function calls BeginPrinting once at the beginning of a print job,...
Definition printout.cpp:150
virtual ~TPrintout()
Place-holder.
Definition printout.cpp:40
void SetPrintDC(TPrintDC *dc)
Sets the associated DC.
Definition printout.cpp:94
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
#define IMPLEMENT_STREAMABLE(cls)
Definition objstrm.h:1724
#define _W2A(lpw)
Definition memory.h:219
#define _A2W(lpw)
Definition memory.h:220
#define _USES_CONVERSION
Definition memory.h:217
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
OWL_DIAGINFO
Definition animctrl.cpp:14
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25