mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 06:39:12 +02:00
Qt: Added devicecontext to TQtPrinter, some cleanups
git-svn-id: trunk@14981 -
This commit is contained in:
parent
d2156b2d40
commit
e31ded9715
@ -272,6 +272,7 @@ type
|
|||||||
public
|
public
|
||||||
{ Our own functions }
|
{ Our own functions }
|
||||||
constructor Create(AWidget: QWidgetH; const APaintEvent: Boolean = False); virtual;
|
constructor Create(AWidget: QWidgetH; const APaintEvent: Boolean = False); virtual;
|
||||||
|
constructor CreatePrinterContext(ADevice: QPrinterH); virtual;
|
||||||
constructor CreateFromPainter(APainter: QPainterH);
|
constructor CreateFromPainter(APainter: QPainterH);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure CreateObjects;
|
procedure CreateObjects;
|
||||||
@ -406,9 +407,7 @@ type
|
|||||||
|
|
||||||
TQtClipboard = class(TQtObject)
|
TQtClipboard = class(TQtObject)
|
||||||
private
|
private
|
||||||
// {$IFNDEF MSWINDOWS}
|
|
||||||
FClipDataChangedHook: QClipboard_hookH;
|
FClipDataChangedHook: QClipboard_hookH;
|
||||||
// {$ENDIF}
|
|
||||||
FClipChanged: Boolean;
|
FClipChanged: Boolean;
|
||||||
FClipBoardFormats: TStringList;
|
FClipBoardFormats: TStringList;
|
||||||
FOnClipBoardRequest: TClipboardRequestEvent;
|
FOnClipBoardRequest: TClipboardRequestEvent;
|
||||||
@ -442,7 +441,9 @@ type
|
|||||||
TQtPrinter = class(TQtObject)
|
TQtPrinter = class(TQtObject)
|
||||||
protected
|
protected
|
||||||
FHandle: QPrinterH;
|
FHandle: QPrinterH;
|
||||||
|
FPrinterContext: TQtDeviceContext;
|
||||||
private
|
private
|
||||||
|
function getPrinterContext: TQtDeviceContext;
|
||||||
function getCollateCopies: Boolean;
|
function getCollateCopies: Boolean;
|
||||||
function getColorMode: QPrinterColorMode;
|
function getColorMode: QPrinterColorMode;
|
||||||
function getCreator: WideString;
|
function getCreator: WideString;
|
||||||
@ -484,6 +485,10 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create; override;
|
constructor Create; override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
procedure beginDoc;
|
||||||
|
procedure endDoc;
|
||||||
|
|
||||||
function NewPage: Boolean;
|
function NewPage: Boolean;
|
||||||
function Abort: Boolean;
|
function Abort: Boolean;
|
||||||
procedure setFromPageToPage(Const AFromPage, AToPage: Integer);
|
procedure setFromPageToPage(Const AFromPage, AToPage: Integer);
|
||||||
@ -510,6 +515,7 @@ type
|
|||||||
property PageOrder: QPrinterPageOrder read getPageOrder write setPageOrder;
|
property PageOrder: QPrinterPageOrder read getPageOrder write setPageOrder;
|
||||||
property PageSize: QPrinterPageSize read getPageSize write setPageSize;
|
property PageSize: QPrinterPageSize read getPageSize write setPageSize;
|
||||||
property PaperSource: QPrinterPaperSource read getPaperSource write setPaperSource;
|
property PaperSource: QPrinterPaperSource read getPaperSource write setPaperSource;
|
||||||
|
property PrinterContext: TQtDeviceContext read getPrinterContext;
|
||||||
property PrinterName: WideString read getPrinterName write setPrinterName;
|
property PrinterName: WideString read getPrinterName write setPrinterName;
|
||||||
property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange;
|
property PrintRange: QPrinterPrintRange read getPrintRange write setPrintRange;
|
||||||
property PrinterState: QPrinterPrinterState read getPrinterState;
|
property PrinterState: QPrinterPrinterState read getPrinterState;
|
||||||
@ -658,12 +664,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function QtDefaultContext: TQtDeviceContext;
|
function QtDefaultContext: TQtDeviceContext;
|
||||||
begin
|
begin
|
||||||
if FDefaultContext = nil then
|
if FDefaultContext = nil then
|
||||||
FDefaultContext := TQtDeviceContext.Create(nil);
|
FDefaultContext := TQtDeviceContext.Create(nil, False);
|
||||||
Result := FDefaultContext;
|
Result := FDefaultContext;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -673,7 +677,7 @@ begin
|
|||||||
FScreenContext := TQtDeviceContext.Create(QApplication_desktop(), False);
|
FScreenContext := TQtDeviceContext.Create(QApplication_desktop(), False);
|
||||||
Result := FScreenContext;
|
Result := FScreenContext;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtObject }
|
{ TQtObject }
|
||||||
|
|
||||||
constructor TQtObject.Create;
|
constructor TQtObject.Create;
|
||||||
@ -1524,6 +1528,16 @@ begin
|
|||||||
FPenPos.Y := 0;
|
FPenPos.Y := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TQtDeviceContext.CreatePrinterContext(ADevice: QPrinterH);
|
||||||
|
begin
|
||||||
|
Parent := nil;
|
||||||
|
Widget := QPainter_Create(ADevice);
|
||||||
|
FOwnPainter := True;
|
||||||
|
CreateObjects;
|
||||||
|
FPenPos.X := 0;
|
||||||
|
FPenPos.Y := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TQtDeviceContext.CreateFromPainter(APainter: QPainterH);
|
constructor TQtDeviceContext.CreateFromPainter(APainter: QPainterH);
|
||||||
begin
|
begin
|
||||||
Widget := APainter;
|
Widget := APainter;
|
||||||
@ -2562,18 +2576,17 @@ end;
|
|||||||
function TQtClipboard.IsClipboardChanged: Boolean;
|
function TQtClipboard.IsClipboardChanged: Boolean;
|
||||||
var
|
var
|
||||||
ClipBord: TClipboard;
|
ClipBord: TClipboard;
|
||||||
AMimeData: QMimeDataH;
|
TempMimeData: QMimeDataH;
|
||||||
Str: WideString;
|
Str: WideString;
|
||||||
Str2: WideString;
|
Str2: WideString;
|
||||||
P: PChar;
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
AMimeData := getMimeData(QClipboardClipboard);
|
TempMimeData := getMimeData(QClipboardClipboard);
|
||||||
if (AMimeData <> nil) and
|
if (TempMimeData <> nil) and
|
||||||
(QMimeData_hasText(AMimeData) or QMimeData_hasHtml(AMimeData) or
|
(QMimeData_hasText(TempMimeData) or QMimeData_hasHtml(TempMimeData) or
|
||||||
QMimeData_hasURLS(AMimeData)) then
|
QMimeData_hasURLS(TempMimeData)) then
|
||||||
begin
|
begin
|
||||||
QMimeData_text(AMimeData, @Str);
|
QMimeData_text(TempMimeData, @Str);
|
||||||
Str := UTF8Encode(Str);
|
Str := UTF8Encode(Str);
|
||||||
|
|
||||||
{we must check for null terminator}
|
{we must check for null terminator}
|
||||||
@ -2771,6 +2784,31 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TQtPrinter.beginDoc;
|
||||||
|
begin
|
||||||
|
getPrinterContext;
|
||||||
|
if not QPainter_isActive(FPrinterContext.Widget) then
|
||||||
|
QPainter_begin(FPrinterContext.Widget, QtDefaultPrinter.Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TQtPrinter.endDoc;
|
||||||
|
begin
|
||||||
|
if FPrinterContext <> nil then
|
||||||
|
begin
|
||||||
|
if QPainter_isActive(FPrinterContext.Widget) then
|
||||||
|
QPainter_end(FPrinterContext.Widget);
|
||||||
|
FPrinterContext.Free;
|
||||||
|
FPrinterContext := nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TQtPrinter.getPrinterContext: TQtDeviceContext;
|
||||||
|
begin
|
||||||
|
if FPrinterContext = nil then
|
||||||
|
FPrinterContext := TQtDeviceContext.CreatePrinterContext(Handle);
|
||||||
|
Result := FPrinterContext;
|
||||||
|
end;
|
||||||
|
|
||||||
function TQtPrinter.getCollateCopies: Boolean;
|
function TQtPrinter.getCollateCopies: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := QPrinter_collateCopies(FHandle);
|
Result := QPrinter_collateCopies(FHandle);
|
||||||
|
Loading…
Reference in New Issue
Block a user