2009-11-14 22:15:22 +00:00
|
|
|
/********************************************/
|
|
|
|
/* PCBNEW - Find dialog box implementation. */
|
|
|
|
/********************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "kicad_string.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
#include "find.h"
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
static wxString s_OldStringFound;
|
2007-08-09 21:15:08 +00:00
|
|
|
static int s_ItemCount, s_MarkerCount;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallFindFrame( const wxPoint& pos, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos );
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
frame->ShowModal();
|
2007-08-10 19:14:51 +00:00
|
|
|
frame->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
PCB_SCREEN* screen = (PCB_SCREEN*) ( m_Parent->GetScreen() );
|
2007-08-09 21:15:08 +00:00
|
|
|
wxPoint locate_pos;
|
|
|
|
wxString msg;
|
|
|
|
bool FindMarker = FALSE;
|
2009-11-14 22:15:22 +00:00
|
|
|
BOARD_ITEM* foundItem = 0;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
switch( event.GetId() )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
case ID_FIND_ITEM:
|
|
|
|
s_ItemCount = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FIND_MARKER:
|
|
|
|
s_MarkerCount = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
|
|
|
// fall thru
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
case ID_FIND_NEXT_MARKER:
|
|
|
|
FindMarker = TRUE;
|
|
|
|
break;
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s_OldStringFound = m_NewText->GetValue();
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x,
|
|
|
|
&screen->m_StartVisu.y );
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
if( FindMarker )
|
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
MARKER_PCB* marker = m_Parent->GetBoard()->GetMARKER( s_MarkerCount++ );
|
2007-11-27 22:49:35 +00:00
|
|
|
if( marker )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
foundItem = marker;
|
2007-12-01 03:42:52 +00:00
|
|
|
locate_pos = marker->GetPosition();
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
else
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-11-27 22:49:35 +00:00
|
|
|
int StartCount = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
for( MODULE* module = m_Parent->GetBoard()->m_Modules;
|
|
|
|
module;
|
|
|
|
module = module->Next() )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( WildCompareString( s_OldStringFound,
|
|
|
|
module->GetReference().GetData(), FALSE ) )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
StartCount++;
|
|
|
|
if( StartCount > s_ItemCount )
|
|
|
|
{
|
2007-10-03 19:45:32 +00:00
|
|
|
foundItem = module;
|
2007-12-01 03:42:52 +00:00
|
|
|
locate_pos = module->GetPosition();
|
2007-08-09 21:15:08 +00:00
|
|
|
s_ItemCount++;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
if( WildCompareString( s_OldStringFound,
|
|
|
|
module->m_Value->m_Text.GetData(), FALSE ) )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
StartCount++;
|
|
|
|
if( StartCount > s_ItemCount )
|
|
|
|
{
|
2007-10-03 19:45:32 +00:00
|
|
|
foundItem = module;
|
|
|
|
locate_pos = module->m_Pos;
|
2007-08-09 21:15:08 +00:00
|
|
|
s_ItemCount++;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-10-03 19:45:32 +00:00
|
|
|
if( foundItem )
|
|
|
|
{
|
|
|
|
m_Parent->SetCurItem( foundItem );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2007-10-03 19:45:32 +00:00
|
|
|
if( FindMarker )
|
|
|
|
msg = _( "Marker found" );
|
|
|
|
else
|
2009-10-14 18:14:58 +00:00
|
|
|
msg.Printf( _( "<%s> Found" ), GetChars( s_OldStringFound ) );
|
2007-10-03 19:45:32 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
m_Parent->SetStatusText( msg );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2007-12-04 07:04:53 +00:00
|
|
|
m_Parent->CursorGoto( locate_pos );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
EndModal( 1 );
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
m_Parent->SetStatusText( wxEmptyString );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
if( FindMarker )
|
|
|
|
msg = _( "Marker not found" );
|
|
|
|
else
|
2009-10-14 18:14:58 +00:00
|
|
|
msg.Printf( _( "<%s> Not Found" ), GetChars( s_OldStringFound ) );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
DisplayError( this, msg, 10 );
|
|
|
|
EndModal( 0 );
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_PcbFindFrame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_PcbFindFrame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_PcbFindFrame event table entries
|
2009-05-01 18:06:03 +00:00
|
|
|
EVT_BUTTON( ID_FIND_ITEM, WinEDA_PcbFindFrame::OnFindItemClick )
|
|
|
|
EVT_BUTTON( ID_FIND_NEXT_ITEM, WinEDA_PcbFindFrame::OnFindNextItemClick )
|
|
|
|
EVT_BUTTON( ID_FIND_MARKER, WinEDA_PcbFindFrame::OnFindMarkerClick )
|
|
|
|
EVT_BUTTON( ID_FIND_NEXT_MARKER, WinEDA_PcbFindFrame::OnFindNextMarkerClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@end WinEDA_PcbFindFrame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame constructors
|
|
|
|
*/
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
WinEDA_PcbFindFrame::WinEDA_PcbFindFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( PCB_BASE_FRAME* parent,
|
|
|
|
wxDC* DC,
|
|
|
|
const wxPoint& pos,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-06-20 00:33:23 +00:00
|
|
|
m_Parent = parent;
|
2009-11-14 22:15:22 +00:00
|
|
|
m_DC = DC;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
Create( parent, id, caption, pos, size, style );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
m_NewText->SetFocus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_PcbFindFrame creator
|
|
|
|
*/
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
bool WinEDA_PcbFindFrame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
2007-08-09 21:15:08 +00:00
|
|
|
const wxString& caption,
|
2009-11-14 22:15:22 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
////@begin WinEDA_PcbFindFrame member initialisation
|
|
|
|
m_NewText = NULL;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_PcbFindFrame creation
|
2009-11-14 22:15:22 +00:00
|
|
|
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
|
2007-05-06 16:03:28 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2009-11-14 22:15:22 +00:00
|
|
|
if( GetSizer() )
|
2009-05-01 18:06:03 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2009-05-01 18:06:03 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
Centre();
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame creation
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_PcbFindFrame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::CreateControls()
|
2007-08-09 21:15:08 +00:00
|
|
|
{
|
2007-05-06 16:03:28 +00:00
|
|
|
////@begin WinEDA_PcbFindFrame content construction
|
2009-05-01 18:06:03 +00:00
|
|
|
// Generated by DialogBlocks, 29/04/2009 15:15:49 (unregistered)
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
WinEDA_PcbFindFrame* itemDialog1 = this;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
itemDialog1->SetSizer( itemBoxSizer2 );
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1,
|
|
|
|
wxID_STATIC,
|
|
|
|
_( "Item to find:" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemBoxSizer2->Add( itemStaticText3,
|
|
|
|
0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer2->Add( m_NewText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer5,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT |
|
|
|
|
wxBOTTOM,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer6 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer5->Add( itemBoxSizer6,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
wxButton* itemButton7 =
|
|
|
|
new wxButton( itemDialog1, ID_FIND_ITEM, _( "Find Item" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
itemButton7->SetDefault();
|
2009-11-14 22:15:22 +00:00
|
|
|
itemBoxSizer6->Add( itemButton7, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton8 =
|
|
|
|
new wxButton( itemDialog1, ID_FIND_NEXT_ITEM, _( "Find Next Item" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemBoxSizer6->Add( itemButton8,
|
|
|
|
0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer5->Add( itemBoxSizer9,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
wxButton* itemButton10 =
|
|
|
|
new wxButton( itemDialog1, ID_FIND_MARKER, _( "Find Marker" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( itemButton10, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton11 = new wxButton( itemDialog1,
|
|
|
|
ID_FIND_NEXT_MARKER,
|
|
|
|
_( "Find Next Marker" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemBoxSizer9->Add( itemButton11,
|
|
|
|
0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@end WinEDA_PcbFindFrame content construction
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_PcbFindFrame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_PcbFindFrame bitmap retrieval
|
2009-11-14 22:15:22 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullBitmap;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_PcbFindFrame icon retrieval
|
2009-11-14 22:15:22 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullIcon;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_PcbFindFrame icon retrieval
|
|
|
|
}
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_ITEM
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindItemClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_ITEM
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindNextItemClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_MARKER
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindMarkerClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_MARKER
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PcbFindFrame::OnFindNextMarkerClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-09 21:15:08 +00:00
|
|
|
FindItem( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|