Search code examples
warningswxwidgets

Alternative for InsertTool Or AddTool


I am using wxWidgets 2.9.2, when i use following code

//ToolBar
wxToolBar *mainTool = new wxToolBar(this, 120);
wxBitmap newTool(_("images/icons/newtool.png"), wxBITMAP_TYPE_PNG);
wxBitmap saveTool(_("images/icons/savetool.png"), wxBITMAP_TYPE_PNG);
mainTool->InsertTool(0, idToolNew, newTool);
mainTool->InsertTool(1, idToolSave, saveTool);
mainTool->Realize();
SetToolBar(mainTool);

i get following warning

warning C4996: 'wxToolBarBase::InsertTool': was declared deprecated c:\wxwidgets-2.9.2\include\wx\tbarbase.h(546) : see declaration of 'wxToolBarBase::InsertTool'

Same happens for AddTool instead of InsertTool

In the tbarbase.h both of them are enclosed in

#if WXWIN_COMPATIBILITY_2_8
    // the old versions of the various methods kept for compatibility
    // don't use in the new code!
    // --------------------------------------------------------------

But i can't find which function to use as alternative. Do you know the new function i should use instead?


Solution

  • I got the answer for this question on wxWidgets IRC. This is currently a bug in documentation, as it does not suggests the new alternative for InsertTool

    from chat

    looking in header file it now has a new third argument which is a label

    so it should be

    mainTool->InsertTool(1, idToolSave,wxT(""), saveTool);

    This makes the warning vanish.