示例#1
0
void MenuContainer::SelectionUp() {
    int i;
    Button *tempButton;

    if (!selected) return;

    for (i = button - 1; i >= 0; i--) {
        if (list[i]->Selectable()) {
            tempButton = (Button*)list[i];
            tempButton->Select();
            tempButton = (Button*)list[button];
            tempButton->Deselect();
            button = i;
            return;
        }
    }

    for (i = (int)list.size() - 1; i > button; i--) {
        if (list[i]->Selectable()) {
            tempButton = (Button*)list[i];
            tempButton->Select();
            tempButton = (Button*)list[button];
            tempButton->Deselect();
            button = i;
            return;
        }
    }
}
示例#2
0
void MenuContainer::SelectionDown() {
    unsigned int i;
    Button *tempButton;

    if (!selected) return;

    for (i = button + 1; i < list.size(); i++) {
        if (list[i]->Selectable()) {
            tempButton = (Button*)list[i];
            tempButton->Select();
            tempButton = (Button*)list[button];
            tempButton->Deselect();
            button = i;
            return;
        }
    }

    for (i = 0; (int) i < button; i++) {
        if (list[i]->Selectable()) {
            tempButton = (Button*)list[i];
            tempButton->Select();
            tempButton = (Button*)list[button];
            tempButton->Deselect();
            button = i;
            return;
        }
    }
}
示例#3
0
bool MenuContainer::MouseSelect(int x, int y) {
    unsigned int i;
    Button* tempItem;

    for (i = 0; i < list.size(); i++) {
        if (list[i]->Selectable()) {
            tempItem = (Button*)list[i];
            if ((y > (TopLeftY + (18 * i)) && (y < (TopLeftY + (18 * (i + 1)))))) {

                // This short circuits the problem of
                // hovering. If you hover over a button
                // without this line, it will always
                // select and deselect the same button...
                // not a good thing.
                if (button == (int) i) return true;

                tempItem->Select();
                if (button != -1) {
                    tempItem = (Button*)list[button];
                    tempItem->Deselect();
                }
                button = i;

                return true;
            }
        }
    }
    return false;
}
示例#4
0
bool MenuContainer::Select() {
    unsigned int i;
    Button* tempButton;

    if (selected) return true;

    for (i = 0; i < list.size(); i++) {
        if (list[i]->Selectable()) {
            button = i;
            tempButton = (Button*)list[i];
            tempButton->Select();
            selected = true;
            return true;
        }
    }

    return false;
}