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:
2026-06-03 21:01:02 +02:00
parent e561c0f960
commit 4803d7d01c
8 changed files with 493 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
#ifndef _WX_FRAME_HPP_
#define _WX_FRAME_HPP_
#include <wx/frame.h>
class WxFrontend;
class wxTreeCtrl;
class wxTextCtrl;
class wxCommandEvent;
// The essim main window. Holds no domain state of its own: it reads and mutates
// the System owned by the WxFrontend, calling the core/app operations directly
// (load, verify, export, save, restore) and rendering their results into a
// model tree, an overview panel and a log.
class EssimFrame : public wxFrame {
public:
explicit EssimFrame(WxFrontend &fe);
private:
// Menu handlers — each is a thin wrapper over a core/app operation.
void OnLoad(wxCommandEvent &);
void OnRestore(wxCommandEvent &);
void OnSave(wxCommandEvent &);
void OnExport(wxCommandEvent &);
void OnVerify(wxCommandEvent &);
void OnQuit(wxCommandEvent &);
void OnAbout(wxCommandEvent &);
void RebuildModelView(); ///< refresh tree + overview from the System
void Log(const wxString &line); ///< append a line to the log pane
WxFrontend &fe_;
wxTreeCtrl *tree_ = nullptr;
wxTextCtrl *overview_ = nullptr;
wxTextCtrl *log_ = nullptr;
};
#endif // _WX_FRAME_HPP_