Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Modified & Improved wxWidgets Project Wizard
byo:
--- Quote from: Biplab on February 17, 2007, 08:26:36 pm ---Thanks Byo for the code. I'll go through it. :D
Actually Today I tried wxSmith again to understand it. But could not post as there was some problem during posting. I've created the following page. Please have a look at it.
My idea is also similar of using macros. Already it's in use in one place. While you add the support to add extension to project file, I would start working with basic templates of wxSmith and as well as wxFormBuilder. :)
Regards,
Biplab
--- End quote ---
Looks promising :)
But there may be some problem when using wxSmith's extension - what will happen when wxSmith plugin is not loaded and there's no extra function registered? I hope that squirrel won't fail and that there's a way to check if function is declared.
Making wxWidgets wizard useless only because wxSmith plugin is not loaded sound really badly :(
BYO
Biplab:
Hi All,
Here is an update. The wizard code has been modified to enable support for wxFormBuilder + wxFrame based app. The wizard works fine in generating the files.
But I'm facing couple of problems. Files can be added to a Project by the Wizard in two ways.
* Show C::B a folder and it will copy the contents without processing them.
* Give C::B file name and contents and it'll add them.
Problem with the first method is that it doesn't parse the files. So customisations of files are not possible.
Problem with the second method is that you can parse files, but AFAIK it can't add files with unrecognised extensions. The wxFormBuilder (wxFB) project file extension is unrecognised by C::B and therefore it is not adding to project after parsing it.
There is another problem with the second method to parse wxFB project file. Pre-processor definition to enable PCH support can't be customised. If I add the wxFB project file with/without parsing, it is going to break the PCH support.
Following piece of code will make my point clear. An example of wxFB generated code is as follows. wxFB uses WX_GCH whereas the project will use USE_PCH.
--- Code: ---#ifdef WX_GCH
#include <wx_pch.h>
#else
#include <wx/wx.h>
#endif
--- End code ---
I have decided to go with first method for the time being. But the PCH support will remain broken for wxFB generated code. Though PCH support should work with remaining part of the project.
@rjmyst3
Is it possible to add customisation of this Pre-processor directive in wxFB project file? I just want to change the Pre-processor directive to USE_PCH and want wxFB to use this while regenerating the source. I don't think this would be quite difficult to implement. :)
@Mandrav
Is there any better alternative to Second method? A link to help would be sufficient. :)
@byo
I'll implement wxSmith after I fix initial problems. But I have one request. Can you please provide me with two project files, one for Dialog based and one for Frame based? Please include wxs file, cpp and header files. :)
Regards,
Biplab
Edit 1: Fixed a Typo.
mandrav:
--- Quote ---Problem with the second method is that you can parse files, but AFAIK it can't add files with unrecognised extensions. The wxFormBuilder (wxFB) project file extension is unrecognised by C::B and therefore it is not adding to project after parsing it.
--- End quote ---
Where did you get that from? You can add whatever kinds of files you want in a project. It's only checking the extensions to decide if each file needs to be built/linked or not.
Give me more info on this. Either you did something wrong or you discovered a bug which we 'll fix.
--- Quote ---There is another problem with the second method. Pre-processor definition to enable PCH support can't be customised. If I add the wxFB project file with/without parsing, it is going to break the PCH support.
--- End quote ---
How come? Why can't you use WX_GCH instead of USE_PCH?
Biplab:
--- Quote from: mandrav on February 19, 2007, 10:21:13 am ---Where did you get that from? You can add whatever kinds of files you want in a project. It's only checking the extensions to decide if each file needs to be built/linked or not.
Give me more info on this. Either you did something wrong or you discovered a bug which we 'll fix.
--- End quote ---
I didn't get it from SDK manual. ;) I found that the script is adding additional *.cpp or *.h files but not adding the *.fbp file. I checked it with ShowInfo() to see whether the parsing is being done or not. I found the parsing is done but it is not adding the file. Later I checked the Debug Log and I found C::B is complaining.
--- Quote ---[17:53:14.125]: Add project Test in parsing queue
[17:53:14.218]: Project's base path: C:\Projects\Test\
[17:53:14.218]: Project's common toplevel path: C:\Projects\Test\
[17:53:14.296]: Generated file C:\Projects\Test\TestApp.h
[17:53:14.312]: Generated file C:\Projects\Test\TestApp.cpp
[17:53:14.328]: Generated file C:\Projects\Test\TestMain.h
[17:53:14.359]: Generated file C:\Projects\Test\TestMain.cpp
[17:53:14.375]: Generated file C:\Projects\Test\Test_pch.h
[17:53:14.390]: Generated file C:\Projects\Test\TestGUIFrame.h
[17:53:14.406]: Generated file C:\Projects\Test\TestGUIFrame.cpp
[17:53:14.406]: Attempt to generate a file with forbidden extension!
File: TestGUIFrame.fbp
--- End quote ---
I'm posting a part of the script for your information.
--- Code: ---function GetGeneratedFile(file_index)
{
if (!IsEmpty)
{
local ProjectName = Wizard.GetProjectName();
if (file_index == 0)
return ProjectName + _T("App.h") + _T(";") + GenerateHeader(file_index);
else if (file_index == 1)
return ProjectName + _T("App.cpp") + _T(";") + GenerateSource(file_index);
else if (file_index == 2)
return ProjectName + _T("Main.h") + _T(";") + GenerateHeader(file_index);
else if (file_index == 3)
return ProjectName + _T("Main.cpp") + _T(";") + GenerateSource(file_index);
else if (file_index == 4)
{
if (WantPCH)
return ProjectName + _T("_pch.h") + _T(";") + GenerateHeader(file_index); // PCH file
else
{
if (GuiBuilder == 0)
return _T(""); // Stop Here.
else if (GuiBuilder == 1)
return ProjectName + _T("_wxsmith.wxs") + _T(";") + GenerateHeader(file_index); // wxSmith file
else if (GuiBuilder == 2)
//return ProjectName + _T("_wxfb.fbp") + _T(";") + GenerateHeader(file_index); // wxFormBuilder file
ShowInfo(ProjectName + _T("_wxfb.fbp") + _T(";") + GenerateHeader(file_index)); // This one is for testing
}
}
else if (file_index == 5)
{
if (GuiBuilder == 2)
{
if (GuiAppType == 1)
return ProjectName + _T("GUIFrame.h") + _T(";") + GenerateHeader(file_index);
else if (GuiAppType == 0)
return ProjectName + _T("GUIDialog.h") + _T(";") + GenerateHeader(file_index);
}
}
else if (file_index == 6)
{
if (GuiBuilder == 2)
{
if (GuiAppType == 1)
return ProjectName + _T("GUIFrame.cpp") + _T(";") + GenerateHeader(file_index);
else if (GuiAppType == 0)
return ProjectName + _T("GUIDialog.cpp") + _T(";") + GenerateHeader(file_index);
}
}
else if (file_index == 7 && WantPCH) // This is to ensure that if WantPCH is true, then project file should be added
{
if (GuiBuilder == 1)
return _T(""); // WIll be added later
else if (GuiBuilder == 2)
{
if (GuiAppType == 0)
return ProjectName + _T("GUIDialog.fbp") + _T(";") + GenerateHeader(file_index);
else if (GuiAppType == 1)
return ProjectName + _T("GUIFrame.fbp") + _T(";") + GenerateHeader(file_index);
}
}
}
return _T(""); // no more generated files
}
--- End code ---
I'm also attaching the full source if you wish to test it. But please make a backup of old folder as this is not fully working yet. :)
--- Quote ---There is another problem with the second method. Pre-processor definition to enable PCH support can't be customised. If I add the wxFB project file with/without parsing, it is going to break the PCH support.
--- End quote ---
Sorry mandrav, this one is a typo. It should be "There is another problem with the second method to parse wxFB project file. Pre-processor definition to enable PCH support can't be customised (as they are not available in Project file). If I add the wxFB project file with/without parsing, it is going to break the PCH support."
--- Quote from: mandrav on February 19, 2007, 10:21:13 am ---How come? Why can't you use WX_GCH instead of USE_PCH?
--- End quote ---
I'm afraid that may create problem when wxSmith support will be added. For all the three possible options (None, wxSmith and wxFormBuilder), the same Pre-processor definition would be helpful. Either we 3 settle for same Pre-processor flag or there should be options available to customise them. :)
[attachment deleted by admin]
rjmyst3:
--- Quote from: Biplab on February 19, 2007, 08:06:50 am ---wxFB uses WX_GCH whereas the project will use USE_PCH.
--- End quote ---
It would be pretty easy for wxFB to change to this:
--- Code: ---#if ( defined(WX_GCH) || defined(USE_PCH) )
#include <wx_pch.h>
#else
#include <wx/wx.h>
#endif
--- End code ---
That way existing projects setup with WX_GCH would not break, but it should also work the with Code::Blocks wizard.
Customization would be better, probably, but I'll need to talk to the other devs about adding a property.
Will that work for you?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version