GRAPHICS: MACGUI: Made selection affecting the MacMenu
This commit is contained in:
parent
aab404864e
commit
afb664df29
7 changed files with 33 additions and 10 deletions
|
@ -183,7 +183,7 @@ Gui::Gui(WageEngine *engine) {
|
||||||
|
|
||||||
uint maxWidth = _screen.w;
|
uint maxWidth = _screen.w;
|
||||||
|
|
||||||
_consoleWindow = _wm.addTextWindow(font, kColorBlack, kColorWhite, maxWidth, Graphics::kTextAlignLeft);
|
_consoleWindow = _wm.addTextWindow(font, kColorBlack, kColorWhite, maxWidth, Graphics::kTextAlignLeft, _menu);
|
||||||
#else
|
#else
|
||||||
_consoleWindow = _wm.addWindow(true, true, true);
|
_consoleWindow = _wm.addWindow(true, true, true);
|
||||||
#endif // USE_MACTEXTWINDOW
|
#endif // USE_MACTEXTWINDOW
|
||||||
|
|
|
@ -591,6 +591,25 @@ void MacMenu::enableCommand(int menunum, int action, bool state) {
|
||||||
_contentIsDirty = true;
|
_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() {
|
void MacMenu::disableAllMenus() {
|
||||||
for (uint i = 1; i < _items.size(); i++) // Leave About menu on
|
for (uint i = 1; i < _items.size(); i++) // Leave About menu on
|
||||||
for (uint j = 0; j < _items[i]->subitems.size(); j++)
|
for (uint j = 0; j < _items[i]->subitems.size(); j++)
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
bool processEvent(Common::Event &event);
|
bool processEvent(Common::Event &event);
|
||||||
|
|
||||||
void enableCommand(int menunum, int action, bool state);
|
void enableCommand(int menunum, int action, bool state);
|
||||||
|
void enableCommand(const char *menuitem, const char *menuaction, bool state);
|
||||||
void disableAllMenus();
|
void disableAllMenus();
|
||||||
|
|
||||||
void setActive(bool active) { _menuActivated = active; }
|
void setActive(bool active) { _menuActivated = active; }
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "graphics/macgui/macwindowmanager.h"
|
#include "graphics/macgui/macwindowmanager.h"
|
||||||
#include "graphics/macgui/macfontmanager.h"
|
#include "graphics/macgui/macfontmanager.h"
|
||||||
#include "graphics/macgui/mactextwindow.h"
|
#include "graphics/macgui/mactextwindow.h"
|
||||||
|
#include "graphics/macgui/macmenu.h"
|
||||||
|
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
|
|
||||||
|
@ -42,10 +43,11 @@ enum {
|
||||||
|
|
||||||
static void cursorTimerHandler(void *refCon);
|
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) {
|
MacWindow(wm->getLastId(), true, true, true, wm) {
|
||||||
|
|
||||||
_font = font;
|
_font = font;
|
||||||
|
_menu = menu;
|
||||||
_mactext = new MacText("", _wm, font, fgcolor, bgcolor, maxWidth, textAlignment);
|
_mactext = new MacText("", _wm, font, fgcolor, bgcolor, maxWidth, textAlignment);
|
||||||
|
|
||||||
_fontRef = wm->_fontMan->getFont(*font);
|
_fontRef = wm->_fontMan->getFont(*font);
|
||||||
|
@ -294,17 +296,17 @@ bool MacTextWindow::processEvent(Common::Event &event) {
|
||||||
(_selectedText.endX == _selectedText.startX && _selectedText.endY == _selectedText.startY)) {
|
(_selectedText.endX == _selectedText.startX && _selectedText.endY == _selectedText.startY)) {
|
||||||
_selectedText.startY = _selectedText.endY = -1;
|
_selectedText.startY = _selectedText.endY = -1;
|
||||||
_contentIsDirty = true;
|
_contentIsDirty = true;
|
||||||
//_menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
|
_menu->enableCommand("Edit", "Copy", false);
|
||||||
} else {
|
} else {
|
||||||
//_menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
|
_menu->enableCommand("Edit", "Copy", true);
|
||||||
|
|
||||||
bool cutAllowed = false;
|
bool cutAllowed = false;
|
||||||
|
|
||||||
if (_selectedText.startY == _selectedText.endY && _selectedText.startY == _mactext->getLineCount() - 1)
|
if (_selectedText.startY == _selectedText.endY && _selectedText.startY == _mactext->getLineCount() - 1)
|
||||||
cutAllowed = true;
|
cutAllowed = true;
|
||||||
|
|
||||||
//_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
|
_menu->enableCommand("Edit", "Cut", cutAllowed);
|
||||||
//_menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed);
|
_menu->enableCommand("Edit", "Clear", cutAllowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct SelectedText {
|
||||||
|
|
||||||
class MacTextWindow : public MacWindow {
|
class MacTextWindow : public MacWindow {
|
||||||
public:
|
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 ~MacTextWindow();
|
||||||
|
|
||||||
virtual void resize(int w, int h);
|
virtual void resize(int w, int h);
|
||||||
|
@ -102,6 +102,7 @@ private:
|
||||||
uint _inputTextHeight;
|
uint _inputTextHeight;
|
||||||
bool _inputIsDirty;
|
bool _inputIsDirty;
|
||||||
|
|
||||||
|
MacMenu *_menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Graphics
|
} // End of namespace Graphics
|
||||||
|
|
|
@ -183,8 +183,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool edi
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacTextWindow *MacWindowManager::addTextWindow(const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign 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);
|
MacTextWindow *w = new MacTextWindow(this, font, fgcolor, bgcolor, maxWidth, textAlignment, menu);
|
||||||
|
|
||||||
addWindowInitialized(w);
|
addWindowInitialized(w);
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public:
|
||||||
* @return Pointer to the newly created window.
|
* @return Pointer to the newly created window.
|
||||||
*/
|
*/
|
||||||
MacWindow *addWindow(bool scrollable, bool resizable, bool editable);
|
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.
|
* Adds a window that has already been initialized to the registry.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue