forked from amix/photoshop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
UFloat.p
3742 lines (2499 loc) · 66.8 KB
/
UFloat.p
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
{Photoshop version 1.0.1, file: UFloat.p
Computer History Museum, www.computerhistory.org
This material is (C)Copyright 1990 Adobe Systems Inc.
It may not be distributed to third parties.
It is licensed for non-commercial use according to
www.computerhistory.org/softwarelicense/photoshop/ }
UNIT UFloat;
INTERFACE
USES
{$LOAD MacIntf.LOAD}
MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
{$LOAD UMacApp.LOAD}
UObject, UList, UMacApp,
{$LOAD UPhotoshop.LOAD}
PaletteMgr, UConstants, UVMemory, UPhotoshop,
{$LOAD}
PickerIntf, UDialog, UBWDialog, UCommands, UFilters,
URootFormat, UPICTFile, UPICTResource;
TYPE
TMoveCommand = OBJECT (TFloatCommand)
fDuplicate: BOOLEAN;
fOutline: BOOLEAN;
fNudge: BOOLEAN;
fHome : Point;
fDest : Point;
fDelta: Point;
fExactHome: BOOLEAN;
fMovedOnce: BOOLEAN;
fHysteresis: Point;
fOutlineMag: INTEGER;
fOutlineData: Handle;
fOutlineVRect: Rect;
fOutlineBounds: Rect;
fBaseChangeCount: LONGINT;
fPreparedFeedback: BOOLEAN;
fSelectRect: Rect;
fSelectMask: TVMArray;
PROCEDURE TMoveCommand.IMoveCommand (view: TImageView;
duplicate: BOOLEAN;
outline: BOOLEAN;
nudge: Point;
VAR hysteresis: Point);
PROCEDURE TMoveCommand.Free; OVERRIDE;
PROCEDURE TMoveCommand.TrackConstrain
(anchorPoint, previousPoint: Point;
VAR nextPoint: Point); OVERRIDE;
PROCEDURE TMoveCommand.PrepareFeedback (downPoint: Point);
PROCEDURE TMoveCommand.TrackFeedback
(anchorPoint, nextPoint: Point;
turnItOn, mouseDidMove: BOOLEAN); OVERRIDE;
FUNCTION TMoveCommand.TrackMouse
(aTrackPhase: TrackPhase;
VAR anchorPoint, previousPoint, nextPoint: Point;
mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
PROCEDURE TMoveCommand.MoveFloat
(pt: Point; obscure: BOOLEAN; canAbort: BOOLEAN);
PROCEDURE TMoveCommand.SwapBelow;
PROCEDURE TMoveCommand.SelectOverlap (r: Rect);
PROCEDURE TMoveCommand.DoIt; OVERRIDE;
PROCEDURE TMoveCommand.UndoIt; OVERRIDE;
PROCEDURE TMoveCommand.RedoIt; OVERRIDE;
END;
TClipImageView = OBJECT (TView)
fSize: Point;
fMask: TVMArray;
fMode: TDisplayMode;
fResolution: FixedScaled;
fData: ARRAY [0..2] OF TVMArray;
fIndexedColorTable: TRGBLookUpTable;
PROCEDURE TClipImageView.IClipImageView;
PROCEDURE TClipImageView.Free; OVERRIDE;
FUNCTION TClipImageView.ContainsClipType
(aType: ResType): BOOLEAN; OVERRIDE;
PROCEDURE TClipImageView.CompTransMap
(iTable: TRGBLookUpTable; VAR map: TLookUpTable);
PROCEDURE TClipImageView.WriteToDeskScrap; OVERRIDE;
END;
TCutCopyCommand = OBJECT (TFloatCommand)
fDuplicate: BOOLEAN;
PROCEDURE TCutCopyCommand.ICutCopyCommand (view: TImageView;
duplicate: BOOLEAN);
PROCEDURE TCutCopyCommand.DoIt; OVERRIDE;
PROCEDURE TCutCopyCommand.UndoIt; OVERRIDE;
PROCEDURE TCutCopyCommand.RedoIt; OVERRIDE;
END;
TPasteCommand = OBJECT (TFloatCommand)
fPasteMode: INTEGER;
PROCEDURE TPasteCommand.IPasteCommand (view: TImageView;
pasteMode: INTEGER);
PROCEDURE TPasteCommand.DoIt; OVERRIDE;
PROCEDURE TPasteCommand.UndoIt; OVERRIDE;
PROCEDURE TPasteCommand.RedoIt; OVERRIDE;
END;
TClearCommand = OBJECT (TFloatCommand)
PROCEDURE TClearCommand.IClearCommand (view: TImageView);
PROCEDURE TClearCommand.DoIt; OVERRIDE;
PROCEDURE TClearCommand.UndoIt; OVERRIDE;
PROCEDURE TClearCommand.RedoIt; OVERRIDE;
END;
TFillCommand = OBJECT (TFloatCommand)
fWithPattern: BOOLEAN;
fBlend: INTEGER;
fMode: TPasteMode;
fChannel: INTEGER;
fWholeImage: BOOLEAN;
fNeedOriginal: BOOLEAN;
fOldControls: TPasteControls;
fNewControls: TPasteControls;
PROCEDURE TFillCommand.IFillCommand (itsCommand: INTEGER;
view: TImageView;
withPattern: BOOLEAN;
blend: INTEGER;
mode: TPasteMode);
PROCEDURE TFillCommand.PatternFill (band: INTEGER;
dstArray: TVMArray);
PROCEDURE TFillCommand.DoFill (r: Rect;
maskArray: TVMArray;
floatArray: TRGBArrayList);
PROCEDURE TFillCommand.DoIt; OVERRIDE;
PROCEDURE TFillCommand.UndoIt; OVERRIDE;
PROCEDURE TFillCommand.RedoIt; OVERRIDE;
END;
TFillBorderCommand = OBJECT (TFillCommand)
fWidth: INTEGER;
PROCEDURE TFillBorderCommand.IFillBorderCommand
(view: TImageView;
width: INTEGER;
blend: INTEGER;
mode: TPasteMode);
PROCEDURE TFillBorderCommand.DoFill
(r: Rect;
maskArray: TVMArray;
floatArray: TRGBArrayList); OVERRIDE;
END;
TGradientTool = OBJECT (TFillCommand)
fPt1: Point;
fPt2: Point;
fSpace: INTEGER;
fRadial: BOOLEAN;
fOffset: INTEGER;
fMidpoint: INTEGER;
PROCEDURE TGradientTool.IGradientTool
(view: TImageView;
radial: BOOLEAN;
midpoint: INTEGER;
offset: INTEGER;
space: INTEGER);
PROCEDURE TGradientTool.TrackConstrain
(anchorPoint: Point;
previousPoint: Point;
VAR nextPoint: Point); OVERRIDE;
PROCEDURE TGradientTool.TrackFeedBack
(anchorPoint: Point;
nextPoint: Point;
turnItOn: BOOLEAN;
mouseDidMove: BOOLEAN); OVERRIDE;
FUNCTION TGradientTool.TrackMouse
(aTrackPhase: TrackPhase;
VAR anchorPoint, previousPoint, nextPoint: Point;
mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
PROCEDURE TGradientTool.DoFill
(r: Rect;
maskArray: TVMArray;
floatArray: TRGBArrayList); OVERRIDE;
END;
PROCEDURE InitFloatCommands;
FUNCTION GetClipSize (VAR width: INTEGER;
VAR height: INTEGER;
VAR resolution: FixedScaled;
VAR color: BOOLEAN): BOOLEAN;
FUNCTION DoMoveSelection (view: TImageView;
duplicate: BOOLEAN;
outline: BOOLEAN;
VAR hysteresis: Point): TCommand;
FUNCTION DoNudgeSelection (view: TImageView;
nudge: Point;
duplicate: BOOLEAN;
outline: BOOLEAN): TCommand;
FUNCTION ConvertPICTDeskScrap (size: LONGINT): TView;
FUNCTION DoCutCopyCommand (view: TImageView;
duplicate: BOOLEAN): TCommand;
FUNCTION DoPasteCommand (view: TImageView; pasteMode: INTEGER): TCommand;
FUNCTION DoClearCommand (view: TImageView): TCommand;
FUNCTION DoFillCommand (view: TImageView; options: BOOLEAN): TCommand;
FUNCTION DoGradientTool (view: TImageView): TCommand;
PROCEDURE DoGradientOptions;
IMPLEMENTATION
{$I UAssembly.a.inc}
{$I UConvert.a.inc}
{$I UFloat.a.inc}
{$I URotate.a.inc}
{$I USelect.p.inc}
CONST
kObscureDelay = 180;
VAR
gFillBlend: INTEGER;
gFillOption: INTEGER;
gFillBorder: INTEGER;
gFillMode: TPasteMode;
gGradientSpace: INTEGER;
gGradientRadial: BOOLEAN;
gGradientOffset: INTEGER;
gGradientMidpoint: INTEGER;
{*****************************************************************************}
{$S AInit}
PROCEDURE InitFloatCommands;
BEGIN
gFillOption := 0;
gFillBorder := 1;
gFillBlend := 100;
gFillMode := PasteNormal;
gGradientSpace := 0;
gGradientRadial := FALSE;
gGradientOffset := 0;
gGradientMidpoint := 50
END;
{*****************************************************************************}
{$S AOpen}
FUNCTION GetClipSize (VAR width: INTEGER;
VAR height: INTEGER;
VAR resolution: FixedScaled;
VAR color: BOOLEAN): BOOLEAN;
BEGIN
IF MEMBER (gClipView, TClipImageView) THEN
BEGIN
width := TClipImageView (gClipView) . fSize . h;
height := TClipImageView (gClipView) . fSize . v;
resolution := TClipImageView (gClipView) . fResolution;
color := TClipImageView (gClipView) . fMode IN
[IndexedColorMode, RGBColorMode];
GetClipSize := TRUE
END
ELSE
GetClipSize := FALSE
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.IMoveCommand (view: TImageView;
duplicate: BOOLEAN;
outline: BOOLEAN;
nudge: Point;
VAR hysteresis: Point);
VAR
old: TMoveCommand;
itsCommand: INTEGER;
BEGIN
fOutline := outline;
fDuplicate := duplicate;
fNudge := LONGINT (nudge) <> 0;
fOutlineMag := 0;
fOutlineData := NIL;
fSelectMask := NIL;
IF fOutline THEN
IF fNudge THEN
itsCommand := cNudgeOutline
ELSE
itsCommand := cMoveOutline
ELSE IF fDuplicate THEN
IF fNudge THEN
itsCommand := cNudge
ELSE
itsCommand := cDuplicate
ELSE
itsCommand := cMove;
IFloatCommand (itsCommand, view);
fDelta := nudge;
fConstrainsMouse := TRUE;
fViewConstrain := FALSE;
fMovedOnce := FALSE;
fPreparedFeedback := FALSE;
fBaseChangeCount := fDoc.fChangeCount;
IF fWasFloating AND NOT fOutline THEN
IF MEMBER (gLastCommand, TMoveCommand) &
(gLastCommand.fChangedDocument = fDoc) &
NOT TMoveCommand (gLastCommand) . fOutline THEN
BEGIN
old := TMoveCommand (gLastCommand);
fHome := old.fHome;
fExactHome := old.fExactHome;
fOutlineMag := old.fOutlineMag;
fOutlineData := old.fOutlineData;
fOutlineVRect := old.fOutlineVRect;
fOutlineBounds := old.fOutlineBounds;
fBaseChangeCount := old.fBaseChangeCount;
old.fOutlineMag := 0;
old.fOutlineData := NIL
END
ELSE
BEGIN
fHome := fDoc.fFloatRect.topLeft;
fExactHome := fDoc.fExactFloat
END
ELSE
BEGIN
fHome := fDoc.fSelectionRect.topLeft;
fExactHome := not fDuplicate
END;
IF MEMBER (gLastCommand, TMoveCommand) THEN
BEGIN
old := TMoveCommand (gLastCommand);
IF old.fOutlineData <> NIL THEN
BEGIN
FreeLargeHandle (old.fOutlineData);
old.fOutlineData := NIL
END;
old.fOutlineMag := 0
END;
IF fWasFloating OR fDuplicate OR fOutline THEN
BEGIN
hysteresis.h := 1;
hysteresis.v := 1
END;
fHysteresis := hysteresis
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.Free; OVERRIDE;
BEGIN
IF fOutlineData <> NIL THEN
FreeLargeHandle (fOutlineData);
FreeObject (fSelectMask);
INHERITED Free
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.TrackConstrain
(anchorPoint, previousPoint: Point; VAR nextPoint: Point); OVERRIDE;
VAR
x: INTEGER;
mag: INTEGER;
delta: Point;
theKeys: KeyMap;
shiftDown: BOOLEAN;
BEGIN
fView.TrackRulers;
GetKeys (theKeys);
shiftDown := theKeys [kShiftCode];
IF shiftDown THEN
BEGIN
delta.h := nextPoint.h - anchorPoint.h;
delta.v := nextPoint.v - anchorPoint.v;
IF ABS (delta.h) >= 2 * ABS (delta.v) THEN
delta.v := 0
ELSE IF ABS (delta.v) >= 2 * ABS (delta.h) THEN
delta.h := 0
ELSE
BEGIN
x := Min (ABS (delta.h), ABS (delta.v));
IF delta.v > 0 THEN
delta.v := x
ELSE
delta.v := -x;
IF delta.h > 0 THEN
delta.h := x
ELSE
delta.h := -x
END;
nextPoint.h := anchorPoint.h + delta.h;
nextPoint.v := anchorPoint.v + delta.v
END;
mag := fView.fMagnification;
IF mag > 1 THEN
BEGIN
nextPoint.h := nextPoint.h DIV mag * mag;
nextPoint.v := nextPoint.v DIV mag * mag
END
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.PrepareFeedback (downPoint: Point);
CONST
kWatchSize = 32000;
VAR
r: Rect;
r1: Rect;
r2: Rect;
pt: Point;
map: BitMap;
mag: INTEGER;
bounds: Rect;
size: LONGINT;
mask: TVMArray;
width: INTEGER;
height: INTEGER;
theScreen: GDHandle;
BEGIN
mag := fView.fMagnification;
IF fWasFloating AND NOT fOutline THEN
BEGIN
r := fDoc.fFloatRect;
mask := fDoc.fFloatMask
END
ELSE
BEGIN
r := fDoc.fSelectionRect;
mask := fDoc.fSelectionMask
END;
pt := r.topLeft;
fView.CvtImage2View (pt, kRoundDown);
r1 := r;
OffsetRect (r1, -r1.left, -r1.top);
fView.CvtImage2View (r1.botRight, kRoundUp);
OffSetRect (r1, pt.h, pt.v);
IF mask = NIL THEN
fOutlineBounds := r1
ELSE
BEGIN
theScreen := fView.GetScreen;
IF theScreen = NIL THEN
bounds := screenBits.bounds
ELSE
bounds := theScreen^^.gdRect;
width := bounds.right - bounds.left;
height := bounds.bottom - bounds.top;
r2.top := downPoint.v - height - 16;
r2.left := downPoint.h - width - 16;
r2.bottom := downPoint.v + height + 16;
r2.right := downPoint.h + width + 16;
IF SectRect (r1, r2, r2) THEN
OffsetRect (r2, -r1.left, -r1.top)
ELSE
r2 := gZeroRect;
IF (fOutlineMag <> mag) |
(r2.top < fOutlineVRect.top ) |
(r2.left < fOutlineVRect.left ) |
(r2.bottom > fOutlineVRect.bottom) |
(r2.right > fOutlineVRect.right ) THEN
BEGIN
IF fOutlineData <> NIL THEN
BEGIN
FreeLargeHandle (fOutlineData);
fOutlineData := NIL
END;
fOutlineVRect := r2;
IF NOT EmptyRect (r2) THEN
BEGIN
map.bounds := r2;
map.rowBytes := BSL (BSR (r2.right - r2.left + 15, 4), 1);
size := ORD4 (r2.bottom - r2.top) * map.rowBytes;
IF size > kWatchSize THEN
MoveHands (FALSE);
fOutlineData := NewLargeHandle (size);
HLock (fOutlineData);
map.baseAddr := fOutlineData^;
OffsetRect (r, -r.left, -r.top);
DrawMaskOutline (map, mask, r, mag);
HUnlock (fOutlineData);
SetToolCursor (MoveTool, TRUE)
END
END;
fOutlineBounds := fOutlineVRect;
{$H-}
OffsetRect (fOutlineBounds, r1.left, r1.top);
{$H+}
END;
fOutlineMag := mag
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.TrackFeedback
(anchorPoint, nextPoint: Point;
turnItOn, mouseDidMove: BOOLEAN); OVERRIDE;
VAR
r: Rect;
vr: Rect;
map: BitMap;
fi: FailInfo;
PROCEDURE CleanUp (error: INTEGER; message: LONGINT);
VAR
newMsg: LONGINT;
BEGIN
IF fOutline THEN
newMsg := msgCannotMoveOutline
ELSE IF fDuplicate THEN
newMsg := msgCannotDuplicate
ELSE
newMsg := msgCannotMove;
Free;
FailNewMessage (error, message, newMsg)
END;
BEGIN
IF NOT fPreparedFeedback THEN
BEGIN
CatchFailures (fi, CleanUp);
PrepareFeedback (anchorPoint);
fPreparedFeedback := TRUE;
Success (fi)
END;
IF mouseDidMove THEN
IF NOT EqualPt (nextPoint, anchorPoint) THEN
BEGIN
r := fOutlineBounds;
OffsetRect (r, nextPoint.h - anchorPoint.h,
nextPoint.v - anchorPoint.v);
IF fOutlineData = NIL THEN
FrameRect (r)
ELSE
BEGIN
fView.fFrame.GetViewedRect (vr);
IF SectRect (r, vr, vr) THEN
BEGIN
HLock (fOutlineData);
map.bounds := r;
map.rowBytes := BSL (BSR (r.right - r.left + 15, 4), 1);
map.baseAddr := fOutlineData^;
CopyBits (map, thePort^.portBits, vr, vr, srcXor, NIL);
HUnlock (fOutlineData)
END
END
END
END;
{*****************************************************************************}
{$S ADoFloat}
FUNCTION TMoveCommand.TrackMouse
(aTrackPhase: TrackPhase;
VAR anchorPoint, previousPoint, nextPoint: Point;
mouseDidMove: BOOLEAN): TCommand; OVERRIDE;
VAR
pt: Point;
fi: FailInfo;
mag: INTEGER;
peekEvent: EventRecord;
PROCEDURE CleanUp (error: INTEGER; message: LONGINT);
BEGIN
TrackMouse := gNoChanges;
EXIT (TrackMouse)
END;
BEGIN
TrackMouse := SELF;
IF mouseDidMove THEN
CASE aTrackPhase OF
trackMove:
fMovedOnce := TRUE;
trackRelease:
BEGIN
IF EventAvail (mUpMask, peekEvent) THEN
BEGIN
pt := peekEvent.where;
GlobalToLocal (pt);
IF (ABS (pt.h - anchorPoint.h) >= fHysteresis.h) OR
(ABS (pt.v - anchorPoint.v) >= fHysteresis.v) THEN
BEGIN
nextPoint := pt;
TrackConstrain (anchorPoint, previousPoint, nextPoint)
END
END;
fDelta.h := nextPoint.h - anchorPoint.h;
fDelta.v := nextPoint.v - anchorPoint.v;
mag := fView.fMagnification;
IF mag > 1 THEN
BEGIN
fDelta.h := fDelta.h DIV mag;
fDelta.v := fDelta.v DIV mag
END
ELSE IF mag < 1 THEN
BEGIN
fDelta.h := fDelta.h * (-mag);
fDelta.v := fDelta.v * (-mag)
END;
IF LONGINT (fDelta) = 0 THEN
IF NOT fMovedOnce THEN
BEGIN
CatchFailures (fi, CleanUp);
TrackMouse := DropSelection (fView);
Success (fi)
END
ELSE IF NOT fWasFloating AND NOT fDuplicate THEN
TrackMouse := gNoChanges
END
END
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.MoveFloat (pt: Point;
obscure: BOOLEAN;
canAbort: BOOLEAN);
VAR
r: Rect;
r1: Rect;
r2: Rect;
fi: FailInfo;
fi2: FailInfo;
oldRect: Rect;
newRect: Rect;
mask: TVMArray;
width: INTEGER;
height: INTEGER;
canMove: BOOLEAN;
saveExact: BOOLEAN;
selectError: OSErr;
PROCEDURE CleanUp (error: INTEGER; message: LONGINT);
BEGIN
FreeObject (mask)
END;
PROCEDURE CleanUp2 (error: INTEGER; message: LONGINT);
BEGIN
CopyBelow (FALSE);
fDoc.fFloatRect := oldRect;
fDoc.fExactFloat := saveExact;
CopyBelow (TRUE);
BlendFloat (FALSE);
IF NOT canMove THEN SelectFloat
END;
BEGIN
MoveHands (canAbort);
oldRect := fDoc.fFloatRect;
width := oldRect.right - oldRect.left;
height := oldRect.bottom - oldRect.top;
newRect.topLeft := pt;
newRect.bottom := newRect.top + height;
newRect.right := newRect.left + width;
ComputeOverlap (r1);
fDoc.fFloatRect := newRect;
ComputeOverlap (r2);
fDoc.fFloatRect := oldRect;
canMove := fDoc.fSelectionFloating AND
(r1.bottom - r1.top = height) AND
(r2.bottom - r2.top = height) AND
(r1.right - r1.left = width) AND
(r2.right - r2.left = width);
IF NOT canMove THEN
BEGIN
fDoc.DeSelect (NOT fDoc.fSelectionFloating);
fDoc.fFloatRect := newRect;
selectError := CanSelect (r, mask);
fDoc.fFloatRect := oldRect;
IF selectError <> noErr THEN
Failure (selectError, msgCannotMove)
END
ELSE
mask := NIL;
CatchFailures (fi, CleanUp);
CopyBelow (FALSE);
saveExact := fDoc.fExactFloat;
fDoc.fFloatRect := newRect;
fDoc.fExactFloat := fExactHome AND
(LONGINT (pt) = LONGINT (fHome));
CopyBelow (TRUE);
CatchFailures (fi2, CleanUp2);
BlendFloat (canAbort AND saveExact);
Success (fi2);
UpdateRects (r1, r2, FALSE);
Success (fi);
obscure := obscure AND
((r2.bottom - r2.top = 1) OR
(r2.right - r2.left = 1));
IF obscure THEN
fView.ObscureSelection (kObscureDelay);
IF canMove THEN
fDoc.MoveSelection (r2)
ELSE
BEGIN
fDoc.Select (r, mask);
fDoc.fSelectionFloating := NOT EmptyRect (r)
END;
IF obscure THEN
fView.ObscureSelection (kObscureDelay)
END;
{*****************************************************************************}
{$S ADoFloat}
PROCEDURE TMoveCommand.SwapBelow;
VAR
save: TVMArray;
channel: INTEGER;
BEGIN
FOR channel := 0 TO 2 DO
IF fBuffer [channel] <> NIL THEN
BEGIN
save := fBuffer [channel];
fBuffer [channel] := fDoc.fFloatBelow [channel];
fDoc.fFloatBelow [channel] := save
END
END;
{*****************************************************************************}
{$S ADoFloat}