2019-10-24 17:07:01 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-06-02 21:56:17 +00:00
|
|
|
* Copyright (C) 2022 Mike Williams <mike at mikebwilliams.com>
|
|
|
|
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-10-24 17:07:01 +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 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2022-12-12 11:46:20 +00:00
|
|
|
#ifndef HIERARCHY_PANE_H
|
|
|
|
#define HIERARCHY_PANE_H
|
2019-10-24 17:07:01 +00:00
|
|
|
|
|
|
|
#include <wx/imaglist.h>
|
2020-11-29 00:10:17 +00:00
|
|
|
#include <wx/object.h> // wxRTTI macros
|
2019-10-24 17:07:01 +00:00
|
|
|
#include <wx/treectrl.h>
|
2022-12-12 11:46:20 +00:00
|
|
|
#include "widgets/wx_panel.h"
|
2019-10-24 17:07:01 +00:00
|
|
|
|
2020-01-08 14:01:22 +00:00
|
|
|
|
2019-10-24 17:07:01 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
class SCH_SHEET_PATH;
|
|
|
|
|
2022-12-12 11:46:20 +00:00
|
|
|
class HIERARCHY_PANE;
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2019-10-24 17:07:01 +00:00
|
|
|
|
|
|
|
/**
|
2022-06-02 21:56:17 +00:00
|
|
|
* Navigation hierarchy tree control.
|
|
|
|
*
|
|
|
|
* wxTreeCtrl must be subclassed to implement the OnCompareItems method
|
|
|
|
* to sort according to page numbers.
|
2019-10-24 17:07:01 +00:00
|
|
|
*/
|
|
|
|
class HIERARCHY_TREE : public wxTreeCtrl
|
|
|
|
{
|
|
|
|
public:
|
2022-12-12 11:46:20 +00:00
|
|
|
HIERARCHY_TREE( HIERARCHY_PANE* parent ) :
|
2022-06-02 21:56:17 +00:00
|
|
|
wxTreeCtrl( (wxWindow*) parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxTR_HAS_BUTTONS, wxDefaultValidator, wxT( "HierachyTreeCtrl" ) )
|
|
|
|
{
|
|
|
|
}
|
2020-09-21 18:16:32 +00:00
|
|
|
|
|
|
|
int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 ) override;
|
2021-03-25 14:07:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Need to use wxRTTI macros in order for OnCompareItems to work properly
|
|
|
|
// See: https://docs.wxwidgets.org/3.1/classwx_tree_ctrl.html#ab90a465793c291ca7aa827a576b7d146
|
|
|
|
wxDECLARE_ABSTRACT_CLASS( HIERARCHY_TREE );
|
2019-10-24 17:07:01 +00:00
|
|
|
};
|
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
|
2022-12-12 11:46:20 +00:00
|
|
|
class HIERARCHY_PANE : public WX_PANEL
|
2019-10-24 17:07:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-12-12 11:46:20 +00:00
|
|
|
HIERARCHY_PANE( SCH_EDIT_FRAME* aParent );
|
2019-10-24 17:07:01 +00:00
|
|
|
|
2022-12-12 11:46:20 +00:00
|
|
|
~HIERARCHY_PANE();
|
2020-01-08 14:01:22 +00:00
|
|
|
|
2019-10-24 17:07:01 +00:00
|
|
|
/**
|
|
|
|
* Update the hierarchical tree of the schematic.
|
|
|
|
*/
|
|
|
|
void UpdateHierarchyTree();
|
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
/**
|
|
|
|
* Updates the tree's selection to match current page
|
|
|
|
*/
|
|
|
|
void UpdateHierarchySelection();
|
|
|
|
|
2019-10-24 17:07:01 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Create the hierarchical tree of the schematic.
|
|
|
|
*
|
2021-03-25 14:07:16 +00:00
|
|
|
* @warning This routine is reentrant!
|
|
|
|
*
|
|
|
|
* @param[in] aList is the #SCH_SHEET_PATH list to explore.
|
|
|
|
* @param aPreviousmenu is the wxTreeItemId used as parent to add sub items.
|
2019-10-24 17:07:01 +00:00
|
|
|
*/
|
2022-06-02 21:56:17 +00:00
|
|
|
void buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItemId& aParent );
|
2019-10-24 17:07:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the selected sheet and display the corresponding screen when a tree item is
|
|
|
|
* selected.
|
|
|
|
*/
|
2022-09-26 20:57:32 +00:00
|
|
|
void onSelectSheetPath( wxTreeEvent& aEvent );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a right-click in the tree.
|
|
|
|
*/
|
|
|
|
void onRightClick( wxTreeEvent& aEvent );
|
2020-11-29 00:10:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String with page number in parenthesis
|
|
|
|
*/
|
|
|
|
wxString getRootString();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String with page number in parenthesis
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
wxString formatPageString( const wxString& aName, const wxString& aPage );
|
2021-03-25 14:07:16 +00:00
|
|
|
|
2022-09-26 20:31:26 +00:00
|
|
|
private:
|
2021-03-25 14:07:16 +00:00
|
|
|
SCH_SHEET_PATH m_list;
|
2022-06-02 21:56:17 +00:00
|
|
|
SCH_EDIT_FRAME* m_frame;
|
|
|
|
HIERARCHY_TREE* m_tree;
|
2022-07-09 22:30:52 +00:00
|
|
|
|
2022-09-26 20:31:26 +00:00
|
|
|
bool m_events_bound;
|
2019-10-24 17:07:01 +00:00
|
|
|
};
|
|
|
|
|
2022-12-12 11:46:20 +00:00
|
|
|
#endif // HIERARCHY_PANE_H
|