------------------------------------------------------------------------------ Performs an action when a menu item that is a submenu is selected/highlighted
| 1796 | //------------------------------------------------------------------------------ |
| 1797 | // Performs an action when a menu item that is a submenu is selected/highlighted |
| 1798 | void GuiMenuBar::onSubmenuAction(S32 selectionIndex, const RectI& bounds, Point2I cellSize) |
| 1799 | { |
| 1800 | if(!mouseOverSubmenu) |
| 1801 | return; |
| 1802 | |
| 1803 | // first, call the script callback for menu selection: |
| 1804 | onSubmenuSelect_callback(mouseOverSubmenu->id, mouseOverSubmenu->text); |
| 1805 | |
| 1806 | MenuItem *visWalk = mouseOverSubmenu->submenu->firstMenuItem; |
| 1807 | while(visWalk) |
| 1808 | { |
| 1809 | if(visWalk->visible) |
| 1810 | break; |
| 1811 | visWalk = visWalk->nextMenuItem; |
| 1812 | } |
| 1813 | if(!visWalk) |
| 1814 | { |
| 1815 | mouseOverSubmenu = NULL; |
| 1816 | return; |
| 1817 | } |
| 1818 | |
| 1819 | mSubmenuTextList = new GuiMenuTextListCtrl(this); |
| 1820 | mSubmenuTextList->setControlProfile(mProfile); |
| 1821 | mSubmenuTextList->isSubMenu = true; // Indicate that this text list is part of a submenu |
| 1822 | |
| 1823 | mSubmenuBackground = new GuiSubmenuBackgroundCtrl(this, mSubmenuTextList); |
| 1824 | |
| 1825 | GuiCanvas *root = getRoot(); |
| 1826 | Point2I windowExt = root->getExtent(); |
| 1827 | |
| 1828 | mSubmenuBackground->resize( Point2I(0,0), root->getExtent()); |
| 1829 | S32 textWidth = 0, width = 0; |
| 1830 | S32 acceleratorWidth = 0; |
| 1831 | |
| 1832 | GFont *font = mProfile->mFont; |
| 1833 | |
| 1834 | for(MenuItem *walk = mouseOverSubmenu->submenu->firstMenuItem; walk; walk = walk->nextMenuItem) |
| 1835 | { |
| 1836 | if(!walk->visible) |
| 1837 | continue; |
| 1838 | |
| 1839 | S32 iTextWidth = font->getStrWidth(walk->text); |
| 1840 | S32 iAcceleratorWidth = walk->accelerator ? font->getStrWidth(walk->accelerator) : 0; |
| 1841 | |
| 1842 | if(iTextWidth > textWidth) |
| 1843 | textWidth = iTextWidth; |
| 1844 | if(iAcceleratorWidth > acceleratorWidth) |
| 1845 | acceleratorWidth = iAcceleratorWidth; |
| 1846 | } |
| 1847 | width = textWidth + acceleratorWidth + maxBitmapSize.x * 2 + 2 + 4; |
| 1848 | |
| 1849 | mSubmenuTextList->setCellSize(Point2I(width, font->getHeight()+3)); |
| 1850 | mSubmenuTextList->clearColumnOffsets(); |
| 1851 | mSubmenuTextList->addColumnOffset(-1); // add an empty column in for the bitmap index. |
| 1852 | mSubmenuTextList->addColumnOffset(maxBitmapSize.x + 1); |
| 1853 | mSubmenuTextList->addColumnOffset(maxBitmapSize.x + 1 + textWidth + 4); |
| 1854 | |
| 1855 | U32 entryCount = 0; |
nothing calls this directly
no test coverage detected