wxHatch Reference: Syntax in the c++ code for successful use of wxHatch

wxHatch searches the code for menus, toolbars, classes and (in the dialog editor) controls belonging to the dialog. Although c++ allows free formatting, the wxHatch search makes a number of assumptions:

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 line

void 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(""));

3. Dialogs have private pointers to all their controls
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

wxHatch Home Link to wxHatch help page