Minor changes to printing sample.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -307,7 +307,7 @@ void MyFrame::Draw(wxDC& dc)
|
|||||||
dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
|
dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
char *test = "Greek (Ελληνικά) Γειά σας -- Hebrew שלום -- Japanese (日本語)";
|
char *test = "Hebrew שלום -- Japanese (日本語)";
|
||||||
wxString tmp = wxConvUTF8.cMB2WC( test );
|
wxString tmp = wxConvUTF8.cMB2WC( test );
|
||||||
dc.DrawText( tmp, 10, 200 );
|
dc.DrawText( tmp, 10, 200 );
|
||||||
#endif
|
#endif
|
||||||
@@ -366,7 +366,7 @@ bool MyPrintout::OnPrintPage(int page)
|
|||||||
|
|
||||||
wxChar buf[200];
|
wxChar buf[200];
|
||||||
wxSprintf(buf, wxT("PAGE %d"), page);
|
wxSprintf(buf, wxT("PAGE %d"), page);
|
||||||
// dc->DrawText(buf, 10, 10);
|
dc->DrawText(buf, 10, 10);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -397,10 +397,8 @@ bool MyPrintout::HasPage(int pageNum)
|
|||||||
|
|
||||||
void MyPrintout::DrawPageOne(wxDC *dc)
|
void MyPrintout::DrawPageOne(wxDC *dc)
|
||||||
{
|
{
|
||||||
/* You might use THIS code if you were scaling
|
// You might use THIS code if you were scaling
|
||||||
* graphics of known size to fit on the page.
|
// graphics of known size to fit on the page.
|
||||||
*/
|
|
||||||
int w, h;
|
|
||||||
|
|
||||||
// We know the graphic is 200x200. If we didn't know this,
|
// We know the graphic is 200x200. If we didn't know this,
|
||||||
// we'd need to calculate it.
|
// we'd need to calculate it.
|
||||||
@@ -416,6 +414,7 @@ void MyPrintout::DrawPageOne(wxDC *dc)
|
|||||||
maxY += (2*marginY);
|
maxY += (2*marginY);
|
||||||
|
|
||||||
// Get the size of the DC in pixels
|
// Get the size of the DC in pixels
|
||||||
|
int w, h;
|
||||||
dc->GetSize(&w, &h);
|
dc->GetSize(&w, &h);
|
||||||
|
|
||||||
// Calculate a suitable scaling factor
|
// Calculate a suitable scaling factor
|
||||||
@@ -432,17 +431,16 @@ void MyPrintout::DrawPageOne(wxDC *dc)
|
|||||||
// Set the scale and origin
|
// Set the scale and origin
|
||||||
dc->SetUserScale(actualScale, actualScale);
|
dc->SetUserScale(actualScale, actualScale);
|
||||||
dc->SetDeviceOrigin( (long)posX, (long)posY );
|
dc->SetDeviceOrigin( (long)posX, (long)posY );
|
||||||
//dc->SetUserScale(1.0, 1.0);
|
|
||||||
|
|
||||||
frame->Draw(*dc);
|
frame->Draw(*dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPrintout::DrawPageTwo(wxDC *dc)
|
void MyPrintout::DrawPageTwo(wxDC *dc)
|
||||||
{
|
{
|
||||||
/* You might use THIS code to set the printer DC to ROUGHLY reflect
|
// You might use THIS code to set the printer DC to ROUGHLY reflect
|
||||||
* the screen text size. This page also draws lines of actual length 5cm
|
// the screen text size. This page also draws lines of actual length
|
||||||
* on the page.
|
// 5cm on the page.
|
||||||
*/
|
|
||||||
// Get the logical pixels per inch of screen and printer
|
// Get the logical pixels per inch of screen and printer
|
||||||
int ppiScreenX, ppiScreenY;
|
int ppiScreenX, ppiScreenY;
|
||||||
GetPPIScreen(&ppiScreenX, &ppiScreenY);
|
GetPPIScreen(&ppiScreenX, &ppiScreenY);
|
||||||
@@ -494,9 +492,13 @@ void MyPrintout::DrawPageTwo(wxDC *dc)
|
|||||||
wxFont fnt(15, wxSWISS, wxNORMAL, wxNORMAL);
|
wxFont fnt(15, wxSWISS, wxNORMAL, wxNORMAL);
|
||||||
|
|
||||||
dc->SetFont(fnt);
|
dc->SetFont(fnt);
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++)
|
||||||
dc->GetTextExtent(words[i], &w, &h);
|
{
|
||||||
|
wxString word = words[i];
|
||||||
|
word.Remove( word.Len()-1, 1 );
|
||||||
|
dc->GetTextExtent(word, &w, &h);
|
||||||
dc->DrawRectangle(x, y, w, h);
|
dc->DrawRectangle(x, y, w, h);
|
||||||
|
dc->GetTextExtent(words[i], &w, &h);
|
||||||
dc->DrawText(words[i], x, y);
|
dc->DrawText(words[i], x, y);
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user