예제 #1
0
void wxSFRectShape::FitToChildren()
{
    // HINT: overload it for custom actions...

    wxSFShapeBase* pChild;

    // get bounding box of the shape and children set be inside it	
	wxRect chBB = this->GetBoundingBox();
	wxRect shpBB = chBB;

    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pChild = (wxSFShapeBase*)node->GetData();

        if( pChild->ContainsStyle(sfsALWAYS_INSIDE) )
        {
            pChild->GetCompleteBoundingBox(chBB, bbSELF | bbCHILDREN);
        }
        node = node->GetNext();
    }

	if(!chBB.IsEmpty())
	{
		//wxRect shpBB = this->GetBoundingBox();

		if(!shpBB.Contains(chBB))
		{
			double dx = chBB.GetLeft() - shpBB.GetLeft();
			double dy = chBB.GetTop() - shpBB.GetTop();

			// resize parent shape
			shpBB.Union(chBB);
			MoveTo(shpBB.GetPosition().x, shpBB.GetPosition().y);
			m_nRectSize = wxRealPoint(shpBB.GetSize().x, shpBB.GetSize().y);

			// move its "1st level" children if neccessary
			if((dx < 0) || (dy < 0))
			{
				node = GetFirstChildNode();
				while(node)
				{
					pChild = (wxSFShapeBase*)node->GetData();
					if(dx < 0)pChild->MoveBy(abs((int)dx), 0);
					if(dy < 0)pChild->MoveBy(0, abs((int)dy));

					node = node->GetNext();
				}
			}
		}
	}
}
예제 #2
0
xsSerializable* xsSerializable::GetSibbling()
{
    wxASSERT( m_pParentItem );

    if( m_pParentItem )
    {
		SerializableList::compatibility_iterator node = m_pParentItem->GetChildrenList().Find( this );
		if( node )
		{
			if( node->GetNext() ) return node->GetNext()->GetData();
		}
    }

    return NULL;
}
예제 #3
0
void wxSFDiagramManager::GetAssignedConnections(wxSFShapeBase* parent, wxClassInfo* shapeInfo, wxSFShapeBase::CONNECTMODE mode, ShapeList& lines)
{
	wxSFLineShape* pLine;
	
	if( parent->GetId() == -1 ) return;

	SerializableList lstLines;
	// lines are children of root item only so we have not to search recursively...
	GetRootItem()->GetChildren( shapeInfo, lstLines );
	
	if( !lstLines.IsEmpty() )
    {
        SerializableList::compatibility_iterator node = lstLines.GetFirst();
        while(node)
        {
            pLine = (wxSFLineShape*)node->GetData();
            switch(mode)
            {
                case wxSFShapeBase::lineSTARTING:
                    if( pLine->GetSrcShapeId() == parent->GetId() ) lines.Append(pLine);
                    break;

                case wxSFShapeBase::lineENDING:
                    if( pLine->GetTrgShapeId() == parent->GetId() ) lines.Append(pLine);
                    break;

                case wxSFShapeBase::lineBOTH:
                    if( ( pLine->GetSrcShapeId() == parent->GetId() ) ||
					    ( pLine->GetTrgShapeId() == parent->GetId() ) ) lines.Append(pLine);
                    break;
            }
            node = node->GetNext();
        }
    }
}
예제 #4
0
void wxXmlSerializer::SetRootItem(xsSerializable* root)
{
    wxASSERT(root);
    wxASSERT(root->IsKindOf(CLASSINFO(xsSerializable)));

	if( m_pRoot )delete m_pRoot;

    if(root && root->IsKindOf(CLASSINFO(xsSerializable)))
    {
        m_pRoot = root;
    }
	else
		m_pRoot = new xsSerializable();

	// update pointers to parent manager
	m_mapUsedIDs.clear();
	
	m_pRoot->m_pParentManager = this;
	m_mapUsedIDs[m_pRoot->GetId()] = m_pRoot;
	
	xsSerializable *pItem;
	SerializableList lstItems;
	GetItems(NULL, lstItems);
	
	SerializableList::compatibility_iterator node = lstItems.GetFirst();
	while( node )
	{
		pItem = node->GetData();
		
		pItem->m_pParentManager = this;
		m_mapUsedIDs[pItem->GetId()] = pItem;
		
		node = node->GetNext();
	}
}
예제 #5
0
void wxSFGridShape::Update()
{
    wxSFShapeBase *pShape;

    // check an existence of already assigned shapes
    for(size_t i = 0; i < m_arrCells.GetCount(); )
    {
        if( !GetChild(m_arrCells[i])) m_arrCells.RemoveAt(i);
		else
			i++;
    }

    // check whether all child shapes' IDs are present in the cells array...
    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pShape = (wxSFShapeBase*)node->GetData();
        if( m_arrCells.Index(pShape->GetId()) == wxNOT_FOUND ) m_arrCells.Add(pShape->GetId());

        node = node->GetNext();
    }

    // do self-alignment
    DoAlignment();

    // do alignment of shape's children
    this->DoChildrenLayout();

    // fit the shape to its children
    this->FitToChildren();

    // do it recursively on all parent shapes
    if( GetParentShape() )GetParentShape()->Update();
}
예제 #6
0
void wxSFGridShape::FitToChildren()
{
    // HINT: overload it for custom actions...

    wxSFShapeBase* pChild;

    // get bounding box of the shape and children set be inside it
    wxRealPoint nAbsPos = GetAbsolutePosition();
    wxRect chBB = wxRect(nAbsPos.x, nAbsPos.y, 0, 0);

    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pChild = (wxSFShapeBase*)node->GetData();

        if( pChild->GetStyle() & sfsALWAYS_INSIDE )
        {
            pChild->GetCompleteBoundingBox(chBB, bbSELF | bbCHILDREN);
        }
        node = node->GetNext();
    }

    // do not let the grid shape 'disappear' due to zero sizes...
    if( (!chBB.GetWidth() || !chBB.GetHeight()) && !m_nCellSpace )
    {
        chBB.SetWidth( 10 );
        chBB.SetHeight( 10 );
    }

    m_nRectSize = wxRealPoint(chBB.GetSize().x + 2*m_nCellSpace, chBB.GetSize().y + 2*m_nCellSpace);
}
예제 #7
0
void wxSFRectShape::OnTopHandle(wxSFShapeHandle& handle)
{
	// HINT: overload it for custom actions...

    wxSFShapeBase *pChild;

	//double dy = (double)handle.GetPosition().y - GetAbsolutePosition().y;
	double dy = (double)handle.GetDelta().y;

	// update position of children
	if( !ContainsStyle( sfsLOCK_CHILDREN ) )
	{
		SerializableList::compatibility_iterator node = GetFirstChildNode();
		while(node)
		{
			pChild = (wxSFShapeBase*)node->GetData();
			if( pChild->GetVAlign() == valignNONE )
			{
				pChild->MoveBy(0, -dy);
			}
			node = node->GetNext();
		}
	}
	// update position and size of the shape
	m_nRectSize.y -= dy;
	m_nRelativePosition.y += dy;
}
void udCPPEnumElementProcessor::ProcessElement(wxSFShapeBase *element)
{	
	udClassAlgorithm *pAlg = (udClassAlgorithm*) m_pParentGenerator->GetActiveAlgorithm();
	
	/*// check whether the enum is already processed
    if( pAlg->GetProcessedElements().IndexOf(element) != wxNOT_FOUND ) return;*/
	
	if( pAlg->GetGenMode() == udGenerator::genDECLARATION )
	{
		udLanguage *pLang = m_pParentGenerator->GetActiveLanguage();
		udEnumElementItem *pEnum = (udEnumElementItem*) udPROJECT::GetDiagramElement( element, udfOMIT_LINKS );
		if( pEnum )
		{
			// get enumeration values
			wxArrayString arrValues;
			SerializableList::compatibility_iterator node = pEnum->GetFirstChildNode();
			while( node )
			{
				arrValues.Add( ((udCodeItem*)node->GetData())->ToString(udCodeItem::cfDECLARATION, pLang) );
				node = node->GetNext();
			}
			
			// write enumeration code
			//pLang->SingleLineCommentCmd( wxT("Enumeration '") + pEnum->GetName() + wxT("'") );
			
			pLang->EnumCmd( pLang->MakeValidIdentifier( pEnum->GetName() ), arrValues, pLang->MakeValidIdentifier( pEnum->GetInstanceName() ) );
			pLang->NewLine();
		}
	}
}
예제 #9
0
ErdPanel::ErdPanel(wxWindow* parent, IDbAdapter* dbAdapter, xsSerializable* pConnections, xsSerializable* pItems)
    : _ErdPanel(parent)
{
    m_pErdTable = NULL;
    m_pDbAdapter = dbAdapter;
    m_pConnections = pConnections;
    Init(parent, dbAdapter);
    int i = 10;
    SerializableList::compatibility_iterator node = pItems->GetFirstChildNode();
    while(node) {
        Table* pTable = wxDynamicCast(node->GetData(), Table);
        if(pTable) {
            ErdTable* pErdTab = new ErdTable(pTable);
            m_diagramManager.AddShape(pErdTab, NULL, wxPoint(i, 10), sfINITIALIZE, sfDONT_SAVE_STATE);
            i += 200;
            pErdTab->UpdateColumns();
        }
        View* pView = wxDynamicCast(node->GetData(), View);
        if(pView) {
            ErdView* pErdView = new ErdView(pView);
            m_diagramManager.AddShape(pErdView, NULL, wxPoint(i, 10), sfINITIALIZE, sfDONT_SAVE_STATE);
            i += 200;
            pErdView->UpdateView();
        }
        node = node->GetNext();
    }
    m_pFrameCanvas->UpdateERD();
    m_pFrameCanvas->UpdateVirtualSize();
}
예제 #10
0
void wxSFThumbnail::DrawContent(wxDC& dc)
{
	// HINT: overload it for custom actions...
	
	wxSFShapeBase *pShape;
	
	SerializableList::compatibility_iterator node = m_pCanvas->GetDiagramManager()->GetRootItem()->GetFirstChildNode();
	while( node )
	{
		pShape = wxDynamicCast( node->GetData(), wxSFShapeBase );
		
		if( pShape )
		{
			if( (m_nThumbStyle & tsSHOW_CONNECTIONS) && pShape->IsKindOf(CLASSINFO(wxSFLineShape)) ) pShape->Draw( dc, sfWITHOUTCHILDREN );
			else if( m_nThumbStyle & tsSHOW_ELEMENTS )
			{
				if( pShape->IsKindOf(CLASSINFO(wxSFBitmapShape)) ) 
				{
					dc.SetPen( wxPen( *wxBLACK, 1, wxDOT) );
					dc.SetBrush( *wxWHITE_BRUSH );
					
					dc.DrawRectangle( pShape->GetBoundingBox() );
					
					dc.SetBrush( wxNullBrush );
					dc.SetPen( wxNullPen );
				}
				else if( !pShape->IsKindOf(CLASSINFO(wxSFLineShape)) ) pShape->Draw( dc, sfWITHOUTCHILDREN );
			}
		}
						
		node = node->GetNext();
	}
}
예제 #11
0
xsSerializable* xsSerializable::GetFirstChild(wxClassInfo *type)
{
	SerializableList::compatibility_iterator node = m_lstChildItems.GetFirst();
    while( node )
	{
		if( node->GetData()->IsKindOf( type ) ) return node->GetData();
		node = node->GetNext();
    }
	return NULL;
}
예제 #12
0
void PostgreSqlDbAdapter::ConvertTable(Table* pTab) {
	SerializableList::compatibility_iterator node = pTab->GetFirstChildNode();
	while( node ) {
		if( node->GetData()->IsKindOf( CLASSINFO(Column)) )  {
			Column* col = (Column*) node->GetData();
			col->SetType(ConvertType(col->GetType()));
		}
		node = node->GetNext();
	}
}
예제 #13
0
wxString MySqlDbAdapter::GetAlterTableConstraintSql(Table* tab)
{
	//TODO:SQL:
	wxString str =  wxString::Format(wxT("-- ---------- CONSTRAINTS FOR TABLE `%s` \n"),tab->GetName().c_str());
	str.append(wxT("-- -------------------------------------------------------------\n"));
	wxString prefix = wxString::Format(wxT("ALTER TABLE `%s` "),tab->GetName().c_str());

	SerializableList::compatibility_iterator node = tab->GetFirstChildNode();
	while( node ) {
		Constraint* constr = NULL;
		constr = wxDynamicCast(node->GetData(), Constraint);
		if (constr) {
			if (constr->GetType() == Constraint::foreignKey) {
				str.append(prefix + wxString::Format(wxT("ADD CONSTRAINT `%s` FOREIGN KEY (`%s`) REFERENCES `%s`(`%s`) " ), constr->GetName().c_str(), constr->GetLocalColumn().c_str(), constr->GetRefTable().c_str(), constr->GetRefCol().c_str()));
				str.append(wxT("ON UPDATE "));
				switch(constr->GetOnUpdate()) {
				case Constraint::restrict:
					str.append(wxT("RESTRICT "));
					break;
				case Constraint::cascade:
					str.append(wxT("CASCADE "));
					break;
				case Constraint::setNull:
					str.append(wxT("SET NULL "));
					break;
				case Constraint::noAction:
					str.append(wxT("NO ACTION "));
					break;
				}
				str.append(wxT("ON DELETE "));
				switch(constr->GetOnDelete()) {
				case Constraint::restrict:
					str.append(wxT("RESTRICT "));
					break;
				case Constraint::cascade:
					str.append(wxT("CASCADE "));
					break;
				case Constraint::setNull:
					str.append(wxT("SET NULL "));
					break;
				case Constraint::noAction:
					str.append(wxT("NO ACTION "));
					break;
				}
				str.append(wxT("; \n"));
			}
		}//if (constr->GetType() == Constraint::primaryKey) str.append(prefix + wxString::Format(wxT("ADD CONSTRAINT `%s` PRIMARY KEY (`%s`); \n"), constr->GetName().c_str(), constr->GetLocalColumn().c_str()));


		node = node->GetNext();
	}
	str.append(wxT("-- -------------------------------------------------------------\n"));
	return str;
}
예제 #14
0
void xsSerializable::GetChildren(wxClassInfo *type, SerializableList& list)
{
    xsSerializable *pChild;

    SerializableList::compatibility_iterator node = m_lstChildItems.GetFirst();
    while(node)
    {
        pChild = node->GetData();

        if( !type || pChild->IsKindOf(type) ) list.Append(pChild);

        node = node->GetNext();
    }
}
예제 #15
0
wxTreeItemId udCodeItemsTree::CreateTreeItems(udProjectItem* item, wxTreeItemId parent)
{
	wxTreeItemId treeId;

    if( item )
    {
		#ifdef __WXMSW__
		wxWindowUpdateLocker noUpdate( this );
		#endif

		int nImageIndex = udArt::GetImageIndex(item->GetClassInfo()->GetClassName());
		
        // create tree item relevat to project items
        if( item->IsKindOf( CLASSINFO(udRootItem)) )
        {
			treeId = AddRoot( wxT("Reusable code fragments"), nImageIndex, nImageIndex, new udTreeItem(this, item));
			//EnsureVisible( treeId );
			//Expand( treeId );
			m_mapTreeItems[ (wxUIntPtr)item ] = treeId;
        }
		else if( item->IsKindOf( CLASSINFO(udCodePackageItem)) )
		{
			treeId = CreateItem( parent, item, nImageIndex );
			//EnsureVisible( treeId );
			//Expand( treeId );
		}
		else if( item->IsKindOf( CLASSINFO(udVariableItem)) || 
				 item->IsKindOf( CLASSINFO(udFunctionItem)) ) 
		{
			treeId = CreateItem( parent, item, nImageIndex );
		}
		
		// show new tree item
		if( treeId.IsOk() )
		{
			EnsureVisible( treeId );
			Expand( treeId );
		
			// create item's children as well
			SerializableList::compatibility_iterator node = item->GetFirstChildNode();
			while(node)
			{
				CreateTreeItems((udProjectItem*)node->GetData(), treeId);
				node = node->GetNext();
			}
		}
	}
	
	return treeId;
}
예제 #16
0
udSettingsCategory* udSettings::GetCategory(const wxString& name)
{
	SerializableList lstCategories;
	GetItems( CLASSINFO(udSettingsCategory), lstCategories );
	
	SerializableList::compatibility_iterator node = lstCategories.GetFirst();
	while( node )
	{
		if( ((udSettingsCategory*)node->GetData())->GetName() == name ) return (udSettingsCategory*)node->GetData();
		
		node = node->GetNext();
	}
	
	return NULL;
}
예제 #17
0
void xsSerializable::GetChildrenRecursively(wxClassInfo *type, SerializableList& list, SEARCHMODE mode)
{
    xsSerializable *pChild;

    SerializableList::compatibility_iterator node = m_lstChildItems.GetFirst();
    while(node)
    {
        pChild = node->GetData();
        if( !type || pChild->IsKindOf(type) ) list.Append(pChild);
		if( mode == searchDFS ) pChild->GetChildrenRecursively(type, list);

        node = node->GetNext();
    }
	
	if( mode == searchBFS )
	{
		node = m_lstChildItems.GetFirst();
		while(node)
		{
			node->GetData()->GetChildrenRecursively(type, list);
			node = node->GetNext();
		}
	}
}
예제 #18
0
void wxXmlSerializer::CopyItems(const wxXmlSerializer& src)
{
	// clear current content
	m_pRoot->GetChildrenList().DeleteContents( true );
	m_pRoot->GetChildrenList().Clear();
	m_pRoot->GetChildrenList().DeleteContents( false );
	
	m_mapUsedIDs.clear();
	
	SerializableList::compatibility_iterator node = src.GetRootItem()->GetFirstChildNode();
	while( node )
	{
		AddItem( m_pRoot, (xsSerializable*)node->GetData()->Clone() );
		node = node->GetNext();
	}
}
예제 #19
0
void wxSFGridShape::DoChildrenLayout()
{
    if( !m_nCols || !m_nRows ) return;

    wxSFShapeBase *pShape;
    int nIndex, nRow, nCol;

    //wxRealPoint nAbsPos = GetAbsolutePosition();

    wxRect currRect, maxRect = wxRect(0,0,0,0);

    // get maximum size of all managed (child) shapes
    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pShape = (wxSFShapeBase*)node->GetData();
        currRect = pShape->GetBoundingBox();

        if( (pShape->GetHAlign() != halignEXPAND) && (currRect.GetWidth() > maxRect.GetWidth()) ) maxRect.SetWidth(currRect.GetWidth());
        if( (pShape->GetVAlign() != valignEXPAND) && (currRect.GetHeight() > maxRect.GetHeight()) ) maxRect.SetHeight(currRect.GetHeight());

        node = node->GetNext();
    }

    // put managed shapes to appropriate positions
    nIndex = nCol = 0;
    nRow = -1;

    for(size_t i = 0; i < m_arrCells.GetCount(); i++ )
    {
        pShape = (wxSFShapeBase*) GetChild(m_arrCells[i]);
        if( pShape )
        {
            if( nIndex++ % m_nCols == 0 )
            {
                nCol = 0; nRow++;
            }
            else
                nCol++;

            FitShapeToRect( pShape, wxRect( nCol*maxRect.GetWidth() + (nCol+1)*m_nCellSpace,
                                            nRow*maxRect.GetHeight() + (nRow+1)*m_nCellSpace,
                                            maxRect.GetWidth(), maxRect.GetHeight() ) );
        }
    }
}
예제 #20
0
xsSerializable* xsSerializable::GetSibbling(wxClassInfo *type)
{
    wxASSERT( m_pParentItem );

    if( m_pParentItem )
    {
		SerializableList::compatibility_iterator node = m_pParentItem->GetChildrenList().Find( this );
		while( node )
		{
			node = node->GetNext();
			
			if( node && (node->GetData()->IsKindOf( type ) ) ) return node->GetData();
		}
    }

    return NULL;
}
예제 #21
0
bool wxXmlSerializer::_Contains(xsSerializable* object, xsSerializable* parent) const
{
    wxASSERT(parent);

    if( !parent )return false;

    if( parent == object )return true;

    bool fFound = false;
    SerializableList::compatibility_iterator node = parent->GetChildrenList().GetFirst();
    while(node)
    {
        fFound = _Contains(object, node->GetData());
        if( fFound )break;
        node = node->GetNext();
    }
    return fFound;
}
예제 #22
0
xsSerializable* wxXmlSerializer::_GetItem(long id, xsSerializable* parent)
{
    wxASSERT(parent);

    if( !parent )return NULL;

    if( parent->GetId() == id )return parent;

    xsSerializable *pItem = NULL;
    SerializableList::compatibility_iterator node = parent->GetChildrenList().GetFirst();
    while(node)
    {
        pItem = _GetItem(id, node->GetData());
        if( pItem )break;
        node = node->GetNext();
    }
    return pItem;
}
예제 #23
0
int wxXmlSerializer::GetIDCount(long id)
{
	int nCount = 0;

    SerializableList items;
    GetItems(CLASSINFO(xsSerializable), items);

	SerializableList::compatibility_iterator node = items.GetFirst();
	while(node)
	{
		if( node->GetData()->GetId() == id ) nCount++;
		node = node->GetNext();
	}

	if( m_pRoot->GetId() == id ) nCount++;

	return nCount;
}
예제 #24
0
void wxSFShapeBase::Draw(wxDC& dc, bool children)
{
	if(!m_pParentManager || !GetShapeManager()->GetShapeCanvas())return;
    if(!m_fVisible)return;

    // draw the shape shadow if required
    if( !m_fSelected && (m_nStyle & sfsSHOW_SHADOW) )
    {
        this->DrawShadow(dc);
    }

	// first, draw itself
	if(m_fMouseOver && ( m_fHighlighParent || (m_nStyle & sfsHOVERING) ))
	{
		if(m_fHighlighParent)
		{
			this->DrawHighlighted(dc);
			m_fHighlighParent = false;
		}
		else
			this->DrawHover(dc);
	}
	else
	    this->DrawNormal(dc);

	if(m_fSelected)this->DrawSelected(dc);
	
	// ... then draw connection points ...
	for( ConnectionPointList::iterator it = m_lstConnectionPts.begin(); it != m_lstConnectionPts.end(); ++it )
	{
		((wxSFConnectionPoint*)(*it))->Draw(dc);
	}

	// ... then draw child shapes
	if(children)
	{
        SerializableList::compatibility_iterator node = GetFirstChildNode();
        while(node)
        {
            ((wxSFShapeBase*)node->GetData())->Draw(dc);
            node = node->GetNext();
        }
	}
}
예제 #25
0
wxString MySqlDbAdapter::GetCreateTableSql(Table* tab, bool dropTable)
{
	//TODO:SQL:
	wxString str = wxT("");
	if (dropTable) str = wxString::Format(wxT("SET FOREIGN_KEY_CHECKS = 0;\nDROP TABLE IF EXISTS `%s` ;\nSET FOREIGN_KEY_CHECKS = 1; \n"),tab->GetName().c_str());
	str.append(wxString::Format(wxT("CREATE TABLE `%s` (\n"),tab->GetName().c_str()));



	SerializableList::compatibility_iterator node = tab->GetFirstChildNode();
	while( node ) {
		Column* col = NULL;
		if( node->GetData()->IsKindOf( CLASSINFO(Column)) ) col = (Column*) node->GetData();
		if(col)	str.append(wxString::Format(wxT("\t`%s` %s"),col->GetName().c_str(), col->GetType()->ReturnSql().c_str()));

		Constraint* constr = wxDynamicCast(node->GetData(),Constraint);
		if (constr) {
			if (constr->GetType() == Constraint::primaryKey) str.append(wxString::Format(wxT("\tPRIMARY KEY (`%s`) \n"), constr->GetLocalColumn().c_str()));
		}

		node = node->GetNext();
		if (node) {
			if (wxDynamicCast(node->GetData(),Column)) str.append(wxT(",\n ")) ;
			else if ((constr = wxDynamicCast(node->GetData(),Constraint))) {
				if (constr->GetType() == Constraint::primaryKey) str.append(wxT(",\n ")) ;
			}

		}
		//else  str.append(wxT("\n ")) ;
	}

	/*	Column* col = tab->GetFristColumn();
		while (col) {
			str.append(wxString::Format(wxT("\t`%s` %s"),col->getName().c_str(), col->getPType()->ReturnSql().c_str()));
			col = wxDynamicCast(col->GetSibbling(),Column);
			if (col) str.append(wxT(",\n ")) ;
			else  str.append(wxT("\n ")) ;
		}*/

	str.append(wxT("\n) ENGINE=INNODB;\n"));
	str.append(wxT("-- -------------------------------------------------------------\n"));
	return str;
}
예제 #26
0
void wxXmlSerializer::SerializeObjects(xsSerializable* parent, wxXmlNode* node, bool withparent)
{
    wxASSERT(parent);
    if(!parent)return;

	wxXmlNode* projectNode = NULL;
	xsSerializable* pChild;

	// serialize parent shape
	if(withparent)
	{
	    if(parent->IsSerialized())
	    {
            projectNode = parent->SerializeObject(NULL);
            if(projectNode)
            {
                SerializeObjects(parent, projectNode, false);
                node->AddChild(projectNode);
            }
	    }
	}
	else
	{
		// serialize parent's children
		SerializableList::compatibility_iterator snode = parent->GetChildrenList().GetFirst();
		while(snode)
		{
			pChild = snode->GetData();

            if(pChild->IsSerialized())
            {
                projectNode = pChild->SerializeObject(NULL);
                if(projectNode)
                {
                    SerializeObjects(pChild, projectNode, false);
                    node->AddChild(projectNode);
                }
            }

			snode = snode->GetNext();
		}
	}
}
예제 #27
0
xsSerializable::xsSerializable(const xsSerializable& obj)
: wxObject(obj)
{
	m_pParentManager = NULL;
    m_pParentItem = NULL;
    m_fSerialize = obj.m_fSerialize;
	m_fClone = obj.m_fClone;
    m_nId = obj.m_nId;

    XS_SERIALIZE(m_nId, wxT("id"));
	
	// copy serialized children as well
	SerializableList::compatibility_iterator node = obj.GetFirstChildNode();
	while( node )
	{
		if( node->GetData()->IsSerialized() ) AddChild( (xsSerializable*)node->GetData()->Clone() );
		node = node->GetNext();
	}
}
예제 #28
0
void wxSFShapeBase::_OnHandle(wxSFShapeHandle& handle)
{
	if( !m_pParentManager )return;

    wxSFShapeBase *pChild;
	wxRect prevBB, currBB;
	
	if( m_pParentItem )
	{
		GetGrandParentShape()->GetCompleteBoundingBox( prevBB );
	}
	else
		this->GetCompleteBoundingBox( prevBB );

    // call appropriate user-defined handler
	this->OnHandle(handle);

    // align children
    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pChild = (wxSFShapeBase*)node->GetData();

        if((pChild->GetVAlign() != valignNONE) || (pChild->GetHAlign() != halignNONE))
        {
            pChild->DoAlignment();
        }
        node = node->GetNext();
    }
    // update shape
    this->Update();
	
	if( m_pParentItem )
	{
		GetGrandParentShape()->GetCompleteBoundingBox( currBB );
	}
	else
		this->GetCompleteBoundingBox( currBB );

    // refresh shape
    Refresh( currBB.Union( prevBB ), sfDELAYED );
}
예제 #29
0
void ClassGenerateDialog::OnGenerateClick(wxCommandEvent& event)
{
    if( m_txVirtualDir->GetValue().IsEmpty() ) {
        wxMessageBox( _("Virtual name cannot be empty"), _("CodeLite"), wxICON_WARNING | wxOK );
        m_txVirtualDir->SetFocus();
        return;
    }
    if (m_dirPicker->GetPath().IsEmpty()) {
        wxMessageBox( _("Folder name cannot be empty"), _("CodeLite"), wxICON_WARNING | wxOK );
        m_dirPicker->SetFocus();
    }

    m_textLog->Clear();

    wxString err_msg;
    wxString project = m_txVirtualDir->GetValue().BeforeFirst(wxT(':'));
    ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(project, err_msg);
    if( proj ) {
        wxString filePath = m_dirPicker->GetPath();//proj->GetFileName().GetPath();

        Table* pTable = wxDynamicCast(m_pItems, Table);

        if (pTable) {
            if (GenerateClass(pTable,filePath)) m_textLog->AppendText(pTable->GetName() + _("......... Generated successfully!\n"));
            else m_textLog->AppendText(pTable->GetName() + _("......... Error!!!\n"));
        } else {
            SerializableList::compatibility_iterator node = m_pItems->GetFirstChildNode();
            while( node ) {
                Table* pTab = wxDynamicCast(node->GetData(),Table);
                if (pTab) {
                    if (GenerateClass(pTab,filePath)) m_textLog->AppendText(pTab->GetName() + _("......... Generated successfully!\n"));
                    else m_textLog->AppendText(pTab->GetName() + _("......... Error!!!\n"));
                }

                node = node->GetNext();
            }
        }
        wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace"));
        m_mgr->GetTheApp()->GetTopWindow()->GetEventHandler()->AddPendingEvent(e);
    }
}
예제 #30
0
xsSerializable* xsSerializable::GetChild(long id, bool recursive)
{
    SerializableList lstChildren;
    SerializableList::compatibility_iterator node;

    if( recursive )
    {
        GetChildrenRecursively( CLASSINFO(xsSerializable), lstChildren );
        node = lstChildren.GetFirst();
    }
    else
        node = m_lstChildItems.GetFirst();

    while(node)
    {
		if( node->GetData()->GetId() == id) return node->GetData();
        node = node->GetNext();
    }

	return NULL;
}