当前位置: 首页>>代码示例>>C++>>正文


C++ ShapeList::Item方法代码示例

本文整理汇总了C++中ShapeList::Item方法的典型用法代码示例。如果您正苦于以下问题:C++ ShapeList::Item方法的具体用法?C++ ShapeList::Item怎么用?C++ ShapeList::Item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShapeList的用法示例。


在下文中一共展示了ShapeList::Item方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessClassDeclaration

void udCPPClassElementProcessor::ProcessClassDeclaration(wxSFShapeBase* element)
{
	udLanguage *pLang = m_pParentGenerator->GetActiveLanguage();
	udClassAlgorithm *pAlg = (udClassAlgorithm*) m_pParentGenerator->GetActiveAlgorithm();
	
	// get base classes if exists
	ShapeList lstBases;
	umlClassDiagram::GetBaseClasses( (umlClassItem*)element, lstBases );
	
	int nTemplateIndex = 0;
	
	wxString sBases;
	for( ShapeList::iterator it = lstBases.begin(); it != lstBases.end(); ++it )
	{
		if( it != lstBases.begin() ) sBases << wxT(", ");
		
		sBases << pLang->MakeValidIdentifier( udPROJECT::GetDiagramElement(*it)->GetName() );
		
		// add template parameter if exists
		umlClassTemplateItem *pTemplate = wxDynamicCast( *it, umlClassTemplateItem );
		if( pTemplate )
		{
			// find corespondent template binding connection
			ShapeList lstConnections;
			element->GetShapeManager()->GetAssignedConnections( element, CLASSINFO(umlTemplateBindItem), wxSFShapeBase::lineSTARTING, lstConnections );
			if( !lstConnections.IsEmpty() )
			{
				// append bind type to the base name
				udTemplateBindElementItem *pBindElement = wxDynamicCast( udPROJECT::GetDiagramElement( lstConnections.Item(nTemplateIndex)->GetData() ), udTemplateBindElementItem );
				if( pBindElement )
				{
					sBases << wxT("<") << pBindElement->GetBindType() << wxT(">");
				}
			}
			nTemplateIndex++;
		}
	}
	
	udClassElementItem *pClass = (udClassElementItem*) udPROJECT::GetDiagramElement(element);
	
	//generate comment if requested
	pLang->WriteCodeBlocks( udGenerator::GetComment( pClass, pLang) );
	
	// write template definition if needed
	udClassTemplateElementItem *pClassTempl = wxDynamicCast( pClass, udClassTemplateElementItem );
	if( pClassTempl )
	{
		pLang->WriteCodeBlocks( wxT("template <typename ") + pClassTempl->GetTemplateName() + wxT(">") );
	}
	
	// generate class declaration
	pLang->ClassDeclCmd( pLang->MakeValidIdentifier( pClass->GetName() ), sBases );
	
	pLang->BeginCmd();
	
	// declare class members
	int nAccessType = 0;
	wxClassInfo *pPrevType;
	
	SerializableList lstMembers;
	ShapeList lstAssocs;
	
	while( pLang->GetAccessTypeString( (udLanguage::ACCESSTYPE) nAccessType ) != wxEmptyString )
	{
		pLang->WriteCodeBlocks( pLang->GetAccessTypeString( (udLanguage::ACCESSTYPE) nAccessType ) + wxT(":") );
		pLang->IncIndentation();
		
		lstMembers.Clear();
		lstAssocs.Clear();
		pPrevType = NULL;
		
		// process associations
		umlClassDiagram::GetClassAssociations( (umlClassItem*) element, CLASSINFO(wxSFLineShape), wxSFLineShape::lineSTARTING, (udLanguage::ACCESSTYPE) nAccessType, lstAssocs );
		for( ShapeList::iterator it = lstAssocs.begin(); it != lstAssocs.end(); ++it )
		{
			udElementProcessor *pProcessor = pAlg->GetElementProcessor( (*it)->GetClassInfo()->GetClassName() );
			if( pProcessor ) pProcessor->ProcessElement( *it );
		}
		
		// process class members
		umlClassDiagram::GetClassMembers( (umlClassItem*) element, CLASSINFO(udMemberDataLinkItem), (udLanguage::ACCESSTYPE) nAccessType, lstMembers);
		umlClassDiagram::GetClassMembers( (umlClassItem*) element, CLASSINFO(udMemberFunctionLinkItem), (udLanguage::ACCESSTYPE) nAccessType, lstMembers);
		for( SerializableList::iterator it = lstMembers.begin(); it != lstMembers.end(); ++it )
		{
			if( pPrevType && ((*it)->GetClassInfo() != pPrevType) ) pLang->NewLine();
			
			// generate comment
			pLang->WriteCodeBlocks( udGenerator::GetComment( ((udCodeLinkItem*)*it)->GetOriginal(), pLang ) );
			// generate function decl
			pLang->WriteCodeBlocks( ((udCodeLinkItem*)*it)->ToString( udCodeItem::cfDECLARATION, pLang ) );
			
			pPrevType = (*it)->GetClassInfo();
		}
		
		nAccessType++;
		
		pLang->DecIndentation();
		pLang->NewLine();
	}
	
//.........这里部分代码省略.........
开发者ID:LETARTARE,项目名称:CodeDesigner,代码行数:101,代码来源:CPPElementProcessors.cpp

示例2: OnDropTable

void DatabaseCanvas::OnDropTable(wxCommandEvent &event)
{
    ShapeList list;
    bool isTable;
    int answer;
    MyErdTable *erdTable = NULL;
    DatabaseTable *table = NULL;
    wxString name;
    ConstraintSign *sign = NULL;
    Constraint *constraint = NULL;
    DrawingDocument *doc = (DrawingDocument *) m_view->GetDocument();
    Database *db = doc->GetDatabase();
    std::vector<std::wstring> errors, localColumns, refColumn;
    std::vector<FKField *> newFK;
    std::wstring command;
    int match = 0;
    GetSelectedShapes( list );
    if( list.size() == 1 )
        isTable = true;
    else
        isTable = false;
    for( ShapeList::iterator it = list.begin(); it != list.end(); it++ )
    {
        MyErdTable *tbl = wxDynamicCast( (*it), MyErdTable );
        if( tbl )
            erdTable = tbl;
        ConstraintSign *s = wxDynamicCast( (*it), ConstraintSign );
        if( s )
            sign = s;
    }
    if( isTable )
    {
        table = &( const_cast<DatabaseTable &>( erdTable->GetTable() ) );
        name = const_cast<DatabaseTable &>( erdTable->GetTable() ).GetTableName();
    }
    else
    {
        constraint = sign->GetConstraint();
        constraint->GetLocalColumns( localColumns );
        constraint->GetRefColumns( refColumn );
        match = constraint->GetPGMatch();
    }
    int eventId = event.GetId();
    if( eventId == wxID_DROPOBJECT )
    {
        wxString message = _( "You are about to delete " );
        if( isTable )
            message += _( "table " ) + name + _( ". Are you sure?" );
        else
        {
            message += _( "foreign key " );
            wxString fkName = constraint->GetName();
            if( !fkName.empty() )
                message += fkName;
            else
                message += _( " on " ) + const_cast<DatabaseTable *>( constraint->GetFKTable() )->GetTableName() + _( " references " ) + constraint->GetRefTable() + _( ". Are you sure?" );
        }
        answer = wxMessageBox( message, _( "Database" ), wxYES_NO | wxNO_DEFAULT );
    }
    else
        answer = wxYES;
    if( answer == wxYES )
    {
        if( isTable && ( ( eventId == wxID_DROPOBJECT && !db->DeleteTable( name.ToStdWstring(), errors ) ) || eventId != wxID_DROPOBJECT ) )
        {
            if( m_realSelectedShape == m_selectedShape )
            {
                m_realSelectedShape = NULL;
                ShapeList listShapes;
                m_pManager.GetShapes( CLASSINFO( MyErdTable ), listShapes );
                int size = listShapes.size();
                if( listShapes.size() == 1 )
                    m_realSelectedShape = NULL;
                else
                {
                    MyErdTable *tableToRemove = (MyErdTable *) ( listShapes.Item( size - 1 )->GetData() );
                    if( tableToRemove == erdTable )
                        m_realSelectedShape = (MyErdTable *) ( listShapes.Item( size - 2 )->GetData() );
                    else
                    {
                        bool found = false;
                        int i;
                        for( i = 0; i < size - 1 || !found; i++ )
                            if( listShapes.Item( i )->GetData() == erdTable )
                                found = true;
                        m_realSelectedShape = listShapes.Item( i + 1 )->GetData();
                    }
                }
            }
            m_pManager.RemoveShape( erdTable );
/*            for( ShapeList::iterator it = listShapes.begin(); it != listShapes.end() || !nextShapeFound; ++it )
            {
                CommentFieldShape *shape = wxDynamicCast( (*it), CommentFieldShape );
                if( m_showComments )
                {
                    shape->SetText( const_cast<Field *>( shape->GetFieldForComment() )->GetComment() );
                }
                else
                {
                    shape->SetText( wxEmptyString );
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的ShapeList::Item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。