home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-09 | 24.3 KB | 992 lines | [TEXT/Earl] |
- ; WDEF.a.
- ; A window definition procedure by Earle R. Horton.
- ; This file looks most attractive with tabstops set to 8.
- ; Portions of this file are based on a disassembly of the standard
- ; 'WDEF' #0 from Apple. Therefore, portions of this file are
- ; Copyright Apple Computer Inc.
- ;
- ; Significant modifications to the Apple Code include:
- ;
- ; Lowmem globals not used for scratch variables.
- ; Source-level support for non-standard width scroll bars:
- ; GrowWidth equate used to determine width of
- ; GrowIcon and gray scroll bar image.
- ; Title bar has a different appearance:
- ; Narrower:
- ; More elegant.
- ; Relieves the boredom.
- ; Close and Zoom icons moved to look better with
- ; new title bar height.
- ; Title drawn in bold Geneva 9.
- ; Squares in GrowIcon are shadowed.
- ;
- STRING ASIS
- include 'Traps.a'
- include 'ToolEqu.a'
- include 'QuickEqu.a'
-
- ROM85 EQU $028E
- WMgrCPort EQU $0D2C
-
- tfinfo EQU -8
- PatMargin EQU tfinfo+leading ; reusable storage
- scratchRgn EQU tfinfo-4
- ctabH EQU scratchRgn-4
- ctabP EQU ctabH-4
- DefaultForeColor EQU ctabP-6
- DefaultBackColor EQU DefaultForeColor-6
- ColorMac EQU DefaultBackColor-2
- savetxFont EQU ColorMac-2
- savetxFace EQU savetxFont-2
- savetxSize EQU savetxFace-2
- gport EQU savetxSize-4
- scratchRect EQU gport-8
- myBitMap EQU scratchRect-bitmapRec
- savePort EQU myBitMap-4
- ourHandle EQU savePort-4
- frameVars EQU ourHandle
-
- wptr EQU A3
- grect EQU A3
-
- varCode EQU D5
- TBarHeight EQU D7
-
- param EQU 8
- message EQU 12
- window EQU 14
- retVal EQU 20
-
- MinTBarHeight EQU 12
- ; Note that scroll bars look funny in other than the standard width
- ; of 16. 13 doesn't look too bad, however. If you want wide scroll
- ; bars (and GrowIcon), then you have to create a BitMap image for the
- ; GrowIcon.
- GrowWidth EQU 13
- UseSystemFont EQU 0 ; System Font if 1, programmer choice otherwise
- TrueShadowColorMac EQU 1
- CZBoxTop EQU 1 ; Offset to close and zoom boxes
-
- ZoomLeft EQU -16
- CloseLeft EQU 6
- PadInsideTitleBarIcons EQU 6
- ;
- ; Must be first code in 'WDEF', since Init routine uses it to get
- ; Handle to 'WDEF'.
- ;
- WDEFProc PROC EXPORT
- BRA.S EntryPoint
- dc.w 0
- dc.l 'WDEF'
- dc.l $0000000A
- EntryPoint
- LINK A6,#frameVars
- MOVEM.L D3-D7/A1-A4,-(A7)
- lea WDEFProc,a0
- _RecoverHandle
- move.l a0,ourHandle(a6)
- _HLock
- CMPI.W #6,Message(A6) ; Range-check message
- BGT LeaveWDEF ; Ignore if > 6
- CMPI.W #0,Message(A6) ; Range-check message
- BMI LeaveWDEF ; ignore if < 0
- pea savePort(a6) ; Restored on exit
- _GetPort ; Get the current port
- CMPI.W #$3FFF,ROM85 ; Test for Color QD
- SLS ColorMac(A6) ; Save in a variable
- BHI.S DoMono ; Set up port for QuickDraw
- BSR SetUpForColor ; Set up port for QD II
- BRA.S SetUpSaveFont ; And skip QuickDraw part
- DoMono
- pea gport(a6) ; QuickDraw: Most routines draw in WMgrPort
- _GetWMgrPort ; Get it
- move.l gport(a6),-(sp) ; Save in a variable
- _SetPort ; Make it the current port
- SetUpSaveFont ; Save current port text settings
- movea.l gport(a6),a0 ; Save text variables
- move.w txFont(a0),savetxFont(a6) ; from our current drawing
- move.w txSize(a0),savetxSize(a6) ; port.
- move.w txFace(a0),savetxFace(a6)
-
- LEA tfinfo(a6),a3
- MOVE.L a3,-(A7)
- ; Before doing any operation which uses text, apply the text settings we
- ; use for the title bar. Afterwards, restore default WMgrPort settings.
- ; This is perhaps overly conservative, but if we draw into the WMgrPort
- ; with a font which is not the system font, we have to be carefulâ•”
- bsr MyFont ; Set up for my text settings.
- _GetFontInfo ; Do the font call.
- bsr RestoreFont ; Restore to normal.
- MOVE.W (a3)+,TBarHeight ; TBarHeight = ascent
- ADD.W (a3)+,TBarHeight ; + descent
- ADDQ.W #2,TBarHeight ; + 2
- bset #0,TBarHeight ; + 1 if even
- moveq #MinTBarHeight,D1
- CMP.W D1,TBarHeight ; > MinTBarHeight?
- BGE.S BigEnough ; OK, great.
- SUB.W TBarHeight,D1 ; No, get difference.
- LSR.W #1,D1 ; Divide by 2.
- ADD.W D1,tfinfo+ascent(a6) ; Add to tfinfo.ascent
- moveq #MinTBarHeight,TBarHeight ; Use MinTBarHeight.
- BigEnough
- MOVE.W TBarHeight,(a3)+ ; tfinfo.widMax = TBarHeight
- move.w #3,(a3) ; PatMargin = 1
- CLR.L -(A7) ; Get a region to work with.
- _NewRgn ; From _NewRgn
- MOVE.L (A7)+,scratchRgn(A6) ; Save it in a variable.
- TST.B ColorMac(A6) ; Doing Color?
- BEQ.S ColorSkip1
- ; Get color info for this window.
- PEA DefaultForeColor(A6) ; Get Fore and Back Colors
- _GetForeColor
- PEA DefaultBackColor(A6)
- _GetBackColor
- CLR.L -(A7) ; Space for Auxiliary Window Record Handle.
- CLR.W -(A7) ; Space for result = Boolean
- MOVE.L window(A6),-(A7) ; Push window pointer
- PEA 6(A7) ; Push address of Handle on stack
- _GetAuxWin ; Get Auxiliary Window Record
- ADDQ.W #2,A7 ; Toss result
- MOVEA.L (A7)+,A0 ; Get Handle into register
- MOVEA.L (A0),A0 ; Dereference
- MOVEA.L awCTable(A0),A0 ; Get CTabHandle
- MOVE.L A0,ctabH(a6) ; save Handle
- _HLock ; Lock it
- MOVE.L (A0),ctabP(a6) ; Get Pointer
- ColorSkip1
- LEA param(A6),A0 ; Fetch function parameters.
- MOVE.L (A0)+,D3 ; param
- MOVE.W (A0)+,D0 ; message
- MOVEA.L (A0)+,wptr ; WindowPtr
- MOVE.W (A0)+,varCode ; varCode
- MOVE.W varCode,D6 ; varCode in d6
- ANDI.W #3,varCode ; low 2 bits in d5
- CLR.L (A0) ; Clears return value.
- ADD.W D0,D0 ; message to jump table offset
- LEA WDispatch,A0 ; Get jump table
- ADDA.W WDispatch(D0.W),A0 ; Add offset of routine.
- JSR (A0) ; Dispatch to service routine.
- MOVE.L scratchRgn(A6),-(A7) ; Done, now we clean up and leave.
- _DisposRgn ; Toss scratchRgn
- TST.B ColorMac(A6) ; Color?
- BEQ.S RestoreAndLeave ; No.
- MOVEA.L ctabH(a6),A0 ; Get CTabHandle.
- _HUnlock ; Unlock it.
- PEA DefaultBackColor(A6) ; Restore colors to those used
- _RGBBackColor ; before we were called.
- PEA DefaultForeColor(A6)
- _RGBForeColor
- RestoreAndLeave
- move.l savePort(a6),-(sp) ; Restore previous port.
- _SetPort
- LeaveWDEF
- move.l ourHandle(a6),a0
- _HLock
- MOVEM.L (A7)+,D3-D7/A1-A4 ; Restore registers.
- UNLK A6 ; Pascal return.
- MOVEA.L (A7)+,A0
- ADDA.W #12,A7
- JMP (A0)
- dc.b 'WDEF ' ; For MacsBug
- WDispatch ; Service routine jump table
- dc.w Draw - WDispatch
- dc.w Hit - WDispatch
- dc.w CalcRgn - WDispatch
- dc.w Init - WDispatch
- dc.w Dispos - WDispatch
- dc.w Grow - WDispatch
- dc.w GIcon - WDispatch
-
- SetUpForColor
- pea gport(a6) ; Standard Color QD WDEF port setup.
- _GetWMgrPort ; Get WMgrPort
- move.l gport(a6),-(sp) ; save on stack
- pea gport(a6) ; Get CWMgrPort
- _GetCWMgrPort
- move.l gport(a6),-(sp) ; Make it the current port
- _SetPort ; to allow for RGB colors in 'wctb'.
- move.l (sp)+,a0 ; a0 -> WMgrPort = source
- move.l gport(a6),a1 ; a1 -> CWMgrPort = destination
- PEA bkPat(A0) ; copy bkPat,
- PEA pnPat(A0) ; pnPat,
- LEA pnLoc(A0),A0 ; pnLoc,
- LEA pnLoc(A1),A1
- MOVE.L (A0)+,(A1)+
- MOVE.L (A0)+,(A1)+ ; pnSize,
- MOVE.W (A0)+,(A1)+ ; pnMode,
- ADDQ.W #8,A0 ; all fields from
- ADDQ.W #8,A1 ; pnVis
- MOVE.W #20,D0 ; to
- portCopy
- MOVE.W (A0)+,(A1)+ ; bkColor
- DBRA D0,portCopy
- _PenPat ; Do the patterns using the traps.
- _BackPat
- RTS
- ;
- ; Init the window. This routine will allocate a Handle, and thus
- ; potentially move memory, if the window has a zoom box. Not to
- ; worry about locking the 'WDEF' resource over this, since the
- ; Window Manager locks us if we are called with the Init message.
- ;
- Init
- ; Set up for Zooming if ZoomDocProc
- BTST #3,D6 ; Bit 3 set means ZoomDocProc
- BEQ.S NoZoom ; OK, forget it.
- CLR.B wZoom(wptr) ; Clear zoom flag.
- TST.W ROM85 ; Test for ROM support.
- BMI.S NoZoom ; Don't have it.
- moveq #16,D0 ; Get a new Handle to store
- _NewHandle ,Clear ; 2 Rects.
- BNE.S NoMem ; No good, SIMM prices must still be high.
- ADDQ.B #1,wZoom(wptr) ; OK, we can zoom.
- MOVE.L A0,wDataHandle(wptr) ; Save Handle in window's wDataHandle.
- MOVEA.L (A0),A4 ; point A4 at contents
- ADDQ.W #8,A4 ; point to stdState
- MOVEA.L GrafGlobals(A5),A1 ; Get screenBits.bounds
- MOVE.L screenBits+bounds+topLeft(A1),(A4)+
- MOVE.L screenBits+bounds+botRight(A1),(A4)+
- moveq #3,D0
- SUB.W D0,-(A4) ; Standard State is inset by 3 from
- SUB.W D0,-(A4) ; screenBits.bounds
- ADD.W D0,-(A4)
- ADD.W D0,-(A4)
- move.w MBarHeight,d0 ; Get Height of MenuBar
- ADD.W d0,(A4) ; Top is dropped for Menu Bar height plus
- ADD.W TBarHeight,(A4) ; Title Bar height.
- MOVEA.L (A0),A4 ; point at userState
- ;
- ; Make 8 bytes pointed to by A4 a copy of wDataHandle^^.userState.
- ;
- Get_userState
- MOVE.L A4,-(A7) ; Push Rect address
- MOVE.L portRect(wptr),(A4) ; Get port topLeft
- MOVE.L portRect+4(wptr),4(A4) ; and botRight.
- MOVEA.L wptr,A0 ; Get WindowPtr
- BSR GetBitsPtr ; Get Ptr to {Bit,Pix}Map in a0
- MOVE.L 6(A0),-(A7) ; Get topLeft of portBits
- NEG.W top(A7) ; Get Global portRect for userState
- NEG.W left(A7) ; Offset by -topLeft.
- _OffsetRect
- NoMem
- NoZoom
- RTS
- ;
- ; This routine tries to determine whether the user has tried to create
- ; a larger-than-normal standard state.
- ; If [s]he has, then wDataHandle^^.userState.topLeft will be slightly
- ; to the left and higher than wDataHandle^^stdState.topLeft, and
- ; wDataHandle^^.userState.botRight will be slightly to the right
- ; and below wDataHandle^^.stdState.botRight.
- ;
- CheckStdState
- SUBQ.W #8,A7 ; Make room for Rect
- MOVEA.L A7,A4 ; Make a4 point to it
- BSR.S Get_userState ; Get copy of wDataHandle^^.userState
- MOVEA.L wDataHandle(wptr),A0 ; Get wDataHandle
- MOVEA.L (A0),A2 ; Dereference
- ADDQ.W #8,A2 ; a2 -> WStateData.stdState
- BSR.S L01C2 ; topLeft in range?
- BNE.S L01B4
- BSR.S L01C2 ; botRight in range, too?
- BEQ.S L01BE
- L01B4 ; Yes, must create
- MOVEA.L wDataHandle(wptr),A0 ; Get wDataHandle
- MOVEA.L (A0),A4 ; a4 points to wDataHandle^^.stdState
- BSR.S Get_userState ; Put current userState into it,
- moveq #1,D0 ; and return 1.
- L01BE
- ADDQ.W #8,A7 ; Pop off temp Rect, and return.
- RTS
- L01C2
- MOVE.L (A2),-(A7) ; stdState.topLeft
- MOVE.L (A2)+,-(A7) ; stdState.botRight
- MOVE.L A7,-(A7) ; push address of Rect on stack
- MOVE.L #$FFF9FFF9,-(A7) ; swell by 7
- _InsetRect
- CLR.W -(A7) ; room for function result
- MOVE.L (A4)+,-(A7) ; push userState.topLeft first time
- ; push userState.botRight second time
- PEA 6(A7) ; push pointer to swelled stdState
- _PtInRect ; contained?
- SUBQ.B #1,(A7) ; subtract 1
- MOVE.B (A7)+,D0 ; move Boolean result - 1 to d0
- ADDQ.W #8,A7 ; fix stack
- RTS
-
- IsZoomWindow
- BTST #3,D6 ; Right varcode?
- BEQ.S NopeItIsnt ; Nope
- TST.B wZoom(wptr) ; Window set up for Zooming?
- NopeItIsnt
- RTS
-
- Dispos ; Toss wDataHandle.
- BSR.S IsZoomWindow ; Anything to toss?
- BEQ.S NothingToDispose ; Nope
- MOVEA.L wDataHandle(wptr),A0 ; Yes, get wDataHandle
- _DisposHandle ; and toss it.
- NothingToDispose
- RTS
-
- getCtabEntry
- MOVE.L D1,-(A7) ; save d1
- MOVEA.L ctabP(a6),A0 ; Point at window color table
- MOVE.W ctSize(A0),D1 ; use ctSize for loop
- MULU #ctEntrySize,D1 ; *size of entry
- getNextColorSpec
- CMP.W ctEntrySize(A0,D1.W),D0 ; ColorSpec.value == d0 ?
- BEQ.S gottheColor ; Yes, return the color
- SUBQ.W #ctEntrySize,D1 ; Decrement loop counter
- BGE.S getNextColorSpec ; loop if > 0
- moveq #0,D1 ; Default to first entry
- gottheColor
- LEA 10(A0,D1.W),A0 ; Point to actual ColorSpec
- MOVE.L A0,D0 ; stick it in d0
- MOVE.L (A7)+,D1 ; restore d1
- MOVEA.L (A7)+,A0 ; pop return address
- MOVE.L D0,-(A7) ; push return value on stack
- JMP (A0) ; return
-
- GetBitsPtr
- ADDQ.W #2,A0 ; a0 -> portBits
- TST.W 4(A0) ; This is portBits.rowBytes in QD I
- BPL.S L022E ; and portVersion in QD II.
- MOVEA.L (A0),A0 ; QD II means we have to dereference
- MOVEA.L (A0),A0 ; the PixMapHandle.
- L022E RTS
-
- Draw
- TST.B wVisible(wptr) ; Window visible?
- BEQ DontThinkWeHaveTo ; No, skip this.
- CMPI.W #wInGoAway,D3 ; >= 4, draw a hit action mask
- BGE ToggleHitMask
- _PenNormal ;
- TST.W varCode ;
- BNE BigShadowTest
- BSR GetTitleBarRect
- TST.B ColorMac(A6)
- BEQ.S ColorSkip2
- MOVE.W #wFrameColor,D0 ; Use correct Frame color.
- BSR.S getCtabEntry
- _RGBForeColor
- MOVE.W #wTitleBarColor,D0 ; Use correct Title bar color.
- BSR.S getCtabEntry
- _RGBBackColor
- ColorSkip2
- PEA scratchRect(a6) ; Push three copies of pointer
- MOVE.L (A7),-(A7) ; to Title Bar Rect.
- MOVE.L (A7),-(A7)
- _FrameRect ; Frame it.
- MOVE.L #$00010001,-(A7) ; inset by one pixel
- _InsetRect
- _EraseRect ; Erase it
- pea scratchRect(a6) ; Push another copy of the pointer
- move.l #-1,-(sp) ; Restore size.
- _InsetRect
- BSR DrawTitleInTitleBar ; Title the window.
- TST.B wHilited(wptr) ; Is it Hilited?
- BEQ L031A
- TST.B ColorMac(A6) ; Does it need color?
- BEQ.S ColorSkip3
- MOVE.W #wHiliteColor,D0 ; Use the Hilite color.
- BSR getCtabEntry ; for ForeGround. (Title Bar color
- _RGBForeColor ; is already set.)
- ColorSkip3
- move.l scratchRect+topLeft(a6),d0 ; Align pattern to start
- andi.l #$00070007,d0 ; at TitleBarRect.topLeft
- move.l (a5),a4 ; by setting a "private" QD
- move.l d0,patAlign(a4) ; global.
- PEA scratchRect(a6) ; Inset on sides by 1,
- MOVE.W #1,-(A7) ; and on top and bottom
- MOVE.W PatMargin(a6),-(A7) ; by saved margin for Pattern.
- _InsetRect
- MOVE.W scratchRect+right(a6),-(A7) ;
- MOVE.W D3,scratchRect+right(a6) ; d3 = left of Title Rect
- PEA scratchRect(a6) ; Fill to left of Title Box
- PEA TBarPat ; Using hard-wired pattern.
- _FillRect
- BSR IsZoomWindow ; Zoom?
- BEQ.S L02DC
- MOVE.W (A7),D0 ; Pop right of scratch Rect.
- add.W #2*ZoomLeft+8,D0
- ; Leave room for Zoom Box
- CMP.W D4,D0 ; (d4 = left of Zoom)
- BGE.S L02DC
- MOVE.W D0,D4
- L02DC MOVE.W (A7)+,scratchRect+right(a6) ; Pop right of scratch Rect.
- MOVE.W D4,scratchRect+left(a6) ; Fill area to left
- PEA scratchRect(a6) ; of zoom box
- PEA TBarPat ; with Title Bar fill pattern.
- _FillRect ; Yeah!
- clr.l patAlign(a4) ; Restore pattern alignment.
- TST.B wGoAway(wptr) ; GoAway box?
- BEQ.S L0306 ; Nope.
- BSR GetTitleBarRect ; Get the Title Bar
- LEA CloseBoxBits,A1 ; Load close box
- moveq #srcCopy,D0 ; Copy it.
- lea scratchRect(a6),a0 ; Load dest Rect
- BSR L0406 ; Draw it.
- L0306 BSR IsZoomWindow ; Window Zoomable?
- BEQ.S L031A ; Nope.
- BSR GetTitleBarRect ; Get the Title Bar.
- LEA ZoomBoxBits,A1 ; Load zoom box,
- lea scratchRect(a6),a0 ; and dest Rect.
- moveq #srcCopy,D0 ; Copy it.
- BSR L03F0 ; Draw it.
- L031A MOVE.L #$00010001,D4 ; Inset by 1.
- L031E TST.B ColorMac(A6) ; Color active?
- BEQ.S ColorSkip4
- moveq #wFrameColor,D0 ; Fore = Frame.
- BSR getCtabEntry
- _RGBForeColor
- moveq #wContentColor,D0 ; Back = content.
- BSR getCtabEntry
- _RGBBackColor
- ColorSkip4
- MOVEA.L structRgn(wptr),A0 ; Get frame box.
- MOVEA.L (A0),A0
- LEA rgnBBox(A0),A4 ; load the region box.
- SUB.W D4,bottom(A4) ; Inset
- SUB.W D4,right(A4)
- MOVE.L A4,-(A7)
- _FrameRect ; Frame it.
- CMPI.W #altDBoxProc,varCode ; Shadowed dBox?
- BEQ.S L0354 ; Nope.
- TST.W varCode
- BNE.S L0358
- L0354 BSR FrameAltdBox
- L0358 CMPI.W #dBoxProc,varCode
- BNE.S L03A4
- MOVE.L (A4),scratchRect(a6)
- MOVE.L 4(A4),scratchRect+botRight(a6)
- PEA scratchRect(a6)
- MOVE.L (A7),-(A7)
- MOVE.L (A7),-(A7)
- MOVE.L #$00010001,-(A7)
- _InsetRect
- MOVE.L #$00070007,-(A7)
- _PenSize
- MOVEA.L (A5),A0
- PEA -8(A0)
- _PenPat
- _FrameRect
- MOVEA.L (A5),A0
- PEA -16(A0)
- _PenPat
- MOVE.L #$00020002,-(A7)
- MOVE.L (A7),-(A7)
- _PenSize
- _InsetRect
- PEA scratchRect(a6)
- _FrameRect
- _PenNormal
- L03A4 MOVEA.L structRgn(wptr),A4
- MOVEA.L (A4),A4
- LEA rgnBBox(A4),A4
- ADD.W D4,bottom(A4)
- ADD.W D4,right(A4)
-
- DontThinkWeHaveTo
- RTS
-
- GetTitleBarRect
- LEA scratchRect(a6),A0 ; Get our scratchRect
- MOVEA.L structRgn(wptr),A1 ; a1 -> structRgn pointer
- MOVEA.L (A1),A1 ; dereference
- ADDQ.W #2,A1 ; a1 -> rgnBBox
- MOVE.L (A1)+,topLeft(A0) ; Copy structRgn^^.rgnBBox to scratchRect
- MOVE.L (A1),botRight(A0)
- MOVE.W top(A0),D0 ; scratchRect.top
- ADD.W TBarHeight,D0 ; + TBarHeight
- MOVE.W D0,bottom(A0) ; to scratchRect.bottom
- SUBQ.W #1,right(A0) ; sub 1 pixel on right for shadow
- RTS
-
- ToggleHitMask
- BEQ.S L03FE ; Equal means goaway.
- BSR IsZoomWindow ; Is it, in fact a zoomable window?
- BEQ.S L042A ; It's not, so forget it.
- BSR.S GetTitleBarRect ; Toggling zoom box.
- LEA ZoomHitMask,A1 ; Load the hit mask.
- moveq #srcXor,D0 ; Draw it in Xor mode to toggle it.
- L03F0
- LEA scratchRect(a6),A0
- MOVE.W right(A0),left(A0)
- moveq #ZoomLeft,D1
- BRA.S L040C
- L03FE
- BSR.S GetTitleBarRect
- LEA CloseHitMask,A1
- moveq #srcXor,D0 ; Draw it in Xor mode to toggle it.
- L0406
- moveq #CloseLeft,D1
- L040C
- LEA scratchRect(a6),A0
- add.w #2,top(a0)
- ADD.W D1,left(A0)
- MOVE.W #CZBoxTop,D1
- ADD.W D1,top(A0)
- SUBQ.W #1,top(A0)
- MOVE.L (A0)+,(A0)
- moveq #11,D1
- ADD.W D1,(A0)+
- ADD.W D1,(A0)
- MOVE.L #$000b000b,D1
- BSR DrawBits
- L042A RTS
-
- BigShadowTest
- MOVE.L #$00020002,D4
- CMPI.W #altDBoxProc,varCode
- BEQ L031E
- moveq #0,D4
- BRA L031E
-
- DrawTitleInTitleBar
- MOVE.W scratchRect+right(a6),D4 ; d4 = right of title bar
- MOVE.W D4,D3
- SUB.W scratchRect+left(a6),D3 ; d3 = width of title bar
-
- movea.l wTitleHandle(wptr),a0
- _Hlock
- movea.l (a0),a0
- clr.w -(sp)
- move.l a0,-(sp)
- bsr MyFont
- _StringWidth
- bsr RestoreFont
- move.w (sp)+,d0
- sub.w d0,d3 ; sub TitleWidth from d3
- movea.l wTitleHandle(wptr),a0
- _HUnlock
- ASR.W #1,D3 ; d3 = (TitleBar - Title)/2
- moveq #2,D0
- TST.B wGoAway(wptr)
- BEQ.S L045A
- moveq #CloseLeft+PadInsideTitleBarIcons+20,D0
- ; Leave space around close box.
- L045A CMP.W D0,D3
- BGE.S L0460
- MOVE.W D0,D3
- L0460 ADD.W scratchRect+left(a6),D3 ; d3 = CloseLeft*2 + 10 + (TitleBar + Title)/2
- MOVE.W D4,-(A7)
- BSR IsZoomWindow
- BEQ.S L0470
- add.w #ZoomLeft+PadInsideTitleBarIcons+10,D4
- ; Leave min space around Zoom box.
- ; d4 = Titlebar + 2*ZoomLeft + 10
- L0470 MOVE.L scratchRgn(a6),-(A7)
- MOVE.L (A7),-(A7)
- _GetClip
- MOVE.W D4,scratchRect+right(a6)
- PEA scratchRect(a6)
- _ClipRect
- MOVEA.L (A5),A0
- MOVEA.L (A0),A0
- MOVE.L 28(A0),-(A7)
- MOVE.L (A7),-(A7)
- _SectRgn
- MOVE.W (A7)+,scratchRect+right(a6)
- MOVE.W D3,-(A7)
- MOVE.W scratchRect+top(a6),D0
- ADD.W tfinfo+ascent(a6),D0
- ADDQ.W #1,D0
- MOVE.W D0,-(A7)
- _MoveTo
- TST.B ColorMac(A6)
- BEQ.S ColorSkip5
- MOVE.W #wTitleBarColor,D0
- BSR getCtabEntry
- _RGBBackColor
- MOVE.W #wTextColor,D0
- BSR getCtabEntry
- _RGBForeColor
- MOVE.W #srcOr,-(A7)
- _TextMode
- ColorSkip5
- MOVEA.L wTitleHandle(wptr),A0
- _HLock
- MOVE.L (A0),-(A7)
- bsr MyFont
- _DrawString
- bsr RestoreFont
- MOVEA.L wTitleHandle(wptr),A0
- _HUnlock
- MOVE.L scratchRgn(A6),-(A7)
- _SetClip
-
- movea.l wTitleHandle(wptr),a0
- _Hlock
- movea.l (a0),a0
- clr.w -(sp)
- move.l a0,-(sp)
- bsr MyFont
- _StringWidth
- bsr RestoreFont
- movea.l wTitleHandle(wptr),a0
- _HUnlock
- move.w (sp)+,d0
- add.w d3,d0 ; d0 = right of title Rect
- SUBQ.W #6,D3 ; d3 = left of title Rect
- CMP.W D4,D0 ; d4 = left of zoom box
- BGE.S L04E6
- MOVE.W D0,D4
- L04E6 ADDQ.W #6,D4
- RTS
-
- Hit
- CLR.W -(A7)
- MOVE.L D3,-(A7)
- MOVE.L contRgn(wptr),-(A7)
- _PtInRgn
- TST.B (A7)+
- BEQ.S L05B0
- TST.W varCode
- BNE.S IsContent
- BTST #2,D6
- BGT.S IsContent
- TST.B wHilited(wptr)
- BEQ.S IsContent
- MOVEA.L contRgn(wptr),A0
- MOVEA.L (A0),A0
- MOVE.L rgnBBox+bottom(A0),D0
- moveq #GrowWidth-2,D4
- SUB.W D4,D0
- CMP.W D0,D3
- BLT.S IsContent
- SWAP D0
- SUB.W D4,D0
- SWAP D3
- CMP.W D0,D3
- BLT.S IsContent
- moveq #wInGrow,D0
- BRA L063A
- IsContent
- moveq #wInContent,D0
- BRA L063A
- L05B0 TST.W varCode
- BNE L063E
- BSR GetTitleBarRect
- CLR.W -(A7)
- MOVE.L D3,-(A7)
- MOVE.L A0,-(A7)
- _PtInRect
- TST.B (A7)+
- BEQ.S L063E
- TST.B wHilited(wptr)
- BEQ.S IsDrag
- MOVE.L D3,D0
- SWAP D0
- MOVEA.L wptr,A0
- BSR GetBitsPtr
- ADD.W 6(A0),D0
- SUB.W portRect+top(wptr),D0
- ADD.W #CZBoxTop,D0
- BPL.S IsDrag
- ADDI.W #11,D0
- BMI.S IsDrag
- TST.B wGoAway(wptr)
- BEQ.S L0608
- MOVE.L D3,D0
- ADD.W portBounds+top(A0),D0
- SUB.W portRect+left(wptr),D0
- CMPI.W #CloseLeft+8,D0
- BGT.S L0608
- SUB.W #CloseLeft,D0
- BMI.S IsDrag
- moveq #wInGoAway,D0
- BRA.S L063A
- L0608 BSR IsZoomWindow
- BEQ.S IsDrag
- MOVE.W D3,D0
- MOVEA.L wptr,A0
- BSR GetBitsPtr
- ADD.W 8(A0),D0
- SUB.W portRect+right(wptr),D0
- CMPI.W #ZoomLeft+2,D0
- BLT.S IsDrag
- CMPI.W #ZoomLeft+10,D0
- BGT.S IsDrag
- BSR CheckStdState
- BEQ.S L0634
- moveq #wInZoomOut,D0
- BRA.S L063A
- L0634 moveq #wInZoomIn,D0
- BRA.S L063A
- IsDrag
- moveq #wInDrag,D0
- L063A MOVE.L D0,retVal(A6)
- L063E RTS
-
- CalcRgn
- BSR IsZoomWindow
- BEQ.S L064A
- BSR CheckStdState
- L064A LEA scratchRect(a6),A0
- MOVE.L A0,-(A7)
- MOVE.L portRect+topLeft(wptr),(A0)+
- MOVE.L portRect+botRight(wptr),(A0)
- MOVEA.L wptr,A0
- BSR GetBitsPtr
- MOVE.L bounds+topLeft(A0),-(A7)
- NEG.W (A7)
- NEG.W 2(A7)
- _OffsetRect
- MOVE.L contRgn(wptr),-(A7)
- PEA scratchRect(a6)
- _RectRgn
- MOVE.L #$00020002,D4
- MOVE.L structRgn(wptr),-(A7)
- PEA scratchRect(a6)
- MOVE.L (A7),-(A7)
- MOVE.L #-1,-(A7)
- _InsetRect
- TST.W varCode
- BNE.S proc14
- MOVE.W TBarHeight,D0
- SUBQ.W #1,D0
- SUB.W D0,scratchRect+top(a6)
- LSR.L #1,D4
- L0698
- _RectRgn
- TST.W varCode
- BEQ.S DoShadow
- CMPI.W #altDBoxProc,varCode
- BNE.S L06DC
- DoShadow
- if TrueShadowColorMac = 0 then
- TST.B ColorMac(A6)
- BEQ.S ColorSkip6
- TST.W varCode
- BNE.S L06BE
- ADD.L D4,scratchRect+botRight(a6)
- MOVE.L structRgn(wptr),-(A7)
- PEA scratchRect(a6)
- _RectRgn
- BRA.S L06DC
- endif
- ColorSkip6
- MOVE.L scratchRgn(A6),-(A7)
- PEA scratchRect(a6)
- MOVE.L (A7),-(A7)
- MOVE.L D4,-(A7)
- _OffsetRect
- _RectRgn
- MOVE.L structRgn(wptr),-(A7)
- MOVE.L scratchRgn(A6),-(A7)
- MOVE.L structRgn(wptr),-(A7)
- _UnionRgn
- L06DC RTS
-
- proc14
- CMPI.W #dBoxProc,varCode
- BNE.S L0698
- PEA scratchRect(a6)
- MOVE.L #$FFF9FFF9,-(A7)
- _InsetRect
- BRA.S L0698
-
- Grow MOVE.L D3,-(A7)
- MOVE.L #-1,-(A7)
- _InsetRect
- MOVEA.L D3,grect
- MOVE.L (grect),-(A7)
- MOVE.W TBarHeight,D0
- SUBQ.W #1,D0
- SUB.W D0,top(grect)
- MOVE.L D3,-(A7)
- _FrameRect
- MOVE.W left(grect),-(A7)
- MOVE.W bottom(grect),-(A7)
- SUBI.W #GrowWidth,(A7)
- MOVE.L (A7),-(A7)
- _MoveTo
- MOVE.W right(grect),2(A7)
- _LineTo
- MOVE.L (A7),(grect)
- MOVE.L (A7),-(A7)
- _MoveTo
- MOVE.W right(grect),2(A7)
- _LineTo
- MOVE.W right(grect),-(A7)
- SUBI.W #GrowWidth,(A7)
- MOVE.W top(grect),-(A7)
- MOVE.L (A7),-(A7)
- _MoveTo
- MOVE.W bottom(grect),(A7)
- _LineTo
- MOVE.L D3,-(A7)
- MOVE.L #$00010001,-(A7)
- _InsetRect
- RTS
-
- FrameAltdBox
- MOVE.L D4,-(A7)
- _PenSize
- MOVE.W right(A4),D0
- MOVE.W D0,-(A7)
- MOVE.W top(A4),-(A7)
- MOVE.W D0,-(A7)
- MOVE.W bottom(A4),D0
- MOVE.W D0,-(A7)
- MOVE.W left(A4),-(A7)
- MOVE.W D0,-(A7)
- if TrueShadowColorMac = 0 then
- TST.B ColorMac(A6)
- BNE.S ColorSkip7
- endif
- TST.W varCode
- BEQ.S ColorSkip7
- ADD.W D4,2(A7)
- ADD.W D4,8(A7)
- ColorSkip7
- _MoveTo
- _LineTo
- _LineTo
- _PenNormal
- RTS
- DrawBits
- LEA myBitMap(a6),A0
- MOVE.L A1,(A0)+
- MOVE.W #2,(A0)+
- CLR.L (A0)+
- MOVE.L D1,(A0)
- PEA myBitMap(a6)
- MOVEA.L (A7),A0
- MOVEA.L (A5),A1
- MOVEA.L (A1),A1
- PEA 2(A1)
- PEA 6(A0)
- PEA scratchRect(a6)
- MOVE.W D0,-(A7)
- CLR.L -(A7)
- _CopyBits
- RTS
- ; This routine is unique in that it draws in the window's port and
- ; not in the WMgrPort.
- GIcon
- pea gport(a6)
- _GetPort
- MOVE.L wptr,-(A7)
- _SetPort
- TST.B ColorMac(A6)
- BEQ.S ColorSkip8
- SUBQ.W #6,A7
- MOVE.L A7,-(A7)
- _GetForeColor
- SUBQ.W #6,A7
- MOVE.L A7,-(A7)
- _GetBackColor
- CLR.W D0
- BSR getCtabEntry
- _RGBBackColor
- MOVE.W #1,D0
- BSR getCtabEntry
- _RGBForeColor
- ColorSkip8
- LEA scratchRect(a6),A4
- MOVE.L portRect+botRight(wptr),botRight(A4)
- MOVE.L botRight(A4),topLeft(A4)
- SUBI.W #GrowWidth-1,top(A4)
- SUBI.W #GrowWidth-1,left(A4)
- TST.B wHilited(wptr)
- BEQ.S EraseGIcon
- LEA GrowBits,A1
- moveq #0,D0
- move.w #GrowWidth,d1
- swap d1
- move.w #GrowWidth,d1
- BSR DrawBits
- DrawGrowLines
- MOVE.W left(A4),-(A7)
- MOVE.W (A7),-(A7)
- MOVE.W portRect+top(wptr),-(A7)
- _MoveTo
- MOVE.W portRect+bottom(wptr),-(A7)
- _LineTo
- MOVE.W portRect+left(wptr),-(A7)
- MOVE.W (A4),-(A7)
- _MoveTo
- MOVE.W portRect+right(wptr),-(A7)
- MOVE.W (A4),-(A7)
- _lineTo
- TST.B ColorMac(a6)
- BEQ.S GIconRet
- MOVE.L A7,-(A7)
- _RGBBackColor
- ADDQ.W #6,A7
- MOVE.L A7,-(A7)
- _RGBForeColor
- ADDQ.W #6,A7
- GIconRet
- move.l gport(a6),-(sp)
- _SetPort
- RTS
-
- EraseGIcon
- PEA scratchRect(a6)
- _EraseRect
- BRA.S DrawGrowLines
- RestoreFont
- if UseSystemFont = 0 then
- move.w savetxFont(a6),-(sp)
- _TextFont
- move.w savetxSize(a6),-(sp)
- _TextSize
- move.w savetxFace(a6),-(sp)
- _TextFace
- endif
- RTS
- MyFont
- if UseSystemFont = 0 then
- move.w #geneva,-(a7)
- _TextFont
- move.w #9,-(a7)
- _TextSize
- move.w #(1 << boldBit),-(a7)
- _TextFace
- endif
- RTS
- ArtWork
- ZoomBoxBits
- dc.l $7FC08420,$84208420,$8420FC20,$80208020
- dc.l $80208020,$7FC00000,$00000000,$00000000
- CloseBoxBits
- dc.l $7FC08020,$80208020,$80208020,$80208020
- dc.l $80208020,$7FC00000,$00000000,$00000000
- CloseHitMask
- ZoomHitMask
- dc.l -1,-1,-1,-1,-1,-1,-1,-1
- if GrowWidth < 16 then
- GrowBits
- dc.l $00000000
- dc.l $3F0021E0
- dc.l $21B021B0
- dc.l $21B03FB0
- dc.l $1FB01030
- dc.l $1FF00FF0
- dc.l $00000000
- dc.l $00000000
-
- elseif GrowWidth = 16 then
- GrowBits
- dc.l $00000000
- dc.l $3FC02060
- dc.l $207C2066
- dc.l $20662066
- dc.l $20663FE6
- dc.l $1FE60806
- dc.l $08060FFE
- dc.l $07FE0000
-
- endif
- TBarPat
- ; This is a gray that looks like a checkerboard in Fat Bits.
- ; dc.l $55aa55aa,$55aa55aa
- ; And this is the familiar horizontal lines pattern used by Apple for
- ; document window Title Bars.
- dc.l $00ff00ff,$00ff00ff
- ENDP
- END
-