Author Topic: How to force UI editor to respect my change about class ?  (Read 6775 times)

Offline eranon

  • Almost regular
  • **
  • Posts: 180
How to force UI editor to respect my change about class ?
« on: May 11, 2012, 01:36:35 am »
Using C::B svn 7932 to manage a project using wxWidgets 2.8, I need a GUI without any title-bar nor system command (min/max/quit). So, rather than to subclass an existing class by myself, I've seen in the wxWidgets classes tree that wxSplashScreen could match my goal (even if exotic goal, I agree:).

Well, so I've taken this way and it works unless a little detail which bother me :

1) Using the CB's project wizard, I've created a wxFrame based project.
2) Replaced every "wxFrame" occurrence by "wxSplashScreen" in projects files (ie. in TestMain.h, TestMain.cpp and testframe.wxs).
3) Replaced "#include <wx/frame.h>" by "#include <wx/splash.h>" in TestMain.h, taking care to put-it out of "//(*Headers(elireFrame)//*)" block.

Then, all compile, link and run very well, but everytime I use wxSmith UI editor, C::B (or its wxSmith plugin) rewrites the "#include <wx/frame.h>" in TestMain.h and "<object class="wxFrame" name="TestFrame">" in testframe.wks. It doesn't break compile and running, but is embarrassing.

So, how to avoid this ? I mean, how to explain to the UI editor to respect my changes ?
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]

Offline renega_666

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: How to force UI editor to respect my change about class ?
« Reply #1 on: May 11, 2012, 09:06:30 am »
Auto generated code should not be edited by hand.

Code
//(*
// auto generated code, should not be edited
//*)

// here you can add custom code

Anyway using a splash screen for a border-less window isn't a good idea.You only need to change the wxFrame style according to your needs.

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Re: How to force UI editor to respect my change about class ?
« Reply #2 on: May 11, 2012, 12:19:14 pm »
Auto generated code should not be edited by hand.

Thanks renega_666, but I didn't change anything in the autogenerated block as you can see below :

Code
/(*Headers(TestFrame)
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/frame.h>
//*)
#include <wx/splash.h>

class TestFrame: public wxSplashScreen

So, knowing TestFrame class is based on wxSplashScreen and seeing frame.h is well provided, wxSmith/CB shouldn't regenerate reference to "frame.h" anymore. So, is there a difference of behavior between wxSmith and wxFormBuilder ?

Quote
Anyway using a splash screen for a border-less window isn't a good idea.You only need to change the wxFrame style according to your needs.

In this special case, yes, I agree, but it may exist cases where we need to go wild way (don't follow the standard)... And it can be important to be able to be not constraint by a tool (here, wxSmith). So, how, if I want to base an app on a class of mine using wxSmith ? Is that possible ? Or should I use wxFormBuilder rather ?
« Last Edit: May 11, 2012, 12:24:24 pm by eanon »
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]

Offline renega_666

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: How to force UI editor to respect my change about class ?
« Reply #3 on: May 11, 2012, 03:25:35 pm »
Quote
Thanks renega_666, but I didn't change anything in the autogenerated block as you can see below :

Code:
/(*Headers(TestFrame)
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/frame.h>
//*)
#include <wx/splash.h>

class TestFrame: public wxSplashScreen

So, knowing TestFrame class is based on wxSplashScreen and seeing frame.h is well provided, wxSmith/CB shouldn't regenerate reference to "frame.h" anymore. So, is there a difference of behavior between wxSmith and wxFormBuilder ?

I don't think wxSmith parse your source code (can anyone confirm this?) so it doesn't know that your class is a wxSplashScreen. I think it automatically rewrites all of its auto-generated source code whenever you make a change in the wxSmith editor panel.

Maybe this should be reported as a bug ???

Quote
In this special case, yes, I agree, but it may exist cases where we need to go wild way (don't follow the standard)... And it can be important to be able to be not constraint by a tool (here, wxSmith). So, how, if I want to base an app on a class of mine using wxSmith ? Is that possible ? Or should I use wxFormBuilder rather ?

Except for the top level classes (such as wxFrame or wxDialog), you can specify a custom class using the Class name property (in the wxSmith's control property grid).

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Re: How to force UI editor to respect my change about class ?
« Reply #4 on: May 11, 2012, 06:21:07 pm »
Quote
Code:
/(*Headers(TestFrame)
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/frame.h>
//*)
#include <wx/splash.h>

class TestFrame: public wxSplashScreen

So, knowing TestFrame class is based on wxSplashScreen and seeing splash.h is well provided, wxSmith/CB shouldn't regenerate reference to "frame.h" anymore. So, is there a difference of behavior between wxSmith and wxFormBuilder ?

I don't think wxSmith parse your source code (can anyone confirm this?) so it doesn't know that your class is a wxSplashScreen. I think it automatically rewrites all of its auto-generated source code whenever you make a change in the wxSmith editor panel.

Maybe this should be reported as a bug ???

Why not ? Where are reported bug and/or feature requests about wxSmith plugin ?
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to force UI editor to respect my change about class ?
« Reply #5 on: May 11, 2012, 07:23:34 pm »
It's not a bug, it's how wxSmith works.
The base class is also stored inside the project-file.

You can change it there with a text-editor, but I don't think it will work, because wxSplashScreen is not (/yet) supported by wxSmith as far as I know.

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Re: How to force UI editor to respect my change about class ?
« Reply #6 on: May 11, 2012, 09:22:30 pm »
So, if it's a not a bug, it could be a smart feature to be able to manage this.
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]