Commit 85d2f2f1 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Eeschema find and replace improvements.

* Add check box and flag to ignore replacing the component reference
  designator field.
* Fix a resizing bug when switching between the find and replace modes of
  the find/replace dialog.
* Fix replace component reference designator field bug.
* Force rebuild of search list when schematic is modified and the replace
  dialog is closed.
* Prevent finding the next item when the find/replace dialog is closed.
* Respect warp mouse pointer setting when closing find/replace dialog.
* Fix duplicate mnemonic control accelerator keys in find/replace dialog.
parent 6c28cdc6
Loading
Loading
Loading
Loading
+63 −6
Original line number Original line Diff line number Diff line
@@ -528,7 +528,7 @@
                            <property name="proportion">0</property>
                            <property name="proportion">0</property>
                            <object class="wxCheckBox" expanded="0">
                            <object class="wxCheckBox" expanded="0">
                                <property name="bg"></property>
                                <property name="bg"></property>
                                <property name="checked">0</property>
                                <property name="checked">1</property>
                                <property name="context_help"></property>
                                <property name="context_help"></property>
                                <property name="context_menu">1</property>
                                <property name="context_menu">1</property>
                                <property name="enabled">1</property>
                                <property name="enabled">1</property>
@@ -536,7 +536,7 @@
                                <property name="font"></property>
                                <property name="font"></property>
                                <property name="hidden">0</property>
                                <property name="hidden">0</property>
                                <property name="id">wxID_ANY</property>
                                <property name="id">wxID_ANY</property>
                                <property name="label">Match &amp;whole word</property>
                                <property name="label">Match whole wor&amp;d</property>
                                <property name="maximum_size"></property>
                                <property name="maximum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="name">m_checkWholeWord</property>
                                <property name="name">m_checkWholeWord</property>
@@ -764,7 +764,7 @@
                                <property name="font"></property>
                                <property name="font"></property>
                                <property name="hidden">0</property>
                                <property name="hidden">0</property>
                                <property name="id">wxID_ANY</property>
                                <property name="id">wxID_ANY</property>
                                <property name="label">Search all component &amp;fields</property>
                                <property name="label">Search all com&amp;ponent fields</property>
                                <property name="maximum_size"></property>
                                <property name="maximum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="name">m_checkAllFields</property>
                                <property name="name">m_checkAllFields</property>
@@ -821,7 +821,7 @@
                                <property name="font"></property>
                                <property name="font"></property>
                                <property name="hidden">0</property>
                                <property name="hidden">0</property>
                                <property name="id">wxID_ANY</property>
                                <property name="id">wxID_ANY</property>
                                <property name="label">Search all pin names and numbers</property>
                                <property name="label">Search all pin &amp;names and numbers</property>
                                <property name="maximum_size"></property>
                                <property name="maximum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="name">m_checkAllPins</property>
                                <property name="name">m_checkAllPins</property>
@@ -878,7 +878,7 @@
                                <property name="font"></property>
                                <property name="font"></property>
                                <property name="hidden">0</property>
                                <property name="hidden">0</property>
                                <property name="id">wxID_ANY</property>
                                <property name="id">wxID_ANY</property>
                                <property name="label">Search the current sheet on&amp;ly</property>
                                <property name="label">Search the current &amp;sheet onl&amp;y</property>
                                <property name="maximum_size"></property>
                                <property name="maximum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="name">m_checkCurrentSheetOnly</property>
                                <property name="name">m_checkCurrentSheetOnly</property>
@@ -921,6 +921,63 @@
                                <event name="OnUpdateUI"></event>
                                <event name="OnUpdateUI"></event>
                            </object>
                            </object>
                        </object>
                        </object>
                        <object class="sizeritem" expanded="1">
                            <property name="border">6</property>
                            <property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</property>
                            <property name="proportion">0</property>
                            <object class="wxCheckBox" expanded="1">
                                <property name="bg"></property>
                                <property name="checked">0</property>
                                <property name="context_help"></property>
                                <property name="context_menu">1</property>
                                <property name="enabled">1</property>
                                <property name="fg"></property>
                                <property name="font"></property>
                                <property name="hidden">1</property>
                                <property name="id">wxID_ANY</property>
                                <property name="label">Replace componen&amp;t reference designators</property>
                                <property name="maximum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="name">m_checkReplaceReferences</property>
                                <property name="permission">protected</property>
                                <property name="pos"></property>
                                <property name="size"></property>
                                <property name="style"></property>
                                <property name="subclass"></property>
                                <property name="tooltip"></property>
                                <property name="validator_data_type"></property>
                                <property name="validator_style">wxFILTER_NONE</property>
                                <property name="validator_type">wxDefaultValidator</property>
                                <property name="validator_variable"></property>
                                <property name="window_extra_style"></property>
                                <property name="window_name"></property>
                                <property name="window_style"></property>
                                <event name="OnChar"></event>
                                <event name="OnCheckBox"></event>
                                <event name="OnEnterWindow"></event>
                                <event name="OnEraseBackground"></event>
                                <event name="OnKeyDown"></event>
                                <event name="OnKeyUp"></event>
                                <event name="OnKillFocus"></event>
                                <event name="OnLeaveWindow"></event>
                                <event name="OnLeftDClick"></event>
                                <event name="OnLeftDown"></event>
                                <event name="OnLeftUp"></event>
                                <event name="OnMiddleDClick"></event>
                                <event name="OnMiddleDown"></event>
                                <event name="OnMiddleUp"></event>
                                <event name="OnMotion"></event>
                                <event name="OnMouseEvents"></event>
                                <event name="OnMouseWheel"></event>
                                <event name="OnPaint"></event>
                                <event name="OnRightDClick"></event>
                                <event name="OnRightDown"></event>
                                <event name="OnRightUp"></event>
                                <event name="OnSetFocus"></event>
                                <event name="OnSize"></event>
                                <event name="OnUpdateUI"></event>
                            </object>
                        </object>
                        <object class="sizeritem" expanded="1">
                        <object class="sizeritem" expanded="1">
                            <property name="border">6</property>
                            <property name="border">6</property>
                            <property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</property>
                            <property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</property>
@@ -935,7 +992,7 @@
                                <property name="font"></property>
                                <property name="font"></property>
                                <property name="hidden">0</property>
                                <property name="hidden">0</property>
                                <property name="id">wxID_ANY</property>
                                <property name="id">wxID_ANY</property>
                                <property name="label">Do not warp cursor to found item</property>
                                <property name="label">D&amp;o not warp cursor to found item</property>
                                <property name="maximum_size"></property>
                                <property name="maximum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="minimum_size"></property>
                                <property name="name">m_checkNoWarpCursor</property>
                                <property name="name">m_checkNoWarpCursor</property>
+49 −1
Original line number Original line Diff line number Diff line
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2010-2011 KiCad Developers, see AUTHORS.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

/**
 * @file dialog_schematic_find.cpp
 * @brief Schematic find and replace dialog implementation.
 */

#include "dialog_schematic_find.h"
#include "dialog_schematic_find.h"




@@ -21,6 +50,7 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData,
        m_buttonReplaceAll->Show( true );
        m_buttonReplaceAll->Show( true );
        m_staticReplace->Show( true );
        m_staticReplace->Show( true );
        m_comboReplace->Show( true );
        m_comboReplace->Show( true );
        m_checkReplaceReferences->Show( true );
        m_checkWildcardMatch->Show( false );  // Wildcard replace is not implemented.
        m_checkWildcardMatch->Show( false );  // Wildcard replace is not implemented.
    }
    }


@@ -36,6 +66,7 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData,
        m_checkWildcardMatch->SetValue( flags & FR_MATCH_WILDCARD );
        m_checkWildcardMatch->SetValue( flags & FR_MATCH_WILDCARD );


    m_checkAllFields->SetValue( flags & FR_SEARCH_ALL_FIELDS );
    m_checkAllFields->SetValue( flags & FR_SEARCH_ALL_FIELDS );
    m_checkReplaceReferences->SetValue( flags & FR_REPLACE_REFERENCES );
    m_checkAllPins->SetValue( flags & FR_SEARCH_ALL_PINS );
    m_checkAllPins->SetValue( flags & FR_SEARCH_ALL_PINS );
    m_checkWrap->SetValue( flags & FR_SEARCH_WRAP );
    m_checkWrap->SetValue( flags & FR_SEARCH_WRAP );
    m_checkCurrentSheetOnly->SetValue( flags & FR_CURRENT_SHEET_ONLY );
    m_checkCurrentSheetOnly->SetValue( flags & FR_CURRENT_SHEET_ONLY );
@@ -43,7 +74,21 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData,
    m_buttonFind->SetDefault();
    m_buttonFind->SetDefault();
    m_comboFind->SetFocus();
    m_comboFind->SetFocus();
    SetPosition( aPosition );
    SetPosition( aPosition );
    SetSize( aSize );

    // Adjust the height of the dialog to prevent controls from being hidden when
    // switching between the find and find/replace modes of the dialog.  This ignores
    // the users preferred height if any of the controls would be hidden.
    wxSize size = aSize;

    if( aSize != wxDefaultSize )
    {
        wxSize bestSize = GetBestSize();

        if( size.GetHeight() != bestSize.GetHeight() )
            size.SetHeight( bestSize.GetHeight() );
    }

    SetSize( size );
}
}




@@ -142,6 +187,9 @@ void DIALOG_SCH_FIND::SendEvent( const wxEventType& aEventType )
    {
    {
        event.SetReplaceString( m_comboReplace->GetValue() );
        event.SetReplaceString( m_comboReplace->GetValue() );
        flags |= FR_SEARCH_REPLACE;
        flags |= FR_SEARCH_REPLACE;

        if( m_checkReplaceReferences->GetValue() )
            flags |= FR_REPLACE_REFERENCES;
    }
    }


    if( m_radioForward->GetValue() )
    if( m_radioForward->GetValue() )
+30 −3
Original line number Original line Diff line number Diff line
#ifndef __dialog_schematic_find__
/*
#define __dialog_schematic_find__
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 2010-2011 KiCad Developers, see AUTHORS.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */


/**
/**
 * @file
 * @file
@@ -12,6 +33,9 @@
 * find out how matching is performed against that item.
 * find out how matching is performed against that item.
 */
 */


#ifndef __dialog_schematic_find__
#define __dialog_schematic_find__

#include "dialog_schematic_find_base.h"
#include "dialog_schematic_find_base.h"


#include <wx/fdrepdlg.h>          // Use the wxFindReplaceDialog events, data, and enums.
#include <wx/fdrepdlg.h>          // Use the wxFindReplaceDialog events, data, and enums.
@@ -49,7 +73,10 @@ enum SchematicFindReplaceFlags


    /// Used by the search event handler to let the dialog know that a replaceable
    /// Used by the search event handler to let the dialog know that a replaceable
    /// item has been found.
    /// item has been found.
    FR_REPLACE_ITEM_FOUND    = wxFR_MATCHCASE << 8
    FR_REPLACE_ITEM_FOUND    = wxFR_MATCHCASE << 8,

    /// Used by replace to ignore the component reference designator field.
    FR_REPLACE_REFERENCES    = wxFR_MATCHCASE << 9
};
};




+11 −5
Original line number Original line Diff line number Diff line
@@ -67,7 +67,8 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con
	
	
	leftSizer->Add( leftGridSizer, 0, wxALL|wxEXPAND, 6 );
	leftSizer->Add( leftGridSizer, 0, wxALL|wxEXPAND, 6 );
	
	
	m_checkWholeWord = new wxCheckBox( this, wxID_ANY, _("Match &whole word"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkWholeWord = new wxCheckBox( this, wxID_ANY, _("Match whole wor&d"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkWholeWord->SetValue(true); 
	leftSizer->Add( m_checkWholeWord, 0, wxALL, 6 );
	leftSizer->Add( m_checkWholeWord, 0, wxALL, 6 );
	
	
	m_checkMatchCase = new wxCheckBox( this, wxID_ANY, _("&Match case"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkMatchCase = new wxCheckBox( this, wxID_ANY, _("&Match case"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -80,16 +81,21 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con
	m_checkWrap->SetValue(true); 
	m_checkWrap->SetValue(true); 
	leftSizer->Add( m_checkWrap, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	leftSizer->Add( m_checkWrap, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	
	
	m_checkAllFields = new wxCheckBox( this, wxID_ANY, _("Search all component &fields"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkAllFields = new wxCheckBox( this, wxID_ANY, _("Search all com&ponent fields"), wxDefaultPosition, wxDefaultSize, 0 );
	leftSizer->Add( m_checkAllFields, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	leftSizer->Add( m_checkAllFields, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	
	
	m_checkAllPins = new wxCheckBox( this, wxID_ANY, _("Search all pin names and numbers"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkAllPins = new wxCheckBox( this, wxID_ANY, _("Search all pin &names and numbers"), wxDefaultPosition, wxDefaultSize, 0 );
	leftSizer->Add( m_checkAllPins, 0, wxBOTTOM|wxRIGHT|wxLEFT, 6 );
	leftSizer->Add( m_checkAllPins, 0, wxBOTTOM|wxRIGHT|wxLEFT, 6 );
	
	
	m_checkCurrentSheetOnly = new wxCheckBox( this, wxID_ANY, _("Search the current sheet on&ly"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkCurrentSheetOnly = new wxCheckBox( this, wxID_ANY, _("Search the current &sheet onl&y"), wxDefaultPosition, wxDefaultSize, 0 );
	leftSizer->Add( m_checkCurrentSheetOnly, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	leftSizer->Add( m_checkCurrentSheetOnly, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	
	
	m_checkNoWarpCursor = new wxCheckBox( this, wxID_ANY, _("Do not warp cursor to found item"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkReplaceReferences = new wxCheckBox( this, wxID_ANY, _("Replace componen&t reference designators"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkReplaceReferences->Hide();
	
	leftSizer->Add( m_checkReplaceReferences, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	
	m_checkNoWarpCursor = new wxCheckBox( this, wxID_ANY, _("D&o not warp cursor to found item"), wxDefaultPosition, wxDefaultSize, 0 );
	leftSizer->Add( m_checkNoWarpCursor, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	leftSizer->Add( m_checkNoWarpCursor, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
	
	
	mainSizer->Add( leftSizer, 1, wxALL|wxEXPAND, 6 );
	mainSizer->Add( leftSizer, 1, wxALL|wxEXPAND, 6 );
+1 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@ class DIALOG_SCH_FIND_BASE : public wxDialog
		wxCheckBox* m_checkAllFields;
		wxCheckBox* m_checkAllFields;
		wxCheckBox* m_checkAllPins;
		wxCheckBox* m_checkAllPins;
		wxCheckBox* m_checkCurrentSheetOnly;
		wxCheckBox* m_checkCurrentSheetOnly;
		wxCheckBox* m_checkReplaceReferences;
		wxCheckBox* m_checkNoWarpCursor;
		wxCheckBox* m_checkNoWarpCursor;
		wxButton* m_buttonFind;
		wxButton* m_buttonFind;
		wxButton* m_buttonReplace;
		wxButton* m_buttonReplace;
Loading