made font a non-pointer; code cleanup
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
#if !wxUSE_PRINTING_ARCHITECTURE
|
||||
#error You must set wxUSE_PRINTING_ARCHITECTURE to 1 in setup.h to compile this demo.
|
||||
#error "You must set wxUSE_PRINTING_ARCHITECTURE to 1 in setup.h, and recompile the library."
|
||||
#endif
|
||||
|
||||
// Set this to 1 if you want to test PostScript printing under MSW.
|
||||
@@ -74,7 +74,7 @@ MyApp::MyApp()
|
||||
// main frame
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
m_testFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
m_testFont.Create(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
|
||||
g_printData = new wxPrintData;
|
||||
g_pageSetupData = new wxPageSetupDialogData;
|
||||
@@ -133,18 +133,17 @@ bool MyApp::OnInit(void)
|
||||
frame->canvas = canvas;
|
||||
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Show(TRUE);
|
||||
frame->Show();
|
||||
|
||||
frame->SetStatusText(_T("Printing demo"));
|
||||
|
||||
SetTopWindow(frame);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
int MyApp::OnExit()
|
||||
{
|
||||
delete wxGetApp().m_testFont;
|
||||
delete g_printData;
|
||||
delete g_pageSetupData;
|
||||
return 1;
|
||||
@@ -167,14 +166,14 @@ END_EVENT_TABLE()
|
||||
|
||||
// Define my frame constructor
|
||||
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
|
||||
wxFrame(frame, -1, title, pos, size)
|
||||
wxFrame(frame, wxID_ANY, title, pos, size)
|
||||
{
|
||||
canvas = (MyCanvas *) NULL;
|
||||
canvas = NULL;
|
||||
}
|
||||
|
||||
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close(TRUE);
|
||||
Close(true /*force closing*/);
|
||||
}
|
||||
|
||||
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -183,7 +182,7 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
wxPrinter printer(& printDialogData);
|
||||
MyPrintout printout(_T("My printout"));
|
||||
if (!printer.Print(this, &printout, TRUE))
|
||||
if (!printer.Print(this, &printout, true /*prompt*/))
|
||||
{
|
||||
if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
|
||||
wxMessageBox(_T("There was a problem printing.\nPerhaps your current printer is not set correctly?"), _T("Printing"), wxOK);
|
||||
@@ -211,7 +210,7 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
|
||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(TRUE);
|
||||
frame->Show();
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -219,7 +218,7 @@ void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
||||
wxPrintDialogData printDialogData(* g_printData);
|
||||
wxPrintDialog printerDialog(this, & printDialogData);
|
||||
|
||||
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
|
||||
printerDialog.GetPrintDialogData().SetSetupDialog(true /*show print setup dialog*/);
|
||||
printerDialog.ShowModal();
|
||||
|
||||
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
|
||||
@@ -241,7 +240,7 @@ void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxPostScriptPrinter printer(g_printData);
|
||||
MyPrintout printout(_T("My printout"));
|
||||
printer.Print(this, &printout, TRUE);
|
||||
printer.Print(this, &printout, true/*prompt*/);
|
||||
|
||||
(*g_printData) = printer.GetPrintData();
|
||||
}
|
||||
@@ -254,7 +253,7 @@ void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
|
||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(TRUE);
|
||||
frame->Show();
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -262,7 +261,7 @@ void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
|
||||
wxPrintDialogData printDialogData(* g_printData);
|
||||
wxGenericPrintDialog printerDialog(this, & printDialogData);
|
||||
|
||||
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
|
||||
printerDialog.GetPrintDialogData().SetSetupDialog(true /*show print setup dialog*/);
|
||||
printerDialog.ShowModal();
|
||||
|
||||
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
|
||||
@@ -291,7 +290,7 @@ void MyFrame::Draw(wxDC& dc)
|
||||
{
|
||||
dc.SetBackground(*wxWHITE_BRUSH);
|
||||
dc.Clear();
|
||||
dc.SetFont(* wxGetApp().m_testFont);
|
||||
dc.SetFont(wxGetApp().m_testFont);
|
||||
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
|
||||
@@ -332,7 +331,7 @@ END_EVENT_TABLE()
|
||||
|
||||
// Define a constructor for my canvas
|
||||
MyCanvas::MyCanvas(wxFrame *frame, const wxPoint& pos, const wxSize& size, long style):
|
||||
wxScrolledWindow(frame, -1, pos, size, style)
|
||||
wxScrolledWindow(frame, wxID_ANY, pos, size, style)
|
||||
{
|
||||
SetBackgroundColour(* wxWHITE);
|
||||
}
|
||||
@@ -368,18 +367,18 @@ bool MyPrintout::OnPrintPage(int page)
|
||||
wxSprintf(buf, wxT("PAGE %d"), page);
|
||||
dc->DrawText(buf, 10, 10);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MyPrintout::OnBeginDocument(int startPage, int endPage)
|
||||
{
|
||||
if (!wxPrintout::OnBeginDocument(startPage, endPage))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
|
||||
@@ -481,7 +480,6 @@ void MyPrintout::DrawPageTwo(wxDC *dc)
|
||||
dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250);
|
||||
dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits));
|
||||
|
||||
dc->SetFont(* wxGetApp().m_testFont);
|
||||
dc->SetBackgroundMode(wxTRANSPARENT);
|
||||
|
||||
|
||||
@@ -492,6 +490,7 @@ void MyPrintout::DrawPageTwo(wxDC *dc)
|
||||
wxFont fnt(15, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
|
||||
dc->SetFont(fnt);
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
wxString word = words[i];
|
||||
@@ -502,9 +501,11 @@ void MyPrintout::DrawPageTwo(wxDC *dc)
|
||||
dc->DrawText(words[i], x, y);
|
||||
x += w;
|
||||
}
|
||||
dc->SetFont(* wxGetApp().m_testFont);
|
||||
|
||||
}
|
||||
|
||||
dc->SetFont(wxGetApp().m_testFont);
|
||||
|
||||
dc->DrawText(_T("Some test text"), 200, 300 );
|
||||
|
||||
// TESTING
|
||||
@@ -564,5 +565,5 @@ dc->SetFont(headerFont);
|
||||
dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
|
||||
(long)rightMarginLogical, (long)topMarginLogical+yExtent );
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ class MyApp: public wxApp
|
||||
bool OnInit();
|
||||
int OnExit();
|
||||
|
||||
wxFont* m_testFont;
|
||||
wxFont m_testFont;
|
||||
};
|
||||
|
||||
DECLARE_APP(MyApp)
|
||||
|
Reference in New Issue
Block a user