Author Topic: Problem with wxSmith  (Read 7692 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5494
Problem with wxSmith
« on: November 01, 2005, 06:52:06 pm »
When I am designing my GUI of my plug-in, I am using the wxSmith to do this.
My dialog has a wxBoxSizer, which in turn contains a wxStaticBoxSizer.
My goals is to change the label at runtime of the staticBoxSizer (?if this is possible?), I first started out with constructs like :
   m_Comments = XRCCTRL(*this, "ID_TEXTCTRL_COMMENTS", wxTextCtrl)->GetValue();
This one is for a textctrl, but when I try this for the sizer it fails.

So , let's try to make it a member of the dialog and see what we can do then.
BUT when in wxSmith I make my wxBoxSizer (or my wxStaticBoxSizer) a member, wxSmith creates code in the constructor of the dialog like this :
    BoxSizer1 = XRCCTRL(*this,"",wxBoxSizer);
But that does not compile, I get the following error on that line :
Ccdialog.cpp:15: error: invalid static_cast from type `wxWindow*' to type `const wxBoxSizer*'


Bug in wxSmith or am I doing something wrong ?
I know that wxSizer does not derive from wxWindow, so maybe the whole construct created is illegal ?

Any ideas welcome,
many thanks,
Lieven
« Last Edit: November 02, 2005, 04:56:49 pm by killerbot »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Problem with wxSmith
« Reply #1 on: November 01, 2005, 07:09:30 pm »
Yes, a sizer is an object *attached* to a wxWindow. You might find the wxWidgets manual useful. Also, try taking a look at some of the XRC files for codeblocks.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5494
Re: Problem with wxSmith
« Reply #2 on: November 01, 2005, 07:47:36 pm »
Conclusion is therefor : bug in wxSmith !

It should not generate code like this, or don'y even allow the sizer to be a member. Probably member might be ok, but other code to retrieve the object is needed.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Problem with wxSmith
« Reply #3 on: November 02, 2005, 03:42:04 pm »
Conclusion is therefor : bug in wxSmith !

It should not generate code like this, or don'y even allow the sizer to be a member. Probably member might be ok, but other code to retrieve the object is needed.

This has already been fixed :)

Using XRC You can only get wxWindow-derived items. XRC headers doesn't even have macros for other objects (like sizers).
I see two solutions here:

* First is to use wxSmith's automatically generated code (without XRC file) but I guess it won't sattisfy You, or
* use GetSizer() to get wxStaticBoxSizer object from widget containing this sizer, next call GetStaticBox from this sizer and then try SetLabel() on wxStaticBox. It worked for me :)


Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5494
Re: Problem with wxSmith
« Reply #4 on: November 02, 2005, 04:40:17 pm »
Can we already download a new 'dll' binary with the fixes of wxSmith ?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5494
Re: Problem with wxSmith
« Reply #5 on: November 02, 2005, 04:52:19 pm »
Another question :

the dialog has several sizers, how to you "GetSizer" the correct one ??

For example : I need the  "StaticBoxSizer1"

    <object class="wxDialog" name="CcDialog">
        <title>ClearCase Plug-in for Code::Blocks</title>
        <style>wxCAPTION|wxTHICK_FRAME|wxSYSTEM_MENU|wxCLOSE_BOX</style>
        <object class="wxBoxSizer" variable="BoxSizer1" member="no">
            <orient>wxVERTICAL</orient>
            <object class="sizeritem">
                <option>1</option>
                <border>5</border>
                <flag>wxALL|wxALIGN_CENTER|wxEXPAND</flag>
                <object class="wxStaticBoxSizer" variable="StaticBoxSizer1" member="no">
« Last Edit: November 02, 2005, 04:56:14 pm by killerbot »

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Problem with wxSmith
« Reply #6 on: November 03, 2005, 12:22:40 am »
Another question :

the dialog has several sizers, how to you "GetSizer" the correct one ??

For example : I need the  "StaticBoxSizer1"

    <object class="wxDialog" name="CcDialog">
        <title>ClearCase Plug-in for Code::Blocks</title>
        <style>wxCAPTION|wxTHICK_FRAME|wxSYSTEM_MENU|wxCLOSE_BOX</style>
        <object class="wxBoxSizer" variable="BoxSizer1" member="no">
            <orient>wxVERTICAL</orient>
            <object class="sizeritem">
                <option>1</option>
                <border>5</border>
                <flag>wxALL|wxALIGN_CENTER|wxEXPAND</flag>
                <object class="wxStaticBoxSizer" variable="StaticBoxSizer1" member="no">



OK, let's see, it would be something like this (Haven't tested that but it should be working ;) ):

Code
wxSizer* MainSizer = GetSizer(); // Getting BoxSizer1 item
wxStaticBoxSizer* Sizer = (wxStaticBoxSizer*)( MainSizer->GetItem(0)->GetSizer() );
wxStaticBox* Box = Sizer->GetStaticBox();
Box->SetLabel(_("Anything You want :)"));

(I would add some NULL checks, one small XRC file change and C::B crashes.)

Maybe new dll will be included in next binary snapshot by ceniza (http://gda.utp.edu.co/~ceniza/CodeBlocks/). But I really don't know when it will be ;)