diff --git a/.gitattributes b/.gitattributes index 09a1046d07..87975d9332 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/components/printers/sample/frmselprinter.lfm b/components/printers/samples/dialogs/frmselprinter.lfm similarity index 100% rename from components/printers/sample/frmselprinter.lfm rename to components/printers/samples/dialogs/frmselprinter.lfm diff --git a/components/printers/sample/frmselprinter.lrs b/components/printers/samples/dialogs/frmselprinter.lrs similarity index 100% rename from components/printers/sample/frmselprinter.lrs rename to components/printers/samples/dialogs/frmselprinter.lrs diff --git a/components/printers/sample/frmselprinter.pas b/components/printers/samples/dialogs/frmselprinter.pas similarity index 100% rename from components/printers/sample/frmselprinter.pas rename to components/printers/samples/dialogs/frmselprinter.pas diff --git a/components/printers/sample/selectprinter.lpi b/components/printers/samples/dialogs/selectprinter.lpi similarity index 100% rename from components/printers/sample/selectprinter.lpi rename to components/printers/samples/dialogs/selectprinter.lpi diff --git a/components/printers/sample/selectprinter.lpr b/components/printers/samples/dialogs/selectprinter.lpr similarity index 100% rename from components/printers/sample/selectprinter.lpr rename to components/printers/samples/dialogs/selectprinter.lpr diff --git a/components/printers/samples/rawmode/rawmodetest.lpi b/components/printers/samples/rawmode/rawmodetest.lpi new file mode 100644 index 0000000000..02e26752be --- /dev/null +++ b/components/printers/samples/rawmode/rawmodetest.lpi @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/printers/samples/rawmode/rawmodetest.lpr b/components/printers/samples/rawmode/rawmodetest.lpr new file mode 100644 index 0000000000..ca3cab8bea --- /dev/null +++ b/components/printers/samples/rawmode/rawmodetest.lpr @@ -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. + diff --git a/components/printers/samples/rawmode/unitmain.lfm b/components/printers/samples/rawmode/unitmain.lfm new file mode 100644 index 0000000000..6f385208e9 --- /dev/null +++ b/components/printers/samples/rawmode/unitmain.lfm @@ -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 diff --git a/components/printers/samples/rawmode/unitmain.lrs b/components/printers/samples/rawmode/unitmain.lrs new file mode 100644 index 0000000000..88a4017f2a --- /dev/null +++ b/components/printers/samples/rawmode/unitmain.lrs @@ -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 +]); diff --git a/components/printers/samples/rawmode/unitmain.pas b/components/printers/samples/rawmode/unitmain.pas new file mode 100644 index 0000000000..3098a661ad --- /dev/null +++ b/components/printers/samples/rawmode/unitmain.pas @@ -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. +