wxMaxima
Loading...
Searching...
No Matches
Data Structures | Functions
MaximaMenuSync.h File Reference

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>
Include dependency graph for MaximaMenuSync.h:
This graph shows which files directly or indirectly include this file:

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.
 

Detailed Description

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.

Function Documentation

◆ MaximaMenuSyncRows()

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.

◆ SyncMenusToMaximaVariable()

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).

Returns
true if the variable has a row in the table (whether or not any check mark changed), false if it is not menu-synced.