Commit fd8bfe0c authored by Marco Mattila's avatar Marco Mattila

Move pcbnew find dialog into dialogs subdirectory and use wxFormBuilder for it.

parent 28bcad84
......@@ -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
......
......@@ -1488,7 +1488,7 @@ public:
void Clean_Pcb( wxDC* DC );
void InstallFindFrame( const wxPoint& pos, wxDC* DC );
void InstallFindFrame();
/**
* Function SendMessageToEESCHEMA
......
......@@ -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
......
......@@ -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 );
}
......
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2012 Marco Mattila <marcom99@gmail.com>
* 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 <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <kicad_string.h>
#include <wxPcbStruct.h>
#include <class_board.h>
#include <class_module.h>
#include <class_marker_pcb.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
#include <protos.h>
#include <dialog_find_base.h>
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();
}
///////////////////////////////////////////////////////////////////////////
// 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 );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// 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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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__
......@@ -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:
......
This diff is collapsed.
/////////////////////////////////////////////////////////////////////////////
// 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_
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