|
wxMaxima
|
Declares the table that keeps menu check marks in sync with Maxima's variables. More...
#include "precomp.h"#include <wx/menu.h>#include <wx/string.h>#include <cstdint>#include <vector>Go to the source code of this file.
Data Structures | |
| struct | MaximaMenuSyncEntry |
| One menu item a Maxima variable value maps to. More... | |
| struct | MaximaMenuSyncRow |
| How the check marks of one Maxima variable's menu items follow its value. More... | |
Functions | |
| const std::vector< MaximaMenuSyncRow > & | MaximaMenuSyncRows () |
| The variable-to-menu-items table itself. | |
| bool | SyncMenusToMaximaVariable (wxMenuBar *menubar, const wxString &variable, const wxString &value) |
| Update the menu check marks that mirror one Maxima variable. | |
Declares the table that keeps menu check marks in sync with Maxima's variables.
Maxima informs wxMaxima whenever one of a watched set of its option variables changes (see MaximaVariableUpdates). For many of these variables the only thing wxMaxima does with the new value is update the check mark of the menu item that controls the same option - a dozen hand-written handler methods inside the wxMaxima god class that all looked alike. That mapping is data, not code, so it now lives in one declarative variable-to-menu-items table here, applied by a single function (the same move that replaced the hand-synced configuration Read/Write pairs with Configuration::ScalarConfigSettings). Handlers with real logic beyond the check mark stay hand-written in wxMaxima.
| const std::vector< MaximaMenuSyncRow > & MaximaMenuSyncRows | ( | ) |
The variable-to-menu-items table itself.
Built on first use so the dynamically-allocated menu ids in EventIDs are guaranteed to exist, whatever the translation units' initialization order.
| bool SyncMenusToMaximaVariable | ( | wxMenuBar * | menubar, |
| const wxString & | variable, | ||
| const wxString & | value | ||
| ) |
Update the menu check marks that mirror one Maxima variable.
Looks the variable up in MaximaMenuSyncRows() and applies its row to the items in menubar (missing items are skipped, so a menu that only exists conditionally cannot make this fail).