void pMenu::append(Action &action) {
action.p.parentMenu = &menu;
if(parentWindow) parentWindow->p.updateMenu();
}
void pMenu::remove(Action &action) {
if(parentWindow) parentWindow->p.updateMenu();
action.p.parentMenu = 0;
}
void pMenu::setText(const string &text) {
if(parentWindow) parentWindow->p.updateMenu();
}
void pMenu::constructor() {
hmenu = 0;
}
//Windows actions lack the ability to toggle visibility.
//To support this, menus must be destroyed and recreated when toggling any action's visibility.
void pMenu::update(Window &parentWindow, Menu *parentMenu) {
this->parentMenu = parentMenu;
this->parentWindow = &parentWindow;
if(hmenu) DestroyMenu(hmenu);
hmenu = CreatePopupMenu();
for(auto &action : menu.state.action) {
action.p.parentMenu = &menu;
action.p.parentWindow = &parentWindow;
unsigned enabled = action.state.enabled ? 0 : MF_GRAYED;
if(dynamic_cast