Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Redixe on October 03, 2008, 06:06:48 pm

Title: Adding a wxs file to project
Post by: Redixe on October 03, 2008, 06:06:48 pm
I used the wxSmith add dialog to add a few dialogs to the project. Because of the way things are setup, when I lost connection to our server the files weren't saved to the project. I still had the .cpp, .h, and .wxs files. I just to C::B to add them to the project. Now, when I try to view the dialog all I get is the text version. How can I add it back where I can view it and add stuff to it with wxSmith?
Title: Re: Adding a wxs file to project
Post by: byo on October 03, 2008, 09:01:44 pm
There's special function exported in scripting engine dedicated for recovering of such files. To recover file do the following:

* Open Project with missing resources
* Open scripting console (available under view menu)
* Enter command in the following form:

For resource not using xrc file:
Code
WxsRecoverWxsFile(_( "[RESOURCE_TYPE] wxs=\"[WXS_FILE_NAME]\" src=\"[SRC_FILE_NAME]\" hdr=\"[HDR_FILE_NAME]\" name=\"[RESOURCE_NAME]" language=\"CPP\" "));

For resource using xrc file:
Code
WxsRecoverWxsFile(_( "[RESOURCE_TYPE] wxs=\"[WXS_FILE_NAME]\" src=\"[SRC_FILE_NAME]\" hdr=\"[HDR_FILE_NAME]\" xrc=\"[XRC_FILE_NAME]\" name=\"[RESOURCE_NAME]" language=\"CPP\" "));


where:

[RESOURCE_TYPE] - is name of wxWidgets class of this resource (for example wxFrame)
[WXS_FILE_NAME] - is name of wxs file containing resource definition (include the wxsmith directory name, for example: wxsmith/frame1.wxs)
[SRC_FILE_NAME] - is name of .cpp file dedicated for the resource
[HDR_FILE_NAME] - is name of .h file dedicated for the resource
[XRC_FILE_NAME] - is name of .xrc file (if used)
[RESOURCE_NAME] - is name of resource as shown in wxSmith panel (generally it's name of resouce's class)

For example if you have created resource called NewFrame (source file: NewFrame.cpp, header: NewFrame.h, wxs: wxsmith/NewFrame.wxs) simply call from the scrip console:

Code
WxsRecoverWxsFile(_( "wxFrame wxs=\"wxsmith/NewFrame.wxs\" src=\"NewFrame.cpp\" hdr=\"NewFrame.h\" name=\"NewFrame\" language=\"CPP\"  " ));

Now if the resource uses xrc file, add extra argument notifying about such file:
Code
WxsRecoverWxsFile(_( "wxFrame wxs=\"wxsmith/NewFrame.wxs\" src=\"NewFrame.cpp\" hdr=\"NewFrame.h\" xrc=\"NewFrame.xrc\" name=\"NewFrame\" language=\"CPP\"  " ));

Hope this will help :)

Regards
   BYO

Title: Re: Adding a wxs file to project
Post by: Redixe on October 03, 2008, 10:54:36 pm
Getting an Error:
Quote
Filename: ScriptConsole
Error: the index 'WxsRecoverWxsFile' does not exist
Details:
AN ERROR HAS OCCURED [the index 'WxsRecoverWxsFile' does not exist]

CALLSTACK
*FUNCTION [main()] ScriptConsole line [1]

LOCALS
[this] TABLE

I ran this command
Code
WxsRecoverWxsFile(_( "wxDialog wxs=\"wxsmith/keyboard.wxs\" src=\"keyboard.cpp\" hdr=\"keyboard.h\" name=\"keyboard\" language=\"CPP\" "));
Title: Re: Adding a wxs file to project
Post by: Jenna on October 04, 2008, 12:23:29 am
Which version of C::B do you use ?

Quote
wxSmith:
* Exported 'WxsRecoverWxsFile' function into squirrel - it may be used to recover resources when they were lost
* Fix potential crash when loading project with invalid resource definitions

Quote from changelog for svn r5042.

If you use an older version (stable 8.02 included) "WxsRecoverWxsFile" is unknown.
Title: Re: Adding a wxs file to project
Post by: Redixe on October 06, 2008, 11:48:08 pm
I am using 8.02
Title: Re: Adding a wxs file to project
Post by: byo on October 07, 2008, 07:39:20 pm
In such case there's no option other than opening .cbp file manually in some text editor and adding proper sections.
Jus search for <wxsmith> - all resources are listed nearby and it's not hard to add new ones manually

Regards
   BYO
Title: Re: Adding a wxs file to project
Post by: Redixe on October 09, 2008, 04:52:47 am
Thank you very much. I will give that a shot when I get back to working in the morning.  :D
Title: Re: Adding a wxs file to project
Post by: MaikoID on November 05, 2008, 12:21:37 pm
"Hi.

I am having a problem with wxSmith, apparently, it lost the reference to my source-code, and now, I can't add events to none of my components. However I can compile and execute and all components are working properly.

 - it have any command to "rebuild" the references?

Why the wxSmith works very better in Windows than in Linux? I am using Ubuntu 7.1, and have many bugs to modify a GUI, in Windows with the same GUI, all works fine.

ps: Sorry about my english."

Hi I am follow what jean told me. I have tried what you said about wxSmith on this post, the console works whitout erros appears to me, but continuos without references, I can't add events on my components.
Title: Re: Adding a wxs file to project
Post by: odubtaig on November 05, 2008, 12:34:31 pm
I'd personally recommend updating to a newer version, running SVN 5274 in Windows and 5273 on Ubuntu Hardy and I can't say I've noticed any lack of stability. Not using wxWidgets just yet though so maybe I'm missing something? Just wanted to get past the SDL include path issue and get a couple new features.
Title: Re: Adding a wxs file to project
Post by: rcoll on February 01, 2009, 07:28:48 pm
There's special function exported in scripting engine dedicated for recovering of such files. To recover file do the following:

* Open Project with missing resources
* Open scripting console (available under view menu)
* Enter command in the following form:

For resource not using xrc file:
Code
WxsRecoverWxsFile(_( "[RESOURCE_TYPE] wxs=\"[WXS_FILE_NAME]\" src=\"[SRC_FILE_NAME]\" hdr=\"[HDR_FILE_NAME]\" name=\"[RESOURCE_NAME]" language=\"CPP\" "));

.......

Regards
   BYO



Can this be used to include any other external WXS+CPP fileset into the current project?  If so, what would
it take to make this a menu item (i.e., it opens a dialog where the user selects the WXS file, the CPP file,
and the H file and it all gets added to the project)?

Thanks,
Ringo
Title: Re: Adding a wxs file to project
Post by: eranon on August 04, 2013, 05:01:02 pm
Old thread, but I'm faced this situation (how to import a wxs file into a project). Does this way through the console still works. I've tried and nothing happen (neither return nor error message). How to re-import a wxs file in 2013 ? Does the WxsRecoverWxsFile command obsolet ?

--
EDIT : Solved, but there's maybe a smarter way (so, I'm still interested to know). Here is how I did it :

1) I've created a new dialog from wxSmith ("Add wxDialog" menu item), giving the same class name as the one I want to re-integrate (say "BambiDialog" class).
2) Closed Code::Blocks.
3) Overwritten BambiDialog.wxs, BambiDialog.h and BambiDialog.cpp with my old real files (the ones I want to re-integrate).
4) Re-opened Code::Blocks and all sounds right.