-
Notifications
You must be signed in to change notification settings - Fork 11
/
BalloonPACK.a
3529 lines (2859 loc) · 132 KB
/
BalloonPACK.a
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
;__________________________________________________________________________________________________
; File: BalloonPACK.a
;
; Contains: Assembly routines for the Balloon Help Package
;
; Written by: Randy Carr
;
; Copyright: © 1989-1992 by Apple Computer, Inc., all rights reserved.
;
; This file is used in these builds: BigBang
;
;
;
; Change History (most recent first):
;
; <SM3> 10/22/92 CSS Change some branch short instructions to word branches.
; <72> 5/14/92 KST #1027497 <JH>: #1025797,#1027497: In '__HMScanHWinResource', we
; ask TSM if the mouse is over a floating window. If it is, then
; TSM will try to locate and open the resource file to load the
; Help resources for the floating window. Balloon help now works
; when mouse is over a floating window.
; <71> 4/6/91 DTY csd, #86370: IsMouseInMenuBar popped off the incorrect number of
; bytes from the stack if it couldnÕt get the 'MBDF' resource,
; which would happen if MenuList was nil. Check to make sure that
; MenuList contains a real handle before trying to get the 'MBDF',
; and pop off the correct number of bytes if this fails anyway.
; <70> 3/19/91 RLC ksm,#BUG.GUIDE Item #8510137 - Fix typo in FillInDialogMsg()
; that was not filling in the variant & proc numbers from an
; 'hdlg' resource from the right register offset.
; <69> 3/13/91 RLC ksm,#83253 - Change call to SaveBits() to create purgeable bits
; so that if we get short on memory, the bits we saved behind the
; balloon will get invalidated by RestoreBits(). GO5 approved.
; <68> 2/20/91 RLC ksm, #BH-TC-0076 Fix modal dialog menu balloons so that apps can
; get special balloons for menu titles and items when a modal
; dialog is up. (GO5 approved)
; <67> 2/8/91 RLC <ksm> #82161 Add the HMStripNullFromProcessName routine that
; removes leading null characters from a pstring so that Text Edit
; doesn't word break a process name in a balloon. [Change approved
; by GO5]
; <66> 2/5/91 stb gs: include MenuMgrPriv.a
; <65> 1/24/91 RLC <gbm> #81591 Change __HMFillInDialogMessage() to respect the
; resource file whether a specified resource file refnum or -1
; from HMScanTemplateItems(). If -1 then have those routines call
; GetResource() else call Get1Resource() [which means specifically
; search a resource file for a help resource].
; <64> 1/22/91 RLC <dc> #81592 Fix bug that leaves a balloon up if the mouse
; moves from a system tracked balloon to the menubar.
; <63> 1/18/91 KSM <RLC> Change include of BalloonPACKEqu to BalloonsPriv.a.
; <62> 1/14/91 RLC <ksm> Change a call to GetResource into Get1Resource when
; fetching a 'hdlg' resource as we must make sure where we're
; fetching the resource from when handling multiple help resources
; with the same ID.
; <61> 1/10/91 RLC <ksm> Fix the check of any setup DialogResID value from
; HMSetDialogResID. Fix a bug that was smashing the return value
; from a call to the HMScanTemplateItems call - this fixes a bug
; that wouldn't track a helpItem driven 'hdlg' and a
; HMSetDialogResID assigned 'hdlg' in the same dialog.
; <60> 1/3/91 RLC <vl> Fix IsBalloonChanged routine to NOT remove a balloon if
; hmgLastMenuID says that there wasn't a balloon that we put up
; ourselves (via HMShowTitleBalloon). This change will allow
; developers to call HMShowBalloon for menu titles instead of
; requiring that they have an 'hmnu' resource.
; <59> 12/18/90 RLC <ksm> Change HMStuffWindow routine to do the right thing in 32
; bit mode and to fix the bug that called _GetAuxWin on B & W
; machines.
; <58> 12/14/90 RLC <ngk> Shorten code in HMSetupBalloonRgns by fetching translation
; of varCode to balloon drawing directions from table instead of a
; giant case statement. Added check in HMFillInMenuMsg that makes
; sure we're in MenuSelect so that popups & hiearchicals menus get
; the right state message in modal dialogs (and movable modals).
; <57> 12/3/90 RLC <ksm> Fix bug that wasn't appending a menu item's mark character to
; the name to fetch when looking up a GetNamedResource item when
; filling out the help msg record in HMFillInMenuMsg.
; <56> 11/29/90 RLC <ksm> Repair the HMStuffWindowInfo code that ksm & gbm made at
; 2:00AM so that it actually works when window does NOT have an
; aux wind record.
; <55> 11/28/90 gbm (with KSM) _HMStuffWindowInfo wasn't 32-bit clean, since it
; messed directly with the window variant in top byte of the
; handle...
; <54> 11/16/90 RLC <ksm> Fix bug that was not respecting the ModalDialog state for
; Apple Menu item help messages. The enabled message was always
; displayed.
; <52+> 10/4/90 RLC <ksm> Optimization in help mgr resource walks. Fixed bug in
; GetIndHelpMsg() that was not returning the correct data in the
; case of a HMCompareItem in an 'hmnu' resource. Fix bug that
; wasn't allowing an 'hmnu' resource to have HMNamedResourceItem
; as the first item (the title balloon msg) and map 'modal dialog'
; title & item balloons to the checked and marked w/ a diamond.
; Change the 'hwin' resource scanning routine to call
; HMScanTemplateItems instead of duplicating this code (saves >
; 720 bytes).
; <52> 10/3/90 RLC Fix a bug when extracting help message data from a help resource
; that wasn't clearing the lower (upper) nibble of the pstring
; index when reaching to 'other' items.
; <51> 9/30/90 RLC Do some code reduction and change most routines to use the link
; patch macros.
; <50> 9/25/90 RLC Move the __HMExtractHelpMsg to be in the BalloonPack.p file and
; just have this routine call the __HMGetIndHelpMsg routine and
; ignore the extraneous params that are returned from this call
; (saves >370 bytes).
; <48+> 9/22/90 RLC Add a routine to resize and restuff the window variant for the
; balloon window.
; <48> 9/17/90 RLC (JSM) Fix HMCallCustomWDEFCalc that was doing a MOVE.L into the
; result instead of the correct MOVE.W instruction. This was
; causing a crash in HMShowBalloon by smashing the hiword of the
; HMGlobalPtr that was on the stack.
; <47> 9/13/90 RLC Changed name of routines to have '__' chars in front of
; procedure name (in jump table as well); Fix bug that put up menu
; title balloons in front of pulled down menu just b4 menu
; disappears; Fixed bug that was bit testing wrong bit when
; scanning 'hrct' resources for hmAbsoluteCoords (Change it to
; match Inside Mac VI doc).
; <46> 8/31/90 RLC Remove priority 2 bug that flashes ModalDialog balloons once
; when dialog first comes up, reentrant support in HMBalloonBulk,
; support for CloseView, fix process & help menu balloons when
; modal dialog is up.
; <44+> 8/21/90 RLC Add in a reentrancy test for BalloonBulk code.
; <43+> 8/20/90 RLC Repair Philip's restored old code and move in _ProcHelper
; dispatcher.
; <46+> 8/9/90 RLC Add some glue to read shift key quickly.
; <44+> 8/3/90 RLC Fix tipProc calling convention: tip,rgn,varCode.
; <43+> 7/31/90 RLC Fix bug that doesn't range check correctly in FillDialogMsg for
; offset msgs.
; <42+> 7/25/90 RLC Add code to support Easy Access and remove calls to ExtractÉ
; <41+> 7/17/90 RLC Fix HMExtract routine to be 1 based and check ranges.
; <41> 7/13/90 RLC Fix modal dialog w/ enabled menu help msg case by calling new
; dialogmgr dispatcher, shortened code by calling globals
; directly, added HMScanHRCTResource routine.
; <39+> 7/6/90 RLC More changes for those modal dialog variants.
; <38+> 7/5/90 RLC Tweak some routines to make sure multiple help items are
; supported correctly.
; <37+> 6/19/90 RLC More variant correction routines.
; <37> 6/18/90 RLC Fix indexing to fetch application's help menu msgs & initial
; variant.
; <35+> 6/15/90 RLC Allow enabled items to get normal hmnu msg in ModalDialogMenu
; state.
; <34+> 6/14/90 RLC Add support for ÒBalloons OnÓ balloon, fix window move bug.
; <34> 6/8/90 KSM Update for new IsFrontWindowModal.
; <33> 6/7/90 RLC Add Kevin's ModalDialogMenus private selector.
; <31+> 6/5/90 RLC Fix a potential front window bug
; <30+> 6/4/90 RLC Fix bug in hmgLastWindowPtr global dereferencing NIL ptr.
; <29+> 5/31/90 RLC Special case the process menu for Finder open only message &
; support for App added help menu messages.
; <28+> 5/4/90 RLC Fix bug in AppendMenu.
; <27+> 5/3/90 RLC Fix bugs in modal dialogs, launching balloons, etc.
; <26+> 4/19/90 RLC Roll in new font & size in reference to script mgr globals
; <26> 4/18/90 RLC Fix bug in NIL test for hdlg items.
; <24+> 4/16/90 RLC Special case the process (MF) menu by hand.
; <23+> 4/10/90 KSM Roll in the System menus.
; <22+> 4/9/90 RLC Frontwindow modal fixes.
; <21+> 4/5/90 RLC More Modal Dialog handling.
; <21> 4/4/90 RLC Fix clicks in modal dialogs.
; <19+> 4/2/90 RLC Reconnect HMSetDialogResID & HMSetMenuResID.
; <19> 3/29/90 HJR Fixed an assembler out of range error.
; <18> 3/29/90 RLC Fix dangling pointer possible bug.
; <17> 3/27/90 RLC Make sure resource driven help msgs use theProc & variant.
; <16> 3/22/90 RLC Change IsThisAModalDialog call to call GetWVariant as well.
; <15> 3/20/90 RLC Hack AppleMenu items separately.
; <14> 3/13/90 RLC Bug fixes.
; <13> 3/8/90 RLC Fix non-frontmost windows & layers balloons to be ignored when
; modal dialog is up.
; <12> 2/8/90 RLC Fix missing msg parameter to include NIL as a 'missing' msg.
; <11> 2/7/90 RLC Fix non-Removal of 'hdlg' driven balloons.
; <10> 2/5/90 RLC Add delay controls.
; <9> 2/2/90 RLC Fix selector return codes.
; <8> 1/30/90 RLC Add remove extraneous calls
; <7> 1/26/90 RLC Add support to remove modal dialog balloons at the right time.
; <6> 1/12/90 RLC Tweak dispatcher to correctly handle extended selector codes.
; <5> 1/11/90 RLC Fix code to scan HMSkipItem in hdlg resource correctly.
; <4> 1/4/90 RLC Support the new resource format.
; <3> 12/22/89 RC Fix some modality conditionals
; <2> 12/21/89 RC Fix error conditions in scanning hwin resource.
; <3.5> 12/15/89 RLC Added TipProc call.
; <3.4> 12/6/89 RLC Fix the odd addressing problem when copying a help msg string
; when filling in record.
; <3.3> 12/1/89 RLC Add short routine to allow Pascal to determine if dialogPtr is a
; modal dialog.
; <3.2> 11/30/89 RLC Fix bug in hdlg scanner that ADD.B was clipping hdlg offset
; length to 256 bytes.
; <3.1> 11/16/89 RLC Update 'hrct' scanning routines as hotRect parameter no longer
; exists.
; <3.0> 11/16/89 RLC Change calling interface to HMTrackTemplateHelpItems.
; <2.9> 11/15/89 RLC Add and fix routines to support tip & altRect in 'hdlg's/
; <2.8> 11/13/89 RLC Changed 'hdlg' scan routines to scan tip and altRect parameters.
; <2.7> 11/9/89 RLC Add support for HMSkipItem in 'hrct' scanning routine.
; <2.6> 11/7/89 RLC Add support for window parts balloons.
; <2.5> 11/2/89 RLC Changed the code into a REAL Package (PACK14)
; <2.4> 10/27/89 RLC Fix bug in NIL menu msg that would loop infinitely.
; <2.3> 10/2/89 RLC Add preflight check when scanning hwin's to make sure the mouse
; is in the portrect before scanning the hrct.
; <2.2> 9/25/89 RLC Added support for MultiFinder application icon, use _CmpString
; trap when comparing window titles to hwin resources.
; <2.1> 9/21/89 RLC Made missing 'hmnu' item work if array contains
; HMCompareItem(s).
; <2.0> 9/20/89 RLC Bug Fixes, set CurResFile to refnum returned from GetIndResource
; when searching for hrcts. Add subrange option to hwin resources.
; <1.9> 9/19/89 RLC Fixed NIL string & Menu Item Checked byte in 'hmnu' scan.
; <1.8> 9/19/89 RLC Bug Fixes again.
; <1.7> 9/18/89 RLC Bug fixes, DrawString patch speedup.
; <1.6> 9/15/89 RLC Fixed ADD.B instructions to allow word length indexing.
; <1.5> 9/14/89 RLC Fixed Register useage problem in ScanHWin routine.
; <1.4> 9/13/89 RLC Bug Fixes, Added new 'hmnu','hdlg' resource template readers.
; <1.3> 8/29/89 RLC Update _Pack14 calling method and added 'hmnu','hdlg', &'hrct'
; scanning routines.
; <1.2> 8/10/89 RLC Added support code for autocontents help balloons
; <1.1> 7/20/89 RLC Added code to support the help menu for What Is? mode.
; <1.0> 6/29/89 RLC Created Today.
;
TITLE 'BalloonPack.a - Balloon HelpMgr trap'
STRING ASIS
IF &TYPE('HelpMgrTesting')='UNDEFINED' THEN
HelpMgrTesting EQU 0
ENDIF
AllowCloseViewChanges EQU 0 ; *** someday I'll make this work!
LOAD 'StandardEqu.d'
INCLUDE 'MFPrivate.a' ; some mf private _GetAuxMenuItem things
INCLUDE 'LayerEqu.a'
INCLUDE 'ScriptPriv.a' ; some private script mgr global records
INCLUDE 'BalloonsPriv.a' ; my private help manager equates
INCLUDE 'InternalMacros.a'
INCLUDE 'Processes.a'
INCLUDE 'DialogsPriv.a'
INCLUDE 'MenuMgrPriv.a' ; for Save|RestoreBits
INCLUDE 'TSMPrivate.a' ; for input method's floating window
;
; Macro to put in debug symbols for MacsBug
;
IF HelpMgrTesting THEN
MACRO
DoDebugSymbols &name
DC.B $80 + &LEN(&name), '&name'
ALIGN
DC.W $0000
ENDM
ENDIF
PackEntry MAIN EXPORT
DC.W $A9FF ; package entry point (unused now)
DC.L ('PACK') ; make sure this is preceded by STRING ASIS
DC.W 14 ; package number
DC.W hmBalloonHelpVersion ; version number
DispatchTable
DC.W 0 ; flags, 0 = selectors are sequential
DC.B minSelector ; first legal selector
DC.B maxSelector ; last legal selector
MACRO
JT &entry
IMPORT &entry
DC.W &entry - DispatchTable
ENDM
JumpStart JT __HMCountDITLHelpItems ; called by: Standard file somewhere
JT __HMModalDialogMenuSetup ; called by: ':DialogMgr:ModalDialogMenuPatches.a'
JT __HMInvalidateSavedBits ; called by: ':WindowMgr:LayerMgr.c'
JT __HMTrackModalHelpItems ; called in patches to _IsDialogEventPatch & _ModalDialog
JT __HMBalloonBulk ; called in patch to _SystemTask
DC.W 0 ; HMInitHelpMenu (return an error if someone calls the pack directly)
JT __HMDrawBalloonFrame ; called by: ':HelpMgr:BalloonWDEF.p' & BalloonPack.p
JT __HMSetupBalloonRgns ; called by: ':HelpMgr:BalloonWDEF.p' & BalloonPack.p
JumpTable JT __HMGetHelpMenuHandle
JT __HMShowBalloon
JT __HMRemoveBalloon
JT __HMGetBalloons
JT __HMSetBalloons
JT __HMShowMenuBalloon
JT __HMGetIndHelpMsg
JT __HMIsBalloon
JT __HMSetFont
JT __HMSetFontSize
JT __HMGetFont
JT __HMGetFontSize
JT __HMSetDialogResID
JT __HMSetMenuResID
JT __HMBalloonRect
JT __HMBalloonPict
JT __HMScanTemplateItems
JT __HMExtractHelpMsg
JT __HMFillCitationString
JT __HMGetDialogResID
JT __HMGetMenuResID
JT __HMGetBalloonWindow
JumpEnd
minSelector EQU (JumpStart - JumpTable) / 2
maxSelector EQU (JumpEnd - JumpTable) / 2 - 1
ENDPROC ; PackEntry
;---------------------------------------------------------------------------------------------
;
; Start of routines needed in Help Manager Package
;
;---------------------------------------------------------------------------------------------
;
; FUNCTION __HMGetHelpGlobal: HMGlobalPtr; ; we need this code for pascal
;
; Returns our global ptr for the help manager globals on stack
;
__HMGetHelpGlobal PROC EXPORT
MOVE.L ExpandMem,A0 ; point to the expand mem ptr
MOVE.L ExpandMemRec.emHelpGlobals(A0),4(SP) ; return the global handle on the stack
RTS ; return to caller
ENDP
;---------------------------------------------------------------------------------------------
;
; FUNCTION __HMGetGlobalMouse: Point; ; we need this code for pascal
;
__HMGetGlobalMouse PROC EXPORT
MOVE.L Mouse,4(SP) ; return the current global mouse on stack
RTS
ENDP
;---------------------------------------------------------------------------------------------
;
; FUNCTION __HMSlopMouse(tip: Point): BOOLEAN;
;
; Returns true if mouse moved beyond our slop rect
;
__HMSlopMouse PROC EXPORT
MOVE.L (SP)+,A0 ; return addr
MOVE.L (SP)+,D2 ; tip point
MOVEQ #0,D0 ; result placeholder
MOVE.L Mouse,D1 ; get the current mouse
CMP.L D1,D2 ; is the tip the same
BEQ.S @NoSlop ; yes, exit now
SUB D1,D2 ; compute Dx
BPL.S @wasHPositive
NEG.W D2 ; abs(deltaX)
@wasHPositive
CMP #kHMSlopPix,D2 ; did the mouse slop (in pixels)?
BGT.S @MouseMoved ; yes, exit true
SWAP D2 ; switch to vertical word
SWAP D1
SUB D1,D2 ; compute Dy
BPL.S @wasVPositive
NEG.W D2 ; abs(deltaX)
@wasVPositive
CMP #kHMSlopPix,D2 ; did the mouse slop?
BLE.S @NoSlop ; no, exit false
@MouseMoved
MOVEQ #1,D0 ; the mouse moved beyond the pixel slop
@NoSlop
MOVE.B D0,(SP) ; return result on stack
JMP (A0) ; return to caller
IF HelpMgrTesting THEN
DoDebugSymbols __HMSlopMouse ; label for MacsBug
ENDIF
ENDP
;---------------------------------------------------------------------------------------------
;
; FUNCTION __HMCallTipProc(tipProc: Ptr;
; tip: Point;
; structure: RgnHandle;
; VAR bounds: Rect;
; VAR varCode: INTEGER); OsErr; EXTERNAL;
;
; Calls the user tip procedure for modifying the varCode just calculated
;
__HMCallTipProc PROC EXPORT
resultsStackFrame
result ds.w 1 ; the resulting OsErr
parametersStackFrame
theTipProc ds.l 1 ; the procPtr to call
theTip ds.l 1 ; the tip of the iceberg
theStructure ds.l 1 ; the structure rgn of the balloon
theBounds ds.l 1 ; the VAR rect (long)
theVarCode ds.l 1 ; the VAR varCode (word)
endStackFrame
linkSave
SUBQ #2,SP ; room for result
MOVE.L theTip(A6),-(SP) ; push the tip point of the balloon
MOVE.L theStructure(A6),-(SP) ; push the structure region of the balloon
MOVE.L theBounds(A6),-(SP) ; push VAR bounds rect
MOVE.L theVarCode(A6),-(SP) ; push VAR varCode
MOVE.L theTipProc(A6),A0 ; get the proc ptr
JSR (A0) ; go call it and return
MOVE (SP)+,result(A6) ; return result
restoreUnlinkReturn
IF HelpMgrTesting THEN
DoDebugSymbols __HMCallTipProc ; label for MacsBug
ENDIF
ENDP
;---------------------------------------------------------------------------------------------
;
; FUNCTION __HMBalloonBulk: OsErr;
;
; Scans for presence of mouse over menu bar and detects hwin & hrcts for Balloon Help
;
; Should only be called if Balloon Help is ON
;
__HMBalloonBulk PROC EXPORT ; *** Note: private pack call
IMPORT __HMIsBalloon
IMPORT __HMRemoveBalloon
IMPORT __HMShowTitleBalloon
IMPORT __HMGetWindowPartCode
IMPORT __HMShowWindowPartBalloon
IMPORT __HMScanHWinResource
IMPORT __HMScanTemplateItems
IMPORT __HMShowEasyAccessBalloon
IMPORT __HMSetBalloons
IMPORT __HMPushMenuState
IMPORT __HMPopMenuState
IMPORT __HMGetDialogResID ; <54>
SaveRegs REG A2-A3/D3-D4 ; Standard registers to save
resultsStackFrame
result ds.w 1 ; the result
localsStackFrame
frontPSN ds.l 2 ; process serial number double longword
currentPSN ds.l 2 ; process serial number double longword
dialogResID ds.w 1 ; <54> a place to put any overridden dialog res ID
sameResult ds.w 1
endStackFrame
linkSave SaveRegs
MOVE.L ExpandMem,A0 ; point to the expand mem ptr
MOVE.L ExpandMemRec.emHelpGlobals(A0),A2 ; A2 = global ptr (used to be a handle)
MOVE hmgBulkReentrantCount(A2),D0 ; get last reentrant count
BNE.S ReentrantCase
ADD #1,hmgBulkReentrantCount(A2) ; say that we're currently executing this routine
SUBQ #2,SP ; make room for OsErr
PEA currentPSN(A6) ; push ptr to cereal number storage (crunch)
_GetCurrentProcess ; get the current process PSN
; do we need to check err? (make room for daddy)
PEA frontPSN(A6) ; push ptr to cereal number storage (crunch)
_GetFrontProcess ; get the frontmost process PSN
; do we need to check err? (make room for daddy)
PEA currentPSN(A6) ; push ptr to cereal number storage (crunch)
PEA frontPSN(A6) ; push ptr to cereal number storage (crunch)
PEA sameResult(A6) ; push a place for the result of call
_SameProcess ; were the PSNs the same?
ADDQ #2,SP ; do we need to check for error?
TST.B sameResult(A6) ; is the front process current?
BEQ.S ScanStandardExit ; EQ means no, so exit
SUBQ #2,SP
_Button ; This used to be _Stilldown, but seems to cause some
; sort of state problem in MF (*** I'll figure it out later)
TST.B (SP)+
BNE.S ScanStandardExit
SUBQ #2,SP
JSR __HMIsBalloon ; was there a balloon up?
MOVE.B (SP)+,D0 ; EQ means no
BEQ.S GoContextualizeMouse ; no, so figure out where the mouse actually is
IF AllowCloseViewChanges THEN
MOVE hmgCloseViewCount(A2),D0 ; get the value of the closeview balloon state (>0 means were ready to remove)
BNE.S @RemoveAndExit
ENDIF
; call IsBalloonPlaceChanged w/ A2 -> globals
BSR IsBalloonPlaceChanged ; go see if the Balloon place has changed
BNE.S @RemoveAndExit ; if changed (NE) then remove the showing balloon and exit
BSR IsMouseOutsideSlop ; go see if the mouse has drifted outside slop rect
BNE.S ScanStandardExit ; NE means mouse is still in rect, so exit
@RemoveAndExit
SUBQ #2,SP ; remove any balloons that might have been up
JSR __HMRemoveBalloon ; do the remove
ADDQ.L #2,SP ; toss result
ScanStandardExit
CLR hmgBulkReentrantCount(A2) ; reset last reentrant count
ReentrantCase
CLR result(A6) ; always return noErr
restoreUnlinkReturn
;
IF HelpMgrTesting THEN
DoDebugSymbols __HMBalloonBulk ; label for MacsBug
ENDIF
;
;
; GoContextualizeMouse
;
; What this routine does is determine whether or not to put up a balloon depending on
; where the mouse is. This routine ONLY gets called if there wasn't a balloon already
; up!
;
GoContextualizeMouse
BSR IsMouseInMenuBar ; returns 'MBAR' proc's test result in D0.L
BMI.S TryWindowParts ; if -1 then mouse wasn't in bar
BEQ.S InBarNoTitle ; if 0 then mouse was in bar, but no title
MOVE.L SavedHandle,D1 ; were there bits being saved behind balloon?
BNE ExitContextualize ; yes, so exit quickly, no title balloon in this case
MOVE.L D0,-(SP)
_DMgrPushMenuState
MOVE.L (SP)+,A1
MOVE.L (SP)+,D0
MOVE.L MenuList,A0 ; mouse was in a title, use the offset in D0.L
MOVE.L (A0),A0 ; A0 -> menuList
MOVE.L menuoH(A0,D0.L),A0 ; get the menu handle
MOVE.L (A0),A0 ; deref to get ptr
MOVE.W menuID(A0),-(SP) ; put the menuID on stack
MOVE.L menuEnable(A0),-(SP) ; push menu flags
MOVE.L A1,-(SP)
_DMgrPopMenuState
JSR __HMShowTitleBalloon ; put a balloon up
BRA ExitContextualize
InBarNoTitle
JSR __HMShowEasyAccessBalloon ; see if we should put up a balloon for easy access icons
@NothingElse
BRA ExitContextualize
;
;
;
TryWindowParts
; First: Fetch the window and part code for that window that
; the mouse was over.
SUBQ #6,SP ; room for INTEGER & VAR port
PEA 2(SP) ; push address of port on stack
JSR __HMGetWindowPartCode ; returns corrected FindWindow result & VAR port
MOVE (SP)+,D0 ; D0 = FindWindow result code for the window (if any)
MOVE.L (SP)+,D1 ; D1 = port that the mouse is in (includes layer, if any)
; Second: Check to see if the mouse is in the content
; area of the window or desk
CMP #inContent,D0 ; was the mouse in a content area of the window?
BEQ.S TryAppWindow ; EQ means yes, so check for hwin driven balloons
CMP #inDesk,D0 ; was the mouse in the desk?
BEQ.S TryInDesk ; EQ means yes, so tell 'em about the desk.
; Third: If it was somewhere else, then show the
; appropriate window part balloon
SUBQ #2,SP
MOVE.L D1,-(SP) ; push the port
MOVE D0,-(SP) ; push findwindow result code
JSR __HMShowWindowPartBalloon
MOVE.B (SP)+,D0 ; returns nonzero if a balloon was shown
BRA.S ExitContextualize
TryInDesk
BSR IsMouseInDesk
BRA.S ExitContextualize
;
; See if someone has setup any dialog res id to be used for the current window
;
TryAppWindow
SUBQ #2,SP ; <54> make some room for the OsErr result
PEA dialogResID(A6) ; <54> put any overridden dialog res id here
JSR __HMGetDialogResID ; <54> call: FUNCTION __HMGetDialogResID(VAR theResID: INTEGER): OsErr;
TST.W (SP)+ ; <54> see if we got a noErr result
BNE.S @noDialogResIDSetup ; <54> NE means there wasn't a currently overridden dialog ID
SUBQ #2,SP ; make some room for the OsErr result
MOVE.W dialogResID(A6),-(SP) ; <54> push the ID
MOVE #-1,-(SP) ; scan this resfile (-1 means current)
MOVE.L #'hdlg',-(SP) ; scan a 'hdlg' resource
JSR __HMScanTemplateItems ; scan any 'hdlg' resource of this ID
TST (SP)+ ; <61> don't scan any hwin stuff if we got a hit
BEQ.S ExitContextualize ; <61> branch to the common exit point
@noDialogResIDSetup
BSR __HMScanHWinResource
;
; do something here
;
ExitContextualize
BRA ScanStandardExit
IF HelpMgrTesting THEN
DoDebugSymbols GoContextualizeMouse ; label for MacsBug
ENDIF
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; IsBalloonPlaceChanged
;
; Enter: A2 = global ptr
;
; Note: lastMenuID EQU lastPartCode
; lastWindowPtr EQU lastEnabled
;
;
imiTempRect EQU -8 ; temprect rect
imiTempPt EQU imiTempRect-4 ; point to test mouse with
imiPort EQU imiTempPt-4 ; the previous port goes here
imiSize EQU imiPort
;
IsBalloonPlaceChanged
LINK A6,#imiSize ; make a stack frame
MOVEM.L D6-D7,-(SP) ; save regs (<64> save D6 as well)
BSR IsMouseInMenuBar ; returns 'MBAR' proc's test result in D0.L (not handle safe)
BMI.S @notInBar ; if -1 then mouse wasn't in bar
BEQ.S @specialBar ; if 0 then mouse was in bar, but no title,
; branch and check any special balloons
MOVE.L MenuList,A0 ; mouse was in a title, use the offset in D0.L
MOVE.L (A0),A0 ; A0 -> menuList
MOVE.L menuoH(A0,D0.L),A0 ; get the menu handle
MOVE.L (A0),A0 ; deref to get ptr
MOVE.W menuID(A0),D6 ; get the menu ID we're examining in D6
MOVE.L A0,-(SP) ; push ptr to menu handle data
_DMgrPushMenuState ; restore off modal dialog menu enable flags if they were pushed
MOVE.L (SP)+,A1 ; get those changed enable flags for pop later
MOVE.L (SP)+,A0 ; restore the ptr to the menu handle data (DMgrPush is handle safe)
MOVE.B menuEnable+3(A0),D7 ; save off flags in D7 for compare later
AND.B #$01,D7 ; toss all bits except title
MOVE.L A1,-(SP) ; restore handle state (if any)
_DMgrPopMenuState
MOVE hmgLastMenuID(A2),D0 ; if -1 then there wasn't a previous menu title balloon up
CMP.W #-1,D0 ; <60> check to see if there was a menu title balloon up
BEQ @ResetMenuTitleBalloon ; <60> -1 means exit with CCRs cleared in this case so that the balloon isn't removed
CMP D6,D0 ; <64> go compare it [menu ID in D6]
BNE @Changed ; if different then toss the current balloon (branch to Changed w/ CCRs set)
MOVE.B hmgLastEnabled+3(A2),D0 ; get original menu handle flags
AND.B #$01,D0 ; toss all bits except title
CMP.B D0,D7 ; Note: EOR.B takes 12 cycles instead of 8
; set CCRs, if menu state changed then mark NE and exit
BRA @Changed ; the current balloon will be removed if NE on exit
@ResetMenuTitleBalloon
MOVE.W D6,-(SP) ; <64> put the menuID on stack
MOVE.L D7,-(SP) ; <64> put the menu flags on stack (we only look at the title bit anyway)
JSR __HMShowTitleBalloon ; <64> put a title balloon up if old menu state (hmgLastMenuID) was -1
BRA @ZipOla ; <64> return with zero set CCRs
@specialBar
JSR __HMShowEasyAccessBalloon ; put up the Easy Access balloon if EA is active and mouse is in EA area of menubar
MOVE.W hmgMenuID(A2),D0
CMPI.W #kwasEasyAccess,D0
BEQ @ZipOla
BRA @Changed ; was in EA icon area (next to MF icon)
@notInBar
SUBQ #2,SP ; make space for Find Window result INTEGER
PEA imiPort(A6) ; returns the findwindow VAR result windowptr
JSR __HMGetWindowPartCode ; returns corrected findwindow result code (Handle safe)
MOVE (SP)+,D7 ; put result code [inDrag..inZoomOut] in D7
CMP hmgLastPartCode(A2),D7 ; A2 is a ptr to our globals
BNE @Changed ; NE means that the current examined part code changed, so,
; remove any balloon up
MOVE.L hmgLastWindowPtr(A2),D0 ; OK, get the last examined window ptr
BEQ @NoChange ; if last examined window ptr was NIL then don't compare it's attributes
MOVE.L D0,A0 ; oops! forgot this in a11! Put the window ptr in A0 for attribute check
CMP.L imiPort(A6),A0 ; see if the current 'mouse-is-over-window' <> last window ptr
BNE @Changed ; if NE then go toss that balloon
; <53> There was a bug in B1 (and A11-A12) that would autohide the
; balloon if someone just changed the origin for whatever reason.
; We now calculate (and keep) the portRect's size and watch the
; difference between the portRect.topLeft & portbits.topLeftÉ
MOVE.W PortRect+right(A0),D0 ; <53> get the window's portrect's right coord
SUB.W PortRect+left(A0),D0 ; <53> less the left, gives us the width of the window in D0
CMP.W hmgLastWidth(A2),D0 ; <53> did the width of the window change?
BNE.S @Changed
MOVE.W PortRect+bottom(A0),D0 ; <53> get the window's portrect's bottom
SUB.W PortRect+top(A0),D0 ; <53> less the top, gives us the height of the window in D0
CMP.W hmgLastHeight(A2),D0 ; <53> did the height of the window change?
BNE.S @Changed
MOVE.W PortRect+left(A0),D1 ; <53> get the window's portrect's left coord again
MOVE.W PortRect+top(A0),D7 ; <53> and the window's portrect's top
MOVE portVersion(A0),D0 ; get window port version of last window ptr
AND #$C000,D0 ; see if it was an old style port
BEQ.S @oldPort
MOVE.L portPixMap(A0),A0 ; if it's a new port then check the port's pixmap's bounds
MOVE.L (A0),A0
LEA bounds(A0),A0
BRA.S @newPort
@oldPort
LEA PortBits+bounds(A0),A0 ; otherwise use the window's portbits.bounds
@newPort
MOVE.W left(A0),D0 ; <53> get the left coord of the bounds
SUB.W D1,D0 ; <53> less the left coord of the portRect to get the difference
CMP.W hmgLastLeft(A2),D0 ; <53> was it the same as the last time we checked it?
BNE.S @Changed ; <53> set ccr's and exit if NE
MOVE.W top(A0),D0 ; <53> get the top coord of the bounds
SUB.W D7,D0 ; <53> less the top coord of the portRect to get the difference
CMP.W hmgLastTop(A2),D0 ; <53> was it the same as the last time we checked it?
BNE.S @Changed ; <53> set ccr's and exit if NE
@NoChange
BSR __HMScanHWinResource ; returns a zero in D0 if something found
@ZipOla
MOVEQ #0,D0 ; always return a clear result (these days!)
@Changed
MOVEM.L (SP)+,D6-D7 ; restore regs (but don't set CCRs [MOVEM]) (<64> restore D6 as well)
UNLK A6
RTS
IF HelpMgrTesting THEN
DoDebugSymbols IsBalloonPlaceChanged ; label for MacsBug
ENDIF
;
;
; IsMouseOutsideSlop
;
IsMouseOutsideSlop
MOVE.L ExpandMem,A0 ; point to the expand mem ptr
MOVE.L ExpandMemRec.emHelpGlobals(A0),A0 ; A0 = global ptr
MOVE.L hmgSlopRect(A0),D0
BNE.S @notEmpty
MOVE.L hmgSlopRect+4(A0),D0
BNE.S @notEmpty
MOVEQ #1,D0
RTS
@notEmpty
SUBQ #2,SP ;
MOVE.L Mouse,-(SP) ; push mouse (global coords)
PEA hmgSlopRect(A0) ; push
_PtInRect
TST.B (SP)+
RTS
;
IF HelpMgrTesting THEN
DoDebugSymbols IsMouseOutsideSlop ; label for MacsBug
ENDIF
;
;
; IsMouseInDesk
;
IsMouseInDesk
; *** call FindLayer and PIDName from Layer to make other kHMInOtherLayer balloon
RTS
IF HelpMgrTesting THEN
DoDebugSymbols IsMouseInDesk ; label for MacsBug
ENDIF
;
; IsMouseInMenuBar
;
; Returns NE if mouse was in menubar
;
IsMouseInMenuBar
MOVEM.L D4-D5,-(SP) ; save regs
MOVE.L MenuList,d4 ; Check to see if there is a menu list <71>
beq.s @noMBDF ; If not, exit. <71>
move.l d4,a0 ; <71>
MOVE.L (A0),A0 ; <71>
move.w mbResID(a0),d4 ; Save MBDF resource ID <71>
;
; Try to get the MBDF before pushing parameters on the stack for it. <71>
;
SUBQ #4,SP ; space for return result
MOVE.L #'MBDF',-(SP)
move.w d4,-(SP) ; get resource ID <71>
MOVE.W #MapTRUE,ROMMapInsert ; set flag to load from ROM [someday, I suppose]
_GetResource
MOVE.L (SP)+,D5 ; D5 = 'MBDF' resource handle
BEQ.S @noMBDF ; ack! how can this happen?
CLR.L -(SP) ; make room for defproc return
move.w d4,-(SP) ; Push MBDF resource ID <71>
AND #$0007,(SP) ; low 3 bits is the variant (selector)
MOVE #1,-(SP) ; message # = hit
CLR -(SP) ; parameter 1 = none
MOVE.L Mouse,-(SP) ; push mouse (global coords)
MOVE.L D5,A0 ; get the menu bar defproc handle
_HGetState ; get the current state
MOVE.L D0,D4 ; save state in D4
_HLock ; lock it
MOVE.L (A0),A0 ; get a pointer to it
JSR (A0) ; jump to it
MOVE.L D5,A0 ; get the handle
MOVE.L D4,D0 ; get previous state from d4
_HSetState ; reset previous state
MOVE.L (SP)+,D0 ; get the defproc return
@noMBDF
MOVEM.L (SP)+,D4-D5 ; restore regs
RTS
IF HelpMgrTesting THEN
DoDebugSymbols IsMouseInMenuBar ; label for MacsBug
ENDIF
;
; End __HMBalloonBulk
;
ENDP
;---------------------------------------------------------------------------------------------
;
;
; FUNCTION __HMMungeSearch(MainString,SubString : Ptr): INTEGER;
;
; Searches MainString looking for SubString.
;
; Returns a 1 if SubString was found in MainString
;
; (Each parameter is a ptr to a PString)
;
__HMMungeSearch FUNC EXPORT
;
mmSubString EQU 8 ; stringptr 1
mmMainString EQU mmSubString+4 ; stringptr 1
mmParamSize EQU mmMainString+4-8 ; # of bytes of parameters
mmMungeValue EQU mmMainString+4 ; return value
;
;
; Follows standard pascal register saving conventions
;
LINK A6,#0 ; set up a stack frame
MOVEM.L D3-D7/A3-A4,-(SP) ; save the usual stuff
CLR mmMungeValue(A6) ; clear initial value
MOVEQ #0,D3
MOVEQ #0,D4
MOVE.L mmSubString(A6),A3 ; get the substring 2 addr
MOVE.L mmMainString(A6),A4 ; get the main string 1 addr
MOVE.B (A3)+,D3 ; D3 = size of substring
MOVE.B (A4)+,D4 ; D4 = size of mainstring
CMP.B D4,D3 ; compare lengths
BGT.S @99 ; if MainString's len>SubString's then exit
; A4 contains string to be searched
; D4 contains len
;
; A3 contains target string pointer doing the search
; D3 contains length
MOVE.L A4,D6 ; put main string in D6
MOVE.L D4,D7 ; get size of string
SUB.L D3,D7 ; subtract len of string
ADD.L D6,D7 ; point to last valid search loc
@outer
MOVE.L D3,D1 ; inner loop ctr for compare
MOVE.L D6,A0 ; working copy of main string
MOVE.L A3,A1 ; working copy of search string
BRA.S @startDBRA
@inner
CMP.L D6,D7 ; see if anchor if past limit
BCS.S @notFound
CMPM.B (A0)+,(A1)+ ; compare bytes
BNE.S @tryNext
@startDBRA
DBRA D1,@inner ;
; If it gets to here, the target string matched!
MOVE #1,mmMungeValue(A6)
BRA.S @99
; The match failed on this byte, move anchor to next and try again
@tryNext
ADDQ.L #1,D6 ; anchor ++
BRA.S @outer
; The match failed entirely, go home with with a zero
@notFound
@99
MOVEM.L (SP)+,D3-D7/A3-A4 ; restore the usual stuff
UNLK A6
MOVE.L (SP)+,A0
ADDA.L #mmParamSize,SP ; or LEA mmParamSize(SP),SP but this is slower
JMP (A0)
IF HelpMgrTesting THEN
DoDebugSymbols __HMMungeSearch ; label for MacsBug
ENDIF
ENDP
;---------------------------------------------------------------------------------------------
;
; __HMScanHWinResource
;
; This routine is called from the _SystemTask patch and scans a 'hwin' resource
; looking for a match for the _FrontWindow's window title and a name in the 'hwin'
; window array. If found, it then scans the corresponding 'hrct' or 'hdlg' resource that
; 'belongs' to the 'hwin' resource. A 'hrct' resource contains an array of tip, altRect,
; and balloon data for the 'hot' rects & the 'hdlg' resource is an array of tip, altRect,
; and balloon data.
;
; Returns 0 if call handled, -1 if missing or false scan
;
; Modification history:
; 08May92 KSCT added code to support Input Method's floating window ... <#72>
;
; some local variables
;
scanHotRect EQU -8 ; hot rect
scanIndex EQU scanHotRect-2 ; current index
scanTempPt EQU scanIndex-4 ; point to test mouse with
scanPort EQU scanTempPt-4 ; the previous port goes here
scanWTitle EQU scanPort-256
scanResFile EQU scanWTitle-2
scanCurResFile EQU scanResFile-2
scanResID EQU scanCurResFile-2
scanResType EQU scanResID-4
scanResName EQU scanResType-256
scanResHandle EQU scanResName-4
scanhwinCount EQU scanResHandle-2
scanhwinIndex EQU scanhwinCount-2
scanHelpMsg EQU scanhwinIndex-khmmMsgSize ; max size of help msg
scanSize EQU scanHelpMsg
;
; Note that the _GetIndResource call below searches all open resource files for
; the current layer. We MUST set the CurResFile to be the matching 'hwin'
; resource's resource reference number in order to find the correct 'hrct' resource.
;
;
__HMScanHWinResource PROC EXPORT
IMPORT __HMScanTemplateItems
IMPORT __HMFillInHelpMessage
IMPORT __HMShowContentBalloon
IMPORT __HMRemoveBalloon
IMPORT __HMMungeSearch
move.l a3,-(sp) ; save a3 <#72>
suba.w #(2+tsmHelpRecSize),sp ; OSErr result + tsmRecSize <#72>
move.w #kMsgHelpHELPMgr,-(sp) ; message number <#72>
pea 4(sp) ; param ptr <#72>
_InformTSM ; call Text Services Manager <#72>
move.w (sp)+,d0 ; is this IM's window? <#72>
movea.l sp,a3 ; a3 = param record <#72>
; (got window/refnum if d0 = noErr) <#72>
clr.l tsmHelpSavedLayer(a3) ; clear layer local <#72>
tst.w d0 ; over a floater? <#72>
bne.s @notIMWindow ; not over a floating, then cool => <#72>
;; need to swap the layer to IM layer ......