void TabbedComponent::changeCallback (const int newCurrentTabIndex, const String& newTabName)
{
    if (panelComponent != nullptr)
    {
        panelComponent->setVisible (false);
        removeChildComponent (panelComponent);
        panelComponent = nullptr;
    }

    if (getCurrentTabIndex() >= 0)
    {
        panelComponent = getTabContentComponent (getCurrentTabIndex());

        if (panelComponent != nullptr)
        {
            // do these ops as two stages instead of addAndMakeVisible() so that the
            // component has always got a parent when it gets the visibilityChanged() callback
            addChildComponent (panelComponent);
            panelComponent->setVisible (true);
            panelComponent->toFront (true);
        }

        repaint();
    }

    resized();

    currentTabChanged (newCurrentTabIndex, newTabName);
}
Example #2
0
void EdoTabs::reorganizeTabs(const int currentSelectedTabIndex, const bool sortTabsByIndex)
{
	for (int i=0; i<getNumTabs(); i++)
	{
		getTabContentComponent(i)->setComponentProperty (T("deleteByTabComp_"), false);
	}

	TabbedComponent::clearTabs();
	
	if (sortTabsByIndex)
	{
		edoTabs.sort (*this);
	}

	for (int i=0; i<edoTabs.size(); i++)
	{
		Component *c = edoTabs[i]->tabComponent;
		if (c)
		{
			edoTabs[i]->tabIndex = i;
			edoTabs[i]->tabComponent->setComponentProperty (T("tabIndex"), i);
			TabbedComponent::addTab (edoTabs[i]->tabName, edoTabs[i]->tabColour, edoTabs[i]->tabComponent, edoTabs[i]->deleteWhenNotNeeded, i);
		}
	}

	setCurrentTabIndex (currentSelectedTabIndex);
}
Example #3
0
const int EdoTabs::getComponentIndex(Component *componentToLookFor)
{
	for (int i=0; i<getNumTabs(); i++)
	{
		if (getTabContentComponent (i) == componentToLookFor)
			return (i);
	}
	
	return (-1);
}
Example #4
0
void EdoTabs::popupMenuClickOnTab (const int tabIndex, const String &tabName)
{
	PopupMenu menu;
	menu.addItem (1, T("Rename tab"));
	menu.addItem (2, T("Close tab"));

	const int ret = menu.show();

	if (ret == 1)
	{
		AlertWindow alert (T("New tab name"), T("Set the new tab name"), AlertWindow::InfoIcon);
		alert.addTextEditor (T("edoTabName"), tabName, T("New tab name"), false);
		alert.addButton (T("OK"), 1, KeyPress (KeyPress::returnKey));
		alert.addButton (T("Cancel"), 2);
		const int ret = alert.runModalLoop();
		if (ret == 2)
		{
			return;
		}
		else
		{
			const String newName = alert.getTextEditorContents(EDO_COMPONENT_NAME);
			Component *edoComponent = dynamic_cast<Component*>(getTabContentComponent (tabIndex));
			if (edoComponent!=0)
			{
				edoComponent->setName (newName);
			}

			setTabName (tabIndex, newName);
		}
	}
	if (ret == 2)
	{
		removeTab (tabIndex);
	}
}