2014-02-14 08:05:04 +00:00
|
|
|
/* -*- c++ -*-
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
|
|
|
|
* Copyright (C) 2014 KiCad Developers, see change_log.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
|
|
|
|
*/
|
2014-02-18 21:41:27 +00:00
|
|
|
#ifndef DIALOG_CHOOSE_COMPONENT_H
|
|
|
|
#define DIALOG_CHOOSE_COMPONENT_H
|
2014-02-14 08:05:04 +00:00
|
|
|
|
|
|
|
#include <dialog_choose_component_base.h>
|
|
|
|
|
|
|
|
class COMPONENT_TREE_SEARCH_CONTAINER;
|
2014-02-24 10:52:08 +00:00
|
|
|
class LIB_ALIAS;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
class LIB_PART;
|
2014-02-14 08:05:04 +00:00
|
|
|
class wxTreeItemId;
|
2014-09-26 10:35:11 +00:00
|
|
|
class SCH_BASE_FRAME;
|
2014-02-14 08:05:04 +00:00
|
|
|
|
|
|
|
class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
|
|
|
|
{
|
2014-09-26 10:35:11 +00:00
|
|
|
SCH_BASE_FRAME* m_parent;
|
|
|
|
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
|
2014-11-19 14:22:47 +00:00
|
|
|
int m_deMorganConvert;
|
2014-09-26 10:35:11 +00:00
|
|
|
bool m_external_browser_requested;
|
|
|
|
bool m_received_doubleclick_in_tree;
|
|
|
|
|
2014-02-14 08:05:04 +00:00
|
|
|
public:
|
2014-02-24 10:52:08 +00:00
|
|
|
/**
|
|
|
|
* Create dialog to choose component.
|
|
|
|
*
|
2014-09-26 10:35:11 +00:00
|
|
|
* @param aParent a SCH_BASE_FRAME parent window.
|
2014-02-24 10:52:08 +00:00
|
|
|
* @param aTitle Dialog title.
|
|
|
|
* @param aSearchContainer The tree selection search container. Needs to be pre-populated
|
|
|
|
* This dialog does not take over ownership of this object.
|
|
|
|
* @param aDeMorganConvert preferred deMorgan conversion (TODO: should happen in dialog)
|
|
|
|
*/
|
2014-09-26 10:35:11 +00:00
|
|
|
DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
2014-11-19 14:22:47 +00:00
|
|
|
COMPONENT_TREE_SEARCH_CONTAINER* const aSearchContainer,
|
2014-02-18 21:41:27 +00:00
|
|
|
int aDeMorganConvert );
|
2014-02-24 10:52:08 +00:00
|
|
|
virtual ~DIALOG_CHOOSE_COMPONENT();
|
2014-02-14 08:05:04 +00:00
|
|
|
|
2014-02-24 10:52:08 +00:00
|
|
|
/** Function GetSelectedAlias
|
2014-02-14 08:05:04 +00:00
|
|
|
* To be called after this dialog returns from ShowModal().
|
|
|
|
*
|
2014-02-18 21:41:27 +00:00
|
|
|
* @param aUnit if not NULL, the selected unit is filled in here.
|
2014-02-24 10:52:08 +00:00
|
|
|
* @return the alias that has been selected, or NULL if there is none.
|
2014-02-14 08:05:04 +00:00
|
|
|
*/
|
2014-02-24 10:52:08 +00:00
|
|
|
LIB_ALIAS* GetSelectedAlias( int* aUnit ) const;
|
2014-02-14 08:05:04 +00:00
|
|
|
|
|
|
|
/** Function IsExternalBrowserSelected
|
|
|
|
*
|
2014-02-24 10:52:08 +00:00
|
|
|
* @return true, iff the user pressed the thumbnail view of the component to
|
|
|
|
* launch the component browser.
|
2014-02-14 08:05:04 +00:00
|
|
|
*/
|
|
|
|
bool IsExternalBrowserSelected() const { return m_external_browser_requested; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void OnSearchBoxChange( wxCommandEvent& aEvent );
|
|
|
|
virtual void OnSearchBoxEnter( wxCommandEvent& aEvent );
|
|
|
|
virtual void OnInterceptSearchBoxKey( wxKeyEvent& aEvent );
|
|
|
|
|
|
|
|
virtual void OnTreeSelect( wxTreeEvent& aEvent );
|
2014-02-24 01:27:07 +00:00
|
|
|
virtual void OnDoubleClickTreeActivation( wxTreeEvent& aEvent );
|
|
|
|
virtual void OnInterceptTreeEnter( wxKeyEvent& aEvent );
|
2014-02-14 08:05:04 +00:00
|
|
|
virtual void OnTreeMouseUp( wxMouseEvent& aMouseEvent );
|
|
|
|
|
|
|
|
virtual void OnStartComponentBrowser( wxMouseEvent& aEvent );
|
2014-02-18 21:41:27 +00:00
|
|
|
virtual void OnHandlePreviewRepaint( wxPaintEvent& aRepaintEvent );
|
2014-02-14 08:05:04 +00:00
|
|
|
|
|
|
|
private:
|
2014-02-18 21:41:27 +00:00
|
|
|
bool updateSelection();
|
|
|
|
void selectIfValid( const wxTreeItemId& aTreeId );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
void renderPreview( LIB_PART* aComponent, int aUnit );
|
2014-02-14 08:05:04 +00:00
|
|
|
};
|
2014-02-18 21:41:27 +00:00
|
|
|
|
|
|
|
#endif /* DIALOG_CHOOSE_COMPONENT_H */
|