home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / defproc / ldefproc.hqx / LDefProc0.A
Encoding:
Text File  |  1990-03-05  |  7.0 KB  |  229 lines

  1. ;EASE$$$ READ ONLY COPY of file ╥LDefProc0.A╙
  2. ; 1.0    CCH 11/16/1988 Added to EASE.
  3. ; END EASE MODIFICATION HISTORY 
  4. ; File LDefProc0.a
  5. ;-------------------------------------------------------------
  6. ;
  7. ; Standard List Definition Procedure for simple text
  8. ;
  9. ;      Ernie Beernink  March 1985
  10. ;
  11. ; This is the standard List defProc.  Its primary task is to draw
  12. ; the contents of a list manager cell, either selected or deselected.
  13. ; It is passed a pointer to the cell's data, the length of the cell's
  14. ; data, and a rectangle in which to draw the cell.  When it is called,
  15. ; the clip region is set to that rect.  The cell data does NOT include a
  16. ; length byte.
  17. ;
  18. ; MODIFICATION HISTORY:
  19. ; S3    05Jan87    JTC    32-bit support changes.
  20. ;
  21. ;        version $0001
  22. ;         8jun87 sad color hilighting, trucation (conditional)
  23. ;-------------------------------------------------------------
  24.  
  25.  
  26.                BLANKS         ON
  27.                STRING         ASIS
  28.  
  29. ;                LOAD          'sysallqk.d'
  30.                 LOAD          'nequ.d'
  31.                 INCLUDE        'SysEqu.a'
  32.                 INCLUDE        'Traps.a'
  33.                 INCLUDE        'QuickEqu.a'
  34.                 INCLUDE        'PackMacs.a'
  35.  
  36. truncate    equ 0    ; truncation off
  37.  
  38. LDEF0          PROC      EXPORT
  39.  
  40. ; PROCEDURE    DrawCell(LMessage:INTEGER; LSelect:BOOLEAN; LRect:Rect; LCell: Cell;
  41. ;                LDataOffset, LDataLen:INTEGER; LHandle:Handle);
  42.  
  43. ; Message equates:
  44.  
  45. ;InitMsg        .EQU      0              ; tell drawing routines to init themselves
  46. ;DrawMsg        .EQU      1              ; draw (and de/select) the indicated data
  47. ;HiliteMsg      .EQU      2              ; de/select the indicated data
  48. ;CloseMsg       .EQU      3              ; shut down, the list is being disposed
  49.  
  50. ; Stack Frame definition for ListDefProc 0
  51.  
  52. LHandle           EQU      8             ; Handle to list data record
  53. LDataLen       EQU      LHandle+4         ; length of data
  54. LDataOffset    EQU      LDataLen+2         ; offset to data
  55. LCell           EQU      LDataOffset+2         ; cell that was hit
  56. LRect           EQU      LCell+4         ; rect to draw in
  57. LSelect           EQU      LRect+4         ; 1=selected, 0=not selected
  58. LMessage       EQU      LSelect+2         ; 0=Init, 1=Draw, 2=Hilite, 3=Close
  59. LParamSize     EQU      LMessage+2-8         ; # of bytes of parameters
  60.  
  61.                BRA.S     @0             ; enter here
  62.  
  63. ; standard header
  64.  
  65.                DC.W      0            ; flags word
  66.                DC.B      'LDEF'    ; type
  67.                DC.W      0         ; ID
  68.                DC.W      $0001        ; version
  69. @0
  70.                LINK     A6,#0             ; set up a stack frame
  71.                MOVEM.L     D3-D7/A2-A4,-(SP)   ; save the usual stuff
  72.                MOVE.L     LHandle(A6),A4         ; get handle to list record
  73.                MOVE.L     (A4),A3         ; get pointer to (locked) record
  74.  
  75.                MOVE.W     LMessage(A6),D0     ; why am I being called?
  76.  
  77.                SUBQ     #1,D0             ; check next in line
  78.                BEQ.S    ListDraw        ; code = 1 -> draw cell
  79.                SUBQ     #1,D0             ; check next
  80.                BEQ.S     LHilite         ; code = 2 -> invert cell
  81.                BPL.S     LDefExit         ; other calls not needed here
  82.  
  83. ;---------------
  84. ; LInit
  85. ; Here is the code that does the initialization for this defproc
  86.  
  87. LInit
  88.  
  89. ; just set up our indent
  90.  
  91.                SUBQ     #8,SP             ; make room for GetFontInfo record
  92.                MOVE.L     SP,-(SP)         ; point to it
  93.                _GetFontInfo             ; and go get info
  94.  
  95.                MOVE.W     (SP),indent+v(A3)   ; indent.v := ascent
  96.                MOVE.W     #4,indent+h(A3)     ; indent.h := 4
  97.                ADDQ     #8,SP             ; fix up stack
  98. LDefExit
  99.                MOVEM.L     (SP)+,D3-D7/A2-A4   ; restore the usual stuff
  100.                UNLK     A6             ; unlink our frame
  101.                MOVE.L     (SP)+,A0         ; get return address
  102.                ADD.L     #LParamSize,SP         ; strip off parameters
  103.                JMP     (A0)             ; and return
  104.  
  105. ;---------------
  106. ; LHilite -- Here is the code that hilights/unhilights the
  107. ; cell.     We know that it's drawn, and that we're only called
  108. ; if it needs to be de/selected, so inverrect is all we need.
  109.  
  110. LHilite
  111.                bclr        #7,HiliteMode        ; now in color! <8jun87>
  112.                MOVE.L     LRect(A6),-(SP)     ; push rect
  113.                _InverRect             ; and invert it
  114.                BRA.S     LDefExit         ; all done
  115.  
  116. ;---------------
  117. ; ListDraw -- Here is the code that does the drawing
  118. ; for the defProc.
  119.  
  120. ListDraw
  121.             MOVE.L    LRect(A6),A4        ; get rect into A4
  122.             MOVE.L    topLeft(A4),-(SP)    ; move pen to indent point
  123.             MOVE.L    indent(A3),-(SP)
  124.             PEA        4(SP)
  125.             _AddPt
  126.             _MoveTo
  127.  
  128. ; use default text mode
  129.  
  130.             _PenNormal
  131.  
  132.             MOVE.L     cells(A3),A2        ; get data handle
  133.             MOVEA.L    A2,A0                ; data handle            <S3>
  134.             TST.W    ROM85                ; old ROMs?                <S3>
  135.             BMI.S    @oldROMs            ; MI means old            <S3>
  136.             _HGetState                    ; D0 := lock state        <S3>
  137.             MOVE.B    D0,-(SP)            ; save lock state        <S3>
  138.             BRA.S    @oldEnd                ; skip over old way        <S3>
  139. @oldROMs                                ;                        <S3>
  140.             MOVE.B    (A0),-(SP)            ; save lock state old way<S3>
  141. @oldEnd                                    ;                        <S3>
  142.             _HLock                        ; lock across QD calls    <S3>
  143.  
  144.             MOVE.L    A4,-(SP)            ; clear out the rect
  145.             _EraseRect
  146.  
  147.             MOVE.W    LDataLen(A6),D3        ; anything to draw?
  148.             BLE.S    @nodraw                ; =>nope, don't draw <22jul87 sad>
  149.  
  150.  if truncate then                        ; <22jul87 sad> to endif
  151.              MOVE.L    (a2),d6                ; d6.l = ptr to the text <22jul87 sad>
  152.             MOVE.W    LDataOffset(a6),d5    ; d5.w = offset to first byte of this cell <22jul87 sad>
  153.  
  154.     ; calculate avail width
  155.             move    right(a4),d7
  156.             sub        left(a4),d7
  157.             sub        indent+h(a3),d7        ; left indent
  158.             sub        #1,d7                ; right indent
  159.  
  160.             moveq    #0,d4                ; no trunc yet
  161.  
  162. @truncloop
  163.             sub        #2,sp
  164.             move.l    d6,-(sp)
  165.             move    d5,-(sp)
  166.             move    d3,-(sp)
  167.             _TextWidth
  168.             cmp        (sp)+,d7            ; will string fit?
  169.             bge.s    @truncout            ; yes, leave
  170.                 ; no, truncate by one char
  171.             tst.b    d4                    ; truncated any yet?
  172.             bnz.s    @3                    ; yes, just drop a char
  173.                 ; no, add elipsis and drop a character
  174.             sub        #2,sp
  175.             move    #'╔',-(sp)
  176.             _CharWidth
  177.             sub        (sp)+,d7
  178.             moveq    #1,d4                ; remember that we have truncated
  179. @3
  180.             sub        #1,d3                ; drop the last character
  181.             bz.s    @nodraw                ; no more chars
  182.             bra.s    @truncloop
  183.             
  184. @truncout
  185.  
  186.             MOVE.L    d6,-(sp)            ; point to the text
  187.             MOVE.W    d5,-(sp)            ; offset to first byte of this cell
  188.  else
  189.              MOVE.L    (A2),-(SP)            ; point to the text
  190.             MOVE.W    LDataOffset(A6),-(SP)    ; offset to first byte
  191.  endif                ; end <22jul87 sad>
  192.             MOVE.W    D3,-(SP)            ; and number of bytes
  193.             _DrawText
  194.  
  195.  if truncate then                        ; <22jul87 sad> to endif
  196.              tst.b    d4                    ; truncated any?
  197.             bz.s    @noelipsis            ; no, don╒t draw elipsis
  198.                 ; yes
  199.             move    #'╔',-(sp)
  200.             _DrawChar
  201. @noelipsis
  202.  endif                                    ; end <22jul87 sad>
  203.  
  204. @nodraw                ; <22jul87 sad>
  205.             MOVEA.L    A2,A0                ; data handle            <S3>
  206.             TST.W    ROM85                ; do we have new ROMs?    <S3>
  207.             BMI.S    @old2ROMs            ; MI means no, do it the old way    <S3>
  208.             MOVE.B    (SP)+,D0            ; saved lock state        <S3>
  209.             _HSetState                    ; stuffed back to handle<S3>
  210.             BRA.S    @old2End            ;                        <S3>
  211. @old2ROMs                                ;                        <S3>
  212.             MOVE.B    (SP)+,(A0)            ; restore lock state
  213. @old2End                                ;                        <S3>
  214.  
  215.             TST.B    LSelect(A6)            ; selected? <22jul87 sad>
  216.  if truncate then
  217.             bnz        LHilite                ; yes <22jul87 sad>
  218.  else
  219.             bnz.s    LHilite                ; yes <22jul87 sad>
  220.  endif
  221.                 ; no <22jul87 sad>
  222.  if truncate then
  223.             BRA        LDefExit            ; and return <22jul87 sad>
  224.  else
  225.             BRA.S    LDefExit            ; and return
  226.  endif
  227.  
  228.             END
  229.