Last active
April 30, 2022 00:55
-
-
Save mingwandroid/9c6c836ddafba547054f to your computer and use it in GitHub Desktop.
WxWidgets CMake MSYS2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cmake -G'MSYS Makefiles' | |
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://wiki.wxwidgets.org/CMake | |
PROJECT(Test) | |
SET(wxWidgets_USE_LIBS) | |
FIND_PACKAGE(wxWidgets) | |
IF(wxWidgets_FOUND) | |
INCLUDE("${wxWidgets_USE_FILE}") | |
ADD_EXECUTABLE(MyTest WIN32 main.cpp) | |
# and for each of your dependant executable/library targets: | |
TARGET_LINK_LIBRARIES(MyTest ${wxWidgets_LIBRARIES}) | |
ELSE(wxWidgets_FOUND) | |
# For convenience. When we cannot continue, inform the user | |
MESSAGE("wxWidgets not found!") | |
ENDIF(wxWidgets_FOUND) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From http://docs.wxwidgets.org/trunk/overview_helloworld.html | |
// wxWidgets "Hello world" Program | |
// For compilers that support precompilation, includes "wx/wx.h". | |
#include <wx/wxprec.h> | |
#ifndef WX_PRECOMP | |
#include <wx/wx.h> | |
#endif | |
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 | |
}; | |
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() | |
wxIMPLEMENT_APP(MyApp); | |
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!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment