]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/printing/printing.cpp
Document ctors creating a wxString from repeated characters.
[wxWidgets.git] / samples / printing / printing.cpp
index 801bb72ab01c869ef076661121255e04f81eecea..735b36f3919ca41e7b1b2434cf494d7293bb2b5b 100644 (file)
@@ -117,7 +117,7 @@ bool MyApp::OnInit(void)
     // Create the main frame window
     // ----------------------------
 
-    MyFrame* frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets Printing Demo"),
+    MyFrame* frame = new MyFrame((wxFrame *) NULL, wxT("wxWidgets Printing Demo"),
                                  wxPoint(0, 0), wxSize(400, 400));
 
     frame->Centre(wxBOTH);
@@ -282,7 +282,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString&title, const wxPoint&pos, const
 #if wxUSE_STATUSBAR
     // Give us a status line
     CreateStatusBar(2);
-    SetStatusText(_T("Printing demo"));
+    SetStatusText(wxT("Printing demo"));
 #endif // wxUSE_STATUSBAR
 
     // Load icon and bitmap
@@ -291,12 +291,12 @@ MyFrame::MyFrame(wxFrame *frame, const wxString&title, const wxPoint&pos, const
     // Make a menubar
     wxMenu *file_menu = new wxMenu;
 
-    file_menu->Append(wxID_PRINT, _T("&Print..."),                 _T("Print"));
-    file_menu->Append(WXPRINT_PAGE_SETUP, _T("Page Set&up..."),    _T("Page setup"));
+    file_menu->Append(wxID_PRINT, wxT("&Print..."),                 wxT("Print"));
+    file_menu->Append(WXPRINT_PAGE_SETUP, wxT("Page Set&up..."),    wxT("Page setup"));
 #ifdef __WXMAC__
-    file_menu->Append(WXPRINT_PAGE_MARGINS, _T("Page Margins..."), _T("Page margins"));
+    file_menu->Append(WXPRINT_PAGE_MARGINS, wxT("Page Margins..."), wxT("Page margins"));
 #endif
-    file_menu->Append(wxID_PREVIEW, _T("Print Pre&view"),          _T("Preview"));
+    file_menu->Append(wxID_PREVIEW, wxT("Print Pre&view"),          wxT("Preview"));
 
 #if wxUSE_ACCEL
     // Accelerators
@@ -308,24 +308,24 @@ MyFrame::MyFrame(wxFrame *frame, const wxString&title, const wxPoint&pos, const
 
 #if defined(__WXMSW__) &&wxTEST_POSTSCRIPT_IN_MSW
     file_menu->AppendSeparator();
-    file_menu->Append(WXPRINT_PRINT_PS, _T("Print PostScript..."),           _T("Print (PostScript)"));
-    file_menu->Append(WXPRINT_PAGE_SETUP_PS, _T("Page Setup PostScript..."), _T("Page setup (PostScript)"));
-    file_menu->Append(WXPRINT_PREVIEW_PS, _T("Print Preview PostScript"),    _T("Preview (PostScript)"));
+    file_menu->Append(WXPRINT_PRINT_PS, wxT("Print PostScript..."),           wxT("Print (PostScript)"));
+    file_menu->Append(WXPRINT_PAGE_SETUP_PS, wxT("Page Setup PostScript..."), wxT("Page setup (PostScript)"));
+    file_menu->Append(WXPRINT_PREVIEW_PS, wxT("Print Preview PostScript"),    wxT("Preview (PostScript)"));
 #endif
 
     file_menu->AppendSeparator();
-    file_menu->Append(WXPRINT_ANGLEUP, _T("Angle up\tAlt-U"),                _T("Raise rotated text angle"));
-    file_menu->Append(WXPRINT_ANGLEDOWN, _T("Angle down\tAlt-D"),            _T("Lower rotated text angle"));
+    file_menu->Append(WXPRINT_ANGLEUP, wxT("Angle up\tAlt-U"),                wxT("Raise rotated text angle"));
+    file_menu->Append(WXPRINT_ANGLEDOWN, wxT("Angle down\tAlt-D"),            wxT("Lower rotated text angle"));
     file_menu->AppendSeparator();
-    file_menu->Append(wxID_EXIT, _T("E&xit"),                                _T("Exit program"));
+    file_menu->Append(wxID_EXIT, wxT("E&xit"),                                wxT("Exit program"));
 
     wxMenu *help_menu = new wxMenu;
-    help_menu->Append(wxID_ABOUT, _T("&About"),                              _T("About this demo"));
+    help_menu->Append(wxID_ABOUT, wxT("&About"),                              wxT("About this demo"));
 
     wxMenuBar *menu_bar = new wxMenuBar;
 
-    menu_bar->Append(file_menu, _T("&File"));
-    menu_bar->Append(help_menu, _T("&Help"));
+    menu_bar->Append(file_menu, wxT("&File"));
+    menu_bar->Append(help_menu, wxT("&Help"));
 
     // Associate the menu bar with the frame
     SetMenuBar(menu_bar);
@@ -351,13 +351,17 @@ void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
     wxPrintDialogData printDialogData(* g_printData);
 
     wxPrinter printer(&printDialogData);
-    MyPrintout printout(this, _T("My printout"));
+    MyPrintout printout(this, wxT("My printout"));
     if (!printer.Print(this, &printout, true /*prompt*/))
     {
         if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
-            wxLogError(_T("There was a problem printing. Perhaps your current printer is not set correctly?"));
+        {
+            wxLogError(wxT("There was a problem printing. Perhaps your current printer is not set correctly?"));
+        }
         else
-            wxLogMessage(_T("You canceled printing"));
+        {
+            wxLogMessage(wxT("You canceled printing"));
+        }
     }
     else
     {
@@ -374,12 +378,12 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
     if (!preview->IsOk())
     {
         delete preview;
-        wxLogError(_T("There was a problem previewing.\nPerhaps your current printer is not set correctly?"));
+        wxLogError(wxT("There was a problem previewing.\nPerhaps your current printer is not set correctly?"));
         return;
     }
 
     wxPreviewFrame *frame =
-        new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
+        new wxPreviewFrame(preview, this, wxT("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
     frame->Centre(wxBOTH);
     frame->Initialize();
     frame->Show();
@@ -400,7 +404,7 @@ void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
 void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
 {
     wxPostScriptPrinter printer(g_printData);
-    MyPrintout printout(_T("My printout"));
+    MyPrintout printout(wxT("My printout"));
     printer.Print(this, &printout, true/*prompt*/);
 
     (*g_printData) = printer.GetPrintData();
@@ -412,7 +416,7 @@ void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
     wxPrintDialogData printDialogData(* g_printData);
     wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, &printDialogData);
     wxPreviewFrame *frame =
-        new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
+        new wxPreviewFrame(preview, this, wxT("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650));
     frame->Centre(wxBOTH);
     frame->Initialize();
     frame->Show();
@@ -445,8 +449,8 @@ void MyFrame::OnPageMargins(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event))
 {
-    (void)wxMessageBox(_T("wxWidgets printing demo\nAuthor: Julian Smart"),
-                       _T("About wxWidgets printing demo"), wxOK|wxCENTRE);
+    (void)wxMessageBox(wxT("wxWidgets printing demo\nAuthor: Julian Smart"),
+                       wxT("About wxWidgets printing demo"), wxOK|wxCENTRE);
 }
 
 void MyFrame::OnAngleUp(wxCommandEvent& WXUNUSED(event))
@@ -658,8 +662,8 @@ void MyPrintout::DrawPageTwo()
     dc->SetBrush(*wxTRANSPARENT_BRUSH);
 
     { // GetTextExtent demo:
-        wxString words[7] = { _T("This "), _T("is "), _T("GetTextExtent "),
-                             _T("testing "), _T("string. "), _T("Enjoy "), _T("it!") };
+        wxString words[7] = { wxT("This "), wxT("is "), wxT("GetTextExtent "),
+                             wxT("testing "), wxT("string. "), wxT("Enjoy "), wxT("it!") };
         wxCoord w, h;
         long x = 200, y= 250;
         wxFont fnt(15, wxSWISS, wxNORMAL, wxNORMAL);
@@ -681,7 +685,7 @@ void MyPrintout::DrawPageTwo()
 
     dc->SetFont(wxGetApp().GetTestFont());
 
-    dc->DrawText(_T("Some test text"), 200, 300 );
+    dc->DrawText(wxT("Some test text"), 200, 300 );
 
     // TESTING
 
@@ -704,7 +708,7 @@ void MyPrintout::DrawPageTwo()
     dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical,
         (long)rightMarginLogical,  (long)bottomMarginLogical);
 
-    WritePageHeader(this, dc, _T("A header"), logUnitsFactor);
+    WritePageHeader(this, dc, wxT("A header"), logUnitsFactor);
 }
 
 // Writes a header on a page. Margin units are in millimetres.