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

Home » Public Forums » archive » changing font type on a widget
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
changing font type on a widget [message #63047] Thu, 23 October 2008 11:49 Go to next message
cgoethel is currently offline  cgoethel
Messages: 20
Registered: April 2008
Junior Member
Hi All,

How do I change the font and size of text on a button (or other
widget)? For example...

myButton = Widget_Button(myBase, value='Test')

How can I change 'Test' to say 'Times' and increase it's size by 2.
What are the size units?

Thanks!

Cindy
Re: changing font type on a widget [message #63074 is a reply to message #63047] Tue, 28 October 2008 13:33 Go to previous message
Chad is currently offline  Chad
Messages: 9
Registered: January 2008
Junior Member
On Oct 23, 2:49 pm, cgoet...@igpp.ucla.edu wrote:
> Hi All,
>
> How do I change the font and size of text on a button (or other
> widget)? For example...
>
>    myButton = Widget_Button(myBase, value='Test')
>
> How can I change 'Test' to say 'Times' and increase it's size by 2.
> What are the size units?
>
> Thanks!
>
> Cindy

You can do all of the above with bitmap buttons. Write your text to a
bitmap using xyouts. Here is a code snippet from a routine of mine.
The text string you want is in 'text'. You should be able to control
the size with CharSize in XYOUTS, although I haven't tested that
particular option - there may be sizing conflicts with the multi-line
options.

Chad

wtlb = WIDGET_BASE()
wbtn = WIDGET_BUTTON(wtlb)
font = WIDGET_INFO(wbtn, /FontName)
WIDGET_CONTROL, wtlb, /Destroy
ss = GET_SCREEN_SIZE()
WINDOW, XSize=ss[0], YSize=ss[1], /Pixmap, /Free
DEVICE, Set_Font=font
nlines = N_ELEMENTS(text)
ysize = (!D.Y_CH_SIZE * nlines) < ss[1]
xx = FLTARR(nlines)
FOR i=0, nlines-1 DO BEGIN
XYOUTS, 0, 0, text[i], /Device, Font=0, CharSize=-1,
Width=xsize
xx[i] = xsize
XYOUTS, 0, 0, STRTRIM(text[i], 2), /Device, Font=0,
CharSize=-1, Width=xsize
ENDFOR
xsize = MAX(xx)*!D.X_VSIZE < ss[0]
xoffset = FLTARR(nlines)
FOR i=0, nlines-1 DO BEGIN
XYOUTS, 0, 0, STRTRIM(text[i], 2), /Device, Font=0,
CharSize=-1, Width=xo
xoffset[i] = (xsize - (xo*!D.X_VSIZE))/2
ENDFOR
WDELETE, !D.Window
border = 2
WINDOW, XSize=xsize + border*2, YSize=ysize + (nlines*border ) +
border, /PixMap, /Free
ERASE, 255
FOR i=0, nlines-1 DO $
XYOUTS, border + xoffset[i], !D.Y_SIZE - ( (i+1) * (border+!
D.Y_CH_SIZE) ), $
STRTRIM(text[i], 2), /Device, Font=0, Color=0
b = TVRD()
WDELETE, !D.Window
r = b
g = b
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Where the heck is the IDL Virtual Machine?
Next Topic: Re: FFT OF A NON RECTANGULAR IMAGE

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

Current Time: Wed Oct 08 19:24:09 PDT 2025

Total time taken to generate the page: 0.00573 seconds