mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-14 16:19:36 +00:00
Replace wxFindReplaceData with our own container
By dropping the flags, we can be strict with options. Also it makes future usage of search functionality a little more "UI" framework independent
This commit is contained in:
parent
ffab57ffd0
commit
e0f28fc4e1
@ -106,7 +106,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||
m_msgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight( this );
|
||||
m_userUnits = EDA_UNITS::MILLIMETRES;
|
||||
m_polarCoords = false;
|
||||
m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
|
||||
m_findReplaceData = std::make_unique<EDA_SEARCH_DATA>();
|
||||
|
||||
m_auimgr.SetFlags( wxAUI_MGR_DEFAULT );
|
||||
|
||||
@ -191,8 +191,6 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
|
||||
delete m_currentScreen;
|
||||
m_currentScreen = nullptr;
|
||||
|
||||
delete m_findReplaceData;
|
||||
|
||||
m_auimgr.UnInit();
|
||||
|
||||
ReleaseFile();
|
||||
@ -648,9 +646,12 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
|
||||
m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
|
||||
|
||||
m_findReplaceData->SetFlags( aCfg->m_FindReplace.flags );
|
||||
m_findReplaceData->SetFindString( aCfg->m_FindReplace.find_string );
|
||||
m_findReplaceData->SetReplaceString( aCfg->m_FindReplace.replace_string );
|
||||
m_findReplaceData->findString = aCfg->m_FindReplace.find_string;
|
||||
m_findReplaceData->replaceString = aCfg->m_FindReplace.replace_string;
|
||||
m_findReplaceData->matchMode =
|
||||
static_cast<EDA_SEARCH_MATCH_MODE>( aCfg->m_FindReplace.match_mode );
|
||||
m_findReplaceData->matchCase = aCfg->m_FindReplace.match_case;
|
||||
m_findReplaceData->searchAndReplace = aCfg->m_FindReplace.search_and_replace;
|
||||
|
||||
for( auto& s : aCfg->m_FindReplace.find_history )
|
||||
m_findStringHistoryList.Add( s );
|
||||
@ -672,9 +673,10 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
|
||||
m_galDisplayOptions.WriteConfig( *window );
|
||||
|
||||
aCfg->m_FindReplace.flags = m_findReplaceData->GetFlags();
|
||||
aCfg->m_FindReplace.find_string = m_findReplaceData->GetFindString();
|
||||
aCfg->m_FindReplace.replace_string = m_findReplaceData->GetReplaceString();
|
||||
aCfg->m_FindReplace.search_and_replace = m_findReplaceData->searchAndReplace;
|
||||
|
||||
aCfg->m_FindReplace.find_string = m_findReplaceData->findString;
|
||||
aCfg->m_FindReplace.replace_string = m_findReplaceData->replaceString;
|
||||
|
||||
aCfg->m_FindReplace.find_history.clear();
|
||||
aCfg->m_FindReplace.replace_history.clear();
|
||||
|
@ -115,23 +115,22 @@ wxString EDA_ITEM::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||
}
|
||||
|
||||
|
||||
bool EDA_ITEM::Matches( const wxString& aText, const wxFindReplaceData& aSearchData ) const
|
||||
bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchData ) const
|
||||
{
|
||||
wxString text = aText;
|
||||
int flags = aSearchData.GetFlags();
|
||||
wxString searchText = aSearchData.GetFindString();
|
||||
wxString searchText = aSearchData.findString;
|
||||
|
||||
// Don't match if searching for replaceable item and the item doesn't support text replace.
|
||||
if( ( flags & FR_SEARCH_REPLACE ) && !IsReplaceable() )
|
||||
if( aSearchData.searchAndReplace && !IsReplaceable() )
|
||||
return false;
|
||||
|
||||
if( !( flags & wxFR_MATCHCASE ) )
|
||||
if( !aSearchData.matchCase )
|
||||
{
|
||||
text.MakeUpper();
|
||||
searchText.MakeUpper();
|
||||
}
|
||||
|
||||
if( flags & wxFR_WHOLEWORD )
|
||||
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD )
|
||||
{
|
||||
int ii = 0;
|
||||
|
||||
@ -156,7 +155,7 @@ bool EDA_ITEM::Matches( const wxString& aText, const wxFindReplaceData& aSearchD
|
||||
|
||||
return false;
|
||||
}
|
||||
else if( flags & FR_MATCH_WILDCARD )
|
||||
else if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WILDCARD )
|
||||
{
|
||||
return text.Matches( searchText );
|
||||
}
|
||||
@ -167,15 +166,14 @@ bool EDA_ITEM::Matches( const wxString& aText, const wxFindReplaceData& aSearchD
|
||||
}
|
||||
|
||||
|
||||
bool EDA_ITEM::Replace( const wxFindReplaceData& aSearchData, wxString& aText )
|
||||
bool EDA_ITEM::Replace( const EDA_SEARCH_DATA& aSearchData, wxString& aText )
|
||||
{
|
||||
wxString text = aText;
|
||||
int flags = aSearchData.GetFlags();
|
||||
wxString searchText = aSearchData.GetFindString();
|
||||
wxString searchText = aSearchData.findString;
|
||||
wxString result;
|
||||
bool replaced = false;
|
||||
|
||||
if( flags & wxFR_MATCHCASE )
|
||||
if( !aSearchData.matchCase )
|
||||
{
|
||||
text = text.Upper();
|
||||
searchText = searchText.Upper();
|
||||
@ -202,7 +200,7 @@ bool EDA_ITEM::Replace( const wxFindReplaceData& aSearchData, wxString& aText )
|
||||
bool startOK;
|
||||
bool endOK;
|
||||
|
||||
if( flags & wxFR_WHOLEWORD )
|
||||
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD )
|
||||
{
|
||||
startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
|
||||
endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
|
||||
@ -215,7 +213,7 @@ bool EDA_ITEM::Replace( const wxFindReplaceData& aSearchData, wxString& aText )
|
||||
|
||||
if( startOK && endOK )
|
||||
{
|
||||
result += aSearchData.GetReplaceString();
|
||||
result += aSearchData.replaceString;
|
||||
replaced = true;
|
||||
ii = next;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ int EDA_TEXT::GetEffectiveTextPenWidth( int aDefaultPenWidth ) const
|
||||
}
|
||||
|
||||
|
||||
bool EDA_TEXT::Replace( const wxFindReplaceData& aSearchData )
|
||||
bool EDA_TEXT::Replace( const EDA_SEARCH_DATA& aSearchData )
|
||||
{
|
||||
bool retval = EDA_ITEM::Replace( aSearchData, m_text );
|
||||
|
||||
|
@ -46,7 +46,14 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||
m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_FALLBACK;
|
||||
|
||||
// Build parameters list:
|
||||
m_params.emplace_back( new PARAM<int>( "find_replace.flags", &m_FindReplace.flags, 1 ) );
|
||||
m_params.emplace_back(
|
||||
new PARAM<int>( "find_replace.match_mode", &m_FindReplace.match_mode, 0 ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<bool>( "find_replace.match_case", &m_FindReplace.match_case, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "find_replace.search_and_replace",
|
||||
&m_FindReplace.search_and_replace, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string",
|
||||
&m_FindReplace.find_string, "" ) );
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <tools/sch_editor_control.h>
|
||||
|
||||
|
||||
DIALOG_SCH_FIND::DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, wxFindReplaceData* aData,
|
||||
DIALOG_SCH_FIND::DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, SCH_SEARCH_DATA* aData,
|
||||
const wxPoint& aPosition, const wxSize& aSize, int aStyle ) :
|
||||
DIALOG_SCH_FIND_BASE( aParent, wxID_ANY, _( "Find" ), aPosition, aSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | aStyle ),
|
||||
@ -50,20 +50,15 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, wxFindReplaceData* aD
|
||||
m_checkWildcardMatch->Show( false ); // Wildcard replace is not implemented.
|
||||
}
|
||||
|
||||
int flags = m_findReplaceData->GetFlags();
|
||||
m_radioForward->SetValue( flags & wxFR_DOWN );
|
||||
m_radioBackward->SetValue( ( flags & wxFR_DOWN ) == 0 );
|
||||
m_checkMatchCase->SetValue( flags & wxFR_MATCHCASE );
|
||||
m_checkWholeWord->SetValue( flags & wxFR_WHOLEWORD );
|
||||
m_checkMatchCase->SetValue( m_findReplaceData->matchCase );
|
||||
m_checkWholeWord->SetValue( m_findReplaceData->matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD );
|
||||
m_checkWildcardMatch->SetValue( m_findReplaceData->matchMode
|
||||
== EDA_SEARCH_MATCH_MODE::WILDCARD );
|
||||
|
||||
/* Whole word and wild card searches are mutually exclusive. */
|
||||
if( !( flags & wxFR_WHOLEWORD ) )
|
||||
m_checkWildcardMatch->SetValue( flags & FR_MATCH_WILDCARD );
|
||||
|
||||
m_checkAllFields->SetValue( flags & FR_SEARCH_ALL_FIELDS );
|
||||
m_checkReplaceReferences->SetValue( flags & FR_REPLACE_REFERENCES );
|
||||
m_checkAllPins->SetValue( flags & FR_SEARCH_ALL_PINS );
|
||||
m_checkCurrentSheetOnly->SetValue( flags & FR_CURRENT_SHEET_ONLY );
|
||||
m_checkAllFields->SetValue( m_findReplaceData->searchAllFields );
|
||||
m_checkReplaceReferences->SetValue( m_findReplaceData->replaceReferences );
|
||||
m_checkAllPins->SetValue( m_findReplaceData->searchAllPins );
|
||||
m_checkCurrentSheetOnly->SetValue( m_findReplaceData->searchCurrentSheetOnly );
|
||||
|
||||
m_buttonFind->SetDefault();
|
||||
SetInitialFocus( m_comboFind );
|
||||
@ -139,14 +134,14 @@ void DIALOG_SCH_FIND::OnChar( wxKeyEvent& aEvent )
|
||||
|
||||
void DIALOG_SCH_FIND::OnSearchForText( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_findReplaceData->SetFindString( m_comboFind->GetValue() );
|
||||
m_findReplaceData->findString = m_comboFind->GetValue();
|
||||
m_findDirty = true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SCH_FIND::OnSearchForSelect( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_findReplaceData->SetFindString( m_comboFind->GetValue() );
|
||||
m_findReplaceData->findString = m_comboFind->GetValue();
|
||||
|
||||
// Move the search string to the top of the list if it isn't already there.
|
||||
if( aEvent.GetSelection() != 0 )
|
||||
@ -163,13 +158,13 @@ void DIALOG_SCH_FIND::OnSearchForSelect( wxCommandEvent& aEvent )
|
||||
|
||||
void DIALOG_SCH_FIND::OnReplaceWithText( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_findReplaceData->SetReplaceString( m_comboReplace->GetValue() );
|
||||
m_findReplaceData->replaceString = m_comboReplace->GetValue();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SCH_FIND::OnReplaceWithSelect( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_findReplaceData->SetReplaceString( m_comboReplace->GetValue() );
|
||||
m_findReplaceData->replaceString = m_comboReplace->GetValue();
|
||||
|
||||
// Move the replace string to the top of the list if it isn't already there.
|
||||
if( aEvent.GetSelection() != 0 )
|
||||
@ -203,33 +198,38 @@ void DIALOG_SCH_FIND::OnOptions( wxCommandEvent& aEvent )
|
||||
void DIALOG_SCH_FIND::updateFlags()
|
||||
{
|
||||
// Rebuild the search flags in m_findReplaceData from dialog settings
|
||||
int flags = 0;
|
||||
|
||||
if( m_radioForward->GetValue() )
|
||||
flags |= wxFR_DOWN;
|
||||
|
||||
if( m_checkMatchCase->GetValue() )
|
||||
flags |= wxFR_MATCHCASE;
|
||||
m_findReplaceData->matchCase = true;
|
||||
else
|
||||
m_findReplaceData->matchCase = false;
|
||||
|
||||
if( m_checkWholeWord->GetValue() )
|
||||
flags |= wxFR_WHOLEWORD;
|
||||
|
||||
if( m_checkWildcardMatch->IsShown() && m_checkWildcardMatch->GetValue() )
|
||||
flags |= FR_MATCH_WILDCARD;
|
||||
m_findReplaceData->matchMode = EDA_SEARCH_MATCH_MODE::WHOLEWORD;
|
||||
else if( m_checkWildcardMatch->IsShown() && m_checkWildcardMatch->GetValue() )
|
||||
m_findReplaceData->matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
||||
else
|
||||
m_findReplaceData->matchMode = EDA_SEARCH_MATCH_MODE::PLAIN;
|
||||
|
||||
if( m_checkAllFields->GetValue() )
|
||||
flags |= FR_SEARCH_ALL_FIELDS;
|
||||
m_findReplaceData->searchAllFields = true;
|
||||
else
|
||||
m_findReplaceData->searchAllFields = false;
|
||||
|
||||
if( m_checkAllPins->GetValue() )
|
||||
flags |= FR_SEARCH_ALL_PINS;
|
||||
m_findReplaceData->searchAllPins = true;
|
||||
else
|
||||
m_findReplaceData->searchAllPins = false;
|
||||
|
||||
if( m_checkCurrentSheetOnly->GetValue() )
|
||||
flags |= FR_CURRENT_SHEET_ONLY;
|
||||
m_findReplaceData->searchCurrentSheetOnly = true;
|
||||
else
|
||||
m_findReplaceData->searchCurrentSheetOnly = false;
|
||||
|
||||
if( m_checkReplaceReferences->GetValue() )
|
||||
flags |= FR_REPLACE_REFERENCES;
|
||||
|
||||
m_findReplaceData->SetFlags( flags );
|
||||
m_findReplaceData->replaceReferences = true;
|
||||
else
|
||||
m_findReplaceData->replaceReferences = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ class SCH_EDITOR_CONTROL;
|
||||
class DIALOG_SCH_FIND : public DIALOG_SCH_FIND_BASE
|
||||
{
|
||||
public:
|
||||
DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, wxFindReplaceData* aData,
|
||||
DIALOG_SCH_FIND( SCH_EDIT_FRAME* aParent, SCH_SEARCH_DATA* aData,
|
||||
const wxPoint& aPosition = wxDefaultPosition,
|
||||
const wxSize& aSize = wxDefaultSize, int aStyle = 0 );
|
||||
|
||||
@ -80,7 +80,7 @@ protected:
|
||||
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
SCH_EDITOR_CONTROL* m_editorControl;
|
||||
wxFindReplaceData* m_findReplaceData;
|
||||
SCH_SEARCH_DATA* m_findReplaceData;
|
||||
bool m_findDirty;
|
||||
|
||||
DECLARE_NO_COPY_CLASS( DIALOG_SCH_FIND )
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="15" />
|
||||
<FileVersion major="1" minor="16" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
@ -14,6 +14,7 @@
|
||||
<property name="file">dialog_schematic_find_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">dialog_sch_find</property>
|
||||
@ -25,6 +26,7 @@
|
||||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Dialog" expanded="1">
|
||||
@ -50,6 +52,7 @@
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">Find</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
@ -1072,6 +1075,7 @@
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
@ -1145,6 +1149,7 @@
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
@ -1219,6 +1224,7 @@
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
@ -1293,6 +1299,7 @@
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
|
@ -138,6 +138,12 @@ void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
|
||||
SCH_BASE_FRAME::LoadSettings( eeconfig() );
|
||||
|
||||
SCH_SEARCH_DATA* searchData = dynamic_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() );
|
||||
searchData->replaceReferences = eeconfig()->m_FindReplaceExtra.replace_references;
|
||||
searchData->searchAllFields = eeconfig()->m_FindReplaceExtra.search_all_fields;
|
||||
searchData->searchAllPins = eeconfig()->m_FindReplaceExtra.search_all_pins;
|
||||
searchData->searchCurrentSheetOnly = eeconfig()->m_FindReplaceExtra.search_current_sheet_only;
|
||||
|
||||
GetRenderSettings()->m_ShowPinsElectricalType = false;
|
||||
}
|
||||
|
||||
@ -156,6 +162,13 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
// Other parameters (hierarchy_panel_float_width, hierarchy_panel_float_height,
|
||||
// and hierarchy_panel_docked_width should have been updated when resizing the
|
||||
// hierarchy panel
|
||||
|
||||
SCH_SEARCH_DATA* searchData = dynamic_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() );
|
||||
eeconfig()->m_FindReplaceExtra.replace_references = searchData->replaceReferences;
|
||||
eeconfig()->m_FindReplaceExtra.search_all_fields = searchData->searchAllFields;
|
||||
eeconfig()->m_FindReplaceExtra.search_all_pins = searchData->searchAllPins;
|
||||
eeconfig()->m_FindReplaceExtra.search_current_sheet_only =
|
||||
searchData->searchCurrentSheetOnly;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
|
||||
m_Appearance(),
|
||||
m_AutoplaceFields(),
|
||||
m_Drawing(),
|
||||
m_FindReplaceExtra(),
|
||||
m_Input(),
|
||||
m_PageSettings(),
|
||||
m_AnnotatePanel(),
|
||||
@ -198,6 +199,19 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
|
||||
m_params.emplace_back(new PARAM <int>( "drawing.junction_size_choice",
|
||||
&m_Drawing.junction_size_choice, 3 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_fields",
|
||||
&m_FindReplaceExtra.search_all_fields, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "find_replace.search_all_pins",
|
||||
&m_FindReplaceExtra.search_all_pins, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "find_replace.search_current_sheet_only",
|
||||
&m_FindReplaceExtra.search_current_sheet_only,
|
||||
false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "find_replace.replace_references",
|
||||
&m_FindReplaceExtra.replace_references, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "input.drag_is_move",
|
||||
&m_Input.drag_is_move, false ) );
|
||||
|
||||
|
@ -236,6 +236,15 @@ public:
|
||||
WINDOW_SETTINGS window;
|
||||
};
|
||||
|
||||
struct FIND_REPLACE_EXTRA
|
||||
{
|
||||
bool search_all_fields;
|
||||
bool search_all_pins;
|
||||
bool search_current_sheet_only;
|
||||
|
||||
bool replace_references;
|
||||
};
|
||||
|
||||
EESCHEMA_SETTINGS();
|
||||
|
||||
virtual ~EESCHEMA_SETTINGS() {}
|
||||
@ -267,6 +276,8 @@ public:
|
||||
|
||||
DRAWING m_Drawing;
|
||||
|
||||
FIND_REPLACE_EXTRA m_FindReplaceExtra;
|
||||
|
||||
INPUT m_Input;
|
||||
|
||||
PAGE_SETTINGS m_PageSettings;
|
||||
|
@ -67,12 +67,12 @@ public:
|
||||
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
||||
{
|
||||
return LIB_ITEM::Matches( GetText(), aSearchData );
|
||||
}
|
||||
|
||||
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
|
||||
{
|
||||
return EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
|
@ -125,6 +125,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
|
||||
m_findReplaceDialog = nullptr;
|
||||
|
||||
m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
|
||||
|
||||
// Give an icon
|
||||
wxIcon icon;
|
||||
wxIconBundle icon_bundle;
|
||||
@ -1045,8 +1047,9 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
|
||||
if( m_findReplaceDialog )
|
||||
m_findReplaceDialog->Destroy();
|
||||
|
||||
m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
|
||||
wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
|
||||
m_findReplaceDialog = new DIALOG_SCH_FIND(
|
||||
this, static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ), wxDefaultPosition,
|
||||
wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
|
||||
|
||||
m_findReplaceDialog->SetFindEntries( m_findStringHistoryList, findString );
|
||||
m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList );
|
||||
|
@ -521,13 +521,24 @@ bool SCH_FIELD::IsVoid() const
|
||||
}
|
||||
|
||||
|
||||
bool SCH_FIELD::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const
|
||||
bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
|
||||
{
|
||||
bool searchHiddenFields = false;
|
||||
bool searchAndReplace = false;
|
||||
bool replaceReferences = false;
|
||||
|
||||
try
|
||||
{
|
||||
const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData ); // downcast
|
||||
searchHiddenFields = schSearchData.searchAllFields;
|
||||
searchAndReplace = schSearchData.searchAndReplace;
|
||||
replaceReferences = schSearchData.replaceReferences;
|
||||
}
|
||||
catch( const std::bad_cast& e )
|
||||
{
|
||||
}
|
||||
|
||||
wxString text = GetShownText();
|
||||
int flags = aSearchData.GetFlags();
|
||||
bool searchHiddenFields = flags & FR_SEARCH_ALL_FIELDS;
|
||||
bool searchAndReplace = flags & FR_SEARCH_REPLACE;
|
||||
bool replaceReferences = flags & FR_REPLACE_REFERENCES;
|
||||
|
||||
wxLogTrace( traceFindItem, wxT( " child item " )
|
||||
+ GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
|
||||
@ -589,8 +600,19 @@ bool SCH_FIELD::IsReplaceable() const
|
||||
}
|
||||
|
||||
|
||||
bool SCH_FIELD::Replace( const wxFindReplaceData& aSearchData, void* aAuxData )
|
||||
bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
|
||||
{
|
||||
bool replaceReferences = false;
|
||||
|
||||
try
|
||||
{
|
||||
const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
|
||||
replaceReferences = schSearchData.replaceReferences;
|
||||
}
|
||||
catch( const std::bad_cast& e )
|
||||
{
|
||||
}
|
||||
|
||||
wxString text;
|
||||
bool resolve = false; // Replace in source text, not shown text
|
||||
bool isReplaced = false;
|
||||
@ -604,7 +626,7 @@ bool SCH_FIELD::Replace( const wxFindReplaceData& aSearchData, void* aAuxData )
|
||||
case REFERENCE_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
|
||||
|
||||
if( !( aSearchData.GetFlags() & FR_REPLACE_REFERENCES ) )
|
||||
if( !replaceReferences )
|
||||
return false;
|
||||
|
||||
text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
|
||||
|
@ -194,9 +194,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
||||
|
||||
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData = nullptr ) override;
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr ) override;
|
||||
|
||||
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
@ -173,7 +173,7 @@ void SCH_MARKER::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse
|
||||
}
|
||||
|
||||
|
||||
bool SCH_MARKER::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const
|
||||
bool SCH_MARKER::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
|
||||
{
|
||||
return SCH_ITEM::Matches( m_rcItem->GetErrorMessage(), aSearchData );
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
* @param[in] aAuxData is the optional data required for the search or NULL if not used.
|
||||
* @return True if the DRC main or auxiliary text matches the search criteria.
|
||||
*/
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxDat ) const override;
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxDat ) const override;
|
||||
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
|
@ -160,9 +160,12 @@ void SCH_PIN::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
}
|
||||
|
||||
|
||||
bool SCH_PIN::Matches( const wxFindReplaceData& aSearchData, void* aAuxDat ) const
|
||||
bool SCH_PIN::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxDat ) const
|
||||
{
|
||||
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS ) )
|
||||
const SCH_SEARCH_DATA& schSearchData =
|
||||
dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
|
||||
|
||||
if( !schSearchData.searchAllPins )
|
||||
return false;
|
||||
|
||||
return EDA_ITEM::Matches( GetName(), aSearchData )
|
||||
@ -170,7 +173,7 @@ bool SCH_PIN::Matches( const wxFindReplaceData& aSearchData, void* aAuxDat ) con
|
||||
}
|
||||
|
||||
|
||||
bool SCH_PIN::Replace( const wxFindReplaceData& aSearchData, void* aAuxData )
|
||||
bool SCH_PIN::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
|
||||
{
|
||||
bool isReplaced = false;
|
||||
|
||||
|
@ -118,9 +118,9 @@ public:
|
||||
/// @return the pin's position in global coordinates.
|
||||
VECTOR2I GetTransformedPosition() const;
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
||||
|
||||
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override;
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
|
||||
|
||||
/*
|
||||
* While many of these are currently simply covers for the equivalent LIB_PIN methods,
|
||||
|
@ -887,7 +887,7 @@ void SCH_SHEET::Resize( const wxSize& aSize )
|
||||
}
|
||||
|
||||
|
||||
bool SCH_SHEET::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const
|
||||
bool SCH_SHEET::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
|
||||
{
|
||||
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
|
||||
|
||||
|
@ -320,7 +320,7 @@ public:
|
||||
void MirrorVertically( int aCenter ) override;
|
||||
void Rotate( const VECTOR2I& aCenter ) override;
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
||||
|
||||
bool IsReplaceable() const override { return true; }
|
||||
|
||||
|
@ -166,12 +166,12 @@ public:
|
||||
void MirrorHorizontally( int aCenter ) override;
|
||||
void Rotate( const VECTOR2I& aCenter ) override;
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
||||
{
|
||||
return SCH_ITEM::Matches( GetText(), aSearchData );
|
||||
}
|
||||
|
||||
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData = nullptr ) override
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr ) override
|
||||
{
|
||||
return EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
|
@ -1585,7 +1585,7 @@ void SCH_SYMBOL::Rotate( const VECTOR2I& aCenter )
|
||||
}
|
||||
|
||||
|
||||
bool SCH_SYMBOL::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const
|
||||
bool SCH_SYMBOL::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
|
||||
{
|
||||
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
|
||||
|
||||
|
@ -605,7 +605,7 @@ public:
|
||||
void MirrorVertically( int aCenter ) override;
|
||||
void Rotate( const VECTOR2I& aCenter ) override;
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
|
||||
|
||||
void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
|
||||
|
||||
|
@ -180,12 +180,12 @@ public:
|
||||
virtual void Rotate90( bool aClockwise );
|
||||
virtual void MirrorSpinStyle( bool aLeftRight );
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
||||
{
|
||||
return SCH_ITEM::Matches( GetText(), aSearchData );
|
||||
}
|
||||
|
||||
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
|
||||
{
|
||||
return EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ public:
|
||||
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
|
||||
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
|
||||
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
||||
{
|
||||
return SCH_ITEM::Matches( GetText(), aSearchData );
|
||||
}
|
||||
|
||||
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override
|
||||
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
|
||||
{
|
||||
return EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user