mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 04:16:10 +02:00
Turbopower_ipro: Improved print preview form.
git-svn-id: trunk@52057 -
This commit is contained in:
parent
7ea0992229
commit
03648e9dcf
@ -99,6 +99,10 @@ const
|
|||||||
FONTSIZESVALUSARRAY : array[0..6] of integer = (8,10,12,14,18,24,36);
|
FONTSIZESVALUSARRAY : array[0..6] of integer = (8,10,12,14,18,24,36);
|
||||||
MAXWORDS = 65536;
|
MAXWORDS = 65536;
|
||||||
|
|
||||||
|
ZOOM_TO_FIT = 0;
|
||||||
|
ZOOM_TO_FIT_WIDTH = -1;
|
||||||
|
ZOOM_TO_FIT_HEIGHT = -2;
|
||||||
|
|
||||||
type
|
type
|
||||||
{$IFDEF IP_LAZARUS}
|
{$IFDEF IP_LAZARUS}
|
||||||
TIpEnumItemsMethod = TLCLEnumItemsMethod;
|
TIpEnumItemsMethod = TLCLEnumItemsMethod;
|
||||||
@ -2235,7 +2239,7 @@ type
|
|||||||
PrintWidth, PrintHeight: Integer;
|
PrintWidth, PrintHeight: Integer;
|
||||||
PrintTopLeft: TPoint;
|
PrintTopLeft: TPoint;
|
||||||
PageCount: Integer;
|
PageCount: Integer;
|
||||||
function AntiAliasingMode: TAntiAliasingMode;
|
function PreviewAntiAliasingMode: TAntiAliasingMode;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
procedure InvalidateSize;
|
procedure InvalidateSize;
|
||||||
property Hyper : TIpHtml read FHyper write SetHtml;
|
property Hyper : TIpHtml read FHyper write SetHtml;
|
||||||
@ -2395,21 +2399,58 @@ type
|
|||||||
TIpHtmlControlEvent2 = procedure(Sender: TIpHtmlCustomPanel;
|
TIpHtmlControlEvent2 = procedure(Sender: TIpHtmlCustomPanel;
|
||||||
Frame: TIpHtmlFrame; Html: TIpHtml; Node: TIpHtmlNodeControl; var cancel: boolean) of object;
|
Frame: TIpHtmlFrame; Html: TIpHtml; Node: TIpHtmlNodeControl; var cancel: boolean) of object;
|
||||||
|
|
||||||
TIpHtmlPrintSettings = class(TPersistent)
|
TIpHtmlPreviewSettings = class(TPersistent)
|
||||||
private
|
private
|
||||||
FAntiAliasingMode: TAntiAliasingMode;
|
FAntiAliasingMode: TAntiAliasingMode;
|
||||||
|
FPosition: TPosition;
|
||||||
|
FMaximized: Boolean;
|
||||||
|
FLeft: Integer;
|
||||||
|
FTop: Integer;
|
||||||
|
FWidth: Integer;
|
||||||
|
FHeight: Integer;
|
||||||
|
FZoom: Integer;
|
||||||
|
private
|
||||||
|
function IsLeftStored: Boolean;
|
||||||
|
function IsHeightStored: Boolean;
|
||||||
|
function IsTopStored: Boolean;
|
||||||
|
function IsWidthStored: Boolean;
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
published
|
||||||
|
property AntiAliasingMode: TAntiAliasingMode
|
||||||
|
read FAntiAliasingMode write FAntiAliasingMode default amDontCare;
|
||||||
|
property Position: TPosition
|
||||||
|
read FPosition write FPosition default poScreenCenter;
|
||||||
|
property Maximized: Boolean
|
||||||
|
read FMaximized write FMaximized default false;
|
||||||
|
property Left: Integer
|
||||||
|
read FLeft write FLeft stored IsLeftStored;
|
||||||
|
property Top: Integer
|
||||||
|
read FTop write FTop stored IsTopStored;
|
||||||
|
property Width: Integer
|
||||||
|
read FWidth write FWidth stored IsWidthStored;
|
||||||
|
property Height: Integer
|
||||||
|
read FHeight write FHeight stored IsHeightStored;
|
||||||
|
property Zoom: integer
|
||||||
|
read FZoom write FZoom default 100;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TIpHtmlPrintSettings = class(TPersistent)
|
||||||
|
private
|
||||||
|
FPreview: TIpHtmlPreviewSettings;
|
||||||
FMarginTop: Double;
|
FMarginTop: Double;
|
||||||
FMarginLeft: Double;
|
FMarginLeft: Double;
|
||||||
FMarginBottom: Double;
|
FMarginBottom: Double;
|
||||||
FMarginRight: Double;
|
FMarginRight: Double;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
published
|
published
|
||||||
property AntiAliasingMode: TAntiAliasingMode read FAntiAliasingMode write FAntiAliasingMode;
|
|
||||||
property MarginLeft: Double read FMarginLeft write FMarginLeft;
|
property MarginLeft: Double read FMarginLeft write FMarginLeft;
|
||||||
property MarginTop: Double read FMarginTop write FMarginTop;
|
property MarginTop: Double read FMarginTop write FMarginTop;
|
||||||
property MarginRight: Double read FMarginRight write FMarginRight;
|
property MarginRight: Double read FMarginRight write FMarginRight;
|
||||||
property MarginBottom: Double read FMarginBottom write FMarginBottom;
|
property MarginBottom: Double read FMarginBottom write FMarginBottom;
|
||||||
|
property Preview: TIpHtmlPreviewSettings read FPreview write FPreview;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIpHtmlCustomPanel }
|
{ TIpHtmlCustomPanel }
|
||||||
@ -13324,9 +13365,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF Html_Print}
|
{$IFDEF Html_Print}
|
||||||
function TIpHtmlInternalPanel.AntiAliasingMode: TAntiAliasingMode;
|
function TIpHtmlInternalPanel.PreviewAntiAliasingMode: TAntiAliasingMode;
|
||||||
begin
|
begin
|
||||||
Result := HTMLPanel.PrintSettings.AntiAliasingMode;
|
Result := HTMLPanel.PrintSettings.Preview.AntiAliasingMode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlInternalPanel.BeginPrint;
|
procedure TIpHtmlInternalPanel.BeginPrint;
|
||||||
@ -13447,20 +13488,46 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlInternalPanel.PrintPreview;
|
procedure TIpHtmlInternalPanel.PrintPreview;
|
||||||
|
var
|
||||||
|
preview: TIpHtmlPreview;
|
||||||
|
p: TPosition;
|
||||||
begin
|
begin
|
||||||
if (Hyper <> nil) then begin
|
if (Hyper <> nil) then begin
|
||||||
BeginPrint;
|
BeginPrint;
|
||||||
try
|
try
|
||||||
|
|
||||||
with TIpHTMLPreview.Create(Application) do
|
preview := TIpHTMLPreview.Create(Application);
|
||||||
|
with preview do
|
||||||
try
|
try
|
||||||
|
p := HTMLPanel.PrintSettings.Preview.Position;
|
||||||
|
if (p = poDesigned) or (p = poDefaultSizeOnly) then begin
|
||||||
|
Left := HTMLPanel.PrintSettings.Preview.Left;
|
||||||
|
Top := HTMLPanel.PrintSettings.Preview.Top;
|
||||||
|
end;
|
||||||
|
if (p <> poDefault) and (p <> poDefaultSizeOnly) then begin
|
||||||
|
Width := HTMLPanel.PrintSettings.Preview.Width;
|
||||||
|
Height := HTMLPanel.PrintSettings.Preview.Height;
|
||||||
|
end;
|
||||||
|
Position := p;
|
||||||
|
if HTMLPanel.PrintSettings.Preview.Maximized then
|
||||||
|
WindowState := wsMaximized else
|
||||||
|
WindowState := wsNormal;
|
||||||
lblMaxPage.Caption := IntToStr(PageCount);
|
lblMaxPage.Caption := IntToStr(PageCount);
|
||||||
FCurPage := 1;
|
FCurPage := 1;
|
||||||
HTML := Hyper;
|
HTML := Hyper;
|
||||||
ScaleFonts := True;
|
ScaleFonts := True;
|
||||||
try
|
try
|
||||||
OwnerPanel := Self;
|
OwnerPanel := Self;
|
||||||
|
Zoom := HTMLPanel.PrintSettings.Preview.Zoom;
|
||||||
ShowModal;
|
ShowModal;
|
||||||
|
HTMLPanel.PrintSettings.Preview.Maximized := (WindowState = wsMaximized);
|
||||||
|
if (WindowState = wsNormal) and (p <> poDefault) and (p <> poDefaultSizeOnly)
|
||||||
|
then begin
|
||||||
|
HTMLPanel.PrintSettings.Preview.Left := Left;
|
||||||
|
HTMLPanel.PrintSettings.Preview.Top := Top;
|
||||||
|
HTMLPanel.PrintSettings.Preview.Width := Width;
|
||||||
|
HTMLPanel.PrintSettings.Preview.Height := Height;
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
ScaleFonts := False;
|
ScaleFonts := False;
|
||||||
end;
|
end;
|
||||||
@ -15851,17 +15918,61 @@ begin
|
|||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TIpHtmlPreviewSettings }
|
||||||
|
|
||||||
|
constructor TIpHtmlPreviewSettings.Create;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
FPosition := poScreenCenter;
|
||||||
|
FZoom := 100;
|
||||||
|
FWidth := Screen.Width * 3 div 4;
|
||||||
|
FHeight := Screen.Height * 3 div 4;
|
||||||
|
FLeft := Screen.Width div 4;
|
||||||
|
FTop := Screen.Height div 4;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIpHtmlPreviewSettings.IsLeftStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := ((FPosition = poDesigned) or (FPosition = poDefaultSizeOnly)) and
|
||||||
|
(FLeft <> Screen.Width div 4);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIpHtmlPreviewSettings.IsHeightStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := ((FPosition = poDesigned) or (FPosition = poDefaultPosOnly)) and
|
||||||
|
(FHeight <> Screen.Height * 3 div 4)
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIpHtmlPreviewSettings.IsTopStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := ((FPosition = poDesigned) or (FPosition = poDefaultSizeOnly)) and
|
||||||
|
(FTop <> Screen.Height div 4);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TIpHtmlPreviewSettings.IsWidthStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := ((FPosition = poDesigned) or (FPosition = poDefaultPosOnly)) and
|
||||||
|
(FWidth <> Screen.Width * 3 div 4)
|
||||||
|
end;
|
||||||
|
|
||||||
{ TIpHtmlPrintSettings }
|
{ TIpHtmlPrintSettings }
|
||||||
|
|
||||||
constructor TIpHtmlPrintSettings.Create;
|
constructor TIpHtmlPrintSettings.Create;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
FPreview := TIpHtmlPreviewSettings.Create;
|
||||||
FMarginLeft := DEFAULT_PRINTMARGIN;
|
FMarginLeft := DEFAULT_PRINTMARGIN;
|
||||||
FMarginTop := DEFAULT_PRINTMARGIN;
|
FMarginTop := DEFAULT_PRINTMARGIN;
|
||||||
FMarginRight := DEFAULT_PRINTMARGIN;
|
FMarginRight := DEFAULT_PRINTMARGIN;
|
||||||
FMarginBottom := DEFAULT_PRINTMARGIN;
|
FMarginBottom := DEFAULT_PRINTMARGIN;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TIpHtmlPrintSettings.Destroy;
|
||||||
|
begin
|
||||||
|
FPreview.Free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TIpHtmlNodeTH }
|
{ TIpHtmlNodeTH }
|
||||||
|
|
||||||
constructor TIpHtmlNodeTH.Create(ParentNode: TIpHtmlNode);
|
constructor TIpHtmlNodeTH.Create(ParentNode: TIpHtmlNode);
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
object IpHTMLPreview: TIpHTMLPreview
|
object IpHTMLPreview: TIpHTMLPreview
|
||||||
Left = 274
|
Left = 274
|
||||||
Height = 372
|
Height = 498
|
||||||
Top = 141
|
Top = 141
|
||||||
Width = 645
|
Width = 868
|
||||||
Caption = 'Print preview'
|
Caption = 'Print preview'
|
||||||
ClientHeight = 372
|
ClientHeight = 498
|
||||||
ClientWidth = 645
|
ClientWidth = 868
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
OnResize = FormResize
|
OnResize = FormResize
|
||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.7'
|
LCLVersion = '1.7'
|
||||||
object Panel1: TPanel
|
object ToolbarPanel: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 36
|
Height = 36
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 645
|
Width = 868
|
||||||
Align = alTop
|
Align = alTop
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 36
|
ClientHeight = 36
|
||||||
ClientWidth = 645
|
ClientWidth = 868
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
AnchorSideLeft.Control = btnPrev
|
AnchorSideLeft.Control = btnPrev
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 422
|
Left = 551
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 11
|
Top = 11
|
||||||
Width = 29
|
Width = 29
|
||||||
@ -39,9 +39,9 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
AnchorSideLeft.Control = edtPage
|
AnchorSideLeft.Control = edtPage
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 493
|
Left = 622
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 11
|
Top = 11
|
||||||
Width = 11
|
Width = 11
|
||||||
@ -52,9 +52,9 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
object lblMaxPage: TLabel
|
object lblMaxPage: TLabel
|
||||||
AnchorSideLeft.Control = Label2
|
AnchorSideLeft.Control = Label2
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 509
|
Left = 638
|
||||||
Height = 1
|
Height = 1
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 1
|
Width = 1
|
||||||
@ -64,7 +64,7 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
AnchorSideLeft.Control = btnSelectPrinter
|
AnchorSideLeft.Control = btnSelectPrinter
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 170
|
Left = 170
|
||||||
Height = 15
|
Height = 15
|
||||||
@ -75,7 +75,7 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object btnPrint: TButton
|
object btnPrint: TButton
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 25
|
Height = 25
|
||||||
@ -89,11 +89,11 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object btnFirst: TButton
|
object btnFirst: TButton
|
||||||
AnchorSideLeft.Control = btnClose
|
AnchorSideLeft.Control = btnFit
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 336
|
Left = 465
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 42
|
Width = 42
|
||||||
@ -101,14 +101,14 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
Caption = '<<'
|
Caption = '<<'
|
||||||
OnClick = btnFirstClick
|
OnClick = btnFirstClick
|
||||||
TabOrder = 1
|
TabOrder = 6
|
||||||
end
|
end
|
||||||
object btnPrev: TButton
|
object btnPrev: TButton
|
||||||
AnchorSideLeft.Control = btnFirst
|
AnchorSideLeft.Control = btnFirst
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 383
|
Left = 512
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 34
|
Width = 34
|
||||||
@ -116,14 +116,14 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
Caption = '<'
|
Caption = '<'
|
||||||
OnClick = btnPrevClick
|
OnClick = btnPrevClick
|
||||||
TabOrder = 2
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
object btnNext: TButton
|
object btnNext: TButton
|
||||||
AnchorSideLeft.Control = lblMaxPage
|
AnchorSideLeft.Control = lblMaxPage
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 515
|
Left = 644
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 34
|
Width = 34
|
||||||
@ -131,14 +131,14 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
Caption = '>'
|
Caption = '>'
|
||||||
OnClick = btnNextClick
|
OnClick = btnNextClick
|
||||||
TabOrder = 4
|
TabOrder = 9
|
||||||
end
|
end
|
||||||
object btnLast: TButton
|
object btnLast: TButton
|
||||||
AnchorSideLeft.Control = btnNext
|
AnchorSideLeft.Control = btnNext
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 554
|
Left = 683
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 42
|
Width = 42
|
||||||
@ -146,68 +146,43 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
Caption = '>>'
|
Caption = '>>'
|
||||||
OnClick = btnLastClick
|
OnClick = btnLastClick
|
||||||
TabOrder = 5
|
TabOrder = 10
|
||||||
end
|
end
|
||||||
object btnClose: TButton
|
object btnClose: TButton
|
||||||
AnchorSideLeft.Control = ZoomCombo
|
AnchorSideLeft.Control = btnLast
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 276
|
Left = 746
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 55
|
Width = 55
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
|
BorderSpacing.Left = 16
|
||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
Cancel = True
|
|
||||||
Caption = 'Close'
|
Caption = 'Close'
|
||||||
ModalResult = 2
|
ModalResult = 2
|
||||||
TabOrder = 6
|
TabOrder = 11
|
||||||
end
|
end
|
||||||
object edtPage: TEdit
|
object edtPage: TEdit
|
||||||
AnchorSideLeft.Control = Label1
|
AnchorSideLeft.Control = Label1
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 456
|
Left = 585
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 7
|
Top = 7
|
||||||
Width = 32
|
Width = 32
|
||||||
|
Alignment = taRightJustify
|
||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
OnChange = edtPageChange
|
OnChange = edtPageChange
|
||||||
TabOrder = 3
|
TabOrder = 8
|
||||||
Text = '1'
|
Text = '1'
|
||||||
end
|
end
|
||||||
object ZoomCombo: TComboBox
|
|
||||||
AnchorSideLeft.Control = Label3
|
|
||||||
AnchorSideLeft.Side = asrBottom
|
|
||||||
AnchorSideTop.Control = Panel1
|
|
||||||
AnchorSideTop.Side = asrCenter
|
|
||||||
Left = 210
|
|
||||||
Height = 23
|
|
||||||
Top = 7
|
|
||||||
Width = 61
|
|
||||||
BorderSpacing.Around = 5
|
|
||||||
ItemHeight = 15
|
|
||||||
Items.Strings = (
|
|
||||||
'10%'
|
|
||||||
'25%'
|
|
||||||
'50%'
|
|
||||||
'75%'
|
|
||||||
'100%'
|
|
||||||
'150%'
|
|
||||||
'200%'
|
|
||||||
'300%'
|
|
||||||
'400%'
|
|
||||||
)
|
|
||||||
OnChange = ZoomComboChange
|
|
||||||
Style = csDropDownList
|
|
||||||
TabOrder = 7
|
|
||||||
end
|
|
||||||
object btnSelectPrinter: TButton
|
object btnSelectPrinter: TButton
|
||||||
AnchorSideLeft.Control = btnPrint
|
AnchorSideLeft.Control = btnPrint
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel1
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 61
|
Left = 61
|
||||||
Height = 25
|
Height = 25
|
||||||
@ -217,21 +192,83 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
BorderSpacing.Around = 5
|
BorderSpacing.Around = 5
|
||||||
Caption = 'Select printer...'
|
Caption = 'Select printer...'
|
||||||
OnClick = btnSelectPrinterClick
|
OnClick = btnSelectPrinterClick
|
||||||
TabOrder = 8
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object edtZoom: TSpinEdit
|
||||||
|
AnchorSideLeft.Control = Label3
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 210
|
||||||
|
Height = 23
|
||||||
|
Top = 7
|
||||||
|
Width = 61
|
||||||
|
Alignment = taRightJustify
|
||||||
|
BorderSpacing.Around = 5
|
||||||
|
MaxValue = 1000
|
||||||
|
MinValue = 1
|
||||||
|
OnChange = edtZoomChange
|
||||||
|
TabOrder = 2
|
||||||
|
Value = 100
|
||||||
|
end
|
||||||
|
object btnFitHeight: TButton
|
||||||
|
AnchorSideLeft.Control = edtZoom
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 276
|
||||||
|
Height = 25
|
||||||
|
Top = 6
|
||||||
|
Width = 62
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 5
|
||||||
|
Caption = 'Height'
|
||||||
|
OnClick = btnFitHeightClick
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
object btnFitWidth: TButton
|
||||||
|
AnchorSideLeft.Control = btnFitHeight
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 343
|
||||||
|
Height = 25
|
||||||
|
Top = 6
|
||||||
|
Width = 58
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 5
|
||||||
|
Caption = 'Width'
|
||||||
|
OnClick = btnFitWidthClick
|
||||||
|
TabOrder = 4
|
||||||
|
end
|
||||||
|
object btnFit: TButton
|
||||||
|
AnchorSideLeft.Control = btnFitWidth
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = ToolbarPanel
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 406
|
||||||
|
Height = 25
|
||||||
|
Top = 6
|
||||||
|
Width = 54
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 5
|
||||||
|
Caption = 'Fit all'
|
||||||
|
OnClick = btnFitClick
|
||||||
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object ScrollBox1: TScrollBox
|
object ScrollBox1: TScrollBox
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 336
|
Height = 462
|
||||||
Top = 36
|
Top = 36
|
||||||
Width = 645
|
Width = 868
|
||||||
HorzScrollBar.Page = 158
|
HorzScrollBar.Page = 158
|
||||||
HorzScrollBar.Tracking = True
|
HorzScrollBar.Tracking = True
|
||||||
VertScrollBar.Page = 125
|
VertScrollBar.Page = 125
|
||||||
VertScrollBar.Tracking = True
|
VertScrollBar.Tracking = True
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ClientHeight = 332
|
ClientHeight = 458
|
||||||
ClientWidth = 641
|
ClientWidth = 864
|
||||||
Color = clBtnFace
|
Color = clBtnFace
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
@ -241,8 +278,9 @@ object IpHTMLPreview: TIpHTMLPreview
|
|||||||
Top = 0
|
Top = 0
|
||||||
Width = 158
|
Width = 158
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 125
|
BorderStyle = bsSingle
|
||||||
ClientWidth = 158
|
ClientHeight = 121
|
||||||
|
ClientWidth = 154
|
||||||
Color = clWhite
|
Color = clWhite
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
@ -48,13 +48,16 @@ uses
|
|||||||
Windows,
|
Windows,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||||
StdCtrls, ExtCtrls, IpHtml;
|
StdCtrls, ExtCtrls, Spin, IpHtml;
|
||||||
|
|
||||||
resourcestring
|
resourcestring
|
||||||
rsIpHTMLPreviewPrintPreview = 'Print preview';
|
rsIpHTMLPreviewPrintPreview = 'Print preview';
|
||||||
rsIpHTMLPreviewPrint = 'Print';
|
rsIpHTMLPreviewPrint = 'Print';
|
||||||
rsIpHTMLPreviewZoom = 'Zoom:';
|
rsIpHTMLPreviewZoom = 'Zoom:';
|
||||||
rsIpHTMLPreviewClose = 'Close';
|
rsIpHTMLPreviewClose = 'Close';
|
||||||
|
rsIpHTMLPreviewFitAll = 'Fit all';
|
||||||
|
rsIpHTMLPreviewFitWidth = 'Width';
|
||||||
|
rsIpHTMLPreviewFitHeight = 'Height';
|
||||||
rsIpHTMLPreviewPage = 'Page:';
|
rsIpHTMLPreviewPage = 'Page:';
|
||||||
rsIpHTMLPreviewOf = 'of';
|
rsIpHTMLPreviewOf = 'of';
|
||||||
rsIpHTMLPreviewSelectPrinter = 'Select printer ...';
|
rsIpHTMLPreviewSelectPrinter = 'Select printer ...';
|
||||||
@ -64,23 +67,15 @@ type
|
|||||||
{ TIpHTMLPreview }
|
{ TIpHTMLPreview }
|
||||||
|
|
||||||
TIpHTMLPreview = class(TForm)
|
TIpHTMLPreview = class(TForm)
|
||||||
|
btnFitHeight: TButton;
|
||||||
|
btnFitWidth: TButton;
|
||||||
|
btnFit: TButton;
|
||||||
btnSelectPrinter: TButton;
|
btnSelectPrinter: TButton;
|
||||||
Label3: TLabel;
|
Label3: TLabel;
|
||||||
ZoomCombo: TComboBox;
|
|
||||||
PaperPanel: TPanel;
|
PaperPanel: TPanel;
|
||||||
PaintBox1: TPaintBox;
|
PaintBox1: TPaintBox;
|
||||||
procedure btnNextClick(Sender: TObject);
|
edtZoom: TSpinEdit;
|
||||||
procedure btnLastClick(Sender: TObject);
|
ToolbarPanel: TPanel;
|
||||||
procedure btnSelectPrinterClick(Sender: TObject);
|
|
||||||
procedure edtPageChange(Sender: TObject);
|
|
||||||
procedure btnPrintClick(Sender: TObject);
|
|
||||||
procedure PaintBox1Paint(Sender: TObject);
|
|
||||||
procedure FormDestroy(Sender: TObject);
|
|
||||||
procedure ZoomComboChange(Sender: TObject);
|
|
||||||
procedure FormCreate(Sender: TObject);
|
|
||||||
procedure FormResize(Sender: TObject);
|
|
||||||
published
|
|
||||||
Panel1: TPanel;
|
|
||||||
btnPrint: TButton;
|
btnPrint: TButton;
|
||||||
btnFirst: TButton;
|
btnFirst: TButton;
|
||||||
btnPrev: TButton;
|
btnPrev: TButton;
|
||||||
@ -92,32 +87,50 @@ type
|
|||||||
Label2: TLabel;
|
Label2: TLabel;
|
||||||
lblMaxPage: TLabel;
|
lblMaxPage: TLabel;
|
||||||
ScrollBox1: TScrollBox;
|
ScrollBox1: TScrollBox;
|
||||||
procedure FormShow(Sender: TObject);
|
|
||||||
procedure btnFirstClick(Sender: TObject);
|
procedure btnFirstClick(Sender: TObject);
|
||||||
|
procedure btnFitClick(Sender: TObject);
|
||||||
|
procedure btnFitHeightClick(Sender: TObject);
|
||||||
|
procedure btnFitWidthClick(Sender: TObject);
|
||||||
|
procedure btnLastClick(Sender: TObject);
|
||||||
|
procedure btnNextClick(Sender: TObject);
|
||||||
procedure btnPrevClick(Sender: TObject);
|
procedure btnPrevClick(Sender: TObject);
|
||||||
procedure SetCurPage(const Value: Integer);
|
procedure btnPrintClick(Sender: TObject);
|
||||||
protected
|
procedure btnSelectPrinterClick(Sender: TObject);
|
||||||
|
procedure edtPageChange(Sender: TObject);
|
||||||
|
procedure edtZoomChange(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure FormDestroy(Sender: TObject);
|
||||||
|
procedure FormResize(Sender: TObject);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure PaintBox1Paint(Sender: TObject);
|
||||||
|
private
|
||||||
FClipRect, SourceRect: TRect;
|
FClipRect, SourceRect: TRect;
|
||||||
Scratch: TBitmap;
|
Scratch: TBitmap;
|
||||||
FScale: double;
|
FScale: double;
|
||||||
FZoom: Integer;
|
FZoom: Integer;
|
||||||
|
FZoomToFit: Integer;
|
||||||
|
FLockZoomUpdate: Integer;
|
||||||
|
procedure SetCurPage(const Value: Integer);
|
||||||
procedure SetZoom(const Value: Integer);
|
procedure SetZoom(const Value: Integer);
|
||||||
procedure ResizeCanvas;
|
protected
|
||||||
procedure ScaleSourceRect;
|
|
||||||
procedure AlignPaintBox;
|
procedure AlignPaintBox;
|
||||||
procedure Render;
|
procedure Render;
|
||||||
|
procedure ResizeCanvas;
|
||||||
|
procedure ScaleSourceRect;
|
||||||
|
procedure UpdateBtnStates;
|
||||||
public
|
public
|
||||||
FCurPage: Integer;
|
FCurPage: Integer;
|
||||||
HTML : TIpHtml;
|
HTML : TIpHtml;
|
||||||
PageRect: TRect;
|
PageRect: TRect;
|
||||||
OwnerPanel: TIpHtmlInternalPanel;
|
OwnerPanel: TIpHtmlInternalPanel;
|
||||||
|
procedure RenderPage(PageNo: Integer);
|
||||||
property ClipRect: TRect read FClipRect write FClipRect;
|
property ClipRect: TRect read FClipRect write FClipRect;
|
||||||
property CurPage: Integer read FCurPage write SetCurPage;
|
property CurPage: Integer read FCurPage write SetCurPage;
|
||||||
procedure RenderPage(PageNo: Integer);
|
|
||||||
property Zoom: Integer read FZoom write SetZoom;
|
|
||||||
property Scale: double read FScale;
|
property Scale: double read FScale;
|
||||||
|
property Zoom: Integer read FZoom write SetZoom;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -132,22 +145,23 @@ uses
|
|||||||
const
|
const
|
||||||
SCRATCH_WIDTH = 800; //640;
|
SCRATCH_WIDTH = 800; //640;
|
||||||
SCRATCH_HEIGHT = 600; //480;
|
SCRATCH_HEIGHT = 600; //480;
|
||||||
|
ZOOM_FACTOR = 1.1;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.FormShow(Sender: TObject);
|
procedure TIpHTMLPreview.AlignPaintBox;
|
||||||
begin
|
|
||||||
Zoom := 100;
|
|
||||||
RenderPage(CurPage);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIpHTMLPreview.RenderPage(PageNo: Integer);
|
|
||||||
var
|
var
|
||||||
CR : TRect;
|
sb: Integer;
|
||||||
begin
|
begin
|
||||||
CR := Rect(0, 0, OwnerPanel.PrintWidth, 0);
|
sb := GetSystemMetrics(SM_CXVSCROLL);
|
||||||
CR.Top := (PageNo - 1) * OwnerPanel.PrintHeight;
|
if PaperPanel.Width < ClientWidth - sb then
|
||||||
CR.Bottom := Cr.Top + OwnerPanel.PrintHeight;
|
PaperPanel.Left := (ClientWidth - sb - PaperPanel.Width) div 2
|
||||||
PageRect := CR;
|
else
|
||||||
PaintBox1.Invalidate;
|
PaperPanel.Left := 0;
|
||||||
|
|
||||||
|
sb := GetSystemMetrics(SM_CXHSCROLL);
|
||||||
|
if PaperPanel.Height < ClientHeight - sb - ToolbarPanel.Height then
|
||||||
|
PaperPanel.Top := (ClientHeight - sb - ToolbarPanel.Height - PaperPanel.Height) div 2
|
||||||
|
else
|
||||||
|
PaperPanel.Top := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.btnFirstClick(Sender: TObject);
|
procedure TIpHTMLPreview.btnFirstClick(Sender: TObject);
|
||||||
@ -155,25 +169,19 @@ begin
|
|||||||
CurPage := 1;
|
CurPage := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.btnPrevClick(Sender: TObject);
|
procedure TIpHTMLPreview.btnFitClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
CurPage := CurPage - 1;
|
SetZoom(ZOOM_TO_FIT);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.SetCurPage(const Value: Integer);
|
procedure TIpHTMLPreview.btnFitHeightClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if (Value <> FCurPage)
|
SetZoom(ZOOM_TO_FIT_HEIGHT);
|
||||||
and (Value >= 1)
|
|
||||||
and (Value <= OwnerPanel.PageCount) then begin
|
|
||||||
FCurPage := Value;
|
|
||||||
RenderPage(Value);
|
|
||||||
edtPage.Text := IntToStr(CurPage);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.btnNextClick(Sender: TObject);
|
procedure TIpHTMLPreview.btnFitWidthClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
CurPage := CurPage + 1;
|
SetZoom(ZOOM_TO_FIT_WIDTH);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.btnLastClick(Sender: TObject);
|
procedure TIpHTMLPreview.btnLastClick(Sender: TObject);
|
||||||
@ -181,6 +189,16 @@ begin
|
|||||||
CurPage := OwnerPanel.PageCount;
|
CurPage := OwnerPanel.PageCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.btnNextClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CurPage := CurPage + 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.btnPrevClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CurPage := CurPage - 1;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.btnSelectPrinterClick(Sender: TObject);
|
procedure TIpHTMLPreview.btnSelectPrinterClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if OwnerPanel <> nil then
|
if OwnerPanel <> nil then
|
||||||
@ -188,11 +206,6 @@ begin
|
|||||||
SetZoom(Zoom); {force recalc of preview sizes}
|
SetZoom(Zoom); {force recalc of preview sizes}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.edtPageChange(Sender: TObject);
|
|
||||||
begin
|
|
||||||
CurPage := StrToInt(edtPage.Text);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIpHTMLPreview.btnPrintClick(Sender: TObject);
|
procedure TIpHTMLPreview.btnPrintClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Screen.Cursor := crHourglass;
|
Screen.Cursor := crHourglass;
|
||||||
@ -206,12 +219,68 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.ScaleSourceRect;
|
procedure TIpHTMLPreview.edtPageChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
SourceRect.Left := round(SourceRect.Left / Scale);
|
CurPage := StrToInt(edtPage.Text);
|
||||||
SourceRect.Top := round(SourceRect.Top / Scale);
|
end;
|
||||||
SourceRect.Right := round(SourceRect.Right / Scale);
|
|
||||||
SourceRect.Bottom := round(SourceRect.Bottom / Scale);
|
procedure TIpHTMLPreview.edtZoomChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
newZoom: Double;
|
||||||
|
begin
|
||||||
|
if (FLockZoomUpdate = 0) and TryStrToFloat(edtZoom.Text, newZoom) then
|
||||||
|
SetZoom(Round(newZoom));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FZoom := 100;
|
||||||
|
FZoomToFit := ZOOM_TO_FIT;
|
||||||
|
Scratch := TBitmap.Create;
|
||||||
|
Scratch.Width := SCRATCH_WIDTH;
|
||||||
|
Scratch.Height := SCRATCH_HEIGHT;
|
||||||
|
|
||||||
|
// localization
|
||||||
|
Self.Caption := rsIpHTMLPreviewPrintPreview;
|
||||||
|
btnPrint.Caption := rsIpHTMLPreviewPrint;
|
||||||
|
Label3.Caption := rsIpHTMLPreviewZoom;
|
||||||
|
btnClose.Caption := rsIpHTMLPreviewClose;
|
||||||
|
Label1.Caption := rsIpHTMLPreviewPage;
|
||||||
|
Label2.Caption := rsIpHTMLPreviewOf;
|
||||||
|
btnSelectPrinter.Caption := rsIpHTMLPreviewSelectPrinter;
|
||||||
|
btnFit.Caption := rsIpHTMLPreviewFitAll;
|
||||||
|
btnFitWidth.Caption := rsIpHTMLPreviewFitWidth;
|
||||||
|
btnFitHeight.Caption := rsIpHTMLPreviewFitHeight;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.FormDestroy(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Scratch.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.FormResize(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (FZoomToFit <= 0) and (OwnerPanel <> nil) then
|
||||||
|
SetZoom(FZoomToFit) {force recalc of preview sizes}
|
||||||
|
else
|
||||||
|
AlignPaintbox;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateBtnStates;
|
||||||
|
// SetZoom(FZoom);
|
||||||
|
RenderPage(CurPage);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.PaintBox1Paint(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SourceRect := PaintBox1.Canvas.ClipRect;
|
||||||
|
ScaleSourceRect;
|
||||||
|
ClipRect := SourceRect;
|
||||||
|
OffsetRect(SourceRect, 0, PageRect.Top);
|
||||||
|
Render;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.Render;
|
procedure TIpHTMLPreview.Render;
|
||||||
@ -246,7 +315,7 @@ begin
|
|||||||
R.Right := R.Left + round(SCRATCH_WIDTH * Scale) + 1;
|
R.Right := R.Left + round(SCRATCH_WIDTH * Scale) + 1;
|
||||||
R.Bottom := R.Top + round(SCRATCH_HEIGHT * Scale) + 1;
|
R.Bottom := R.Top + round(SCRATCH_HEIGHT * Scale) + 1;
|
||||||
|
|
||||||
PaintBox1.Canvas.AntialiasingMode := OwnerPanel.AntiAliasingMode;
|
PaintBox1.Canvas.AntialiasingMode := OwnerPanel.PreviewAntiAliasingMode;
|
||||||
PaintBox1.Canvas.StretchDraw(R, Scratch);
|
PaintBox1.Canvas.StretchDraw(R, Scratch);
|
||||||
|
|
||||||
inc(WindowLeft, SCRATCH_WIDTH);
|
inc(WindowLeft, SCRATCH_WIDTH);
|
||||||
@ -260,77 +329,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.PaintBox1Paint(Sender: TObject);
|
procedure TIpHTMLPreview.RenderPage(PageNo: Integer);
|
||||||
begin
|
|
||||||
SourceRect := PaintBox1.Canvas.ClipRect;
|
|
||||||
ScaleSourceRect;
|
|
||||||
ClipRect := SourceRect;
|
|
||||||
OffsetRect(SourceRect, 0, PageRect.Top);
|
|
||||||
Render;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIpHTMLPreview.FormDestroy(Sender: TObject);
|
|
||||||
begin
|
|
||||||
Scratch.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIpHTMLPreview.ZoomComboChange(Sender: TObject);
|
|
||||||
var
|
var
|
||||||
S: string;
|
CR : TRect;
|
||||||
begin
|
begin
|
||||||
with ZoomCombo do
|
CR := Rect(0, 0, OwnerPanel.PrintWidth, 0);
|
||||||
S := Items[ItemIndex];
|
CR.Top := (PageNo - 1) * OwnerPanel.PrintHeight;
|
||||||
Zoom := StrToInt(copy(S, 1, length(S) - 1));
|
CR.Bottom := Cr.Top + OwnerPanel.PrintHeight;
|
||||||
end;
|
PageRect := CR;
|
||||||
|
PaintBox1.Invalidate;
|
||||||
procedure TIpHTMLPreview.FormCreate(Sender: TObject);
|
|
||||||
begin
|
|
||||||
ZoomCombo.ItemIndex := 4;
|
|
||||||
FZoom := 100;
|
|
||||||
Scratch := TBitmap.Create;
|
|
||||||
Scratch.Width := SCRATCH_WIDTH;
|
|
||||||
Scratch.Height := SCRATCH_HEIGHT;
|
|
||||||
|
|
||||||
// localization
|
|
||||||
Self.Caption := rsIpHTMLPreviewPrintPreview;
|
|
||||||
btnPrint.Caption := rsIpHTMLPreviewPrint;
|
|
||||||
Label3.Caption := rsIpHTMLPreviewZoom;
|
|
||||||
btnClose.Caption := rsIpHTMLPreviewClose;
|
|
||||||
Label1.Caption := rsIpHTMLPreviewPage;
|
|
||||||
Label2.Caption := rsIpHTMLPreviewOf;
|
|
||||||
btnSelectPrinter.Caption := rsIpHTMLPreviewSelectPrinter
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIpHTMLPreview.SetZoom(const Value: Integer);
|
|
||||||
var
|
|
||||||
Scale1, Scale2, Scale0: double;
|
|
||||||
{$IFDEF IP_LAZARUS}
|
|
||||||
ClientHeightDbl, ClientWidthDbl: double;
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
|
||||||
FZoom := Value;
|
|
||||||
{$IFDEF IP_LAZARUS}
|
|
||||||
ClientHeightDbl := ClientHeight;
|
|
||||||
ClientWidthDbl := ClientWidth;
|
|
||||||
if Printer.PageHeight>0 then
|
|
||||||
Scale1 := ClientHeightDbl/Printer.PageHeight
|
|
||||||
else
|
|
||||||
Scale1 := ClientHeightDbl/500;
|
|
||||||
if Printer.PageWidth>0 then
|
|
||||||
Scale2 := ClientWidthDbl/ Printer.PageWidth
|
|
||||||
else
|
|
||||||
Scale2 := ClientWidthDbl/ 500;
|
|
||||||
{$ELSE}
|
|
||||||
Scale1 := ClientHeight/ Printer.PageHeight; //JMN
|
|
||||||
Scale2 := ClientWidth/ Printer.PageWidth; //JMN
|
|
||||||
{$ENDIF}
|
|
||||||
if Scale1 < Scale2 then
|
|
||||||
Scale0 := Scale1
|
|
||||||
else
|
|
||||||
Scale0 := Scale2;
|
|
||||||
FScale := Scale0 * FZoom / 100;
|
|
||||||
ResizeCanvas;
|
|
||||||
AlignPaintBox;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.ResizeCanvas;
|
procedure TIpHTMLPreview.ResizeCanvas;
|
||||||
@ -357,22 +364,72 @@ begin
|
|||||||
AlignPaintBox;
|
AlignPaintBox;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.AlignPaintBox;
|
procedure TIpHTMLPreview.ScaleSourceRect;
|
||||||
begin
|
begin
|
||||||
if PaperPanel.Width < ClientWidth then
|
SourceRect.Left := round(SourceRect.Left / Scale);
|
||||||
PaperPanel.Left := ClientWidth div 2 - (PaperPanel.Width div 2)
|
SourceRect.Top := round(SourceRect.Top / Scale);
|
||||||
else
|
SourceRect.Right := round(SourceRect.Right / Scale);
|
||||||
PaperPanel.Left := 0;
|
SourceRect.Bottom := round(SourceRect.Bottom / Scale);
|
||||||
if PaperPanel.Height < ClientHeight then
|
|
||||||
PaperPanel.Top := ClientHeight div 2 - (PaperPanel.Height div 2)
|
|
||||||
else
|
|
||||||
PaperPanel.Top := 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHTMLPreview.FormResize(Sender: TObject);
|
procedure TIpHTMLPreview.SetCurPage(const Value: Integer);
|
||||||
begin
|
begin
|
||||||
if OwnerPanel<>nil then
|
if (Value <> FCurPage)
|
||||||
SetZoom(Zoom); {force recalc of preview sizes}
|
and (Value >= 1)
|
||||||
|
and (Value <= OwnerPanel.PageCount) then begin
|
||||||
|
FCurPage := Value;
|
||||||
|
RenderPage(Value);
|
||||||
|
edtPage.Text := IntToStr(CurPage);
|
||||||
|
UpdateBtnStates;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHTMLPreview.SetZoom(const Value: Integer);
|
||||||
|
var
|
||||||
|
ClientHeightDbl, ClientWidthDbl: Double;
|
||||||
|
PrnPgHeight, PrnPgWidth: Double;
|
||||||
|
scaleW, scaleH: Integer;
|
||||||
|
sb: Integer;
|
||||||
|
begin
|
||||||
|
FZoomToFit := Value;
|
||||||
|
|
||||||
|
// Available client area in inches, without scrollbars
|
||||||
|
sb := GetSystemMetrics(SM_CXHSCROLL);
|
||||||
|
ClientHeightDbl := (ClientHeight - sb - ToolbarPanel.Height) / ScreenInfo.PixelsPerInchY;
|
||||||
|
sb := GetSystemMetrics(SM_CXVSCROLL);
|
||||||
|
ClientWidthDbl := (ClientWidth - sb)/ ScreenInfo.PixelsPerInchX;
|
||||||
|
|
||||||
|
// Printer page size in inches
|
||||||
|
PrnPgHeight := Printer.PageHeight / Printer.YDpi;
|
||||||
|
PrnPgWidth := Printer.PageWidth / Printer.XDpi;
|
||||||
|
|
||||||
|
case Value of
|
||||||
|
ZOOM_TO_FIT:
|
||||||
|
begin
|
||||||
|
scaleW := round(ClientWidthDbl / PrnPgWidth * 100);
|
||||||
|
scaleH := round(ClientHeightDbl / PrnPgHeight * 100);
|
||||||
|
if scaleW < scaleH then FZoom := scaleW else FZoom := scaleH;
|
||||||
|
end;
|
||||||
|
ZOOM_TO_FIT_WIDTH:
|
||||||
|
FZoom := round(ClientWidthDbl / PrnPgWidth * 100);
|
||||||
|
ZOOM_TO_FIT_HEIGHT:
|
||||||
|
FZoom := round(ClientHeightDbl / PrnPgHeight * 100);
|
||||||
|
else
|
||||||
|
FZoom := Value;
|
||||||
|
end;
|
||||||
|
inc(FLockZoomUpdate);
|
||||||
|
edtZoom.Value := FZoom;
|
||||||
|
dec(FLockZoomUpdate);
|
||||||
|
FScale := ScreenInfo.PixelsPerInchX / Printer.XDpi * FZoom * 0.01;
|
||||||
|
ResizeCanvas;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHtmlPreview.UpdateBtnStates;
|
||||||
|
begin
|
||||||
|
btnFirst.Enabled := (FCurPage > 1);
|
||||||
|
btnPrev.Enabled := (FCurPage > 1);
|
||||||
|
btnNext.Enabled := (FCurPage < OwnerPanel.PageCount);
|
||||||
|
btnLast.Enabled := (FCurPage < OwnerPanel.PageCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -15,6 +15,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Fermer"
|
msgstr "Fermer"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "de"
|
msgstr "de"
|
||||||
@ -38,3 +50,4 @@ msgstr "Choisir une imprimante..."
|
|||||||
#: iphtmlpv.rsiphtmlpreviewzoom
|
#: iphtmlpv.rsiphtmlpreviewzoom
|
||||||
msgid "Zoom:"
|
msgid "Zoom:"
|
||||||
msgstr "Zoom :"
|
msgstr "Zoom :"
|
||||||
|
|
||||||
|
@ -15,6 +15,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Bezárás"
|
msgstr "Bezárás"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "/"
|
msgstr "/"
|
||||||
@ -38,3 +50,4 @@ msgstr "Nyomtató választása..."
|
|||||||
#: iphtmlpv.rsiphtmlpreviewzoom
|
#: iphtmlpv.rsiphtmlpreviewzoom
|
||||||
msgid "Zoom:"
|
msgid "Zoom:"
|
||||||
msgstr "Nagyítás:"
|
msgstr "Nagyítás:"
|
||||||
|
|
||||||
|
@ -16,6 +16,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Chiudi"
|
msgstr "Chiudi"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "di"
|
msgstr "di"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
Valdas Jankunas <zmuogs@gmail.com>, 2012.
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
@ -16,6 +15,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Užverti"
|
msgstr "Užverti"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "iš"
|
msgstr "iš"
|
||||||
|
@ -5,6 +5,18 @@ msgstr "Content-Type: text/plain; charset=UTF-8"
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -13,6 +13,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Fechar"
|
msgstr "Fechar"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "de"
|
msgstr "de"
|
||||||
|
@ -13,6 +13,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Закрыть"
|
msgstr "Закрыть"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "из"
|
msgstr "из"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
Igor Paliychuk <mansonigor@gmail.com>, 2012.
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
@ -17,6 +16,18 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Закрити"
|
msgstr "Закрити"
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitall
|
||||||
|
msgid "Fit all"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitheight
|
||||||
|
msgid "Height"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: iphtmlpv.rsiphtmlpreviewfitwidth
|
||||||
|
msgid "Width"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: iphtmlpv.rsiphtmlpreviewof
|
#: iphtmlpv.rsiphtmlpreviewof
|
||||||
msgid "of"
|
msgid "of"
|
||||||
msgstr "з"
|
msgstr "з"
|
||||||
|
Loading…
Reference in New Issue
Block a user