Setting up wxWindows using XRC files?

3 views
Skip to first unread message

bobpitbull

unread,
Dec 15, 2009, 12:02:16 PM12/15/09
to wx-users
Hey All,

I’m trying to set up a very simple window – due to implementation, I
need to do it through a .xrc file...

What I want is to have a wxTreeCtrl on the left side of the window
(non-editable) and a scrollable (editable part) on the right side...

Right now here’s what I have:-

<object class="wxPanel" name="ID_PANEL_MYBROWSER">
<title>My Browser</title>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<flag>wxGROW|wxALL</flag>
<option>1</option>
<object class="wxTreeCtrl" name="IDTC_MyTreeControl”>
<size>300,1000</size>
<style>wxTR_HAS_BUTTONS|wxTR_ROW_LINES|wxTR_MULTIPLE</
style>
</object>
</object>
<object class="sizeritem">
<flag>wxGROW|wxALL</flag>
<option>1</option>
<object class="wxScrolledWindow" name="IDSW_PROPERTIES">
<size>450,1000</size>
<style>wxHSCROLL|wxVSCROLL</style>
</object>
</object>
</object>
</object>

The RHS of the window is completely wrong ... it’s offsetting the
ScrolledWindow portion such that, when the window first appears, it’s
nearly off screen...? So there’s just a large, blank area to the right
of my tree control...

Can anyone advise on the correct way to setup the sizing? And anything
else wrong with the above..?

Robert

PS. I can’t find any documentation for <option> but it seems to be
littered all over our codebase... can someone explain what it’s for?

Vadim Zeitlin

unread,
Dec 15, 2009, 4:07:36 PM12/15/09
to wx-u...@googlegroups.com
On Tue, 15 Dec 2009 09:02:16 -0800 (PST) bobpitbull <bobpi...@gmail.com> wrote:

b> I’m trying to set up a very simple window – due to implementation, I
b> need to do it through a .xrc file...

But you don't need to create XRC file by hand, most people prefer to use a
dialog editor for it. Of course, there is absolutely nothing wrong with
writing it manually neither, this is what I personally do. But if you don't
know the meaning of "option" tag, it's probably better to start
experimenting with the GUI tools.

b> PS. I can’t find any documentation for <option> but it seems to be
b> littered all over our codebase... can someone explain what it’s for?

The documentation for option itself is at

http://docs.wxwidgets.org/trunk/overview_xrcformat.html#overview_xrcformat_sizers

but the meaning of it is found in wxSizer documentation (overview and
wxBoxSizer description).

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

bobpitbull

unread,
Dec 15, 2009, 4:25:56 PM12/15/09
to wx-users
Thanks for the answer, Vadim.

I usually prefer to code without external tools where I can... but it
may be useful to use something in this case so that I can see how
generated .xrc differs from what I have...

I'm pretty new to wxWidgets, really, so forgive me for this "stupid"
question, but... basically... all that I need to tell it to do is to
let me split the parent window up into 2 parts - about 40% for left,
60% for right (option = 2 and option = 3?)... then... simply use the
full height of the window, if needed, for both - and have vertical and
horizontal scrollbars in case things don't fit.

Is this possible through .xrc files? Both my wxTreeCtrl and my panel/
scrollablewindow/whatever on the right are "dynamic" - they can change
in total height dependent on what you choose to expand/collapse when
clicking on them...

Thanks for the help,
Bob

On Dec 15, 9:07 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> On Tue, 15 Dec 2009 09:02:16 -0800 (PST) bobpitbull <bobpitb...@gmail.com> wrote:
>
> b> I’m trying to set up a very simple window – due to implementation, I
> b> need to do it through a .xrc file...
>
>  But you don't need to create XRC file by hand, most people prefer to use a
> dialog editor for it. Of course, there is absolutely nothing wrong with
> writing it manually neither, this is what I personally do. But if you don't
> know the meaning of "option" tag, it's probably better to start
> experimenting with the GUI tools.
>
> b> PS. I can’t find any documentation for <option> but it seems to be
> b> littered all over our codebase... can someone explain what it’s for?
>
>  The documentation for option itself is at
>
> http://docs.wxwidgets.org/trunk/overview_xrcformat.html#overview_xrcf...
>
> but the meaning of it is found in wxSizer documentation (overview and
> wxBoxSizer description).
>
>  Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>
>  application_pgp-signature_part
> < 1KViewDownload

bobpitbull

unread,
Dec 15, 2009, 6:18:57 PM12/15/09
to wx-users
I've tried using DialogBlocks to help me with this - but with no
luck :-( .. anyone got any advice?

Anton

unread,
Dec 15, 2009, 7:12:28 PM12/15/09
to wx-u...@googlegroups.com
On 16/12/2009 0:18, bobpitbull wrote:
> I've tried using DialogBlocks to help me with this - but with no
> luck :-( .. anyone got any advice?
>

When DialogBlocks tries to import the sample you posted,
it gives an XML parsing error on the opening tag for the wxTreeCtrl
object: the closing bracket of the name attribute is � instead of "
(unicode right double quotation mark instead of plain quotation
mark). That makes the xml not well-formed.

I think you will get the result you are expecting if you fix that error
and then:
- remove all <size> tags (for the wxTreeCtrl and the wxScrolledWindow)
- use option 2 for the first sizeritem and option 3 for the second, just
like you already suggested yourself

HTH,
Anton

Vadim Zeitlin

unread,
Dec 16, 2009, 4:32:47 AM12/16/09
to wx-u...@googlegroups.com
On Tue, 15 Dec 2009 13:25:56 -0800 (PST) bobpitbull <bobpi...@gmail.com> wrote:

b> I'm pretty new to wxWidgets, really, so forgive me for this "stupid"
b> question, but... basically... all that I need to tell it to do is to
b> let me split the parent window up into 2 parts - about 40% for left,
b> 60% for right (option = 2 and option = 3?)... then... simply use the
b> full height of the window, if needed, for both - and have vertical and
b> horizontal scrollbars in case things don't fit.
b>
b> Is this possible through .xrc files?

Yes, of course. Just create a horizontal wxBoxSizer with 2 items with the
proportions 2 and 3, just as you wrote, and wxEXPAND flag. You're probably
just making some mistake in your XML, it's easy to do unfortunately (XML
may have its advantages but being easily human-editable is not one of them).

Reply all
Reply to author
Forward
0 new messages