Add a wxWidgets GUI frontend (second frontend, proves the split).
A native wx GUI built entirely on essim_core via the Frontend interface — no
Tui reuse, no command shell. Demonstrates the core/frontends architecture by
adding a real second frontend:
- WxFrontend : public Frontend — owns the System + a console buffer; handles
boot headlessly (restore for --restore/--batch; honest note for source);
Run() boots wx without a generated main (SetInstance + wxEntryStart/
CallOnInit/OnRun) so the shared frontend_main stays in control.
- EssimFrame (wxFrame) — menu-driven window: Load (app::load_module), Restore/
Save (persist), Export (app::export_connections), Verify (app::verify),
rendered into a model tree (modules → parts), an overview + verify-health
panel, and a log. Each handler is a thin wrapper over a core/app op.
- main.cpp: construct WxFrontend, call frontend_main — same 4 lines as tui.
- CMakeLists.txt: find_package(wxWidgets) + essim_add_frontend(wx LIBS …);
select with -DESSIM_FRONTEND=wx. ESSIM_FRONTEND gains wx in its STRINGS.
Set LC_CTYPE from the environment at GUI init so wxString decodes the UTF-8 in
narrow literals (em dash, ellipsis); LC_NUMERIC stays "C". .gitignore: build*/.
Needs libwxgtk3.2-dev. Verified: builds clean (wx 3.2.9 GTK3), window opens and
renders with no wx asserts; --commands-md/--restore/--batch behave headlessly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
37
src/frontends/wx/wx_frontend.hpp
Normal file
37
src/frontends/wx/wx_frontend.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _WX_FRONTEND_HPP_
|
||||
#define _WX_FRONTEND_HPP_
|
||||
|
||||
#include "frontends/frontend.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class System;
|
||||
|
||||
// wxWidgets GUI frontend. Implements the shared Frontend interface so the same
|
||||
// launcher (frontend_main) drives it: it owns the System and a console buffer,
|
||||
// handles boot commands headlessly (for --restore/--batch), and Run() opens the
|
||||
// wxWidgets window. The window itself (EssimFrame) drives essim_core / app::*
|
||||
// operations directly — no command shell, no TUI reuse.
|
||||
class WxFrontend : public Frontend {
|
||||
public:
|
||||
WxFrontend();
|
||||
~WxFrontend() override;
|
||||
|
||||
// --- Frontend interface ---
|
||||
void BootDispatch(const std::string &raw) override;
|
||||
void DumpCommandsMd(std::ostream &out) const override;
|
||||
void DumpOutput(std::ostream &out) const override;
|
||||
void Run() override;
|
||||
|
||||
// --- used by the window (EssimFrame) ---
|
||||
System *system() const { return sys_.get(); }
|
||||
void set_system(System *fresh); ///< take ownership (used by Restore)
|
||||
void ensure_system(); ///< create an empty System if none yet
|
||||
|
||||
private:
|
||||
std::unique_ptr<System> sys_;
|
||||
std::string output_; ///< console buffer surfaced by DumpOutput (batch)
|
||||
};
|
||||
|
||||
#endif // _WX_FRONTEND_HPP_
|
||||
Reference in New Issue
Block a user