diff options
author | Eugene Sandulenko | 2017-08-03 19:45:04 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-08-04 21:54:20 +0200 |
commit | afb664df290c54febd48b25efe6eeb5fccc0cfcc (patch) | |
tree | f39427938716e8fd8e72c05eed4ec4f15e966a43 | |
parent | aab404864e16f07307e44ed20310037c05e09ceb (diff) | |
download | scummvm-rg350-afb664df290c54febd48b25efe6eeb5fccc0cfcc.tar.gz scummvm-rg350-afb664df290c54febd48b25efe6eeb5fccc0cfcc.tar.bz2 scummvm-rg350-afb664df290c54febd48b25efe6eeb5fccc0cfcc.zip |
GRAPHICS: MACGUI: Made selection affecting the MacMenu
-rw-r--r-- | engines/wage/gui.cpp | 2 | ||||
-rw-r--r-- | graphics/macgui/macmenu.cpp | 19 | ||||
-rw-r--r-- | graphics/macgui/macmenu.h | 1 | ||||
-rw-r--r-- | graphics/macgui/mactextwindow.cpp | 12 | ||||
-rw-r--r-- | graphics/macgui/mactextwindow.h | 3 | ||||
-rw-r--r-- | graphics/macgui/macwindowmanager.cpp | 4 | ||||
-rw-r--r-- | graphics/macgui/macwindowmanager.h | 2 |
7 files changed, 33 insertions, 10 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index e6e439b018..f4028dfe17 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -183,7 +183,7 @@ Gui::Gui(WageEngine *engine) { uint maxWidth = _screen.w; - _consoleWindow = _wm.addTextWindow(font, kColorBlack, kColorWhite, maxWidth, Graphics::kTextAlignLeft); + _consoleWindow = _wm.addTextWindow(font, kColorBlack, kColorWhite, maxWidth, Graphics::kTextAlignLeft, _menu); #else _consoleWindow = _wm.addWindow(true, true, true); #endif // USE_MACTEXTWINDOW diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 6cb14f9740..e42430ba99 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -591,6 +591,25 @@ void MacMenu::enableCommand(int menunum, int action, bool state) { _contentIsDirty = true; } +void MacMenu::enableCommand(const char *menuitem, const char *menuaction, bool state) { + int menunum = 0; + + while (menunum < _items.size()) + if (_items[menunum]->name.equalsIgnoreCase(menuitem)) + break; + else + menunum++; + + if (menunum == _items.size()) + return; + + for (uint i = 0; i < _items[menunum]->subitems.size(); i++) + if (_items[menunum]->subitems[i]->text.equalsIgnoreCase(menuaction)) + _items[menunum]->subitems[i]->enabled = state; + + _contentIsDirty = true; +} + void MacMenu::disableAllMenus() { for (uint i = 1; i < _items.size(); i++) // Leave About menu on for (uint j = 0; j < _items[i]->subitems.size(); j++) diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h index e7dde9a59a..a25b65afbc 100644 --- a/graphics/macgui/macmenu.h +++ b/graphics/macgui/macmenu.h @@ -59,6 +59,7 @@ public: bool processEvent(Common::Event &event); void enableCommand(int menunum, int action, bool state); + void enableCommand(const char *menuitem, const char *menuaction, bool state); void disableAllMenus(); void setActive(bool active) { _menuActivated = active; } diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp index 506cd364f6..ce84a5b8f0 100644 --- a/graphics/macgui/mactextwindow.cpp +++ b/graphics/macgui/mactextwindow.cpp @@ -26,6 +26,7 @@ #include "graphics/macgui/macwindowmanager.h" #include "graphics/macgui/macfontmanager.h" #include "graphics/macgui/mactextwindow.h" +#include "graphics/macgui/macmenu.h" namespace Graphics { @@ -42,10 +43,11 @@ enum { static void cursorTimerHandler(void *refCon); -MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment) : +MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu) : MacWindow(wm->getLastId(), true, true, true, wm) { _font = font; + _menu = menu; _mactext = new MacText("", _wm, font, fgcolor, bgcolor, maxWidth, textAlignment); _fontRef = wm->_fontMan->getFont(*font); @@ -294,17 +296,17 @@ bool MacTextWindow::processEvent(Common::Event &event) { (_selectedText.endX == _selectedText.startX && _selectedText.endY == _selectedText.startY)) { _selectedText.startY = _selectedText.endY = -1; _contentIsDirty = true; - //_menu->enableCommand(kMenuEdit, kMenuActionCopy, false); + _menu->enableCommand("Edit", "Copy", false); } else { - //_menu->enableCommand(kMenuEdit, kMenuActionCopy, true); + _menu->enableCommand("Edit", "Copy", true); bool cutAllowed = false; if (_selectedText.startY == _selectedText.endY && _selectedText.startY == _mactext->getLineCount() - 1) cutAllowed = true; - //_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed); - //_menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed); + _menu->enableCommand("Edit", "Cut", cutAllowed); + _menu->enableCommand("Edit", "Clear", cutAllowed); } } diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h index 14f9d2c29a..bc1bf2d113 100644 --- a/graphics/macgui/mactextwindow.h +++ b/graphics/macgui/mactextwindow.h @@ -48,7 +48,7 @@ struct SelectedText { class MacTextWindow : public MacWindow { public: - MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment); + MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu); virtual ~MacTextWindow(); virtual void resize(int w, int h); @@ -102,6 +102,7 @@ private: uint _inputTextHeight; bool _inputIsDirty; + MacMenu *_menu; }; } // End of namespace Graphics diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp index d3f7d22c4d..9a3e711c19 100644 --- a/graphics/macgui/macwindowmanager.cpp +++ b/graphics/macgui/macwindowmanager.cpp @@ -183,8 +183,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool edi return w; } -MacTextWindow *MacWindowManager::addTextWindow(const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment) { - MacTextWindow *w = new MacTextWindow(this, font, fgcolor, bgcolor, maxWidth, textAlignment); +MacTextWindow *MacWindowManager::addTextWindow(const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu) { + MacTextWindow *w = new MacTextWindow(this, font, fgcolor, bgcolor, maxWidth, textAlignment, menu); addWindowInitialized(w); diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h index 963fc358dd..bc0224a321 100644 --- a/graphics/macgui/macwindowmanager.h +++ b/graphics/macgui/macwindowmanager.h @@ -107,7 +107,7 @@ public: * @return Pointer to the newly created window. */ MacWindow *addWindow(bool scrollable, bool resizable, bool editable); - MacTextWindow *addTextWindow(const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment); + MacTextWindow *addTextWindow(const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu); /** * Adds a window that has already been initialized to the registry. |