1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/printing.cpp
3 // Purpose: Printing demo for wxWidgets
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #if !wxUSE_PRINTING_ARCHITECTURE
24 #error "You must set wxUSE_PRINTING_ARCHITECTURE to 1 in setup.h, and recompile the library."
27 // Set this to 1 if you want to test PostScript printing under MSW.
28 // However, you'll also need to edit src/msw/makefile.nt.
29 #define wxTEST_POSTSCRIPT_IN_MSW 0
32 #include "wx/metafile.h"
34 #include "wx/printdlg.h"
38 #if wxTEST_POSTSCRIPT_IN_MSW
39 #include "wx/generic/printps.h"
40 #include "wx/generic/prntdlgg.h"
43 #if wxUSE_GRAPHICS_CONTEXT
44 #include "wx/graphics.h"
48 #include "wx/mac/printdlg.h"
54 #include "mondrian.xpm"
58 MyFrame
*frame
= (MyFrame
*) NULL
;
59 // int orientation = wxPORTRAIT;
61 // Global print data, to remember settings during the session
62 wxPrintData
*g_printData
= (wxPrintData
*) NULL
;
64 // Global page setup data
65 wxPageSetupDialogData
* g_pageSetupData
= (wxPageSetupDialogData
*) NULL
;
70 // Writes a header on a page. Margin units are in millimetres.
71 bool WritePageHeader(wxPrintout
*printout
, wxDC
*dc
, const wxChar
*text
, float mmToLogical
);
73 // The `main program' equivalent, creating the windows and returning the
76 bool MyApp::OnInit(void)
78 if ( !wxApp::OnInit() )
81 wxInitAllImageHandlers();
83 m_testFont
.Create(10, wxSWISS
, wxNORMAL
, wxNORMAL
);
85 g_printData
= new wxPrintData
;
86 // You could set an initial paper size here
87 // g_printData->SetPaperId(wxPAPER_LETTER); // for Americans
88 // g_printData->SetPaperId(wxPAPER_A4); // for everyone else
90 g_pageSetupData
= new wxPageSetupDialogData
;
91 // copy over initial paper size from print record
92 (*g_pageSetupData
) = *g_printData
;
93 // Set some initial page margins in mm.
94 g_pageSetupData
->SetMarginTopLeft(wxPoint(15, 15));
95 g_pageSetupData
->SetMarginBottomRight(wxPoint(15, 15));
97 // Create the main frame window
98 frame
= new MyFrame((wxFrame
*) NULL
, _T("wxWidgets Printing Demo"),
99 wxPoint(0, 0), wxSize(400, 400));
102 // Give it a status line
103 frame
->CreateStatusBar(2);
104 #endif // wxUSE_STATUSBAR
106 // Load icon and bitmap
107 frame
->SetIcon( wxICON( mondrian
) );
110 wxMenu
*file_menu
= new wxMenu
;
112 file_menu
->Append(WXPRINT_PRINT
, _T("&Print..."), _T("Print"));
113 file_menu
->Append(WXPRINT_PAGE_SETUP
, _T("Page Set&up..."), _T("Page setup"));
115 file_menu
->Append(WXPRINT_PAGE_MARGINS
, _T("Page Margins..."), _T("Page margins"));
117 file_menu
->Append(WXPRINT_PREVIEW
, _T("Print Pre&view"), _T("Preview"));
121 wxAcceleratorEntry entries
[1];
122 entries
[0].Set(wxACCEL_CTRL
, (int) 'V', WXPRINT_PREVIEW
);
123 wxAcceleratorTable
accel(1, entries
);
124 frame
->SetAcceleratorTable(accel
);
127 #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
128 file_menu
->AppendSeparator();
129 file_menu
->Append(WXPRINT_PRINT_PS
, _T("Print PostScript..."), _T("Print (PostScript)"));
130 file_menu
->Append(WXPRINT_PAGE_SETUP_PS
, _T("Page Setup PostScript..."), _T("Page setup (PostScript)"));
131 file_menu
->Append(WXPRINT_PREVIEW_PS
, _T("Print Preview PostScript"), _T("Preview (PostScript)"));
134 file_menu
->AppendSeparator();
135 file_menu
->Append(WXPRINT_ANGLEUP
, _T("Angle up\tAlt-U"), _T("Raise rotated text angle"));
136 file_menu
->Append(WXPRINT_ANGLEDOWN
, _T("Angle down\tAlt-D"), _T("Lower rotated text angle"));
137 file_menu
->AppendSeparator();
138 file_menu
->Append(WXPRINT_QUIT
, _T("E&xit"), _T("Exit program"));
140 wxMenu
*help_menu
= new wxMenu
;
141 help_menu
->Append(WXPRINT_ABOUT
, _T("&About"), _T("About this demo"));
143 wxMenuBar
*menu_bar
= new wxMenuBar
;
145 menu_bar
->Append(file_menu
, _T("&File"));
146 menu_bar
->Append(help_menu
, _T("&Help"));
148 // Associate the menu bar with the frame
149 frame
->SetMenuBar(menu_bar
);
151 MyCanvas
*canvas
= new MyCanvas(frame
, wxPoint(0, 0), wxSize(100, 100), wxRETAINED
|wxHSCROLL
|wxVSCROLL
);
153 // Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
154 canvas
->SetScrollbars(20, 20, 50, 50);
156 frame
->canvas
= canvas
;
158 frame
->Centre(wxBOTH
);
162 frame
->SetStatusText(_T("Printing demo"));
163 #endif // wxUSE_STATUSBAR
173 delete g_pageSetupData
;
177 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
178 EVT_MENU(WXPRINT_QUIT
, MyFrame::OnExit
)
179 EVT_MENU(WXPRINT_PRINT
, MyFrame::OnPrint
)
180 EVT_MENU(WXPRINT_PREVIEW
, MyFrame::OnPrintPreview
)
181 EVT_MENU(WXPRINT_PAGE_SETUP
, MyFrame::OnPageSetup
)
182 EVT_MENU(WXPRINT_ABOUT
, MyFrame::OnPrintAbout
)
183 #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
184 EVT_MENU(WXPRINT_PRINT_PS
, MyFrame::OnPrintPS
)
185 EVT_MENU(WXPRINT_PREVIEW_PS
, MyFrame::OnPrintPreviewPS
)
186 EVT_MENU(WXPRINT_PAGE_SETUP_PS
, MyFrame::OnPageSetupPS
)
189 EVT_MENU(WXPRINT_PAGE_MARGINS
, MyFrame::OnPageMargins
)
191 EVT_MENU(WXPRINT_ANGLEUP
, MyFrame::OnAngleUp
)
192 EVT_MENU(WXPRINT_ANGLEDOWN
, MyFrame::OnAngleDown
)
195 // Define my frame constructor
196 MyFrame::MyFrame(wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
197 wxFrame(frame
, wxID_ANY
, title
, pos
, size
)
202 wxImage
image( wxT("test.jpg") );
205 for (i
= 0; i
< image
.GetWidth(); i
++)
206 for (j
= 0; j
< image
.GetHeight(); j
++)
207 image
.SetAlpha( i
, j
, 50 );
212 void MyFrame::OnExit(wxCommandEvent
& WXUNUSED(event
))
214 Close(true /*force closing*/);
217 void MyFrame::OnPrint(wxCommandEvent
& WXUNUSED(event
))
219 wxPrintDialogData
printDialogData(* g_printData
);
221 wxPrinter
printer(& printDialogData
);
222 MyPrintout
printout(_T("My printout"));
223 if (!printer
.Print(this, &printout
, true /*prompt*/))
225 if (wxPrinter::GetLastError() == wxPRINTER_ERROR
)
226 wxMessageBox(_T("There was a problem printing.\nPerhaps your current printer is not set correctly?"), _T("Printing"), wxOK
);
228 wxMessageBox(_T("You canceled printing"), _T("Printing"), wxOK
);
232 (*g_printData
) = printer
.GetPrintDialogData().GetPrintData();
236 void MyFrame::OnPrintPreview(wxCommandEvent
& WXUNUSED(event
))
238 // Pass two printout objects: for preview, and possible printing.
239 wxPrintDialogData
printDialogData(* g_printData
);
240 wxPrintPreview
*preview
= new wxPrintPreview(new MyPrintout
, new MyPrintout
, & printDialogData
);
244 wxMessageBox(_T("There was a problem previewing.\nPerhaps your current printer is not set correctly?"), _T("Previewing"), wxOK
);
248 wxPreviewFrame
*frame
= new wxPreviewFrame(preview
, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
249 frame
->Centre(wxBOTH
);
254 void MyFrame::OnPageSetup(wxCommandEvent
& WXUNUSED(event
))
256 (*g_pageSetupData
) = *g_printData
;
258 wxPageSetupDialog
pageSetupDialog(this, g_pageSetupData
);
259 pageSetupDialog
.ShowModal();
261 (*g_printData
) = pageSetupDialog
.GetPageSetupDialogData().GetPrintData();
262 (*g_pageSetupData
) = pageSetupDialog
.GetPageSetupDialogData();
265 #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
266 void MyFrame::OnPrintPS(wxCommandEvent
& WXUNUSED(event
))
268 wxPostScriptPrinter
printer(g_printData
);
269 MyPrintout
printout(_T("My printout"));
270 printer
.Print(this, &printout
, true/*prompt*/);
272 (*g_printData
) = printer
.GetPrintData();
275 void MyFrame::OnPrintPreviewPS(wxCommandEvent
& WXUNUSED(event
))
277 // Pass two printout objects: for preview, and possible printing.
278 wxPrintDialogData
printDialogData(* g_printData
);
279 wxPrintPreview
*preview
= new wxPrintPreview(new MyPrintout
, new MyPrintout
, & printDialogData
);
280 wxPreviewFrame
*frame
= new wxPreviewFrame(preview
, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
281 frame
->Centre(wxBOTH
);
286 void MyFrame::OnPageSetupPS(wxCommandEvent
& WXUNUSED(event
))
288 (*g_pageSetupData
) = * g_printData
;
290 wxGenericPageSetupDialog
pageSetupDialog(this, g_pageSetupData
);
291 pageSetupDialog
.ShowModal();
293 (*g_printData
) = pageSetupDialog
.GetPageSetupDialogData().GetPrintData();
294 (*g_pageSetupData
) = pageSetupDialog
.GetPageSetupDialogData();
300 void MyFrame::OnPageMargins(wxCommandEvent
& WXUNUSED(event
))
302 (*g_pageSetupData
) = *g_printData
;
304 wxMacPageMarginsDialog
pageMarginsDialog(this, g_pageSetupData
);
305 pageMarginsDialog
.ShowModal();
307 (*g_printData
) = pageMarginsDialog
.GetPageSetupDialogData().GetPrintData();
308 (*g_pageSetupData
) = pageMarginsDialog
.GetPageSetupDialogData();
313 void MyFrame::OnPrintAbout(wxCommandEvent
& WXUNUSED(event
))
315 (void)wxMessageBox(_T("wxWidgets printing demo\nAuthor: Julian Smart"),
316 _T("About wxWidgets printing demo"), wxOK
|wxCENTRE
);
319 void MyFrame::OnAngleUp(wxCommandEvent
& WXUNUSED(event
))
325 void MyFrame::OnAngleDown(wxCommandEvent
& WXUNUSED(event
))
331 void MyFrame::Draw(wxDC
& dc
)
333 // This routine just draws a bunch of random stuff on the screen so that we
334 // can check that different types of object are being drawn consistently
335 // between the screen image, the print preview image (at various zoom
336 // levels), and the printed page.
337 dc
.SetBackground(*wxWHITE_BRUSH
);
339 dc
.SetFont(wxGetApp().m_testFont
);
341 // dc.SetBackgroundMode(wxTRANSPARENT);
343 dc
.SetPen(*wxBLACK_PEN
);
344 dc
.SetBrush(*wxLIGHT_GREY_BRUSH
);
346 dc
.DrawRectangle(0, 0, 230, 350);
347 dc
.DrawLine(0, 0, 229, 349);
348 dc
.DrawLine(229, 0, 0, 349);
349 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
351 dc
.SetBrush(*wxCYAN_BRUSH
);
352 dc
.SetPen(*wxRED_PEN
);
354 dc
.DrawRoundedRectangle(0, 20, 200, 80, 20);
356 dc
.DrawText( wxT("Rectangle 200 by 80"), 40, 40);
358 dc
.SetPen( wxPen(*wxBLACK
,0,wxDOT_DASH
) );
359 dc
.DrawEllipse(50, 140, 100, 50);
360 dc
.SetPen(*wxRED_PEN
);
362 dc
.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
365 const char *test
= "Hebrew שלום -- Japanese (日本語)";
366 wxString tmp
= wxConvUTF8
.cMB2WC( test
);
367 dc
.DrawText( tmp
, 10, 200 );
381 dc
.DrawPolygon( 5, points
, 20, 250, wxODDEVEN_RULE
);
382 dc
.DrawPolygon( 5, points
, 50, 250, wxWINDING_RULE
);
384 dc
.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 );
394 dc
.DrawSpline( 4, points
);
396 dc
.DrawArc( 20,10, 10,10, 25,40 );
400 str
.Printf( wxT("---- Text at angle %d ----"), i
);
401 dc
.DrawRotatedText( str
, 100, 300, i
);
404 str
.Printf( wxT("---- Text at angle %d ----"), i
);
405 dc
.DrawRotatedText( str
, 100, 300, i
);
407 wxIcon my_icon
= wxICON(mondrian
) ;
409 dc
.DrawIcon( my_icon
, 100, 100);
412 dc
.DrawBitmap( m_bitmap
, 10, 10 );
414 #if wxUSE_GRAPHICS_CONTEXT
415 wxGraphicsContext
*gc
= dc
.CreateGraphicsContext();
418 // make a path that contains a circle and some lines, centered at 100,100
419 gc
->SetPen( *wxRED_PEN
);
420 wxGraphicsPath path
= gc
->CreatePath();
421 path
.AddCircle( 50.0, 50.0, 50.0 );
422 path
.MoveToPoint(0.0, 50.0);
423 path
.AddLineToPoint(100.0, 50.0);
424 path
.MoveToPoint(50.0, 0.0);
425 path
.AddLineToPoint(50.0, 100.0 );
427 path
.AddRectangle(25.0, 25.0, 50.0, 50.0);
429 gc
->StrokePath(path
);
437 void MyFrame::OnSize(wxSizeEvent
& event
)
439 wxFrame::OnSize(event
);
442 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
443 EVT_MOUSE_EVENTS(MyCanvas::OnEvent
)
446 MyCanvas::MyCanvas(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
, long style
):
447 wxScrolledWindow(frame
, wxID_ANY
, pos
, size
, style
)
449 SetBackgroundColour(* wxWHITE
);
452 void MyCanvas::OnDraw(wxDC
& dc
)
457 void MyCanvas::OnEvent(wxMouseEvent
& WXUNUSED(event
))
461 bool MyPrintout::OnPrintPage(int page
)
471 // Draw page numbers at top left corner of printable area, sized so that
472 // screen size of text matches paper size.
473 MapScreenSizeToPage();
475 wxSprintf(buf
, wxT("PAGE %d"), page
);
476 dc
->DrawText(buf
, 0, 0);
484 bool MyPrintout::OnBeginDocument(int startPage
, int endPage
)
486 if (!wxPrintout::OnBeginDocument(startPage
, endPage
))
492 void MyPrintout::GetPageInfo(int *minPage
, int *maxPage
, int *selPageFrom
, int *selPageTo
)
500 bool MyPrintout::HasPage(int pageNum
)
502 return (pageNum
== 1 || pageNum
== 2);
505 void MyPrintout::DrawPageOne()
507 // You might use THIS code if you were scaling graphics of known size to fit
508 // on the page. The commented-out code illustrates different ways of scaling
511 // We know the graphic is 230x350. If we didn't know this, we'd need to
516 // This sets the user scale and origin of the DC so that the image fits
517 // within the paper rectangle (but the edges could be cut off by printers
518 // that can't print to the edges of the paper -- which is most of them. Use
519 // this if your image already has its own margins.
520 // FitThisSizeToPaper(wxSize(maxX, maxY));
521 // wxRect fitRect = GetLogicalPaperRect();
523 // This sets the user scale and origin of the DC so that the image fits
524 // within the page rectangle, which is the printable area on Mac and MSW
525 // and is the entire page on other platforms.
526 // FitThisSizeToPage(wxSize(maxX, maxY));
527 // wxRect fitRect = GetLogicalPageRect();
529 // This sets the user scale and origin of the DC so that the image fits
530 // within the page margins as specified by g_PageSetupData, which you can
531 // change (on some platforms, at least) in the Page Setup dialog. Note that
532 // on Mac, the native Page Setup dialog doesn't let you change the margins
533 // of a wxPageSetupDialogData object, so you'll have to write your own dialog or
534 // use the Mac-only wxMacPageMarginsDialog, as we do in this program.
535 FitThisSizeToPageMargins(wxSize(maxX
, maxY
), *g_pageSetupData
);
536 wxRect fitRect
= GetLogicalPageMarginsRect(*g_pageSetupData
);
538 // This sets the user scale and origin of the DC so that the image appears
539 // on the paper at the same size that it appears on screen (i.e., 10-point
540 // type on screen is 10-point on the printed page) and is positioned in the
541 // top left corner of the page rectangle (just as the screen image appears
542 // in the top left corner of the window).
543 // MapScreenSizeToPage();
544 // wxRect fitRect = GetLogicalPageRect();
546 // You could also map the screen image to the entire paper at the same size
547 // as it appears on screen.
548 // MapScreenSizeToPaper();
549 // wxRect fitRect = GetLogicalPaperRect();
551 // You might also wish to do you own scaling in order to draw objects at
552 // full native device resolution. In this case, you should do the following.
553 // Note that you can use the GetLogicalXXXRect() commands to obtain the
554 // appropriate rect to scale to.
555 // MapScreenSizeToDevice();
556 // wxRect fitRect = GetLogicalPageRect();
558 // Each of the preceding Fit or Map routines positions the origin so that
559 // the drawn image is positioned at the top left corner of the reference
560 // rectangle. You can easily center or right- or bottom-justify the image as
563 // This offsets the image so that it is centered within the reference
564 // rectangle defined above.
565 wxCoord xoff
= (fitRect
.width
- maxX
) / 2;
566 wxCoord yoff
= (fitRect
.height
- maxY
) / 2;
567 OffsetLogicalOrigin(xoff
, yoff
);
569 // This offsets the image so that it is positioned at the bottom right of
570 // the reference rectangle defined above.
571 // wxCoord xoff = (fitRect.width - maxX);
572 // wxCoord yoff = (fitRect.height - maxY);
573 // OffsetLogicalOrigin(xoff, yoff);
575 frame
->Draw(*GetDC());
578 void MyPrintout::DrawPageTwo()
580 // You might use THIS code to set the printer DC to ROUGHLY reflect
581 // the screen text size. This page also draws lines of actual length
584 // Compare this to DrawPageOne(), which uses the really convenient routines
585 // from wxPrintout to fit the screen image onto the printed page. This page
586 // illustrates how to do all the scaling calculations yourself, if you're so
591 // Get the logical pixels per inch of screen and printer
592 int ppiScreenX
, ppiScreenY
;
593 GetPPIScreen(&ppiScreenX
, &ppiScreenY
);
594 int ppiPrinterX
, ppiPrinterY
;
595 GetPPIPrinter(&ppiPrinterX
, &ppiPrinterY
);
597 // This scales the DC so that the printout roughly represents the the screen
598 // scaling. The text point size _should_ be the right size but in fact is
599 // too small for some reason. This is a detail that will need to be
600 // addressed at some point but can be fudged for the moment.
601 float scale
= (float)((float)ppiPrinterX
/(float)ppiScreenX
);
603 // Now we have to check in case our real page size is reduced (e.g. because
604 // we're drawing to a print preview memory DC)
605 int pageWidth
, pageHeight
;
608 GetPageSizePixels(&pageWidth
, &pageHeight
);
610 // If printer pageWidth == current DC width, then this doesn't change. But w
611 // might be the preview bitmap width, so scale down.
612 float overallScale
= scale
* (float)(w
/(float)pageWidth
);
613 dc
->SetUserScale(overallScale
, overallScale
);
615 // Calculate conversion factor for converting millimetres into logical
616 // units. There are approx. 25.4 mm to the inch. There are ppi device units
617 // to the inch. Therefore 1 mm corresponds to ppi/25.4 device units. We also
618 // divide by the screen-to-printer scaling factor, because we need to
619 // unscale to pass logical units to DrawLine.
621 // Draw 50 mm by 50 mm L shape
622 float logUnitsFactor
= (float)(ppiPrinterX
/(scale
*25.4));
623 float logUnits
= (float)(50*logUnitsFactor
);
624 dc
->SetPen(* wxBLACK_PEN
);
625 dc
->DrawLine(50, 250, (long)(50.0 + logUnits
), 250);
626 dc
->DrawLine(50, 250, 50, (long)(250.0 + logUnits
));
628 dc
->SetBackgroundMode(wxTRANSPARENT
);
629 dc
->SetBrush(*wxTRANSPARENT_BRUSH
);
631 { // GetTextExtent demo:
632 wxString words
[7] = {_T("This "), _T("is "), _T("GetTextExtent "), _T("testing "), _T("string. "), _T("Enjoy "), _T("it!")};
634 long x
= 200, y
= 250;
635 wxFont
fnt(15, wxSWISS
, wxNORMAL
, wxNORMAL
);
639 for (int i
= 0; i
< 7; i
++)
641 wxString word
= words
[i
];
642 word
.Remove( word
.Len()-1, 1 );
643 dc
->GetTextExtent(word
, &w
, &h
);
644 dc
->DrawRectangle(x
, y
, w
, h
);
645 dc
->GetTextExtent(words
[i
], &w
, &h
);
646 dc
->DrawText(words
[i
], x
, y
);
652 dc
->SetFont(wxGetApp().m_testFont
);
654 dc
->DrawText(_T("Some test text"), 200, 300 );
659 int rightMargin
= 20;
661 int bottomMargin
= 20;
663 int pageWidthMM
, pageHeightMM
;
664 GetPageSizeMM(&pageWidthMM
, &pageHeightMM
);
666 float leftMarginLogical
= (float)(logUnitsFactor
*leftMargin
);
667 float topMarginLogical
= (float)(logUnitsFactor
*topMargin
);
668 float bottomMarginLogical
= (float)(logUnitsFactor
*(pageHeightMM
- bottomMargin
));
669 float rightMarginLogical
= (float)(logUnitsFactor
*(pageWidthMM
- rightMargin
));
671 dc
->SetPen(* wxRED_PEN
);
672 dc
->DrawLine( (long)leftMarginLogical
, (long)topMarginLogical
,
673 (long)rightMarginLogical
, (long)topMarginLogical
);
674 dc
->DrawLine( (long)leftMarginLogical
, (long)bottomMarginLogical
,
675 (long)rightMarginLogical
, (long)bottomMarginLogical
);
677 WritePageHeader(this, dc
, _T("A header"), logUnitsFactor
);
680 // Writes a header on a page. Margin units are in millimetres.
681 bool WritePageHeader(wxPrintout
*printout
, wxDC
*dc
, const wxChar
*text
, float mmToLogical
)
684 static wxFont *headerFont = (wxFont *) NULL;
687 headerFont = wxTheFontList->FindOrCreateFont(16, wxSWISS, wxNORMAL, wxBOLD);
689 dc->SetFont(headerFont);
692 int pageWidthMM
, pageHeightMM
;
694 printout
->GetPageSizeMM(&pageWidthMM
, &pageHeightMM
);
695 wxUnusedVar(pageHeightMM
);
699 int rightMargin
= 10;
701 float leftMarginLogical
= (float)(mmToLogical
*leftMargin
);
702 float topMarginLogical
= (float)(mmToLogical
*topMargin
);
703 float rightMarginLogical
= (float)(mmToLogical
*(pageWidthMM
- rightMargin
));
705 wxCoord xExtent
, yExtent
;
706 dc
->GetTextExtent(text
, &xExtent
, &yExtent
);
707 float xPos
= (float)(((((pageWidthMM
- leftMargin
- rightMargin
)/2.0)+leftMargin
)*mmToLogical
) - (xExtent
/2.0));
708 dc
->DrawText(text
, (long)xPos
, (long)topMarginLogical
);
710 dc
->SetPen(* wxBLACK_PEN
);
711 dc
->DrawLine( (long)leftMarginLogical
, (long)(topMarginLogical
+yExtent
),
712 (long)rightMarginLogical
, (long)topMarginLogical
+yExtent
);