Re: resizing draw widgets [message #7067] |
Mon, 23 September 1996 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
In article <526ajc$3h1@ruby.digisys.net>, "Arno F. Granados" <granados> wrote:
> Does anyone have a straightforward method for handling re-sizing of
> draw widgets (in particular scrollable widgets with a viewport
> smaller than the actual image) under UNIX. In particular, I want to be able
> to automatically deal with a user resizing the widget base that
> the draw widget is sitting on. I want my IDL base widgets to
> be fixed (where the user cannot change the size), and the draw widgets
> to either be fixed in size, or to automatically resize the viewport.
> I've tried using the TLB_FRAME_ATTR keyword when creating the base
> widgets, but it has no effect on my system (Solaris 2.4, IDL 4.0.1)
> Suggestions greatly appreciated.
Here is a straightforward example of handing the re-sizing of
draw widgets with scroll bars. I assume in this example
that the draw widget holds a image on a large canvas and
what the user wants is a larger scrollable area when he
resizes the graphics window.
This example can easily be extended to other kinds of IDL
graphics besides images. All you have to do is recreate the
graphic after the window is resized. (I have several flavors
of "smart" IDL graphics windows that can do this automatically
with any IDL graphics procedure. Email me if you want
more information about them.)
As far as I know, the TLB_FRAME_ATTR keyword does not
have any effect on the Solaris 2.4 operating system. You
can write a hack by setting up a resize event handler for
the top-level base you *don't* want to be resized, and
every time it is resized by the user, you set it back to
its original size.
Hope this gives you some ideas.
David
**************** Cut Here **********************
PRO DRAW_RESIZE, event
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
; Resize the draw widget viewport. Make sure it is not
; bigger than the drawing canvas.
xsize = event.x < info.canvasXsize
ysize = event.y < info.canvasYsize
WIDGET_CONTROL, info.drawid, XSIZE=xsize, YSIZE=ysize
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
END ; of ******************** DRAW_RESIZE event handler.
PRO EXAMPLE
; Use the heart example in IDL demo for big image.
file = FILEPATH(SUBDIR=['examples', 'data'], 'cereb.dat')
IF file NE '' THEN BEGIN
image = BYTARR(512, 512)
OPENR, lun, file, /GET_LUN
READU, lun, image
FREE_LUN, lun
image = REBIN(TEMPORARY(image), 1024, 1024)
ENDIF ELSE image = DIST(1024, 1024)
tlb = WIDGET_BASE(TITLE='Resize Example', TLB_SIZE_EVENTS=1)
drawID = WIDGET_DRAW(tlb, XSIZE=1024, YSIZE=1024, $
X_SCROLL_SIZE=256, Y_SCROLL_SIZE=256)
WIDGET_CONTROL, tlb, /REALIZE
WIDGET_CONTROL, drawID, GET_VALUE=wid
WSET, wid
TVSCL, image
info = { drawID: drawID, $
canvasXsize:1024, $
canvasYsize:1024}
WIDGET_CONTROL, tlb, SET_UVALUE=info, /NO_COPY
XMANAGER, 'example', tlb, EVENT_HANDLER='DRAW_RESIZE'
END
--
David Fanning, Ph.D.
Phone: 970-221-0438
Fax: 970-221-4728
E-Mail: davidf@fortnet.org
|
|
|