Titled border

Hi folks,

I have a few ListBox controls in my small app, and I wanted to put a
kind of title above each of them.
The easiest and somehow best looking solution I had thought of, was a
kind of border around the ListBox which would have some text at it’s
top. ( for instance like:
http://www.cloudgarden1.com/swing_tutorial/titled_border.png the left
circle ).

Is there anything like that in the API? I had a look but couldn’t find
anything…

Regards,
Pierre

Hi Pierre

Pierre P. wrote:

The control you want is Wx::StaticBox (and also see Wx::StaticBoxSizer)

http://wxruby.rubyforge.org/doc/staticbox.html

a

Alex F. wrote:

Hi Pierre

Pierre P. wrote:

The control you want is Wx::StaticBox (and also see Wx::StaticBoxSizer)

http://wxruby.rubyforge.org/doc/staticbox.html

a

Thanks Alex, that was indeed the control I was looking for!
Yet, somehow, I quite didn’t get how to use it.
For instance if if I want to add an other control in it (ListBox,
StaticText, whatever), it’ll also be in the top-left corner on the top
of the border, instead of in it’s center.
I guess I’m missing something really basic, I just couldn’t figure out
yet what.

Awesome Alex!
Thank to you it looks like I’ll have a great and productive day today
:slight_smile:

Big thanks

Pierre P. wrote:

Thanks Alex, that was indeed the control I was looking for!
Yet, somehow, I quite didn’t get how to use it.
For instance if if I want to add an other control in it (ListBox,
StaticText, whatever), it’ll also be in the top-left corner on the top
of the border, instead of in it’s center.

With Sizer-based layouts (recommended) I’ve found it easier to use
Wx::StaticBoxSizer to get a label round controls. I probably should have
pointed you at this first. See the simple example below:

alex
__

require ‘wx’

Wx::App.run do
frame = Wx::Frame.new(nil, :title => ‘staticbox demo’)
panel = Wx::Panel.new(frame)
sizer = Wx::StaticBoxSizer.new( Wx::VERTICAL, panel, ‘a label’)
sizer.add( Wx::ListBox.new(panel), 1, Wx::ALL|Wx::GROW, 5 )
panel.sizer = sizer
frame.show
end