Hi.
ACtually there's a way to use some class instead of wxPanel and wxSmith will still see this widget as standard wxPanel item.
If you select panel and look into set of properties you will find one called "Class name". This property may be used to inform wxSmith that it should create class of different name instead of standard wxPanel. The only requirement is that such class would have to provide exactly the same constructor as original class (wxSmith will use same argument list as it would in case of wxPanel).
Here's an example of such item:
class SomeClass: public wxPanel
{
public:
SomeClass(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxPanel(parent,id,pos,size,style,name)
{
// Some extra initialization here
}
// Some extra stuff here
};
After you enter "SomeClass" in "Class name" property, wxSmith will create SomeClass instead of wxPanel.
If you don't use XRC files, the only extra requirement here is that you will have to add #include "SomeClass.h" manually into .h file of the resource (missing include will come out when you try to compile so it's easy to find).
When using XRC files, wxSmith will use something called subclassing (it's built into XRC loading system and allows to use one class instead of another) but it would require much more work.
Other solution is that you create separate wxPanel resource and insert this one into wxNotebook instead of wxPanel class. By using such solution you will have the main resource with wxNotebook in one editor and the content of each notebook's page in separate resources/editors (usually should be one resource per one page but that's not a rule). This can be done in few ways, I'll describe the easiest one:
- For each notebook's page which should be in separate resource, you have to create new wxPanel resource.
In "New wxPanel resource" dialog, expand advanced options, in "Constructor arguments" select all checkbockses in first column and unselect all in the second one, next copy this: "long style,const wxString& name" into "Custom arguments" - after that new resource will have same list of arguments as wxPanel class, other options may be as you wish. - When panel is ready, open resouce with wxNotebook
- Now we have to add panels from other resources into the notebook, we will do this simillarily to the solution used before:
add normal wxPanel pages and then change the "Class name" property to name of resource with required page
finally add missing #include entries
Now you have one window divided into few resources.
Of course that's not as easy as "integrated" version, but hopefully this will be implemented one day :) I rather won't be able to implement it before the day of Reyes (hmm, I don't know yet when I'll start implementing this). But it definitely shouldn't wait forever.
Regards
BYO
Hi again :) Nice to hear that my solution worked well before :).
For your current problem there's also a solution. Instead of adding wxPanel item inside the "parent" resource you will have to put something called "Custom". It's a little bit harder to work on but it's nothing more that just few minutes of initial set-up and you're ready to work :).
Here's the guide:
- Create child wxPanel resource as before, you may customize constructor arguments, don't have to manually add extra includes
- In the parent resource add "Custom" item - it's the last one on the Standard palette
- Go to properties of this Custom item
- Change "Class Name" property to name of the wxPanel resource
- Enter name of panel's header file in the "Include file" property
- Check the "Use "" for includes ..." so it will point to local file name
- Open the "Creating code" property in editor (using ... button) - here you have some skeleton of how to create the child item. Here's some detailed description on how to use this property:
This property shows how wxSmith should build source code which will generate this custom item. It may contain any valid c++ code. Some things can be written using macro-like form like $(ID). Those macros are replaced with proper equivalents for this item:
- $(THIS) - it's replaced with variable name of this custom item
- $(CLASS) - it's replaced with name of item's class
- $(PARENT) - replaced with pointer to parent item
- $(ID) - replaced with item's id
- $(POS) - replaced with item's position
- $(SIZE) - replaced with item's size
- $(STYLE) - replaced with items' style
- $(NAME) - replaced with item's name (item's id represented as wxString)
In this code you can put other values passed to item's constructor, like:
$(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE),elements);
This code will require the item to have constructor simillar to this one:
SomeItem::SomeItem(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, SomeArray& elems)
So you can pass any value into item's constructor. The only requirement is that this value (int the example above it's elements variable) must be known in scope of creating code - so it may be member variable of parent resource class, some variable passed into parent resource constructor etc. It can also be some local variable declared in constructor but it will have to be declared (and probably initialized) before the //(*Initialize(...) ... //*) code section.
Hope this description will be enough :) In case of any questions just write here :)
Regards
BYO