|
1 |
| -// @(#)root/gui:$Name: $:$Id: TRootCanvas.cxx,v 1.64 2004/12/07 01:38:14 rdm Exp $ |
| 1 | +// @(#)root/gui:$Name: $:$Id: TRootCanvas.cxx,v 1.65 2004/12/10 12:54:17 brun Exp $ |
2 | 2 | // Author: Fons Rademakers 15/01/98
|
3 | 3 |
|
4 | 4 | /*************************************************************************
|
|
31 | 31 | #include "TGWidget.h"
|
32 | 32 | #include "TGFileDialog.h"
|
33 | 33 | #include "TGStatusBar.h"
|
| 34 | +#include "TGTextEditDialogs.h" |
34 | 35 | #include "TROOT.h"
|
35 | 36 | #include "TSystem.h"
|
36 | 37 | #include "TCanvas.h"
|
@@ -165,6 +166,7 @@ static ToolBarData_t gToolBarData[] = {
|
165 | 166 | { "newcanvas.xpm", "New", kFALSE, kFileNewCanvas, NULL },
|
166 | 167 | { "open.xpm", "Open", kFALSE, kFileOpen, NULL },
|
167 | 168 | { "save.xpm", "Save As", kFALSE, kFileSaveAs, NULL },
|
| 169 | + { "printer.xpm", "Print", kFALSE, kFilePrint, NULL }, |
168 | 170 | { "", "", kFALSE, -1, NULL },
|
169 | 171 | { "interrupt.xpm", "Interrupt", kFALSE, kOptionInterrupt,NULL },
|
170 | 172 | { "refresh2.xpm", "Refresh", kFALSE, kOptionRefresh, NULL },
|
@@ -826,7 +828,7 @@ Bool_t TRootCanvas::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
|
826 | 828 | fCanvas->SaveAs(".jpg");
|
827 | 829 | break;
|
828 | 830 | case kFilePrint:
|
829 |
| - fCanvas->Print(); |
| 831 | + PrintCanvas(); |
830 | 832 | break;
|
831 | 833 | case kFileCloseCanvas:
|
832 | 834 | if (!fEditor && (TVirtualPadEditor::GetPadEditor(kFALSE) != 0))
|
@@ -1179,6 +1181,62 @@ void TRootCanvas::FitCanvas()
|
1179 | 1181 | }
|
1180 | 1182 | }
|
1181 | 1183 |
|
| 1184 | + |
| 1185 | + //______________________________________________________________________________ |
| 1186 | +void TRootCanvas::PrintCanvas() |
| 1187 | +{ |
| 1188 | + // Print the canvas. |
| 1189 | + |
| 1190 | + Int_t ret = 0; |
| 1191 | + Bool_t pname = kTRUE; |
| 1192 | + char *printer, *printCmd; |
| 1193 | + static TString sprinter, sprintCmd; |
| 1194 | + |
| 1195 | + if (sprinter == "") |
| 1196 | + printer = StrDup(gEnv->GetValue("Print.Printer", "")); |
| 1197 | + else |
| 1198 | + printer = StrDup(sprinter); |
| 1199 | + if (sprintCmd == "") |
| 1200 | +#ifndef WIN32 |
| 1201 | + printCmd = StrDup(gEnv->GetValue("Print.Command", "")); |
| 1202 | +#else |
| 1203 | + printCmd = StrDup(gEnv->GetValue("Print.Command", "start AcroRd32.exe /p")); |
| 1204 | +#endif |
| 1205 | + else |
| 1206 | + printCmd = StrDup(sprintCmd); |
| 1207 | + |
| 1208 | + new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150, |
| 1209 | + &printer, &printCmd, &ret); |
| 1210 | + if (ret) { |
| 1211 | + sprinter = printer; |
| 1212 | + sprintCmd = printCmd; |
| 1213 | + |
| 1214 | + if (sprinter == "") |
| 1215 | + pname = kFALSE; |
| 1216 | + |
| 1217 | + TString fn = gSystem->ConcatFileName(gSystem->TempDirectory(), "rootprintFile01.pdf"); |
| 1218 | + fCanvas->Print(fn); |
| 1219 | + |
| 1220 | + TString cmd = sprintCmd; |
| 1221 | + if (cmd.Contains("%p")) |
| 1222 | + cmd.ReplaceAll("%p", sprinter); |
| 1223 | + else if (pname) { |
| 1224 | + cmd += " "; cmd += sprinter; cmd += " "; |
| 1225 | + } |
| 1226 | + |
| 1227 | + if (cmd.Contains("%f")) |
| 1228 | + cmd.ReplaceAll("%f", fn); |
| 1229 | + else { |
| 1230 | + cmd += " "; cmd += fn; cmd += " "; |
| 1231 | + } |
| 1232 | + |
| 1233 | + gSystem->Exec(cmd); |
| 1234 | + gSystem->Unlink(fn); |
| 1235 | + } |
| 1236 | + delete [] printer; |
| 1237 | + delete [] printCmd; |
| 1238 | +} |
| 1239 | + |
1182 | 1240 | //______________________________________________________________________________
|
1183 | 1241 | void TRootCanvas::ShowMenuBar(Bool_t show)
|
1184 | 1242 | {
|
|
0 commit comments