Пример #1
0
void csDiagramView::DoCut(wxList& shapes)
{
    csDiagramDocument *doc = (csDiagramDocument *)GetDocument();

    if (shapes.GetCount() > 0)
    {
        csDiagramCommand* cmd = new csDiagramCommand(_T("Cut"), doc);

        wxObjectList::compatibility_iterator node = shapes.GetFirst();
        while (node)
        {
            wxShape *theShape = (wxShape*) node->GetData();
            csCommandState* state = new csCommandState(ID_CS_CUT, NULL, theShape);

            // Insert lines at the front, so they are cut first.
            // Otherwise we may try to remove a shape with a line still
            // attached.
            if (theShape->IsKindOf(CLASSINFO(wxLineShape)))
                cmd->InsertState(state);
            else
                cmd->AddState(state);

            node = node->GetNext();
        }
        cmd->RemoveLines(); // Schedule any connected lines, not already mentioned,
                            // to be removed first

        doc->GetCommandProcessor()->Submit(cmd);
    }
}
Пример #2
0
void MyFrame::OnClose(wxCloseEvent& event)
{
    if ( !event.CanVeto() )
    {
        event.Skip();
        return ;
    }
    if ( m_children.GetCount () < 1 )
    {
        event.Skip();
        return ;
    }
    // now try the children
    wxObjectList::compatibility_iterator pNode = m_children.GetFirst ();
    wxObjectList::compatibility_iterator pNext ;
    MyChild * pChild ;
    while ( pNode )
    {
        pNext = pNode -> GetNext ();
        pChild = (MyChild*) pNode -> GetData ();
        if (pChild -> Close ())
        {
            m_children.Erase(pNode) ;
        }
        else
        {
            event.Veto();
            return;
        }
        pNode = pNext ;
    }
    event.Skip();
}
Пример #3
0
// Generalised command
void csDiagramView::DoCmd(wxList& shapes, wxList& oldShapes, int cmd, const wxString& op)
{
    csDiagramDocument *doc = (csDiagramDocument *)GetDocument();

    if (shapes.GetCount() > 0)
    {
        csDiagramCommand* command = new csDiagramCommand(op, doc);

        wxObjectList::compatibility_iterator node = shapes.GetFirst();
        wxObjectList::compatibility_iterator node1 = oldShapes.GetFirst();
        while (node && node1)
        {
            wxShape *theShape = (wxShape*) node->GetData();
            wxShape *oldShape = (wxShape*) node1->GetData();
            csCommandState* state = new csCommandState(cmd, theShape, oldShape);
            command->AddState(state);

            node = node->GetNext();
            node1 = node1->GetNext();
        }
        doc->GetCommandProcessor()->Submit(command);
    }
}