summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcat <[email protected]>2023-06-21 20:52:59 +0800
committercat <[email protected]>2023-06-21 20:52:59 +0800
commit2baa93db3dcafd834f4bd68fa47775f8f1ae2e23 (patch)
treeebf9a5547906d2cdeef265b7b1d4dc34ed164ccc
parent960b46e798d5a4977af7e5f0e74b61a59ad61846 (diff)
add wxwidgets template
-rw-r--r--xmake/templates/c++/wxwidgets/project/src/main.cpp44
-rw-r--r--xmake/templates/c++/wxwidgets/project/xmake.lua11
-rw-r--r--xmake/templates/c++/wxwidgets/template.lua3
3 files changed, 58 insertions, 0 deletions
diff --git a/xmake/templates/c++/wxwidgets/project/src/main.cpp b/xmake/templates/c++/wxwidgets/project/src/main.cpp
new file mode 100644
index 000000000..fbf187aa9
--- /dev/null
+++ b/xmake/templates/c++/wxwidgets/project/src/main.cpp
@@ -0,0 +1,44 @@
+#include <wx/wx.h>
+
+namespace Examples {
+ class Frame : public wxFrame {
+ enum wxOwnedID {
+ ID_Hello = 2
+ };
+
+ public:
+ Frame(): wxFrame(nullptr, wxID_ANY, "Hello World") {
+ auto 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);
+
+ auto menuHelp = new wxMenu();
+ menuHelp->Append(wxID_ABOUT);
+ auto menuBar = new wxMenuBar();
+
+ menuBar->Append(menuFile, "&File");
+ menuBar->Append(menuHelp, "&Help");
+ SetMenuBar(menuBar);
+
+ CreateStatusBar();
+ SetStatusText("Welcome to wxWidgets!");
+
+ menuBar->Bind(wxEVT_MENU, [&](wxCommandEvent& event) {
+ if (event.GetId() == ID_Hello) wxLogMessage("Hello world from wxWidgets!");
+ else if (event.GetId() == wxID_ABOUT) wxMessageBox("This is a wxWidgets Hello World example", "About Hello World", wxOK|wxICON_INFORMATION);
+ else if (event.GetId() == wxID_EXIT) Close(true);
+ else event.Skip();
+ });
+ }
+ };
+
+ class Application : public wxApp {
+ bool OnInit() override {
+ (new Frame())->Show();
+ return true;
+ }
+ };
+}
+
+wxIMPLEMENT_APP(Examples::Application); \ No newline at end of file
diff --git a/xmake/templates/c++/wxwidgets/project/xmake.lua b/xmake/templates/c++/wxwidgets/project/xmake.lua
new file mode 100644
index 000000000..4b062189f
--- /dev/null
+++ b/xmake/templates/c++/wxwidgets/project/xmake.lua
@@ -0,0 +1,11 @@
+add_rules("mode.debug", "mode.release")
+
+add_requires("wxwidgets")
+
+target("${TARGETNAME}")
+ set_kind("binary")
+ add_files("src/*.cpp")
+ set_languages("c++14")
+ add_packages("wxwidgets")
+
+${FAQ} \ No newline at end of file
diff --git a/xmake/templates/c++/wxwidgets/template.lua b/xmake/templates/c++/wxwidgets/template.lua
new file mode 100644
index 000000000..ca0fc6319
--- /dev/null
+++ b/xmake/templates/c++/wxwidgets/template.lua
@@ -0,0 +1,3 @@
+template("wxwidgets")
+ add_configfiles("xmake.lua")
+