mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:29:28 +02:00
+ printing support, currently win32 only
git-svn-id: trunk@1553 -
This commit is contained in:
parent
2dcefd968f
commit
3f77cccc7d
@ -143,6 +143,7 @@ const
|
||||
hidBreakpointDialogName = 208;
|
||||
hidRunDir = 209;
|
||||
hidBreakpointDialogCond = 210;
|
||||
hidPrinterDevice = 211;
|
||||
|
||||
{ Command constants }
|
||||
cmShowClipboard = 201;
|
||||
@ -191,14 +192,18 @@ const
|
||||
cmDoReload = 244;
|
||||
cmVectorRegisters = 245;
|
||||
|
||||
|
||||
{ in wviews.pas defined
|
||||
cmSelectAll = 246;
|
||||
cmUnselect = 247;
|
||||
}
|
||||
|
||||
cmPrint = 248;
|
||||
|
||||
cmNotImplemented = 1000;
|
||||
cmNewFromTemplate = 1001;
|
||||
cmShowReadme = 1002;
|
||||
cmPrinterSetup = 1003;
|
||||
|
||||
cmSearchWindow = 1500;
|
||||
cmSourceWndClosing = 1601;
|
||||
@ -415,6 +420,8 @@ const
|
||||
hcRegistersWindow = hcShift+cmRegisters;
|
||||
hcFPURegisters = hcShift+cmFPURegisters;
|
||||
hcVectorRegisters = hcShift+cmVectorRegisters;
|
||||
hcPrint = hcShift+cmPrint;
|
||||
hcPrinterSetup = hcShift+cmPrinterSetup;
|
||||
|
||||
hcOpenAtCursor = hcShift+cmOpenAtCursor;
|
||||
hcBrowseAtCursor = hcShift+cmBrowseAtCursor;
|
||||
|
@ -117,6 +117,8 @@ begin
|
||||
hcSave : S:=hint_filesave;
|
||||
hcSaveAs : S:=hint_filesaveas;
|
||||
hcSaveAll : S:=hint_filesaveall;
|
||||
hcPrint : S:=hint_print;
|
||||
hcPrinterSetup : S:=hint_printersetup;
|
||||
hcChangeDir : S:=hint_changedir;
|
||||
hcDOSShell : S:=hint_dosshell;
|
||||
hcQuit : S:=hint_exit;
|
||||
|
@ -58,6 +58,8 @@ type
|
||||
procedure NewFromTemplate;
|
||||
procedure OpenRecentFile(RecentIndex: integer);
|
||||
procedure ChangeDir;
|
||||
procedure Print;
|
||||
procedure PrinterSetup;
|
||||
procedure ShowClipboard;
|
||||
procedure FindProcedure;
|
||||
procedure Objects;
|
||||
@ -313,10 +315,13 @@ begin
|
||||
NewItem(menu_file_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
|
||||
NewItem(menu_file_saveall,'',kbNoKey,cmSaveAll,hcSaveAll,
|
||||
NewLine(
|
||||
NewItem(menu_file_print,'',kbNoKey,cmPrint,hcPrint,
|
||||
NewItem(menu_file_printsetup,'',kbNoKey,cmPrinterSetup,hcPrinterSetup,
|
||||
NewLine(
|
||||
NewItem(menu_file_changedir,'',kbNoKey,cmChangeDir,hcChangeDir,
|
||||
NewItem(menu_file_dosshell,'',kbNoKey,cmDOSShell,hcDOSShell,
|
||||
NewItem(menu_file_exit,menu_key_file_exit,kbNoKey,cmQuit,hcQuit,
|
||||
nil)))))))))))),
|
||||
nil))))))))))))))),
|
||||
NewSubMenu(menu_edit,hcEditMenu, NewMenu(
|
||||
NewItem(menu_edit_undo,menu_key_edit_undo, kbAltBack, cmUndo, hcUndo,
|
||||
NewItem(menu_edit_redo,'', kbNoKey, cmRedo, hcRedo,
|
||||
@ -663,6 +668,8 @@ begin
|
||||
end;
|
||||
OpenFileName:='';
|
||||
end;
|
||||
cmPrint : Print;
|
||||
cmPrinterSetup : PrinterSetup;
|
||||
cmSaveAll : SaveAll;
|
||||
cmChangeDir : ChangeDir;
|
||||
cmDOSShell : DOSShell;
|
||||
|
@ -26,6 +26,8 @@ procedure CheckINIFile;
|
||||
function ReadINIFile: boolean;
|
||||
function WriteINIFile(FromSaveAs : boolean) : boolean;
|
||||
|
||||
function GetPrinterDevice: string;
|
||||
procedure SetPrinterDevice(const Device: string);
|
||||
|
||||
implementation
|
||||
|
||||
@ -40,6 +42,22 @@ uses
|
||||
{$ifndef NODEBUG}FPDebug,{$endif}FPConst,FPVars,
|
||||
FPIntf,FPTools,FPSwitch,FPString;
|
||||
|
||||
const
|
||||
PrinterDevice : string = 'prn';
|
||||
|
||||
|
||||
function GetPrinterDevice: string;
|
||||
begin
|
||||
GetPrinterDevice:=PrinterDevice;
|
||||
end;
|
||||
|
||||
|
||||
procedure SetPrinterDevice(const Device: string);
|
||||
begin
|
||||
PrinterDevice:=Device;
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
{ INI file sections }
|
||||
secFiles = 'Files';
|
||||
@ -60,6 +78,7 @@ const
|
||||
|
||||
{ INI file tags }
|
||||
ieRecentFile = 'RecentFile';
|
||||
iePrinterDevice = 'PrinterDevice';
|
||||
(* ieOpenFile = 'OpenFile';
|
||||
ieOpenFileCount = 'OpenFileCount'; *)
|
||||
ieRunDir = 'RunDirectory';
|
||||
@ -351,6 +370,7 @@ begin
|
||||
{ Run }
|
||||
SetRunDir(INIFile^.GetEntry(secRun,ieRunDir,GetRunDir));
|
||||
SetRunParameters(INIFile^.GetEntry(secRun,ieRunParameters,GetRunParameters));
|
||||
SetPrinterDevice(INIFile^.GetEntry(secFiles,iePrinterDevice,GetPrinterDevice));
|
||||
{ First read the primary file, which can also set the parameters which can
|
||||
be overruled with the parameter loading }
|
||||
SetPrimaryFile(INIFile^.GetEntry(secCompile,iePrimaryFile,PrimaryFile));
|
||||
@ -548,6 +568,7 @@ begin
|
||||
{ Run }
|
||||
INIFile^.SetEntry(secRun,ieRunDir,GetRunDir);
|
||||
INIFile^.SetEntry(secRun,ieRunParameters,GetRunParameters);
|
||||
INIFile^.SetEntry(secFiles,iePrinterDevice,GetPrinterDevice);
|
||||
{ If DebuggeeTTY<>'' then }
|
||||
INIFile^.SetEntry(secRun,ieDebuggeeRedir,DebuggeeTTY);
|
||||
{$ifdef SUPPORT_REMOTE}
|
||||
|
@ -222,3 +222,67 @@ begin
|
||||
GetDir(0,StartUpDir);
|
||||
end;
|
||||
|
||||
|
||||
procedure TIDEApp.PrinterSetup;
|
||||
var R,R2: TRect;
|
||||
D: PCenterDialog;
|
||||
IL: PEditorInputLine;
|
||||
begin
|
||||
R.Assign(0,0,round(ScreenWidth*54/80),4);
|
||||
New(D, Init(R, dialog_setupprinter));
|
||||
with D^ do
|
||||
begin
|
||||
GetExtent(R); R.Grow(-2,-1); Inc(R.A.Y); R.B.Y:=R.A.Y+1;
|
||||
R2.Copy(R); R2.A.X:=16; Dec(R2.B.X,4);
|
||||
New(IL, Init(R2, 255));
|
||||
IL^.Data^:=GetPrinterDevice;
|
||||
Insert(IL);
|
||||
R2.Copy(R); R2.A.X:=R2.B.X-3; R2.B.X:=R2.A.X+3;
|
||||
Insert(New(PHistory, Init(R2, IL, hidPrinterDevice)));
|
||||
R2.Copy(R); R2.B.X:=16;
|
||||
Insert(New(PLabel, Init(R2, label_setupprinter_device, IL)));
|
||||
end;
|
||||
InsertButtons(D);
|
||||
IL^.Select;
|
||||
if Desktop^.ExecView(D)=cmOK then
|
||||
SetPrinterDevice(IL^.Data^);
|
||||
Dispose(D, Done);
|
||||
end;
|
||||
|
||||
|
||||
procedure TIDEApp.Print;
|
||||
var
|
||||
d : string;
|
||||
P : PSourceWindow;
|
||||
i : longint;
|
||||
f : text;
|
||||
begin
|
||||
d:=GetPrinterDevice;
|
||||
{ sanity check }
|
||||
if d='' then
|
||||
d:='prn';
|
||||
|
||||
P:=Message(Desktop,evBroadcast,cmSearchWindow,nil);
|
||||
if assigned(P) then
|
||||
begin
|
||||
assign(f,d);
|
||||
rewrite(f);
|
||||
if ioresult<>0 then
|
||||
begin
|
||||
MessageBox(#3+msg_PrintError,nil,mferror+mfokbutton);
|
||||
exit;
|
||||
end;
|
||||
for i:=0 to P^.Editor^.Core^.GetLineCount-1 do
|
||||
begin
|
||||
writeln(f,P^.Editor^.Core^.GetLineText(i));
|
||||
if ioresult<>0 then
|
||||
begin
|
||||
MessageBox(#3+msg_PrintError,nil,mferror+mfokbutton);
|
||||
close(f);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
write(f,#12);
|
||||
close(f);
|
||||
end;
|
||||
end;
|
||||
|
@ -53,6 +53,8 @@ const
|
||||
menu_file_saveas = 'Save ~a~s...';
|
||||
menu_file_saveall = 'Save a~l~l';
|
||||
menu_file_reload = '~R~eload';
|
||||
menu_file_print = '~P~rint';
|
||||
menu_file_printsetup = 'Print s~e~tup';
|
||||
menu_file_changedir = '~C~hange dir...';
|
||||
menu_file_dosshell = 'Comman~d~ shell';
|
||||
menu_file_exit = 'E~x~it';
|
||||
@ -269,6 +271,8 @@ const
|
||||
|
||||
msg_quitconfirm = 'Do You really want to quit?';
|
||||
|
||||
msg_printerror = 'Error while printing';
|
||||
|
||||
{ CodeComplete dialog }
|
||||
dialog_codecomplete = 'CodeComplete';
|
||||
label_codecomplete_keywords = '~K~eywords';
|
||||
@ -362,6 +366,9 @@ const
|
||||
dialog_programparameters = 'Program parameters';
|
||||
label_parameters_parameter = '~P~arameter';
|
||||
|
||||
dialog_setupprinter = 'Setup printer';
|
||||
label_setupprinter_device = '~D~evice';
|
||||
|
||||
dialog_openoptions = 'Open Options';
|
||||
msg_cantopenconfigfile = 'Can''t open config file.';
|
||||
msg_errorsavingconfigfile = 'Error saving config file.';
|
||||
@ -936,6 +943,8 @@ const
|
||||
hint_filesave = 'Save the file in the active edit window';
|
||||
hint_filesaveas = 'Save the current file under a different name, directory or drive';
|
||||
hint_filesaveall = 'Save all modified files';
|
||||
hint_print = 'Print current file';
|
||||
hint_printersetup = 'Setup printer output device';
|
||||
hint_changedir = 'Choose a new default directory';
|
||||
hint_dosshell = 'Temporarily exit to shell';
|
||||
hint_exit = 'Exit the IDE';
|
||||
|
Loading…
Reference in New Issue
Block a user