1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextprint.cpp
3 // Purpose: Rich text printing classes
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_RICHTEXT && wxUSE_PRINTING_ARCHITECTURE && wxUSE_STREAMS
24 #include "wx/settings.h"
25 #include "wx/msgdlg.h"
28 #include "wx/datetime.h"
30 #include "wx/printdlg.h"
31 #include "wx/richtext/richtextprint.h"
32 #include "wx/wfstream.h"
38 wxRichTextPrintout::wxRichTextPrintout(const wxString
& title
) : wxPrintout(title
)
40 m_numPages
= wxRICHTEXT_PRINT_MAX_PAGES
;
42 SetMargins(); // to default values
45 wxRichTextPrintout::~wxRichTextPrintout()
49 void wxRichTextPrintout::OnPreparePrinting()
55 m_pageBreaksStart
.Clear();
56 m_pageBreaksEnd
.Clear();
60 wxRect rect
, headerRect
, footerRect
;
62 /// Sets the DC scaling and returns important page rectangles
63 CalculateScaling(GetDC(), rect
, headerRect
, footerRect
);
65 if (GetRichTextBuffer())
67 GetRichTextBuffer()->Invalidate(wxRICHTEXT_ALL
);
69 GetRichTextBuffer()->Layout(*GetDC(), rect
, wxRICHTEXT_FIXED_WIDTH
|wxRICHTEXT_VARIABLE_HEIGHT
);
71 // Now calculate the page breaks
75 wxRichTextLine
* lastLine
= NULL
;
77 wxRichTextObjectList::compatibility_iterator node
= GetRichTextBuffer()->GetChildren().GetFirst();
80 // child is a paragraph
81 wxRichTextParagraph
* child
= wxDynamicCast(node
->GetData(), wxRichTextParagraph
);
82 wxASSERT (child
!= NULL
);
84 wxRichTextLineList::compatibility_iterator node2
= child
->GetLines().GetFirst();
87 wxRichTextLine
* line
= node2
->GetData();
89 // Set the line to the page-adjusted position
90 line
->SetPosition(wxPoint(line
->GetPosition().x
, line
->GetPosition().y
- yOffset
));
92 int lineY
= child
->GetPosition().y
+ line
->GetPosition().y
;
94 // Break the page if either we're going off the bottom, or this paragraph specifies
95 // an explicit page break
97 if (((lineY
+ line
->GetSize().y
) > rect
.GetBottom()) ||
98 ((node2
== child
->GetLines().GetFirst()) && child
->GetAttributes().HasPageBreak()))
100 // New page starting at this line
103 // We increase the offset by the difference between new and old positions
105 int increaseOffsetBy
= lineY
- newY
;
106 yOffset
+= increaseOffsetBy
;
108 line
->SetPosition(wxPoint(line
->GetPosition().x
, newY
- child
->GetPosition().y
));
113 m_pageBreaksStart
.Add(lastStartPos
);
114 m_pageBreaksEnd
.Add(lastLine
->GetAbsoluteRange().GetEnd());
116 lastStartPos
= line
->GetAbsoluteRange().GetStart();
123 node2
= node2
->GetNext();
126 node
= node
->GetNext();
129 // Closing page break
130 if (m_pageBreaksStart
.GetCount() == 0 || (m_pageBreaksEnd
[m_pageBreaksEnd
.GetCount()-1] < (GetRichTextBuffer()->GetRange().GetEnd()-1)))
132 m_pageBreaksStart
.Add(lastStartPos
);
133 m_pageBreaksEnd
.Add(GetRichTextBuffer()->GetRange().GetEnd());
138 bool wxRichTextPrintout::OnBeginDocument(int startPage
, int endPage
)
140 if (!wxPrintout::OnBeginDocument(startPage
, endPage
)) return false;
145 bool wxRichTextPrintout::OnPrintPage(int page
)
151 RenderPage(dc
, page
);
157 void wxRichTextPrintout::GetPageInfo(int *minPage
, int *maxPage
, int *selPageFrom
, int *selPageTo
)
160 *maxPage
= m_numPages
;
162 *selPageTo
= m_numPages
;
165 bool wxRichTextPrintout::HasPage(int pageNum
)
167 return pageNum
> 0 && pageNum
<= m_numPages
;
170 void wxRichTextPrintout::RenderPage(wxDC
*dc
, int page
)
172 if (!GetRichTextBuffer())
177 wxRect textRect
, headerRect
, footerRect
;
179 /// Sets the DC scaling and returns important page rectangles
180 CalculateScaling(dc
, textRect
, headerRect
, footerRect
);
182 if (page
> 1 || m_headerFooterData
.GetShowOnFirstPage())
184 if (m_headerFooterData
.GetFont().Ok())
185 dc
->SetFont(m_headerFooterData
.GetFont());
187 dc
->SetFont(*wxNORMAL_FONT
);
188 if (m_headerFooterData
.GetTextColour().Ok())
189 dc
->SetTextForeground(m_headerFooterData
.GetTextColour());
191 dc
->SetTextForeground(*wxBLACK
);
192 dc
->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT
);
194 // Draw header, if any
195 wxRichTextOddEvenPage oddEven
= ((page
% 2) == 1) ? wxRICHTEXT_PAGE_ODD
: wxRICHTEXT_PAGE_EVEN
;
197 wxString headerTextCentre
= m_headerFooterData
.GetHeaderText(oddEven
, wxRICHTEXT_PAGE_CENTRE
);
198 wxString headerTextLeft
= m_headerFooterData
.GetHeaderText(oddEven
, wxRICHTEXT_PAGE_LEFT
);
199 wxString headerTextRight
= m_headerFooterData
.GetHeaderText(oddEven
, wxRICHTEXT_PAGE_RIGHT
);
201 if (!headerTextLeft
.IsEmpty())
203 SubstituteKeywords(headerTextLeft
, GetTitle(), page
, m_numPages
);
206 //dc->GetTextExtent(headerTextLeft, & tx, & ty);
208 int x
= headerRect
.GetLeft();
209 int y
= headerRect
.GetX();
210 dc
->DrawText(headerTextLeft
, x
, y
);
212 if (!headerTextCentre
.IsEmpty())
214 SubstituteKeywords(headerTextCentre
, GetTitle(), page
, m_numPages
);
217 dc
->GetTextExtent(headerTextCentre
, & tx
, & ty
);
219 int x
= headerRect
.GetWidth()/2 - tx
/2 + headerRect
.GetLeft();
220 int y
= headerRect
.GetY();
221 dc
->DrawText(headerTextCentre
, x
, y
);
223 if (!headerTextRight
.IsEmpty())
225 SubstituteKeywords(headerTextRight
, GetTitle(), page
, m_numPages
);
228 dc
->GetTextExtent(headerTextRight
, & tx
, & ty
);
230 int x
= headerRect
.GetRight() - tx
;
231 int y
= headerRect
.GetY();
232 dc
->DrawText(headerTextRight
, x
, y
);
235 // Draw footer, if any
236 wxString footerTextCentre
= m_headerFooterData
.GetFooterText(oddEven
, wxRICHTEXT_PAGE_CENTRE
);
237 wxString footerTextLeft
= m_headerFooterData
.GetFooterText(oddEven
, wxRICHTEXT_PAGE_LEFT
);
238 wxString footerTextRight
= m_headerFooterData
.GetFooterText(oddEven
, wxRICHTEXT_PAGE_RIGHT
);
240 if (!footerTextLeft
.IsEmpty())
242 SubstituteKeywords(footerTextLeft
, GetTitle(), page
, m_numPages
);
245 dc
->GetTextExtent(footerTextLeft
, & tx
, & ty
);
247 int x
= footerRect
.GetLeft();
248 int y
= footerRect
.GetBottom() - ty
;
249 dc
->DrawText(footerTextLeft
, x
, y
);
251 if (!footerTextCentre
.IsEmpty())
253 SubstituteKeywords(footerTextCentre
, GetTitle(), page
, m_numPages
);
256 dc
->GetTextExtent(footerTextCentre
, & tx
, & ty
);
258 int x
= footerRect
.GetWidth()/2 - tx
/2 + footerRect
.GetLeft();
259 int y
= footerRect
.GetBottom() - ty
;
260 dc
->DrawText(footerTextCentre
, x
, y
);
262 if (!footerTextRight
.IsEmpty())
264 SubstituteKeywords(footerTextRight
, GetTitle(), page
, m_numPages
);
267 dc
->GetTextExtent(footerTextRight
, & tx
, & ty
);
269 int x
= footerRect
.GetRight() - tx
;
270 int y
= footerRect
.GetBottom() - ty
;
271 dc
->DrawText(footerTextRight
, x
, y
);
275 wxRichTextRange
rangeToDraw(m_pageBreaksStart
[page
-1], m_pageBreaksEnd
[page
-1]);
277 GetRichTextBuffer()->Draw(*dc
, rangeToDraw
, wxRichTextRange(-1,-1), textRect
, 0 /* descent */, wxRICHTEXT_DRAW_IGNORE_CACHE
/* flags */);
280 void wxRichTextPrintout::SetMargins(int top
, int bottom
, int left
, int right
)
283 m_marginBottom
= bottom
;
285 m_marginRight
= right
;
288 /// Calculate scaling and rectangles, setting the device context scaling
289 void wxRichTextPrintout::CalculateScaling(wxDC
* dc
, wxRect
& textRect
, wxRect
& headerRect
, wxRect
& footerRect
)
291 // Get the logical pixels per inch of screen and printer
292 int ppiScreenX
, ppiScreenY
;
293 GetPPIScreen(&ppiScreenX
, &ppiScreenY
);
294 int ppiPrinterX
, ppiPrinterY
;
295 GetPPIPrinter(&ppiPrinterX
, &ppiPrinterY
);
297 // This scales the DC so that the printout roughly represents the
298 // the screen scaling.
299 float scale
= (float)((float)ppiPrinterX
/(float)ppiScreenX
);
301 // Now we have to check in case our real page size is reduced
302 // (e.g. because we're drawing to a print preview memory DC)
303 int pageWidth
, pageHeight
;
306 GetPageSizePixels(&pageWidth
, &pageHeight
);
308 // If printer pageWidth == current DC width, then this doesn't
309 // change. But w might be the preview bitmap width, so scale down.
310 float previewScale
= (float)(w
/(float)pageWidth
);
311 float overallScale
= scale
* previewScale
;
313 // The dimensions used for indentation etc. have to be unscaled
314 // during printing to be correct when scaling is applied.
316 m_richTextBuffer
->SetScale(scale
);
319 int marginLeft
= wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX
, m_marginLeft
);
320 int marginTop
= wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX
, m_marginTop
);
321 int marginRight
= wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX
, m_marginRight
);
322 int marginBottom
= wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX
, m_marginBottom
);
324 // Header and footer margins
325 int headerMargin
= wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX
, m_headerFooterData
.GetHeaderMargin());
326 int footerMargin
= wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX
, m_headerFooterData
.GetFooterMargin());
328 dc
->SetUserScale(overallScale
, overallScale
);
330 wxRect
rect((int) (marginLeft
/scale
), (int) (marginTop
/scale
),
331 (int) ((pageWidth
- marginLeft
- marginRight
)/scale
), (int)((pageHeight
- marginTop
- marginBottom
)/scale
));
333 headerRect
= wxRect(0, 0, 0, 0);
335 if (!m_headerFooterData
.GetHeaderText(wxRICHTEXT_PAGE_ODD
, wxRICHTEXT_PAGE_LEFT
).IsEmpty() ||
336 !m_headerFooterData
.GetHeaderText(wxRICHTEXT_PAGE_ODD
, wxRICHTEXT_PAGE_CENTRE
).IsEmpty() ||
337 !m_headerFooterData
.GetHeaderText(wxRICHTEXT_PAGE_ODD
, wxRICHTEXT_PAGE_RIGHT
).IsEmpty() ||
339 !m_headerFooterData
.GetHeaderText(wxRICHTEXT_PAGE_EVEN
, wxRICHTEXT_PAGE_LEFT
).IsEmpty() ||
340 !m_headerFooterData
.GetHeaderText(wxRICHTEXT_PAGE_EVEN
, wxRICHTEXT_PAGE_CENTRE
).IsEmpty() ||
341 !m_headerFooterData
.GetHeaderText(wxRICHTEXT_PAGE_EVEN
, wxRICHTEXT_PAGE_RIGHT
).IsEmpty())
343 if (m_headerFooterData
.GetFont().Ok())
344 dc
->SetFont(m_headerFooterData
.GetFont());
346 dc
->SetFont(*wxNORMAL_FONT
);
348 int charHeight
= dc
->GetCharHeight();
350 int headerHeight
= (int) (charHeight
+ headerMargin
/scale
);
352 headerRect
= wxRect(rect
.x
, rect
.y
, rect
.width
, headerHeight
);
354 rect
.y
+= headerHeight
;
355 rect
.height
-= headerHeight
;
358 footerRect
= wxRect(0, 0, 0, 0);
360 if (!m_headerFooterData
.GetFooterText(wxRICHTEXT_PAGE_ODD
, wxRICHTEXT_PAGE_LEFT
).IsEmpty() ||
361 !m_headerFooterData
.GetFooterText(wxRICHTEXT_PAGE_ODD
, wxRICHTEXT_PAGE_CENTRE
).IsEmpty() ||
362 !m_headerFooterData
.GetFooterText(wxRICHTEXT_PAGE_ODD
, wxRICHTEXT_PAGE_RIGHT
).IsEmpty() ||
364 !m_headerFooterData
.GetFooterText(wxRICHTEXT_PAGE_EVEN
, wxRICHTEXT_PAGE_LEFT
).IsEmpty() ||
365 !m_headerFooterData
.GetFooterText(wxRICHTEXT_PAGE_EVEN
, wxRICHTEXT_PAGE_CENTRE
).IsEmpty() ||
366 !m_headerFooterData
.GetFooterText(wxRICHTEXT_PAGE_EVEN
, wxRICHTEXT_PAGE_RIGHT
).IsEmpty())
368 if (m_headerFooterData
.GetFont().Ok())
369 dc
->SetFont(m_headerFooterData
.GetFont());
371 dc
->SetFont(*wxNORMAL_FONT
);
373 int charHeight
= dc
->GetCharHeight();
375 int footerHeight
= (int) (charHeight
+ footerMargin
/scale
);
377 footerRect
= wxRect(rect
.x
, rect
.y
+ rect
.height
, rect
.width
, footerHeight
);
379 rect
.height
-= footerHeight
;
385 bool wxRichTextPrintout::SubstituteKeywords(wxString
& str
, const wxString
& title
, int pageNum
, int pageCount
)
389 num
.Printf(wxT("%i"), pageNum
);
390 str
.Replace(wxT("@PAGENUM@"), num
);
392 num
.Printf(wxT("%lu"), (unsigned long) pageCount
);
393 str
.Replace(wxT("@PAGESCNT@"), num
);
395 wxDateTime now
= wxDateTime::Now();
397 str
.Replace(wxT("@DATE@"), now
.FormatDate());
398 str
.Replace(wxT("@TIME@"), now
.FormatTime());
400 str
.Replace(wxT("@TITLE@"), title
);
409 wxRichTextPrinting::wxRichTextPrinting(const wxString
& name
, wxWindow
*parentWindow
)
411 m_richTextBufferPrinting
= NULL
;
412 m_richTextBufferPreview
= NULL
;
414 m_parentWindow
= parentWindow
;
418 m_previewRect
= wxRect(wxPoint(100, 100), wxSize(800, 800));
420 m_pageSetupData
= new wxPageSetupDialogData
;
421 m_pageSetupData
->EnableMargins(true);
422 m_pageSetupData
->SetMarginTopLeft(wxPoint(25, 25));
423 m_pageSetupData
->SetMarginBottomRight(wxPoint(25, 25));
426 wxRichTextPrinting::~wxRichTextPrinting()
429 delete m_pageSetupData
;
430 delete m_richTextBufferPrinting
;
431 delete m_richTextBufferPreview
;
434 wxPrintData
*wxRichTextPrinting::GetPrintData()
436 if (m_printData
== NULL
)
437 m_printData
= new wxPrintData();
441 /// Set print and page setup data
442 void wxRichTextPrinting::SetPrintData(const wxPrintData
& printData
)
444 (*GetPrintData()) = printData
;
447 void wxRichTextPrinting::SetPageSetupData(const wxPageSetupData
& pageSetupData
)
449 (*GetPageSetupData()) = pageSetupData
;
452 /// Set the rich text buffer pointer, deleting the existing object if present
453 void wxRichTextPrinting::SetRichTextBufferPrinting(wxRichTextBuffer
* buf
)
455 if (m_richTextBufferPrinting
)
457 delete m_richTextBufferPrinting
;
458 m_richTextBufferPrinting
= NULL
;
460 m_richTextBufferPrinting
= buf
;
463 void wxRichTextPrinting::SetRichTextBufferPreview(wxRichTextBuffer
* buf
)
465 if (m_richTextBufferPreview
)
467 delete m_richTextBufferPreview
;
468 m_richTextBufferPreview
= NULL
;
470 m_richTextBufferPreview
= buf
;
473 bool wxRichTextPrinting::PreviewFile(const wxString
& richTextFile
)
475 SetRichTextBufferPreview(new wxRichTextBuffer
);
477 if (!m_richTextBufferPreview
->LoadFile(richTextFile
))
479 SetRichTextBufferPreview(NULL
);
483 SetRichTextBufferPrinting(new wxRichTextBuffer(*m_richTextBufferPreview
));
485 wxRichTextPrintout
*p1
= CreatePrintout();
486 p1
->SetRichTextBuffer(m_richTextBufferPreview
);
488 wxRichTextPrintout
*p2
= CreatePrintout();
489 p2
->SetRichTextBuffer(m_richTextBufferPrinting
);
490 return DoPreview(p1
, p2
);
493 bool wxRichTextPrinting::PreviewBuffer(const wxRichTextBuffer
& buffer
)
495 SetRichTextBufferPreview(new wxRichTextBuffer(buffer
));
496 SetRichTextBufferPrinting(new wxRichTextBuffer(buffer
));
498 wxRichTextPrintout
*p1
= CreatePrintout();
499 p1
->SetRichTextBuffer(m_richTextBufferPreview
);
501 wxRichTextPrintout
*p2
= CreatePrintout();
502 p2
->SetRichTextBuffer(m_richTextBufferPrinting
);
504 return DoPreview(p1
, p2
);
507 bool wxRichTextPrinting::PrintFile(const wxString
& richTextFile
)
509 SetRichTextBufferPrinting(new wxRichTextBuffer
);
511 if (!m_richTextBufferPrinting
->LoadFile(richTextFile
))
513 SetRichTextBufferPrinting(NULL
);
517 wxRichTextPrintout
*p
= CreatePrintout();
518 p
->SetRichTextBuffer(m_richTextBufferPrinting
);
520 bool ret
= DoPrint(p
);
525 bool wxRichTextPrinting::PrintBuffer(const wxRichTextBuffer
& buffer
)
527 SetRichTextBufferPrinting(new wxRichTextBuffer(buffer
));
529 wxRichTextPrintout
*p
= CreatePrintout();
530 p
->SetRichTextBuffer(m_richTextBufferPrinting
);
532 bool ret
= DoPrint(p
);
537 bool wxRichTextPrinting::DoPreview(wxRichTextPrintout
*printout1
, wxRichTextPrintout
*printout2
)
539 // Pass two printout objects: for preview, and possible printing.
540 wxPrintDialogData
printDialogData(*GetPrintData());
541 wxPrintPreview
*preview
= new wxPrintPreview(printout1
, printout2
, &printDialogData
);
548 wxPreviewFrame
*frame
= new wxPreviewFrame(preview
, m_parentWindow
,
549 m_title
+ _(" Preview"),
550 m_previewRect
.GetPosition(), m_previewRect
.GetSize());
551 frame
->Centre(wxBOTH
);
557 bool wxRichTextPrinting::DoPrint(wxRichTextPrintout
*printout
)
559 wxPrintDialogData
printDialogData(*GetPrintData());
560 wxPrinter
printer(&printDialogData
);
562 if (!printer
.Print(m_parentWindow
, printout
, true))
567 (*GetPrintData()) = printer
.GetPrintDialogData().GetPrintData();
571 void wxRichTextPrinting::PageSetup()
573 if (!GetPrintData()->Ok())
575 wxLogError(_("There was a problem during page setup: you may need to set a default printer."));
579 m_pageSetupData
->SetPrintData(*GetPrintData());
580 wxPageSetupDialog
pageSetupDialog(m_parentWindow
, m_pageSetupData
);
582 if (pageSetupDialog
.ShowModal() == wxID_OK
)
584 (*GetPrintData()) = pageSetupDialog
.GetPageSetupData().GetPrintData();
585 (*m_pageSetupData
) = pageSetupDialog
.GetPageSetupData();
589 wxRichTextPrintout
*wxRichTextPrinting::CreatePrintout()
591 wxRichTextPrintout
*p
= new wxRichTextPrintout(m_title
);
593 p
->SetHeaderFooterData(GetHeaderFooterData());
594 p
->SetMargins(10*m_pageSetupData
->GetMarginTopLeft().y
,
595 10*m_pageSetupData
->GetMarginBottomRight().y
,
596 10*m_pageSetupData
->GetMarginTopLeft().x
,
597 10*m_pageSetupData
->GetMarginBottomRight().x
);
602 /// Set/get header text, e.g. wxRICHTEXT_PAGE_ODD, wxRICHTEXT_PAGE_LEFT
603 void wxRichTextPrinting::SetHeaderText(const wxString
& text
, wxRichTextOddEvenPage page
, wxRichTextPageLocation location
)
605 m_headerFooterData
.SetHeaderText(text
, page
, location
);
608 wxString
wxRichTextPrinting::GetHeaderText(wxRichTextOddEvenPage page
, wxRichTextPageLocation location
) const
610 return m_headerFooterData
.GetHeaderText(page
, location
);
613 /// Set/get footer text, e.g. wxRICHTEXT_PAGE_ODD, wxRICHTEXT_PAGE_LEFT
614 void wxRichTextPrinting::SetFooterText(const wxString
& text
, wxRichTextOddEvenPage page
, wxRichTextPageLocation location
)
616 m_headerFooterData
.SetFooterText(text
, page
, location
);
619 wxString
wxRichTextPrinting::GetFooterText(wxRichTextOddEvenPage page
, wxRichTextPageLocation location
) const
621 return m_headerFooterData
.GetFooterText(page
, location
);
628 IMPLEMENT_CLASS(wxRichTextHeaderFooterData
, wxObject
)
631 void wxRichTextHeaderFooterData::Copy(const wxRichTextHeaderFooterData
& data
)
634 for (i
= 0; i
< 12; i
++)
635 m_text
[i
] = data
.m_text
[i
];
636 m_font
= data
.m_font
;
637 m_colour
= data
.m_colour
;
638 m_headerMargin
= data
.m_headerMargin
;
639 m_footerMargin
= data
.m_footerMargin
;
640 m_showOnFirstPage
= data
.m_showOnFirstPage
;
644 void wxRichTextHeaderFooterData::SetText(const wxString
& text
, int headerFooter
, wxRichTextOddEvenPage page
, wxRichTextPageLocation location
)
646 int idx
= headerFooter
+ (2 * (int) page
) + (4 * (int) location
);
647 wxASSERT( idx
>= 0 && idx
< 12 );
649 if (idx
>= 0 && idx
< 12)
653 wxString
wxRichTextHeaderFooterData::GetText(int headerFooter
, wxRichTextOddEvenPage page
, wxRichTextPageLocation location
) const
655 int idx
= headerFooter
+ (2 * (int) page
) + (4 * (int) location
);
656 wxASSERT( idx
>= 0 && idx
< 12 );
658 if (idx
>= 0 && idx
< 12)
661 return wxEmptyString
;
664 /// Set/get header text, e.g. wxRICHTEXT_PAGE_ODD, wxRICHTEXT_PAGE_LEFT
665 void wxRichTextHeaderFooterData::SetHeaderText(const wxString
& text
, wxRichTextOddEvenPage page
, wxRichTextPageLocation location
)
667 if (page
== wxRICHTEXT_PAGE_ALL
)
669 SetText(text
, 0, wxRICHTEXT_PAGE_ODD
, location
);
670 SetText(text
, 0, wxRICHTEXT_PAGE_EVEN
, location
);
673 SetText(text
, 0, page
, location
);
676 wxString
wxRichTextHeaderFooterData::GetHeaderText(wxRichTextOddEvenPage page
, wxRichTextPageLocation location
) const
678 return GetText(0, page
, location
);
681 /// Set/get footer text, e.g. wxRICHTEXT_PAGE_ODD, wxRICHTEXT_PAGE_LEFT
682 void wxRichTextHeaderFooterData::SetFooterText(const wxString
& text
, wxRichTextOddEvenPage page
, wxRichTextPageLocation location
)
684 if (page
== wxRICHTEXT_PAGE_ALL
)
686 SetText(text
, 1, wxRICHTEXT_PAGE_ODD
, location
);
687 SetText(text
, 1, wxRICHTEXT_PAGE_EVEN
, location
);
690 SetText(text
, 1, page
, location
);
693 wxString
wxRichTextHeaderFooterData::GetFooterText(wxRichTextOddEvenPage page
, wxRichTextPageLocation location
) const
695 return GetText(1, page
, location
);
699 void wxRichTextHeaderFooterData::Clear()
702 for (i
= 0; i
< 12; i
++)
703 m_text
[i
] = wxEmptyString
;
706 #endif // wxUSE_RICHTEXT & wxUSE_PRINTING_ARCHITECTURE