-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUFormView_FitWindow.pas
131 lines (115 loc) · 3.17 KB
/
UFormView_FitWindow.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//-----------------------
function TFormViewUV.GetImageBorderWidth: Integer;
begin
Result := 0;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
Result := Width - ClientWidth;
end;
function TFormViewUV.GetImageBorderHeight: Integer;
begin
Result := 0;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
Result := Height - ClientHeight;
end;
function TFormViewUV.GetImageWidthActual: Integer;
begin
Result := 0;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
begin
if ImageFitToWindow then
Result := ImageWidth
else
Result := Image.Width;
end;
end;
function TFormViewUV.GetImageHeightActual: Integer;
begin
Result := 0;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
begin
if ImageFitToWindow then
Result := ImageHeight
else
Result := Image.Height;
end;
end;
function TFormViewUV.GetImageWidthActual2: Integer;
begin
Result := 0;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
Result := Image.Width;
end;
function TFormViewUV.GetImageHeightActual2: Integer;
begin
Result := 0;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
Result := Image.Height;
end;
function TFormViewUV.GetImageScrollVisible: Boolean;
begin
Result := False;
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
Result := HorzScrollBar.Visible or VertScrollBar.Visible;
end;
procedure TFormViewUV.SetImageScrollVisible(AValue: Boolean);
begin
if Assigned(Viewer.ImageBox) then
with Viewer.ImageBox do
begin
HorzScrollBar.Visible := AValue;
VertScrollBar.Visible := AValue;
end;
end;
//---------------------------------------------------------------
procedure TFormViewUV.UpdateFitWindow(AUseOriginalImageSizes: boolean);
function WidthIncrement: integer;
begin
Result:= 0;
end;
function HeightIncrement: integer;
begin
Result:= 0;
if StatusBar1.Visible then
Inc(Result, StatusBar1.Height);
if Toolbar.Visible then
Inc(Result, Toolbar.Height);
end;
var
ALeft, ATop, AWidth, AHeight: integer;
begin
if (Viewer.Mode=vmodeMedia) and Viewer.IsImage then
if MediaFitWindow then
begin
//Set window sizes
ImageScrollVisible:= false;
if AUseOriginalImageSizes then
begin
AWidth:= ImageWidthActual + ImageBorderWidth;
AHeight:= ImageHeightActual + ImageBorderHeight;
end
else
begin
AWidth:= ImageWidthActual2 + ImageBorderWidth;
AHeight:= ImageHeightActual2 + ImageBorderHeight;
end;
//Return back from Maximized and Full Screen states:
ShowFullScreen:= false;
WindowState:= wsNormal;
ClientWidth:= AWidth + WidthIncrement;
ClientHeight:= AHeight + HeightIncrement;
ImageScrollVisible:= true;
//Move window
ALeft:= IMax(IMin(Left, Screen.WorkAreaWidth - Width), Screen.WorkAreaLeft);
ATop:= IMax(IMin(Top, Screen.WorkAreaHeight- Height), Screen.WorkAreaTop);
AWidth:= IMin(Width, Screen.WorkAreaWidth);
AHeight:= IMin(Height, Screen.WorkAreaHeight);
SetBounds(ALeft, ATop, AWidth, AHeight);
end;
end;