home *** CD-ROM | disk | FTP | other *** search
/ Carousel / CAROUSEL.cdr / mactosh / code / asm_ldef.sit < prev    next >
Text File  |  1988-06-20  |  6KB  |  158 lines

  1. 18-Jun-88 14:33:07-MDT,5729;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:33:00 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22299; Sat, 18 Jun 88 14:33:01 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24661; Sat, 18 Jun 88 14:32:59 MDT
  8. Date: Sat, 18 Jun 88 14:32:59 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182032.AA24661@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: LDEF-zero.asm
  13.  
  14. ; File LDefProc0.Text
  15. ;-------------------------------------------------------------
  16. ;
  17. ; Standard List Definition Procedure for simple text
  18. ;
  19. ;      Ernie Beernink  March 1985
  20. ;
  21. ; This is the standard List defProc.  Its primary task is to draw
  22. ; the contents of a list manager cell, either selected or deselected.
  23. ; It is passed a pointer to the cell's data, the length of the cell's
  24. ; data, and a rectangle in which to draw the cell.  When it is called,
  25. ; the clip region is set to that rect.
  26.  
  27. ; MODIFICATION HISTORY:
  28. ;
  29. ;-------------------------------------------------------------
  30.  
  31. ROM128K           .EQU     0
  32. HFSUsed           .EQU     0
  33.  
  34.                .INCLUDE     TLAsm/SysEqu.text
  35.                .INCLUDE     TLAsm/ToolEqu.text
  36.                .INCLUDE     TLAsm/QuickEqu.text
  37.                .INCLUDE     TLAsm/QuickTraps.text
  38.                .INCLUDE     TLAsm/PackMacs.text
  39.  
  40.                .PROC     LDEF0
  41.  
  42. ; PROCEDURE    DrawCell(LMessage:INTEGER; LSelect:BOOLEAN; LRect:Rect; LCell: Cell;
  43. ;                LDataOffset, LDataLen:INTEGER; LHandle:Handle);
  44.  
  45. ; Message equates:
  46.  
  47. ;InitMsg        .EQU      0              ; tell drawing routines to init themselves
  48. ;DrawMsg        .EQU      1              ; draw (and de/select) the indicated data
  49. ;HiliteMsg      .EQU      2              ; de/select the indicated data
  50. ;CloseMsg       .EQU      3              ; shut down, the list is being disposed
  51.  
  52. ; Stack Frame definition for ListDefProc 0
  53.  
  54. LHandle           .EQU     8             ; Handle to list data record
  55. LDataLen       .EQU     LHandle+4         ; length of data
  56. LDataOffset    .EQU     LDataLen+2         ; offset to data
  57. LCell           .EQU     LDataOffset+2         ; cell that was hit
  58. LstRect           .EQU     LCell+4         ; rect to draw in
  59. LSelect           .EQU     LstRect+4         ; 1=selected, 0=not selected
  60. LMessage       .EQU     LSelect+2         ; 0=Init, 1=Draw, 2=Hilite, 3=Close
  61. LParamSize     .EQU     LMessage+2-8         ; # of bytes of parameters
  62.  
  63.                BRA.S     @0             ; enter here
  64.  
  65. ; standard header
  66.  
  67.                .WORD     0             ; flags word
  68.                .ASCII     'LDEF'             ; type
  69.                .WORD     0             ; ID
  70.                .WORD     0             ; version
  71. @0
  72.                LINK     A6,#0             ; set up a stack frame
  73.                MOVEM.L     D3-D7/A2-A4,-(SP)   ; save the usual stuff
  74.                MOVE.L     LHandle(A6),A4         ; get handle to list record
  75.                MOVE.L     (A4),A3         ; get pointer to (locked) record
  76.  
  77.                MOVE.W     LMessage(A6),D0     ; why am I being called?
  78.  
  79.                SUBQ     #1,D0             ; check next in line
  80.                BEQ.S     LstDraw         ; code = 1 -> draw cell
  81.                SUBQ     #1,D0             ; check next
  82.                BEQ.S     LHilite         ; code = 2 -> invert cell
  83.                BPL.S     LDefExit         ; other calls not needed here
  84.  
  85. ;---------------
  86. ; LInit
  87. ; Here is the code that does the initialization for this defproc
  88.  
  89. LInit
  90.  
  91. ; just set up our indent
  92.  
  93.                SUBQ     #8,SP             ; make room for GetFontInfo record
  94.                MOVE.L     SP,-(SP)         ; point to it
  95.                _GetFontInfo             ; and go get info
  96.  
  97.                MOVE.W     (SP),indent+v(A3)   ; indent.v := ascent
  98.                MOVE.W     #4,indent+h(A3)     ; indent.h := 4
  99.                ADDQ     #8,SP             ; fix up stack
  100. LDefExit
  101.                MOVEM.L     (SP)+,D3-D7/A2-A4   ; restore the usual stuff
  102.                UNLK     A6             ; unlink our frame
  103.                MOVE.L     (SP)+,A0         ; get return address
  104.                ADD.L     #LParamSize,SP         ; strip off parameters
  105.                JMP     (A0)             ; and return
  106.  
  107. ;---------------
  108. ; LHilite -- Here is the code that hilights/unhilights the
  109. ; cell.     We know that it's drawn, and that we're only called
  110. ; if it needs to be de/selected, so inverrect is all we need.
  111.  
  112. LHilite
  113.                MOVE.L     LstRect(A6),-(SP)   ; push rect
  114.                _InverRect             ; and invert it
  115.                BRA.S     LDefExit         ; all done
  116.  
  117. ;---------------
  118. ; LstDraw -- Here is the code that does the drawing
  119. ; for the defProc.
  120.  
  121. LstDraw
  122.                MOVE.L     LstRect(A6),A4         ; get rect into A4
  123.                MOVE.L     topLeft(A4),-(SP)   ; move pen to indent point
  124.                MOVE.L     indent(A3),-(SP)
  125.                PEA     4(SP)
  126.                _AddPt
  127.                _MoveTo
  128.  
  129. ; use default text mode
  130.  
  131.                _PenNormal
  132.  
  133.                MOVE.L     cells(A3),A2          ; get data handle
  134.                MOVE.B     (A2),-(SP)          ; save current state
  135.                BSET     #lock,(A2)          ; and lock it
  136.  
  137.                MOVE.L     A4,-(SP)          ; clear out the rect
  138.                _EraseRect
  139.  
  140.                MOVE.W     LDataLen(A6),D3      ; anything to draw?
  141.                BLE.S     @1              ; =>nope, don't draw
  142.  
  143.                MOVE.L     (A2),-(SP)          ; point to the text
  144.                MOVE.W     LDataOffset(A6),-(SP)      ; offset to first byte
  145.                MOVE.W     D3,-(SP)          ; and number of bytes
  146.                _DrawText
  147. @1
  148.                TST.B     LSelect(A6)          ; selected?
  149.                BEQ.S     @0
  150.                MOVE.L     A4,-(SP)          ; push rect
  151.                _InverRect              ; and invert it
  152. @0
  153.                MOVE.B       (SP)+,(A2)          ; restore lock state
  154.                BRA.S       LDefExit          ; and return
  155.  
  156.  
  157.                .END
  158.