JD Smith wrote:
> On Wed, 27 Sep 2006 15:42:43 +0200, Laurens wrote:
>
>> Hi,
>>
>> I have a couple of draw widgets displaying various gamma-scans. Now the
>> user has to select two of them by clicking on them; done.
>> But now I want to let the user know where he clicked, so is it possible
>> to draw some sort of red border of a few pix around the clicked
>> draw-widget? I know they have a frame property, but that's just too thin
>> and doesn't attract attention...
>
> You could make the frame thicker. Something like:
>
> IDL> b=widget_base(/ROW)
> IDL> t=widget_draw(b,xsize=200,ysize=200,FRAME=10)
> IDL> b2=widget_base(b,xsize=200,ysize=200,xpad=10,ypad=10,/COLUMN )
> IDL> t2=widget_draw(b2,xsize=200,ysize=200)
> IDL> widget_control, b,/realize
>
> Unfortunately with this setup, you'll have to kill and re-create
> everything whenever the user selects a new draw widget (since FRAME's
> are only possible when the widget is created). Not ideal. You'll
> probably want to use UPDATE=0/1 to avoid flickering.
>
> Here's a trick that avoids all that killing/recreating. Use a
> bulletin board base (no /ROW or /COLUMN), and then layer two bases
> inside it: one which holds your draw widget, offset by 10 pixels in x an
> y, and one empty base which has FRAME=10 set, whose only purpose in life
> is to display that frame. Simply map and unmap the empty draw base to
> add/remove the frame as necessary. Something like:
>
> IDL> b=widget_base()
> IDL> b1=widget_base(b,xsize=200,ysize=200,xpad=10,ypad=10)
> IDL> t=widget_draw(b1,xsize=200,ysize=200)
> IDL> b2=widget_base(b,xsize=200,ysize=200,FRAME=10)
> IDL> widget_control, b,/realize
> IDL> widget_control, b2,map=0 ; remove frame
> IDL> widget_control, b2,map=1 & widget_control, b1,map=1 ; add frame back
>
> To make it easier, wrap this functionality up in a compound
> "frame-toggle-draw" widget of some sort, and then layout as many of
> these as you need. I might instead make it an object widget for
> additional convenience (so I can pass it an image to draw, tell it to
> erase, etc.), but a regular compound widget would work as well. Then
> something like:
>
> widget_control,frame_toggle_draw_widget_id,SET_VALUE=0 ; turn frame off
>
> could be enough to "de-select" that draw.
>
> JD
>
Thanks very much for that explanation!
Could you tell me how to make such a widget-object? It sounds like
something I was already thinking about...
Laurens
|