wxSmith: how to rename an auto generated class Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
827rk4
In need of some credit
In need of some credit
Posts: 7
Joined: Tue Apr 03, 2018 12:10 pm

wxSmith: how to rename an auto generated class

Post by 827rk4 »

I have several panel built using wxSmith. The panel was created by choosing 'add wxPanel' from wxSmith menu on codeblocks. The problem is that I give the name of the panel class with lowercase letter, e.g:

mypanelclass

I want to change it into:

MyPanelClass

I try to rename it manually (by replacing all mypanelclass with MyPanelClass) but didn't work because every time I edit the .wxs file the name will be reverted to the original setting.

thanks
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxSmith: how to rename an auto generated class

Post by ONEEYEMAN »

Hi,
Why do you want to change the wxs file?
Can't you just simply open the project, rename the class and save?

Thank you.
827rk4
In need of some credit
In need of some credit
Posts: 7
Joined: Tue Apr 03, 2018 12:10 pm

Re: wxSmith: how to rename an auto generated class

Post by 827rk4 »

ONEEYEMAN wrote:Hi,
Why do you want to change the wxs file?
Can't you just simply open the project, rename the class and save?

Thank you.
Hi,
1.because I need to add or remove or change the layout of the widgets on the panel. I am doing it by drag 'n droping widgets from pallete to the panel.

2.no. for example

this is mypanelclass.h:

Code: Select all

class mypanelclass : public wxPanel
{
  protected:
    static const long ID_STATIXTEZT7;//auto-generated code
.....
}
and this is mypanelclass.cpp:

Code: Select all

...
const long mypanelclass::ID_STATIXTEZT7 = wxNewId();//auto-generated code
...
so that if I change the class name manually into MyPanelClass the line above on mypanelclass.cpp would be error since mypanelclass::ID_STATIXTEZT7 is undeclared.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxSmith: how to rename an auto generated class

Post by ONEEYEMAN »

Hi,
I understand that. But if you open the file in wxSmith and modify the design by renaming whatever you want then save the modified design everything should be in order.

Did you try that?

Thank you.
827rk4
In need of some credit
In need of some credit
Posts: 7
Joined: Tue Apr 03, 2018 12:10 pm

Re: wxSmith: how to rename an auto generated class

Post by 827rk4 »

ONEEYEMAN wrote:Hi,
I understand that. But if you open the file in wxSmith and modify the design by renaming whatever you want then save the modified design everything should be in order.

Did you try that?

Thank you.
I also thought that I should rename the class through the GUI designer (wxSmith). However I can't find a menu or anything in the designer editor to do it. Could you show me please?
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: wxSmith: how to rename an auto generated class

Post by eranon »

Hello,

If it's about a wxPanel based class of yours, you have a "Class name" field in wxSmith. If it's about an instance name rather than the class one, you have a field for variable name.

However, you can't rename all the classes from within the wxSmith's interface. For example, unless mistake, you can't rename the top window (wxFrame or wxDialog based)... But, in this case, you can simply rename all the concerned classname occurrences through you project files using a search & replace tool. It's what I do below: the wxFrame based class orginally named "wxSmith_testFrame" has been renamed as "MainFrame". Afterward I verified in wxSmith and it accepted the change (ie. there's no hidden checking like MD5 or something around the .wxs file format). The project is still consistent and build successfully after change too, of course!
snap_0005895.png
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
827rk4
In need of some credit
In need of some credit
Posts: 7
Joined: Tue Apr 03, 2018 12:10 pm

Re: wxSmith: how to rename an auto generated class

Post by 827rk4 »

Hi, eranon.

In my case 'mypanelclass' is the top widget/top window. So I can not rename the class from wxSmith's interface.

And as I said before I also have try to rename all class name occurences using search & replace tool (I call it as manual replacement). It works, however if I re-edit the panel GUI with wxSmith, the class names inside mypanelclass.cpp file will reverted to original class name.

have you try to re-edit the frame GUI?
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: wxSmith: how to rename an auto generated class

Post by eranon »

Yes, I can still edit what I want in wxSmith after the change. In my opinion, if it reverts it could be because your missed some occurrences (for example, in the .wxs or .cbp files). You should avoid to do it manually. With a search & replace tool, the overall job is done in seconds.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
827rk4
In need of some credit
In need of some credit
Posts: 7
Joined: Tue Apr 03, 2018 12:10 pm

Re: wxSmith: how to rename an auto generated class

Post by 827rk4 »

eranon wrote:In my opinion, if it reverts it could be because your missed some occurrences (for example, in the .wxs or .cbp files).
Maybe you're right :) . I try to change the text more thoroughly with more specific options. And it works now :D

Thank you
Post Reply