Ejemplo n.º 1
0
void ComboBox::showPopup()
{
    if (! menuActive)
    {
        const int selectedId = getSelectedId();

        PopupMenu menu;
        menu.setLookAndFeel (&getLookAndFeel());

        for (int i = 0; i < items.size(); ++i)
        {
            const ItemInfo* const item = items.getUnchecked(i);

            if (item->isSeparator())
                menu.addSeparator();
            else if (item->isHeading)
                menu.addSectionHeader (item->name);
            else
                menu.addItem (item->itemId, item->name,
                              item->isEnabled, item->itemId == selectedId);
        }

        if (items.size() == 0)
            menu.addItem (1, noChoicesMessage, false);

        menuActive = true;

        menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
                                                .withItemThatMustBeVisible (selectedId)
                                                .withMinimumWidth (getWidth())
                                                .withMaximumNumColumns (1)
                                                .withStandardItemHeight (jlimit (12, 24, getHeight())),
                            ModalCallbackFunction::forComponent (popupMenuFinishedCallback, this));
    }
}
Ejemplo n.º 2
0
void ComboBoxImage::showPopup() {
    popup.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
                         .withItemThatMustBeVisible(getSelectedId())
                         .withMinimumWidth(getWidth())
                         .withMaximumNumColumns(1)
                         .withStandardItemHeight(itemHeight),
                         ModalCallbackFunction::forComponent(comboBoxPopupMenuFinishedCallback, this));
}
Ejemplo n.º 3
0
void ComboBox::showPopup()
{
    PopupMenu menu;
    menu.setLookAndFeel (&getLookAndFeel());
    addItemsToMenu (menu);

    menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
                                            .withItemThatMustBeVisible (getSelectedId())
                                            .withMinimumWidth (getWidth())
                                            .withMaximumNumColumns (1)
                                            .withStandardItemHeight (label->getHeight()),
                        ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this));
}
Ejemplo n.º 4
0
void Core::select(int x, int y, int key_event, int type)
{
  CoreVisual *visual;
  //if (type != KEV_MOUSE_UP)
    selected_id = getSelectedId(x, y);
  //printf("selected %d\n", selected_id);
  if (!selected_id)
    return;
  visual = (CoreVisual *) tree.search(selected_id);
  if (visual == NULL)
    return;
  visual->touch(key_event, type);
  //if (type != KEV_MOUSE_DOWN)
    selected_id = 0;
  //printf("touch\n");
  visual_update = 1;
}
Ejemplo n.º 5
0
//==============================================================================
void ComboBox::showPopup()
{
    if (! menuActive)
    {
        const int selectedId = getSelectedId();
        ComponentDeletionWatcher deletionWatcher (this);

        PopupMenu menu;

        menu.setLookAndFeel (&getLookAndFeel());

        for (int i = 0; i < items.size(); ++i)
        {
            const ItemInfo* const item = items.getUnchecked(i);

            if (item->isSeparator())
                menu.addSeparator();
            else if (item->isHeading)
                menu.addSectionHeader (item->name);
            else
                menu.addItem (item->itemId, item->name,
                              item->isEnabled, item->itemId == selectedId);
        }

        if (items.size() == 0)
            menu.addItem (1, noChoicesMessage, false);

        const int itemHeight = jlimit (12, 24, getHeight());

        menuActive = true;
        const int resultId = menu.showAt (this, selectedId,
                                          getWidth(), 1, itemHeight);

        if (deletionWatcher.hasBeenDeleted())
            return;

        menuActive = false;

        if (resultId != 0)
            setSelectedId (resultId);
    }
}
Ejemplo n.º 6
0
void ComboBox::addItemsToMenu (PopupMenu& menu) const
{
    const int selectedId = getSelectedId();

    for (int i = 0; i < items.size(); ++i)
    {
        const ItemInfo* const item = items.getUnchecked(i);
        jassert (item != nullptr);

        if (item->isSeparator())
            menu.addSeparator();
        else if (item->isHeading)
            menu.addSectionHeader (item->name);
        else
            menu.addItem (item->itemId, item->name,
                          item->isEnabled, item->itemId == selectedId);
    }

    if (items.size() == 0)
        menu.addItem (1, noChoicesMessage, false);
}
Ejemplo n.º 7
0
void FilterToolButton::fill(const QStringList & _groups) {
    QString text = this->text();
    FilterToolButton::ItemId id = getSelectedId();
    QStringList groups = _groups;
    groups.sort();

    QMenu * menu = new TreeItemsMenu(this);
    QMenu * state_menu = new QMenu(menu);
    QString all_str = tr("All");
    IdAction::addAction(IS_ALL,QIcon(":/pics/folder-tar.png"),all_str,state_menu);
    IdAction::addAction(IS_INSTALLED,QIcon(":/pics/dialog-ok-apply.png"),tr("Installed"),state_menu);
    IdAction::addAction(IS_NONINSTALLED,tr("Non-Installed"),state_menu);
    IdAction::addAction(IS_NEEDUPDATE,QIcon(":/pics/distro-upgrade.png"),tr("Updates"),state_menu);
    IdAction::addAction(IS_ORPHANED,tr("Orphaned"),state_menu);
    IdAction::addAction(IS_MARKED,QIcon(":/pics/edit-select-all.png"),tr("Marked"),state_menu);
    state_menu->setTitle(tr("By state"));
    state_menu->setIcon(QIcon(":/pics/view-filter.png"));
    menu->addMenu(state_menu);
    connect(this,SIGNAL(triggered(QAction *)),this,SLOT(onMenuItemSelected(QAction *)));

    QIcon icon(":/pics/package-group.png");
    QMenu * group_menu = new QMenu(menu);
    group_menu->setTitle(tr("By group"));
    group_menu->setIcon(icon);

    for (int i=0;i<groups.count();i++) {
        IdAction::addAction(IS_GROUP,icon,groups[i],group_menu);
    }
    menu->addMenu(group_menu);

    is_sel = IS_ALL;
    QMenu * old_menu = this->menu();
    setMenu(menu);
    if (old_menu != NULL) delete old_menu;

    setText(text);
    if (!setFilter(id,text)) setText(all_str);
}
Ejemplo n.º 8
0
void FilterToolButton::onMenuItemSelected(QAction * action) {
    is_sel = ((action->menu() == NULL)?((IdAction *)action)->id():IS_UNKNOWN);
    emit selected(getSelectedId(),action->iconText());
}