You've already forked lazarus-ccr
tvplanit: Cometic changes in print preview units. Activate some commented Delphi-only code.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4792 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -61,8 +61,8 @@ uses
|
||||
{$ELSE}
|
||||
Windows, Messages,
|
||||
{$ENDIF}
|
||||
SysUtils,Classes,Controls,Forms,Graphics, Printers, VpBase,
|
||||
VpMisc,VpBaseDS, VpSR, VpException, Menus;
|
||||
SysUtils, Classes, Controls, Forms, Graphics, Printers,
|
||||
VpBase, VpMisc, VpBaseDS, VpSR, VpException, Menus;
|
||||
|
||||
type
|
||||
TVpPageChange = procedure(Sender: TObject; NewPage: Integer) of object;
|
||||
@@ -71,6 +71,11 @@ type
|
||||
zf25Percent, zf33Percent, zf50Percent,
|
||||
zf67Percent, zf75Percent);
|
||||
|
||||
const
|
||||
ZOOM_FACTOR_VALUES: array[TVpPPZoomFactor] of Double = (
|
||||
-1, 1.0, 0.25, 1.0/3, 0.5, 2.0/3, 0.75);
|
||||
|
||||
type
|
||||
TVpPageInfo = record
|
||||
Date: TDateTime;
|
||||
Task: Integer;
|
||||
@@ -107,7 +112,7 @@ type
|
||||
function CalculatePageHeight(Printer: TPrinter): Integer;
|
||||
function CalculatePageWidth(Printer: TPrinter): Integer;
|
||||
procedure ClearPageData;
|
||||
{$IFNDEF LCL}
|
||||
{$IFDEF DELPHI}
|
||||
procedure CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
||||
message CM_WANTSPECIALKEY;
|
||||
{$ENDIF}
|
||||
@@ -116,17 +121,13 @@ type
|
||||
procedure DoScroll(var Msg: {$IFNDEF LCL}TWMSCROLL{$ELSE}TLMScroll{$ENDIF}; BarDirection: Integer);
|
||||
procedure GeneratePageImage;
|
||||
procedure GetLastPage;
|
||||
procedure InitHScrollBar (PageSize : Integer;
|
||||
TotalSize : Integer);
|
||||
procedure InitHScrollBar(PageSize, TotalSize: Integer);
|
||||
procedure InitializeDefaultPopup;
|
||||
procedure InitVScrollBar (PageSize : Integer;
|
||||
TotalSize : Integer);
|
||||
procedure InitVScrollBar(PageSize, TotalSize: Integer);
|
||||
function IsPageLoaded(PageNum: Integer): Boolean;
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure Loaded; override;
|
||||
function LoadPage (PageNum : Integer;
|
||||
StartDate : TDateTime;
|
||||
EndDate : TDateTime) : Integer;
|
||||
function LoadPage(PageNum: Integer; StartDate, EndDate: TDateTime): Integer;
|
||||
procedure Paint; override;
|
||||
procedure PopupFirstPage(Sender: TObject);
|
||||
procedure PopupLastPage(Sender: TObject);
|
||||
@@ -148,7 +149,7 @@ type
|
||||
procedure SetZoomFactor(const v: TVpPPZoomFactor);
|
||||
|
||||
// procedure VpPrintFormatChanged (var Msg : {$IFNDEF LCL}TMessage{$ELSE}TLMessage{$ENDIF}; message Vp_PrintFormatChanged;
|
||||
{$IFNDEF LCL}
|
||||
{$IFDEF DELPHI}
|
||||
procedure WMEraseBackground(var Msg: TWMERASEBKGND); message WM_ERASEBKGND;
|
||||
procedure WMHScroll(var Msg: TWMSCROLL); message WM_HSCROLL;
|
||||
procedure WMVScroll(var Msg: TWMSCROLL); message WM_VSCROLL;
|
||||
@@ -159,6 +160,7 @@ type
|
||||
procedure WMVScroll(var Msg: TLMSCROLL); message LM_VSCROLL;
|
||||
procedure WMRButtonDown(var Msg: TLMRButtonDown); message LM_RBUTTONDOWN;
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@@ -174,28 +176,20 @@ type
|
||||
|
||||
property Printer: TPrinter read FPrinter write SetPrinter;
|
||||
property DestPrinter: TPrinter read FPrinter write SetPrinter;
|
||||
|
||||
published
|
||||
property BorderColor : TColor read FBorderColor write SetBorderColor
|
||||
default clBlack;
|
||||
property BorderStyle : TBorderStyle
|
||||
read FBorderStyle write SetBorderStyle default bsSingle;
|
||||
property ControlLink : TVpControlLink
|
||||
read FControlLink write SetControlLink;
|
||||
property BorderColor: TColor read FBorderColor write SetBorderColor default clBlack;
|
||||
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
|
||||
property ControlLink: TVpControlLink read FControlLink write SetControlLink;
|
||||
property CurPage: Integer read FCurPage write SetCurPage;
|
||||
// property DestPrinter: TPrinter read FPrinter write SetPrinter;
|
||||
property DrawingStyle : TVpDrawingStyle
|
||||
read FDrawingStyle write SetDrawingStyle default ds3d;
|
||||
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d;
|
||||
property EndDate: TDateTime read FEndDate write SetEndDate;
|
||||
property OffPageColor : TColor read FOffPageColor write SetOffPageColor
|
||||
default clSilver;
|
||||
property PageColor : TColor read FPageColor write SetPageColor
|
||||
default clWhite;
|
||||
property OffPageColor: TColor read FOffPageColor write SetOffPageColor default clSilver;
|
||||
property PageColor: TColor read FPageColor write SetPageColor default clWhite;
|
||||
property StartDate: TDateTime read FStartDate write SetStartDate;
|
||||
property ZoomFactor : TVpPPZoomFactor
|
||||
read FZoomFactor write SetZoomFactor default zfFitToControl;
|
||||
|
||||
property OnPageChange : TVpPageChange
|
||||
read FOnPageChange write FOnPageChange;
|
||||
property ZoomFactor: TVpPPZoomFactor read FZoomFactor write SetZoomFactor default zfFitToControl;
|
||||
property OnPageChange: TVpPageChange read FOnPageChange write FOnPageChange;
|
||||
|
||||
property Anchors;
|
||||
property Align;
|
||||
@@ -232,6 +226,7 @@ type
|
||||
property OnStartDrag;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
constructor TVpPrintPreview.Create(AOwner: TComponent);
|
||||
@@ -279,9 +274,7 @@ begin
|
||||
|
||||
RenderBmp.Free;
|
||||
WorkBmp.Free;
|
||||
|
||||
FPageInfo.Free;
|
||||
|
||||
FDefaultPopup.Free;
|
||||
|
||||
inherited Destroy;
|
||||
@@ -291,28 +284,30 @@ function TVpPrintPreview.CalculatePageHeight (Printer : TPrinter) : Integer;
|
||||
var
|
||||
ScreenPPI: Integer;
|
||||
PrinterPPI: Integer;
|
||||
|
||||
begin
|
||||
{$IFNDEF LCL}
|
||||
ScreenPPI := GetDeviceCaps (Canvas.Handle, LOGPIXELSY);
|
||||
{$IFDEF DELPHI}
|
||||
PrinterPPI := GetDeviceCaps (Printer.Handle, LOGPIXELSY);
|
||||
{$ELSE}
|
||||
PrinterPPI := Printer.XDpi;
|
||||
{$ENDIF}
|
||||
|
||||
if PrinterPPI <> 0 then
|
||||
Result := Round (ScreenPPI / PrinterPPI * Printer.PageHeight)
|
||||
else
|
||||
Result := ScreenPPI * Printer.PageHeight;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TVpPrintPreview.CalculatePageWidth (Printer : TPrinter) : Integer;
|
||||
var
|
||||
ScreenPPI: Integer;
|
||||
PrinterPPI: Integer;
|
||||
|
||||
begin
|
||||
{$IFNDEF LCL}
|
||||
ScreenPPI := GetDeviceCaps (Canvas.Handle, LOGPIXELSX);
|
||||
{$IFDEF DELPHI}
|
||||
PrinterPPI := GetDeviceCaps (Printer.Handle, LOGPIXELSX);
|
||||
{$ELSE}
|
||||
PrinterPPI := Printer.XDpi;
|
||||
|
||||
if PrinterPPI <> 0 then
|
||||
Result := Round (ScreenPPI / PrinterPPI * Printer.PageWidth)
|
||||
@@ -324,7 +319,6 @@ end;
|
||||
procedure TVpPrintPreview.ClearPageData;
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
begin
|
||||
for i := FPageInfo.Count - 1 downto 0 do begin
|
||||
if Assigned (FPageInfo[i]) then
|
||||
@@ -334,7 +328,7 @@ begin
|
||||
CurPage := 0;
|
||||
end;
|
||||
|
||||
{$IFNDEF LCL}
|
||||
{$IFDEF DELPHI}
|
||||
procedure TVpPrintPreview.CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
||||
begin
|
||||
inherited;
|
||||
@@ -357,7 +351,7 @@ end;
|
||||
|
||||
procedure TVpPrintPreview.CreateWnd;
|
||||
begin
|
||||
if (HandleAllocated) and (Assigned (FControlLink)) then
|
||||
if HandleAllocated and Assigned(FControlLink) then
|
||||
FControlLink.Printer.DeregisterWatcher(Handle);
|
||||
|
||||
inherited CreateWnd;
|
||||
@@ -366,19 +360,13 @@ begin
|
||||
FControlLink.Printer.RegisterWatcher(Handle);
|
||||
end;
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpPrintPreview.DoScroll (var Msg : TWMSCROLL;
|
||||
procedure TVpPrintPreview.DoScroll(var Msg: {$IFNDEF LCL}TWMSCROLL{$ELSE}TLMScroll{$ENDIF};
|
||||
BarDirection: Integer);
|
||||
{$ELSE}
|
||||
procedure TVpPrintPreview.DoScroll (var Msg : TLMSCROLL;
|
||||
BarDirection : Integer);
|
||||
{$ENDIF}
|
||||
var
|
||||
ScrollBarInfo: TScrollInfo;
|
||||
|
||||
begin
|
||||
Msg.Result := 0;
|
||||
ScrollBarInfo.cbSize := SizeOf (TscrollInfo);
|
||||
ScrollBarInfo.cbSize := SizeOf(TScrollInfo);
|
||||
ScrollBarInfo.fMask := SIF_ALL;
|
||||
GetScrollInfo (Handle, BarDirection, ScrollBarInfo);
|
||||
ScrollBarInfo.fMask := SIF_POS;
|
||||
@@ -395,7 +383,7 @@ begin
|
||||
end;
|
||||
|
||||
ScrollBarInfo.fMask := SIF_POS;
|
||||
if ScrollBarInfo.nPos < ScrollBarInfo.nMin Then
|
||||
if ScrollBarInfo.nPos < ScrollBarInfo.nMin then
|
||||
ScrollBarInfo.nPos := ScrollBarInfo.nMin;
|
||||
if ScrollBarInfo.nPos + Integer(ScrollBarInfo.nPage) >
|
||||
ScrollBarInfo.nMax Then
|
||||
@@ -436,7 +424,6 @@ var
|
||||
UseDate: TDateTime;
|
||||
UseContact: Integer;
|
||||
UseTask: Integer;
|
||||
|
||||
begin
|
||||
if not Assigned(FControlLink) then
|
||||
Exit;
|
||||
@@ -445,17 +432,22 @@ begin
|
||||
Exit;
|
||||
|
||||
if (FControlLink.Printer.PrintFormats.Count = 0) or
|
||||
(FControlLink.Printer.CurFormat < 0) then
|
||||
(FControlLink.Printer.CurFormat < 0)
|
||||
then
|
||||
Exit;
|
||||
|
||||
FCurrentFormat := FControlLink.Printer.CurFormat;
|
||||
|
||||
if (FPrinter <> nil) and
|
||||
((RenderBmp.Width = 0) or (RenderBmp.Height = 0)) then begin
|
||||
((RenderBmp.Width = 0) or (RenderBmp.Height = 0)) then
|
||||
begin
|
||||
RenderBmp.Width := CalculatePageWidth(FPrinter);
|
||||
RenderBmp.Height := CalculatePageHeight(FPrinter);
|
||||
end else if (FPrinter = nil) and
|
||||
((RenderBmp.Width = 0) or (RenderBmp.Height = 0)) then begin
|
||||
end
|
||||
else
|
||||
if (FPrinter = nil) and
|
||||
((RenderBmp.Width = 0) or (RenderBmp.Height = 0)) then
|
||||
begin
|
||||
RenderBmp.Width := ClientWidth;
|
||||
RenderBmp.Height := ClientHeight;
|
||||
end;
|
||||
@@ -468,24 +460,25 @@ begin
|
||||
RenderBmp.Canvas.FillRect(Rect(0, 0, RenderBmp.Width, RenderBmp.Height));
|
||||
|
||||
if not IsPageLoaded(CurPage) then
|
||||
FControlLink.Printer.PaintToCanvasRect (RenderBmp.Canvas,
|
||||
Rect (0, 0,
|
||||
RenderBmp.Width,
|
||||
RenderBmp.Height),
|
||||
StartDate)
|
||||
FControlLink.Printer.PaintToCanvasRect(
|
||||
RenderBmp.Canvas,
|
||||
Rect(0, 0, RenderBmp.Width, RenderBmp.Height),
|
||||
StartDate
|
||||
)
|
||||
else begin
|
||||
UseDate := PVpPageInfo(FPageInfo[CurPage]).Date;
|
||||
UseContact := PVpPageInfo(FPageInfo[CurPage]).Contact;
|
||||
UseTask := PVpPageInfo(FPageInfo[CurPage]).Task;
|
||||
FControlLink.Printer.RenderPage (RenderBmp.Canvas,
|
||||
Rect (0, 0, RenderBmp.Width,
|
||||
RenderBmp.Height),
|
||||
FControlLink.Printer.RenderPage(
|
||||
RenderBmp.Canvas,
|
||||
Rect(0, 0, RenderBmp.Width, RenderBmp.Height),
|
||||
CurPage,
|
||||
UseDate,
|
||||
EndDate,
|
||||
UseContact,
|
||||
UseTask,
|
||||
LastPage);
|
||||
LastPage
|
||||
);
|
||||
end;
|
||||
SetScrollBars;
|
||||
end;
|
||||
@@ -493,39 +486,35 @@ end;
|
||||
procedure TVpPrintPreview.GetLastPage;
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
begin
|
||||
i := FPageInfo.Count - 1;
|
||||
while (not PVpPageInfo (FPageInfo[i]).LastPage) and
|
||||
(i < FPageInfo.Count) do begin
|
||||
Inc (i);
|
||||
while (not PVpPageInfo(FPageInfo[i]).LastPage) and (i < FPageInfo.Count) do
|
||||
begin
|
||||
inc(i);
|
||||
LoadPage(i, StartDate, EndDate);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpPrintPreview.InitHScrollBar (PageSize : Integer;
|
||||
TotalSize : Integer);
|
||||
procedure TVpPrintPreview.InitHScrollBar(PageSize, TotalSize: Integer);
|
||||
var
|
||||
ScrollBarInfo: TScrollInfo;
|
||||
|
||||
begin
|
||||
FNeedHScroll := True;
|
||||
|
||||
ScrollBarInfo.cbSize := SizeOf (TScrollInfo);
|
||||
ScrollBarInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
||||
ScrollBarInfo.nMin := 0;
|
||||
|
||||
ScrollBarInfo.nMax := TotalSize;
|
||||
ScrollBarInfo.nPage := PageSize;
|
||||
ScrollBarInfo.nPos := 0;
|
||||
ScrollBarInfo.nTrackPos := 0;
|
||||
|
||||
SetScrollInfo(Handle, SB_HORZ, ScrollBarInfo, True);
|
||||
end;
|
||||
|
||||
procedure TVpPrintPreview.InitializeDefaultPopup;
|
||||
var
|
||||
NewItem: TMenuItem;
|
||||
|
||||
begin
|
||||
if RSPrintPrvPrevPage <> '' then begin
|
||||
NewItem := TMenuItem.Create (Self);
|
||||
@@ -560,11 +549,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpPrintPreview.InitVScrollBar (PageSize : Integer;
|
||||
TotalSize : Integer);
|
||||
procedure TVpPrintPreview.InitVScrollBar(PageSize, TotalSize: Integer);
|
||||
var
|
||||
ScrollBarInfo: TScrollInfo;
|
||||
|
||||
begin
|
||||
FNeedVScroll := True;
|
||||
|
||||
@@ -575,6 +562,7 @@ begin
|
||||
ScrollBarInfo.nPage := PageSize;
|
||||
ScrollBarInfo.nTrackPos := 0;
|
||||
ScrollBarInfo.nPos := 0;
|
||||
|
||||
SetScrollInfo (Handle, SB_VERT, ScrollBarInfo, True);
|
||||
end;
|
||||
|
||||
@@ -587,7 +575,8 @@ function TVpPrintPreview.IsLastPage : Boolean;
|
||||
begin
|
||||
if FPageInfo.Count = 0 then
|
||||
Result := True
|
||||
else if CurPage < FPageInfo.Count then
|
||||
else
|
||||
if CurPage < FPageInfo.Count then
|
||||
Result := PVpPageInfo(FPageInfo[CurPage]).LastPage
|
||||
else begin
|
||||
GetLastPage;
|
||||
@@ -600,11 +589,9 @@ begin
|
||||
Result := PageNum < FPageInfo.Count;
|
||||
end;
|
||||
|
||||
|
||||
procedure TVpPrintPreview.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
PopupPoint: TPoint;
|
||||
|
||||
begin
|
||||
case Key of
|
||||
VK_LEFT, VK_PRIOR :
|
||||
@@ -612,18 +599,21 @@ begin
|
||||
FirstPage
|
||||
else
|
||||
PrevPage;
|
||||
|
||||
VK_RIGHT, VK_NEXT:
|
||||
if ssCtrl in Shift then
|
||||
LastPage
|
||||
else
|
||||
NextPage;
|
||||
|
||||
$5A: {z}
|
||||
if ssCtrl in Shift then begin
|
||||
if ZoomFactor = High(FZoomFactor) then
|
||||
ZOomFactor := Low(FZoomFactor)
|
||||
else
|
||||
ZoomFactor := Succ(FZoomFactor);
|
||||
end else if ssShift in Shift then begin
|
||||
end else
|
||||
if ssShift in Shift then begin
|
||||
if ZoomFactor = Low(FZoomFactor) then
|
||||
ZOomFactor := High(FZoomFactor)
|
||||
else
|
||||
@@ -635,32 +625,29 @@ begin
|
||||
ControlLink.Printer.CurFormat := ControlLink.Printer.CurFormat + 1
|
||||
else
|
||||
ControlLink.Printer.CurFormat := 0;
|
||||
end else if (ssShift in Shift) and Assigned (ControlLink) then begin
|
||||
end else
|
||||
if (ssShift in Shift) and Assigned(ControlLink) then begin
|
||||
if ControlLink.Printer.CurFormat > 0 then
|
||||
ControlLink.Printer.CurFormat := ControlLink.Printer.CurFormat - 1
|
||||
else
|
||||
ControlLink.Printer.CurFormat := ControlLink.Printer.PrintFormats.Count - 1;
|
||||
end;
|
||||
{$IFDEF DELPHI}
|
||||
VK_TAB:
|
||||
{$IFNDEF LCL}
|
||||
if ssShift in Shift then
|
||||
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False))
|
||||
else
|
||||
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True));
|
||||
{$ELSE}
|
||||
;
|
||||
{$ENDIF}
|
||||
VK_F10:
|
||||
if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin
|
||||
if (ssShift in Shift) and not Assigned(PopupMenu) then begin
|
||||
PopupPoint := GetClientOrigin;
|
||||
FDefaultPopup.Popup (PopupPoint.x + 10,
|
||||
PopupPoint.y + 10);
|
||||
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
||||
end;
|
||||
VK_APPS:
|
||||
if not Assigned (PopupMenu) then begin
|
||||
PopupPoint := GetClientOrigin;
|
||||
FDefaultPopup.Popup (PopupPoint.x + 10,
|
||||
PopupPoint.y + 10);
|
||||
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
||||
end;
|
||||
else
|
||||
inherited;
|
||||
@@ -670,13 +657,11 @@ end;
|
||||
procedure TVpPrintPreview.LastPage;
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
begin
|
||||
if CurPage < FPageInfo.Count then begin
|
||||
i := CurPage;
|
||||
if (not PVpPageInfo (FPageInfo[i]).LastPage) and
|
||||
(i < FPageInfo.Count) then
|
||||
Inc (i);
|
||||
if (not PVpPageInfo(FPageInfo[i]).LastPage) and (i < FPageInfo.Count) then
|
||||
inc(i);
|
||||
if (not PVpPageInfo(FPageInfo[i]).LastPage) then
|
||||
GetLastPage;
|
||||
end else
|
||||
@@ -687,17 +672,15 @@ end;
|
||||
procedure TVpPrintPreview.Loaded;
|
||||
begin
|
||||
inherited Loaded;
|
||||
|
||||
DestPrinter := Printer;
|
||||
GeneratePageImage;
|
||||
end;
|
||||
|
||||
function TVpPrintPreview.LoadPage (PageNum : Integer;
|
||||
StartDate : TDateTime;
|
||||
EndDate : TDateTime) : Integer;
|
||||
{ Loads the requested page. Returns the last page loaded. If the
|
||||
return value is less than the requested page, the requested page
|
||||
is past the last page }
|
||||
function TVpPrintPreview.LoadPage(PageNum: Integer;
|
||||
StartDate, EndDate: TDateTime): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
LastPage: Boolean;
|
||||
@@ -705,7 +688,6 @@ var
|
||||
ADate: TDateTime;
|
||||
ATask: Integer;
|
||||
AContact: Integer;
|
||||
|
||||
begin
|
||||
Result := PageNum;
|
||||
if PageNum < FPageInfo.Count then
|
||||
@@ -737,18 +719,17 @@ begin
|
||||
|
||||
{ The only way to see how the pages are going to increment is to render
|
||||
them and get the return information }
|
||||
|
||||
while (i <= PageNum) and (not LastPage) do begin
|
||||
|
||||
FControlLink.Printer.RenderPage (RenderBmp.Canvas,
|
||||
Rect (0, 0, RenderBmp.Width,
|
||||
RenderBmp.Height),
|
||||
FControlLink.Printer.RenderPage(
|
||||
RenderBmp.Canvas,
|
||||
Rect(0, 0, RenderBmp.Width, RenderBmp.Height),
|
||||
i + 1,
|
||||
ADate,
|
||||
FEndDate,
|
||||
AContact,
|
||||
ATask,
|
||||
LastPage);
|
||||
LastPage
|
||||
);
|
||||
Result := i;
|
||||
GetMem(PPageInfo, SizeOf(TVpPageInfo));
|
||||
PPageInfo.Date := ADate;
|
||||
@@ -756,7 +737,7 @@ begin
|
||||
PPageInfo.Contact := AContact;
|
||||
PPageInfo.LastPage := LastPage;
|
||||
FPageInfo.Add(PPageInfo);
|
||||
Inc (i);
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -798,36 +779,33 @@ var
|
||||
if FBorderStyle = bsSingle then begin
|
||||
if FDrawingStyle = dsFlat then begin
|
||||
{ draw an outer and inner bevel }
|
||||
DrawBevelRect (WorkBmp.Canvas,
|
||||
Rect (ClientRect.Left,
|
||||
ClientRect.Top,
|
||||
ClientRect.Right - 1,
|
||||
ClientRect.Bottom - 1),
|
||||
DrawBevelRect(
|
||||
WorkBmp.Canvas,
|
||||
Rect(ClientRect.Left, ClientRect.Top, ClientRect.Right - 1, ClientRect.Bottom - 1),
|
||||
clBtnShadow,
|
||||
clBtnHighlight);
|
||||
DrawBevelRect (WorkBmp.Canvas,
|
||||
Rect (ClientRect.Left + 1,
|
||||
ClientRect.Top + 1,
|
||||
ClientRect.Right - 2,
|
||||
ClientRect.Bottom - 2),
|
||||
clBtnHighlight
|
||||
);
|
||||
DrawBevelRect(
|
||||
WorkBmp.Canvas,
|
||||
Rect(ClientRect.Left + 1, ClientRect.Top + 1, ClientRect.Right - 2, ClientRect.Bottom - 2),
|
||||
clBtnHighlight,
|
||||
clBtnShadow);
|
||||
end else if FDrawingStyle = ds3d then begin
|
||||
clBtnShadow
|
||||
);
|
||||
end else
|
||||
if FDrawingStyle = ds3d then begin
|
||||
{ draw a 3d bevel }
|
||||
DrawBevelRect (WorkBmp.Canvas,
|
||||
Rect (ClientRect.Left,
|
||||
ClientRect.Top,
|
||||
ClientRect.Right - 1,
|
||||
ClientRect.Bottom - 1),
|
||||
DrawBevelRect(
|
||||
WorkBmp.Canvas,
|
||||
Rect(ClientRect.Left, ClientRect.Top, ClientRect.Right - 1, ClientRect.Bottom - 1),
|
||||
clBtnShadow,
|
||||
clBtnHighlight);
|
||||
DrawBevelRect (WorkBmp.Canvas,
|
||||
Rect (ClientRect.Left + 1,
|
||||
ClientRect.Top + 1,
|
||||
ClientRect.Right - 2,
|
||||
ClientRect.Bottom - 2),
|
||||
clBtnHighlight
|
||||
);
|
||||
DrawBevelRect(
|
||||
WorkBmp.Canvas,
|
||||
Rect(ClientRect.Left + 1, ClientRect.Top + 1, ClientRect.Right - 2, ClientRect.Bottom - 2),
|
||||
cl3DDkShadow,
|
||||
clBtnFace);
|
||||
clBtnFace
|
||||
);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -868,7 +846,6 @@ var
|
||||
ScaleY: Extended;
|
||||
Offset1: Integer;
|
||||
Offset2: Integer;
|
||||
|
||||
begin
|
||||
Offset1 := 3;
|
||||
Offset2 := 3;
|
||||
@@ -883,12 +860,19 @@ var
|
||||
else
|
||||
ScaleY := 1;
|
||||
if ScaleX > ScaleY then
|
||||
Result := Rect (Offset1, Offset1, ClientWidth - Offset2,
|
||||
Round (FPrinter.PageHeight / ScaleX))
|
||||
Result := Rect(
|
||||
Offset1,
|
||||
Offset1,
|
||||
ClientWidth - Offset2,
|
||||
Round(FPrinter.PageHeight / ScaleX)
|
||||
)
|
||||
else
|
||||
Result := Rect (Offset1, Offset1,
|
||||
Result := Rect(
|
||||
Offset1,
|
||||
Offset1,
|
||||
Round(FPrinter.PageWidth / ScaleY),
|
||||
ClientHeight - Offset2);
|
||||
ClientHeight - Offset2
|
||||
);
|
||||
end else
|
||||
Result := Rect(3, 3, ClientWidth, ClientHeight);
|
||||
end;
|
||||
@@ -898,7 +882,6 @@ var
|
||||
AspectRect: TRect;
|
||||
WorkHeight: Integer;
|
||||
WorkWidth: Integer;
|
||||
|
||||
begin
|
||||
if FControlLink.Printer.PrintFormats.Count <= 0 then
|
||||
Exit;
|
||||
@@ -906,12 +889,46 @@ var
|
||||
if CurPage > FPageInfo.Count then
|
||||
GeneratePageImage;
|
||||
|
||||
case FZoomFactor of
|
||||
zfFitToControl : begin
|
||||
if FZoomFactor = zfFitToControl then
|
||||
begin
|
||||
AspectRect := GetAspectRectangle;
|
||||
WorkBmp.Canvas.CopyRect (AspectRect, RenderBmp.Canvas,
|
||||
Rect (0, 0,
|
||||
RenderBmp.Width, RenderBmp.Height));
|
||||
WorkBmp.Canvas.CopyRect(
|
||||
AspectRect,
|
||||
RenderBmp.Canvas,
|
||||
Rect (0, 0, RenderBmp.Width, RenderBmp.Height)
|
||||
);
|
||||
RealWidth := AspectRect.Right - AspectRect.Left + 3;
|
||||
RealHeight := AspectRect.Bottom - AspectRect.Top + 3;
|
||||
end else
|
||||
begin
|
||||
WorkWidth := Round(RenderBmp.Width * ZOOM_FACTOR_VALUES[FZoomFactor]);
|
||||
WorkHeight := Round(RenderBmp.Height * ZOOM_FACTOR_VALUES[FZoomFactor]);
|
||||
if WorkHeight > ClientHeight - 3 then WorkHeight := ClientHeight - 3;
|
||||
if WorkWidth > ClientWidth - 3 then WorkWidth := ClientWidth - 3;
|
||||
WorkBmp.Canvas.CopyRect(
|
||||
Rect(3, 3, WorkWidth, WorkHeight),
|
||||
RenderBmp.Canvas,
|
||||
Rect(
|
||||
Round(FScrollX / ZOOM_FACTOR_VALUES[FZoomFactor]),
|
||||
Round(FScrollY / ZOOM_FACTOR_VALUES[FZoomFactor]),
|
||||
Round((WorkWidth + FScrollX) / ZOOM_FACTOR_VALUES[FZoomFactor]),
|
||||
Round((WorkHeight + FScrollY) / ZOOM_FACTOR_VALUES[FZoomFactor])
|
||||
)
|
||||
);
|
||||
RealWidth := round(RenderBmp.Width / ZOOM_FACTOR_VALUES[FZoomFactor]);
|
||||
RealHeight := round(RenderBmp.Height / ZOOM_FACTOR_VALUES[FZoomFactor]);
|
||||
end;
|
||||
|
||||
(*
|
||||
case FZoomFactor of
|
||||
zfFitToControl:
|
||||
begin
|
||||
AspectRect := GetAspectRectangle;
|
||||
WorkBmp.Canvas.CopyRect(
|
||||
AspectRect,
|
||||
RenderBmp.Canvas,
|
||||
Rect (0, 0, RenderBmp.Width, RenderBmp.Height)
|
||||
);
|
||||
RealWidth := AspectRect.Right - AspectRect.Left + 3;
|
||||
RealHeight := AspectRect.Bottom - AspectRect.Top + 3;
|
||||
end;
|
||||
@@ -1024,6 +1041,7 @@ var
|
||||
RealHeight := RenderBmp.Height;
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
|
||||
procedure RenderImage;
|
||||
@@ -1073,7 +1091,6 @@ end;
|
||||
procedure TVpPrintPreview.RemoveHScrollbar;
|
||||
var
|
||||
Style: Integer;
|
||||
|
||||
begin
|
||||
FNeedHScroll := False;
|
||||
Style := GetWindowLong(Handle, GWL_STYLE);
|
||||
@@ -1086,7 +1103,6 @@ end;
|
||||
procedure TVpPrintPreview.RemoveVScrollbar;
|
||||
var
|
||||
Style: Integer;
|
||||
|
||||
begin
|
||||
FNeedVScroll := False;
|
||||
Style := GetWindowLong (Handle, GWL_STYLE);
|
||||
@@ -1114,7 +1130,7 @@ end;
|
||||
|
||||
procedure TVpPrintPreview.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
|
||||
begin
|
||||
inherited SetBounds (aLeft, ATop, AWidth, AHeight);
|
||||
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
|
||||
SetScrollBars;
|
||||
end;
|
||||
|
||||
@@ -1196,7 +1212,6 @@ var
|
||||
RealHeight: Integer;
|
||||
Style: Integer;
|
||||
NeedRecreate: Boolean;
|
||||
|
||||
begin
|
||||
if csDesigning in ComponentState then
|
||||
Exit;
|
||||
@@ -1205,46 +1220,23 @@ begin
|
||||
FScrollY := 0;
|
||||
RealHeight := ClientHeight;
|
||||
RealWidth := ClientWidth;
|
||||
case ZoomFactor of
|
||||
zfActualSize : begin
|
||||
RealHeight := RenderBmp.Height;
|
||||
RealWidth := RenderBmp.Width;
|
||||
end;
|
||||
zfFitToControl : begin
|
||||
if ZoomFactor = zfFitToControl then begin
|
||||
RealHeight := ClientHeight - 4;
|
||||
RealWidth := ClientWidth - 4;
|
||||
end;
|
||||
zf25Percent : begin
|
||||
RealHeight := RenderBmp.Height div 4;
|
||||
RealWidth := RenderBmp.Width div 4;
|
||||
end;
|
||||
zf33Percent : begin
|
||||
RealHeight := RenderBmp.Height div 3;
|
||||
RealWidth := RenderBmp.Width div 3;
|
||||
end;
|
||||
zf50Percent : begin
|
||||
RealHeight := RenderBmp.Height div 2;
|
||||
RealWidth := RenderBmp.Width div 2;
|
||||
end;
|
||||
zf67Percent : begin
|
||||
RealHeight := Round (RenderBmp.Height * 0.67);
|
||||
RealWidth := Round (RenderBmp.Width * 0.67);
|
||||
end;
|
||||
zf75Percent : begin
|
||||
RealHeight := Round (RenderBmp.Height * 0.75);
|
||||
RealWidth := Round (RenderBmp.Width * 0.75);
|
||||
end;
|
||||
end else begin
|
||||
RealHeight := Round(RenderBmp.Height * ZOOM_FACTOR_VALUES[ZoomFactor]);
|
||||
RealWidth := Round(RenderBmp.Width * ZOOM_FACTOR_VALUES[ZoomFactor]);
|
||||
end;
|
||||
|
||||
if (RealWidth > ClientWidth) or (RealHeight > ClientHeight) then begin
|
||||
NeedRecreate := False;
|
||||
Style := GetWindowLong(Handle, GWL_STYLE);
|
||||
if ((Style and WS_HSCROLL) = 0) and (RealWidth > ClientWidth) then begin
|
||||
if (Style and WS_HSCROLL = 0) and (RealWidth > ClientWidth) then begin
|
||||
Style := Style or WS_HSCROLL;
|
||||
FNeedHScroll := True;
|
||||
NeedRecreate := True;
|
||||
end;
|
||||
if ((Style and WS_VSCROLL) = 0) and (RealHeight > ClientHeight) then begin
|
||||
if (Style and WS_VSCROLL = 0) and (RealHeight > ClientHeight) then begin
|
||||
Style := Style or WS_VSCROLL;
|
||||
FNeedVScroll := True;
|
||||
NeedRecreate := True;
|
||||
@@ -1292,47 +1284,30 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpPrintPreview.WMEraseBackground (var Msg : TWMERASEBKGND);
|
||||
{$ELSE}
|
||||
procedure TVpPrintPreview.WMEraseBackground (var Msg : TLMERASEBKGND);
|
||||
{$ENDIF}
|
||||
procedure TVpPrintPreview.WMEraseBackground(var Msg: {$IFDEF DELPHI}TWMERASEBKGND){$ELSE}TLMERASEBKGND){$ENDIF};
|
||||
begin
|
||||
Msg.Result := 1;
|
||||
end;
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpPrintPreview.WMVScroll (var Msg : TWMSCROLL);
|
||||
{$ELSE}
|
||||
procedure TVpPrintPreview.WMVScroll (var Msg : TLMSCROLL);
|
||||
{$ENDIF}
|
||||
procedure TVpPrintPreview.WMVScroll(var Msg: {$IFDEF DELPHI}TWMSCROLL){$ELSE}TLMSCROLL{$ENDIF});
|
||||
begin
|
||||
DoScroll(Msg, SB_VERT);
|
||||
end;
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpPrintPreview.WMHScroll (var Msg : TWMSCROLL);
|
||||
{$ELSE}
|
||||
procedure TVpPrintPreview.WMHScroll (var Msg : TLMSCROLL);
|
||||
{$ENDIF}
|
||||
procedure TVpPrintPreview.WMHScroll(var Msg: {$IFDEF DELPHI}TWMSCROLL){$ELSE}TLMSCROLL){$ENDIF};
|
||||
begin
|
||||
DoScroll(Msg, SB_HORZ);
|
||||
end;
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpPrintPreview.WMRButtonDown(var Msg : TWMRButtonDown);
|
||||
{$ELSE}
|
||||
procedure TVpPrintPreview.WMRButtonDown(var Msg : TLMRButtonDown);
|
||||
{$ENDIF}
|
||||
procedure TVpPrintPreview.WMRButtonDown(var Msg: {$IFDEF DELPHI}TWMRButtonDown{$ELSE}TLMRButtonDown{$ENDIF});
|
||||
var
|
||||
ClientOrigin: TPoint;
|
||||
i: Integer;
|
||||
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if not Assigned (PopupMenu) then begin
|
||||
if not focused then
|
||||
if not Focused then
|
||||
SetFocus;
|
||||
ClientOrigin := GetClientOrigin;
|
||||
|
||||
@@ -1344,8 +1319,7 @@ begin
|
||||
FDefaultPopup.Items[i].Enabled := False;
|
||||
end;
|
||||
|
||||
FDefaultPopup.Popup (Msg.XPos + ClientOrigin.x,
|
||||
Msg.YPos + ClientOrigin.y);
|
||||
FDefaultPopup.Popup(Msg.XPos + ClientOrigin.x, Msg.YPos + ClientOrigin.y);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@@ -16,17 +16,17 @@ object frmPrintPreview: TfrmPrintPreview
|
||||
LCLVersion = '1.7'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 73
|
||||
Height = 62
|
||||
Top = 0
|
||||
Width = 477
|
||||
Align = alTop
|
||||
ClientHeight = 73
|
||||
ClientHeight = 62
|
||||
ClientWidth = 477
|
||||
TabOrder = 0
|
||||
object cboxZoom: TComboBox
|
||||
Left = 217
|
||||
Left = 216
|
||||
Height = 23
|
||||
Top = 40
|
||||
Top = 32
|
||||
Width = 145
|
||||
ItemHeight = 15
|
||||
Items.Strings = (
|
||||
@@ -45,7 +45,7 @@ object frmPrintPreview: TfrmPrintPreview
|
||||
object VpPrintFormatComboBox1: TVpPrintFormatComboBox
|
||||
Left = 8
|
||||
Height = 23
|
||||
Top = 40
|
||||
Top = 32
|
||||
Width = 201
|
||||
ItemHeight = 15
|
||||
Sorted = True
|
||||
@@ -69,13 +69,13 @@ object frmPrintPreview: TfrmPrintPreview
|
||||
TabOrder = 0
|
||||
object btnPrint: TToolButton
|
||||
Left = 1
|
||||
Top = 2
|
||||
Top = 0
|
||||
Action = actPrint
|
||||
end
|
||||
object ToolButton3: TToolButton
|
||||
Left = 52
|
||||
Height = 25
|
||||
Top = 2
|
||||
Top = 0
|
||||
Width = 8
|
||||
Caption = 'ToolButton3'
|
||||
ImageIndex = 2
|
||||
@@ -83,32 +83,32 @@ object frmPrintPreview: TfrmPrintPreview
|
||||
end
|
||||
object btnFirstPage: TToolButton
|
||||
Left = 60
|
||||
Top = 2
|
||||
Top = 0
|
||||
Action = actFirstPage
|
||||
ShowCaption = False
|
||||
end
|
||||
object btnPrevPage: TToolButton
|
||||
Left = 85
|
||||
Top = 2
|
||||
Top = 0
|
||||
Action = actPrevPage
|
||||
ShowCaption = False
|
||||
end
|
||||
object btnNextPage: TToolButton
|
||||
Left = 110
|
||||
Top = 2
|
||||
Action = actPrevPage
|
||||
Top = 0
|
||||
Action = actNextPage
|
||||
ShowCaption = False
|
||||
end
|
||||
object btnLastPage: TToolButton
|
||||
Left = 135
|
||||
Top = 2
|
||||
Top = 0
|
||||
Action = actLastPage
|
||||
ShowCaption = False
|
||||
end
|
||||
object ToolButton8: TToolButton
|
||||
Left = 160
|
||||
Height = 25
|
||||
Top = 2
|
||||
Top = 0
|
||||
Width = 8
|
||||
Caption = 'ToolButton8'
|
||||
ImageIndex = 6
|
||||
@@ -116,15 +116,15 @@ object frmPrintPreview: TfrmPrintPreview
|
||||
end
|
||||
object btnCancel: TToolButton
|
||||
Left = 168
|
||||
Top = 2
|
||||
Top = 0
|
||||
Action = actCancel
|
||||
end
|
||||
end
|
||||
end
|
||||
object VpPrintPreview1: TVpPrintPreview
|
||||
Left = 0
|
||||
Height = 445
|
||||
Top = 73
|
||||
Height = 456
|
||||
Top = 62
|
||||
Width = 477
|
||||
CurPage = 0
|
||||
EndDate = 37355.4526088079
|
||||
|
Reference in New Issue
Block a user