home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / cdef-fjci-fb.hqx / CDEF-FJCI / Source for buttons / fiveButton.bas < prev    next >
Encoding:
BASIC Source File  |  1994-09-30  |  2.0 KB  |  83 lines

  1.  
  2. 'Copyright 1994 Robert Schenk
  3. RESOURCES "NewButton.rsc","rsrcRSED","CDEF",20,"FiveButtons",0
  4. COMPILE 0,4
  5.  
  6. DIM scratchRect;8
  7. DIM active%(5)
  8. "Entry"
  9. ENTERPROC%(varCode%, the Control&, message%, param&)
  10.   returnValue&=0
  11.   scratchRect;8= [theControl&]+_contrlRect
  12.   SELECT message%
  13.     CASE _drawCtlMsg
  14.       GOSUB "Draw Control"
  15.     CASE _hitCtlMsg
  16.       GOSUB "User Action"
  17.     CASE _calcCtlMsg
  18.       GOSUB "Calc Control Regions"
  19.   END SELECT
  20.   "Exit"
  21. EXITPROC%=returnValue&
  22. END
  23.  
  24. "Draw Control"
  25. ctlTitle$=PSTR$([theControl&]+_contrltitle)
  26. iconid=VAL(ctlTitle$)
  27.  
  28. LONG IF PEEK ([theControl&]+_contrlVis)
  29.   scratchRect.right=scratchRect.left+32
  30.   scratchRect.bottom=scratchRect.top+32
  31.   selector= PEEK([theControl&]+_contrlHilite)
  32.   active(4)=selector/16:selector=selector-active(4)*16
  33.   active(3)=selector/8:selector=selector-active(3)*8
  34.   active(2)=selector/4:selector=selector-active(2)*4
  35.   active(1)=selector/2::selector=selector-active(1)*2
  36.   active(0)=selector
  37.   selector= PEEK([theControl&]+_contrlHilite)
  38.   FOR i = 0 TO 4
  39.     id =iconid+5*i
  40.     LONG IF selector=255
  41.       Hndl&=    FN GETICON(id+2)
  42.       LONG IF Hndl&
  43.         CALL PLOTICON(scratchRect,Hndl&)
  44.       END IF
  45.     XELSE
  46.       LONG IF active(i)=1
  47.         Hndl&=    FN GETICON(id+1)
  48.         LONG IF Hndl&
  49.           CALL PLOTICON(scratchRect,Hndl&)
  50.         END IF
  51.       XELSE
  52.         Hndl&=    FN GETICON(id)
  53.         LONG IF Hndl&
  54.           CALL PLOTICON(scratchRect,Hndl&)
  55.         END IF
  56.       END IF
  57.     END IF
  58.     CALL OFFSETRECT(scratchRect,32,0)
  59.   NEXT i
  60. END IF
  61. RETURN
  62. "User Action"
  63. scratchRect.right=scratchRect.left+32
  64. scratchRect.bottom=scratchRect.top+32
  65. FOR i% = 0 TO 4
  66.   LONG IF FN PTINRECT(param&, scratchRect)      
  67.     returnValue&=1<<i%                           
  68.   END IF
  69.   CALL OFFSETRECT(scratchRect,32,0)
  70. NEXT i%
  71. i%=returnValue&
  72. POKE WORD ([theControl&]+_contrlValue), i%
  73. RETURN
  74.  
  75. "Calc Control Regions"
  76. scratchRect.right=scratchRect.left+160
  77. scratchRect.bottom=scratchRect.top+32
  78. CALL OPENRGN
  79. CALL FRAMERECT(scratchRect)
  80. CALL CLOSERGN(param&)
  81. RETURN
  82.  
  83.