Toolbar Custom ID

Post here wxCrafter related issues / features / bugs
musictreeAstro
CodeLite Curious
Posts: 7
Joined: Sat Sep 14, 2013 1:50 am
Genuine User: Yes
IDE Question: C++
Contact:

Toolbar Custom ID

Post by musictreeAstro »

Right now in wxCrafter we can choose an ID from a dropdown list for a toolbar item, for example. However, if we type in a custom ID, of course we need to declare it as a wxNewId(). However, if I add

Code: Select all

const long MainFrame::ID_MYID = wxNewId();
in wxcrafter.cpp and

Code: Select all

static const long ID_MYID;
in wxcrafter.h, these will be erased automatically by wxCrafter whenever I "Generate Code".

I understand that it is not recommended to edit wxcrafter.cpp and wxcrafter.h in the first place, so how can I use custom IDs? I am asking this because I have several similar toolbar buttons which need unique IDs.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Toolbar Custom ID

Post by eranif »

There are 4 ways to set Window IDS:

1) Select the ID from the dropdown list
2) Use XRCID so instead of typing MY_ID, type: XRCID("MY_ID")
3) Use custom header file with all your IDs, and include this header by selecting the top level item in the wxCrafter view and add it to the 'Additional include headers' - so wxCrafter will include it while generating the code
4) (and this is what you are looking for) Click on the top level item in the tree view of wxCrafter and in its properties, select 'Generate Window ID' to True and just type your ID: MY_ID the generated codelite will include a enum with all your IDs

See this screenshot:
1.png
Here is an example of the generated code:

Code: Select all

class MainDialogBaseClass : public wxDialog
{
protected:
    enum {
        ID_BUTTON1 = 1003,
        ID_BUTTON2 = 1004,
        ID_BUTTON3 = 1005,
    };
protected:
    wxBoxSizer* mainSizer;
    wxPanel* m_panel69;
    wxBoxSizer* boxSizer71;
    wxRibbonBar* m_ribbonBar;
...
Eran
You do not have the required permissions to view the files attached to this post.
Make sure you have read the HOW TO POST thread
musictreeAstro
CodeLite Curious
Posts: 7
Joined: Sat Sep 14, 2013 1:50 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Toolbar Custom ID

Post by musictreeAstro »

Thanks! That was exactly what I was looking for.

Forrest
Post Reply