void GfxMenu::kernelDrawMenuBar(bool clear) { if (!clear) { Port *oldPort = _ports->setPort(_ports->_menuPort); calculateMenuWidth(); drawBar(); _paint16->bitsShow(_ports->_menuBarRect); _ports->setPort(oldPort); } else { kernelDrawStatus("", 0, 0); } }
void Menu::calcMenuBounds(MenuItem *menu) { // TODO: cache maxWidth int maxWidth = calculateMenuWidth(menu); int x1 = menu->bbox.left - 1; int y1 = menu->bbox.bottom + 1; int x2 = x1 + maxWidth + kMenuDropdownPadding * 2 - 4; int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight + 2; menu->subbbox.left = x1; menu->subbbox.top = y1; menu->subbbox.right = x2; menu->subbbox.bottom = y2; }
// This helper calculates all text widths for all menus/items void GfxMenu::calculateMenuAndItemWidth() { GuiMenuItemList::iterator itemIterator; GuiMenuItemList::iterator itemEnd = _itemList.end(); GuiMenuItemEntry *itemEntry; int16 dummyHeight; calculateMenuWidth(); itemIterator = _itemList.begin(); while (itemIterator != itemEnd) { itemEntry = *itemIterator; // Split the text now for multilingual SCI01 games itemEntry->textSplit = g_sci->strSplit(itemEntry->text.c_str(), NULL); _text16->StringWidth(itemEntry->textSplit.c_str(), 0, itemEntry->textWidth, dummyHeight); _text16->StringWidth(itemEntry->textRightAligned.c_str(), 0, itemEntry->textRightAlignedWidth, dummyHeight); itemIterator++; } }