Reputation: 147
I'm trying to accomplish a very simple task, add a toolbar to an app. I tried the most simple thing I could come up with, but the result is kind of strange, and I was wondering if this is suppose to behave this way or if I'm missing something.
The code is below, note that I even tried to use a native image(commented), but the result was the same.
#include <wx/wx.h>
#include <wx/image.h>
// #include <wx/artprov.h>
class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
};
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame("Simple test", wxPoint(50, 50), wxSize(450, 340) );
frame->Show( true );
return true;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, wxID_ANY, title, pos, size)
{
// wxToolBar *toolbar = CreateToolBar();
// toolbar->AddTool(1001, _("New"), wxArtProvider::GetBitmap("wxART_NEW"));
// toolbar->Realize();
CreateStatusBar();
SetStatusText(wxT("Start"));
wxInitAllImageHandlers();
wxImage image(wxT("save.png"), wxBITMAP_TYPE_PNG);
if (image.Ok())
{
wxToolBar *toolbar = CreateToolBar();
toolbar->AddTool(1001, _("New"), image);
toolbar->Realize();
}
else
{
SetStatusText(wxT("image not ok"));
}
}
The result is here, note that the icon is in the app bar instead in a separate toolbar.
Upvotes: 1
Views: 363
Reputation: 22688
This is how toolbars work in recent macOS versions and wxWidgets is all about using the native UI, so this is most definitely a feature and not a bug, as this is how the native apps look too -- just look at Finder, for example.
Upvotes: 2