[futurebasic] Re: [FB] Appearance button ?s

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2003 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Sat, 15 Nov 2003 21:25:05 -0500
On Saturday, November 15, 2003, at 08:50  PM, Steve Crossman wrote:

> I want to create an appearance button to assign color selections. A 
> color well, or whatever you call it. I want to click on the button 
> which has a previous color selection defined and bring up the color 
> picker with that color.  I am always getting black.  My problem is how 
> to set the color picker to the color assigned to the button, and what 
> the proper button type should be.
>
> ~ steve

I don't know about the color wells that much , but if your pickers are 
not getting the right RGB-In color...

I sent you some code that works fine with appearance and OS X here.

If you are getting black, are you setting the RGB record from 0-65535 
and not 0-255?

See the below, work fine?


Robert

// FB3
// Appearance Color Picker Demo, Cheap.
// Can be made simpler, but for illustration...
// Don't whine about globals, you purist-rorists it's a demo
// and info like this needs persistence usually.

// Robert Covington

begin globals
DIM oneRect as Rect
DIM twoRect as Rect
DIM rgbIn1 as RGBColor
DIM rgbOut1 as RGBColor
DIM rgbIn2 as RGBColor
DIM rgbOut2 as RGBColor

_one = 0
_two = 1

end globals


Local FN PaintARect(which)

Long if which = _one
Long color rgbOut1.blue,rgbOut1.green,rgbOut1.red
Paintrect(OneRect)
xelse
Long color rgbOut2.blue,rgbOut2.green,rgbOut2.red
PaintRect(TwoRect)
end if
end fn

Local FN PickAColor(flag)
DIM @wherePt as point
DIM Msg$
DIM Picked as int

setPt(WherePt,50,50) // dummy setup

Msg$    = "Choose a color…"
long if flag
// 2 vars used for clarity...
Picked = FN GetColor (WherePt, Msg$, rgbIn2,rgbOut2)
rgbIn2 = rgbOut2// Reset InColor to match for next time
// that is, if you don't want to just use the same one variable.
xelse
Picked = FN GetColor (WherePt, Msg$, rgbIn1,rgbOut1)
rgbIn1 = rgbOut1 // Reset InColor to match for next time
// that is, if you don't want to just use the same one variable.
end if
if Picked then  FN PaintARect(flag)

End fn = picked


Local FN Setup

rgbIn1.red   = 65535
rgbIn2.green = 65535

rgbOut1 = rgbIn1
rgbOut2 = rgbIn2

Window 1,"Test Me",(0,0)-(400,400),_kDocumentWindowClass
SetRect(oneRect, 20,20,80,60)
twoRect = oneRect
offSetRect(twoRect,0,60)

End Fn

Local FN DoDialog
DIM evnt, id
evnt = Dialog(0)
id   = dialog(evnt)

Select evnt
case _wndRefresh
select id
case 1
FN PaintARect(_one)
FN PaintARect(_two)
end select
end select

End fn

Local FN DoMouse
DIM pt as point

GetMouse(pt)

long if FN PtInRect(pt,oneRect)
FN PickAColor(_One)
end if

long if FN PtInRect(pt,twoRect)
FN PickAColor(_Two)
end if

End fn

FN Setup

On mouse FN DoMouse
On dialog FN doDialog

do
handleEvents
until 0