/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
/*************************************
*
* USED IN:
* The Apartment
*
*************************************/
/*
* --PopMenu, Tool, 1.0, 4/1/90
* --© 1989, 1990 MacroMind, Inc.
* -- by Jeff Tanner
* ------------------------------------------------
* ------------------------------------------------
* -- IMPORTANT NOTE: In Lingo, build PopMenus after using
* -- the command installMenu. On the Mac, Pop-up menus are
* -- extensions of the menu bar. When the command installMenu
* -- is called, this will remove all menus currently on
* -- the menubar (including pop-up menus) and only install those
* -- menus defined in the text window referenced by the
* -- castNum parameter. If installMenu is used after
* -- creating PopMenus, these PopMenus must be disposed of
* -- and then recreated.
* ------------------------------------------------
* -- MENULIST NOTE: In Lingo, there are several ways
* -- to build the menu list for a PopUp menu.
* --
* -- - a menulist can be a continuous string
* -- with items separated by semicolons.
* -- example: "item1;item2;item3"
* --
* -- - a menulist can be a set of strings, each
* -- representing an item, separated by
* -- &return& and ending with &return
* -- example: "item1"&return&"item2"&return
* --
* -- - a menulist could come from a cast member with
* -- each menu item separated by a carrage return.
* -- example: set menulist to the text of cast A31
* ------------------------------------------------
* -- MENUITEM NOTE: Use only alphanumeric characters,
* -- 0 - 9 and A - Z. Avoid dashes. Indicate
* -- style by "item1;item2exposeXObject(xlibName, xobj);
}
}
void PopUpMenuXObj::close(ObjectType type) {
if (type == kXObj) {
PopUpMenuXObject::cleanupMethods();
g_lingo->_globalvars[xlibName] = Datum();
}
}
PopUpMenuXObject::PopUpMenuXObject(ObjectType ObjectType) : Object("PopMenu") {
_objType = ObjectType;
}
void PopUpMenuXObj::m_new(int nargs) {
PopUpMenuXObject *me = static_cast(g_lingo->_state->me.u.obj);
int menuId = g_lingo->pop().asInt();
Common::String menuList = g_lingo->pop().asString();
new Graphics::MacPopUp(menuId, g_director->_wm->getScreenBounds(), g_director->_wm, menuList.c_str());
me->_menuId = menuId;
g_lingo->push(g_lingo->_state->me);
}
void PopUpMenuXObj::m_popNum(int nargs) {
PopUpMenuXObject *me = static_cast(g_lingo->_state->me.u.obj);
int itemNum = g_lingo->pop().asInt();
int top = g_lingo->pop().asInt();
int left = g_lingo->pop().asInt();
// Convert window coordinates to screen coordinates
Common::Rect windowRect = g_director->getCurrentWindow()->getMacWindow()->getInnerDimensions();
int screenTop = top + windowRect.top - 1;
int screenLeft = left + windowRect.left - 1;
Graphics::MacPopUp *menu = static_cast(g_director->_wm->getMenu(me->_menuId));
int selected = menu->drawAndSelectMenu(screenLeft, screenTop, itemNum);
g_lingo->push(Datum(selected));
}
void PopUpMenuXObj::m_popText(int nargs) {
PopUpMenuXObject *me = static_cast(g_lingo->_state->me.u.obj);
int itemNum = g_lingo->pop().asInt();
int top = g_lingo->pop().asInt();
int left = g_lingo->pop().asInt();
// Convert window coordinates to screen coordinates
Common::Rect windowRect = g_director->getCurrentWindow()->getMacWindow()->getInnerDimensions();
int screenTop = top + windowRect.top - 1;
int screenLeft = left + windowRect.left - 1;
Graphics::MacPopUp *menu = static_cast(g_director->_wm->getMenu(me->_menuId));
int selected = menu->drawAndSelectMenu(screenLeft, screenTop, itemNum);
Common::String selectedText = menu->getItemText(selected);
g_lingo->push(Datum(selectedText));
}
void PopUpMenuXObj::m_smart(int nargs) {
PopUpMenuXObject *me = static_cast(g_lingo->_state->me.u.obj);
bool isSmart = g_lingo->pop().asInt() != 0;
Graphics::MacPopUp *menu = static_cast(g_director->_wm->getMenu(me->_menuId));
menu->setSmart(isSmart);
}
XOBJSTUBNR(PopUpMenuXObj::m_appendMenu)
XOBJSTUBNR(PopUpMenuXObj::m_disableItem)
XOBJSTUBNR(PopUpMenuXObj::m_enableItem)
XOBJSTUB(PopUpMenuXObj::m_getItem, "")
XOBJSTUB(PopUpMenuXObj::m_getMenuID, 0)
XOBJSTUBNR(PopUpMenuXObj::m_setItem)
XOBJSTUBNR(PopUpMenuXObj::m_setItemMark)
XOBJSTUBNR(PopUpMenuXObj::m_setItemIcon)
} // End of namespace Director