示例#1
0
void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent )
{
    SCH_FIND_COLLECTOR_DATA data;

    bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR );
    SCH_ITEM* item = (SCH_ITEM*) m_foundItems.GetItem( data );

    wxCHECK_RET( item != NULL, wxT( "Invalid replace item in find collector list." ) );

    wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ),
                GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ),
                GetChars( m_foundItems.GetText() ) );

    SCH_ITEM* undoItem = data.GetParent();

    if( undoItem == NULL )
        undoItem = item;

    SetUndoItem( undoItem );

    if( m_foundItems.ReplaceItem() )
    {
        OnModify();
        SaveUndoItemInUndoList( undoItem );
        RedrawScreen( data.GetPosition(), warpCursor );
    }

    OnFindSchematicItem( aEvent );

    if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL )
    {
        while( ( item = (SCH_ITEM*) m_foundItems.GetItem( data ) ) != NULL )
        {
            wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ),
                        GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ),
                        GetChars( m_foundItems.GetText() ) );

            SCH_ITEM* undoItem = data.GetParent();

            // Don't save child items in undo list.
            if( undoItem == NULL )
                undoItem = item;

            SetUndoItem( undoItem );

            if( m_foundItems.ReplaceItem() )
            {
                OnModify();
                SaveUndoItemInUndoList( undoItem );
                RedrawScreen( data.GetPosition(), warpCursor );
            }

            OnFindSchematicItem( aEvent );
        }
    }
}
示例#2
0
void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
{
    // If the user dismissed the dialog with the mouse, this will send the cursor back
    // to the last item found.
    OnFindSchematicItem( event );

    if( m_dlgFindReplace )
    {
        m_findDialogPosition = m_dlgFindReplace->GetPosition();
        m_findDialogSize = m_dlgFindReplace->GetSize();
        m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
        m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
        m_dlgFindReplace->Destroy();
        m_dlgFindReplace = NULL;
    }
}