add text editor to gui

pull/3/head
Clyne 4 years ago
parent 32fc992f6a
commit 02ef389567

@ -0,0 +1,45 @@
The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License
The work in the DejaVu project was committed to the public domain.
Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera"
### MIT License
Copyright (c) 2018 Source Foundry Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
### BITSTREAM VERA LICENSE
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.

Binary file not shown.

@ -8,7 +8,7 @@ CXXFLAGS = --std=c++20 -ggdb -Og \
CXXFILES = $(shell find serial/src -name "*.cc") $(wildcard *.cpp) CXXFILES = $(shell find serial/src -name "*.cc") $(wildcard *.cpp)
OFILES = $(patsubst %.cc, %.o, $(patsubst %.cpp, %.o, $(CXXFILES))) OFILES = $(patsubst %.cc, %.o, $(patsubst %.cpp, %.o, $(CXXFILES)))
LIBS = $(shell wx-config --libs) LIBS = $(shell wx-config --libs) -lwx_gtk3u_stc-3.1
OUTELF = stmdspgui OUTELF = stmdspgui
all: $(OUTELF) all: $(OUTELF)

@ -9,8 +9,10 @@
#include <wx/combobox.h> #include <wx/combobox.h>
#include <wx/dcclient.h> #include <wx/dcclient.h>
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include <wx/font.h>
#include <wx/frame.h> #include <wx/frame.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/stc/stc.h>
#include <wx/timer.h> #include <wx/timer.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>
@ -28,18 +30,54 @@ class MainFrame : public wxFrame
wxTimer *m_render_timer = nullptr; wxTimer *m_render_timer = nullptr;
wxComboBox *m_device_combo = nullptr; wxComboBox *m_device_combo = nullptr;
const wxRect m_clipping_region = {20, 100, 600, 360}; const wxRect m_clipping_region = {20, 500, 600, 360};
stmdsp::device *m_device = nullptr; stmdsp::device *m_device = nullptr;
std::future<std::vector<stmdsp::adcsample_t>> m_device_samples_future; std::future<std::vector<stmdsp::adcsample_t>> m_device_samples_future;
std::vector<stmdsp::adcsample_t> m_device_samples; std::vector<stmdsp::adcsample_t> m_device_samples;
public: public:
MainFrame() : wxFrame(nullptr, -1, "Hello world", wxPoint(50, 50), wxSize(640, 480)) MainFrame() : wxFrame(nullptr, -1, "Hello world", wxPoint(50, 50), wxSize(640, 880))
{ {
new wxStaticText(this, Id::Welcome, "Welcome to the GUI.", wxPoint(20, 20)); new wxStaticText(this, Id::Welcome, "Welcome to the GUI.", wxPoint(20, 20));
new wxButton(this, Id::Single, "Single", wxPoint(20, 60)); new wxButton(this, Id::Single, "Single", wxPoint(20, 60));
new wxButton(this, Id::UploadFilter, "Upload Filter", wxPoint(120, 60)); new wxButton(this, Id::UploadFilter, "Upload Filter", wxPoint(120, 60));
auto stc = new wxStyledTextCtrl(this, wxID_ANY, wxPoint(20, 100), wxSize(600, 400));
stc->SetLexer(wxSTC_LEX_CPP);
stc->SetMarginWidth(0, 30);
stc->SetMarginType(0, wxSTC_MARGIN_NUMBER);
wxFont::AddPrivateFont("./Hack-Regular.ttf");
stc->StyleSetFaceName(wxSTC_STYLE_DEFAULT, "Hack");
stc->StyleClearAll();
stc->SetTabWidth(4);
stc->StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColor(75, 75, 75));
stc->StyleSetBackground(wxSTC_STYLE_LINENUMBER, wxColor(220, 220, 220));
stc->StyleSetForeground (wxSTC_C_STRING, wxColour(150,0,0));
stc->StyleSetForeground (wxSTC_C_PREPROCESSOR, wxColour(165,105,0));
stc->StyleSetForeground (wxSTC_C_IDENTIFIER, wxColour(40,0,60));
stc->StyleSetForeground (wxSTC_C_NUMBER, wxColour(0,150,0));
stc->StyleSetForeground (wxSTC_C_CHARACTER, wxColour(150,0,0));
stc->StyleSetForeground (wxSTC_C_WORD, wxColour(0,0,150));
stc->StyleSetForeground (wxSTC_C_WORD2, wxColour(0,150,0));
stc->StyleSetForeground (wxSTC_C_COMMENT, wxColour(150,150,150));
stc->StyleSetForeground (wxSTC_C_COMMENTLINE, wxColour(150,150,150));
stc->StyleSetForeground (wxSTC_C_COMMENTDOC, wxColour(150,150,150));
stc->StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORD, wxColour(0,0,200));
stc->StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORDERROR, wxColour(0,0,200));
stc->StyleSetBold(wxSTC_C_WORD, true);
stc->StyleSetBold(wxSTC_C_WORD2, true);
stc->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true);
// a sample list of keywords, I haven't included them all to keep it short...
stc->SetKeyWords(0,
wxT("return for while do break continue if else goto"));
stc->SetKeyWords(1,
wxT("void char short int long float double unsigned signed "
"volatile static const constexpr constinit consteval "
"virtual final noexcept public private protected"));
m_device_combo = new wxComboBox(this, Id::SelectDevice, "", wxPoint(470, 20), wxSize(150, 30)); m_device_combo = new wxComboBox(this, Id::SelectDevice, "", wxPoint(470, 20), wxSize(150, 30));
m_device_combo->SetEditable(false); m_device_combo->SetEditable(false);
stmdsp::scanner scanner; stmdsp::scanner scanner;

Loading…
Cancel
Save