comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Image wallpapered GUI
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Image wallpapered GUI [message #13710 is a reply to message #13682] Fri, 04 December 1998 00:00 Go to previous message
harald is currently offline  harald
Messages: 5
Registered: October 1998
Junior Member
On Thu, 3 Dec 1998 19:13:50 -0600, "T Bowers"
<tbowers@nrlssc.navy.mil> wrote:

> Hi all,
>
> I'm trying to create a simple GUI that is a form "wallpapered" with
> a .gif image, and a few buttons running down the form (a column of
> buttons, if you will) that are centered. Sounds easy enough. First, I
> thought
> I'd try cw_form(), but theres no way to assign it a background image. So I
> thought
> I'd be cute and create a baseWidget, then a widget_draw(baseWidget) to hold
> my image.gif, then just center my widget_button(baseWidget)'s (or a
> cw_bgroup())
> on that draw widget. Well... it isn't so easy. I can't use /column with my
> baseWidget
> so that I can take advantage of the align_center keyword or it'll put the
> image lined up
> below the buttons. The only way I can get the buttons to appear on top of
> the image
> is to *not* specify the /column keyword for baseWidget, but then the buttons
> appear
> on the top/left side and there's no way to align them to center. Hardcoding
> the offsets
> in there is not an option. The only other way I can think of doing it is to
> do the math
> on the x and y sizes of my widgets so I can place my buttons in the center
> of the draw
> widget, but I can't do this cause I can't find a way to access the
> dimensions of the damned
> widgets.
>
> ... (code section snipped)

Hello Todd,

To get the proper size of the widgets you have to realize them before.
Afterwards you can use the WIDGET_INFO(/GEOMETRY) function to retrieve
the size of a special widget.

Try the code below (event handler not implemented):

;
; Simple GUI program using a GIF image as wallpaper.
;

PRO SimpleGUI

; use color tables on my 24-bit display

DEVICE, DECOMPOSED=0

; read image

READ_GIF, "image.gif", bkgrnd, r, g, b

; create widget hierarchy

mainBase = WIDGET_BASE(MAP=0)

; create button base

buttonBase = WIDGET_BASE(mainBase, /COLUMN, XPAD=0, YPAD=0,
SPACE=0)

button1 = widget_button(buttonBase, value="Button1")
button2 = widget_button(buttonBase, value="Button2")
button3 = widget_button(buttonBase, value="Button3")

; detect image size and create background draw widget

info = SIZE(bkgrnd)
xsize = info[1]
ysize = info[2]

draw = WIDGET_DRAW(mainBase, XSIZE=xsize, YSIZE=ysize)

; realize the widget hierarchy to size the widgets

WIDGET_CONTROL, mainBase, /REALIZE

; now you can get the size of the button base and display it at
; the center of the background draw widget

info = WIDGET_INFO(buttonBase, /GEOMETRY)
xoff = (xsize - info.SCR_XSIZE)/2
yoff = (ysize - info.SCR_YSIZE)/2

WIDGET_CONTROL, buttonBase, XOFFSET=xoff, YOFFSET=yoff

; display background image and show GUI

TV, bkgrnd
WIDGET_CONTROL, mainBase, /MAP

XMANAGER, "SimpleGUI", mainBase, /NO_BLOCK

END ; SimpleGUI

;
; End of code section.
;


Regards,
Harald

------------------------------------------------------
Harald Jan Jeszenszky
harald@iwf.tu-graz.ac.at

Space Research Institute
Austrian Academy of Sciences
------------------------------------------------------
[Message index]
 
Read Message
Read Message
Previous Topic: Re: New dollar coin designed using IDL (please vote)
Next Topic: Message command output sent to Journal file?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 13:23:12 PDT 2025

Total time taken to generate the page: 1.75957 seconds