很抱歉这个(可能非常愚蠢)的问题,但我很困惑:我尝试使用SetScaleMode()
as described in the documentation在wxWidgets v3.0.2中缩放位图。我使用了include语句,虽然我的编译器(GCC遵循C ++ 11)说'class wxStaticBitmap' has no member named 'SetScaleMode'|
和'Scale_AspectFit' was not declared in this scope|
。
也许我忽略了一些东西,下面是我的(缩短的)代码:
#include <wx/msgdlg.h>
#include <wx/thread.h>
#include <wx/event.h>
#include <wx/statbmp.h>
//(*InternalHeaders(WindowsDgpsGUIFrame)
#include <wx/bitmap.h>
#include <wx/icon.h>
#include <wx/intl.h>
#include <wx/image.h>
#include <wx/string.h>
//*)
//wxTextFile file;
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(WindowsDgpsGUIFrame)
const long WindowsDgpsGUIFrame::ID_STATICBITMAP1 = wxNewId();
const long WindowsDgpsGUIFrame::ID_PANEL1 = wxNewId();
BEGIN_EVENT_TABLE(WindowsDgpsGUIFrame,wxFrame)
//(*EventTable(WindowsDgpsGUIFrame)
//*)
END_EVENT_TABLE()
WindowsDgpsGUIFrame::WindowsDgpsGUIFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(WindowsDgpsGUIFrame)
wxBoxSizer* pBitmapBoxSizer;
wxBoxSizer* pPanelBoxSizer;
Create(parent, wxID_ANY, _("SensoRun"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxMAXIMIZE_BOX, _T("wxID_ANY"));
SetForegroundColour(wxColour(187,0,0));
SetBackgroundColour(wxColour(128,128,128));
{
wxIcon FrameIcon;
FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T(".\\resources\\sd.ico"))));
SetIcon(FrameIcon);
}
pPanel = new wxPanel(this, ID_PANEL1, wxPoint(280,352), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
pPanelBoxSizer = new wxBoxSizer(wxVERTICAL);
pBitmapBoxSizer = new wxBoxSizer(wxVERTICAL);
StaticDirectionBitmap = new wxStaticBitmap(pPanel, ID_STATICBITMAP1, wxBitmap(wxImage(_T(".\\resources\\kein_pfeil.png"))), wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER, _T("ID_STATICBITMAP1"));
pBitmapBoxSizer->Add(StaticDirectionBitmap, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
pPanelBoxSizer->Add(pBitmapBoxSizer, 1, wxALL|wxEXPAND|wxFIXED_MINSIZE|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticDirectionBitmap->SetScaleMode(Scale_AspectFit);
}
(我希望我没有删除这个片段中重要的内容,我想让它更容易阅读)
答案 0 :(得分:0)
正如您在链接到的文档中肯定会看到的那样,wxStaticBitmap::SetScaleMode()
是Since 3.1.0
,而您使用的是“wxWidgets v3.0.2”。所以只需升级到正确的版本。