Commit 82879001 authored by Wayne Stambaugh's avatar Wayne Stambaugh

EESchema find dialog improvements.

* Add option to disable warping mouse to item found.
* Add code to warp mouse when dialog is closed.
parent 50f063da
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<property name="name">leftSizer</property> <property name="name">leftSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="1">
<property name="border">6</property> <property name="border">6</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
...@@ -921,6 +921,63 @@ ...@@ -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">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Do not warp cursor to found item</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_checkNoWarpCursor</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> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
......
...@@ -25,6 +25,7 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData, ...@@ -25,6 +25,7 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData,
m_radioBackward->SetValue( ( flags & wxFR_DOWN ) == 0 ); m_radioBackward->SetValue( ( flags & wxFR_DOWN ) == 0 );
m_checkMatchCase->SetValue( flags & wxFR_MATCHCASE ); m_checkMatchCase->SetValue( flags & wxFR_MATCHCASE );
m_checkWholeWord->SetValue( flags & wxFR_WHOLEWORD ); m_checkWholeWord->SetValue( flags & wxFR_WHOLEWORD );
m_checkNoWarpCursor->SetValue( flags & FR_NO_WARP_CURSOR );
/* Whole word and wild card searches are mutually exclusive. */ /* Whole word and wild card searches are mutually exclusive. */
if( !( flags & wxFR_WHOLEWORD ) ) if( !( flags & wxFR_WHOLEWORD ) )
...@@ -131,6 +132,9 @@ void DIALOG_SCH_FIND::SendEvent( const wxEventType& aEventType ) ...@@ -131,6 +132,9 @@ void DIALOG_SCH_FIND::SendEvent( const wxEventType& aEventType )
if( m_checkCurrentSheetOnly->GetValue() ) if( m_checkCurrentSheetOnly->GetValue() )
flags |= FR_CURRENT_SHEET_ONLY; flags |= FR_CURRENT_SHEET_ONLY;
if( m_checkNoWarpCursor->GetValue() )
flags |= FR_NO_WARP_CURSOR;
m_findReplaceData->SetFindString( event.GetFindString() ); m_findReplaceData->SetFindString( event.GetFindString() );
if( HasFlag( wxFR_REPLACEDIALOG ) if( HasFlag( wxFR_REPLACEDIALOG )
......
...@@ -38,7 +38,10 @@ enum SchematicFindReplaceFlags ...@@ -38,7 +38,10 @@ enum SchematicFindReplaceFlags
FR_MATCH_WILDCARD = wxFR_MATCHCASE << 4, FR_MATCH_WILDCARD = wxFR_MATCHCASE << 4,
/* Wrap around the beginning or end of search list. */ /* Wrap around the beginning or end of search list. */
FR_SEARCH_WRAP = wxFR_MATCHCASE << 5 FR_SEARCH_WRAP = wxFR_MATCHCASE << 5,
/* Don't warp cursor to found item until the dialog is closed. */
FR_NO_WARP_CURSOR = wxFR_MATCHCASE << 6
}; };
......
...@@ -89,6 +89,9 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con ...@@ -89,6 +89,9 @@ DIALOG_SCH_FIND_BASE::DIALOG_SCH_FIND_BASE( wxWindow* parent, wxWindowID id, con
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 on&ly"), 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 );
leftSizer->Add( m_checkNoWarpCursor, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 );
mainSizer->Add( leftSizer, 1, wxALL|wxEXPAND, 6 ); mainSizer->Add( leftSizer, 1, wxALL|wxEXPAND, 6 );
wxBoxSizer* rightSizer; wxBoxSizer* rightSizer;
......
...@@ -48,6 +48,7 @@ class DIALOG_SCH_FIND_BASE : public wxDialog ...@@ -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_checkNoWarpCursor;
wxButton* m_buttonFind; wxButton* m_buttonFind;
wxButton* m_buttonReplace; wxButton* m_buttonReplace;
wxButton* m_buttonReplaceAll; wxButton* m_buttonReplaceAll;
......
...@@ -42,12 +42,13 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) ...@@ -42,12 +42,13 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
SCH_SHEET_PATH* sheetFoundIn = NULL; SCH_SHEET_PATH* sheetFoundIn = NULL;
bool wrap = ( event.GetFlags() & FR_SEARCH_WRAP ) != 0; bool wrap = ( event.GetFlags() & FR_SEARCH_WRAP ) != 0;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() ); wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
bool warpCursor = ( ( event.GetId() == wxEVT_COMMAND_FIND_CLOSE ) ||
!( event.GetFlags() & FR_NO_WARP_CURSOR ) );
if( event.GetFlags() & FR_CURRENT_SHEET_ONLY ) if( event.GetFlags() & FR_CURRENT_SHEET_ONLY )
{ {
sheetFoundIn = m_CurrentSheet; sheetFoundIn = m_CurrentSheet;
lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T, lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T, lastMarker, wrap );
lastMarker, wrap );
} }
else else
{ {
...@@ -66,7 +67,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) ...@@ -66,7 +67,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos; sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos;
RedrawScreen( TRUE ); RedrawScreen( warpCursor );
wxString path = sheetFoundIn->Path(); wxString path = sheetFoundIn->Path();
wxString units = GetAbbreviatedUnitsLabel(); wxString units = GetAbbreviatedUnitsLabel();
...@@ -109,69 +110,71 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -109,69 +110,71 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
wxSize DrawAreaSize = DrawPanel->GetClientSize(); wxSize DrawAreaSize = DrawPanel->GetClientSize();
wxPoint pos, curpos; wxPoint pos, curpos;
bool DoCenterAndRedraw = FALSE; bool DoCenterAndRedraw = false;
bool NotFound = true; bool NotFound = true;
wxString msg; wxString msg;
LIB_PIN* pin; LIB_PIN* pin;
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
sheet = SheetList.GetFirst(); sheet = SheetList.GetFirst();
if( !Find_in_hierarchy ) if( !Find_in_hierarchy )
sheet = m_CurrentSheet; sheet = m_CurrentSheet;
for( ; sheet != NULL; sheet = SheetList.GetNext() ) for( ; sheet != NULL; sheet = SheetList.GetNext() )
{ {
DrawList = (SCH_ITEM*) sheet->LastDrawList(); DrawList = (SCH_ITEM*) sheet->LastDrawList();
for( ; ( DrawList != NULL ) && ( NotFound == true );
DrawList = DrawList->Next() ) for( ; ( DrawList != NULL ) && ( NotFound == true ); DrawList = DrawList->Next() )
{ {
if( DrawList->Type() == SCH_COMPONENT_T ) if( DrawList->Type() != SCH_COMPONENT_T )
continue;
SCH_COMPONENT* pSch = (SCH_COMPONENT*) DrawList;
if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 )
{ {
SCH_COMPONENT* pSch; Component = pSch;
pSch = (SCH_COMPONENT*) DrawList; SheetWithComponentFound = sheet;
if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 )
switch( SearchType )
{ {
Component = pSch; default:
SheetWithComponentFound = sheet; case 0: // Find component only
NotFound = false;
switch( SearchType ) pos = pSch->m_Pos;
{ break;
default:
case 0: // Find component only case 1: // find a pin
NotFound = FALSE; pos = pSch->m_Pos; /* temporary: will be changed if the pin is found */
pos = pSch->m_Pos; pin = pSch->GetPin( text_to_find );
if( pin == NULL )
break; break;
case 1: // find a pin NotFound = false;
pos = pSch->m_Pos; /* temporary: will be changed if pos += pin->GetPosition();
* the pin is found */ break;
pin = pSch->GetPin( text_to_find );
if( pin == NULL ) case 2: // find reference
break; NotFound = false;
pos = pSch->GetField( REFERENCE )->m_Pos;
break;
NotFound = FALSE; case 3: // find value
pos += pin->GetPosition(); pos = pSch->m_Pos;
break;
case 2: // find reference if( text_to_find.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 )
NotFound = FALSE;
pos = pSch->GetField( REFERENCE )->m_Pos;
break; break;
case 3: // find value NotFound = false;
pos = pSch->m_Pos; pos = pSch->GetField( VALUE )->m_Pos;
if( text_to_find.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 ) break;
break;
NotFound = FALSE;
pos = pSch->GetField( VALUE )->m_Pos;
break;
}
} }
} }
} }
if( (Find_in_hierarchy == FALSE) || (NotFound == FALSE) ) if( (Find_in_hierarchy == false) || (NotFound == false) )
break; break;
} }
...@@ -184,8 +187,9 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -184,8 +187,9 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheet; *m_CurrentSheet = *sheet;
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
DoCenterAndRedraw = TRUE; DoCenterAndRedraw = true;
} }
wxPoint delta; wxPoint delta;
pos -= Component->m_Pos; pos -= Component->m_Pos;
delta = Component->GetTransform().TransformCoordinate( pos ); delta = Component->GetTransform().TransformCoordinate( pos );
...@@ -196,9 +200,8 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -196,9 +200,8 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
curpos = DrawPanel->CursorScreenPosition(); curpos = DrawPanel->CursorScreenPosition();
DrawPanel->GetViewStart( DrawPanel->GetViewStart( &( GetScreen()->m_StartVisu.x ),
&( GetScreen()->m_StartVisu.x ), &( GetScreen()->m_StartVisu.y ) );
&( GetScreen()->m_StartVisu.y ) );
// Calculating cursor position with original screen. // Calculating cursor position with original screen.
curpos -= GetScreen()->m_StartVisu; curpos -= GetScreen()->m_StartVisu;
...@@ -299,18 +302,24 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) ...@@ -299,18 +302,24 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event )
* note: the actual matched item can be a * note: the actual matched item can be a
* part of lastItem (for instance a field in a component * part of lastItem (for instance a field in a component
*/ */
static wxPoint lastItemPosition; // the actual position of the matched sub item static wxPoint lastItemPosition; // the actual position of the matched sub item
SCH_SHEET_LIST schematic; SCH_SHEET_LIST schematic;
wxString msg; wxString msg;
SCH_SHEET_PATH* sheetFoundIn = NULL; SCH_SHEET_PATH* sheetFoundIn = NULL;
wxFindReplaceData searchCriteria; wxFindReplaceData searchCriteria;
bool warpCursor = !( event.GetFlags() & FR_NO_WARP_CURSOR );
searchCriteria.SetFlags( event.GetFlags() ); searchCriteria.SetFlags( event.GetFlags() );
searchCriteria.SetFindString( event.GetFindString() ); searchCriteria.SetFindString( event.GetFindString() );
searchCriteria.SetReplaceString( event.GetReplaceString() ); searchCriteria.SetReplaceString( event.GetReplaceString() );
if( event.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 ) if( event.GetEventType() == wxEVT_COMMAND_FIND_CLOSE )
{
sheetFoundIn = m_CurrentSheet;
warpCursor = true;
}
else if( event.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 )
{ {
sheetFoundIn = m_CurrentSheet; sheetFoundIn = m_CurrentSheet;
lastItem = m_CurrentSheet->MatchNextItem( searchCriteria, lastItem, &lastItemPosition ); lastItem = m_CurrentSheet->MatchNextItem( searchCriteria, lastItem, &lastItemPosition );
...@@ -330,9 +339,9 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) ...@@ -330,9 +339,9 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event )
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
} }
// sheetFoundIn->LastScreen()->m_Curseur = lastItem->GetBoundingBox().Centre();
sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition; sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition;
RedrawScreen( true );
RedrawScreen( warpCursor );
msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable(); msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable();
SetStatusText( msg ); SetStatusText( msg );
......
...@@ -609,6 +609,10 @@ void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& event ) ...@@ -609,6 +609,10 @@ void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event ) 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 ) if( m_dlgFindReplace )
{ {
m_findDialogPosition = m_dlgFindReplace->GetPosition(); m_findDialogPosition = m_dlgFindReplace->GetPosition();
...@@ -619,7 +623,7 @@ void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event ) ...@@ -619,7 +623,7 @@ void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
m_dlgFindReplace = NULL; m_dlgFindReplace = NULL;
} }
this->DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment