2022-09-14 02:59:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2022-09-14 02:59:57 +00:00
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SEARCH_PANE_H
|
|
|
|
#define SEARCH_PANE_H
|
|
|
|
|
2024-11-02 01:30:45 +08:00
|
|
|
#include <memory>
|
2022-09-14 02:59:57 +00:00
|
|
|
#include <vector>
|
2024-11-02 01:30:45 +08:00
|
|
|
|
|
|
|
#include <widgets/search_pane_base.h>
|
2023-10-01 22:45:12 +01:00
|
|
|
#include <wx/listbase.h>
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2024-11-02 01:30:45 +08:00
|
|
|
|
2025-03-11 22:36:46 -04:00
|
|
|
class wxAuiManagerEvent;
|
2024-11-02 01:30:45 +08:00
|
|
|
class ACTION_MENU;
|
2022-09-14 02:59:57 +00:00
|
|
|
class EDA_DRAW_FRAME;
|
|
|
|
class SEARCH_PANE_TAB;
|
|
|
|
|
|
|
|
class SEARCH_HANDLER
|
|
|
|
{
|
|
|
|
public:
|
2023-08-09 18:30:58 +01:00
|
|
|
SEARCH_HANDLER( const wxString& aName ) :
|
|
|
|
m_name( aName )
|
|
|
|
{}
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2025-01-04 18:59:00 +00:00
|
|
|
virtual ~SEARCH_HANDLER()
|
|
|
|
{}
|
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
wxString GetName() const { return m_name; }
|
|
|
|
|
2023-10-01 22:45:12 +01:00
|
|
|
std::vector<std::tuple<wxString, int, wxListColumnFormat>> GetColumns() const
|
|
|
|
{
|
|
|
|
return m_columns;
|
|
|
|
}
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
virtual int Search( const wxString& string ) = 0;
|
|
|
|
virtual wxString GetResultCell( int row, int col ) = 0;
|
2024-05-11 16:20:09 +01:00
|
|
|
virtual void Sort( int aCol, bool aAscending, std::vector<long>* aSelection ) = 0;
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2022-09-20 23:58:49 -04:00
|
|
|
virtual void SelectItems( std::vector<long>& aItemRows ) {}
|
2023-01-25 11:09:23 -05:00
|
|
|
virtual void ActivateItem( long aItemRow ) {}
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
protected:
|
2023-10-01 22:45:12 +01:00
|
|
|
wxString m_name;
|
|
|
|
std::vector<std::tuple<wxString, int, wxListColumnFormat>> m_columns;
|
2022-09-14 02:59:57 +00:00
|
|
|
};
|
|
|
|
|
2024-11-02 01:30:45 +08:00
|
|
|
|
2022-09-14 02:59:57 +00:00
|
|
|
class SEARCH_PANE : public SEARCH_PANE_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SEARCH_PANE( EDA_DRAW_FRAME* aFrame );
|
|
|
|
virtual ~SEARCH_PANE();
|
|
|
|
|
2025-08-02 20:11:12 +01:00
|
|
|
// We own at least one list of raw pointers. Don't let the compiler fill in copy c'tors that
|
|
|
|
// will only land us in trouble.
|
|
|
|
SEARCH_PANE( const SEARCH_PANE& ) = delete;
|
|
|
|
SEARCH_PANE& operator=( const SEARCH_PANE& ) = delete;
|
|
|
|
|
2025-08-02 22:02:39 +01:00
|
|
|
void AddSearcher( const std::shared_ptr<SEARCH_HANDLER>& aHandler );
|
2022-09-14 02:59:57 +00:00
|
|
|
void OnSearchTextEntry( wxCommandEvent& aEvent ) override;
|
2022-09-20 23:38:06 -04:00
|
|
|
void OnNotebookPageChanged( wxBookCtrlEvent& aEvent ) override;
|
2022-09-14 02:59:57 +00:00
|
|
|
|
|
|
|
void RefreshSearch();
|
|
|
|
void FocusSearch();
|
2022-09-20 23:38:06 -04:00
|
|
|
void ClearAllResults();
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2025-07-24 13:13:42 -07:00
|
|
|
void OnCharHook( wxKeyEvent& aEvent );
|
|
|
|
|
2022-09-20 23:38:06 -04:00
|
|
|
protected:
|
2024-03-03 10:57:26 -05:00
|
|
|
void OnLanguageChange( wxCommandEvent& aEvent );
|
2022-09-20 23:38:06 -04:00
|
|
|
SEARCH_PANE_TAB* GetCurrentTab() const;
|
2025-03-11 22:36:46 -04:00
|
|
|
void OnClosed( wxAuiManagerEvent& aEvent );
|
2022-09-14 02:59:57 +00:00
|
|
|
|
2022-09-20 23:38:06 -04:00
|
|
|
private:
|
2025-08-02 22:02:39 +01:00
|
|
|
std::vector<std::shared_ptr<SEARCH_HANDLER>> m_handlers;
|
|
|
|
std::vector<SEARCH_PANE_TAB*> m_tabs;
|
|
|
|
wxString m_lastQuery;
|
|
|
|
EDA_DRAW_FRAME* m_frame;
|
|
|
|
ACTION_MENU* m_menu;
|
2022-09-14 02:59:57 +00:00
|
|
|
};
|
|
|
|
|
2023-01-25 11:09:23 -05:00
|
|
|
#endif
|