Example #1
0
//==============================================================================
bool ComboBox::keyPressed (const KeyPress& key)
{
    if (key.isKeyCode (KeyPress::upKey) || key.isKeyCode (KeyPress::leftKey))
    {
        int index = getSelectedItemIndex() - 1;

        while (index >= 0 && ! selectIfEnabled (index))
            --index;

        return true;
    }
    else if (key.isKeyCode (KeyPress::downKey) || key.isKeyCode (KeyPress::rightKey))
    {
        int index = getSelectedItemIndex() + 1;

        while (index < getNumItems() && ! selectIfEnabled (index))
            ++index;

        return true;
    }
    else if (key.isKeyCode (KeyPress::returnKey))
    {
        showPopup();
        return true;
    }

    return false;
}
Example #2
0
void ComboBox::refreshFromValueTree (const ValueTree& state, ComponentBuilder&)
{
    ComponentBuilder::refreshBasicComponentProperties (*this, state);

    {
        StringArray items;
        items.addLines (state [Ids::items].toString());
        items.removeEmptyStrings (true);

        StringArray existingItems;

        for (int i = 0; i < getNumItems(); ++i)
            existingItems.add (getItemText (i));

        if (existingItems != items)
        {
            clear();

            for (int i = 0; i < items.size(); ++i)
                addItem (items[i], i + 1);
        }
    }

    setEditableText (state [Ids::editable]);
    setJustificationType ((int) state [Ids::textJustification]);
    setTextWhenNothingSelected (state [Ids::unselectedText].toString());
    setTextWhenNoChoicesAvailable (state [Ids::noItemsText].toString());
}
void ListFileProvider::getThumbnail( ThumbnailManager& manager,
									int index, CImage& img, int w, int h,
									ThumbnailUpdater* updater )
{
	if ( index < 0 || getNumItems() <= index )
		return;

	mutex_.grab();
	std::string item;
	if ( isFiltering() )
		item = searchResults_[ index ]->fileName;
	else
		item = items_[ index ]->fileName;
	mutex_.give();

	// find thumbnail

	HICON extIcon = getExtensionIcons( item );
	if ( extIcon )
	{
		CBrush back;
		back.CreateSolidBrush( GetSysColor( COLOR_WINDOW ) );
		img.Create( w, h, 32 );
		CDC* pDC = CDC::FromHandle( img.GetDC() );
		DrawIconEx( pDC->m_hDC, 0, 0, extIcon, w, h, 0, (HBRUSH)back, DI_NORMAL );
		img.ReleaseDC();
	}

	manager.create( item, img, w, h, updater );
}
Example #4
0
XFE_ToolboxItem *
XFE_Toolbox::firstOpenAndManagedItem()
{
	XP_ASSERT( XfeIsAlive(m_widget) );

	Cardinal	num_items = getNumItems();
	Cardinal	i;

	// Make sure toolbox has items
	if (!num_items)
	{
		return NULL;
	}

	for (i = 0; i < num_items; i++)
	{
		Widget item = XfeToolBoxItemGetByIndex(m_widget,i);

		if (XfeIsAlive(item) && XtIsManaged(item) &&
			XfeToolBoxItemGetOpen(m_widget,item))
		{
			return (XFE_ToolboxItem *) XfeUserData(item);
		}
	}

	return NULL;
}
Example #5
0
// Get item based on its position (first position is 0)
StringItem* StringList::getItemAtPos(const int pos)
{
    int num = getNumItems();

    if ((num == 0) || (pos < 0) || (pos > num-1))
    {
        return(NULL);
    }

    StringItem* item;

    item = this->first;
    if (pos == 0)
    {
        return(item);
    }

    num = 0;
    while (item != NULL)
    {
        item = item->next;
        num++;
        if (pos == num)
        {
            break;
        }
    }
    return(item);
}
Example #6
0
bool ComboBox::nudgeSelectedItem (int delta)
{
    for (int i = getSelectedItemIndex() + delta; isPositiveAndBelow (i, getNumItems()); i += delta)
        if (selectIfEnabled (i))
            return true;

    return false;
}
Example #7
0
String Toolbar::toString() const
{
    String s ("TB:");

    for (int i = 0; i < getNumItems(); ++i)
        s << getItemId(i) << ' ';

    return s.trimEnd();
}
Example #8
0
void ComboBoxImage::setImage(Image image) {
    items = image;
    
    int numItems = getNumItems();
    itemHeight = image.getHeight() / numItems;

    for(int i=0;i<numItems;i++) {
        Image tmp = image.getClippedImage(Rectangle<int>(0,itemHeight*i, image.getWidth(), itemHeight));
        popup.addItem(i+1, getItemText(i), true, false, tmp);
    }
}
DialogRigidBody::DialogRigidBody(hkpRigidBody* rb, QWidget *parent) :
	QDialog(parent),
	ui(new Ui::DialogRigidBody)
{
	ui->setupUi(this);
	setWindowTitle("RigidBody");
	setWindowFlags(windowFlags()|Qt::MSWindowsFixedSizeDialogHint);
	
	if(rb)
	{
		rigidbody = rb;
		rigidbody->addReference();
	}
	else
	{
		hkpRigidBodyCinfo cinfo;
		cinfo.m_shape = new hkpSphereShape(1);
		rb = rigidbody = new hkpRigidBody(cinfo);
		rb->setName("New Rigidbody");
		cinfo.m_shape->removeReference();
	}
	
	ui->lineEditName->setText(tr(rb->getName()));
	ui->spinBoxFriction->setValue(rb->getFriction());
	ui->spinBoxRestitution->setValue(rb->getRestitution());
	ui->spinBoxLinearDamping->setValue(rb->getLinearDamping());
	ui->spinBoxAngularDamping->setValue(rb->getAngularDamping());
	ui->spinBoxTimeFactor->setValue(rb->getTimeFactor());
	ui->spinBoxGravityFactor->setValue(rb->getGravityFactor());
	
	ui->collisionFilterSetter->setFilterInfo(rb->getCollisionFilterInfo());
	
	hkMassProperties pi;
	pi.m_mass = rb->getMass();
	pi.m_centerOfMass = rb->getCenterOfMassLocal();
	rb->getInertiaLocal(pi.m_inertiaTensor);
	ui->widgetMassProperties->setMassProperties(pi);
	
	ui->widgetShape->setShape(rb->getCollidable()->getShape());
	
	auto motionTypeClass = hkpMotionClass.getDeclaredEnumByName("MotionType");
	for(int i=1; i<motionTypeClass->getNumItems()-1; ++i)
	{
		auto name = motionTypeClass->getItem(i).getName();
		auto value = motionTypeClass->getItem(i).getValue();
		ui->comboMotionType->addItem(tr(name), QVariant(value));
		if(value == rb->getMotionType())
		{
			ui->comboMotionType->setCurrentIndex(i);
			ui->comboMotionType->setCurrentText(tr(name));
		}
	}
}
Example #10
0
void ComboBoxImage::setImage(Image image, int pos[]) {
    items = image;

    int numItems = getNumItems();
    itemHeight = 26;

    for(int i=0;i<numItems;i++) {
        Image tmp = image.getClippedImage(Rectangle<int>(0,itemHeight*pos[i], image.getWidth(), itemHeight));
        popup.addItem(i+1, getItemText(i), true, false, tmp);
    }

    for(int i=0;i<4;i++)
        itemPos[i] = pos[i];
}
Example #11
0
void PopupMenu::setSelection(const Int32& Index)
{
	if(Index >= 0 && Index < getNumItems())
	{
        if(getSelectionModel() != NULL)
        {
		    getSelectionModel()->setSelectedIndex(Index);
        }
	}
	else
	{
		clearSelection();
	}
}
Example #12
0
XFE_ToolboxItem *	
XFE_Toolbox::getItemAtIndex(Cardinal index)
{
	XP_ASSERT( XfeIsAlive(m_widget) );
	XP_ASSERT( index < getNumItems() );

	XP_ASSERT( XfeIsAlive(m_widget) );

	Widget item = XfeToolBoxItemGetByIndex(m_widget,index);

	XP_ASSERT( XfeIsAlive(item) );

	return (XFE_ToolboxItem *) XfeUserData(item);
}
const AssetInfo ListFileProvider::getAssetInfo( int index )
{
	if ( index < 0 || getNumItems() <= index )
		return AssetInfo();

	SimpleMutexHolder smh( mutex_ );
	ListItemPtr item;
	if ( isFiltering() )
		item = searchResults_[ index ];
	else
		item = items_[ index ];

	return AssetInfo(
		type_,
		item->title,
		item->fileName );
}
Example #14
0
long MyIconList::onFocusInOut(FXObject*o, FXSelector sel, void*p)
{
  long rv=FXIconList::handle(o,sel,p);
  switch (FXSELTYPE(sel)) {
    case SEL_FOCUSIN: {
      if (getNumItems()>0) {
        if (!isItemSelected(getCurrentItem())) {
          setCurrentItem(0);
          selectItem(0, true);
          target->handle(this,FXSEL(SEL_COMMAND,message),0);
        }
        setListStyle(ICONLIST_BROWSESELECT);
      }
      break; 
    }
    case SEL_FOCUSOUT: {
      setListStyle(ICONLIST_SINGLESELECT);
      break; 
    }
  }
  return rv;
}
Example #15
0
// Get item based on its position (first position is 0)
StringItem* StringList::getItemAtPos(const FXint pos)
{
    FXint num=getNumItems();
	if (num==0 || pos<0 || pos>num-1)
		return NULL;
	
	StringItem* item;
	
    item=this->first;
	if (pos==0)
		return item;
    
	num=0;
	while(item!=NULL)
    {
        item=item->next;
		num++;
		if (pos==num)
			break;
    }
	return item;
}
//==============================================================================
bool ComboBox::keyPressed (const KeyPress& key)
{
    bool used = false;

    if (key.isKeyCode (KeyPress::upKey)
        || key.isKeyCode (KeyPress::leftKey))
    {
        setSelectedItemIndex (jmax (0, getSelectedItemIndex() - 1));
        used = true;
    }
    else if (key.isKeyCode (KeyPress::downKey)
              || key.isKeyCode (KeyPress::rightKey))
    {
        setSelectedItemIndex (jmin (getSelectedItemIndex() + 1, getNumItems() - 1));
        used = true;
    }
    else if (key.isKeyCode (KeyPress::returnKey))
    {
        showPopup();
        used = true;
    }

    return used;
}
Example #17
0
void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{
    ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get());

    if (tc != nullptr)
    {
        if (! items.contains (tc))
        {
            if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
            {
                ToolbarItemPalette* const palette = tc->findParentComponentOfClass<ToolbarItemPalette>();

                if (palette != nullptr)
                    palette->replaceComponent (tc);
            }
            else
            {
                jassert (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar);
            }

            items.add (tc);
            addChildComponent (tc);
            updateAllItemPositions (true);
        }

        for (int i = getNumItems(); --i >= 0;)
        {
            const int currentIndex = items.indexOf (tc);
            int newIndex = currentIndex;

            const int dragObjectLeft = vertical ? (dragSourceDetails.localPosition.getY() - tc->dragOffsetY)
                                                : (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
            const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());

            const Rectangle<int> current (Desktop::getInstance().getAnimator()
                                            .getComponentDestination (getChildComponent (newIndex)));
            ToolbarItemComponent* const prev = getNextActiveComponent (newIndex, -1);

            if (prev != nullptr)
            {
                const Rectangle<int> previousPos (Desktop::getInstance().getAnimator().getComponentDestination (prev));

                if (abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX())
                      < abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight()))))
                {
                    newIndex = getIndexOfChildComponent (prev);
                }
            }

            ToolbarItemComponent* const next = getNextActiveComponent (newIndex, 1);
            if (next != nullptr)
            {
                const Rectangle<int> nextPos (Desktop::getInstance().getAnimator().getComponentDestination (next));

                if (abs (dragObjectLeft - (vertical ? current.getY() : current.getX())
                     > abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight()))))
                {
                    newIndex = getIndexOfChildComponent (next) + 1;
                }
            }

            if (newIndex == currentIndex)
                break;

            items.removeObject (tc, false);
            removeChildComponent (tc);
            addChildComponent (tc, newIndex);
            items.insert (newIndex, tc);
            updateAllItemPositions (true);
        }
    }
}