ListBox's overlapping

Guys,

I have a bug which I can’t solve at the moment. I tried various
solutions, changing the sizers and lots of different ways, I still
couldn’t fix it.

In my code, I have basically two ListBox in the same panel, one above
the other.
When the upper ListBox has too many elements, I have a nice scroll bar,
and looks good. But When I resize my complete frame, it draws itself
over the bottom one, and I can’t see it anymore. And the scroll bar is
even gone, so I can’t even see all the elements.

Here is my code:

def initialize title, xml_h
super(nil, -1, title)
@xml_helper = xml_h

global_sizer = BoxSizer.new(VERTICAL)

@top_p = Panel.new(self)
@bottom_p = Panel.new(self)

global_sizer.add(@top_p, 3, GROW|ALL, 2)
global_sizer.add(@bottom_p, 1, GROW|ALL, 2)

top_sizer = BoxSizer.new(HORIZONTAL)
@m_list = ListBox.new(@top_p, -1, DEFAULT_POSITION, DEFAULT_SIZE,
@xml_helper.get_magicians, LB_SINGLE|LB_SORT|DOUBLE_BORDER)
evt_listbox @m_list, :on_magician_pressed
top_sizer.add(@m_list,1, GROW|ALL, 2)

@mc = MediaCtrl.new(@top_p)
evt_media_loaded @mc,:on_media_loaded
top_sizer.add(@mc, 3, GROW|ALL, 2)

right_sizer = GridSizer.new(2, 0, 2, 2)

right_p = Panel.new(@top_p)
right_p.fit
right_p.set_sizer right_sizer
@v_list = ListBox.new(right_p, -1, DEFAULT_POSITION, DEFAULT_SIZE, [],
LB_SINGLE)
evt_listbox @v_list, :on_video_pressed
right_sizer.add @v_list

@t_list = ListBox.new(right_p, -1, DEFAULT_POSITION, DEFAULT_SIZE, [],
LB_SINGLE)
evt_listbox @t_list, :on_trick_pressed
right_sizer.add @t_list
top_sizer.add(right_p, 1, ALIGN_RIGHT, 2)
@top_p.sizer = top_sizer
self.sizer = global_sizer
show
end

Note that the @bottom_p isn’t used, but will be later, once I have fixed
that.
So the problematic code lies with the right_sizer and the right_p (p for
Panel)
The @v_list is the upper ListBox and @t_list is the bottom one.

Appreciate the help,

Pierre

Hi Pierre

Pierre P. wrote:

Here is my code:

def initialize title, xml_h

[ … ]

I’m afraid that most people who might be able to help with this don’t
have time to work through a long snippet this copied straight from an
application, and figure out what’s going on. If you want help with code,
please reduce it to a bare minimum that runs on its own, and
demonstrates just the problem. Please see the guidelines here:

http://wxruby.rubyforge.org/wiki/wiki.pl?MailingLists

The kind of problem you describe with items overlapping is usually
caused by failing to add some control to a sizer, or adding it to the
wrong sizer (eg not one belonging to its parent). I would check through
the controls for this. Perhaps also consider using or at least
prototyping using an XRC editor like DialogBlocks for layouts, which can
really help understanding sizers.

Lastly I suggest also reading the Style Guide, which will help you
structure and write wxRuby code in a more readable way:

http://wxruby.rubyforge.org/wiki/wiki.pl?StyleGuide

hth
alex

Alex,

Thanks again for this reply as well.
Actually, I have fixed that issue, by simplifying the behavior (not 100%
what I wanted) and also changing the sizer.

Thanks also for that Style Guide, it will definitely help me.

Cheers!