diff options
| -rw-r--r-- | GUI/GUI/GUI/App.cpp | 10 | ||||
| -rw-r--r-- | GUI/GUI/GUI/App.h | 13 | ||||
| -rw-r--r-- | GUI/GUI/GUI/Frame.cpp | 27 | ||||
| -rw-r--r-- | GUI/GUI/GUI/Frame.h | 20 | ||||
| -rw-r--r-- | GUI/GUI/GUI/GUI.vcxproj | 4 | ||||
| -rw-r--r-- | GUI/GUI/GUI/GUI.vcxproj.filters | 12 | ||||
| -rw-r--r-- | GUI/GUI/GUI/main.cpp | 74 |
7 files changed, 87 insertions, 73 deletions
diff --git a/GUI/GUI/GUI/App.cpp b/GUI/GUI/GUI/App.cpp new file mode 100644 index 0000000..8456447 --- /dev/null +++ b/GUI/GUI/GUI/App.cpp @@ -0,0 +1,10 @@ +#include "App.h"
+#include "Frame.h"
+
+bool MyApp::OnInit()
+{
+ Frame* frame = new Frame();
+ frame->Show(true);
+
+ return true;
+}
diff --git a/GUI/GUI/GUI/App.h b/GUI/GUI/GUI/App.h new file mode 100644 index 0000000..fe6eeec --- /dev/null +++ b/GUI/GUI/GUI/App.h @@ -0,0 +1,13 @@ +#pragma once
+
+#include <wx/wxprec.h>
+
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+class MyApp : public wxApp
+{
+public:
+ virtual bool OnInit();
+};
diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp new file mode 100644 index 0000000..841bfb9 --- /dev/null +++ b/GUI/GUI/GUI/Frame.cpp @@ -0,0 +1,27 @@ +#include "Frame.h"
+
+#include <filesystem>
+
+Frame::Frame()
+ : wxFrame(nullptr, wxID_ANY, "TaSTT")
+{
+ Bind(wxEVT_MENU, &Frame::OnExit, this, wxID_EXIT);
+
+ // wx needs this to be able to load PNGs.
+ wxImage::AddHandler(&png_handler_);
+
+ const std::string logo_path = "Resources/logo.png";
+ if (!std::filesystem::exists(logo_path)) {
+ wxLogFatalError("Logo is missing from %s", logo_path.c_str());
+ }
+ wxBitmap icon_img("Resources/logo.png", wxBITMAP_TYPE_PNG);
+ wxIcon icon;
+ icon.CopyFromBitmap(icon_img);
+ SetIcon(icon);
+}
+
+void Frame::OnExit(wxCommandEvent& event)
+{
+ Close(true);
+}
+
diff --git a/GUI/GUI/GUI/Frame.h b/GUI/GUI/GUI/Frame.h new file mode 100644 index 0000000..4dcfd4a --- /dev/null +++ b/GUI/GUI/GUI/Frame.h @@ -0,0 +1,20 @@ +#pragma once
+
+#include <wx/wxprec.h>
+
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+class Frame : public wxFrame
+{
+public:
+ Frame();
+
+private:
+ wxPNGHandler png_handler_;
+
+ void OnHello(wxCommandEvent& event);
+ void OnExit(wxCommandEvent& event);
+ void OnAbout(wxCommandEvent& event);
+};
diff --git a/GUI/GUI/GUI/GUI.vcxproj b/GUI/GUI/GUI/GUI.vcxproj index e97523c..79bb220 100644 --- a/GUI/GUI/GUI/GUI.vcxproj +++ b/GUI/GUI/GUI/GUI.vcxproj @@ -135,9 +135,13 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="App.cpp" />
+ <ClCompile Include="Frame.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="App.h" />
+ <ClInclude Include="Frame.h" />
<ClInclude Include="ScopeGuard.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/GUI/GUI/GUI/GUI.vcxproj.filters b/GUI/GUI/GUI/GUI.vcxproj.filters index beb1941..c332693 100644 --- a/GUI/GUI/GUI/GUI.vcxproj.filters +++ b/GUI/GUI/GUI/GUI.vcxproj.filters @@ -18,10 +18,22 @@ <ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="App.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Frame.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ScopeGuard.h">
<Filter>Source Files</Filter>
</ClInclude>
+ <ClInclude Include="App.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Frame.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/GUI/GUI/GUI/main.cpp b/GUI/GUI/GUI/main.cpp index c2e0222..d9303f5 100644 --- a/GUI/GUI/GUI/main.cpp +++ b/GUI/GUI/GUI/main.cpp @@ -1,4 +1,4 @@ -// wxWidgets "Hello World" Program
+#include "App.h"
#include <wx/wxprec.h>
@@ -6,77 +6,5 @@ #include <wx/wx.h>
#endif
-#include "ScopeGuard.h"
-
-#include <filesystem>
-
-class MyApp : public wxApp
-{
-public:
- virtual bool OnInit();
-};
-
-class MyFrame : public wxFrame
-{
-public:
- MyFrame();
-
-private:
- wxPNGHandler png_handler_;
-
- 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(nullptr, wxID_ANY, "TaSTT")
-{
- Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
- Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
- Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
-
- // wx needs this to be able to load PNGs.
- wxImage::AddHandler(&png_handler_);
-
- const std::string logo_path = "Resources/logo.png";
- if (!std::filesystem::exists(logo_path)) {
- wxLogFatalError("Logo is missing from %s", logo_path.c_str());
- }
- wxBitmap icon_img("Resources/logo.png", wxBITMAP_TYPE_PNG);
- wxIcon icon;
- icon.CopyFromBitmap(icon_img);
- SetIcon(icon);
-}
-
-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!");
-}
-
|
