-
Notifications
You must be signed in to change notification settings - Fork 0
/
TopView_.PAS
158 lines (140 loc) · 3.8 KB
/
TopView_.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
unit TopView_;
interface
uses
Views, Streams, Drivers
;
type
PTopView = ^TTopView;
{`2 §®¢ë© ⨯ ¤«ï ⥪áâ , ¢ë¢®¤¨¬®£® ¢ § £®«®¢ª¥ ¯ ¥«¨. }
TTopView = object(TView)
Panel: PView; //ä ªâ¨ç¥áª¨ - PFilePanel
constructor Load(var S: TStream);
procedure Store(var S: TStream); virtual;
procedure Draw; virtual;
{` ’¥ªáâ æ¥âà¨àã¥âáï, ¥ ¯¥à¥ªàë¢ ï í«¥¬¥â ã¯à ¢«¥¨ï ®ª
¬¥¥¤¦¥à `}
function GetPalette: PPalette; virtual;
function GetText(MaxWidth: Integer): String; virtual;
{` â®â ¬¥â®¤ ®¡ï§ â¥«ì® ¤®«¦¥ ¡ëâì ¯¥à¥ªàëâ `}
end;
{`}
PSortView = ^TSortView;
{`2 ˆ¤¨ª æ¨ï ⥪ã饩 á®àâ¨à®¢ª¨ ¯ ¥«¨ ¡ãª®¢ª®© ¢ «¥¢®¬ ¢¥à奬 㣫ã `}
TSortView = object(TView)
Panel: PView; //ä ªâ¨ç¥áª¨ - PFilePanel;
constructor Load(var S: TStream);
procedure Store(var S: TStream); virtual;
procedure Draw; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
end;
implementation
uses
Defines, DblWnd, Advance1, flpanelx, Commands, dnApp, PDSetup
;
const
CTopView = #11#12;
constructor TTopView.Load(var S: TStream);
begin
inherited Load(S);
GetPeerViewPtr(S, Panel);
end;
procedure TTopView.Store(var S: TStream);
begin
inherited Store(S);
PutPeerViewPtr(S, Panel);
end;
function TTopView.GetPalette: PPalette;
const
S: String[Length(CTopView)] = CTopView;
begin
GetPalette := @S;
end;
function TTopView.GetText(MaxWidth: Integer): String;
begin
end;
procedure TTopView.Draw;
var
C: Word;
B: TDrawBuffer;
S: String;
R, OldR: TRect;
D: Integer;
Width: Integer;
Right: Boolean;
begin
Right := PDoubleWindow(Owner)^.Panel[pRight].AnyPanel = Panel;
Width := Panel^.Size.X - 4 - Ord(Right);
{4 - íâ® è¨à¨ í«¥¬¥â ã¯à ¢«¥¨ï (®¬¥à ®ª ¢ «¥¢®© ¯ ¥«¨
¨ ª®¯ª¨ ¬ ªá¨¬¨§ 樨 ¢ ¯à ¢®© ¯ ¥«¨. „«ï ¯à ¢®© ¯ ¥«¨ ¥éñ
®¤¨ ᨬ¢®« - íâ® ¯à®¡¥« ¬¥¦¤ã ¨¤¨ª â®à®¬ á®àâ¨à®¢ª¨ ¨ TopView }
if Width < 1 then
Exit;
S := GetText(Width);
if Length(S) < Width - 2 then
S := ' ' + S + ' ';
R.A := Panel^.Origin;
R.B.Y := R.A.Y;
Dec(R.A.Y);
D := (Width - Length(S) + 4) div 2;
if D >= 4 then
Inc(R.A.X, D) { ¯®ª ¬®¦®, æ¥âà¨à㥬 ¡¥§ ãçñâ ᨬ¬¥âਨ }
else if Right then { ¯à ¢ ï ¯ ¥«ì, ¯à¨¦¨¬ ¥¬ ª ª®¯ª¥ ¬ ªá¨¬¨§ 樨 }
inc(R.A.X, Width - Length(S) + 1)
else { «¥¢ ï ¯ ¥«ì, ¯à¨¦¨¬ ¥¬ ª ®¬¥àã ®ª }
inc(R.A.X, 4);
R.B.X := R.A.X + Length(S);
GetBounds(OldR);
if not MemEqual(R, OldR, SizeOf(R)) then
begin
Locate(R); { ’ã⠡㤥â ४ãàá¨ï, ¯®í⮬㠢â®à®© à § à¨á®¢ âì ¥ ¤® }
Exit;
end;
C := GetColor(1);
if not Panel^.GetState(sfSelected) then
C := GetColor(2);
MoveStr(B[0], S, C);
WriteLine(0, 0, Size.X, Size.Y, B);
end { TTopView.Draw };
{ ---------------------------- TSortView ------------------------------ }
constructor TSortView.Load(var S: TStream);
begin
inherited Load(S);
GetPeerViewPtr(S, Panel);
end;
procedure TSortView.Store(var S: TStream);
begin
inherited Store(S);
PutPeerViewPtr(S, Panel);
end;
procedure TSortView.Draw;
var
B: Word;
C: Char;
R: TRect;
SortSetup: ^TPanelSortSetup;
begin
if (Size.X <> 1) or (Size.Y <> 1) then
begin
GetBounds(R);
R.B.X := R.A.X;
Dec(R.A.X);
R.B.Y := R.A.Y + 1;
Locate(R); // âã⠡㤥â ४ãàá¨ï, ª®â®à ï ¨ à¨áã¥â
Exit;
end;
SortSetup := @PFilePanelRoot(Panel)^.PanSetup^.Sort;
C := GetString(dlSortTag)[SortSetup^.SortMode + 1];
if (SortSetup^.SortFlags and psfInverted) <> 0 then
C := Upcase(C);
MoveChar(B, C, Panel^.Owner^.GetColor(3), 1);
WriteLine(0, 0, 1, 1, B);
end;
procedure TSortView.HandleEvent(var Event: TEvent);
begin
if Event.What = evMouseDown then
begin
ClearEvent(Event);
Message(Panel, evCommand, {cmPanelSortSetup}cmSortBy, nil);
end;
end;
end.