home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 372.lha / PopUpMenu_3.2 / Source / Highlight.a < prev    next >
Text File  |  1990-05-06  |  5KB  |  198 lines

  1.            INCLUDE      "exec/types.i"
  2.            INCLUDE      "graphics/rastport.i"
  3.            INCLUDE      "intuition/intuition.i"
  4.            INCLUDE      "PopUpMenu.i"
  5.  
  6. _LVOSetDrMd    EQU      -$162
  7. _LVODraw       EQU      -$f6
  8. _LVOMove       EQU      -$f0
  9. _LVORectFill   EQU      -$132
  10.  
  11. BORDERSIZE     EQU      2
  12.  
  13.            xdef      @HighLightItem
  14.            xdef      @ToggleMenu
  15.  
  16.            xref      @DrawMenuItem
  17.  
  18.            section      text,code
  19.  
  20. ***************************************************
  21. * HighLightItem(Item, ItemWindow, Mode)           *
  22. *                          *
  23. * Input:                      *
  24. *   Item  -      Item to highlight.          *
  25. *   ItemWindow -  Data for the window to draw in. *
  26. *   Mode   -      HIGHLIGHTON or HIGHLIGHTOFF.      *
  27. * Output:                      *
  28. *   none                      *
  29. ***************************************************
  30. @HighLightItem:
  31.            MOVEM.L     D2-D7/A2-A3/A5-A6,-(SP)
  32.            MOVEA.L     A0,A3
  33.            MOVEA.L     A1,A2
  34.  
  35. * ------------ Possible to highlight item ?
  36.            MOVEQ.L     #ITEMENABLED,D1
  37.            AND.W     mi_Flags(A3),D1
  38.            BEQ.B     HighlightDone
  39.  
  40. * ------------ Start highlighting.
  41.            LEA     _Rp(A4),A5
  42.            MOVEA.L     _GfxBase(A4),A6
  43.  
  44.            MOVE.W     #HIGHFLAGS,D7
  45.            AND.W     mi_Flags(A3),D7
  46.            BNE.B     NotHighImage
  47.  
  48. * ------------ Invert Mode and call DrawMenuItem.
  49. * ------------ DrawMenuItem(Item, ItemWindow, !Mode,CLEAROLD);
  50. HighImage:     MOVEQ.L     #1,D1          * CLEAROLD
  51.            ADDQ.W     #1,D0
  52.            AND.W     D1,D0
  53.            JSR     @DrawMenuItem(PC)
  54.            BRA.B     HighlightDone
  55.  
  56. * ------------ Left   = Item->LeftEdge - ItemWindow->LeftValue
  57. NotHighImage:  MOVE.W     mi_LeftEdge(A3),D6
  58.            SUB.W     wd_LeftValue(A2),D6
  59.            EXT.L     D6
  60.  
  61. * ------------ Right  = Left + Item->Width
  62.            MOVE.W     mi_Width(A3),D5
  63.            EXT.L     D5
  64.            ADD.L     D6,D5
  65.  
  66. * ------------ Top    = Item->TopEdge - ItemWindow->TopValue
  67.            MOVE.W     mi_TopEdge(A3),D4
  68.            SUB.W     wd_TopValue(A2),D4
  69.            EXT.L     D4
  70.  
  71. * ------------ Bottom = Top + Item->Height
  72.            MOVE.W     mi_Height(A3),D3
  73.            EXT.L     D3
  74.            ADD.L     D4,D3
  75.  
  76. * ------------ Set drawmode = COMPLEMENT.
  77.            MOVEQ.L     #RP_COMPLEMENT,D0
  78.            MOVEA.L     A5,A1
  79.            JSR     _LVOSetDrMd(A6)
  80.  
  81. * ------------ Check out kind of highlighting.
  82. HighType:      CMPI.W     #HIGHBOX,D7
  83.            BEQ.B     HighBox
  84.            CMPI.W     #HIGHCOMP,D7
  85.            BNE.B     HighlightDone
  86.  
  87. * ------------ RectFill(Left, Top, Right - 1, Bottom - 1)
  88. HighComp:      MOVE.L     D6,D0
  89.            MOVE.L     D4,D1
  90.            MOVEA.L     A5,A1
  91.            MOVE.L     D5,D2
  92.            SUBQ.L     #1,D2
  93.            SUBQ.L     #1,D3
  94.            JSR     _LVORectFill(A6)
  95.            BRA.B     HighlightDone
  96.  
  97. * ------------ DrawRect(Left, Top, Right, Bottom)
  98. HighBox:       BSR.B     DrawRect
  99.  
  100. * ------------ DrawRect(Left - 1, Top - 1, Right + 1, Bottom + 1)
  101.            ADDQ.L     #1,D5
  102.            ADDQ.L     #1,D3
  103.            BSR.B     DrawRect
  104.  
  105. HighlightDone: MOVEM.L     (SP)+,D2-D7/A2-A3/A5-A6
  106.            RTS
  107.  
  108. * ------------ Draw a rectangle.
  109. * ------------ Move(--Left,Top).
  110. DrawRect:      SUBQ.L     #1,D6
  111.            MOVE.L     D6,D0
  112.            MOVE.L     D4,D1
  113.            MOVEA.L     A5,A1
  114.            JSR     _LVOMove(A6)
  115.  
  116. * ------------ Draw(Left,Bottom).
  117.            MOVE.L     D6,D0
  118.            MOVE.L     D3,D1
  119.            BSR.B     Draw
  120.  
  121. * ------------ Draw(Right,Bottom).
  122.            MOVE.L     D5,D0
  123.            MOVE.L     D3,D1
  124.            BSR.B     Draw
  125.  
  126. * ------------ Draw(Right,--Top).
  127.            SUBQ.L     #1,D4
  128.            MOVE.L     D5,D0
  129.            MOVE.L     D4,D1
  130.            BSR.B     Draw
  131.  
  132. * ------------ Draw(Left,Top).
  133.            MOVE.L     D6,D0
  134.            MOVE.L     D4,D1
  135.  
  136. Draw:           MOVEA.L     A5,A1           * Get RastPort
  137.            JMP     _LVODraw(A6)
  138.  
  139. *********************************************
  140. * ToggleMenu(Number,Menu)                   *
  141. *                        *
  142. * Input:                    *
  143. *   Number - Menu to highlight.         *
  144. *   Menu   - Pointer to the Menu structure. *
  145. * Output:                    *
  146. *   none                    *
  147. *********************************************
  148. @ToggleMenu    MOVEM.L     D2-D3/A6,-(A7)
  149.  
  150. * ------------ Menu enabled ?
  151.            MOVEQ.L     #MENUENABLED,D2
  152.            AND.W     mu_Flags(A0),D2
  153.            BEQ.B     ToggleDone
  154.  
  155.            MOVE.W     D0,D3
  156.  
  157. * ------------ Set drawmode = COMPLEMENT.
  158.            LEA     _Rp(A4),A1
  159.            MOVEQ     #RP_COMPLEMENT,D0
  160.            MOVEA.L     _GfxBase(A4),A6
  161.            JSR     _LVOSetDrMd(A6)
  162.  
  163. * ------------ Invert menu.
  164. * ------------ Bottom = Number * MenuFontSize + MenuWindow.TopEdge.
  165.            MOVE.W     _MenuFontSize(A4),D2
  166.            MULU.W     D2,D3
  167.            ADD.W     _MenuWindow+wd_TopEdge(A4),D3
  168.  
  169. * ------------ Top = Bottom - MenuFontSize + BORDERSIZE.
  170.            MOVE.L     D3,D1
  171.            SUB.L     D2,D1
  172.            ADDQ.L     #BORDERSIZE,D1
  173.  
  174. * ------------ Left = MenuWindow.LeftEdge + BORDERSIZE.
  175.            MOVEQ.L     #BORDERSIZE,D0
  176.            ADD.W     _MenuWindow+wd_LeftEdge(A4),D0
  177.  
  178. * ------------ Right = MenuWindow.RightEdge - BORDERSIZE.
  179.            MOVE.W     _MenuWindow+wd_RightEdge(A4),D2
  180.            SUBQ.L     #BORDERSIZE,D2
  181.  
  182.            LEA     _Rp(A4),A1
  183.            JSR     _LVORectFill(A6)
  184.  
  185. ToggleDone     MOVEM.L     (A7)+,D2-D3/A6
  186.            RTS
  187.  
  188.  
  189.            section     __MERGED,bss
  190.  
  191.            xref     _Rp
  192.            xref     _GfxBase
  193.            xref     _MenuFontSize
  194.            xref     _MenuWindow
  195.  
  196.            END
  197.  
  198.