📄 awfview.pas
字号:
W := Succ(R.Right - R.Left);
H := Succ(R.Bottom - R.Top);
{calculate the maximum scrollbar position that will show}
{the right edge of the image flush against the right}
{edge of the window}
if (vScaledWidth > W) then
vMaxHScroll := vScaledWidth - W
else if (vLeftOfs = 0) then
vMaxHScroll := 0
else
vMaxHScroll := vLeftOfs;
{calculate the maximum scrollbar position that will show}
{the bottom edge of the image flush against the bottom}
{edge of the window}
if (vScaledHeight > H) then
vMaxVScroll := vScaledHeight - H
else if (vTopRow = 0) then
vMaxVScroll := 0
else
vMaxVScroll := vTopRow;
end;
end;
procedure TViewer.vScrollUpPrim(Delta : Cardinal);
{-Scroll the display up Delta rows}
var
R : TRect;
begin
if (vImage = nil) then
Exit;
if (Integer(vTopRow - Delta) < 0) then
Delta := vTopRow;
if (Delta = 0) then
Exit;
{change the top row}
Dec(vTopRow, Delta);
{create a rectangle describing the new, invalid region}
GetClientRect(vWnd, R);
R.Bottom := R.Top + Integer(Delta) - 1;
{scroll the window up}
ScrollWindow(vWnd, 0, Delta, nil, nil);
{invalidate and update the changed area}
InvalidateRect(vWnd, @R, False);
UpdateWindow(vWnd);
{if not already scrolling by scrollbar, and the scroll}
{thumb has been homed, reinitialize the scrollbars}
if not vVScrolling and (vTopRow = 0) then
vInitScrollbars
else
{update the scrollbar}
vUpdateScrollThumb(True);
end;
procedure TViewer.vScrollDownPrim(Delta : Cardinal);
{-Scroll the display down Delta rows}
var
R : TRect;
begin
if (vImage = nil) then
Exit;
if ((vTopRow + Delta) > vMaxVScroll) then
Delta := vMaxVScroll - vTopRow;
if (Delta = 0) then
Exit;
{change the top row}
Inc(vTopRow, Delta);
{create a rectangle describing the new, invalid region}
GetClientRect(vWnd, R);
R.Top := R.Bottom - Integer(Delta) + 1;
{scroll the window up}
ScrollWindow(vWnd, 0, -Delta, nil, nil);
{invalidate and update the changed area}
InvalidateRect(vWnd, @R, False);
UpdateWindow(vWnd);
{update the scrollbar}
vUpdateScrollThumb(True);
end;
procedure TViewer.vScrollLeftPrim(Delta : Cardinal);
{-Scroll the display left Delta columns}
var
R : TRect;
W : Word;
begin
if (vImage = nil) then
Exit;
if (Integer(vLeftOfs - Delta) < 0) then
Delta := vLeftOfs;
if (Delta = 0) then
Exit;
{get the width of the client area}
GetClientRect(vWnd, R);
W := Succ(R.Right - R.Left);
{change the left offset}
Dec(vLeftOfs, Delta);
{if the amount to scroll is greater than the display width,}
{then invalidate everything}
if (Delta > W) then
vInvalidateAll
else begin
{create a rectangle describing the new, invalid region}
R.Left := R.Right - Integer(Delta) + 1;
{scroll the window left}
ScrollWindow(vWnd, Delta, 0, nil, nil);
{invalidate and update the changed area}
InvalidateRect(vWnd, @R, False);
end;
{make the changes show}
UpdateWindow(vWnd);
{if not already scrolling by scrollbar, and the scroll}
{thumb has been homed, reinitialize the scrollbars}
if not vHScrolling and (vLeftOfs = 0) then
vInitScrollbars
else
{update the scrollbar}
vUpdateScrollThumb(False);
end;
procedure TViewer.vScrollRightPrim(Delta : Cardinal);
{-Scroll the display right Delta columns}
var
R : TRect;
W : Word;
begin
if (vImage = nil) then
Exit;
if ((vLeftOfs + Delta) > vMaxHScroll) then
Delta := vMaxHScroll - vLeftOfs;
if (Delta = 0) then
Exit;
{get the width of the client area}
GetClientRect(vWnd, R);
W := Succ(R.Right - R.Left);
{change the left offset}
Inc(vLeftOfs, Delta);
{if the amount to scroll is greater than the display width,}
{then invalidate everything}
if (Delta > W) then
vInvalidateAll
else begin
{create a rectangle describing the new, invalid region}
R.Right := R.Left + Integer(Delta) - 1;
{scroll the window left}
ScrollWindow(vWnd, -Delta, 0, nil, nil);
{invalidate and update the changed area}
InvalidateRect(vWnd, @R, False);
end;
{make the changes show}
UpdateWindow(vWnd);
{update the scrollbar}
vUpdateScrollThumb(False);
end;
procedure TViewer.vScrollUp;
{-Scroll the display up vVScrollInc lines}
begin
vScrollUpPrim(vVScrollInc);
end;
procedure TViewer.vScrollDown;
{-Scroll the display down vVScrollInc lines}
begin
vScrollDownPrim(vVScrollInc);
end;
procedure TViewer.vScrollLeft;
{-Scroll the display left vHScrollInc columns}
begin
vScrollLeftPrim(vHScrollInc);
end;
procedure TViewer.vScrollRight;
{-Scroll the display left vHScrollInc columns}
begin
vScrollRightPrim(vHScrollInc);
end;
procedure TViewer.vJumpUp;
{-Scroll the display up vVScrollInc * 10 lines}
begin
vScrollUpPrim(vVScrollInc * 10);
end;
procedure TViewer.vJumpDown;
{-Scroll the display down vVScrollInc * 10 lines}
begin
vScrollDownPrim(vVScrollInc * 10);
end;
procedure TViewer.vJumpLeft;
{-Scroll the display left vHScrollInc * 10 columns}
begin
vScrollLeftPrim(vHScrollInc * 10);
end;
procedure TViewer.vJumpRight;
{-Scroll the display left vHScrollInc * 10 columns}
begin
vScrollRightPrim(vHScrollInc * 10);
end;
procedure TViewer.vHomeVertical;
{-Home the vertical display}
begin
if (vTopRow <> 0) then
vScrollUpPrim(vTopRow);
end;
procedure TViewer.vEndVertical;
{-Scroll the vertical display to the end}
var
H : Word;
R : TRect;
begin
if (vImage = nil) then
Exit;
{get the width of the client area}
GetClientRect(vWnd, R);
H := Succ(R.Bottom - R.Top);
{if the height of the client area is greater than the height of the}
{bitmap, then this is the same as moving home}
if (H > vScaledHeight) then
vHomeVertical
{otherwise, scroll so that the bottom edge of the bitmap is touching}
{the bottom edge of the client area}
else if (vTopRow <> vMaxVScroll) then
vScrollDownPrim(vMaxVScroll - vTopRow);
end;
procedure TViewer.vHomeHorizontal;
{-Home the horizontal display}
begin
if (vImage = nil) then
Exit;
if (vLeftOfs <> 0) then
vScrollLeftPrim(vLeftOfs);
end;
procedure TViewer.vEndHorizontal;
{-Scroll the horizontal display to the end}
var
W : Word;
R : TRect;
begin
if (vImage = nil) then
Exit;
{get the width of the client area}
GetClientRect(vWnd, R);
W := Succ(R.Right - R.Left);
{if the width of the client area is greater than the width of the bitmap,}
{then this is the same as moving home}
if (W > vScaledWidth) then
vHomeHorizontal
{otherwise, scroll so that the right edge of the bitmap is touching}
{the right edge of the client area}
else if (vLeftOfs <> vMaxHScroll) then
vScrollRightPrim(vMaxHScroll - vLeftOfs);
end;
const
InVInitPage : Boolean = False; {Re-entrancy flag}
procedure TViewer.vInitPage;
{-Initialize a new page for viewing}
var
Code : Integer;
I : Integer;
OldCursor : HCursor;
begin
if (vImage = nil) then
Exit;
if not InVInitPage then
try
InVInitPage := True;
if not vLoadWholeFax and (vImage^[vOnPage].Bitmap = 0) then begin
{dispose of old bitmap(s)}
for I := 1 to vNumPages do
if (vImage^[I].Bitmap <> 0) then begin
DeleteObject(vImage^[I].Bitmap);
vImage^[I].Bitmap := 0;
end;
OldCursor := SetCursor(vBusyCursor);
Code := upUnpackPageToBitmap(vUnpacker, vFileName, vOnPage, vImage^[vOnPage], True);
SetCursor(OldCursor);
if (Code < ecOK) then begin
SendMessage(vWnd, apw_ViewerError, Code, 0);
vDisposeFax;
Exit;
end;
if (vRotateDir <> 0) then
if (vRotatePage(vOnPage, vRotateDir) <> ecOK) then begin
SendMessage(vWnd, apw_ViewerError, Word(ecOutOfMemory), 0);
vDisposeFax;
Exit;
end;
end;
{reset page variables and calculate page specific stuff}
vTopRow := 0;
vLeftOfs := 0;
vScaledWidth := DWORD(vImage^[vOnPage].Width) * vHMult div vHDiv;
vScaledHeight := DWORD(vImage^[vOnPage].Height) * vVMult div vVDiv;
vMarked := False;
if vCaptured then
ReleaseCapture;
{initialize scrollbars and redraw}
vInitScrollbars;
vInvalidateAll;
SendMessage(vWnd, apw_ViewNotifyPage, 0, vOnPage);
finally
InVInitPage := False;
end;
end;
procedure TViewer.vPageUp;
{-Go to the previous page}
begin
if (vImage = nil) then
Exit;
if InVInitPage then
Exit;
if (vOnPage > 1) then begin
Dec(vOnPage);
vInitPage;
end;
end;
procedure TViewer.vPageDown;
{-Go to the next page}
begin
if (vImage = nil) then
Exit;
if InVInitPage then
Exit;
if (vOnPage < vNumPages) then begin
Inc(vOnPage);
vInitPage;
end;
end;
procedure TViewer.vFirstPage;
{-Go to the first page}
begin
if (vImage = nil) then
Exit;
if InVInitPage then
Exit;
if (vOnPage = 1) then begin
vHomeVertical;
vHomeHorizontal;
end else begin
vOnPage := 1;
vInitPage;
end;
end;
procedure TViewer.vLastPage;
{-Go to the last page}
begin
if (vImage = nil) then
Exit;
if InVInitPage then
Exit;
if (vNumPages = 1) or (vOnPage = vNumPages) then begin
vHomeVertical;
vHomeHorizontal;
end else begin
vOnPage := vNumPages;
vInitPage;
end;
end;
{$IFNDEF Win32}
procedure ReverseBits(Dest, Src : Pointer; L : Cardinal); assembler;
asm
push ds
lds si,Src {DS:SI->Src}
les di,Dest {ES:DI->Dest}
mov cx,L {Get length of row in CX}
add di,cx {point ES:DI to end of destination}
dec di
dec di
shr cx,1 {count words, not bytes}
@1: cld {go forward}
lodsw {get next input word}
xchg ah,al {put bits in proper order}
@2:
{put reverse of AL in AH}
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
shr ax,1
rcl bx,1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -