
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM |
TEXT
Display a focus border with Edit Fields
"Foucus Ring", or a border of the EditText can draw `DrawTgeneEditTextFrame' function of Appearance Manager. Or, in case, you set focus to control using "SetKeyboardFoucus", it will be handled automatically.
With Appearance 1.1 or later, you can get "GetThemeBrushAsColor" with kTheBrushFocusHighlight, or set your own color using "SetThemeBrush".
For more details:
http://developer.apple.com/techpubs/macos8/HumanInterfaceToolbox/humaninterfacetoolbox.html
http://developer.apple.com/macos/8.5.html#toolbox
Tempolary, I write following routine with Mel's code.
Essentially, border color should be obtaim from Appearance Manager.
_darkenValue = -16383
_lightenValue = 16383
LOCAL MODE
LOCAL FN ShiftColor(@cPtr&,amt%) ' In Areal PANL.FLTR
` move.l ^cPtr&,A0
` beq exit ; nil pointer check
` move.w ^amt%,D2 ; set up remaining registers
` ext.l D2
` moveq.w #2,D0 ; init loop count
`startshiftloop
` clr.l D1
` move.w (A0),D1
` add.l D2,D1 ; shift color value by amount
`testlowerlimit
` cmpi.l #0,D1 ; ck if d1 = 0
` bge testupperlimit ; if the value is OK, skip next check
` move.l #0,D1 ; reset it to zero
`testupperlimit
` cmpi.l #$FFFF,D1 ; compare value to FFFF
` ble endshiftloop ; if the value is OK, skip next step
` move.l #$0000FFFF,D1 ; set it to max
`endshiftloop
` move.w D1,(A0)+ ; copy final value into destination
` dbra D0,startshiftloop
`exit
END FN
LOCAL
"Broder"
` dc.w $6666,$6666,$9999
LOCAL FN threeDFX(whichEF)
DIM t,l,b,r
DIM oldColor.rgbColor
DIM bkColor.rgbColor
DIM efH&
LONG IF SYSTEM (_maxColors) >= 32
CALL GETFORECOLOR (oldColor.red%)
efH& = TEHANDLE (whichEF)
LONG IF efH&
t;8 = [efH&]
CALL INSETRECT (t,-4,-4)
CALL PENNORMAL
LONG IF whichEF = WINDOW (_efNum)
CALL RGBFORECOLOR (#LINE "Broder")
CALL FRAMEROUNDRECT (t,4,4)
CALL INSETRECT (t,1,1)
CALL FRAMERECT (t)
XELSE
CALL GETBACKCOLOR (bkColor.red%)
CALL RGBFORECOLOR (bkColor.red%)
CALL FRAMEROUNDRECT (t,4,4)
CALL INSETRECT (t,1,1)
DEC (b) : DEC (r)
FN ShiftColor(bkColor.red%,_lightenValue)
CALL RGBFORECOLOR (bkColor.red%)
PLOT r,t TO r,b TO l,b
CALL GETBACKCOLOR (bkColor.red%)
FN ShiftColor(bkColor.red%,_darkenValue)
CALL RGBFORECOLOR (bkColor.red%)
PLOT TO l,t TO r,t
END IF
END IF
CALL RGBFORECOLOR (oldColor.red%)
END IF
END FN
By layering edit fields (placing static type down first) it is possible to achieve a result very similar to your "focus ring":
WINDOW 1,"Cmd.period to Quit",(30,40)-(400,300)
FOR numColor% = 1 TO 7
COLOR numColor%
EDIT FIELD#100,"",(60,60)-(290,120),197 'Static rounder,boldBox
COLOR _zblack
EDIT FIELD#1,"",(64,64)-(286,116),2,2
DELAY 1500
NEXT
DO
HANDLEEVENTS
UNTIL 0
Color selection may be increased by substituting LONG COLOR blue%, green%, red% for the first COLOR statement.
|