Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

wxSmith extending widgets

<< < (2/2)

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:

--- Code: ---$(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE),elements);

--- End code ---

This code will require the item to have constructor simillar to this one:

--- Code: ---SomeItem::SomeItem(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, SomeArray& elems)

--- End code ---

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

Navigation

[0] Message Index

[*] Previous page

Go to full version