Bring in CubeE sources

Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included.

The Tools directory, containing mostly junk, is also excluded.
This commit is contained in:
Elliot Nunn
2017-09-17 17:09:04 +08:00
commit 4325cdcc78
1820 changed files with 1351740 additions and 0 deletions
+954
View File
@@ -0,0 +1,954 @@
;
; File: ButtonCDEF.a
;
; Contains: Standard Button Definition Procedure for the MacIntosh Control Manager
; This file contains the control definition procedures that define
; the standard "button" type controls. These include PushButtons,
; CheckBoxes, and a checkBox variant called RadioButton.
;
; Written by: Andy Hertzfeld August, 1982
;
; Copyright: © 1982-1992 by Apple Computer, Inc., all rights reserved.
;
; This file is used in these builds: Mac32 HcMac MacPP BigBang Sys606
;
; Change History (most recent first):
;
; <SM2> 10/22/92 CSS Change short branches to word branches.
; <14> 4/11/91 gbm csd, KSM, BRC#86464: Fix many references to the control
; rectangle which are invalid because the control handle can be
; unlocked.
; <13> 3/4/91 dba dty: get rid of SysVers conditionals
; <12> 12/14/90 VL (ksm) Use PaintRoundRect instead of PaintRect for dithering
; text. Also, changed PenMode to TextMode since grayishTextOr is a
; text mode.
; <11> 8/23/90 SAM Removed the MoveHHi from the DrawPBut routine so that MacApp
; will work (it assumes that handles will be ok across calls to
; DrawControl -- idiots!)
; <10> 8/17/90 dvb Change grayish textMode pnMode to txMode
; <9> 8/13/90 VL Fixed test for portVersion to avoid trashing portVersion's
; value.
; <8> 8/2/90 VL Replaced SysVers switch with UseTrueGrayText (for ROM build).
; <7> 8/1/90 VL Make text to be drawn in TrueGray when disabled (in a color
; grafport).
; <6> 6/14/90 DDG NEEDED FOR SIXPACK: Moved the control manager handle with
; _MoveHHi before we lock it down while we are drawing. This
; should prevent out-of memory problems.
; <5> 5/29/90 DDG NEEDED FOR SIXPACK: Added the proper tag to the previous
; comment.
; <4> 5/29/90 DDG NEEDED FOR SIXPACK: Fix a bug where the button title is left
; unlocked for the duration of the drawing call.
; <3> 5/1/90 DDG Removed the temporary conditionals that I added for Sys605.
; <2> 3/2/90 DDG Adding conditionals for Sys605
; <1.4> 11/17/89 dba took out checks for 64K ROMs
; <1.3> 8/22/89 SES removed references to nFiles; updated equates accordingly
; <1.2> 2/9/89 EMT added new messages for 32-bit clean Control Manager.
; <1.1> 11/11/88 CCH Fixed Header.
; <1.0> 11/9/88 CCH adding to EASE.
; <¥1.1> 9/23/88 CCH Got rid of inc.sum.d and empty nFiles
; <1.0> 2/12/88 BBM Adding file for the first time into EASEÉ
; <C948> 11/8/87 DAF Updated romres sources from system disk sources
; SMAB156> 3/30/87 DAF Tested ROM version before using teSysJust.
; <C818> 2/14/87 DAF Converted nuMac PaintRoundRgn to be unified with other MacsÕ
; Erase stopped setting backColor when drawing text.
; <C700> 1/26/87 DAF Universal version of ButtonCDEF.a (version 10)
; <C637> 1/14/87 DAF Changed textMode back to srcOR from srcCopy (sigh...)
; <C560> 12/21/86 DAF Added Mark DavisÕ code to allow reversed checkmarks for intl
; <C424> 11/18/86 DAF converted a BSET/BCLR to an HLock/HUnlock, in CalcPBut
; <C407> 11/16/86 DAF changed textMode (again) to srcCopy, as per CaryÕs
; recommendation
; <C203> 10/8/86 DAF updated color support on nuMac for RGBColors changed textMode to
; srcOr.
; <C59> 6/30/86 DAF added color support for nuMac (mucho chango)
; <v4> 8/26/85 EHB made variable sized fonts work (ROM85>0 only)
; <v3> 5/20/85 EHB implemented Multi-Line buttons
; <v2> 5/16/85 EHB only return "254" if point in control!
; 3/12/85 JTC changed occurrences of LGlobals to GrafGlobals
; 2/14/85 JTC added res name
; 1/14/85 JTC convert to MDS
; 12/31/83 AJH made text of checkBox/radioButtons grayed out if disabled
; 10/17/83 AJH back to "gray-out" button disabling
; 10/12/83 AJH changed button disabling
; 9/27/83 AJH made variants > 7 not force the system font
; 8/29/83 AJH fixed scrambling bug in CalcPBut
; 6/7/83 AJH fixed scrambling bug, changed check draw for new QuickDraw
; 4/4/83 AJH made it force size 12 for text
; 4/1/83 AJH made it use hardwired gray
; 3/27/83 AJH made it respect initial clip in button drawing
; 3/11/83 AJH fixed up check box drawing
; 12/28/82 AJH Put button definitions in their own file
; 11/16/82 AJH Made branch tables offset based
; 11/14/82 AJH Improved PushButton roundness scaling; removed box in arrowBits
; 10/17/82 AJH Made controlProcs preserve A1
; 10/10/82 AJH Converted for QuickDraw Trap Interface
; 10/5/82 AJH Fixed checkBox flashing, added code saving optimizations
; 10/3/82 AJH Fixed bug in scrollBar positioning -- wasnÕt ctl relative
; 9/29/82 AJH Added CheckBox control definition procedure
; 8/29/82 AJH Added "255" hiliting,
; 8/25/82 AJH Fixed corner-clobber bug in pushButProc
; 8/22/82 AJH Added clipping, centering to PushButProc
;
; To Do:
;
PRINT PUSH,OFF
LOAD 'StandardEqu.d'
INCLUDE 'ColorEqu.a'
PRINT POP
;----------------------------------------------------------------------------------------------------
CDEF0 PROC EXPORT
; FUNCTION PushButProc( selector: INTEGER; 18
; theControl: ControlHandle; 14
; message: INTEGER; 12
; param: LongInt): LongInt; 8 : 20
;
; PushButProc is the control definition procedure for simple pushButtons, one of the
; standard control types supported by the user interface toolBox.
; And a stack frame definition
CtlHndl EQU 14 ;incoming control handle param <C59/30Jun86> DAF
SavePen EQU -20
Align EQU -21 ;a dead byte for IsColor <C700/26Jan87> DAF
IsColor EQU -22 ;do we have colorQD and toolbox [boolean] <C700/26Jan87> DAF
IndicatorRect EQU -30
AuxCtlHndl EQU -34 ;handle of auxCtl ColorTable <C59/30Jun86> DAF
AuxCtlPtr EQU -38 ;ptr to auxCtl ColorTable <C59/30Jun86> DAF
ContentRGB EQU -44 ;window content color <C59/30Jun86> DAF
SavFgCol EQU -50 ;window portÕs RGBFgColor <Cxxx/06Oct86> DAF
SavBkCol EQU -56 ;window portÕs RGBBkColor <Cxxx/06Oct86> DAF
useGrayText EQU -58
FrameSize EQU -58
BRA.S @0 ; skip header
; standard header
DC.W 0 ; flags
DC.L ('CDEF')
DC.W 0
DC.W 11 ; version #
@0
LINK A6,#FrameSize ; set up a stack frame to address parameters <C59/30Jun86> DAF
MOVEM.L D3-D7/A1-A4,-(SP) ; save work registers
;
; buttons only handle messages 0,1,2,10,11 <1.2>
;
CMP.W #calcCtlMsg,12(A6) ; inspect message value <1.2>
BLS.S @MsgOK ; if <2, itÕs OK <1.2>
CMP.W #calcWholeCtlMsg,12(A6) ; <1.2>
BEQ.S @MsgOK ; 10 is OK too <1.2>
CMP.W #calcThumbCtlMsg,12(A6) ; <1.2>
BNE DoneP1 ; And 11 <1.2>
@MsgOK
;
; save the penState and set it our way
;
PEA SavePen(A6) ; push pointer to savePenState
_GetPenState ; remember current penState
_PenNormal ; set the pen the way we want it
; Determine type of system. We need to know if we have color QuickDraw and a color
; window manager port.
CMP.W #$3FFF,ROM85 ; do we have color QD?
SLS IsColor(A6) ; set boolean depending on color or B&W system
BHI @BWSys ; no, this system has B&W QD <SM2> CSS
; save the current portÕs colors and textMode <C59/30Jun86> DAF
MOVE.L GrafGlobals(A5),A0 ; get pointer to grafGlobals <C407/16Nov86> DAF
MOVE.L thePort(A0),A0 ; get pointer to thePort <C407/16Nov86> DAF
MOVE.W txMode(A0),-(SP) ; save the current text mode <C407/16Nov86> DAF
MOVE.W #srcOR,-(SP) ; push text mode <C637/16Nov86> DAF
_TextMode ; <C407/16Nov86> DAF
PEA SavFgCol(A6) ; save foreColor
_GetForeColor ;
PEA SavBkCol(A6) ; save backColor too
_GetBackColor ;
;
; get the CtlAuxRec for this guy and lock its colortable <C59/30Jun86> DAF
;
CLR.L -(SP) ; return the handle here
CLR.B -(SP) ; space for boolean func return
MOVE.L CtlHndl(A6),-(SP) ; push the control handle
PEA 6(SP) ; push a pointer to placeholder
_GetAuxCtl ; get its auxRec
ADDQ #2,SP ; donÕt need boolean result
MOVE.L (SP)+,A0 ; get auxCtl handle
MOVE.L (A0),A0 ; a pointer to the auxCtlRec
MOVE.L acCTable(A0),A0 ; get colortableÕs handle <1.3>
MOVE.L A0,AuxCtlHndl(A6) ; save the handle
_HLock ; lock the handle
MOVE.L (A0),AuxCtlPtr(A6) ; save a pointer
;
; get the WinAuxRec that this control is in and copy its content color to
; the stack frame.
;
CLR.L -(SP) ; make a placeholder for a handle
CLR.B -(SP) ; room for a boolean result
MOVE.L CtlHndl(A6),A0 ; get the controlHandle again
MOVE.L (A0),A0 ; get a pointer
MOVE.L contrlOwner(A0),-(SP) ; push the owning window pointer
PEA 6(SP) ; pointer to the placeholder
_GetAuxWin ; get the window auxRec
ADDQ #2,SP ; bag the boolean
MOVE.L (SP)+,A0 ; get the WinAuxRec handle
MOVE.L (A0),A0 ; handle->ptr
MOVE.L awCTable(A0),A0 ; get the colortable handle <1.3>
MOVE.L (A0),A0 ; handle->ptr
MOVE.W CTSize(A0),D0 ; get the table count
MULU.W #8,D0 ; get a table index
@1
TST.W CTTable+value(A0,D0) ; is it wContentColor (=0)?
BEQ.S @2 ;
SUBQ #8,D0 ; move to previous colorSpec
BGE.S @1 ; and loop back
CLR.L D0 ; if not found, just use the first one
@2
MOVE.L CTTable+rgb(A0,D0),ContentRGB(A6) ; copy the color over
MOVE.W CTTable+rgb+4(A0,D0),ContentRGB+4(A6) ;
@BWSys
;
; fetch the parameters into registers
;
LEA 8(A6),A0 ; get ptr to first parameter
MOVE.L (A0)+,D3 ; get param in D3
MOVE.W (A0)+,D0 ; get message
MOVE.L (A0)+,A3 ; get the control handle
MOVE.W (A0)+,D6 ; get selection index
MOVE.W D6,D7 ; remember raw selection code
AND #7,D6 ; strip high part of selection code
CLR.L (A0) ; clear out function result
MOVE.L (A3),A0 ; get control pointer in A0
;
; case out on the message number
;
msgAdjust EQU calcWholeCtlMsg-calcCtlMsg-1 ; So that 10 becomes 3, 11 becomes 4 <1.2>
CMP.W #calcCtlMsg, D0 ; Does message need adjusting? <1.2>
BLS @LoMsg ; DonÕt adjust if not. <1.2>
SUBQ.W #msgAdjust, D0 ; Adjust message for address calculation <1.2>
@LoMsg
ADD D0,D0 ; double for word index
LEA GoPushBut,A1 ; get table address
ADD 0(A1,D0),A1 ; compute dispatch address
JSR (A1) ; dispatch to appropriate routine
;
; clean up color stuff
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor1 ; if on B&W, then skip
MOVE.L AuxCtlHndl(A6),A0 ; unlock the CDEF
_HUnlock
PEA SavFgCol(A6) ; restore the port colors
_RGBForeColor ;
PEA SavBkCol(A6) ;
_RGBBackColor ;
_TextMode ; restore the textMode <C407/16Nov86> DAF
@noColor1 ; END OF A COLOR-ONLY SECTION
;
; restore original pen state
;
PEA SavePen(A6) ; push savePenState
_SetPenState ; restore original pen state
;
; weÕre done -- restore registers and return to caller
;
DoneP1
MOVEM.L (SP)+,D3-D7/A1-A4 ; restore work registers
UNLK A6 ; unlink stack frame
TenBytExit MOVE.L (SP)+,A0 ; get return address
ADD #12,SP ; strip parameters
JMP (A0) ; return to caller
;
; PushButProc dispatch table -- entries must be long branches!
;
GoPushBut
DC.W DrawPBut-GoPushBut ; draw is message 0
DC.W HitPBut-GoPushBut ; hit test is message 1
DC.W CalcPBut-GoPushBut ; calc regions is message 2
DC.W CalcWholePBut-GoPushBut ; calc whole regions is message 10 <1.2>
DC.W CalcThumbPBut-GoPushBut ; calc thumb regions is message 11 <1.2>
ButStub RTS
; SetUpColor takes a window part identifier in D0, finds the corresponding
; part in the AuxWinTable (the part code is in the .value field) and returns
; a pointer to its RGB on the stack. If the requested part is not found,
; the first color table element is used (IÕd use frameColor, but that might
; not be there!). Trashes A0/D0.
SetUpColor
MOVE.L D1,-(SP) ; save a register
MOVE.L AuxCtlPtr(A6),A0 ; get the color table pointer
MOVE.W CTSize(A0),D1 ; get the color table size
MULU #8,D1 ; convert to color table index
LegalIndex
CMP.W CTTable+value(A0,D1),D0 ; is this the one?
BEQ.S FoundIt ; if equal, then done
SUB.W #8,D1 ; try the previous one
BGE.S LegalIndex ; loop while index positive
MOVEQ #0,D1 ; OK, use the first one
FoundIt
LEA CTTable+rgb(A0,D1),A0 ; get the address of the color to use
MOVE.L A0,D0 ; weÕll need A0 in a second
MOVE.L (SP)+,D1 ; restore the register
MOVE.L (SP)+,A0 ; get the return address
MOVE.L D0,-(SP) ; push the rgb addr on the stack
JMP (A0) ; return to caller
;
; DrawPBut draws the pushButton
;
DrawPBut
TST.B ContrlVis(A0) ; is it visible?
BEQ.S ButStub ; if not, weÕre done
;
; calculate roundness as function of rectangle size
;
BSR RoundCalc ; compute roundNess factor in D4
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor2 ; if on B&W, then skip
;
; if pushbutton, paint bk to body color; if checkmark then erase to window content <C59/30Jun86> DAF
;
@9 TST.B D6 ; is it a pushButton?
BEQ.S @4 ;
; set the window content color to the back for the eraseRRect <C59/30Jun86> DAF
PEA ContentRGB(A6) ; push the pointer to content color
BRA.S @5
; set the body color for button <C59/30Jun86> DAF
@4
MOVE.L (A3),A0 ; get control rec pointer
MOVE.B contrlHilite(A0),D0 ; get the hilite byte
SUBQ.B #1,D0 ; make 0->$FF
CMP.B #$FD,D0 ; is the control hilited?
BHS.S @8 ; no, so continue
MOVEQ #cTextColor,D0 ; if it is, paint the button in text color
BRA.S @0
@8 MOVEQ #cBodyColor,D0 ; if its not, then paint body color
@0 BSR.S SetUpColor ; get info on the stack
;
; erase the bounding rectangle (if necessary)
;
@5
_RGBBackColor ; set it
MOVE.L (A3),A0 ; get controlHandle again
@NoColor2 ; END OF A COLOR-ONLY SECTION
LEA ContrlRect(A0),A4 ; get pointer to bounding rect
TST.B D6 ; is it a pushButton?
BEQ.S EraseCBound ; push buttons are always erased
TST.B D3 ; draw all?
BNE.S SkipCErase ; if not, donÕt bother to erase
;
EraseCBound
MOVE.L A4,-(SP) ; push rect
MOVE.L D4,-(SP) ; push rounding factor
_EraseRoundRect ; paint it the background color
;
; save the current font and force the system font
;
SkipCErase MOVE.L GrafGlobals(A5),A0 ; get GrafGlobals base
MOVE.L ThePort(A0),A0 ; get current port
MOVE.L txFont(A0),-(SP) ; remember the font,face
MOVE.W txSize(A0),-(SP) ; remember the size
SUBQ #8,D7 ; was code 8 or greater?
BGE.S @gotFont ; if so, use windowÕs font
CLR.L txFont(A0) ; force system font, normal face
MOVE.W SysFontSize,D0 ; get default size <EHB 26Aug85>
BNZ.S @gotSize ; => itÕs 0! <EHB 26Aug85>
MOVE.B FMDefaultSize,D0 ; get default size <EHB 26Aug85>
@gotSize
MOVE.W D0,txSize(A0) ; set size of font <EHB 26Aug85>
@gotFont
MOVE.L ClipRgn(A0),-(SP) ; push the current clipRgn handle
; save old clip region and clip to the bounding rectangle sected with oldClip
CLR.L -(SP) ; make space for region handle
_NewRgn ; allocate a region
MOVE.L (SP),A2 ; remember region but leave on stack
_GetClip ; remember the current clipRgn
MOVE.L (A3),A0 ; get control pointer
PEA ContrlRect(A0) ; push pointer to its bounding rect
_ClipRect ; make that the clipping region
MOVE.L A2,-(SP) ; push the old ClipRgn
MOVE.L 4(SP),-(SP) ; the answer goes into current clip
_SectRgn ; intersect new and old
; Save off some registers for mondo button title calculations, then
; set them up for our use
MOVE.L A3,A0 ; copy control handle to A0 for memory calls
_HGetState
MOVE.L D0,-(SP) ; save the state of the control handle for later
;;; _MoveHHi ; move it up, before we lock it down <11> SAM (Removed)
_HLock ; lock it down
MOVEM.L D4/A2-A3,-(SP) ; save registers <EHB 20-May-85>
MOVE.L (A3),A0 ; get pointer to control
LEA contrlTitle(A0),A2 ; get title into A2
LEA contrlRect(A0),A4 ; get rect into A4 <EHB 20-May-85>
MOVEQ #0,D7 ; <EHB 20-May-85>
MOVE.B (A2),D7 ; get string length into D7 <EHB 20-May-85>
BEQ NoTitle ; quick check for nothing <EHB 20-May-85>
; now count the number of lines in the title. Lines are separated by CRÕs
MOVEQ #0,D4 ; save number of lines in D4 <EHB 20-May-85>
@2
ADDQ #1,D4 ; count next line <EHB 20-May-85>
BSR Pt2Next ; point to next line (index in D7) <EHB 20-May-85>
TST.B D7 ; D7 < 0 if done <EHB 20-May-85>
BPL.S @2 ; => get next line <EHB 20-May-85>
MOVE.B (A2),D7 ; get string length back <EHB 20-May-85>
; now get a font info record on stack, pointer to it in A3
SUBQ #8,SP ; make room for 4 INTEGERS <EHB 20-May-85>
MOVE.L SP,A3 ; save pointer in A3 <EHB 20-May-85>
MOVE.L A3,-(SP) ; push pointer to record <EHB 20-May-85>
_GetFontInfo ; and fill the record <EHB 20-May-85>
; Set up D5 to point to the baseline of the last line
BSR GetHeight ; get height of line into D0 <EHB 20-May-85>
MULU D4,D0 ; #lines times height <EHB 20-May-85>
MOVE.W bottom(A4),D1 ; get bottom of rect <EHB 20-May-85>
MOVE.W D1,D5 ; D5 will be baseline <EHB 20-May-85>
SUB.W top(A4),D1 ; get height of rect <EHB 20-May-85>
SUB.W D0,D1 ; get unused space <EHB 20-May-85>
ASR.W #1,D1 ; and DIV by 2 <EHB 20-May-85>
SUB.W D1,D5 ; move up from bottom <EHB 20-May-85>
SUB.W leading(A3),D5 ; to bottom of descender <EHB 20-May-85>
SUB.W descent(A3),D5 ; to first baseline <EHB 20-May-85>
DoNextLine
; get the width of the current line into D0
BSR Pt2Next ; next line in D7, len in D3 <EHB 20-May-85>
CLR.W -(SP) ; make room for result <EHB 20-May-85>
MOVE.L A2,-(SP) ; push title pointer <EHB 20-May-85>
MOVE.W D7,D0 ; get our offset into string <EHB 20-May-85>
ADDQ.B #2,D0 ; bump past length (or CR) <EHB 20-May-85>
MOVE.W D0,-(SP) ; push true offset into string <EHB 20-May-85>
MOVE.W D3,-(SP) ; push number of bytes <EHB 20-May-85>
_TextWidth ; get the stringÕs width <EHB 20-May-85>
MOVE.W (SP)+,D0 ; and save result in D0 <EHB 20-May-85>
; if itÕs a checkbox, donÕt center it, just move to right a little
TST.B D6 ; is it a check box?
BEQ.S ElCentro ; => no, go center the string <EHB 20-May-85>
; adjust positioning for push button
tst.w teSysJust ; right to left? <MED 27-Aug-86>
beq.s LeftBox ; no, normal case <MED 27-Aug-86>
RightBox
MOVE.W right(A4),D1 ; get the right edge <MED 27-Aug-86>
SUB.W left(A4),D1 ; get the width <MED 27-Aug-86>
SUB.W D0,D1 ; subtract stringÕs width <MED 27-Aug-86>
sub.w #18,d1 ; subtract room for box <MED 27-Aug-86>
ADD.W left(A4),D1 ; and add into left <MED 27-Aug-86>
BRA.S DrawBTitle ; back to common code <MED 27-Aug-86>
LeftBox
MOVE.W Left(A4),D1 ; get the left edge
ADD.W #18,D1 ; leave room for check box
BRA.S DrawBTitle ; back to common code
ElCentro
; center the line in the rect
MOVE.W right(A4),D1 ; get the right edge
SUB.W left(A4),D1 ; get the width
SUB.W D0,D1 ; subtract stringÕs width
ASR.W #1,D1 ; get centering offset
ADD.W left(A4),D1 ; and add into left
DrawBTitle
MOVE.W D1,-(SP) ; push horizontal position
MOVE.W D5,-(SP) ; and vertical position <EHB 20-May-85>
_MoveTo ; move the pen there
; now that registers are free, push colors on stack <C59/30Jun86> DAF
MOVE.L GrafGlobals(A5),A0 ; Save the pen mode
MOVE.L thePort(A0),A0 ;
MOVE.W txMode(A0),-(SP) ; <12>
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @notColor ; no, skip the gray text checking stuff totally
MOVE.W portVersion(A0),D0 ; get portVersion into D0 for comparison
AND.W #$C000,D0 ; are we using a color grafport?
SNE useGrayText(A6) ; yes, set boolean useGrayText to true for future reference
BRA.S @doneCheckingForGrayText
@notColor ;
MOVE.B #0,useGrayText(A6) ; set boolean useGrayText to false
@doneCheckingForGrayText
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor4 ; if on B&W, then skip
MOVE.L CtlHndl(A6),A0 ; get the control handle (not A3 in this section) <DAF 29Apr86>
MOVE.L (A0),A0 ; get control pointer
MOVE.B ContrlHilite(A0),D0 ; need to handle the case of 254/5 hiliting
BEQ.S @1 ; skip if hiliteValue == 0
CMP.B #$FE,D0 ; Is the button hilited?
BHS.S @Hilited ; skip if hiliteValue > 254 (i.e. disabled)
TST.B D6 ; Is it a check box or radio button?
BNE.S @1 ; yes => Want to set the forecolor to CTextColor in 7.0
MOVE.W #cBodyColor,D0 ; no => use cBodyColor as ForeColor in 6.0
BRA.S @4 ; (because BackColor is cTextColor)
@Hilited ;
TST.B useGrayText(A6) ; can we use GrayText?
BEQ.S @1 ;
MOVE.W #grayishTextOr,-(SP) ; yes => set the pen mode to grayishTextCopy
_TextMode ;
@1
MOVE.W #cTextColor,D0 ; use cTextColor as ForeColor
@4
BSR SetUpColor ; deposit appropriate values on stack
_RGBForeColor
@NoColor4
MOVE.L A2,-(SP) ; point to string <EHB 20-May-85>
MOVE.W D7,D0 ; get our offset into string <EHB 20-May-85>
ADDQ.B #2,D0 ; bump past length (or CR) <EHB 20-May-85>
MOVE.W D0,-(SP) ; push true offset into string <EHB 20-May-85>
MOVE.W D3,-(SP) ; push length in bytes <EHB 20-May-85>
_DrawText ; this is where we draw the line
_TextMode ; <12>
; bump baseline point up to next line, test for end
BSR GetHeight ; get line height into D0 <EHB 20-May-85>
SUB.W D0,D5 ; go up to next base line <EHB 20-May-85>
TST.B D7 ; done yet? <EHB 20-May-85>
BPL DoNextLine ; => nope <EHB 20-May-85>
ADDQ #8,SP ; strip font record <EHB 20-May-85>
NoTitle
MOVEM.L (SP)+,D4/A2-A3 ; and all those registers <EHB 20-May-85>
MOVE.L A3,A0 ; copy control handle to A0 for HSetState
MOVE.L (SP)+,D0 ; get the state off the stack and set it back
_HSetState
; <14>
; WARNING! Setting the state of the control record handle here may leave it unlocked! Several
; references are made below to items in the control record (mostly the control rect).
; Each reference must include reloading the control record pointer from the control
; record handle contained in register a3.
;
; We now return you to your regularly scheduled program.
; <14>
; restore original font, face and size
MOVE.L GrafGlobals(A5),A0 ; get GrafGlobals base
MOVE.L ThePort(A0),A0 ; get current port
MOVE.W (SP)+,txSize(A0) ; restore the size
MOVE.L (SP)+,txFont(A0) ; restore the font,face
;
; set the pen color to FrameColor <C59/30Jun86> DAF
;
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor5 ; if on B&W, then skip
MOVEQ #cFrameColor,D0 ;
BSR SetUpColor ;
_RGBForeColor ;
@NoColor5 ; END OF A COLOR-ONLY SECTION
TST.B D6 ; is it a checkBox?
BNE PlotCheck ; if so, go draw it
move.l (a3), a0 ; get control pointer <14>
lea contrlRect(a0), a4 ; point to the control rect <14>
MOVE.L A4,-(SP) ; push the rectangle pointer
MOVE.L D4,-(SP) ; push rounding factor
_FrameRoundRect ; frame the button
;
; perform SpecialHilite if necessary
;
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor6 ; if on B&W, then skip
TST.B useGrayText(A6) ; did we use GrayText?
BNE.S @skipSpecialHilite ; yes => skip SpecialHilite since GrayText represents hilite state already
MOVE.L (A3),A0 ; get control pointer
CMP.B #$FE,ContrlHilite(A0) ; is it the special hilite state?
BHS.S SpecialHilite ; if so, go do it
@skipSpecialHilite
BRA.S @Common6 ; and continue...
@NoColor6
;
; hilite the button if necessary
;
MOVE.L (A3),A0 ; get control pointer
MOVE.B ContrlHilite(A0),D0 ; is it hilited?
BEQ.S DoneDrwBut ; if not, weÕre done
;
TST.B useGrayText(A6) ; did we use GrayText?
BNE.S @Common6 ; yes, skip SpecialHilite since GrayText represents hilite state already
CMP.B #$FE,D0 ; is it the special hilite state?
BHS.S SpecialHilite ; if so, go do it
;
lea contrlRect(a0), a4 ; point to the control rect <14>
MOVE.L A4,-(SP) ; push rectangle
MOVE.L D4,-(SP) ; push rounding factor
_InverRoundRect ; hilite by inverting
@Common6
;
; restore original clipping region and weÕre done
;
DoneDrwBut
_PenNormal ; set the pen back to normal
MOVE.L A2,-(SP) ; push old clip region
_SetClip ; restore it
MOVE.L A2,-(SP) ; dispose of temporary region
_DisposRgn ; de-allocate it
RTS ; all done!
;------------
; Utility Pt2Next -- Point to next line within the title
; On Entry: A2 Title pointer
; D7 offset to end of next line to do
; On Exit: D7 offset to next line-2 (D7<0 if last line)
; D3 length of next line
CR EQU $0D ; CR = carriage return
Pt2Next
MOVEQ #0,D3 ; clear out count <EHB 20-May-85>
TST.B D7 ; pointing at count? <EHB 20-May-85>
BEQ.S @2 ; => yes, a leading CR <EHB 20-May-85>
@1
CMP.B #CR,0(A2,D7) ; is char a CR? <EHB 20-May-85>
BEQ.S @2 ; => yes, all done <EHB 20-May-85>
ADDQ #1,D3 ; else bump count by one <EHB 20-May-85>
SUBQ.B #1,D7 ; and move back in string <EHB 20-May-85>
BNE.S @1 ; => not end of string <EHB 20-May-85>
@2
SUBQ.B #1,D7 ; prepare for next string <EHB 20-May-85>
RTS ; D7 < 0 if last line <EHB 20-May-85>
;------------
; Utility GetHeight -- return in D0 the height of on line
; On Entry: A3 Font Record
; On Exit: D0 Line height
GetHeight
MOVEQ #0,D0 ; clear out height <EHB 20-May-85>
ADD.W ascent(A3),D0 ; height = ascent + descent + leading <EHB 20-May-85>
ADD.W descent(A3),D0 ; <EHB 20-May-85>
ADD.W leading(A3),D0 ; <EHB 20-May-85>
RTS
; SpecialHilite handles drawing the disabled button
SpecialHilite
BSR.S DisableText
BRA.S DoneDrwBut
DisableText
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor7 ; if on B&W, then skip
TST.B D6 ; is it a pushbutton?
BNE.S @NoColor7 ; a checkbox, so go
MOVEQ #cTextColor,D0 ; set the colors apropos
BSR SetUpColor ;
_RGBForeColor ;
MOVEQ #cBodyColor,D0 ;
BSR SetUpColor ;
_RGBBackColor ;
@NoColor7 ; END OF A COLOR-ONLY SECTION
move.l (a3), a0 ; get control pointer <14>
lea contrlRect(a0), a4 ; point to the control rect <14>
MOVE.L A4,-(SP) ; push rectangle
MOVE.L #$00010001,-(SP) ; <12>
_InsetRect
MOVE.L A4,-(SP) ; push rectangle
MOVE.L D4,-(SP) ; push the rounding factor <12>
MOVE.L (A5),A0
PEA Gray(A0)
_PenPat
MOVE #patBIC,-(SP)
_PenMode
_PaintRoundRect ; gray it out <12>
_PenNormal
move.l (a3), a0 ; get control pointer <14>
lea contrlRect(a0), a4 ; point to the control rect <14>
MOVE.L A4,-(SP)
MOVE.L #$FFFFFFFF,-(SP) ; <12>
_InsetRect
RTS
; RoundCalc calculates the rounding factor in D4 based on the controlÕs rect
RoundCalc
TST.B D6 ; is it a checkBox?
BNE.S CheckRound ; if so, special case it
;
MOVE.W ContrlRect+Bottom(A0),D4 ; get bottom coordinate
SUB.W ContrlRect+Top(A0),D4 ; figure out vertical height
LSR #1,D4 ; scale it down by a factor of 2
MOVE D4,D0 ; fill both halves with it
SWAP D4 ; get in high part
MOVE D0,D4 ; and in low part
RTS
;
CheckRound MOVEQ #0,D4 ; checkBoxes are square!
RTS
;
; HitPBut handles the button hit-test
;
HitPBut
MOVE.B ContrlHilite(A0),D4 ; get hiliteState <EHB 16-May-85>
ADDQ.B #1,D4 ; is it 255? <EHB 16-May-85>
BEQ.S @1 ; if so, skip
CLR.W -(SP) ; make room for function result
MOVE.L D3,-(SP) ; push the point
PEA ContrlRect(A0) ; push address of rect
_PtInRect ; in the rectangle?
TST.B (SP)+ ; examine result
BEQ.S @1 ; if not, weÕre done
ADDQ.B #1,D4 ; 254 hiliting? <EHB 16-May-85>
BEQ.S Return254 ; => say it is so <EHB 16-May-85>
MOVE #inButton,22(A6) ; return that it was
TST.B D6 ; a checkBox?
BEQ.S @1 ; if not, weÕre done
ADDQ #1,22(A6) ; if so, flag it
@1 RTS
Return254
MOVE #254,22(A6) ; indicate its 254-disabled
RTS
CalcWholePBut
CalcThumbPBut
MOVE.B #1, 23(A6) ; return 1 to show that we respond <V1.2>
;
; CalcPBut returns the bounding region of the button
;
CalcPBut
TST.B D6 ; is it a checkBox?
BNE.S CalcSquare ; check box bounds are just rects
;
BSR.S RoundCalc ; calculate rounding factor
_HidePen ; dont draw anything
_OpenRgn
MOVE.L A3,A0 ; copy to A0 for HLock <C424/18Nov86> DAF
_HLock ; lock it down <C424/18Nov86> DAF
MOVE.L (A3),A0 ; get pointer to control
PEA ContrlRect(A0) ; push rectangle pointer
MOVE.L D4,-(SP) ; push rounding factor
_FrameRoundRect ; frame the button
MOVE.L D3,-(SP) ; push the region
_CloseRgn ; make the rounded rectangular region
_ShowPen
MOVE.L A3,A0 ; copy to A0 for HLock <C424/18Nov86> DAF
_HUnlock ; unlock the control <C424/18Nov86> DAF
;
; set the pattern for indicator dragging
;
DragGray
MOVE.L (A5),A0 ; get qDraw globals
LEA Gray(A0),A0 ; point to gray pattern
MOVE.L (A0)+,DragPattern ; move in the 1st half
MOVE.L (A0),DragPattern+4 ; move in the 2nd half
RTS ; all done!
;
CalcSquare
MOVE.L D3,-(SP) ; push the region
PEA ContrlRect(A0) ; push the rectangle pointer
_RectRgn ; make a rectangular region
BRA.S DragGray ; all done -- go set drag pattern
;
; PlotCheck takes care of drawing the actual check box of the check box button. It
; figures out where to draw the box, draws it, and then checks it or not based on
; the current value and hilite state of the button
;
PlotCheck
; first set the window content color <C59/30Jun86> DAF
TST.B IsColor(A6) ; are we on a color system?
BEQ.S @NoColor8 ; if on B&W, then skip
PEA ContentRGB(A6)
_RGBBackColor ;
@NoColor8 ; END OF A COLOR-ONLY SECTION
move.l (a3), a0 ; get control pointer <14>
lea contrlRect(a0), a4 ; point to the control rect <14>
SUBQ #8,SP ; allocate a rectangle on the stack
MOVE.W bottom(A4),D0 ; get rect height <EHB 20-May-85>
MOVE.W D0,D1 ; save a copy <EHB 20-May-85>
SUB.W top(A4),D0 ; get height <EHB 20-May-85>
SUB.W #12,D0 ; sub box height <EHB 20-May-85>
ASR.W #1,D0 ; div by 2 <EHB 20-May-85>
SUB.W D0,D1 ; get offset from bottom <EHB 20-May-85>
MOVE D1,Bottom(SP) ; set up the bottom <EHB 20-May-85>
SUB #12,D1 ; compute the top <EHB 20-May-85>
MOVE D1,Top(SP) ; set up the top <EHB 20-May-85>
tst.w teSysJust ; right to left? <MED 27-Aug-86>
beq.s LeftBoxTitle ; no, normal case <MED 27-Aug-86>
RightBoxTitle
MOVE Right(A4),D1 ; get left edge of boundsRect <MED 27-Aug-86>
subq #2,D1 ; indent 2 pixels <MED 27-Aug-86>
MOVE D1,Right(SP) ; thatÕs the left of the checkRect <MED 27-Aug-86>
sub #12,D1 ; compute right edge <MED 27-Aug-86>
MOVE D1,Left(SP) ; update the right edge <MED 27-Aug-86>
bra.s EraseCheck ; continue <MED 27-Aug-86>
LeftBoxTitle
MOVE Left(A4),D1 ; get left edge of boundsRect <EHB 20-May-85>
ADDQ #2,D1 ; indent 2 pixels <EHB 20-May-85>
MOVE D1,Left(SP) ; thatÕs the left of the checkRect <EHB 20-May-85>
ADD #12,D1 ; compute right edge <EHB 20-May-85>
MOVE D1,Right(SP) ; update the right edge <EHB 20-May-85>
EraseCheck
;
; erase the check box
;
MOVE.L SP,-(SP) ; push rectangle pointer
_EraseRect ; erase it
;
; OK, now we must fill in the checkBox rectangle based on the value and hilite state
; of the control
;
MOVE.L (A3),A0 ; get control pointer <14>
MOVE.W ContrlValue(A0),D5 ; get the value
MOVE.B ContrlHilite(A0),D0 ; is it hilited?
BEQ.S FrameCheck ; if not, skip
;
; its hilited so up the penSize to indicate its hilited
;
CMP.B #$FE,D0 ; disabled?
BLO.S SkipDis ; if so, skip doubling
;
TST.B useGrayText(A6) ; did we use GrayText?
BNE.S FrameCheck ; yes => skip DisableText since GrayText represents disabled state
BSR DisableText
BRA.S FrameCheck
SkipDis
MOVE.L #$00020002,-(SP)
_PenSize ; up the penSize
FrameCheck
MOVE.L SP,-(SP) ; push the rectangle
CMP.B #2,D6 ; test for radio button
BEQ.S @1 ; if its a radio button, go do it
_FrameRect ; frame it
BRA.S @2
@1
_FrameOval
@2
_PenNormal
;
; now we can draw the check if weÕre supposed to
;
LSR #1,D5 ; check out the low bit of D5
BCC.S DonePCheck ; if its off, weÕre done
;
CMP.W #2,D6 ; test for radio button
BEQ.S DrawRButton ; if its a radio button, go do it
;
MOVE.L SP,-(SP) ; push the rectangle pointer
MOVE.L OneOne,-(SP) ; push the inset factor
_InsetRect ; inset the rectangle
MOVE.L TopLeft(SP),-(SP) ; push top left
_MoveTo ; move to it
MOVE.L BotRight(SP),-(SP) ; push bottom right
_LineTo ; draw one line of the cross
;
MOVE Right(SP),-(SP) ; push right
MOVE Top+2(SP),-(SP) ; push top
SUBQ #1,(SP) ; bias the top
_MoveTo ; move to it
MOVE Left(SP),-(SP) ; push left
SUBQ #1,(SP) ; bias the left
MOVE Bottom+2(SP),-(SP) ; push bottom
_LineTo ; draw the line
BRA.S DonePCheck
;
; draw the radio button check mark -- a little circle
;
DrawRButton
MOVE.L SP,-(SP) ; push pointer to rect
MOVE.L #$00030003,-(SP) ; push inset factor
_InsetRect ; inset it
MOVE.L SP,-(SP) ; push rect again
_PaintOval ; draw the circle?
;
DonePCheck
ADDQ #8,SP ; pop off the rectangle
BRA DoneDrwBut ; all done!
END
File diff suppressed because it is too large Load Diff
+54
View File
@@ -0,0 +1,54 @@
#
# File: ControlMgr.make
#
# Contains: Makefile for the Control Manager.
#
# Written by: Kurt Clark, Chas Spillar, and Tim Nichols
#
# Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
#
# Change History (most recent first):
#
# <SM2> 12/2/92 kc Added " || Exit 1" to commands with a double dependency.
ControlMgrObjs = "{ObjDir}ControlMgr.a.o" ¶
"{ObjDir}ControlMgrExtensions.a.o"
"{RsrcDir}ControlMgr.rsrc" ÄÄ "{ObjDir}ButtonCDEF.a.o"
Link {StdLOpts} {StdAlign} -rt CDEF=0 -o "{Targ}" "{ObjDir}ButtonCDEF.a.o" || Exit 1
"{RsrcDir}ControlMgr.rsrc" ÄÄ "{ObjDir}ScrollBarCDEF.a.o"
Link {StdLOpts} {StdAlign} -rt CDEF=1 -o "{Targ}" "{ObjDir}ScrollBarCDEF.a.o" || Exit 1
"{LibDir}ControlMgr.lib" Ä {ControlMgrObjs}
Lib {StdLibOpts} -o "{Targ}" {ControlMgrObjs}
"{ObjDir}ControlMgr.a.o" Ä "{ObjDir}StandardEqu.d" ¶
"{IntAIncludes}LinkedPatchMacros.a" ¶
"{IntAIncludes}ControlPriv.a" ¶
"{ControlMgrDir}ControlMgr.a"
Asm {StdAOpts} -o "{Targ}" "{ControlMgrDir}ControlMgr.a"
"{ObjDir}ControlMgrExtensions.a.o" Ä "{ObjDir}StandardEqu.d" ¶
"{IntAIncludes}LinkedPatchMacros.a" ¶
"{IntAIncludes}ControlPriv.a" ¶
"{ControlMgrDir}ControlMgrExtensions.a"
Asm {StdAOpts} -o "{Targ}" "{ControlMgrDir}ControlMgrExtensions.a"
"{ObjDir}ScrollBarCDEF.a.o" Ä "{ObjDir}StandardEqu.d" ¶
"{IntAIncludes}ColorEqu.a" ¶
"{ControlMgrDir}ScrollBarCDEF.a"
Asm {StdAOpts} -o "{Targ}" "{ControlMgrDir}ScrollBarCDEF.a"
"{ObjDir}ButtonCDEF.a.o" Ä "{ObjDir}StandardEqu.d" ¶
"{IntAIncludes}ColorEqu.a" ¶
"{ControlMgrDir}ButtonCDEF.a"
Asm {StdAOpts} -o "{Targ}" "{ControlMgrDir}ButtonCDEF.a"
+146
View File
@@ -0,0 +1,146 @@
;
; File: ControlMgrExtensions.a
;
; Contains: Extensions to the Control Manager used by both the ROM and System.
;
; Written by: Ed Tecot and Jeff Miller
;
; Copyright: © 1989-1990, 1992-1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM2> 5/18/93 RC perfomance/bug fix (speed up scrolling with Truth changes to
; ScrollDelay)
; <2> 6/30/92 JSM Move scroll speed throttling code here from ScrollSpeedFix.a,
; add install proc for the future and ROM builds to set up
; ExpandMem.
; <1> 6/30/92 JSM first checked in
;
LOAD 'StandardEqu.d'
INCLUDE 'LinkedPatchMacros.a'
INCLUDE 'ControlPriv.a'
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; Implement humane scrolling speeds on Òwicked fastÓ machines.
IF forROM OR TheFuture THEN ; donÕt put data in code space in ROMs or in the future
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; InitScrollSpeedGlobals Ñ allocate and initialize globals stored in emScrollSpeedGlobals
;
; Called by StartBoot.a for the ROM, or by a MakeInstall macro in ControlMgrPatches.a for the System.
;
InitScrollSpeedGlobals Proc Export
with ScrollSpeedGlobals
; allocate mem & get ptr to it
move.l #ScrollSpeedGlobalsSize,D0 ; D0 = size of RAM we need
_NewPtr SYS,CLEAR ; Get RAM for variables
; set ptr in ExpandMemRec.emScrollSpeedGlobals
move.l ExpandMem,A1 ; A1 -> ExpandedMem
move.l A0,ExpandMemRec.emScrollSpeedGlobals(A1) ; store vars Pointer in ExpandMem
endwith
rts
endproc
ENDIF
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; UserDelay is a dispatcher style trap which accepts a selector in D0 and
; some parameters on the stack and returns an OSErr.
; Currently only selector 0 (ScrollDelay) is defined.
__UserDelay Dispatcher _UserDelay,(Plus,SE,II,Portable,IIci), \
(\
ScrollDelay, \
)
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; FUNCTION ScrollDelay(startTicks, actionTicks: LONGINT; itemsVisible: INTEGER): OSErr
; startTicks is the time the scrolling started, usually from the mouse down event.
; actionTicks is the time that began this particular scroll action.
; itemsVisible is the number of items visible in the list, 0 if unknown.
ScrollDelay PROC EXPORT
sdFrame RECORD 0
returnAddress DS.L 1
itemsVisible DS.W 1
actionTicks DS.L 1
startTicks DS.L 1
result DS.W 1
ENDR
FirstValue EQU 12 ; Number of ticks to begin with.
KnownEndValue EQU 3 ; Number of ticks to end with, when the list size is known.
UnknownEndValue EQU 0 ; Number of ticks to end with, when the list size is unknown.
DecayValue EQU 48 ; Time to decay from StartValue to EndValue.
KnownConst EQU DecayValue / (FirstValue - KnownEndValue)
UnknownConst EQU DecayValue / (FirstValue - UnknownEndValue)
; Calculate the time to wait until. EndValue is the number of ticks to end with: KnownEndValue
; if the list size is known, UnknownEndValue if unknown. The equation is:
; DecayValue
; Delay = actionTicks + EndValue + --------------------------------------------------------
; DecayValue
; (actionTicks - startTicks) + -------------------------
; FirstValue - EndValue
WITH sdFrame
CLR.W result(SP) ; No error.
; Commented out 5/18/93 RPC so that EndValue is always 0 for both ListMgr and non-ListMgr alike.
; TST.W itemsVisible(SP) ; Know the number of items visible?
; BEQ.S @unknown ; No, skip this part.
; MOVEQ.L #KnownEndValue, D0 ; EndValue = KnownEndValue
; MOVEQ.L #KnownConst, D1 ; For speed
; BRA.S @calcDelay
;@unknown
MOVEQ.L #UnknownEndValue, D0 ; EndValue = UnknownEndValue
MOVEQ.L #UnknownConst, D1 ; For speed
@calcDelay
MOVE.L actionTicks(SP), D2
ADD.L D2, D0 ; D0 = actionTicks + EndValue
ADD.L D2, D1 ; DecayValue
SUB.L startTicks(SP), D1 ; D1 = (actionTicks - startTicks) + ---------------------
; FirstValue - EndValue
MOVEQ.L #DecayValue, D2
DIVU D1, D2
EXT.L D2 ; Toss the remainder (assume quotient < 32767)
ADD.L D2, D0 ; Now everything's in D0
; We need to loop until D0 <= TickCount() or the mouse button comes up.
MOVE.L D0, -(SP) ; Save the time on the stack.
@loopDelay
SUBQ.L #4, SP
_TickCount
MOVE.L (SP)+, D0
CMP.L (SP), D0 ; Timed out?
BHS.S @endDelay ; Yes, Get Out.
SUBQ.L #2, SP
_StillDown ; Mouse still down?
TST.B (SP)+
BNE.S @loopDelay ; Yes, Try Again.
@endDelay
MOVE.L returnAddress+4(SP), startTicks+4(SP)
LEA startTicks+4(SP), SP ; Clean up the stack frame.
RTS
ENDWITH
ENDPROC
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
end
+381
View File
@@ -0,0 +1,381 @@
;
; File: ControlMgrPatches.a
;
; Contains: linked patches to the Control Mgr.
;
; Copyright: © 1989-1990, 1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <9> 7/1/92 JSM Fix bug in one of the changes I made for TheFuture in the last
; revision, add comments about IIci patches that have been rolled
; into ControlMgr.a: FixNewControl32Bit,
; PatchDisposeControlForInvisibleControlsIIci,
; PatchDisposeControlForCorrectLayer, CheckMemErrInSetCTitle, and
; ThrottleScrollingSpeed.
; <8> 6/30/92 JSM Move patch on _TrackControl for scroll speed throttling here
; from ScrollSpeedFix.a, add a MakeInstall for TheFuture to
; allocate globals in ExpandMem for this patch.
; <7> 4/22/92 pvh Fix bug so that the right layer is switched in when we're
; disposing of a control (_DisposeControl patch). Added new patch
; to swap in the correct layer before calling real
; _DisposeControl.
; <6> 1/18/91 VL <jsm> DrawThumbOutline should check whether it is coming from
; DragControl also. Otherwise, we may be accessing bogus
; ControlRecord.
; <5> 1/13/91 VL <dba> Added a patch to FrameRect to draw a solid outline when
; dragging the thumb in 7.0 scroll bar (CDEF 1).
; <4> 11/8/90 dba & gbm; move patch that does a system error if we canÕt load a
; CDEF here from PTCH files; move patch that disables Plus check
; for control visible (for MacExpress) here from PatchPlusROM
; <3> 10/24/90 KSM <dba>Fix SetCTitle to check if SetHandleSize failed.
; <2> 10/8/90 dba move the NewControl/contrlOwner bug fix here from
; WindowMgrPatches.a
; <1> 9/23/90 dba Created today with two patches; NewControl heap scramble bug in
; 32-bit mode, DisposeControl erasing invisible controls.
;
load 'StandardEqu.d'
include 'LinkedPatchMacros.a'
include 'LayerEqu.a'
include 'ControlPriv.a'
; NOTE: patches to SetCtlColor and GetAuxCtl are found in WindowMgrPatches.a
EraseControlInDisposeControl ROMBind (Plus,$12E9C),(SE,$D4A0),(II,$11DC4),(Portable,$1270E),(IIci,$15F00)
AfterEraseControlInDisposeControl ROMBind (Plus,$12E9E),(SE,$D4A2),(II,$11DC6),(Portable,$12710),(IIci,$15F02)
AfterSetCtlColorInNewControl ROMBind (II,$11C6A),(IIci,$15D84)
AfterSetHandleSizeInSetCTitle ROMBind (Plus,$13002),(SE,$D606),(II,$11F44),(IIci,$160C0),(Portable,$12874)
GoTstVisInSetCTitle ROMBind (Plus,$13010),(SE,$D614),(II,$11F52),(IIci,$160CE),(Portable,$12882)
AfterLoadResourceInCallControl ROMBind (Plus,$12E58),(SE,$0D45C),(II,$11D46)
AfterSectRectInCallControl ROMBind (Plus,$12E1E)
AfterFrameRectInFastPaint ROMBind (II,$105B4),(IIci,$19492)
GetCVariantInCallControl ROMBind (II,$11D2E),(IIci,$15E48)
OwnerPortInROM ROMBind (II,$12084),(IIci,$16218)
AfterDragTheRgnInDragControl ROMBind (II,$12044),(IIci,$161D8)
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; NewControl Ñ also, SetCtlColor needs contrlOwner, so we need to set it up before calling
; fix bug where we have a dereferenced handle across SetCtlColor in 32-bit mode
;
; This patch has been rolled into ControlMgr.a.
;
FixNewControl32Bit ComeFromPatchProc _SetCtlColor,AfterSetCtlColorInNewControl,(II,IIci)
addq #4,sp ; get rid of the return address
move.l 30(a6),contrlOwner(a2) ; copy the owner into the field
jsrOld ; call SetCtlColor
move.l (a3),a2 ; re-dereference the control handle
jmpROM AfterSetCtlColorInNewControl
EndProc
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; DisposeControl Ñ fix bug where we erase controls even if they are invisible
PatchDisposeControlForInvisibleControls PatchProc _DisposeControl,(Plus,SE,II,Portable)
; Here we check to see if the control is invisible, and rejoin the ROM just before the routine that
; does the erasing, if the control is visible, or just after if it is invisible.
MOVE.L A3,-(SP) ;preserve a work register
MOVE.L 8(SP),A3 ;get the control handle
move.l (a3),a0
tst.b contrlVis(A0) ;is the control visible?
beqROM AfterEraseControlInDisposeControl ; no, skip erasing
jmpROM EraseControlInDisposeControl ; yes, go erase
EndProc
PatchDisposeControlForInvisibleControlsIIci PatchProc _DisposeControl,(IIci)
; The IIci version of the control manager saves two registers instead of one.
;
; This patch has been rolled into ControlMgr.a.
;
MOVEM.L A2/A3,-(SP) ;preserve work registers
MOVE.L 12(SP),A3 ;get the control handle
move.l (a3),a0
tst.b contrlVis(A0) ;is the control visible?
beqROM AfterEraseControlInDisposeControl ; no, skip erasing
jmpROM EraseControlInDisposeControl ; yes, go erase
EndProc
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; DisposeControl Ñ fix bug so that the current layer is switched in when disposing the control <7>
;
; This patch has been rolled into ControlMgr.a.
;
PatchDisposeControlForCorrectLayer PatchProc _DisposeControl,(Plus,SE,II,IIci,Portable) ; <7>
move.l 4(sp), d0 ; get the control handle <7>
move.l d0, a0
beq.s @failNil ; in case it's bogus <7>
move.l (a0), a0 ; get pointer <7>
subq.l #4, sp ; room for result <7>
subq.l #4, sp ; room for result for _SwapCurLayer <7>
move.l contrlOwner(a0), -(sp) ; setup for _GetParent <7>
_GetParent
_SwapCurLayer ; swap for parent, leaves original layer on stack <7>
move.l 8(sp), -(sp) ; repush control handle for old routine <7>
jsrOld ; call old <7>
_SetCurLayer ; original should be on stack waiting for us <7>
@failNil move.l (sp), a0 ; get return address <7>
addq.l #8, sp ; remove address and control handle <7>
jmp (a0) ; return from whence we came <7>
EndProc ; <7>
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; SetCTitle Ñ Check MemError after SetHandleSize before BlockMoving new data
;
; This patch has been rolled into ControlMgr.a.
;
CheckMemErrInSetCTitle ComeFromPatchProc _SetHandleSize,AfterSetHandleSizeInSetCTitle,(Plus,SE,II,IIci,Portable)
LEA AfterOSDispatcher, A1 ; after doing the SetHandleSize, come back here
MOVE.L A1, ReturnAddressDepth(sp) ; jam in that return address
jmpOld ; go do the SetHandleSize
AfterOSDispatcher
beqROM AfterSetHandleSizeInSetCTitle
ADDQ.W #4, SP ; Pull the size off the stack
jmpROM GoTstVisInSetCTitle ; And skip over BlockMove call
EndProc
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; LoadResource Ñ do a system error if we try to load a CDEF resource and fail
SysErrorIfNoCDEF ComeFromPatchProc _LoadResource,AfterLoadResourceInCallControl,(Plus,SE,II)
addq #4,sp ; get rid of the return address
jsrOld ; call LoadResource
tst.l (a0) ; is the handle we just tried to load still empty?
bnzROM AfterLoadResourceInCallControl ; no, go back to the ROM
moveq #dsCDEFNotFound,D0 ; get error code
_SysError
EndProc
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; drawing controls Ñ always draw controls, even if there rectangles are outside the portRect
; The control manager on the Plus only drew controls whose rects lay within the portRect.
; Unfortunately MacExpress does some strange mapping of coordinates into its split
; view windows at the QuickDraw level (that is, after we have decided not to draw it).
; This patch ignores the SectRect completely and returns that it should always be drawn.
DontCheckControlRects ComeFromPatchProc _SectRect,AfterSectRectInCallControl,(Plus)
move.l (sp)+,a0 ; get return address
lea 12(sp),sp ; strip parameters
st (sp) ; return true
jmp (a0) ; and return to caller
EndProc
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; FrameRect in FastPaint
DrawThumbOutline ComeFromPatchProc _FrameRect,AfterFrameRectInFastPaint,(II,IIci)
tst.w DragFlag ; are we drawing the thumb outline?
beqOld ; no => do the old stuff
cmpROM AfterDragTheRgnInDragControl,4(a6) ; do we come from DragControl?
bneOld ; no => do the old stuff
move.l -48(a6),a0 ; get the control record
move.l (a0),a0 ; get the ptr to control record
move.l contrlDefHandle(a0),a0 ; get the CDEF handle
move.l (a0),a0 ; get the ptr to CDEF
cmp.l #'CDEF',4(a0) ; Is this a CDEF?
bneOld ; No => FrameRect
btst #0,3(a0) ; Can CDEF handle this message?
beqOld ; No => FrameRect
move.l a3,-(sp) ; save off a3
move.l -48(a6),a3 ; put the control record in a3 since ROM routines need it
pea comeBackHere ; push an artificial return address
jsrROM OwnerPortInROM ; get the old port
clr.l -(sp) ; result code
clr.w -(sp) ; varCode
move.l a3,-(sp) ; control handle
move.w #drawThumbOutlineMsg,-(sp) ; message
move.l 28(sp),-(sp) ; put rect into parameter
subq.l #2,sp ; room for results
move.l a3,-(sp) ; control handle
jmpROM GetCVariantInCallControl ; borrow CallControl from ROM to save code
comeBackHere
move.l (sp)+,a3 ; restore a3
tst.l d0 ; did CDEF handle the drawing?
beqOld ; No => FrameRect
move.l (sp)+,(sp) ; back from CallControl
rts ; return to DragControl
EndProc
IF TheFuture THEN ; donÕt put data in code space in the future
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; InitScrollSpeedGlobals - defined in ControlMgrExtensions.a
;
; allocate and initialize globals stored in emScrollSpeedGlobals
;
import InitScrollSpeedGlobals
MakeInstall InitScrollSpeedGlobals,(Plus,SE,II,Portable,IIci)
ENDIF ; TheFuture
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
; ThrottleScrollingSpeed - formerly in ScrollSpeedFix.a
;
; We patch TrackControl to substitute in our "special" action proc. In order to
; communicate the old action proc, we need to store it in a PC relative place.
; This makes TrackControl non-reentrant, but I don't think it ever was expected to be.
;
; This patch has been rolled into ControlMgr.a.
;
ThrottleScrollingSpeed PatchProc _TrackControl,(Plus,SE,II,Portable,IIci)
tcFrame RECORD 0
returnAddress DS.L 1
actionProc DS.L 1
startPoint DS.L 1
theControl DS.L 1
result DS.W 1
ENDR
WITH tcFrame
MOVE.L actionProc(SP), D0 ; Get the actionProc.
BEQ.S @noAction ; Skip patch if none.
BTST #0, D0 ; Is it odd?
BNE.S @noAction ; Skip patch if so.
IF TheFuture THEN
move.l ExpandMem,a0
move.l ExpandMemRec.emScrollSpeedGlobals(a0),a0
MOVE.L D0,ScrollSpeedGlobals.saveAction(A0) ; Save the old actionProc.
ELSE
LEA saveAction, A0
MOVE.L D0, (A0) ; Save the old actionProc.
ENDIF
LEA ScrollAction, A0
MOVE.L A0, actionProc(SP) ; And replace it with mine.
SUBQ.L #4, SP
_TickCount ; Get a time stamp.
IF TheFuture THEN
move.l ExpandMem,a0
move.l ExpandMemRec.emScrollSpeedGlobals(a0),a0
MOVE.L (SP)+,ScrollSpeedGlobals.startTicks(A0) ; And save it.
ELSE
LEA startTicks, A0
MOVE.L (SP)+, (A0) ; And save it.
ENDIF
@noAction
jmpOld ; Return to old _TrackControl
ENDWITH
IF NOT TheFuture THEN ; donÕt put data in code space in the future
saveAction DS.L 1
startTicks DS.L 1
actionTicks DS.L 1
saveReturn DS.L 1 ; must follow actionTicks
ENDIF ; NOT TheFuture
ScrollAction
saFrame RECORD 0
returnAddress DS.L 1
partCode DS.W 1
theControl DS.L 1
ENDR
WITH saFrame
MOVE.W partCode(SP), D0 ; Get the part code
CMP.W #inUpButton, D0 ; < up button?
BLT.S @callAction ; Skip if so.
CMP.W #inPageDown, D0 ; > page down?
BGT.S @callAction ; Skip if so.
SUBQ.L #4, SP
_TickCount ; Get a time stamp.
IF TheFuture THEN
move.l ExpandMem,a0
move.l ExpandMemRec.emScrollSpeedGlobals(a0),a0
MOVE.L (SP)+,ScrollSpeedGlobals.actionTicks(A0) ; Save it
MOVE.L (SP)+,ScrollSpeedGlobals.saveReturn(A0) ; Copy the return address into a safe place.
ELSE
LEA actionTicks, A0
MOVE.L (SP)+, (A0)+ ; Save it and have A0 point to saveReturn
MOVE.L (SP)+, (A0) ; Copy the return address into a safe place.
ENDIF
BSR.S @callAction ; Call the old action procedure.
ENDWITH
SUBQ.L #2, SP ; Room for result.
IF TheFuture THEN
move.l ExpandMem,a0
move.l ExpandMemRec.emScrollSpeedGlobals(a0),a0
MOVE.L ScrollSpeedGlobals.startTicks(a0), -(SP)
MOVE.L ScrollSpeedGlobals.actionTicks(a0), -(SP)
ELSE
MOVE.L startTicks(PC), -(SP)
MOVE.L actionTicks(PC), -(SP)
ENDIF
CLR.W -(SP) ; itemsVisible is unknown.
_ScrollDelay
ADDQ.L #2, SP ; Toss result.
IF TheFuture THEN
move.l ExpandMem,a0
move.l ExpandMemRec.emScrollSpeedGlobals(a0),a0
move.l ScrollSpeedGlobals.saveReturn(a0),a0
ELSE
MOVE.L saveReturn(PC), A0
ENDIF
JMP (A0) ; And return.
@callAction
IF TheFuture THEN
move.l ExpandMem,a0
move.l ExpandMemRec.emScrollSpeedGlobals(a0),a0
move.l ScrollSpeedGlobals.saveAction(a0),a0
ELSE
MOVE.L saveAction(PC), A0
ENDIF
JMP (A0) ; Just call the action proc normally.
ENDPROC
;ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
End
+675
View File
@@ -0,0 +1,675 @@
;
; File: PictButtonCDEF.a
;
; Contains: This file contains the control definition procedure (CDEF) for the
; "Pict Button control". It is like the standard button control, except
; it draws a picture instead of text for the contents of the button.
;
; Written by: Nick Kledzik
;
; Copyright: © 1982-1990 by Apple Computer, Inc., all rights reserved.
;
; This file is used in these builds: BigBang
;
; Change History (most recent first):
;
; <2> 11/8/90 ngk <VL> Changed dimmed state to draw in true gray unless version of
; picb is 2.
; <1> 6/18/90 ngk first checked in
; <0+> 6/16/90 ngk Submitted for the first time.
;
;
; The parameters for the button are read from a 'picb' resource. It
; currently contains the PICT resource ID of the picture to draw and
; the offset from the top left corner of the control rect to begin
; drawing the picture. The picture is never scaled. It is clipped
; to fit inside the control rect.
;
; Before drawing the picture, the foreground and background colors are
; set up based on the hilite state of the control. Your PICT should
; have the opcodes which change the fore or back-ground colors last. This
; way in the "inverted state", the beginning items will draw with fore-
; and back-ground colors swapped and hard colored items will remain the same.
; This disabled state is drawn using gray (average of fore- and back-ground
; color) if version = 1 and color machine with color graphport and enough
; depth, otherwise the picture is drawn and then 50% gray is BICed over it.
; (Forcing dithering to disable might be desired for a solid colored pict.
; For instance, a red record button would look more disabled if it had
; half its pixels off, as opposed to a dimmed red.)
;
; type 'picb' {
; integer = 1; /* version */
; integer; /* PICT resource ID */
; integer; /* delta v */
; integer; /* delta h */
; fill long; /* space for handle */
; };
;
; resource 'picb' (200) {
; 300, /* PICT resource ID */
; 0, /* dv */
; 0 /* dh */
; };
;
; To Do:
;
PRINT PUSH,OFF
LOAD 'StandardEqu.d'
INCLUDE 'ColorEqu.a'
PRINT POP
;----------------------------------------------------------------------------------------------------
CDEF2 PROC EXPORT
; FUNCTION PushButProc( selector: INTEGER;
; theControl: ControlHandle;
; message: INTEGER;
; param: LongInt): LongInt;
;
; stack frame definition
StackFrame RECORD {A6Link},DECR
result DS.L 1 ; LongInt
paramSize EQU *-8 ; prameters to remove on return
; parameters
selector DS.W 1 ; INTEGER
theControl DS.L 1 ; ControlHandle
message DS.W 1 ; INTEGER
param DS.L 1 ; LongInt
ReturnAddr DS.L 1
A6Link DS.L 1
; locals variables
ALIGN
isDimmed DS.B 1 ; Boolean
isInverted DS.B 1 ; Boolean
theControlRect DS.W 4 ; Rect
tempRect DS.W 4 ; Rect
savedPen DS.B psRec
savedFgColor DS.B rgbColor
savedBkColor DS.B rgbColor
frameColor DS.B rgbColor
bodyColor DS.B rgbColor
textColor DS.B rgbColor
theQDprocs DS.B cqdProcsRec
oldQDprocsPtr DS.L 1
oldCommentProc DS.L 1
savedClip DS.L 1
frameSize EQU * ; size of link
ENDR
picb RECORD 0
version DS.W 1 ; 1 => dim with true gray, 2=> dim by dithering
pictResID DS.W 1 ; resource ID of PICT to use
dv DS.W 1 ; vertical offset from topLeft of button to draw picture
dh DS.W 1 ; horizontial offset from topLeft of button to draw picture
pictHandle DS.L 1 ; handle to copy of PICT resource
ENDR
BRA.S @0 ; skip header
; standard header
DC.W 0 ; flags
DC.L ('CDEF')
DC.W 61 ; resource ID
DC.W 2 ; version #
@0
WITH StackFrame
LINK A6,#frameSize ; set up a stack frame to address parameters <C59/30Jun86> DAF
MOVEM.L D3-D7/A1-A4,-(SP) ; save work registers
;
; buttons only handle messages 0,1,2,3,4,10,11
;
MOVE.W selector(A6),D0
CMP.W #dispCtlMsg,D0 ; inspect message value <1.2>
BLS.S @MsgOK ; if < 4, itÕs OK <1.2>
CMP.W #calcWholeCtlMsg,D0 ; <1.2>
BEQ.S @MsgOK ; 10 is OK too <1.2>
CMP.W #calcThumbCtlMsg,D0 ; <1.2>
bne.s @done ; And 11 <1.2>
@MsgOK
;
; fetch the parameters into registers
;
LEA 8(A6),A0 ; get ptr to first parameter
MOVE.L (A0)+,D3 ; get param in D3
MOVE.W (A0)+,D0 ; get message
MOVE.L (A0)+,A3 ; get the control handle
MOVE.W (A0)+,D7 ; get selection index
CLR.L (A0) ; clear out function result
move.l (a3),a0 ; get control pointer in A0
tst.b contrlHilite(A0)
smi isDimmed(a6) ; set up whether it is dimmed
sgt isInverted(a6) ; set up whether it is inverted
move.l contrlRect(a0),theControlRect(a6) ; make local copy of rect
move.l contrlRect+4(a0),theControlRect+4(a6)
; Determine type of system. We need to know if we have color QuickDraw
; and a color window.
CMP.W #$3FFF,ROM85 ; do we have color QD?
SLS D6 ; set boolean depending on color or B&W system
bhi.s @haveD6
move.l contrlOwner(A0),a1 ; get window it is in
move.w portVersion(A1),d1 ;
and.w #$C000,d1 ; are we using a color grafport?
sne d6 ; if so set d6 to true
@haveD6
;
; case out on the message number
;
CMP.W #dispCtlMsg, D0 ; Does message need adjusting? <1.2>
BLS.S @loMsg ; DonÕt adjust if not. <1.2>
SUBQ.W #calcWholeCtlMsg-dispCtlMsg-1, D0 ; Adjust message for address calculation <1.2>
@loMsg
ADD D0,D0 ; double for word index
LEA GoPushBut,A1 ; get table address
ADD 0(A1,D0),A1 ; compute dispatch address
JSR (A1) ; dispatch to appropriate routine
;
; weÕre done -- restore registers and return to caller
;
@done
MOVEM.L (SP)+,D3-D7/A1-A4 ; restore work registers
UNLK A6 ; unlink stack frame
MOVE.L (SP)+,A0 ; get return address
ADD #paramSize,SP ; strip parameters
JMP (A0) ; return to caller
;
; PushButProc dispatch table -- entries must be long branches!
;
GoPushBut
DC.W DrawPBut-GoPushBut ; draw is message 0
DC.W HitPBut-GoPushBut ; hit test is message 1
DC.W CalcPBut-GoPushBut ; calc regions is message 2
DC.W InitBut-GoPushBut ; new button is message 3
DC.W DispBut-GoPushBut ; dispose button is message 4
DC.W CalcWholePBut-GoPushBut ; calc whole regions is message 10 <1.2>
DC.W CalcThumbPBut-GoPushBut ; calc thumb regions is message 11 <1.2>
MyComment DC.B $00 ; nop / pad
DC.B $A1 ; longComment
DC.W $0000 ; kind
DC.W 8 ; size of following data
DC.L ('nick') ; my marker
MyA6Offset EQU *-MyComment ; offset to place to store A6
DC.L $0 ; A6 will go here
MyCommentLen EQU *-MyComment ; size of the comment inserted
;
;
;
InitBut move.l theControl(A6),A3 ; get the control handle
move.l (A3),A0 ; get control pointer
subq #4,sp ; room for result
move.l #'picb',-(sp)
move.w ContrlRfCon+2(A0),-(sp) ; low word of refcon is 'picb' res ID
_GetResource
move.l (sp)+,a0 ; duplicate picb, cause we will be modifying it
_HandToHand
move.l a0,a2
move.l (a3),a0 ; get control pointer
move.l a2,contrlData(A0) ; set handle to copied 'picb'
beq.s @done ; if no handle then skip out
subq #4,sp ; room for result
move.l #'PICT',-(sp)
move.l (a2),a0 ; get control pointer
move.w picb.pictResID(a0),-(sp) ; get res ID of PICT to load
_GetResource
move.l (sp)+,a0 ; duplicate picture, cause we will munge it
_HandToHand
move.l (A2),A1 ; get picb pointer
move.l a0,picb.pictHandle(A1) ; set handle to copied PICT
beq.s @done
subq #4,sp ; result
move.l a0,-(sp) ; handle to munge
moveq #10,d0
move.l d0,-(sp) ; offset
moveq #0,d0
move.l d0,-(sp) ; ptr1
move.l d0,-(sp) ; len1
pea MyComment ; ptr2
moveq #MyCommentLen,d0
move.l d0,-(sp) ; len2
_Munger
addq #4,sp
@done rts
;
;
;
DispBut move.l theControl(A6),A0 ; get the control handle
move.l (A0),A0
move.l ContrlData(A0),d0 ; get handle to 'picb'
beq.s @done
move.l d0,a2
move.l (a2),a0
move.l picb.pictHandle(a0),a0 ; get handle to copied 'PICT'
_DisposeHandle ; dump 'picb'
move.l a2,a0
_DisposeHandle ; dump 'PICT'
@done rts
;
; saves off StdComment for current port and installs MyCommentProc
; only called on Color QD systems
InstallMyCommentHandler
move.l grafGlobals(A5),A2 ; get GrafGlobals base
move.l thePort(A2),A2 ; get current port
move.l grafProcs(a2),d0
move.l d0,oldQDprocsPtr(a6) ; save off current StdProcs
move.l d0,a0
bne.s @hasProcs ; if currently not NIL then use it
pea theQDprocs(a6)
_SetStdCProcs ; else allocate my own procs record
lea theQDprocs(a6),a0
move.l a0,grafProcs(a2) ; stuff pointer to my own procs
@hasProcs move.l commentProc(a0),oldCommentProc(a6) ; save off current comment handler
lea MyCommentProc,a1
move.l a1,commentProc(a0) ; override comment handle to be me
rts
;
; Restores old StdComment
;
RemoveMyCommentHandler
move.l grafGlobals(A5),A2 ; get GrafGlobals base
move.l thePort(A2),A2 ; get current port
move.l oldQDprocsPtr(a6),d0
move.l d0,grafProcs(a2) ; restore old StdProcs
beq.s @done ; if it was NIL then done
move.l d0,a0
move.l oldCommentProc(a6),commentProc(a0) ; else also restore old commentProc
@done rts
;
; PROCEDURE StdComment(kind,dataSize: INTEGER; dataHandle: Handle);
;
MyCommentProc
move.l 4(sp),d0 ; get dataHandle
beq.s @notMyComment ; NIL handle can't be my comment
move.l d0,a0
move.l (a0),a0
cmp.l #'nick',(a0)
bne.s @notMyComment
move.l a6,-(sp) ; save off a6
move.l 4(a0),a6 ; retrieve my a6
pea textColor(A6) ; set foreColor
_RGBForeColor
pea bodyColor(A6) ; set backColor
_RGBBackColor
move.l (sp)+,a6 ; restore QD's a6
bra.s @done
@notMyComment
; want to call old StdComment, but can't find it without a6
nop
@done move.l (sp)+,a0
add #8,sp
jmp (a0)
;
;
; in: d0.w = part identifier
; a0 = pointer to place to store found RGB color
; a1 = pointer to AuxCntlRec
;
; trashes a1,d1
GetColor
move.l a1,-(sp)
MOVE.W ctSize(A1),D1 ; get the color table size
ASL #3,D1 ; convert to color table index
@loop CMP.W ctTable+value(A1,D1),D0 ; is this the one?
BEQ.S @FoundIt ; if equal, then done
SUB.W #8,D1 ; try the previous one
BGE.S @loop ; loop while index positive
MOVEQ #0,D1 ; OK, use the first one
@FoundIt
lea ctTable+rgb(A1,D1),A1 ; get the address of the color to use
move.l (A1)+,(A0) ; copy RGB value
move.w (A1),4(a0)
move.l (sp)+,a1 ; restore a1
rts
;
; DrawPBut draws the pushButton
;
DrawPBut
tst.b contrlVis(A0) ; is it visible?
beq @done ; if not, weÕre done
;
; save the penState and set it our way
;
pea savedPen(A6) ; push pointer to savedPenState
_GetPenState ; remember current penState
_PenNormal ; set the pen the way we want it
tst.b d6
beq @noColor ; no, this system has B&W QD
; save the current portÕs colors
PEA savedFgColor(A6) ; save foreColor
_GetForeColor ;
PEA savedBkColor(A6) ; save backColor too
_GetBackColor ;
;
; get the CtlAuxRec for this guy and lock its colortable <C59/30Jun86> DAF
;
CLR.L -(SP) ; return the handle here
CLR.B -(SP) ; space for boolean func return
MOVE.L theControl(A6),-(SP) ; push the control handle
PEA 6(SP) ; push a pointer to placeholder
_GetAuxCtl ; get its auxRec
ADDQ #2,SP ; donÕt need boolean result
MOVE.L (SP)+,A0 ; get auxCtl handle
MOVE.L (A0),A0 ; a pointer to the auxCtlRec
MOVE.L acCTable(A0),A0 ; get colortableÕs handle
move.l (A0),a1 ; set up a1 to point to auxCntrlRec
moveq #cFrameColor,d0 ; get frame color for this control
lea frameColor(a6),a0
bsr.s GetColor
moveq #cBodyColor,d0 ; assume body color is cBodyColor
moveq #cTextColor,d2 ; assume text color is cTextColor
tst.b isInverted(a6)
beq.s @1
exg d0,d2 ; oops, it is inverted so swap
@1 lea bodyColor(a6),a0
bsr.s GetColor
move.w d2,d0
lea textColor(a6),a0
bsr.s GetColor
tst.b isDimmed(a6)
beq.s @noColor
move.l (a3),a0 ; get control pointer in A0
move.l contrlData(a0),a0 ; get picb handle
move.l (a0),a0 ; get picb ptr
cmp.w #2,picb.version(a0) ; what version of picb is it
beq.s @noColor ; version 2 => dim button by dithering
move.l theControlRect+botRight(a6),-(sp) ; create a temp rect
move.l theControlRect+topLeft(a6),-(sp) ; that is a copy of boundary
pea (sp)
_LocalToGlobal ; change topleft to global coordinates
pea 4(sp)
_LocalToGlobal ; change botright to global coordinates
subq #4,sp ; GDevice from GetMaxDevice
pea 4(sp)
_GetMaxDevice ; get device for it
move.l (sp)+,d0
; ### really want GetMinDevice. But GetMaxDevice works as long as the button
; is completely on one monitor. Currently, the only place that uses this
; CDEF is StandardFile, which is always on one monitor.
addq #8,sp ; deallocate temp rect
subq #2,sp ; room for boolean
move.l d0,-(sp) ; device handle
pea bodyColor(A6)
pea textColor(a6)
_GetGray ; change textColor to gray
tst.b (sp)+
beq.s @noColor ; if no true gray possible, then done
sf isDimmed(a6) ; else, forget that it is dimmed
@noColor
; save old clip region and clip to the bounding rectangle sected with oldClip
subq #4,sp ; make space for region handle
_NewRgn ; allocate a region
move.l (SP),A2 ; remember region but leave on stack
move.l a2,savedClip(a6) ; save off old clip
_GetClip ; remember the current clipRgn
pea theControlRect(A6) ; push pointer to its bounding rect
_ClipRect ; make that the clipping region
move.l grafGlobals(A5),A0 ; get GrafGlobals base
move.l thePort(A0),A0 ; get current port
move.l clipRgn(A0),-(SP) ; push the current clipRgn
move.l A2,-(SP) ; push the old ClipRgn
move.l clipRgn(A0),-(SP) ; the answer goes into current clip
_SectRgn ; intersect new and old
;
; calculate roundness as function of rectangle size
;
BSR RoundCalc ; compute roundNess factor in D4
;
; erase the background before drawing the picture
;
tst.b D6 ; are we on a color system?
beq.s @NoColor2 ; if on B&W, then skip
pea bodyColor(a6)
_RGBBackColor ; set it
@NoColor2
pea theControlRect(a6) ; push rect
move.l D4,-(SP) ; push rounding factor
_EraseRoundRect ; paint it the background color
;
; Draw the picture
;
move.l theControl(A6),A0 ; get the control handle
move.l (A0),A0
move.l contrlData(A0),d0 ; get handle to 'picb'
beq.s @doneDraw ; bail out if no 'picb'
move.l d0,a1
move.l (a1),a1
move.l picb.pictHandle(a1),d0 ; get handle to PICT
beq.s @doneDraw ; if NIL then don't draw
move.l d0,a0
move.l (a0),a0
move.l a6,10+MyA6Offset(a0) ; stuff my current a6 into pict comment
move.l d0,-(sp) ; pict handle parameter to DrawPicture
pea tempRect(a6) ; rect parameter to DrawPicture
; calculate bounding rect for drawPicture
move.l 2+botRight(a0),tempRect+botRight(a6); create a temp rect from picture bounds
move.l 2+topLeft(a0),tempRect+topLeft(a6)
move.w theControlRect+top(a6),d0 ; calc desired vertical movement
sub.w tempRect+top(a6),d0
add.w picb.dv(a1),d0
swap d0 ; put vertical in high word
move.w theControlRect+left(a6),d0 ; calc desired horizontal movement
sub.w tempRect+left(a6),d0
add.w picb.dh(a1),d0
pea tempRect(a6) ; VAR Rect
move.l d0,-(sp) ; dh, dv: INTEGER
_OffsetRect
tst.b D6 ; are we on a color system?
beq.s @NoColor4 ; if on B&W, then skip
bsr InstallMyCommentHandler
@NoColor4
_DrawPicture
tst.b D6 ; are we on a color system?
beq.s @NoColor5 ; if on B&W, then skip
bsr RemoveMyCommentHandler
@NoColor5
@doneDraw
;
; draw the frame around the button
;
tst.b D6 ; are we on a color system?
beq.s @NoColor9 ; if on B&W, then skip
pea frameColor(a6)
_RGBForeColor
@NoColor9
pea theControlRect(a6) ; push rect
move.l D4,-(SP) ; push rounding factor
_FrameRoundRect ; frame the button
;
; perform Hilite if necessary
;
tst.b isDimmed(a6)
beq.s @PotentialInvert
tst.b D6 ; are we on a color system?
beq.s @NoColor6 ; if on B&W, then skip
pea textColor(a6)
_RGBForeColor
pea bodyColor(a6)
_RGBBackColor
@NoColor6
move.l (A5),A0
pea Gray(A0)
_PenPat
move.w #patBIC,-(SP)
_PenMode
move.l theControlRect+botRight(a6),-(sp) ; create a temp rect
move.l theControlRect+topLeft(a6),-(sp)
pea (sp)
move.l #$00010001,-(sp)
_InsetRect ; that is inset by one
pea (sp) ; push inset rect
move.l D4,-(SP) ; push rounding factor
_PaintRoundRect ; gray it out
add #8,sp ; dispose of temp rect
_PenNormal
bra.s @DoneDrwBut ; and continue...
@PotentialInvert
tst.b isInverted(a6) ; only invert if needed
beq.s @DoneDrwBut
tst.b d6
bne.s @DoneDrwBut ; only invert on non-CQD systems
pea theControlRect(a6)
move.l D4,-(SP) ; push rounding factor
_InverRoundRect ; hilite by inverting
@DoneDrwBut
;
; restore original pen state
;
pea savedPen(A6) ; push savedPenState
_SetPenState ; restore original pen state
move.l savedClip(a6),a2 ; retreive orginal clip
move.l a2,-(sp) ; push old clip region
_SetClip ; restore it
move.l a2,-(sp) ; dispose of temporary region
_DisposRgn ; de-allocate it
;
; clean up color stuff
tst.b D6 ; are we on a color system?
beq.s @done ; if on B&W, then skip
pea savedFgColor(A6) ; restore the port colors
_RGBForeColor ;
pea savedBkColor(A6) ;
_RGBBackColor ;
@done rts ; all done!
;
; RoundCalc calculates the rounding factor in D4 based on the controlÕs rect
;
RoundCalc
moveq #0,d4
btst #0,d7 ; a 1 in bit-0 of variation code means square corners
bne.s @done ; otherwise round corners like normal buttons
MOVE.W theControlRect+Bottom(A6),D4 ; get bottom coordinate
SUB.W theControlRect+Top(A6),D4 ; figure out vertical height
LSR #1,D4 ; scale it down by a factor of 2
MOVE D4,D0 ; fill both halves with it
SWAP D4 ; get in high part
MOVE D0,D4 ; and in low part
@done RTS
;
; HitPBut handles the button hit-test
;
HitPBut tst.b isDimmed(a6) ; is button dimmed ?
bne.s @done ; if so, skip
subq #2,sp ; make room for function result
move.l D3,-(SP) ; push the point
pea theControlRect(A6) ; push address of rect
_PtInRect ; in the rectangle?
tst.b (SP)+ ; examine result
beq.s @done ; if not, weÕre done
move.w #inButton,result+2(A6); return that it was
@done rts
CalcWholePBut
CalcThumbPBut
move.w #1,result(A6) ; return 1 to show that we respond
;
; CalcPBut returns the bounding region of the button
;
CalcPBut
BSR.S RoundCalc ; calculate rounding factor
_HidePen ; dont draw anything
_OpenRgn
MOVE.L A3,A0 ; copy to A0 for HLock <C424/18Nov86> DAF
_HLock ; lock it down <C424/18Nov86> DAF
pea theControlRect(A6) ; push address of rect
MOVE.L D4,-(SP) ; push rounding factor
_FrameRoundRect ; frame the button
MOVE.L D3,-(SP) ; push the region
_CloseRgn ; make the rounded rectangular region
_ShowPen
MOVE.L A3,A0 ; copy to A0 for HLock <C424/18Nov86> DAF
_HUnlock ; unlock the control <C424/18Nov86> DAF
;
; set the pattern for indicator dragging ????
;
MOVE.L (A5),A0 ; get qDraw globals
LEA Gray(A0),A0 ; point to gray pattern
MOVE.L (A0)+,DragPattern ; move in the 1st half
MOVE.L (A0),DragPattern+4 ; move in the 2nd half
RTS ; all done!
ENDWITH
END ; of file
+39
View File
@@ -0,0 +1,39 @@
;
; File: PopupCDEF.a
;
; Contains: xxx put contents here xxx
;
; Written by: xxx put writers here xxx
;
; Copyright: © 1990 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <1> 3/5/90 BBH first checked in
;
; To Do:
;
;
; Popup.a - assembler header for popup menu CDEF
; Copyright © 1989 Apple Computer Inc. All rights reserved
;
; Written by Byron Han
; Revision History
; 12/2/89 BBH Swapped version and procID
; 7/27/89 BBH Changed procID from 2 to 63
; 6/20/89 BBH Changed procID from 10 to 2
; 3/22/89 BBH started
POPUP PROC EXPORT
IMPORT REALPOPUP
BRA.S @0
DC.W 0 ; flags
DC.L ('CDEF')
DC.W 63 ; procID
DC.W 0 ; version
@0 JMP REALPOPUP
ENDPROC
END
File diff suppressed because it is too large Load Diff
+214
View File
@@ -0,0 +1,214 @@
/*
File: PopupCDEF.h
Contains: Header for Popup CDEF
Written by: Byron Han
Copyright: © 1989-1992 by Apple Computer, Inc., all rights reserved.
This file is used in these builds: BigBang
Change History (most recent first):
<20> 11/7/92 JDR Removed the PopupPrivateData record, which is really publicly
known about.
<19> 5/21/92 gbm #1030284,<dty>: Take popup font size change for Cube-E
<18> 5/10/92 BH added definition for structure WMgrPortState and prototypes for
SaveAndResetWMPorts() and ResetoreWMPorts() under TheFuture
conditional
<17> 8/22/91 KSM PKE,#85693-Bruges: Added utility routine header to get a
tokenized bullet (GetIntlTokenChar).
<16> 2/4/91 kaz jng, #74915: Adding a boolean to DrawTriangle() to determine
whether to dim the triangle.
<15> 1/23/91 kaz <jng>, #81486: Adding resID field to private struct to
differentiate between menuID and 'MENU' resID.
<14> 1/16/91 kaz Adding ApFontID global location for Popup access
<13> 12/14/90 kaz Added comments for private record.
<12> 12/7/90 kaz Hierarchial Menu support: adding popupResult and FindHMenu()
proto. <jng>
<11> 11/12/90 kaz Adding flags to track changes for smarter drawing; removed
hasColor as redundant. <jng>
<10> 10/30/90 kaz Adding changedVal to flag a change in the control's value; added
popupSlopV constant; Removed PaintMyGrayRect() prototype. < BBH>
<9> 9/14/90 kaz Adding old menu height field
<8> 8/5/90 kaz Added new prototypes for gray drawing.
<7> 8/3/90 kaz Prototype & constant mods
<6> 6/12/90 kaz Prototype changes galore. Replaced TextInfo w/ TextState.
<5> 6/4/90 kaz Added fields for new drawing and new fixedWidth mentality.
<4> 5/29/90 kaz Removed SKANKY #ifdef
<3> 3/16/90 BBH stop diddling with wmgrport and wmgrcport font and size so
removed appropriate entries from the TextInfo data structure
(compiler directive SKANKY is undef-ed to turn off the wmgrport
diddling)
<2> 3/5/90 BBH change spandex MDEF to be spandex proc resource type
<1> 3/5/90 BBH first checked in
To Do:
*/
#include <Controls.h>
#include "ControlPriv.h" // private control manager equates (for triangle ID)
// the constants
////////////////////////////////////////////////////////////////////////////////
// low memory globals used
#define SysFontFam 0x0BA6
#define SysFontSize 0x0BA8
#define CurFMInput 0x0988
#define ApFontID 0x0984
// characters
#define BulletMark 0xA5
// color grafport signature
#define cGrafSignature 0x0000C000
// patterns to be gotten from the system file
#define blackPatternID 1
#define grayPatternID 4
// part code
#define myPartCode 1
#define movedPartCode 129
// menu command key special values
#define useReducedIcon 0x001D
#define useSmallIcon 0x001E
// MDEF's owned by me (CDEF 63)
#define SpandexResType 'proc'
#define SpandexMDEF 0xDFE0
#ifndef mDrawItemMsg
#define mDrawItemMsg 4
#endif mDrawItemMsg
#ifndef mCalcItemMsg
#define mCalcItemMsg 5
#endif mCalcItemMsg
#ifndef calcCntlRgn
#define calcCntlRgn 10
#endif calcCntlRgn
#ifndef calcThumbRgn
#define calcThumbRgn 11
#endif calcThumbRgn
// internal constants
#define popupTitleJustMask 0x00FF
#define popupTitleStyleMask 0x7F00
#define popupSlop 3
#define popupSlopV 3
#define shadowTop 3
#define shadowLeft 3
// the data structures
////////////////////////////////////////////////////////////////////////////////
typedef struct myData { // private data structure from contrlData
// the following structure MUST NOT be moved
// it's documented in Inside Mac as being here
// but we can have our private data following this
PopupPrivateData public; // publicly known data structure
long popupResult; // MacApp: hierarchial popups (hiword == menuId)
Rect myCtlRect; // StdFile: area where the control is drawn
// Everything below this is private
Rect oldContrlRect; // in case control moves
short minWidth; // min width for fixedWidth CNTLs
short maxWidth; // contrlRect.right - contrlRect.left
short oldHeight; // last menu item height
short oldWidth; // last menu width
short oldMax; // last # of menu items
short resID; // 'MENU' resID can be differnt from menuID
Boolean changedVal; // if the user has TRACKED a new value
// other characteristics
Boolean useColor; // are we going to use CQD?
Boolean makeCPort; // do we need to create a cGrafPort?
Style titleStyle; // style of the popup label
short titleWidth; // width of popup label area
short titleJust; // justification of the popup label
short preinstalled; // menu preinstalled in menulist?
// below here is dynamic recalculated when we draw
short sysJust;
FontInfo info;
} myData, *myDataP, **myDataH;
// This is also defined in CommToolboxPriv.h
typedef struct TextState {
short theFont;
Style theFace;
short theSize;
short theMode;
} TextState, *TextStatePtr;
typedef struct WMgrPortState {
short savedFont;
short savedSize;
short savedCFont;
short savedCSize;
} WMPortState, *WMPortStatePtr;
typedef struct Spandex { // header for spandex MDEF
short branch; // BRA.S @0
short flags;
ResType rType;
short procID;
short version;
// this is important below
Handle defProc; // saved mdefproc to be called
short dH; // amount to expand menuWidth by
} Spandex, *SpandexP, **SpandexH;
// functional prototypes
pascal long nupopup(short theVar, ControlHandle hControl, short msg, long theParam);
// action procedures
void DoInit(ControlHandle hControl, short theVar);
long DoDraw(ControlHandle hControl, short theVar, short theParam);
long DoTest(ControlHandle hControl, long theParam);
void DoCalc(ControlHandle hControl, short theVar, long *theParam);
void DoDispose(ControlHandle hControl);
long DoTrack(ControlHandle hControl, short theVar);
typedef pascal void (**MDEFHandle)(short msg, MenuHandle hMenu, Rect *mRect, Point hitPt,
short *whichItem);
// drawing routines
void ResizeControl(ControlHandle hControl, short theVar);
void EraseControl(ControlHandle hControl);
void DrawTriangle(myDataP dataP, Boolean dimmed);
void DrawTitle(ControlPtr controlP, myDataP dataP);
void SetColors(short menuID, short menuItem, Boolean isHilited);
CGrafPtr MakeColorPort(GrafPtr owner);
PixPatHandle BeginMyGray(myDataP dataP);
// calculate routines
void CalcTitleArea(myDataP dataP, Rect *theRect);
void CalcBoxArea(myDataP dataP, Rect *theRect);
void CalcMenuArea(myDataP dataP, Rect *theRect);
void CalcShadowArea(myDataP dataP, Rect *theRect);
void CalcTriangleRect(myDataP dataP, Rect *theRect);
void CalcAndDrawItem(ControlHandle hControl, short theVar,
short theMsg, Rect *theRect);
// more utils
void GetTextState(TextState *txState);
void SetTextState(TextState *txState);
void SaveAndResetWMPorts(WMPortState *savedWMPortState);
void RestoreWMPorts(WMPortState *savedWMPortState);
void DoUseWFont(TextState *savedInfo, WindowPtr owner, Boolean saveIt);
short FindHItem(MenuHandle hMenu, short hMenuID);
char GetIntlTokenChar(short whichToken, short whichScript, char defaultChar);
+145
View File
@@ -0,0 +1,145 @@
;
; File: PopupCDEFMDEF.a
;
; Contains: code resource that postprocesses menu defproc's mSizeMsg
; by expanding the width by a given delta amount
;
; Written by: Byron Han
;
; Copyright: © 1989-1990, 1992 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <5> 11/3/92 DTY Clean up includes.
; <4> 3/30/91 DTY ngk, #f1-ngk-002: lock down MDEF before calling through to it.
; <3> 3/19/90 EMT Deleted spurious characters inserted in <2>.
; <2> 3/19/90 BBH moved dsMDEFNotFound to SysErr.a
; <1> 3/5/90 BBH first checked in to BBS
;
; Pre-BBS Modification History
; 12/2/89 BBH Swap version/procID
; Incorporate changes from code revu
; (tighten up code, add syserr if cannot load mdef)
; 11/28/89 BBH Created
;
;
; PROCEDURE MyMDEF(msg: INTEGER; hMenu: MenuHandle;
; VAR mRect: Rect; hitPt: Point; VAR mItem: INTEGER);
;
; This MDEF calls the mdef stored in the header. If the size message is
; passed in, we increase the width by the value in extend.
;
; So, to do this from pascalÉ
;
; TYPE
; MyHandle = ^MyPtr;
; MyPtr = ^MyRecord;
; MyRecord = RECORD { format of the header }
; branch: INTEGER; { BRA.S blah blah blah }
; flags: INTEGER;
; rType: ResType;
; procID: INTEGER;
; version: INTEGER;
;
; defProc: Handle;
; extend: INTEGER;
; END;
;
; theHandle := MyHandle(GetResource('MDEF', $DFE0)); { get new mdef }
; WITH theHandle^^ DO { and fill in the blanks }
; BEGIN
; defProc := theMenu^^.menuProc;
; extend := info.widMax
; END;
;
; theMenu^^.menuProc := Handle(theHandle); { set up new mdefproc }
;
; { call popupmenuselect here }
;
; theMenu^^.menuProc := theHandle^.defProc; { restore the mdefproc }
;
wholeErrors EQU 1 ; <BBH 12/2/89> we want ALL error codes
INCLUDE 'SysErr.a' ; <BBH 12/2/89>
INCLUDE 'ToolEqu.a'
INCLUDE 'Traps.a'
MDEF PROC EXPORT
retAddr EQU 4 ; stack frame constants
mItem EQU retAddr+4
hitPt EQU mItem+4
mRect EQU hitPt+4
hMenu EQU mRect+4
msg EQU hMenu+4
branch BRA.S Main ; 2 bytes
flags DC.W 0 ; flags
rType DC.L ('MDEF')
procID DC.W $DFE0 ; procID (owned by CDEF 63)
version DC.W 0 ; version
defproc DC.L 0 ; handle for the menu defproc
extend DC.W 0 ; amount to increase horizontal by
Main LINK A6,#-2 ; create a stack frame
MOVE.W msg(A6),-(SP) ; repush the parameters
MOVE.L hMenu(A6),-(SP)
MOVE.L mRect(A6),-(SP)
MOVE.L hitPt(A6),-(SP)
MOVE.L mItem(A6),-(SP)
MOVE.L defProc,A0 ; replaces two lines below <BBH 12/2/89>
; LEA defproc,A0 ; get the defProc storage
; MOVE.L (A0),A0 ; get the defproc
MOVE.L A0,-(SP) ; load mdefproc <BBH 12/2/89>
_LoadResource
MOVE.L (A0),D1 ; check if still not loaded <BBH 12/2/89> <4, #f1-ngk-002>
BNE.S @AOK ; all right
MOVEQ #dsMDEFNotFound,D0 ; deep shit alert error
_SysError
BRA.S @byebye ; and now back to the futureÉ
@AOK ; end addition <BBH 12/2/89>
_HGetState ; Get state of MDEF <4, #f1-ngk-002>
move.w d0,-2(a6) ; Save state <4, #f1-ngk-002>
_HLock ; <4, #f1-ngk-002>
MOVE.L D1,A0 ; dereference defproc <4, #f1-ngk-002>
JSR (A0) ; jump through it please
move.l defProc,a0 ; <4, #f1-ngk-002>
move.w -2(a6),d0 ; Restore state of handle <4, #fl-ngk-002>
_HSetState ; <4, #f1-ngk-002>
CMP.W #mSizeMsg,msg(A6) ; replaces two lines below <BBH 12/2/89>
; MOVE.W msg(A6),D0 ; is this a size measurement?
; CMP #mSizeMsg,D0
BNE.S @byebye
MOVE.W extend,D0 ; replaces two lines below <BBH 12/2/89>
; LEA extend,A0 ; get amount to widen the menu
; MOVE.W (A0),D0
MOVE.L hMenu(A6),A0 ; get the mHandle
MOVE.L (A0),A0 ; dereference
ADD.W D0,menuWidth(A0) ; and add amount to extend byÉ
@byebye ; common exit code
UNLK A6 ; destroy stack frame
MOVE.L (SP)+,A0 ; get return address
LEA 18(SP),SP ; replaces line below <BBH 12/2/89>
; ADD.L #18,SP ; strip
JMP (A0) ; and go home
ENDPROC
END
+52
View File
@@ -0,0 +1,52 @@
/*
File: PopupTriangle.r
Contains: xxx put contents here xxx
Written by: xxx put writers here xxx
Copyright: © 1990 by Apple Computer, Inc., all rights reserved.
Change History (most recent first):
<2> 3/5/90 BBH checkin script nuked part of file so I'm putting it back in
<1> 3/5/90 BBH first checked in
To Do:
*/
#include "Pict.r"
#include "ControlPriv.h"
resource 'PICT' (PopupTrianglePictID, purgeable) {
{-1, -1, 74, 146},
VersionOne {
{ /* array OpCodes: 24 elements */
/* [2] */
clipRgn {
{-1, -1, 74, 146},
$""
},
/* [7] */
paintPoly {
{1, 1, 73, 145},
{ /* array framePoly: 4 elements */
/* [1] */
{1, 1},
/* [2] */
{1, 145},
/* [3] */
{73, 73},
/* [4] */
{1, 1}
}
},
/* [8] */
clipRgn {
{0, 0, 0, 0},
$""
},
}
}
};
File diff suppressed because it is too large Load Diff