EESchema find dialog improvements.
* Add option to disable warping mouse to item found. * Add code to warp mouse when dialog is closed.
This commit is contained in:
parent
50f063da07
commit
828790017b
|
@ -93,7 +93,7 @@
|
|||
<property name="name">leftSizer</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">6</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
|
@ -921,6 +921,63 @@
|
|||
<event name="OnUpdateUI"></event>
|
||||
</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 class="sizeritem" expanded="1">
|
||||
|
|
|
@ -25,6 +25,7 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData,
|
|||
m_radioBackward->SetValue( ( flags & wxFR_DOWN ) == 0 );
|
||||
m_checkMatchCase->SetValue( flags & wxFR_MATCHCASE );
|
||||
m_checkWholeWord->SetValue( flags & wxFR_WHOLEWORD );
|
||||
m_checkNoWarpCursor->SetValue( flags & FR_NO_WARP_CURSOR );
|
||||
|
||||
/* Whole word and wild card searches are mutually exclusive. */
|
||||
if( !( flags & wxFR_WHOLEWORD ) )
|
||||
|
@ -131,6 +132,9 @@ void DIALOG_SCH_FIND::SendEvent( const wxEventType& aEventType )
|
|||
if( m_checkCurrentSheetOnly->GetValue() )
|
||||
flags |= FR_CURRENT_SHEET_ONLY;
|
||||
|
||||
if( m_checkNoWarpCursor->GetValue() )
|
||||
flags |= FR_NO_WARP_CURSOR;
|
||||
|
||||
m_findReplaceData->SetFindString( event.GetFindString() );
|
||||
|
||||
if( HasFlag( wxFR_REPLACEDIALOG )
|
||||
|
|
|
@ -38,7 +38,10 @@ enum SchematicFindReplaceFlags
|
|||
FR_MATCH_WILDCARD = wxFR_MATCHCASE << 4,
|
||||
|
||||
/* 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
|
|||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
wxBoxSizer* rightSizer;
|
||||
|
|
|
@ -48,6 +48,7 @@ class DIALOG_SCH_FIND_BASE : public wxDialog
|
|||
wxCheckBox* m_checkAllFields;
|
||||
wxCheckBox* m_checkAllPins;
|
||||
wxCheckBox* m_checkCurrentSheetOnly;
|
||||
wxCheckBox* m_checkNoWarpCursor;
|
||||
wxButton* m_buttonFind;
|
||||
wxButton* m_buttonReplace;
|
||||
wxButton* m_buttonReplaceAll;
|
||||
|
|
|
@ -42,12 +42,13 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
|
|||
SCH_SHEET_PATH* sheetFoundIn = NULL;
|
||||
bool wrap = ( event.GetFlags() & FR_SEARCH_WRAP ) != 0;
|
||||
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 )
|
||||
{
|
||||
sheetFoundIn = m_CurrentSheet;
|
||||
lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T,
|
||||
lastMarker, wrap );
|
||||
lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T, lastMarker, wrap );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,7 +67,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
|
|||
|
||||
sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos;
|
||||
|
||||
RedrawScreen( TRUE );
|
||||
RedrawScreen( warpCursor );
|
||||
|
||||
wxString path = sheetFoundIn->Path();
|
||||
wxString units = GetAbbreviatedUnitsLabel();
|
||||
|
@ -109,26 +110,28 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
|
|||
SCH_COMPONENT* Component = NULL;
|
||||
wxSize DrawAreaSize = DrawPanel->GetClientSize();
|
||||
wxPoint pos, curpos;
|
||||
bool DoCenterAndRedraw = FALSE;
|
||||
bool DoCenterAndRedraw = false;
|
||||
bool NotFound = true;
|
||||
wxString msg;
|
||||
LIB_PIN* pin;
|
||||
SCH_SHEET_LIST SheetList;
|
||||
|
||||
sheet = SheetList.GetFirst();
|
||||
|
||||
if( !Find_in_hierarchy )
|
||||
sheet = m_CurrentSheet;
|
||||
|
||||
for( ; sheet != NULL; sheet = SheetList.GetNext() )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
SCH_COMPONENT* pSch;
|
||||
pSch = (SCH_COMPONENT*) DrawList;
|
||||
if( DrawList->Type() != SCH_COMPONENT_T )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* pSch = (SCH_COMPONENT*) DrawList;
|
||||
|
||||
if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 )
|
||||
{
|
||||
Component = pSch;
|
||||
|
@ -138,40 +141,40 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
|
|||
{
|
||||
default:
|
||||
case 0: // Find component only
|
||||
NotFound = FALSE;
|
||||
NotFound = false;
|
||||
pos = pSch->m_Pos;
|
||||
break;
|
||||
|
||||
case 1: // find a pin
|
||||
pos = pSch->m_Pos; /* temporary: will be changed if
|
||||
* the pin is found */
|
||||
pos = pSch->m_Pos; /* temporary: will be changed if the pin is found */
|
||||
pin = pSch->GetPin( text_to_find );
|
||||
|
||||
if( pin == NULL )
|
||||
break;
|
||||
|
||||
NotFound = FALSE;
|
||||
NotFound = false;
|
||||
pos += pin->GetPosition();
|
||||
break;
|
||||
|
||||
case 2: // find reference
|
||||
NotFound = FALSE;
|
||||
NotFound = false;
|
||||
pos = pSch->GetField( REFERENCE )->m_Pos;
|
||||
break;
|
||||
|
||||
case 3: // find value
|
||||
pos = pSch->m_Pos;
|
||||
|
||||
if( text_to_find.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 )
|
||||
break;
|
||||
NotFound = FALSE;
|
||||
|
||||
NotFound = false;
|
||||
pos = pSch->GetField( VALUE )->m_Pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (Find_in_hierarchy == FALSE) || (NotFound == FALSE) )
|
||||
if( (Find_in_hierarchy == false) || (NotFound == false) )
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -184,8 +187,9 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
|
|||
sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
|
||||
*m_CurrentSheet = *sheet;
|
||||
m_CurrentSheet->UpdateAllScreenReferences();
|
||||
DoCenterAndRedraw = TRUE;
|
||||
DoCenterAndRedraw = true;
|
||||
}
|
||||
|
||||
wxPoint delta;
|
||||
pos -= Component->m_Pos;
|
||||
delta = Component->GetTransform().TransformCoordinate( pos );
|
||||
|
@ -196,8 +200,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
|
|||
|
||||
curpos = DrawPanel->CursorScreenPosition();
|
||||
|
||||
DrawPanel->GetViewStart(
|
||||
&( GetScreen()->m_StartVisu.x ),
|
||||
DrawPanel->GetViewStart( &( GetScreen()->m_StartVisu.x ),
|
||||
&( GetScreen()->m_StartVisu.y ) );
|
||||
|
||||
// Calculating cursor position with original screen.
|
||||
|
@ -305,12 +308,18 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event )
|
|||
wxString msg;
|
||||
SCH_SHEET_PATH* sheetFoundIn = NULL;
|
||||
wxFindReplaceData searchCriteria;
|
||||
bool warpCursor = !( event.GetFlags() & FR_NO_WARP_CURSOR );
|
||||
|
||||
searchCriteria.SetFlags( event.GetFlags() );
|
||||
searchCriteria.SetFindString( event.GetFindString() );
|
||||
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;
|
||||
lastItem = m_CurrentSheet->MatchNextItem( searchCriteria, lastItem, &lastItemPosition );
|
||||
|
@ -330,9 +339,9 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event )
|
|||
m_CurrentSheet->UpdateAllScreenReferences();
|
||||
}
|
||||
|
||||
// sheetFoundIn->LastScreen()->m_Curseur = lastItem->GetBoundingBox().Centre();
|
||||
sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition;
|
||||
RedrawScreen( true );
|
||||
|
||||
RedrawScreen( warpCursor );
|
||||
|
||||
msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable();
|
||||
SetStatusText( msg );
|
||||
|
|
|
@ -609,6 +609,10 @@ void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& 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 )
|
||||
{
|
||||
m_findDialogPosition = m_dlgFindReplace->GetPosition();
|
||||
|
@ -619,7 +623,7 @@ void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
|
|||
m_dlgFindReplace = NULL;
|
||||
}
|
||||
|
||||
this->DrawPanel->m_IgnoreMouseEvents = FALSE;
|
||||
DrawPanel->m_IgnoreMouseEvents = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue