2017-01-27 17:37:51 +02:00
|
|
|
// ************************************************************************
|
|
|
|
// ***************************** CEF4Delphi *******************************
|
|
|
|
// ************************************************************************
|
|
|
|
//
|
2019-10-19 10:58:34 +02:00
|
|
|
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
2017-01-27 17:37:51 +02:00
|
|
|
// browser in Delphi applications.
|
|
|
|
//
|
|
|
|
// The original license of DCEF3 still applies to CEF4Delphi.
|
|
|
|
//
|
|
|
|
// For more information about CEF4Delphi visit :
|
|
|
|
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
|
|
|
//
|
2019-01-08 20:15:25 +02:00
|
|
|
// Copyright � 2019 Salvador Diaz Fau. All rights reserved.
|
2017-01-27 17:37:51 +02:00
|
|
|
//
|
|
|
|
// ************************************************************************
|
|
|
|
// ************ vvvv Original license and comments below vvvv *************
|
|
|
|
// ************************************************************************
|
|
|
|
(*
|
|
|
|
* Delphi Chromium Embedded 3
|
|
|
|
*
|
|
|
|
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
|
|
|
* or alternatively the restrictions of the Mozilla Public License 1.1
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
|
|
|
* the specific language governing rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
|
|
|
* Web site : http://www.progdigy.com
|
|
|
|
* Repository : http://code.google.com/p/delphichromiumembedded/
|
|
|
|
* Group : http://groups.google.com/group/delphichromiumembedded
|
|
|
|
*
|
|
|
|
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
|
|
|
* this source code without explicit permission.
|
|
|
|
*
|
|
|
|
*)
|
|
|
|
|
|
|
|
unit uCEFPrintSettings;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2018-11-22 16:02:21 +02:00
|
|
|
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
2017-01-27 17:37:51 +02:00
|
|
|
|
2017-02-05 21:56:46 +02:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2017-01-27 17:37:51 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 20:09:42 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 17:37:51 +02:00
|
|
|
|
|
|
|
type
|
2017-03-16 20:09:42 +02:00
|
|
|
TCefPrintSettingsRef = class(TCefBaseRefCountedRef, ICefPrintSettings)
|
2017-01-27 17:37:51 +02:00
|
|
|
protected
|
2018-03-29 20:02:04 +02:00
|
|
|
function IsValid: Boolean;
|
|
|
|
function IsReadOnly: Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetOrientation(landscape: Boolean);
|
2018-03-29 20:02:04 +02:00
|
|
|
function IsLandscape: Boolean;
|
|
|
|
procedure SetPrinterPrintableArea(const physicalSizeDeviceUnits: PCefSize; const printableAreaDeviceUnits: PCefRect; landscapeNeedsFlip: Boolean);
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetDeviceName(const name: ustring);
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetDeviceName: ustring;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetDpi(dpi: Integer);
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetDpi: Integer;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetPageRanges(const ranges: TCefRangeArray);
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetPageRangesCount: NativeUInt;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure GetPageRanges(out ranges: TCefRangeArray);
|
|
|
|
procedure SetSelectionOnly(selectionOnly: Boolean);
|
2018-03-29 20:02:04 +02:00
|
|
|
function IsSelectionOnly: Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetCollate(collate: Boolean);
|
2018-03-29 20:02:04 +02:00
|
|
|
function WillCollate: Boolean;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetColorModel(model: TCefColorModel);
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetColorModel: TCefColorModel;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetCopies(copies: Integer);
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetCopies: Integer;
|
2017-01-27 17:37:51 +02:00
|
|
|
procedure SetDuplexMode(mode: TCefDuplexMode);
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetDuplexMode: TCefDuplexMode;
|
2017-01-27 17:37:51 +02:00
|
|
|
public
|
|
|
|
class function New: ICefPrintSettings;
|
|
|
|
class function UnWrap(data: Pointer): ICefPrintSettings;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions;
|
|
|
|
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.GetColorModel: TCefColorModel;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.get_color_model(FData);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.GetCopies: Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.get_copies(FData);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.GetDeviceName: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefPrintSettings(FData)^.get_device_name(FData));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.GetDpi: Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.get_dpi(FData);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.GetDuplexMode: TCefDuplexMode;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.get_duplex_mode(FData);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
procedure TCefPrintSettingsRef.GetPageRanges(out ranges: TCefRangeArray);
|
2017-01-27 17:37:51 +02:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempLen : NativeUInt;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempLen := GetPageRangesCount;
|
|
|
|
SetLength(ranges, TempLen);
|
|
|
|
|
|
|
|
if (TempLen > 0) then PCefPrintSettings(FData)^.get_page_ranges(FData, @TempLen, @ranges[0]);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.GetPageRangesCount: NativeUInt;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.get_page_ranges_count(FData);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.IsLandscape: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.is_landscape(FData) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.IsReadOnly: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.is_read_only(FData) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.IsSelectionOnly: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.is_selection_only(FData) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.IsValid: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.is_valid(FData) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefPrintSettingsRef.New: ICefPrintSettings;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := UnWrap(cef_print_settings_create());
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetCollate(collate: Boolean);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_collate(FData, Ord(collate));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetColorModel(model: TCefColorModel);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_color_model(FData, model);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetCopies(copies: Integer);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_copies(FData, copies);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetDeviceName(const name: ustring);
|
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempName : TCefString;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempName := CefString(name);
|
|
|
|
PCefPrintSettings(FData)^.set_device_name(FData, @TempName);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetDpi(dpi: Integer);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_dpi(FData, dpi);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetDuplexMode(mode: TCefDuplexMode);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_duplex_mode(FData, mode);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetOrientation(landscape: Boolean);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_orientation(FData, Ord(landscape));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
procedure TCefPrintSettingsRef.SetPageRanges(const ranges: TCefRangeArray);
|
2017-01-27 17:37:51 +02:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempLen : NativeUInt;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempLen := Length(ranges);
|
|
|
|
|
|
|
|
if (TempLen > 0) then
|
|
|
|
PCefPrintSettings(FData)^.set_page_ranges(FData, TempLen, @ranges[0])
|
|
|
|
else
|
|
|
|
PCefPrintSettings(FData)^.set_page_ranges(FData, 0, nil);
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
procedure TCefPrintSettingsRef.SetPrinterPrintableArea(const physicalSizeDeviceUnits : PCefSize;
|
|
|
|
const printableAreaDeviceUnits : PCefRect;
|
|
|
|
landscapeNeedsFlip : Boolean);
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_printer_printable_area(FData,
|
|
|
|
physicalSizeDeviceUnits,
|
|
|
|
printableAreaDeviceUnits,
|
|
|
|
Ord(landscapeNeedsFlip));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPrintSettingsRef.SetSelectionOnly(selectionOnly: Boolean);
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefPrintSettings(FData)^.set_selection_only(FData, Ord(selectionOnly));
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
class function TCefPrintSettingsRef.UnWrap(data: Pointer): ICefPrintSettings;
|
2017-01-27 17:37:51 +02:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefPrintSettings
|
|
|
|
else
|
2017-01-27 17:37:51 +02:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPrintSettingsRef.WillCollate: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefPrintSettings(FData)^.will_collate(FData) <> 0;
|
2017-01-27 17:37:51 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|