Skip to content

Instantly share code, notes, and snippets.

@hajimehoshi
Created February 28, 2012 16:29
Show Gist options
  • Save hajimehoshi/1933478 to your computer and use it in GitHub Desktop.
Save hajimehoshi/1933478 to your computer and use it in GitHub Desktop.
wxMac 2.8 Test
// Ref: http://www.wxwidgets.org/docs/tutorials/hello.htm
#include "wx/wx.h"
enum {
ID_Quit = 1,
ID_About,
};
class MyFrame : public wxFrame {
public:
MyFrame(wxString const& title,
wxPoint const& pos,
wxSize const& size)
: wxFrame(0, -1, title, pos, size) {
wxMenu* menuFile = new wxMenu();
menuFile->Append(ID_About, _("&About..."));
menuFile->AppendSeparator();
menuFile->Append(ID_Quit, _("E&xit"));
wxMenuBar* menuBar = new wxMenuBar();
menuBar->Append(menuFile, _("&File"));
SetMenuBar(menuBar);
CreateStatusBar();
SetStatusText(_("Welcome to wxWidgets!"));
}
void
OnQuit(wxCommandEvent& event) {
Close(true);
}
void
OnAbout(wxCommandEvent& event) {
wxMessageBox(_("This is a wxWidgets Hello world sample"),
_("About Hello World"),
wxOK | wxICON_INFORMATION,
this);
}
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
class MyApp : public wxApp {
virtual bool OnInit() {
MyFrame* frame = new MyFrame(_("Hello World"), wxPoint(50, 50), wxSize(450, 340));
frame->Show(true);
SetTopWindow(frame);
return true;
}
};
IMPLEMENT_APP(MyApp)
TARG := wxtest
run: $(TARG).app
open $<
$(TARG).app: $(TARG)
mkdir -p $@/Contents/MacOS
cp $< $@/Contents/MacOS
$(TARG): main.cpp
clang++ -o $@ `wx-config --cppflags --libs` $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment