News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Adding a wxs file to project

Started by Redixe, October 03, 2008, 06:06:48 PM

Previous topic - Next topic

Redixe

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?

byo

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:

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:

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:

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:

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


Redixe

Getting an Error:
QuoteFilename: 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
WxsRecoverWxsFile(_( "wxDialog wxs=\"wxsmith/keyboard.wxs\" src=\"keyboard.cpp\" hdr=\"keyboard.h\" name=\"keyboard\" language=\"CPP\" "));

Jenna

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.

Redixe


byo

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

Redixe

Thank you very much. I will give that a shot when I get back to working in the morning.  :D

MaikoID

"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.

odubtaig

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.

rcoll

Quote from: 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:

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

eranon

#10
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.
[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"]