Author Topic: Two issues with wxSmith  (Read 3737 times)

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Two issues with wxSmith
« on: December 20, 2013, 07:55:55 pm »
I am a long time Code::Blocks enthusiast and find it to be the one tool I can't live without  ::)

Recently, I have been porting my projects to wx3.0 and in that process I have found a couple of issues with wxSmith that I wanted to highlight so they may be fixed:

issue #1: wxSmith doesn't generate code for wxStaticBoxSizer correctly

Please read this thread for details: wxStaticBoxSizer problem with wxGTK and wxWidgets 3.0
In short, under wx3.0, any controls added inside a wxStaticBoxSizer needs to be children of the sizer, not siblings as wxSmith generates them today. Apparently, this has been true also under wx2.x, but the layout effects caused by wrong use appear to be more noticable under wx3.0. In the link above, the problem is shown for wxGTK, but I have since seen related effects also for wxMSW.

Here is some sample code as generated by wxSmith, the control is then a sibling of the wxStaticBoxSizer
Quote
StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Offset (x,y)"));
BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
m_xvalue = new wxSpinCtrlDbl(this, ID_SPINCTRL1, _T("0"),wxDefaultPosition, wxSize(70,-1), 0, -100, 100, 0, _T("ID_SPINCTRL1"));

Modified code, the control is a child of the wxStaticBoxSizer
Quote
StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Offset(x,y)"));
BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
m_xvalue = new wxSpinCtrlDbl(StaticBoxSizer1->GetStaticBox(), ID_SPINCTRL1,_T("0"), wxDefaultPosition, wxSize(70,-1), 0, -100, 100, 0,_T("ID_SPINCTRL1"));

The modified code shows how wxSmith should work, according to the developers of wxWidgets.

EDIT: While the above is almost certainly true, the tread linked to shows that there could be more issues.

issue #2 Spurious event handler functions generated by accident when clicking in wxSmith resource view

I have had this happening several times recently, when simply checking the properties of e.g. a wxSpinCtrl by clicking it in wxSmith. Generating events by just clicking a control is not what I want and it is highly intrusive and annoying when it happens (i.e. quite often). When it happens, the handler must be undefined and the code must be manually removed from both header file and implementation file. A significant distraction. I think this feature is too subtle and should be removed or at least there should be an option in the wxSmith settings to swich such code generation off. Handlers should normally only be generated using the explicit "{}" option.


Any views on this?
« Last Edit: December 20, 2013, 08:09:19 pm by cacb »