forked from unxed/dn2l
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DblWnd.pas
1250 lines (1176 loc) · 35.2 KB
/
DblWnd.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{/////////////////////////////////////////////////////////////////////////
//
// Dos Navigator Open Source 1.51.08
// Based on Dos Navigator (C) 1991-99 RIT Research Labs
//
// This programs is free for commercial and non-commercial use as long as
// the following conditions are aheared to.
//
// Copyright remains RIT Research Labs, and as such any Copyright notices
// in the code are not to be removed. If this package is used in a
// product, RIT Research Labs should be given attribution as the RIT Research
// Labs of the parts of the library used. This can be in the form of a textual
// message at program startup or in documentation (online or textual)
// provided with the package.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// "Based on Dos Navigator by RIT Research Labs."
//
// THIS SOFTWARE IS PROVIDED BY RIT RESEARCH LABS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// The licence and distribution terms for any publically available
// version or derivative of this code cannot be changed. i.e. this code
// cannot simply be copied and put under another distribution licence
// (including the GNU Public Licence).
//
//////////////////////////////////////////////////////////////////////////}
{$I STDEFINE.INC}
unit DblWnd;
interface
uses
Views, Defines, Streams, Drivers, FlPanelX, FlPanel
;
type
TPanelDescr = record
{` Ž¯¨á â¥«ì ®¤®© (¨§ ¤¢ãå) ¯ ¥«¥© }
AnyPanel: PView; // ¥á«¨ í⮩ ¯ ¥«¨ çâ®-â® ¢¨¤® - â® ¨¬¥® íâ®.
FilePanel: PFilePanel; { ” ©«®¢ ï ¯ ¥«ì. ˆ¬¥¥âáï ¢á¥£¤ , ®,
¢®§¬®¦®, áªàëâ , çâ®¡ë ¯®ª § âì ¥ä ©«®¢ãî.
…᫨ ¢¨¤ ä ©«®¢ ï ¯ ¥«ì, â® AnyPanel = FilePanel }
PanelType: Byte; // ⨯ AnyPanel
Drive: Byte; // ¤«ï FilePanel
end;
{`}
TPanelNum = boolean;
{` ‘á뫪 ®¤ã ¨§ ¤¢ãå ¯ ¥«©; ¤«ï £«ï¤®á⨠®¯à¥¤¥«ë
â ª¦¥ ª®áâ âë pLeft ¨ pRight. ‡ 票ï í⮣® ⨯ á«ã¦ â
¤«ï ®â¢¥â ¢®¯à®á "ª®â®à ï", ¯à¨¬¥à, ¨¬¨ ¨¤¥ªá¨àãâáï
TDoubleWindow.Panel.
`}
const
pLeft = false; // ¤«ï TPanelNum
pRight = true; // ¤«ï TPanelNum
type
PSeparator = ^TSeparator;
{`2 ‚¥à⨪ «ìë© à §¤¥«¨â¥«ì ¬¥¦¤ã ¯ ¥«ï¬¨. ˆ¬¨â¨àã¥â «¥¢ãî «¨¨î
à ¬ª¨ ¯à ¢®© ¯ ¥«¨ ¨ ¯à ¢ãî «¨¨î à ¬ª¨ «¥¢®© ¯ ¥«¨ ( á ¬®¬
¤¥«¥ ¯ ¥«¨ à ¬®ª ¥ ¨¬¥îâ ¢®®¡é¥.) }
TSeparator = object(TView)
OldX, OldW: AInt;
constructor Init(R: TRect; AH: Integer);
procedure HandleEvent(var Event: TEvent); virtual;
procedure Draw; virtual;
constructor Load(var S: TStream);
procedure Store(var S: TStream);
end;
{`}
PDoubleWindow = ^TDoubleWindow;
{`2 „¢ãå¯ ¥«ìë© ¬¥¥¤¦¥à.}
TDoubleWindow = object( {TStd}TWindow)
Separator: PSeparator; // ¢¥à⨪ «ìë© ¬¥¦¤ã ¯ ¥«ï¬¨
Panel: array[TPanelNum] of TPanelDescr;
OldBounds: TRect;
OldPanelBounds: TRect;
NonFilePanelType: Byte;
{`⨯ ¥ä ©«®¢®© ¯ ¥«¨; 0, ¥á«¨ â ª®¢®© ¥â`}
NonFilePanel: TPanelNum;
{`Š®â®à ï ¨§ ¯ ¥«¥© ¥ä ©«®¢ ï; ¬ãá®à, ¥á«¨ ®¡¥ ä ©«®¢ë¥ `}
PanelZoomed: Boolean;
{` Ž¤ ¨§ ¯ ¥«¥© ¬ ªá¨¬¨§¨à®¢ `}
SinglePanel: Boolean;
{` ë« «¨ ¯ ¥«ì ¤® ¬ ªá¨¬¨§ 樨 ¥¤¨á⢥®© `}
isValid: Boolean;
constructor Init(Bounds: TRect; ANumber, ADrive: Integer);
procedure InitPanel(N: TPanelNum; R: TRect);
procedure InitInterior;
constructor Load(var S: TStream);
procedure Store(var S: TStream);
procedure SwitchView(dtType: Byte);
{`‘¤¥« âì ¥ ªâ¨¢ãî ¯ ¥«ì 㪠§ ®£® ⨯ , ¥á«¨ ᥩç á ã
¥ñ ¤à㣮© ⨯; ¥á«¨ ¨¬¥® â ª®© - ⮠ᤥ« âì ¯ ¥«ì
ä ©«®¢®©`}
function Valid(C: Word): Boolean; virtual;
procedure ChangeBounds(var Bounds: TRect); virtual;
procedure HandleCommand(var Event: TEvent);
{`DblWnd`}
procedure SwitchPanel(N: TPanelNum);
{`áªàëâì/¯®ª § âì ¯ ¥«ì`}
procedure ChangeDrv(N: TPanelNum);
{`ᬥ¨âì ¤¨áª á ¤¨ «®£®¬ (Alt-F1/F2)`}
procedure SetMaxiState(P: PFilePanelRoot);
{` “áâ ®¢¨âì á®áâ®ï¨¥ ¬ ªá¨¬¨§¨à®¢ ®á⨠ªâ¨¢®© ä ©«®¢®©
¯ ¥«¨ ¢ ᮮ⢥âá⢨¨ á ¥ñ áâனª®© `}
procedure ToggleViewMaxiState(P: PView; Other: TPanelNum);
{` ˆ¢¥àâ¨à®¢ âì á®áâ®ï¨¥ ¬ ªá¨¬¨§¨à®¢ ®á⨠ªâ¨¢®© ¯ ¥«¨
(¢®§¬®¦®, ¥ä ©«®¢®©). ®¬¥à ¤à㣮© ¯ ¥«¨ - Other `}
end;
{`}
const
CDoubleWindow = #80#81#82+ { 1-3 Frame (P,A,I) }
#83#84+ { 4,5 Scroll Bar (Page, Arrow) }
#85#86#87#88#89+ { 6-10 Panel (NT,Sp,ST,NC,SC) }
#90#91+ { 11,12 Panel Top (A,P) }
#92#93+ { 13,14 Viewer (NT,ST) }
#94#95#96#97+
#98#99#100+ { 15-21 Tree (T,NI,SI,Df,DS,SI,DI}
#101+ { 22 Tree info }
#102#103+ { 23,24 Disk info (NT, HT) }
#119#120#121#122+
#123#124#125+ { 25-31 File Info }
#165+ { 32 File Panel }
#172#173#174#175#176#177#180#181+ { 33-40 Highlight groups}
#186#187#188+ { 41-43 Drive Line }
#192#193#194#195#196+ { 44-48 JO - 5 additional highlight groups}
#130#131; { 49,50 JO - File Info (LFN in footer)}
const
dtPanel = 1;
dtInfo = 2;
dtTree = 3;
dtQView = 4;
dtDizView = 5;
{$IFDEF NETINFO}
dtNetInfo = 6; {-$VIV}
{$ENDIF}
implementation
uses
DiskInfo, Commands, FileCopy, FilesCol, Advance, Advance1, Advance2,
Startup, DNApp, TopView, Tree, FViewer
{$IFDEF NETINFO}, NetInfo {-$VIV} {$ENDIF}
, Dos, VPUtils
;
constructor TDoubleWindow.Init;
var
P: PFilePanel;
R: TRect;
PV: PView;
i: TPanelNum;
begin
inherited Init(Bounds, '', ANumber);
Options := Options or ofTileable;
EventMask := $FFFF;
Abort := False;
if (ADrive <= 0) or not ValidDrive(Char(ADrive+64)) then
ADrive := 0;
Panel[pLeft].Drive := ADrive;
Panel[pRight].Drive := ADrive;
GetExtent(R);
R.Grow(-1, 0);
R.A.X := R.B.X div 2;
R.B.X := R.A.X+2;
Separator := New(PSeparator, Init(R, Size.X));
Insert(Separator);
InitInterior;
PassivePanel := Panel[pLeft].FilePanel;
if not Abort then
isValid := True;
case FMSetup.LeftPanelType of
fdoInfoDrive:
Message(@Self, evCommand, cmDiskInfo, nil);
fdoTreeFrive:
Message(@Self, evCommand, cmDirTree, nil);
fdoRightOnly:
Message(@Self, evCommand, cmHideLeft, nil);
end {case};
end { TDoubleWindow.Init };
procedure TDoubleWindow.InitPanel(N: TPanelNum; R: TRect);
var
PV: PMyScrollBar;
P: PFilePanel;
P1: PInfoView;
P2: PDirView;
P3: PSortView;
PD: PDriveLine;
B: TRect;
begin
if Abort then
Exit;
B := R;
B.A.X := B.B.X;
Inc(B.B.X);
Inc(B.A.Y);
Dec(B.B.Y, 3);
New(PV, Init(B));
New(P, Init(R, Panel[N].Drive, PV));
if Abort then
begin
Dispose(P, Done);
Dispose(PV, Done);
Exit
end;
New(P1, Init(R));
P1^.Panel := P;
P1^.CompileShowOptions;
P^.InfoView := P1;
New(P2, Init(R));
P2^.Panel := P;
P^.DirView := P2;
P2^.EventMask := $FFFF;
New(P3, Init(R));
P3^.Panel := P;
P^.SortView := P3;
P3^.EventMask := evMouseDown;
New(PD, Init(R, P));
P^.DriveLine := PD;
P^.ChangeBounds(R);
Insert(PV);
Insert(P3);
Insert(P2);
Insert(P1);
Insert(P);
Insert(PD);
with Panel[N] do
begin
AnyPanel := P;
FilePanel := PFilePanel(P);
PanelType := dtPanel;
FilePanel.SelfNum := N;
P^.Select;
end;
end { TDoubleWindow.InitPanel };
function TDoubleWindow.Valid;
begin
Valid := inherited Valid(C) and isValid;
end;
procedure TDoubleWindow.ChangeBounds(var Bounds: TRect);
var
D: TPoint;
R: TRect;
SVisible: Boolean;
N: TPanelNum;
label 1;
begin
D.X := Bounds.B.X-Bounds.A.X-Size.X;
D.Y := Bounds.B.Y-Bounds.A.Y-Size.Y;
GetExtent(R);
R.Grow(-1, 0);
R.A.X := (R.B.X*Separator^.OldX) div Separator^.OldW;
if D.EqualsXY(0, 0) and (R.A.X = Separator^.Origin.X) then
begin
SetBounds(Bounds);
DrawView;
end
else
begin
FreeBuffer;
SetBounds(Bounds);
GetExtent(Clip);
GetBuffer;
Lock;
GetExtent(R);
Frame^.ChangeBounds(R);
SVisible := Separator^.GetState(sfVisible);
for N := pLeft to pRight do
begin
with Panel[N] do
if not AnyPanel^.GetState(sfVisible) then
begin
if SVisible then
Separator^.Hide;
GetExtent(R);
R.Grow(-1, -1);
Panel[not N].AnyPanel^.ChangeBounds(R);
goto 1;
end;
end;
if not SVisible then
Separator^.Show;
GetExtent(R);
R.Grow(-1, 0);
R.A.X := (R.B.X*Separator^.OldX) div Separator^.OldW;
R.B.X := R.A.X+2;
Separator^.ChangeBounds(R);
GetExtent(R);
R.Grow(-1, -1);
R.A.X := (R.B.X*Separator^.OldX) div Separator^.OldW+2;
Panel[pRight].AnyPanel^.ChangeBounds(R);
GetExtent(R);
R.Grow(-1, -1);
R.B.X := (R.B.X*Separator^.OldX) div Separator^.OldW;
Panel[pLeft].AnyPanel^.ChangeBounds(R);
1:
Redraw;
UnLock;
end;
end { TDoubleWindow.ChangeBounds };
constructor TDoubleWindow.Load;
const
SaveBlockLen =
SizeOf(OldBounds) +
SizeOf(OldPanelBounds) +
SizeOf(NonFilePanelType) +
SizeOf(NonFilePanel) +
SizeOf(PanelZoomed) +
SizeOf(SinglePanel);
var
N: TPanelNum;
begin
inherited Load(S);
S.Read(OldBounds, SaveBlockLen);
GetSubViewPtr(S, Separator);
for N := pLeft to pRight do
with Panel[N] do
begin
S.Read(PanelType, SizeOf(PanelType)+SizeOf(Drive));
GetSubViewPtr(S, FilePanel);
if FilePanel = nil then
Fail;
AnyPanel := FilePanel;
FilePanel.SelfNum := N;
end;
PassivePanel := OtherFilePanel(ActivePanel);
if NonFilePanelType <> 0 then
GetSubViewPtr(S, Panel[NonFilePanel].AnyPanel);
{Cat}
if (Separator = nil)
or (Panel[pLeft].AnyPanel = nil) or (Panel[pRight].AnyPanel = nil)
then
Fail;
{/Cat}
case NonFilePanelType of
dtQView, dtDizView:
with Panel[not NonFilePanel].FilePanel^ do
begin
QuickViewEnabled := True;
SendLocated;
end;
dtTree:
with PHTreeView(Panel[NonFilePanel].AnyPanel)^ do
ReadAfterLoad;
dtInfo:
with PDiskInfo(Panel[NonFilePanel].AnyPanel)^ do
begin
OtherPanel := Panel[not NonFilePanel].FilePanel;
ReadData;
end;
end {case};
isValid := True;
end { TDoubleWindow.Load };
procedure TDoubleWindow.Store;
const
SaveBlockLen =
SizeOf(OldBounds) +
SizeOf(OldPanelBounds) +
SizeOf(NonFilePanelType) +
SizeOf(NonFilePanel) +
SizeOf(PanelZoomed) +
SizeOf(SinglePanel);
var
N: TPanelNum;
begin
inherited Store(S);
S.Write(OldBounds, SaveBlockLen);
PutSubViewPtr(S, Separator);
for N := pLeft to pRight do
with Panel[N] do
begin
S.Write(PanelType, SizeOf(PanelType)+SizeOf(Drive));
PutSubViewPtr(S, FilePanel);
end;
if NonFilePanelType <> 0 then
PutSubViewPtr(S, Panel[NonFilePanel].AnyPanel);
end { TDoubleWindow.Store };
const
VScrollRect: TRect = (A:(X:1;Y:1);B:(X:2;Y:5));
{‘ãé¥á⢥®, çâ® B.X-A.X = 1, â® ¥áâì ¢¥à⨪ «ìë©.
Žá⠫쮥 ¥ ¢ ¦®.}
{ ‘®§¤ ¨¥ ¢¥à⨪ «ì®£® áªà®««¡ à ¤«ï ¯ ¥«¨ ¯à®á¬®âà }
function MakeVScroll: PViewScroll;
begin
Result := New(PViewScroll, Init(VScrollRect));
Result^.Options := Result^.Options or ofPostProcess;
end;
{ Š®â஫ì ᢥ¦¥á®§¤ ®© ¥ä ©«®¢®© ¯ ¥«¨ P; ¯à¨ ®è¨¡ª å ¡ã¤¥â P=nil }
function ValidVP(var P: PView; S: PView {áªà®««¡ à}): Boolean;
begin
Result := False;
if (S = nil) or (P = nil) or not P^.Valid(0) then
begin
S.Free;
P.Free;
P := nil;
Exit;
end;
Result := True;
end;
procedure InsertView(var P: PView; S: PView; Manager: PDoubleWindow);
begin
if ValidVP(P, S) then
with Manager do
begin
Insert(P);
Insert(S);
P^.Hide;
end;
end;
{ ®áâந⥫¨ ¥ä ©«®¢ëå ¯ ¥«¥© }
function InsertQView(R1: TRect;
Manager: PDoubleWindow; Other: PFilePanelRoot): PView;
var
S: PViewScroll;
begin
S := MakeVScroll;
Result := New(PQFileViewer, Init(R1, nil, '', '', S, True,
(EditorDefaults.ViOpt and 1) <> 0));
InsertView(Result, S, Manager);
end { InsertQView };
function InsertDizView(R1: TRect;
Manager: PDoubleWindow; Other: PFilePanelRoot): PView;
var
S: PViewScroll;
begin
S := MakeVScroll;
Result := New(PDFileViewer, Init(R1, nil, '', '', S, True,
(EditorDefaults.ViOpt and 1) <> 0));
InsertView(Result, S, Manager);
end { InsertDizView };
function InsertTree(R1: TRect;
Manager: PDoubleWindow; Other: PFilePanelRoot): PView;
var
S: PMyScrollBar;
P: PView;
begin
S := New(PMyScrollBar, Init(VScrollRect));
S^.Options := S^.Options or ofPostProcess;
{ Ž¡« áâì ¤¥«¨¬ ¯® ¢¥à⨪ «¨ ¬¥¦¤ã ¯®¤¢ «®¬ (2 áâப¨) ¨ ¤¥à¥¢®¬}
Dec(R1.B.Y, 2);
Result := New(PHTreeView, Init(R1, 0, False, S));
if ValidVP(Result, S) then
begin
R1.A.Y := R1.B.Y;
Inc(R1.B.Y, 2);
P := New(PTreeInfoView, Init(R1, PHTreeView(Result)));
PHTreeView(Result)^.Info := P;
with Manager do
begin
Insert(P);
Insert(Result);
Insert(S);
end;
end;
end { InsertTree };
function InsertInfo(R1: TRect;
Manager: PDoubleWindow; Other: PFilePanelRoot): PView;
begin
Result := New(PDiskInfo, Init(R1, Other));
Result^.Hide;
Manager.Insert(Result);
PDiskInfo(Result)^.InsertDriveView;
PDiskInfo(Result)^.ReadData;
// â® ¤® ¤¥« âì ¯®á«¥ Insert
end { InsertTree };
type
TPanelConstructor = function(R1: TRect;
Manager: PDoubleWindow; Other: PFilePanelRoot): PView;
{ ‚ íâ®â ¬ áᨢ ªâ® 㣮¤® (¯« £¨, ª ¯à¨¬¥àã) ¬®¦¥â ¤®¡ ¢¨âì ᢮©
í«¥¬¥â ¢¬¥áâ® «î¡®£® nil, ¯®á«¥ 祣® íâ®â ®¢ë© ⨯ ¥ä ©«®¢®© ¯ ¥«¨
¬®¦® ¡ã¤¥â ¡¥§ ¯à®¡«¥¬ ¢ª«îç âì-¢ëª«îç âì ç¥à¥§ SwitchView ¯®
ᮮ⢥âáâ¢ãîé¥ã ®¬¥àã.}
const
PanelConstructor: array[dtInfo..10] of TPanelConstructor =
( InsertInfo
, InsertTree
, InsertQView
, InsertDizView
, nil
, nil
, nil
, nil
, nil
);
procedure TDoubleWindow.SwitchView(dtType: Byte);
var
R1: TRect;
V: PView;
N, Selected: TPanelNum;
VisibleN: Boolean;
label Ex;
begin
Lock;
if PanelZoomed then
Message(@Self, evCommand, cmMaxi, nil);
{ ਠPanelZoomed ¬®¦¥â ¯®âॡ®¢ âìáï SwitchView ⮫쪮 ¥á«¨
¬ ªá¨¬¨§¨à®¢ ï ¯ ¥«ì - ä ©«®¢ ï. ’® ¥áâì íâ® çâ®-â® ¢à®¤¥
Ctrl-Q ¯à¨ ¬ ªá¨¬¨§¨à®¢ ®© ¯ ¥«¨. —â®¡ë ¡ë«® £¤¥ ®âªàë¢ âì
¥ä ©«®¢ãî ¯ ¥«ì, ¬ ªá¨¬¨§ æ¨î ¤® ã¡à âì. }
Selected := Panel[pRight].AnyPanel^.GetState(sfSelected);
N := not Selected;
VisibleN := Panel[N].AnyPanel^.GetState(sfVisible);
Panel[N].AnyPanel^.GetBounds(R1);
{ …᫨ ¥ä ©«®¢ ï ¯ ¥«ì ¡ë« - ¥¥ ¤® ¢ «î¡®¬ á«ãç ¥ ã¨ç⮦¨âì.
…᫨ ® ¡ë« , ¨ ¯à¨â®¬ ¨¬¥® ⨯ dtType, â® ¤® ¡ã¤¥â ¢®ááâ ®¢¨âì
ä ©«®¢ãî ¯ ¥«ì; ¢ ®áâ «ìëå á«ãç ïå ᮧ¤ âì ¯ ¥«ì dtType. …᫨ ¥ñ
¥ ¡ë«®, ¤® ¯®£ á¨âì ä ©«®¢ãî ¯ ¥«ì}
with Panel[N].AnyPanel^ do
begin
if not VisibleN then
SwitchPanel(N);
Hide;
if NonFilePanelType <> 0 then
Free;
end;
if NonFilePanelType <> dtType then
begin
NonFilePanelType := 0;
V := PanelConstructor[dtType](R1, @self, Panel[not N].FilePanel);
if V = nil then
goto Ex;
NonFilePanel := N;
NonFilePanelType := dtType;
Panel[N].AnyPanel := V;
R1.A.Y := 1;
R1.B.Y := Size.Y-1;
V^.Locate(R1);
V^.Show;
Panel[N].PanelType := dtType;
Panel[Selected].AnyPanel^.Select;
if dtType in [dtQView, dtDizView] then
Panel[Selected].FilePanel.QuickViewEnabled := True;
Redraw;
end
else
begin
NonFilePanelType := 0;
if VisibleN then
begin
Panel[N].AnyPanel := Panel[N].FilePanel;
R1.A.Y := 1;
R1.B.Y := Size.Y-1;
Panel[N].FilePanel^.Locate(R1);
Panel[N].FilePanel^.Show;
Panel[N].PanelType := dtPanel;
Panel[not N].FilePanel.QuickViewEnabled := False;
if not N <> Selected then
Panel[not N].FilePanel^.Select;
end
else
if not VisibleN then
SwitchPanel(N);
end;
Ex:
UnLock;
end { TDoubleWindow.SwitchView };
procedure TDoubleWindow.InitInterior;
var
R: TRect;
RP: array[TPanelNum] of TRect;
N: TPanelNum;
begin
GetExtent(R);
R.Grow(-1, -1);
RP[pRight] := R;
RP[pLeft] := R;
RP[pLeft].B.X := RP[pLeft].B.X div 2;
RP[pRight].A.X := RP[pLeft].B.X + 2;
for N := pLeft to pRight do
begin
InitPanel(N, RP[N]);
if Abort then
Exit;
end;
end { TDoubleWindow.InitInterior };
{ ‘ªàëâì/¯®ª § âì ¯ ¥«ì }
procedure TDoubleWindow.SwitchPanel(N: TPanelNum);
var
R, RN: TRect;
ThisPanel: PView;
NewXBound: Integer;
ForceResize: Boolean;
begin
if PanelZoomed or not Panel[not N].AnyPanel^.GetState(sfVisible) then
Exit;
Lock;
GetBounds(R);
ThisPanel := Panel[N].AnyPanel;
if ThisPanel^.GetState(sfVisible) then
begin // áªàëâì
OldBounds := R;
NewXBound := Separator^.Origin.X+R.A.X+1;
if N then {áªàë¢ ¥¬ ¯à ¢ãî}
R.B.X := NewXBound
{ …᫨ è¨à¨ ¬¥¥¤¦¥à áâ « ¬¥ìè¥ MinWinSize.X, â®
ChangeBounds à áè¨à¨â ®ª® ¢¯à ¢®, çâ® ¨ âॡã¥âáï}
else {áªàë¢ ¥¬ «¥¢ãî}
begin
R.A.X := NewXBound;
if R.B.X-R.A.X < MinWinSize.X then
R.A.X := R.B.X - MinWinSize.X;
{ € âãâ ¤® à áè¨àïâì ¢«¥¢®, â ª çâ® ¤¥« ¥¬ íâ® á ¬¨ }
end;
ThisPanel^.Hide;
end
else
begin // ¯®ª § âì
ThisPanel^.Show;
R.A.X := OldBounds.A.X;
R.B.X := OldBounds.B.X;
end;
if OldBounds.B.X - OldBounds.A.X = MinWinSize.X then {<Dblwnd.002>}
begin
Inc(R.B.X);
ChangeBounds(R);
Dec(R.B.X);
end;
Locate(R);
UnLock;
end { TDoubleWindow.SwitchPanel };
{ ‘¬¥ ¤¨áª ç¥à¥§ ¬¥î Alt-F1/F2 }
procedure TDoubleWindow.ChangeDrv(N: TPanelNum);
var
R, R1: TRect;
S: String;
P: TPoint;
ThisPanel: PView;
PanelSelected, PanelVisible: Boolean;
begin
ThisPanel := Panel[N].AnyPanel;
PanelVisible := ThisPanel^.GetState(sfVisible);
if (NonFilePanelType <> 0) and (N = NonFilePanel) then
begin
ThisPanel^.GetBounds(R);
R.A.Y := 1;
R.B.Y := Size.Y;
Panel[N].FilePanel^.Locate(R);
end;
GetBounds(R);
if not PanelVisible or (Panel[N].PanelType <> dtPanel) then
begin
with ThisPanel do
P.X := Origin.X + Size.X div 2 - 8;
P.Y := Origin.Y+3;
S := SelectDrive(P.X, P.Y,
Panel[N].FilePanel^.DirectoryName[1], True);
if S = '' then
Exit;
ClrIO;
Lock;
if not PanelVisible then
SwitchPanel(N);
Message(Panel[N].FilePanel, evCommand, cmChangeDrv, @S);
with Panel[N] do
begin
if PanelType <> dtPanel then
begin
with Panel[NonFilePanel].AnyPanel^ do
begin
PanelSelected := GetState(sfSelected);
GetBounds(R1);
Hide;
Free;
end;
NonFilePanelType := 0;
R1.A.Y := 1;
R1.B.Y := Size.Y-1;
FilePanel^.Locate(R1);
AnyPanel := FilePanel;
PanelType := dtPanel;
FilePanel^.Show;
if PanelSelected then
FilePanel^.Select;
end;
end;
end
else
begin
Message(Panel[N].FilePanel, evCommand, cmChangeDrive, nil);
end;
if (ShiftState and 3 <> 0) and (PanelSelected <> N) then
ThisPanel^.Select;
UnLock;
end { TDoubleWindow.ChangeDrv };
procedure TDoubleWindow.SetMaxiState(P: PFilePanelRoot);
var
Other: TPanelNum;
begin
if PanelZoomed and (P = PassivePanel) then
begin { ®¯ë⪠¬ ªá¨¬¨§¨à®¢ âì ¯ áᨢãî ¯ ¥«ì, ª®£¤ ªâ¨¢ ï 㦥
¬ ªá¨¬¨§¨à®¢ . ‚ í⮬ á«ãç ¥ ¥ ¬ ªá¨¬¨§¨à㥬 ¥ñ, ®¡®à®â,
á¡à áë¢ ¥¬ ¢ ¥ñ áâனª å ä« £ ¬ ªá¨¬¨§ 樨. ‚ë¥¨¥ í⮩ á¨âã 樨
¤¥« ¥âáï áà ¢¥¨¥¬ á PassivePanel, ¥ ¯à®¢¥àª®© ¢¨¤¨¬®áâ¨,
â ª ª ª ¢® ¢à¥¬ï Load ¯ ¥«ì ¢¯®«¥ ¬®¦¥â ¡ëâì ¥¢¨¤¨¬®©. }
with P^.PanSetup^.Show do
MiscOptions := MiscOptions and not 1;
end
else if ((P^.PanSetup^.Show.MiscOptions and 1) <> 0) <>
PanelZoomed
then
ToggleViewMaxiState(P, not P^.SelfNum);
end;
procedure TDoubleWindow.ToggleViewMaxiState(P: PView; Other: TPanelNum);
begin
Lock;
if not PanelZoomed then
begin { Œ ªá¨¬¨§¨à®¢ âì }
SinglePanel := not Panel[Other].AnyPanel^.GetState(sfVisible);
if not SinglePanel then
SwitchPanel(Other);
GetBounds(OldPanelBounds);
ChangeBounds(OldBounds);
PanelZoomed := True;
end
else
begin { “¡à âì ¬ ªá¨¬¨§ æ¨î }
if SinglePanel then
Hide; {AK155 ®ç¥¬ã-â® ¡¥§ í⮣® ¥ áâ¨à îâáï
®áâ ⪨ à ᯠåã⮩ ¯ ¥«¨ }
ChangeBounds(OldPanelBounds);
Show;
PanelZoomed := False;
if not SinglePanel then
SwitchPanel(Other);
end;
UnLock;
end;
procedure TDoubleWindow.HandleCommand;
var
Selected: Boolean;
Visible: array [TPanelNum] of Boolean;
Sp: PSeparator;
EV: TEvent;
procedure CE;
begin
ClearEvent(Event)
end;
{ Ÿ¢«ï¥âáï «¨ Selected ¯ ¥«ì ä ©«®¢®©, â® ¥áâì ¬®¦® «¨ ª ¥© 楯«ïâì
¥ä ©«®¢ãî ¯ ¥«ì }
function isFilePanel: Boolean;
begin
result := (NonFilePanelType = 0) or (Selected <> NonFilePanel);
end;
procedure InsertPath(N: TPanelNum);
var
S: string;
begin
S := '';
Message(Panel[N].AnyPanel, evCommand, cmGetDirName, @S);
if S <> '' then
begin
if not (S[Length(S)] in ['\', '/']) then
AddStr(S, '/'); // slash change by unxed
S := SquashesName(S);
Message(CommandLine, evCommand, cmInsertName, @S);
end;
CE;
end;
{ ‘¤¢¨£ à §¤¥«¨â¥«ï ¢¯à ¢® (D=1) ¨«¨ ¢«¥¢® (D=-1). …᫨
¦ â Shift - ⮠楫ãî ä ©«®¢ãî ª®«®ªã }
procedure SeparatorMove(D: Integer);
var
X: Integer;
N: TPanelNum;
R: TRect;
begin
if Visible[pRight] and Visible[pLeft] then
begin
if ShiftState and (kbLeftShift+kbRightShift) <> 0 then
begin
{ ਠᤢ¨£¥ è¨à¨ã ä ©«®¢®© ª®«®ªã ¤® ¢ë¡à âì ¯ ¥«ì,
¨§ ª®â®à© ¡à âì íâã á ¬ãî è¨à¨ã. ¥àñ¬ ªâ¨¢ãî, ¥á«¨ ®
ä ©«®¢ ï, ¨«¨ ¤àã£ãî, ¥á«¨ ªâ¨¢ ï - ¥ä ©«®¢ ï.}
N := Selected xor (Panel[Selected].PanelType <> dtPanel);
D := D*Panel[N].FilePanel^.LineLength;
end;
Sp^.OldW := Size.X;
X := Sp^.Origin.X + D + 1;
Sp^.OldX := Min(Max(X, 0), Sp^.OldW);
GetBounds(R);
ChangeBounds(R);
CE;
end;
end;
var
R, R1, R2: TRect;
I, K: Integer;
AP, PP: PFilePanel;
D: Word;
P: PView;
N: TPanelNum;
S: String;
WPanel: TPanelDescr;
WR: array[TPanelNum] of TRect;
begin { TDoubleWindow.HandleCommand }
for N := pLeft to pRight do
Visible[N] := Panel[N].AnyPanel^.GetState(sfVisible);
Selected := Panel[pRight].AnyPanel^.GetState(sfSelected);
Sp := Separator;
case Event.What of
evKeyDown:
case Event.KeyCode of
kbCtrlLeft, kbCtrlRight,
kbCtrlShiftLeft, kbCtrlShiftRight:
if not QuickSearch and
(FMSetup.LRCtrlInDriveLine <> fdlNoDifference) and
(Visible[pLeft] and Visible[pRight]) then
begin
N := (ShiftState2 and 1 = 0);
if (FMSetup.LRCtrlInDriveLine = fdlPassive) then
N := N xor not Selected;
Panel[N].AnyPanel^.HandleEvent(Event);
Exit;
end;
kbAlt1, kbAlt2, kbAlt3, kbAlt4, kbAlt5, kbAlt0,
kbAlt6, kbAlt7, kbAlt8, kbAlt9:
if FMSetup.Options and fmoAltDifference <> 0 then
begin
if Visible[pLeft] and (ShiftState2 and 2 <> 0) then
Panel[pLeft].AnyPanel^.HandleEvent(Event)
else
Panel[pRight].AnyPanel^.HandleEvent(Event);
Exit;
end;
{
kbCtrl1, kbCtrl2, kbCtrl3, kbCtrl4, kbCtrl5, kbCtrl6, kbCtrl7,
kbCtrl8, kbCtrl9, kbCtrl0:
if FMSetup.Options and fmoCtrlDifference <> 0 then
begin
if Visible[pLeft] and (ShiftState2 and 1 <> 0) then
Panel[pLeft].AnyPanel^.HandleEvent(Event) else
Panel[pRight].AnyPanel^.HandleEvent(Event);
Exit;
end;
}
kbAltLeft, kbAltShiftLeft:
SeparatorMove(-1);
kbAltRight, kbAltShiftRight:
SeparatorMove(1);
kbAltCtrlSqBracketL, kbCtrlSqBracketL:
InsertPath(pLeft);
kbAltCtrlSqBracketR, kbCtrlSqBracketR:
InsertPath(pRight);
end {case};
evBroadcast:
case Event.Command of
cmLookForPanels:
ClearEvent(Event);
cmGetUserParams, cmGetUserParamsWL:
begin
PP := Panel[not Selected].FilePanel;
AP := Panel[Selected].FilePanel;
with PUserParams(Event.InfoPtr)^ do
begin
AP^.GetUserParams(Active, ActiveList, Event.Command =
cmGetUserParamsWL);
PP^.GetUserParams(Passive, PassiveList, Event.Command =
cmGetUserParamsWL);
end;
CE;
end;
cmChangeDirectory:
begin
Panel[Selected].FilePanel^.ChDir(PString(Event.InfoPtr)^);
CE;
end;
cmChangeDrv: {ª®¬áâப ⨯ C: ¨«¨ *: }
begin
Event.What := evCommand;
Panel[Selected].FilePanel^.HandleEvent(Event);
ClearEvent(Event);
end;
cmIsRightPanel:
if Event.InfoPtr = Panel[pRight].FilePanel then
ClearEvent(Event);
end {case};
evCommand:
case Event.Command of
cmSwitchOther:
if not PanelZoomed then
begin
CE;
SwitchPanel(not Selected);
end;
cmZoom:
begin
{ Flash 05-02-2004 >>> }
if Panel[Selected].PanelType = dtQView then
begin
GetBounds(OldBounds);
GetBounds(OldPanelBounds);
if (Size.X < Desktop.Size.X) or PanelZoomed then
Message(@Self, evCommand, cmMaxi, nil);
end;
{ Flash 05-02-2004 <<< }
end;
cmMaxi:
begin
CE;
if (NonFilePanelType <> 0) and (NonFilePanel = Selected) then
begin { à ¡®â á ¥ä ©«®¢®© ¯ ¥«ìî }
ToggleViewMaxiState(Panel[Selected].AnyPanel, not Selected);
end
else
begin { à ¡®â á ä ©«®¢®© ¯ ¥«ìî }
with ActivePanel^.PanSetup^.Show do
MiscOptions := MiscOptions xor 1;
SetMaxiState(ActivePanel);
end;
end;
cmGetName:
begin
PString(Event.InfoPtr)^:= GetString(dlFileManager);
K := (55-Length(PString(Event.InfoPtr)^)) div 2;
for N := pLeft to pRight do
begin
S := '??'; // á«ãç ©, ¥á«¨ ®ª® ¥ ®¡à ¡®â ¥â cmGetName
Message(Panel[N].AnyPanel, evCommand, cmGetName, @S);
PString(Event.InfoPtr)^:= PString(Event.InfoPtr)^+
Cut({$IFDEF RecodeWhenDraw}CharToOemStr{$ENDIF}(S),K);