Added support for wxwidgets. Closes #27.

pull/34/head
Jussi Pakkanen 10 years ago
parent 646afcac0d
commit 59b7fa8ed3
  1. 67
      dependencies.py
  2. 23
      test cases/frameworks/9 wxwidgets/mainwin.h
  3. 10
      test cases/frameworks/9 wxwidgets/meson.build
  4. 57
      test cases/frameworks/9 wxwidgets/wxprog.cpp

@ -135,6 +135,72 @@ class PkgConfigDependency(Dependency):
def found(self):
return self.is_found
class WxDependency(Dependency):
wx_found = None
def __init__(self, kwargs):
Dependency.__init__(self)
if WxDependency.wx_found is None:
self.check_wxconfig()
if not WxDependency.wx_found:
raise DependencyException('Wx-config not found.')
self.is_found = False
p = subprocess.Popen(['wx-config', '--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
mlog.log('Dependency wxwidgets found:', mlog.red('NO'))
self.cargs = []
self.libs = []
self.is_found = False
else:
mlog.log('Dependency wxwidgets found:', mlog.green('YES'))
self.is_found = True
self.modversion = out.decode().strip()
# wx-config seems to have a cflags as well but since it requires C++,
# this should be good, at least for now.
p = subprocess.Popen(['wx-config', '--cxxflags'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate cargs for wxwidgets.')
self.cargs = out.decode().split()
p = subprocess.Popen(['wx-config', '--libs'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate libs for wxwidgets.')
self.libs = out.decode().split()
def get_modversion(self):
return self.modversion
def get_compile_args(self):
return self.cargs
def get_link_args(self):
return self.libs
def check_wxconfig(self):
try:
p = subprocess.Popen(['wx-config', '--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode == 0:
mlog.log('Found wx-config:', mlog.bold(shutil.which('wx-config')),
'(%s)' % out.decode().strip())
WxDependency.wx_found = True
return
except Exception:
pass
WxDependency.wxconfig_found = False
mlog.log('Found wx-config:', mlog.red('NO'))
def found(self):
return self.is_found
class ExternalProgram():
def __init__(self, name, fullpath=None, silent=False, search_dir=None):
self.name = name
@ -730,4 +796,5 @@ packages = {'boost': BoostDependency,
'Qt5': Qt5Dependency, # Qt people sure do love their upper case.
'gnustep': GnuStepDependency,
'appleframeworks': AppleFrameworks,
'wxwidgets' : WxDependency,
}

@ -0,0 +1,23 @@
#pragma once
#include <wx/wx.h>
class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
void OnHello(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE();
};
enum {
ID_Hello = 1
};

@ -0,0 +1,10 @@
project('wxwidgets test', 'cpp')
add_global_arguments('-std=c++11', language : 'cpp')
wxd = dependency('wxwidgets')
wp = executable('wxprog', 'wxprog.cpp',
dependencies : wxd)
test('wxtest', wp)

@ -0,0 +1,57 @@
#include"mainwin.h"
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Hello, MyFrame::OnHello)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
wxEND_EVENT_TABLE()
bool MyApp::OnInit() {
MyFrame *frame = new MyFrame( "Hello World", 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) {
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
"Help string shown in status bar for this menu item");
menuFile->AppendSeparator();
menuFile->Append(wxID_EXIT);
wxMenu *menuHelp = new wxMenu;
menuHelp->Append(wxID_ABOUT);
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, "&File" );
menuBar->Append( menuHelp, "&Help" );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( "Welcome to wxWidgets!" );
}
void MyFrame::OnExit(wxCommandEvent& event) {
Close( true );
}
void MyFrame::OnAbout(wxCommandEvent& event) {
wxMessageBox( "This is a wxWidgets' Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION );
}
void MyFrame::OnHello(wxCommandEvent& event) {
wxLogMessage("Hello world from wxWidgets!");
}
#if 0
wxIMPLEMENT_APP(MyApp);
#else
// Don't open a window because this is an unit test and needs to
// run headless.
int main(int, char **) {
wxString name("Some app");
wxPoint p(0, 0);
wxSize s(100, 100);
return 0;
}
#endif
Loading…
Cancel
Save