From da45f02f6ad93e7d9e1be26645df38e665612f5c Mon Sep 17 00:00:00 2001 From: Marco Mattila Date: Mon, 28 May 2012 23:01:51 +0300 Subject: [PATCH] Move pcbnew find dialog into dialogs subdirectory and use wxFormBuilder for it. --- include/wxBasePcbFrame.h | 5 +- include/wxPcbStruct.h | 2 +- pcbnew/CMakeLists.txt | 3 +- pcbnew/basepcbframe.cpp | 13 +- pcbnew/dialogs/dialog_find.cpp | 212 +++++++++ pcbnew/dialogs/dialog_find_base.cpp | 69 +++ pcbnew/dialogs/dialog_find_base.fbp | 681 ++++++++++++++++++++++++++++ pcbnew/dialogs/dialog_find_base.h | 58 +++ pcbnew/edit.cpp | 2 +- pcbnew/find.cpp | 380 ---------------- pcbnew/find.h | 126 ----- 11 files changed, 1035 insertions(+), 516 deletions(-) create mode 100644 pcbnew/dialogs/dialog_find.cpp create mode 100644 pcbnew/dialogs/dialog_find_base.cpp create mode 100644 pcbnew/dialogs/dialog_find_base.fbp create mode 100644 pcbnew/dialogs/dialog_find_base.h delete mode 100644 pcbnew/find.cpp delete mode 100644 pcbnew/find.h diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index b9e22ac5f4..e0c1596723 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -238,9 +238,10 @@ public: * Function CursorGoto * positions the cursor at a given coordinate and reframes the drawing if the * requested point is out of view. - * @param aPos The point to go to. + * @param aPos is the point to go to. + * @param aWarp is true if the pointer should be warped to the new position. */ - void CursorGoto( const wxPoint& aPos ); + void CursorGoto( const wxPoint& aPos, bool aWarp = true ); /** * Function Save_Module_In_Library diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index daf0211155..e550c18f6e 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -1488,7 +1488,7 @@ public: void Clean_Pcb( wxDC* DC ); - void InstallFindFrame( const wxPoint& pos, wxDC* DC ); + void InstallFindFrame(); /** * Function SendMessageToEESCHEMA diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 7a93d5f7ed..dbe64d2766 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -39,6 +39,8 @@ set(PCBNEW_DIALOGS dialogs/dialog_edit_module_text_base.cpp dialogs/dialog_exchange_modules_base.cpp dialogs/dialog_export_3Dfiles_base.cpp + dialogs/dialog_find_base.cpp + dialogs/dialog_find.cpp dialogs/dialog_freeroute_exchange.cpp dialogs/dialog_freeroute_exchange_base.cpp dialogs/dialog_gendrill.cpp @@ -123,7 +125,6 @@ set(PCBNEW_SRCS export_gencad.cpp export_vrml.cpp files.cpp - find.cpp gen_drill_report_files.cpp gen_holes_and_tools_lists_for_drill.cpp gen_modules_placefile.cpp diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 6cfbdb02bb..87eecffca8 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -266,28 +266,31 @@ double PCB_BASE_FRAME::BestZoom() } -void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos ) +void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp ) { // factored out of pcbnew/find.cpp PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); - wxClientDC dc( m_canvas ); + INSTALL_UNBUFFERED_DC( dc, m_canvas ); // There may be need to reframe the drawing. if( !m_canvas->IsPointOnDisplay( aPos ) ) { screen->SetCrossHairPosition( aPos ); - RedrawScreen( aPos, true ); + RedrawScreen( aPos, aWarp ); } else { // Put cursor on item position m_canvas->CrossHairOff( &dc ); screen->SetCrossHairPosition( aPos ); - m_canvas->MoveCursorToCrossHair(); - m_canvas->CrossHairOn( &dc ); + + if( aWarp ) + m_canvas->MoveCursorToCrossHair(); } + m_canvas->CrossHairOn( &dc ); + m_canvas->CrossHairOn( &dc ); } diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp new file mode 100644 index 0000000000..bfa29d3b42 --- /dev/null +++ b/pcbnew/dialogs/dialog_find.cpp @@ -0,0 +1,212 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2012 Marco Mattila + * Copyright (C) 1992-2012 Kicad Developers, see AUTHORS.txt for contributors. + * + * 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 + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + + +class DIALOG_FIND : public DIALOG_FIND_BASE +{ +public: + DIALOG_FIND( PCB_BASE_FRAME* aParent ); + +private: + PCB_BASE_FRAME* parent; + + int itemCount, markerCount; + static wxString prevSearchString; + static bool warpMouse; + + static wxPoint prevPosition; + static wxSize prevSize; + + void onButtonFindItemClick( wxCommandEvent& event ); + void onButtonFindMarkerClick( wxCommandEvent& event ); + void onButtonCloseClick( wxCommandEvent& event ); + void onClose( wxCloseEvent& event ); +}; + + +// Initialize static member variables +wxPoint DIALOG_FIND::prevPosition( -1, -1 ); +wxSize DIALOG_FIND::prevSize; +wxString DIALOG_FIND::prevSearchString; +bool DIALOG_FIND::warpMouse = true; + + +DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aParent ) : DIALOG_FIND_BASE( aParent ) +{ + parent = aParent; + SetFocus(); + GetSizer()->SetSizeHints( this ); + + m_SearchTextCtrl->AppendText( prevSearchString ); + m_NoMouseWarpCheckBox->SetValue( !warpMouse ); + + itemCount = markerCount = 0; + + if( prevPosition.x != -1 ) + SetSize( prevPosition.x, prevPosition.y, + prevSize.x, prevSize.y ); + else + Center(); +} + + +void DIALOG_FIND::onButtonCloseClick( wxCommandEvent& aEvent ) +{ + Close( true ); +} + + +void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent ) +{ + PCB_SCREEN* screen = (PCB_SCREEN*) ( parent->GetScreen() ); + wxPoint pos; + BOARD_ITEM* foundItem = 0; + + wxString searchString = m_SearchTextCtrl->GetValue(); + + if( !searchString.IsSameAs( prevSearchString, false ) ) + { + itemCount = 0; + } + prevSearchString = searchString; + + parent->GetCanvas()->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y ); + + int count = 0; + + for( MODULE* module = parent->GetBoard()->m_Modules; module; module = module->Next() ) + { + if( WildCompareString( searchString, module->GetReference().GetData(), false ) ) + { + count++; + + if( count > itemCount ) + { + foundItem = module; + pos = module->GetPosition(); + itemCount++; + break; + } + } + + if( WildCompareString( searchString, module->m_Value->m_Text.GetData(), false ) ) + { + count++; + + if( count > itemCount ) + { + foundItem = module; + pos = module->m_Pos; + itemCount++; + break; + } + } + } + + wxString msg; + if( foundItem ) + { + parent->SetCurItem( foundItem ); + msg.Printf( _( "<%s> found" ), GetChars( searchString ) ); + parent->SetStatusText( msg ); + + parent->CursorGoto( pos, !m_NoMouseWarpCheckBox->IsChecked() ); + } + else + { + parent->SetStatusText( wxEmptyString ); + msg.Printf( _( "<%s> not found" ), GetChars( searchString ) ); + DisplayError( this, msg, 10 ); + itemCount = 0; + } +} + + +void DIALOG_FIND::onButtonFindMarkerClick( wxCommandEvent& aEvent ) +{ + PCB_SCREEN* screen = (PCB_SCREEN*) ( parent->GetScreen() ); + wxPoint pos; + BOARD_ITEM* foundItem = 0; + + parent->GetCanvas()->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y ); + + MARKER_PCB* marker = parent->GetBoard()->GetMARKER( markerCount++ ); + + if( marker ) + { + foundItem = marker; + pos = marker->GetPosition(); + } + + wxString msg; + if( foundItem ) + { + parent->SetCurItem( foundItem ); + msg = _( "Marker found" ); + parent->SetStatusText( msg ); + + parent->CursorGoto( pos, !m_NoMouseWarpCheckBox->IsChecked() ); + } + else + { + parent->SetStatusText( wxEmptyString ); + msg = _( "No marker found" ); + DisplayError( this, msg, 10 ); + markerCount = 0; + } +} + + +void DIALOG_FIND::onClose( wxCloseEvent& aEvent ) +{ + prevPosition = GetPosition(); + prevSize = GetSize(); + warpMouse = !m_NoMouseWarpCheckBox->IsChecked(); + + EndModal( 1 ); +} + + +void PCB_EDIT_FRAME::InstallFindFrame() +{ + DIALOG_FIND dlg( this ); + dlg.ShowModal(); +} + diff --git a/pcbnew/dialogs/dialog_find_base.cpp b/pcbnew/dialogs/dialog_find_base.cpp new file mode 100644 index 0000000000..279770c043 --- /dev/null +++ b/pcbnew/dialogs/dialog_find_base.cpp @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Aug 24 2011) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_find_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxVERTICAL ); + + m_staticText1 = new wxStaticText( this, wxID_ANY, _("Search for:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + bSizer3->Add( m_staticText1, 0, wxALL, 5 ); + + m_SearchTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), 0 ); + bSizer3->Add( m_SearchTextCtrl, 0, wxALL|wxEXPAND, 5 ); + + m_NoMouseWarpCheckBox = new wxCheckBox( this, wxID_ANY, _("Do not warp mouse pointer"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_NoMouseWarpCheckBox, 0, wxALL, 5 ); + + bSizerMain->Add( bSizer3, 1, 0, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); + + m_button1 = new wxButton( this, wxID_ANY, _("Find Item"), wxDefaultPosition, wxDefaultSize, 0 ); + m_button1->SetDefault(); + bSizer4->Add( m_button1, 0, wxALL, 5 ); + + m_button2 = new wxButton( this, wxID_ANY, _("Find Marker"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_button2, 0, wxALL, 5 ); + + m_button3 = new wxButton( this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_button3, 0, wxALL, 5 ); + + bSizerMain->Add( bSizer4, 0, 0, 5 ); + + this->SetSizer( bSizerMain ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIND_BASE::onClose ) ); + m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onButtonFindItemClick ), NULL, this ); + m_button2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onButtonFindMarkerClick ), NULL, this ); + m_button3->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onButtonCloseClick ), NULL, this ); +} + +DIALOG_FIND_BASE::~DIALOG_FIND_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIND_BASE::onClose ) ); + m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onButtonFindItemClick ), NULL, this ); + m_button2->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onButtonFindMarkerClick ), NULL, this ); + m_button3->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onButtonCloseClick ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_find_base.fbp b/pcbnew/dialogs/dialog_find_base.fbp new file mode 100644 index 0000000000..7482db3338 --- /dev/null +++ b/pcbnew/dialogs/dialog_find_base.fbp @@ -0,0 +1,681 @@ + + + + + + C++ + 1 + source_name + 0 + res + UTF-8 + connect + dialog_find_base + 1000 + none + 1 + dialog_find + + . + + 1 + 1 + 0 + 0 + + 1 + 1 + 1 + 1 + 0 + + + + + 1 + wxBOTH + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + impl_virtual + + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + DIALOG_FIND_BASE + 1 + + + 1 + + + Resizable + + 1 + 350,150 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + Find + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + onClose + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxHORIZONTAL + none + + 5 + + 1 + + + bSizer3 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Search for: + + + 0 + + + 0 + + 1 + m_staticText1 + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + 0 + + 1 + m_SearchTextCtrl + 1 + + + protected + 1 + + + Resizable + + 1 + 200,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Do not warp mouse pointer + + + 0 + + + 0 + + 1 + m_NoMouseWarpCheckBox + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + + bSizer4 + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Find Item + + + 0 + + + 0 + + 1 + m_button1 + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onButtonFindItemClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Find Marker + + + 0 + + + 0 + + 1 + m_button2 + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onButtonFindMarkerClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Close + + + 0 + + + 0 + + 1 + m_button3 + 1 + + + protected + 1 + + + Resizable + + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onButtonCloseClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_find_base.h b/pcbnew/dialogs/dialog_find_base.h new file mode 100644 index 0000000000..3373ad0945 --- /dev/null +++ b/pcbnew/dialogs/dialog_find_base.h @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Aug 24 2011) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_FIND_BASE_H__ +#define __DIALOG_FIND_BASE_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_FIND_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_FIND_BASE : public wxDialog +{ + private: + + protected: + wxStaticText* m_staticText1; + wxTextCtrl* m_SearchTextCtrl; + wxCheckBox* m_NoMouseWarpCheckBox; + wxButton* m_button1; + wxButton* m_button2; + wxButton* m_button3; + + // Virtual event handlers, overide them in your derived class + virtual void onClose( wxCloseEvent& event ) { event.Skip(); } + virtual void onButtonFindItemClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onButtonFindMarkerClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onButtonCloseClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Find"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 350,150 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_FIND_BASE(); + +}; + +#endif //__DIALOG_FIND_BASE_H__ diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 99d86af6a1..d9127490a7 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -286,7 +286,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_FIND_ITEMS: - InstallFindFrame( pos, &dc ); + InstallFindFrame(); break; case ID_POPUP_CLOSE_CURRENT_TOOL: diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp deleted file mode 100644 index 0e75b9bfc3..0000000000 --- a/pcbnew/find.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/** - * @file pcbnew/find.cpp - * @brief Pcbnew find dialog box implementation. - */ - - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - - -static wxString s_OldStringFound; -static int s_ItemCount, s_MarkerCount; - - -void PCB_EDIT_FRAME::InstallFindFrame( const wxPoint& pos, wxDC* DC ) -{ - WinEDA_PcbFindFrame* frame = new WinEDA_PcbFindFrame( this, DC, pos ); - - frame->ShowModal(); - frame->Destroy(); -} - - -void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event ) -{ - PCB_SCREEN* screen = (PCB_SCREEN*) ( m_Parent->GetScreen() ); - wxPoint locate_pos; - wxString msg; - bool FindMarker = false; - BOARD_ITEM* foundItem = 0; - - switch( event.GetId() ) - { - case ID_FIND_ITEM: - s_ItemCount = 0; - break; - - case ID_FIND_MARKER: - s_MarkerCount = 0; - - // fall thru - - case ID_FIND_NEXT_MARKER: - FindMarker = true; - break; - } - - s_OldStringFound = m_NewText->GetValue(); - - m_Parent->GetCanvas()->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y ); - - if( FindMarker ) - { - MARKER_PCB* marker = m_Parent->GetBoard()->GetMARKER( s_MarkerCount++ ); - - if( marker ) - { - foundItem = marker; - locate_pos = marker->GetPosition(); - } - } - else - { - int StartCount = 0; - - for( MODULE* module = m_Parent->GetBoard()->m_Modules; module; module = module->Next() ) - { - if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), false ) ) - { - StartCount++; - - if( StartCount > s_ItemCount ) - { - foundItem = module; - locate_pos = module->GetPosition(); - s_ItemCount++; - break; - } - } - - if( WildCompareString( s_OldStringFound, module->m_Value->m_Text.GetData(), false ) ) - { - StartCount++; - - if( StartCount > s_ItemCount ) - { - foundItem = module; - locate_pos = module->m_Pos; - s_ItemCount++; - break; - } - } - } - } - - if( foundItem ) - { - m_Parent->SetCurItem( foundItem ); - - if( FindMarker ) - msg = _( "Marker found" ); - else - msg.Printf( _( "<%s> Found" ), GetChars( s_OldStringFound ) ); - - m_Parent->SetStatusText( msg ); - - m_Parent->CursorGoto( locate_pos ); - - EndModal( 1 ); - } - else - { - m_Parent->SetStatusText( wxEmptyString ); - - if( FindMarker ) - msg = _( "Marker not found" ); - else - msg.Printf( _( "<%s> Not Found" ), GetChars( s_OldStringFound ) ); - - DisplayError( this, msg, 10 ); - EndModal( 0 ); - } -} - - -/*! - * 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 - 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 ) - -////@end WinEDA_PcbFindFrame event table entries - -END_EVENT_TABLE() -/*! - * WinEDA_PcbFindFrame constructors - */ - -WinEDA_PcbFindFrame::WinEDA_PcbFindFrame() -{ -} - - -WinEDA_PcbFindFrame::WinEDA_PcbFindFrame( PCB_BASE_FRAME* parent, - wxDC* DC, - const wxPoint& pos, - wxWindowID id, - const wxString& caption, - const wxSize& size, - long style ) -{ - m_Parent = parent; - m_DC = DC; - - Create( parent, id, caption, pos, size, style ); - - m_NewText->SetFocus(); -} - - -/*! - * WinEDA_PcbFindFrame creator - */ - -bool WinEDA_PcbFindFrame::Create( wxWindow* parent, - wxWindowID id, - const wxString& caption, - const wxPoint& pos, - const wxSize& size, - long style ) -{ -////@begin WinEDA_PcbFindFrame member initialisation - m_NewText = NULL; - -////@end WinEDA_PcbFindFrame member initialisation - -////@begin WinEDA_PcbFindFrame creation - SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); - wxDialog::Create( parent, id, caption, pos, size, style ); - - CreateControls(); - - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } - - Centre(); - -////@end WinEDA_PcbFindFrame creation - return true; -} - - -/*! - * Control creation for WinEDA_PcbFindFrame - */ - -void WinEDA_PcbFindFrame::CreateControls() -{ -////@begin WinEDA_PcbFindFrame content construction - // Generated by DialogBlocks, 29/04/2009 15:15:49 (unregistered) - - WinEDA_PcbFindFrame* itemDialog1 = this; - - 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, 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 ); - itemButton7->SetDefault(); - 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 ); - -////@end WinEDA_PcbFindFrame content construction -} - - -/*! - * Should we show tooltips? - */ - -bool WinEDA_PcbFindFrame::ShowToolTips() -{ - return true; -} - - -/*! - * Get bitmap resources - */ - -wxBitmap WinEDA_PcbFindFrame::GetBitmapResource( const wxString& name ) -{ - // Bitmap retrieval -////@begin WinEDA_PcbFindFrame bitmap retrieval - wxUnusedVar( name ); - return wxNullBitmap; - -////@end WinEDA_PcbFindFrame bitmap retrieval -} - - -/*! - * Get icon resources - */ - -wxIcon WinEDA_PcbFindFrame::GetIconResource( const wxString& name ) -{ - // Icon retrieval -////@begin WinEDA_PcbFindFrame icon retrieval - wxUnusedVar( name ); - return wxNullIcon; - -////@end WinEDA_PcbFindFrame icon retrieval -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_ITEM - */ - -void WinEDA_PcbFindFrame::OnFindItemClick( wxCommandEvent& event ) -{ - FindItem( event ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_ITEM - */ - -void WinEDA_PcbFindFrame::OnFindNextItemClick( wxCommandEvent& event ) -{ - FindItem( event ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_MARKER - */ - -void WinEDA_PcbFindFrame::OnFindMarkerClick( wxCommandEvent& event ) -{ - FindItem( event ); -} - - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_MARKER - */ - -void WinEDA_PcbFindFrame::OnFindNextMarkerClick( wxCommandEvent& event ) -{ - FindItem( event ); -} diff --git a/pcbnew/find.h b/pcbnew/find.h deleted file mode 100644 index c48e8c770c..0000000000 --- a/pcbnew/find.h +++ /dev/null @@ -1,126 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: find.h -// Purpose: -// Author: jean-pierre Charras -// Modified by: -// Created: 04/03/2006 13:58:04 -// RCS-ID: -// Copyright: License GNU -// Licence: -///////////////////////////////////////////////////////////////////////////// - -// Generated by DialogBlocks (unregistered), 04/03/2006 13:58:04 - -#ifndef _FIND_H_ -#define _FIND_H_ - -/*! - * Includes - */ - -////@begin includes -////@end includes - -/*! - * Forward declarations - */ - -////@begin forward declarations -////@end forward declarations - -/*! - * Control identifiers - */ - -////@begin control identifiers -#define ID_DIALOG 10000 -#define ID_TEXTCTRL 10001 -#define ID_FIND_ITEM 10002 -#define ID_FIND_NEXT_ITEM 10003 -#define ID_FIND_MARKER 10004 -#define ID_FIND_NEXT_MARKER 10005 -#define SYMBOL_WINEDA_PCBFINDFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER -#define SYMBOL_WINEDA_PCBFINDFRAME_TITLE _("Find") -#define SYMBOL_WINEDA_PCBFINDFRAME_IDNAME ID_DIALOG -#define SYMBOL_WINEDA_PCBFINDFRAME_SIZE wxSize(400, 300) -#define SYMBOL_WINEDA_PCBFINDFRAME_POSITION wxDefaultPosition -////@end control identifiers - -/*! - * Compatibility - */ - -#ifndef wxCLOSE_BOX -#define wxCLOSE_BOX 0x1000 -#endif - -/*! - * WinEDA_PcbFindFrame class declaration - */ - -class WinEDA_PcbFindFrame: public wxDialog -{ - DECLARE_DYNAMIC_CLASS( WinEDA_PcbFindFrame ) - DECLARE_EVENT_TABLE() - -public: - /// Constructors - WinEDA_PcbFindFrame( ); - WinEDA_PcbFindFrame( PCB_BASE_FRAME* parent, - wxDC * DC, const wxPoint& pos = SYMBOL_WINEDA_PCBFINDFRAME_POSITION, - wxWindowID id = SYMBOL_WINEDA_PCBFINDFRAME_IDNAME, - const wxString& caption = SYMBOL_WINEDA_PCBFINDFRAME_TITLE, - const wxSize& size = SYMBOL_WINEDA_PCBFINDFRAME_SIZE, - long style = SYMBOL_WINEDA_PCBFINDFRAME_STYLE ); - - /// Creation - bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_PCBFINDFRAME_IDNAME, - const wxString& caption = SYMBOL_WINEDA_PCBFINDFRAME_TITLE, - const wxPoint& pos = SYMBOL_WINEDA_PCBFINDFRAME_POSITION, - const wxSize& size = SYMBOL_WINEDA_PCBFINDFRAME_SIZE, - long style = SYMBOL_WINEDA_PCBFINDFRAME_STYLE ); - - /// Creates the controls and sizers - void CreateControls(); - -////@begin WinEDA_PcbFindFrame event handler declarations - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_ITEM - void OnFindItemClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_ITEM - void OnFindNextItemClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_MARKER - void OnFindMarkerClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FIND_NEXT_MARKER - void OnFindNextMarkerClick( wxCommandEvent& event ); - -////@end WinEDA_PcbFindFrame event handler declarations - -////@begin WinEDA_PcbFindFrame member function declarations - - /// Retrieves bitmap resources - wxBitmap GetBitmapResource( const wxString& name ); - - /// Retrieves icon resources - wxIcon GetIconResource( const wxString& name ); -////@end WinEDA_PcbFindFrame member function declarations - - /// Should we show tooltips? - static bool ShowToolTips(); - - void FindItem(wxCommandEvent& event); - void FindMarker(wxCommandEvent& event); - -////@begin WinEDA_PcbFindFrame member variables - wxTextCtrl* m_NewText; -////@end WinEDA_PcbFindFrame member variables - - PCB_BASE_FRAME * m_Parent; - wxDC * m_DC; -}; - -#endif - // _FIND_H_