void TabPanel::insertTab(Component* const TabInsert, Component* const Tab, Component* const TabContent)
{
    UInt32 index(0);
    pushToChildren(Tab);
    pushToChildren(TabContent);
    // check if the component is a tab or tabcontent, then insert accordingly
    if (editMFTabs()->end() == editMFTabs()->find(TabInsert))
    {
        for (UInt32 i = 0; i < getMFTabContents()->size(); ++i)
        {
            if(editMFTabContents()->find(TabInsert) == editMFTabContents()->find(getTabContents(i)))
                index = i;
        }
        editMFTabContents()->insert(editMFTabContents()->find(TabInsert), TabContent);
        editMFTabs()->insert(editMFTabs()->find(getTabs(index)), Tab);
    }
    else
    {
        for (UInt32 i = 0; i < getMFTabs()->size(); ++i)
        {
            if(editMFTabs()->find(TabInsert) == editMFTabs()->find(getTabs(i)))
                index = i;
        }
        editMFTabs()->insert(editMFTabs()->find(TabInsert), Tab);
        editMFTabContents()->insert(editMFTabContents()->find(getTabContents(index)), TabContent);
    }
}
void TabPanel::removeTab(Component* const Tab)
{
    UInt32 index(0);
    // also erase the the tab from the components list
    removeObjFromChildren(Tab);
    // check if the component is a tab or tabcontent, then erase accordingly
    if (editMFTabs()->end() == editMFTabs()->find(Tab))
    {	// so it isn't in tabs
        for (UInt32 i = 0; i < getMFTabContents()->size(); ++i)
        {
            if(editMFTabContents()->find(Tab) == editMFTabContents()->find(getTabContents(i)))
                index = i;
        }
        editMFTabContents()->erase(editMFTabContents()->find(Tab));
        // also erase the the tab from the components list
        removeObjFromChildren(getTabs(index));
        editMFTabs()->erase(editMFTabs()->find(getTabs(index)));
    }
    else
    {
        for (UInt32 i = 0; i < getMFTabs()->size(); ++i)
        {
            if(editMFTabs()->find(Tab) == editMFTabs()->find(getTabs(i)))
                index = i;
        }
        editMFTabs()->erase(editMFTabs()->find(Tab));
        // also erase the the tab from the components list
        removeObjFromChildren(getTabContents(index)); 
        editMFTabContents()->erase(editMFTabContents()->find(getTabContents(index)));
    }
}
void TabPanel::mousePressed(MouseEventDetails* const e)
{
    bool isContained;
    for(Int32 i(getMFTabs()->size()-1) ; i>=0 ; --i)
    {   // going backwards through through elements, so only top button is pressed
        isContained = getTabs(i)->isContained(e->getLocation(), true);
        checkMouseEnterExit(e,e->getLocation(),getTabs(i),isContained,e->getViewport());
        if(isContained)
        {
            //Give myself temporary focus
            takeFocus(true);
            if(!getTabs(i)->getType().isDerivedFrom(ComponentContainer::getClassType()))
            {
                getTabs(i)->takeFocus();
            }
            getTabs(i)->mousePressed(e);
            break;
        }
    }
    if(isContained)
    {
        //Remove my temporary focus
        giveFocus(NULL, false);
    }
    else
    {
        //Give myself permanant focus
        takeFocus();
    }

    // now do it for the content tab
    isContained = getTabContents(getSelectedIndex())->isContained(e->getLocation(), true);
    checkMouseEnterExit(e,e->getLocation(),getTabContents(getSelectedIndex()),isContained,e->getViewport());
    if(isContained)
    {
        //Give myself temporary focus
        takeFocus(true);
        if(!getTabContents(getSelectedIndex())->getType().isDerivedFrom(ComponentContainer::getClassType()))
        {
            getTabContents(getSelectedIndex())->takeFocus();
        }
        getTabContents(getSelectedIndex())->mousePressed(e);

        giveFocus(NULL, false);
    }
    else
    {
        //Give myself permanent focus
        takeFocus();
    }

    Component::mousePressed(e);
}
void CtrlrLuaMethodEditor::saveAndCompilAllMethods()
{
	for (int i=0; i<getTabs()->getNumTabs(); i++)
	{
		CtrlrLuaMethodCodeEditor *ed = dynamic_cast<CtrlrLuaMethodCodeEditor*> (getTabs()->getTabContentComponent (i));

		if (ed)
		{
			ed->saveAndCompileDocument();
		}
	}
}
void TabPanel::removeTab(const UInt32 TabIndex)
{
    if(TabIndex == getMFTabs()->size()-1 &&
       TabIndex == getSelectedIndex())
    {
        setSelectedIndex(TabIndex-1);
    }

    removeObjFromChildren(getTabs(TabIndex));
    removeObjFromChildren(getTabContents(TabIndex));
    editMFTabs()->erase(editMFTabs()->find(getTabs(TabIndex)));
    editMFTabContents()->erase(editMFTabContents()->find(getTabContents(TabIndex)));
}
void TabPanel::drawTab(UInt32 TabIndex, Graphics* const TheGraphics, Real32 Opacity) const
{
    Pnt2f TabPosition(getTabs(TabIndex)->getPosition()), 
          TabBorderPosition;
    Vec2f TabSize(getTabs(TabIndex)->getSize()), 
          TabBorderSize;

    BorderRefPtr DrawnTabBorder(getDrawnTabBorder(TabIndex));

    LayerRefPtr DrawnTabBackground(getDrawnTabBackground(TabIndex));

    Real32 TabBorderLeftWidth, TabBorderRightWidth,TabBorderTopWidth, TabBorderBottomWidth;
    calculateTabBorderLengths(DrawnTabBorder, TabBorderLeftWidth, TabBorderRightWidth,TabBorderTopWidth, TabBorderBottomWidth);

    TabBorderPosition.setValues(TabPosition.x() - TabBorderLeftWidth, TabPosition.y() - TabBorderTopWidth);
    TabBorderSize.setValues(TabSize.x() + TabBorderLeftWidth + TabBorderRightWidth,
                            TabSize.y() + TabBorderTopWidth + TabBorderBottomWidth);

    if(DrawnTabBorder != NULL)
    {
        DrawnTabBorder->draw(TheGraphics,
                             TabBorderPosition.x(), TabBorderPosition.y(),
                             TabBorderSize.x(), TabBorderSize.y(),
                             getOpacity()*Opacity);
        //DrawnTabBorder->activateInternalDrawConstraints(TheGraphics,
        //                 TabBorderPosition.x(), TabBorderPosition.y(),
        //				 TabBorderSize.x(), TabBorderSize.y());
    }

    if(DrawnTabBackground != NULL)
    {
        DrawnTabBackground->draw(TheGraphics, 
                                 TabPosition, 
                                 TabPosition + TabSize, 
                                 getOpacity()*Opacity);
    }

    //Draw the tab component
    getTabs(TabIndex)->draw(TheGraphics, getOpacity()*Opacity);

    setupClipping(TheGraphics);

    if(DrawnTabBorder != NULL)
    {
        DrawnTabBorder->deactivateInternalDrawConstraints(TheGraphics,
                                                          TabBorderPosition.x(), TabBorderPosition.y(),
                                                          TabBorderSize.x(), TabBorderSize.y());
    }
}
void TabPanel::insertTab(const UInt32 TabIndex, Component* const Tab, Component* const TabContent)
{
    pushToChildren(Tab);
    pushToChildren(TabContent);
    editMFTabs()->insert(editMFTabs()->find(getTabs(TabIndex)), Tab); // an incredibly ridiculous function call
    editMFTabContents()->insert(editMFTabContents()->find(getTabContents(TabIndex)), TabContent);
}
void xmlwriter::_CreateChild(const RGString& sTag, const RGString& sValue)
{
//	fputs("\n",fp);
	fp->Write ("\n");

	//Indent properly
  fp->Write (getTabs(iLevel));
//		fputs("\t",fp);

	temp = "<" + sTag;
//	fprintf(fp,"<%s",sTag.c_str());

	//Add Attributes
	while(0 < vectAttrData.size()/2)
	{
//		string sTmp = vectAttrData.back();
		temp += " " + vectAttrData.back () + "=";
//		fprintf(fp," %s=", sTmp.c_str());
		vectAttrData.pop_back();
//		sTmp = vectAttrData.back();
		temp += "\"" + vectAttrData.back () + "\"";
//		fprintf(fp,"\"%s\"", sTmp.c_str());
		vectAttrData.pop_back();
	}
	vectAttrData.clear();
	//add value and close tag
	temp += ">" + sValue + "</" + sTag + ">";
	fp->Write (temp);
//	fprintf(fp,">%s</%s>",sValue.c_str(),sTag.c_str());
}
void xmlwriter :: _CreateTag (const RGString& sTag)
{
	fp->Write ("\n");
	
	//Indent properly
  fp->Write (getTabs(iLevel));

	temp = "<" + sTag;

	//Add Attributes
	while(0 < vectAttrData.size()/2)
	{
		temp += " " + vectAttrData.back() + "=";
//		fprintf(fp," %s=", sTmp.c_str());
		vectAttrData.pop_back();
//		sTmp = vectAttrData.back();
		temp += "\"" + vectAttrData.back() + "\"";
//		fprintf(fp,"\"%s\"", sTmp.c_str());
		vectAttrData.pop_back();
	}

	vectAttrData.clear();
	temp += ">";
	fp->Write (temp);
//	fputs(">",fp);
	sTagStack.push (sTag);
	iLevel++;
}
Beispiel #10
0
Layer* TabPanel::getDrawnTabBackground(const UInt32& Index) const
{
    if(getEnabled())
    {
        if(Index == getSelectedIndex())
        {
            return getTabActiveBackground();
        }
        else if(Index == _MouseInTabLastMouse)
        {
            return getTabRolloverBackground();
        }
        else if(getTabs(Index)->getFocused())
        {
            return getTabFocusedBackground();
        }
        else
        {
            return getTabBackground();
        }
    }
    else
    {
        return getTabDisabledBackground();
    }
}
Beispiel #11
0
static std::string visitMap(const T& v, int depth) {
	std::stringstream ret;

	if (depth > 0)
		ret << "\n";

	ret << getTabs(depth) << "{\n";

	for (auto iter = v.begin(); iter != v.end(); ++iter) {
		ret << getTabs(depth + 1) << iter->first << ": ";
		ret << visit(iter->second, depth + 1);
	}

	ret << getTabs(depth) << "}\n";

	return ret.str();
}
Beispiel #12
0
static std::string visitVector(const ValueArray& v, int depth) {
	std::stringstream ret;

	if (depth > 0)
		ret << "\n";

	ret << getTabs(depth) << "[\n";

	int i = 0;
	for (const auto& child : v) {
		ret << getTabs(depth + 1) << i << ": " << visit(child, depth + 1);
		++i;
	}

	ret << getTabs(depth) << "]\n";

	return ret.str();
}
static std::string visitMap(const T& v, int depth)
{
    std::stringstream ret;

    if (depth > 0)
        ret << "\n";

    ret << getTabs(depth) << "{\n";

    for (auto& iter : v)
    {
        ret << getTabs(depth + 1) << iter.first << ": ";
        ret << visit(iter.second, depth + 1);
    }

    ret << getTabs(depth) << "}\n";

    return ret.str();
}
void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuIndex)
{
	if (menuItemID == 2 && topLevelMenuIndex == 0)
	{
		if (getCurrentEditor())
		{
			getCurrentEditor()->saveDocument();
		}
	}
	else if (menuItemID == 3 && topLevelMenuIndex == 0)
	{
		if (getCurrentEditor())
		{
			getCurrentEditor()->saveAndCompileDocument();
		}
	}
	else if (menuItemID == 4 && topLevelMenuIndex == 0)
	{
		for (int i=0; i<getTabs()->getNumTabs(); i++)
		{
			CtrlrLuaMethodCodeEditor *ed = dynamic_cast<CtrlrLuaMethodCodeEditor*> (getTabs()->getTabContentComponent (i));

			if (ed)
			{
				ed->saveAndCompileDocument();
			}
		}
	}
	else if (menuItemID == 4 && topLevelMenuIndex == 1)
	{
		methodEditArea->showFindDialog();
	}
	else if (menuItemID == 5 && topLevelMenuIndex == 1)
	{
		CtrlrLuaMethodCodeEditorSettings s(*this);
		CtrlrDialogWindow::showModalDialog ("Code editor settings", &s, false, this);

		componentTree.setProperty (Ids::luaMethodEditorFont, owner.getOwner().getFontManager().getStringFromFont (s.getFont()), nullptr);
		componentTree.setProperty (Ids::luaMethodEditorBgColour, COLOUR2STR (s.getColour()), nullptr);
	}
}
Beispiel #15
0
void TabPanel::updateTabFocusConnections(void)
{
    for(UInt32 i(0) ; i<_TabFocusGainedConnections.size() ; ++i)
    {
        _TabFocusGainedConnections[i].disconnect();
    }
    _TabFocusGainedConnections.clear();
    for(UInt32 i(0) ; i<getMFTabs()->size() ; ++i)
    {
        _TabFocusGainedConnections.push_back(getTabs(i)->connectFocusGained(boost::bind(&TabPanel::handleTabFocusGained, this, _1)));
    }
}
bool CtrlrLuaMethodEditArea::keyPressed (const KeyPress &key, Component *event)
{
    if (getTabs())
    {
        if (getTabs()->getCurrentTabIndex() < (getTabs()->getNumTabs()-1) && getTabs()->getCurrentTabIndex() >= 0)
        {
            getTabs()->setCurrentTabIndex(getTabs()->getCurrentTabIndex() + 1);
            return (true);
        }

        if (getTabs()->getCurrentTabIndex() >= getTabs()->getNumTabs() - 1)
        {
            getTabs()->setCurrentTabIndex(0);
            return (true);
        }
    }
    return (false);
}
void xmlwriter::_AddComment(const RGString& sComment)
{
//	fputs("\n",fp);
	fp->Write ("\n");

	//Indent properly
	fp->Write (getTabs(iLevel));
//		fputs("\t",fp);

	temp = "<!--" + sComment + "-->";
	fp->Write (temp);
//	fprintf(fp,"<!--%s-->",sComment.c_str());
}
Beispiel #18
0
// generating the actual json string to send back to client
string JSONobject::str(int depth) {
	// { intoduces new object
	string JSONstr = "{";
	// entering new level so increase tabulator depth
	depth++;
	
	// go through all children
	vChildren::iterator vIter;
	for (vIter = children.begin(); vIter != children.end(); ++vIter) {
		// add key to string first
		JSONstr += "\n" + getTabs(depth) + "\"" + vIter->first + "\": ";
		
		// child is a string
		if (!vIter->second->value.empty()) {
			JSONstr += "\"" + vIter->second->value + "\"";
		// child is an object
		} else if (vIter->second->object != NULL) {
			JSONstr += vIter->second->object->str(depth);
		// child is an array
		} else if (vIter->second->array != NULL) {
			JSONstr += vIter->second->array->str(depth);
		// no value given -> empty
		} else {
			JSONstr += "\"\"";
		}
		
		// add comma leading to the next child
		if (vIter+1 != children.end()) {
			JSONstr += ",";
		}
		
	}
	// leaving this level so decrease depth
	depth--;
	// new line, tabulators and closing }
	JSONstr += "\n" + getTabs(depth) + "}";
	
	return JSONstr;
}
Beispiel #19
0
string JSONarray::str(int depth) {
	string JSONstr = "[";
	depth++;
	
	vChildren::iterator vIter;
	for (vIter = children.begin(); vIter != children.end(); ++vIter) {
		JSONstr += "\n" + getTabs(depth);
		if (!(*vIter)->value.empty()) {
			JSONstr += "\"" + (*vIter)->value + "\"";
		} else if ((*vIter)->object != NULL) {
			JSONstr += (*vIter)->object->str(depth);
		}
		
		JSONstr += ",";
	}
	
	JSONstr.erase(JSONstr.size()-1, 1);
	depth--;
	JSONstr += "\n" + getTabs(depth) + "]";
	
	return JSONstr;
}	
Beispiel #20
0
void TabPanel::mouseWheelMoved(MouseWheelEventDetails* const e)
{
    bool isContained;
    for(UInt32 i(0) ; i<getMFTabs()->size() ; ++i)
    {
        isContained = getTabs(i)->isContained(e->getLocation(), true);
        checkMouseEnterExit(e,e->getLocation(),getTabs(i),isContained,e->getViewport());
        if(isContained)
        {
            getTabs(i)->mouseWheelMoved(e);
        }
    }

    isContained = getTabContents(getSelectedIndex())->isContained(e->getLocation(), true);
    checkMouseEnterExit(e,e->getLocation(),getTabContents(getSelectedIndex()),isContained,e->getViewport());
    if(isContained)
    {
        getTabContents(getSelectedIndex())->mouseWheelMoved(e);
    }

    Component::mouseWheelMoved(e);
}
	void  Serialization::appendHypothesisWithThreshold(int iteration, BaseLearner* pWeakHypothesis, double threshold, int numTab)
	{
        // just for readability
   		string shiftTab = getTabs(numTab);
        
		// open the hypothesis tag (parameters: iteration, weak learner's name)
		_shypFile << shiftTab << "\t<weakhyp iter=\"" << iteration << "\">" << endl;
        
        _shypFile << shiftTab << "\t\t<rejecthresh>" << threshold << "</rejecthresh>" << endl ;
		
		// save the hypothesis
		pWeakHypothesis->save(_shypFile, 2 + numTab); 
		
		// close the hypothesis tag
		_shypFile << shiftTab << "\t</weakhyp>"<< endl;
		
		// add a separation "comment"
		_shypFile << "\t<!-- ################################## -->" << endl;
		
		if ( _isComp ) {
			_shypFile.flush();
			//cout << "Shypfile size:\t" << _shypFile.tellp() << endl;
			
			if ( _shypFile.tellp() > 10e6 ) {
				_shypFile.close();
				_shypFile.clear();
				
				ifstream inFile;
				string str;
				char buf[ 4086 ];
				inFile.open( _shypFileName.c_str() );
				
				Bzip2WrapperWriter bzw;
				
				bzw.open( _bzipFileName.c_str(), true );
				
				getline( inFile, str );
				while ( inFile ) {
					sprintf( buf, "%s\n", str.c_str() );
					bzw << buf;
					getline( inFile, str );
				}
				
				
				inFile.close();
				bzw.close();
				_shypFile.open( _shypFileName.c_str() );
			}
		}
	}
void xmlwriter :: CloseLastTag ()
{
//	fputs("\n",fp);
	fp->Write ("\n");
	iLevel--;

    //Indent properly
  fp->Write(getTabs(iLevel));

	temp = "</" + sTagStack.top () + ">";
	fp->Write (temp);
//	fprintf(fp,"</%s>",sTagStack.top().c_str());
	sTagStack.pop();//pop out the last tag
	return;
}
Beispiel #23
0
void TabPanel::handleTabFocusGained(FocusEventDetails* const e)
{
    ComponentRefPtr Tab = dynamic_cast<Component*>(e->getSource());
    Int32 index(-1);

    for (UInt32 i = 0; i < getMFTabs()->size(); ++i)
    {
        if(editMFTabs()->find(Tab) == editMFTabs()->find(getTabs(i)))
        {
            index = i;
        }
    }
    if (index != -1)
    {
        setSelectedIndex(index);
    }
}
Beispiel #24
0
void TabPanel::updateLayout(void)
{
    Pnt2f InsideInsetsTopLeft,InsideInsetsBottomRight;
    getInsideInsetsBounds(InsideInsetsTopLeft,InsideInsetsBottomRight);

    UInt16 AxisIndex(0);
    if (getTabPlacement() == PLACEMENT_EAST || getTabPlacement() == PLACEMENT_WEST)
    {
        AxisIndex=1;
    }
    Real32 largestMinorAxis(0.0f);
    Real32 cumMajorAxis(0.0f);
    Pnt2f alignOffset(0.0f,0.0f);
    Vec2f offset(0.0f,0.0f);

    Vec2f TabBorderTopLeftWidth, TabBorderBottomRightWidth;
    calculateMaxTabBorderLengths(TabBorderTopLeftWidth[0], TabBorderBottomRightWidth[0],TabBorderTopLeftWidth[1], TabBorderBottomRightWidth[1]);

    // first layout all of the tabs
    // naturally the alignments and such is necessary
    // on the first sweep, get the maximum size and cumLength
    const Real32 TabMajorAxisSpacing(5.0f);
    Vec2f TabReqSize;
    for (UInt32 i=0; i < getMFTabs()->size(); ++i)
    {
        TabReqSize = getTabs(i)->getRequestedSize() + Vec2f(getTabBorderInsets().x() + getTabBorderInsets().y(),
                                                            getTabBorderInsets().z() + getTabBorderInsets().w());
        cumMajorAxis += TabReqSize[AxisIndex];
        if (TabReqSize[(AxisIndex+1)%2] > largestMinorAxis)
        {
            largestMinorAxis = TabReqSize[(AxisIndex+1)%2];
        }
    }
    cumMajorAxis += TabMajorAxisSpacing * 2.0f * getMFTabs()->size();
    cumMajorAxis += static_cast<Real32>(getMFTabs()->size()) * (TabBorderTopLeftWidth[AxisIndex] + TabBorderBottomRightWidth[AxisIndex]);
    largestMinorAxis += (TabBorderTopLeftWidth[(AxisIndex+1)%2] + TabBorderBottomRightWidth[(AxisIndex+1)%2]);


    // set up the alignment and offset
    Vec2f TabSize;
    TabSize[AxisIndex] = cumMajorAxis;
    TabSize[(AxisIndex+1)%2] = largestMinorAxis;
    Vec2f Alignment;
    Alignment[(AxisIndex+1)%2] = getTabAlignment();
    switch(getTabPlacement())
    {
        case PLACEMENT_SOUTH:
        case PLACEMENT_EAST:
            Alignment[AxisIndex] = 1.0;
            break;
        case PLACEMENT_NORTH:
        case PLACEMENT_WEST:
            Alignment[AxisIndex] = 0.0;
            break;
    }
    alignOffset = calculateAlignment(InsideInsetsTopLeft, (InsideInsetsBottomRight-InsideInsetsTopLeft),TabSize,Alignment.x(),Alignment.y());
    offset = Vec2f(InsideInsetsTopLeft);
    offset[(AxisIndex+1)%2] += TabBorderTopLeftWidth[(AxisIndex+1)%2];

    // set sizes and positions of all tabs
    Vec2f Size;
    Pnt2f Pos;
    for (UInt32 i=0; i < getMFTabs()->size(); ++i)
    {
        offset[AxisIndex] += TabBorderTopLeftWidth[AxisIndex];
        Size = getTabs(i)->getRequestedSize() + Vec2f(getTabBorderInsets().x() + getTabBorderInsets().y(),
                                                      getTabBorderInsets().z() + getTabBorderInsets().w());
        if(getTabs(i)->getSize() != Size)
        {
            getTabs(i)->setSize(Size);
        }
        Pos = alignOffset + offset;
        if(getTabs(i)->getPosition() != Pos)
        {
            getTabs(i)->setPosition(Pos);
        }
        offset[AxisIndex] += getTabs(i)->getSize()[AxisIndex] + TabBorderBottomRightWidth[AxisIndex];
    }

    if((getSelectedIndex()+1) > getMFTabContents()->size())
    {
        setSelectedIndex(getMFTabContents()->size()-1);
    }
    if(getMFTabContents()->size() > 0 && getSelectedIndex() != -1)
    {
        Vec2f ContentBorderTopLeftWidth, ContentBorderBottomRightWidth;
        calculateContentBorderLengths(getContentBorder(), ContentBorderTopLeftWidth[0], ContentBorderBottomRightWidth[0],ContentBorderTopLeftWidth[1], ContentBorderBottomRightWidth[1]);
        // now set size and position of the active tab's contents
        offset = Vec2f(InsideInsetsTopLeft);
        if (getTabPlacement() == PLACEMENT_NORTH || getTabPlacement() == PLACEMENT_WEST)
        {
            offset[(AxisIndex+1)%2] += largestMinorAxis;
        }
        Size = InsideInsetsBottomRight-InsideInsetsTopLeft-(ContentBorderTopLeftWidth + ContentBorderBottomRightWidth);
        Size[(AxisIndex+1)%2] -= TabSize[(AxisIndex+1)%2];
        if(getTabContents(getSelectedIndex())->getSize() != Size)
        {
            getTabContents(getSelectedIndex())->setSize(Size);
        }
        Pos = Pnt2f(0.0f,0.0f) + offset + ContentBorderTopLeftWidth;
        if(getTabContents(getSelectedIndex())->getPosition() != Pos)
        {
            getTabContents(getSelectedIndex())->setPosition(Pos);
        }
    }
}