home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / lang / listmana.sha / ldproc0.asm next >
Assembly Source File  |  1986-07-10  |  5KB  |  172 lines

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