cocoa-printing: Now the print dialog shows

git-svn-id: trunk@47788 -
This commit is contained in:
sekelsenmat 2015-02-14 19:15:59 +00:00
parent f6d307d5c2
commit 7fbf0b2c70
4 changed files with 30 additions and 25 deletions

View File

@ -176,6 +176,8 @@ begin
end;
constructor TCocoaPrinter.Create;
var
FPrintViewRect: NSRect;
begin
inherited Create;

View File

@ -28,8 +28,7 @@ type
TCocoaPrinter = class(Printers.TPrinter)
private
FDefaultPrinter: String;
FPrintView: NSView;
FPrintViewRect: NSRect;
FPrintView: TCocoaPrinterView;
FPrintOp: NSPrintOperation;
FPrintInfo: NSPrintInfo;
@ -87,12 +86,12 @@ type
public
constructor Create; override;
function Write(const {%H-}Buffer; {%H-}Count:Integer; var {%H-}Written: Integer): Boolean; override;
// Warning not portable functions here
{property CurrentPrinterName: String read GetCurrentPrinterName;
property PrintSession: PMPrintSession read FPrintSession;
property PrintSettings: PMPrintSettings read FPrintSettings;
property PageFormat: PMPageFormat read FPageFormat;
// Warning it is a not portable property
property Handle: TCocoaPrinterContext read FPrinterContext;}
// Warning not portable properties here
//property CurrentPrinterName: String read GetCurrentPrinterName;
property PrintSession: PMPrintSession read GetPrintSession;
property PrintSettings: PMPrintSettings read GetPrintSettings;
property PageFormat: PMPageFormat read GetPageFormat;
property PrintOperation: NSPrintOperation read FPrintOp;
property PrintInfo: NSPrintInfo read FPrintInfo;
end;

View File

@ -40,27 +40,24 @@ end;
{ TPrintDialog }
function TPrintDialog.Execute: Boolean;
{var
CarbonPrinter: TCarbonPrinter;
var
CocoaPrinter: TCocoaPrinter;
DialogSettings: PMPrintSettings;
V: UInt32;
B: Boolean;
PMin, PMax, PFrom, PTo: Integer; }
PMin, PMax, PFrom, PTo: Integer;
begin
{ Result := False;
Result := False;
// TODO: Options, Title
if not Assigned(Printer) then Exit;
CarbonPrinter := Printer as TCarbonPrinter;
CocoaPrinter := Printer as TCocoaPrinter;
//DebugLn('TPrintDialog.Execute ' + CarbonPrinter.CurrentPrinterName);
DialogSettings:=nil;
if OSError(PMCreatePrintSettings(DialogSettings),
Self, SExecute, 'PMCreatePrintSettings') then Exit;
try
if OSError(PMCopyPrintSettings(CarbonPrinter.PrintSettings, DialogSettings),
Self, SExecute, 'PMCopyPrintSettings') then Exit;
//if PMCreatePrintSettings(DialogSettings) <> noErr then Exit;
//try
{if PMCopyPrintSettings(CocoaPrinter.PrintSettings, DialogSettings) <> noErr then Exit;
OSError(PMSetCollate(DialogSettings, Collate), Self, SExecute, 'PMSetCollate');
OSError(PMSetCopies(DialogSettings, Copies, False), Self, SExecute, 'PMSetCopies');
@ -79,9 +76,12 @@ begin
end;
if OSError(PMSessionPrintDialog(CarbonPrinter.PrintSession, DialogSettings, CarbonPrinter.PageFormat, Result),
Self, SExecute, 'PMSessionPrintDialog') then Exit;
Self, SExecute, 'PMSessionPrintDialog') then Exit;}
if Result then
//CocoaPrinter.PrintView.setBounds();
CocoaPrinter.PrintOperation.runOperation();
{if Result then
begin
B := Collate;
OSError(PMGetCollate(DialogSettings, B), Self, SExecute, 'PMGetCollate');
@ -110,8 +110,8 @@ begin
Self, SExecute, 'PMCopyPrintSettings') then Exit;
CarbonPrinter.UpdatePrinter;
end;
finally
end; }
{finally
PMRelease(PMObject(DialogSettings));
end; }
end;

View File

@ -13,7 +13,11 @@
------------------------------------------------------------------------------}
unit PrintersDlgs;
{$mode objfpc}{$H+}
{$mode objfpc}
{$IFDEF LCLCocoa}
{$modeswitch objectivec1}
{$ENDIF}
{$H+}
interface