Beispiel #1
0
void
IconMenuItem::SetMarked(bool mark)
{
    _inherited::SetMarked(mark);

    if (!mark)
        return;

    // we are marking the item

    BMenu* menu = Menu();
    if (menu == NULL)
        return;

    // we have a parent menu

    BMenu* _menu = menu;
    while ((_menu = _menu->Supermenu()) != NULL)
        menu = _menu;

    // went up the hierarchy to found the topmost menu

    if (menu == NULL || menu->Parent() == NULL)
        return;

    // our topmost menu has a parent

    if (dynamic_cast<BMenuField*>(menu->Parent()) == NULL)
        return;

    // our topmost menu's parent is a BMenuField

    BMenuItem* topLevelItem = menu->ItemAt((int32)0);

    if (topLevelItem == NULL)
        return;

    // our topmost menu has a menu item

    IconMenuItem* topLevelIconMenuItem
        = dynamic_cast<IconMenuItem*>(topLevelItem);
    if (topLevelIconMenuItem == NULL)
        return;

    // our topmost menu's item is an IconMenuItem

    // update the icon
    topLevelIconMenuItem->SetIcon(fDeviceIcon);
    menu->Invalidate();
}