From 876bbbec3a6bf3d02d4ab7020cc73eaa6e247e9e Mon Sep 17 00:00:00 2001
From: Clyne Sullivan <clyne@bitgloo.com>
Date: Fri, 12 Jun 2020 18:49:09 -0400
Subject: have basic wxwidgets gui working

---
 .gitignore     |  1 +
 gui/Makefile   | 10 +++++++---
 gui/main.cpp   | 22 +++++++++++++---------
 gui/stmdsp.hpp |  7 ++++---
 gui/wxapp.hpp  | 20 ++++++++++++++++++++
 gui/wxmain.hpp | 17 +++++++++++++++++
 6 files changed, 62 insertions(+), 15 deletions(-)
 create mode 100644 gui/wxapp.hpp
 create mode 100644 gui/wxmain.hpp

diff --git a/.gitignore b/.gitignore
index ccfe582..804a382 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 build
 ChibiOS_*
 **/.*
+gui/stmdspgui
 
diff --git a/gui/Makefile b/gui/Makefile
index 419ed33..7cb0315 100644
--- a/gui/Makefile
+++ b/gui/Makefile
@@ -1,13 +1,17 @@
-CXX = clang++-10
-CXXFLAGS = --std=c++20 -Wall -Wextra -pedantic
+CXX = g++-10
+CXXFLAGS = --std=c++20 \
+		   -Wall -Wextra -pedantic \
+		   -Wno-deprecated-copy \
+		   $(shell wx-config --cxxflags)
 
 CXXFILES = $(wildcard *.cpp)
 
+LIBS = $(shell wx-config --libs)
 OUTELF = stmdspgui
 
 all: $(CXXFILES)
 	@echo "  CXX    " $(CXXFILES)
-	@$(CXX) $(CXXFLAGS) $(CXXFILES) -o $(OUTELF)
+	@$(CXX) $(CXXFLAGS) $(CXXFILES) $(LIBS) -o $(OUTELF)
 
 clean:
 	@echo "  CLEAN"
diff --git a/gui/main.cpp b/gui/main.cpp
index 48f2990..ae6ecb4 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -1,15 +1,19 @@
 #include "stmdsp.hpp"
+#include "wxapp.hpp"
 
 #include <iostream>
+#include <wx/app.h>
 
-int main()
-{
-    stmdsp::scanner scanner;
+wxIMPLEMENT_APP(MainApp);
 
-    scanner.scan();
-    for (const auto& device : scanner.devices())
-        std::cout << "Found stmdsp at: " << device.path() << std::endl;
-
-    return 0;
-}
+//int main()
+//{
+//    stmdsp::scanner scanner;
+//
+//    scanner.scan();
+//    for (const auto& device : scanner.devices())
+//        std::cout << "Found stmdsp at: " << device.path() << std::endl;
+//
+//    return 0;
+//}
 
diff --git a/gui/stmdsp.hpp b/gui/stmdsp.hpp
index 12e4578..99a3bd3 100644
--- a/gui/stmdsp.hpp
+++ b/gui/stmdsp.hpp
@@ -1,5 +1,5 @@
-#ifndef STMDSPSCANNER_H
-#define STMDSPSCANNER_H
+#ifndef STMDSP_HPP_
+#define STMDSP_HPP_
 
 #include <fstream>
 #include <set>
@@ -57,4 +57,5 @@ namespace stmdsp
     };
 }
 
-#endif // STMDSPSCANNER_H
+#endif // STMDSP_HPP_
+
diff --git a/gui/wxapp.hpp b/gui/wxapp.hpp
new file mode 100644
index 0000000..6536554
--- /dev/null
+++ b/gui/wxapp.hpp
@@ -0,0 +1,20 @@
+#ifndef WXAPP_HPP_
+#define WXAPP_HPP_
+
+#include "wxmain.hpp"
+
+#include <wx/app.h>
+
+class MainApp : public wxApp
+{
+public:
+    virtual bool OnInit() final {
+        auto mainFrame = new MainFrame;
+        mainFrame->Show(true);
+        SetTopWindow(mainFrame);
+        return true;
+    }
+};
+
+#endif // WXAPP_HPP_
+
diff --git a/gui/wxmain.hpp b/gui/wxmain.hpp
new file mode 100644
index 0000000..b5122f6
--- /dev/null
+++ b/gui/wxmain.hpp
@@ -0,0 +1,17 @@
+#ifndef WXMAIN_HPP_
+#define WXMAIN_HPP_
+
+#include <wx/frame.h>
+#include <wx/stattext.h>
+
+class MainFrame : public wxFrame
+{
+public:
+    MainFrame() : wxFrame(nullptr, -1, "Hello world", wxPoint(50, 50), wxSize(640, 480))
+    {
+        auto lTitle = new wxStaticText(this, wxID_ANY, "Welcome to the GUI.");
+    }
+};
+
+#endif // WXMAIN_HPP_
+
-- 
cgit v1.2.3