1. Method declarations need to be all on one line
As the Code lines are parsed, looking for class members, and particularly event handlers, it is assumed that method declarations are all on one line. These syntaxes will fail:
void
MyFrame::OnFilesave (wxCommandEvent & event); //void not on the same linevoid MyFrame::OnFilesave (wxCommandEvent
& event); //parameters not all on one line
2. Adding items to a
Toolbar
or Menu
needs to be done on a single line too, like this
Test_menu -> Append ( wxH_TESTSHOW_DIALOG, wxT("&Show dialog"), wxT("") );
toolBar->AddTool(wxH_TESTSHOW_DIALOG, wxBitmap ( TestShow_dialog_xpm ), wxT(""));
All the controls belonging to a dialog should be declared as private in the header. Thus in the .cpp file, the controls are created by wxhatch with calls to new on one line and the addition to a sizer on a subsequent line:
button665 = new wxButton(this, button665Id, wxT("label"));
mainsizer -> Add(button665, 0, wxALL | wxEXPAND, 5);
Code like this will not be paresed correctly
mainsizer -> Add(new wxButton(this, button665Id, wxT("label")), 0, wxALL | wxEXPAND, 5);
If you want to access a control from the main program, either add a Set/Get method, or move the control from private to public. Both of these are honoured by wxHatch parsing
Declaring IDs for menus
New wxhatch projects use
an enum to set up the IDs, like
this
enum
{
// menu IDs these two are needed by
wxHatch
wxH_FILE = 1,
wxH_FILENEW,
wxH_FILEOPEN,
wxH_FILESAVE,
wxH_FILESAVE__AS,
wxH_FILEE_XIT,
wxH_QUIT
};
This is also used in most wxWidgets/samples projects. In versions >06 of wxhatch, code using #define or const int for the identifiers (instead of an enum) should also be correctly parsed, and more #define entries added. However you will need to check if the old IDs are reused or if new IDs are assigned correctly