mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 10:59:14 +02:00
added sample for printing in RawMode
git-svn-id: trunk@10129 -
This commit is contained in:
parent
78ac6c89ab
commit
8075abcdf3
15
.gitattributes
vendored
15
.gitattributes
vendored
@ -291,11 +291,16 @@ components/printers/printer4lazarus.pas svneol=native#text/pascal
|
||||
components/printers/printersdlgs.lrs svneol=native#text/pascal
|
||||
components/printers/printersdlgs.pp svneol=native#text/pascal
|
||||
components/printers/readme.txt svneol=native#text/plain
|
||||
components/printers/sample/frmselprinter.lfm svneol=native#text/plain
|
||||
components/printers/sample/frmselprinter.lrs svneol=native#text/pascal
|
||||
components/printers/sample/frmselprinter.pas svneol=native#text/pascal
|
||||
components/printers/sample/selectprinter.lpi svneol=native#text/plain
|
||||
components/printers/sample/selectprinter.lpr svneol=native#text/pascal
|
||||
components/printers/samples/dialogs/frmselprinter.lfm svneol=native#text/plain
|
||||
components/printers/samples/dialogs/frmselprinter.lrs svneol=native#text/pascal
|
||||
components/printers/samples/dialogs/frmselprinter.pas svneol=native#text/pascal
|
||||
components/printers/samples/dialogs/selectprinter.lpi svneol=native#text/plain
|
||||
components/printers/samples/dialogs/selectprinter.lpr svneol=native#text/pascal
|
||||
components/printers/samples/rawmode/rawmodetest.lpi svneol=native#text/plain
|
||||
components/printers/samples/rawmode/rawmodetest.lpr svneol=native#text/pascal
|
||||
components/printers/samples/rawmode/unitmain.lfm svneol=native#text/plain
|
||||
components/printers/samples/rawmode/unitmain.lrs svneol=native#text/pascal
|
||||
components/printers/samples/rawmode/unitmain.pas svneol=native#text/pascal
|
||||
components/printers/unix/cupsdyn.pp svneol=native#text/pascal
|
||||
components/printers/unix/cupsprinters.inc svneol=native#text/pascal
|
||||
components/printers/unix/cupsprinters_h.inc svneol=native#text/pascal
|
||||
|
91
components/printers/samples/rawmode/rawmodetest.lpi
Normal file
91
components/printers/samples/rawmode/rawmodetest.lpi
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="5"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveClosedFiles Value="False"/>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="Printer4Lazarus"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="rawmodetest.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="rawmodetest"/>
|
||||
<CursorPos X="40" Y="17"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unitmain.pas"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ResourceFilename Value="unitmain.lrs"/>
|
||||
<UnitName Value="unitmain"/>
|
||||
<CursorPos X="21" Y="35"/>
|
||||
<TopLine Value="44"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="2">
|
||||
<Item1>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item2>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
18
components/printers/samples/rawmode/rawmodetest.lpr
Normal file
18
components/printers/samples/rawmode/rawmodetest.lpr
Normal file
@ -0,0 +1,18 @@
|
||||
program rawmodetest;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ add your units here }, unitmain, OsPrinters;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
57
components/printers/samples/rawmode/unitmain.lfm
Normal file
57
components/printers/samples/rawmode/unitmain.lfm
Normal file
@ -0,0 +1,57 @@
|
||||
object Form1: TForm1
|
||||
Left = 289
|
||||
Height = 240
|
||||
Top = 100
|
||||
Width = 242
|
||||
HorzScrollBar.Page = 241
|
||||
VertScrollBar.Page = 239
|
||||
Caption = 'RawMode Print Test'
|
||||
ClientHeight = 240
|
||||
ClientWidth = 242
|
||||
Constraints.MaxHeight = 240
|
||||
Constraints.MinHeight = 240
|
||||
OnCreate = FormCreate
|
||||
object Label1: TLabel
|
||||
Left = 15
|
||||
Height = 14
|
||||
Top = 5
|
||||
Width = 61
|
||||
Caption = 'Printers List:'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 11
|
||||
Height = 14
|
||||
Top = 150
|
||||
Width = 71
|
||||
Caption = 'String to print:'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object ListBox1: TListBox
|
||||
Left = 11
|
||||
Height = 115
|
||||
Top = 25
|
||||
Width = 220
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 11
|
||||
Height = 25
|
||||
Top = 205
|
||||
Width = 75
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Print'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Edit1: TEdit
|
||||
Left = 11
|
||||
Height = 23
|
||||
Top = 170
|
||||
Width = 219
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
19
components/printers/samples/rawmode/unitmain.lrs
Normal file
19
components/printers/samples/rawmode/unitmain.lrs
Normal file
@ -0,0 +1,19 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TForm1','FORMDATA',[
|
||||
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'!'#1#6'Height'#3#240#0#3'Top'#2'd'#5'Widt'
|
||||
+'h'#3#242#0#18'HorzScrollBar.Page'#3#241#0#18'VertScrollBar.Page'#3#239#0#7
|
||||
+'Caption'#6#18'RawMode Print Test'#12'ClientHeight'#3#240#0#11'ClientWidth'#3
|
||||
+#242#0#21'Constraints.MaxHeight'#3#240#0#21'Constraints.MinHeight'#3#240#0#8
|
||||
+'OnCreate'#7#10'FormCreate'#0#6'TLabel'#6'Label1'#4'Left'#2#15#6'Height'#2#14
|
||||
+#3'Top'#2#5#5'Width'#2'='#7'Caption'#6#14'Printers List:'#5'Color'#7#6'clNon'
|
||||
+'e'#11'ParentColor'#8#0#0#6'TLabel'#6'Label2'#4'Left'#2#11#6'Height'#2#14#3
|
||||
+'Top'#3#150#0#5'Width'#2'G'#7'Caption'#6#16'String to print:'#5'Color'#7#6'c'
|
||||
+'lNone'#11'ParentColor'#8#0#0#8'TListBox'#8'ListBox1'#4'Left'#2#11#6'Height'
|
||||
+#2's'#3'Top'#2#25#5'Width'#3#220#0#8'TabOrder'#2#0#0#0#7'TButton'#7'Button1'
|
||||
+#4'Left'#2#11#6'Height'#2#25#3'Top'#3#205#0#5'Width'#2'K'#25'BorderSpacing.I'
|
||||
+'nnerBorder'#2#4#7'Caption'#6#5'Print'#7'OnClick'#7#12'Button1Click'#8'TabOr'
|
||||
+'der'#2#1#0#0#5'TEdit'#5'Edit1'#4'Left'#2#11#6'Height'#2#23#3'Top'#3#170#0#5
|
||||
+'Width'#3#219#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrder'#2#2
|
||||
+#0#0#0
|
||||
]);
|
71
components/printers/samples/rawmode/unitmain.pas
Normal file
71
components/printers/samples/rawmode/unitmain.pas
Normal file
@ -0,0 +1,71 @@
|
||||
unit unitmain;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
Buttons, Printers;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Button1: TButton;
|
||||
Edit1: TEdit;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
ListBox1: TListBox;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// fill in the printer list
|
||||
Listbox1.Items.Assign(Printer.Printers);
|
||||
end;
|
||||
|
||||
procedure PrintRawString(const S:String);
|
||||
var
|
||||
Written: Integer;
|
||||
begin
|
||||
Printer.BeginDoc;
|
||||
Printer.Write(S[1], Length(S), Written);
|
||||
Printer.EndDoc;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
begin
|
||||
if Listbox1.ItemIndex<0 then begin
|
||||
ShowMessage('Select a printer from the list');
|
||||
exit;
|
||||
end;
|
||||
if Edit1.Text='' then begin
|
||||
ShowMessage('There is nothing to print!');
|
||||
exit;
|
||||
end;
|
||||
Printer.PrinterIndex := Listbox1.ItemIndex;
|
||||
Printer.Title := Caption;
|
||||
Printer.RawMode := True;
|
||||
PrintRawString(Edit1.Text);
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I unitmain.lrs}
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user