2011-12-21 20:21:15 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-05-19 21:04:04 +00:00
|
|
|
* Copyright (C) 2010-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-21 20:21:15 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
|
|
|
|
*
|
|
|
|
* This dialog is used to define the search criteria used to search for items
|
|
|
|
* in the current schematic. What is searched depends on the schematic item
|
|
|
|
* type. Check the Matches() method for each item derived from SCH_ITEM() to
|
|
|
|
* find out how matching is performed against that item.
|
|
|
|
*/
|
|
|
|
|
2011-12-21 20:21:15 +00:00
|
|
|
#ifndef __dialog_schematic_find__
|
|
|
|
#define __dialog_schematic_find__
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
#include "dialog_schematic_find_base.h"
|
|
|
|
|
|
|
|
#include <wx/fdrepdlg.h> // Use the wxFindReplaceDialog events, data, and enums.
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
class SCH_EDITOR_CONTROL;
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/**
|
|
|
|
* Define schematic specific find and replace dialog flags based on the enum entries
|
2010-03-16 18:22:59 +00:00
|
|
|
* in wxFindReplaceFlags. These flags are intended to be used as bit masks in the
|
2011-12-01 16:49:28 +00:00
|
|
|
* wxFindReplaceData::m_Flags member variable. The variable is defined as a wxUint32.
|
2010-03-16 18:22:59 +00:00
|
|
|
*/
|
|
|
|
enum SchematicFindReplaceFlags
|
|
|
|
{
|
2013-10-27 18:21:53 +00:00
|
|
|
// The last wxFindReplaceFlag enum is wxFR_MATCHCASE = 0x4.
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/// Search the current sheet only.
|
2010-03-16 18:22:59 +00:00
|
|
|
FR_CURRENT_SHEET_ONLY = wxFR_MATCHCASE << 1,
|
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/// Search all fields in component, not just the value and reference fields.
|
2010-03-16 18:22:59 +00:00
|
|
|
FR_SEARCH_ALL_FIELDS = wxFR_MATCHCASE << 2,
|
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/// Search texts (name and number (a 4 letters text) )in pins.
|
|
|
|
FR_SEARCH_ALL_PINS = wxFR_MATCHCASE << 3,
|
2010-10-20 19:43:58 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/// Perform search using simple wild card matching (* & ?).
|
2010-10-20 19:43:58 +00:00
|
|
|
FR_MATCH_WILDCARD = wxFR_MATCHCASE << 4,
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
/// Wrap around the beginning or end of search list.
|
2011-02-03 21:57:02 +00:00
|
|
|
FR_SEARCH_WRAP = wxFR_MATCHCASE << 5,
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
/// Perform a search for a item that has replaceable text.
|
2011-11-17 01:06:08 +00:00
|
|
|
FR_SEARCH_REPLACE = wxFR_MATCHCASE << 7,
|
|
|
|
|
|
|
|
/// Used by the search event handler to let the dialog know that a replaceable
|
|
|
|
/// item has been found.
|
2011-12-21 20:21:15 +00:00
|
|
|
FR_REPLACE_ITEM_FOUND = wxFR_MATCHCASE << 8,
|
|
|
|
|
|
|
|
/// Used by replace to ignore the component reference designator field.
|
|
|
|
FR_REPLACE_REFERENCES = wxFR_MATCHCASE << 9
|
2010-03-16 18:22:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
/**
|
2013-07-14 18:08:20 +00:00
|
|
|
* Definition FR_MASK_NON_COMPARE_FLAGS
|
2011-12-13 15:37:33 +00:00
|
|
|
* is used to mask find/replace flag bits that do not effect the search results.
|
|
|
|
*/
|
2019-05-19 21:04:04 +00:00
|
|
|
#define FR_MASK_NON_COMPARE_FLAGS ~( wxFR_DOWN | FR_SEARCH_WRAP | FR_REPLACE_ITEM_FOUND )
|
2011-12-13 15:37:33 +00:00
|
|
|
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
/**
|
|
|
|
* Class SCH_FIND_REPLACE_DATA
|
|
|
|
* adds missing useful comparison and assignment operators to the wxFindReplaceData object.
|
|
|
|
*/
|
|
|
|
class SCH_FIND_REPLACE_DATA : public wxFindReplaceData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
SCH_FIND_REPLACE_DATA& operator =( const SCH_FIND_REPLACE_DATA& aFindReplaceData )
|
2011-12-01 16:49:28 +00:00
|
|
|
{
|
|
|
|
if( this == &aFindReplaceData )
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
SetFlags( aFindReplaceData.GetFlags() );
|
|
|
|
SetFindString( aFindReplaceData.GetFindString() );
|
|
|
|
SetReplaceString( aFindReplaceData.GetReplaceString() );
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator ==( SCH_FIND_REPLACE_DATA& aFindReplaceData )
|
|
|
|
{
|
|
|
|
return ( (GetFlags() == aFindReplaceData.GetFlags())
|
|
|
|
&& (GetFindString() == aFindReplaceData.GetFindString())
|
|
|
|
&& (GetReplaceString() == aFindReplaceData.GetReplaceString()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator !=( SCH_FIND_REPLACE_DATA& aFindReplaceData )
|
|
|
|
{
|
|
|
|
return !( *this == aFindReplaceData );
|
|
|
|
}
|
2011-12-13 15:37:33 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Function GetSearchFlags
|
|
|
|
* @return The flags that only effect the search result.
|
|
|
|
*/
|
2013-07-14 18:08:20 +00:00
|
|
|
wxUint32 GetCompareFlags() const { return GetFlags() & FR_MASK_NON_COMPARE_FLAGS; }
|
2011-12-01 16:49:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
/** Implementing DIALOG_SCH_FIND_BASE */
|
|
|
|
class DIALOG_SCH_FIND : public DIALOG_SCH_FIND_BASE
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Handlers for DIALOG_SCH_FIND_BASE events.
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnClose( wxCloseEvent& aEvent ) override;
|
2019-05-19 21:04:04 +00:00
|
|
|
void OnSearchForText( wxCommandEvent& aEvent ) override;
|
2018-02-12 22:48:37 +00:00
|
|
|
void OnTextEnter( wxCommandEvent& event ) override;
|
2019-05-19 21:04:04 +00:00
|
|
|
void OnOptions( wxCommandEvent& event ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnUpdateReplaceUI( wxUpdateUIEvent& aEvent ) override;
|
|
|
|
void OnUpdateReplaceAllUI( wxUpdateUIEvent& aEvent ) override;
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
void OnChar( wxKeyEvent& aEvent );
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnFind( wxCommandEvent& aEvent ) override;
|
|
|
|
void OnReplace( wxCommandEvent& aEvent ) override;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
SCH_EDIT_FRAME* m_frame;
|
|
|
|
SCH_EDITOR_CONTROL* m_editorControl;
|
|
|
|
wxFindReplaceData* m_findReplaceData;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS( DIALOG_SCH_FIND )
|
|
|
|
|
|
|
|
public:
|
2019-05-19 21:04:04 +00:00
|
|
|
DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, wxFindReplaceData* aData,
|
2010-03-16 18:22:59 +00:00
|
|
|
const wxPoint& aPosition = wxDefaultPosition,
|
|
|
|
const wxSize& aSize = wxDefaultSize, int aStyle = 0 );
|
|
|
|
|
|
|
|
void SetFindEntries( const wxArrayString& aEntries );
|
|
|
|
wxArrayString GetFindEntries() const;
|
|
|
|
|
|
|
|
void SetReplaceEntries( const wxArrayString& aEntries );
|
|
|
|
wxArrayString GetReplaceEntries() const { return m_comboReplace->GetStrings(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __dialog_schematic_find__
|