mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add a boilerplate wxwidgets example.
This commit is contained in:
3
Makefile
3
Makefile
@@ -48,9 +48,10 @@ export CXX = g++
|
||||
export AR = ar rc
|
||||
export RANLIB = ranlib
|
||||
export STRIP = strip
|
||||
export CFLAGS += $(shell pkg-config --cflags $(PACKAGES))
|
||||
export CFLAGS += $(shell pkg-config --cflags $(PACKAGES)) $(shell wx-config --cflags)
|
||||
export LDFLAGS +=
|
||||
export LIBS += $(shell pkg-config --libs $(PACKAGES))
|
||||
export GUILIBS += $(shell wx-config --libs)
|
||||
export EXTENSION =
|
||||
|
||||
ifeq ($(shell uname),Darwin)
|
||||
|
||||
@@ -551,6 +551,9 @@ buildlibrary libfrontend.a \
|
||||
src/fe-write.cc \
|
||||
src/fluxengine.cc \
|
||||
|
||||
buildlibrary libgui.a \
|
||||
src/gui/main.cc
|
||||
|
||||
buildprogram fluxengine \
|
||||
libfrontend.a \
|
||||
libformats.a \
|
||||
@@ -561,6 +564,10 @@ buildprogram fluxengine \
|
||||
libfmt.a \
|
||||
libagg.a \
|
||||
|
||||
buildprogram fluxengine-gui \
|
||||
-rule linkgui \
|
||||
libgui.a
|
||||
|
||||
buildlibrary libemu.a \
|
||||
dep/emu/fnmatch.c
|
||||
|
||||
|
||||
70
src/gui/main.cc
Normal file
70
src/gui/main.cc
Normal file
@@ -0,0 +1,70 @@
|
||||
#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();
|
||||
private:
|
||||
void OnHello(wxCommandEvent& event);
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
};
|
||||
enum
|
||||
{
|
||||
ID_Hello = 1
|
||||
};
|
||||
wxIMPLEMENT_APP(MyApp);
|
||||
bool MyApp::OnInit()
|
||||
{
|
||||
MyFrame *frame = new MyFrame();
|
||||
frame->Show(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
MyFrame::MyFrame()
|
||||
: wxFrame(NULL, wxID_ANY, "Hello World")
|
||||
{
|
||||
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!");
|
||||
Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
|
||||
Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
|
||||
Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
|
||||
}
|
||||
|
||||
void MyFrame::OnExit(wxCommandEvent& event)
|
||||
{
|
||||
Close(true);
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
wxMessageBox("This is a wxWidgets Hello World example",
|
||||
"About Hello World", wxOK | wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
void MyFrame::OnHello(wxCommandEvent& event)
|
||||
{
|
||||
wxLogMessage("Hello world from wxWidgets!");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user