Eeschema: symbol library viewer improvements.

Select the first library in the list and the first symbol in the first
library if they exist the first time the symbol viewer is opened.

Prevent clicking on the next or previous toolbar buttons from wrapping
past the end of the symbol list to mimic the behavior of the up and down
arrow key strokes.opens a select
library dialog.

Use incriminating or decrementing the current symbol selection when using
the next and previous symbol toolbar buttons rather looking up the next
symbol in the library.  Just use the next or previous symbol name in the
list.

Replace the select library and select symbol from library list dialogs
which where redundant with the symbol search dialog used in place symbol
tool in the schematic editor.  This gives the user type ahead search and
selects the library and symbol in one dialog.

Move updating toolbar buttons from the ReCreateHToolbar() function into
dedicated wxUpdateUIEvents.

Break Process_Special_Functions() into individual event handlers.

Remove PART_LIB::GetNextEntry() and PART_LIB::GetPreviousEntry() as they
are no longer required due to the changes to the symbol library viewer.

Purge wxT() macros from all modified source files.
This commit is contained in:
Wayne Stambaugh 2016-10-21 08:38:08 -04:00
parent a2f06a9dc4
commit 1e752ba164
8 changed files with 237 additions and 311 deletions

View File

@ -329,38 +329,6 @@ LIB_PART* PART_LIB::ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart )
}
LIB_ALIAS* PART_LIB::GetNextEntry( const wxString& aName )
{
if( m_amap.empty() )
return NULL;
LIB_ALIAS_MAP::iterator it = m_amap.find( aName );
it++;
if( it == m_amap.end() )
it = m_amap.begin();
return it->second;
}
LIB_ALIAS* PART_LIB::GetPreviousEntry( const wxString& aName )
{
if( m_amap.empty() )
return NULL;
LIB_ALIAS_MAP::iterator it = m_amap.find( aName );
if( it == m_amap.begin() )
it = m_amap.end();
it--;
return it->second;
}
bool PART_LIB::Load( wxString& aErrorMsg )
{
if( fileName.GetFullPath().IsEmpty() )

View File

@ -509,28 +509,6 @@ public:
*/
LIB_PART* ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart );
/**
* Find next library entry by \a aName.
*
* If the name of the entry is the last entry in the library, the first
* entry in the list is returned.
*
* @param aName - Name of current entry.
* @return Next entry if entry name is found. Otherwise NULL.
*/
LIB_ALIAS* GetNextEntry( const wxString& aName );
/**
* Find previous library entry by \a aName.
*
* If the name of the entry is the first entry in the library, the last
* entry in the list is returned.
*
* @param aName - Name of current entry.
* @return Previous entry if entry name is found, otherwise NULL.
*/
LIB_ALIAS* GetPreviousEntry( const wxString& aName );
/**
* Return the file name without path or extension.
*

View File

@ -236,10 +236,9 @@ enum id_eeschema_frm
ID_LIBEDIT_GEN_SVG_FILE,
/* Library viewer horizontal toolbar IDs */
ID_LIBVIEW_SELECT_PART,
ID_LIBVIEW_NEXT,
ID_LIBVIEW_PREVIOUS,
ID_LIBVIEW_SELECT_PART,
ID_LIBVIEW_SELECT_LIB,
ID_LIBVIEW_VIEWDOC,
ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT,
ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,

View File

@ -4,7 +4,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2015-2016 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

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2016 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
@ -44,8 +44,6 @@
void LIB_VIEW_FRAME::ReCreateHToolbar()
{
wxString msg;
LIB_ALIAS* entry = NULL;
bool asdeMorgan = false;
LIB_PART* part = NULL;
if( m_mainToolBar == NULL )
@ -53,11 +51,6 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
// Set up toolbar
m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_LIB, wxEmptyString,
KiBitmap( library_xpm ),
_( "Select library to browse" ) );
m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString,
KiBitmap( add_component_xpm ),
_( "Select component to browse" ) );
@ -134,30 +127,12 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
if( PART_LIB* lib = Prj().SchLibs()->FindLibrary( m_libraryName ) )
{
part = lib->FindPart( m_entryName );
if( part && part->HasConversion() )
asdeMorgan = true;
entry = lib->FindAlias( m_entryName );
}
}
// Must be AFTER Realize():
m_mainToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, asdeMorgan );
m_mainToolBar->EnableTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan );
if( asdeMorgan )
{
bool normal = m_convert <= 1;
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT,normal );
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, !normal );
}
else
{
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, true );
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, false );
}
/// @todo Move updating the symbol units in the combobox to the symbol select function
/// and stop calling this function to update the toolbar. All of the other toolbar
/// updates are handled by wxUpdateUIEvents.
int parts_count = 1;
if( part )
@ -174,8 +149,6 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
m_selpartBox->SetSelection( m_unit > 0 ? m_unit - 1 : 0 );
m_selpartBox->Enable( parts_count > 1 );
m_mainToolBar->EnableTool( ID_LIBVIEW_VIEWDOC, entry && !!entry->GetDocFileName() );
m_mainToolBar->Refresh();
}
@ -207,13 +180,6 @@ void LIB_VIEW_FRAME::ReCreateMenuBar( void )
// Menu File:
wxMenu* fileMenu = new wxMenu;
// Active library selection
AddMenuItem( fileMenu, ID_LIBVIEW_SELECT_LIB, _("Set Current Library"),
_( "Select library to be displayed" ),
KiBitmap( open_library_xpm ) );
fileMenu->AppendSeparator();
// Close viewer
AddMenuItem( fileMenu, wxID_EXIT,
_( "Cl&ose" ),
_( "Close schematic component viewer" ),

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -57,11 +57,14 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate )
// Toolbar events
EVT_TOOL_RANGE( ID_LIBVIEW_NEXT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
LIB_VIEW_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBVIEW_SELECT_PART, LIB_VIEW_FRAME::OnSelectSymbol )
EVT_TOOL( ID_LIBVIEW_NEXT, LIB_VIEW_FRAME::onSelectNextSymbol )
EVT_TOOL( ID_LIBVIEW_PREVIOUS, LIB_VIEW_FRAME::onSelectPreviousSymbol )
EVT_TOOL( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onViewSymbolDocument )
EVT_TOOL_RANGE( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
LIB_VIEW_FRAME::onSelectSymbolBodyStyle )
EVT_TOOL( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, LIB_VIEW_FRAME::ExportToSchematicLibraryPart )
EVT_COMBOBOX( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::Process_Special_Functions )
EVT_COMBOBOX( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onSelectSymbolUnit )
// listbox events
EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
@ -74,6 +77,9 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset )
EVT_UPDATE_UI( ID_LIBVIEW_VIEWDOC, onUpdateViewDoc )
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, onUpdateNormalBodyStyleButton )
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, onUpdateAlternateBodyStyleButton )
END_EVENT_TABLE()
@ -95,8 +101,8 @@ END_EVENT_TABLE()
#define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
#endif
#define LIB_VIEW_FRAME_NAME wxT( "ViewlibFrame" )
#define LIB_VIEW_FRAME_NAME_MODAL wxT( "ViewlibFrameModal" )
#define LIB_VIEW_FRAME_NAME "ViewlibFrame"
#define LIB_VIEW_FRAME_NAME_MODAL "ViewlibFrameModal"
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
PART_LIB* aLibrary ) :
@ -163,9 +169,8 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
}
// Creates the component window display
m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST,
wxPoint( 0, 0 ), wxSize(m_cmpListWidth, -1),
0, NULL, wxLB_HSCROLL );
m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxPoint( 0, 0 ),
wxSize( m_cmpListWidth, -1 ), 0, NULL, wxLB_HSCROLL );
if( m_libList )
ReCreateListLib();
@ -189,25 +194,21 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
// Manage main toolbal
m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) );
wxAuiPaneInfo( horiz ).Name( "m_mainToolBar" ).Top().Row( 0 ) );
// Manage the left window (list of libraries)
if( m_libList )
m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) ).
Left().Row( 0 ) );
m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( "m_libList" ).Left().Row( 0 ) );
// Manage the list of components)
m_auimgr.AddPane( m_cmpList,
wxAuiPaneInfo( info ).Name( wxT( "m_cmpList" ) ).
Left().Row( 1 ) );
m_auimgr.AddPane( m_cmpList, wxAuiPaneInfo( info ).Name( "m_cmpList" ).Left().Row( 1 ) );
// Manage the draw panel
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
// Manage the message panel
m_auimgr.AddPane( m_messagePanel,
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
wxAuiPaneInfo( mesg ).Name( "MsgPanel" ).Bottom().Layer( 10 ) );
/* Now the minimum windows are fixed, set library list
* and component list of the previous values from last viewlib use
@ -243,6 +244,68 @@ LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
}
LIB_ALIAS* LIB_VIEW_FRAME::getSelectedAlias()
{
LIB_ALIAS* alias = NULL;
if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() )
{
PART_LIB* lib = Prj().SchLibs()->FindLibrary( m_libraryName );
if( lib )
alias = lib->FindAlias( m_entryName );
}
return alias;
}
LIB_PART* LIB_VIEW_FRAME::getSelectedSymbol()
{
LIB_PART* symbol = NULL;
LIB_ALIAS* alias = getSelectedAlias();
if( alias )
symbol = alias->GetPart();
return symbol;
}
void LIB_VIEW_FRAME::onUpdateAlternateBodyStyleButton( wxUpdateUIEvent& aEvent )
{
LIB_PART* symbol = getSelectedSymbol();
aEvent.Enable( symbol && symbol->HasConversion() );
if( symbol )
aEvent.Check( m_convert > 1 );
else
aEvent.Check( false );
}
void LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent )
{
LIB_PART* symbol = getSelectedSymbol();
aEvent.Enable( symbol && symbol->HasConversion() );
if( symbol )
aEvent.Check( m_convert <= 1 );
else
aEvent.Check( true );
}
void LIB_VIEW_FRAME::onUpdateViewDoc( wxUpdateUIEvent& aEvent )
{
LIB_ALIAS* alias = getSelectedAlias();
aEvent.Enable( alias && !alias->GetDocFileName().IsEmpty() );
}
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
if( !IsModal() )
@ -357,6 +420,9 @@ void LIB_VIEW_FRAME::ReCreateListLib()
}
}
if( libs.IsEmpty() )
return;
m_libList->Append( libs );
// Search for a previous selection:
@ -370,7 +436,7 @@ void LIB_VIEW_FRAME::ReCreateListLib()
{
// If not found, clear current library selection because it can be
// deleted after a config change.
m_libraryName = wxEmptyString;
m_libraryName = libs[0];
m_entryName = wxEmptyString;
m_unit = 1;
m_convert = 1;
@ -392,7 +458,7 @@ void LIB_VIEW_FRAME::ReCreateListCmp()
PART_LIB* lib = Prj().SchLibs()->FindLibrary( m_libraryName );
if( !lib )
if( !lib || lib->IsEmpty() )
{
m_libraryName = wxEmptyString;
m_entryName = wxEmptyString;
@ -414,14 +480,18 @@ void LIB_VIEW_FRAME::ReCreateListCmp()
if( index == wxNOT_FOUND )
{
m_entryName = wxEmptyString;
// Select the first library entry when the previous entry name does not exist in
// the current library.
m_convert = 1;
m_unit = 1;
index = 0;
}
else
{
m_entryName = wxEmptyString;
m_cmpList->SetSelection( index, true );
}
wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST );
ProcessEvent( evt );
}
@ -467,6 +537,7 @@ void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event )
void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
{
// Aren't component names case sensitive now?
if( m_entryName.CmpNoCase( aComponentName ) != 0 )
{
m_entryName = aComponentName;
@ -527,13 +598,13 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
}
#define LIBLIST_WIDTH_KEY wxT( "ViewLiblistWidth" )
#define CMPLIST_WIDTH_KEY wxT( "ViewCmplistWidth" )
#define LIBLIST_WIDTH_KEY "ViewLiblistWidth"
#define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
// Currently, the library viewer has no dialog to change the background color
// of the draw canvas. Therefore the background color is here just
// in case of this option is added to some library viewer config dialog
#define LIBVIEW_BGCOLOR wxT( "LibviewBgColor" )
#define LIBVIEW_BGCOLOR "LibviewBgColor"
void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
@ -586,6 +657,7 @@ void LIB_VIEW_FRAME::CloseLibraryViewer( wxCommandEvent& event )
Close();
}
void LIB_VIEW_FRAME::SetFilter( const SCHLIB_FILTER* aFilter )
{
m_listPowerCmpOnly = false;

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2014 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2016 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
@ -39,6 +39,8 @@
class wxListBox;
class PART_LIB;
class SCHLIB_FILTER;
class LIB_ALIAS;
class LIB_PART;
/**
@ -72,7 +74,6 @@ public:
void ReCreateListLib();
void ReCreateListCmp();
void Process_Special_Functions( wxCommandEvent& event );
void DisplayLibInfos();
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
void OnCloseWindow( wxCloseEvent& Event );
@ -86,6 +87,7 @@ public:
void ClickOnLibList( wxCommandEvent& event );
void ClickOnCmpList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event );
void OnSelectSymbol( wxCommandEvent& aEvent );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
@ -100,7 +102,8 @@ public:
* case insensitive
* </p>
*/
bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL ) override;
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;
@ -145,18 +148,26 @@ private:
*/
virtual void OnActivate( wxActivateEvent& event ) override;
void SelectCurrentLibrary();
void SelectAndViewLibraryPart( int option );
/**
* Function ExportToSchematicLibraryPart
* exports the current component to schematic and close the library browser.
*/
void ExportToSchematicLibraryPart( wxCommandEvent& event );
void ViewOneLibraryContent( PART_LIB* Lib, int Flag );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
void DClickOnCmpList( wxCommandEvent& event );
void onUpdateAlternateBodyStyleButton( wxUpdateUIEvent& aEvent );
void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent );
void onUpdateViewDoc( wxUpdateUIEvent& aEvent );
void onSelectNextSymbol( wxCommandEvent& aEvent );
void onSelectPreviousSymbol( wxCommandEvent& aEvent );
void onViewSymbolDocument( wxCommandEvent& aEvent );
void onSelectSymbolBodyStyle( wxCommandEvent& aEvent );
void onSelectSymbolUnit( wxCommandEvent& aEvent );
LIB_ALIAS* getSelectedAlias();
LIB_PART* getSelectedSymbol();
// Private members:
wxComboBox* m_selpartBox;

View File

@ -40,39 +40,81 @@
#include <eeschema_id.h>
#include <class_library.h>
#include <dialog_helpers.h>
#include <dialog_choose_component.h>
#include <component_tree_search_container.h>
#define NEXT_PART 1
#define NEW_PART 0
#define PREVIOUS_PART -1
void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
{
wxString msg;
LIB_ALIAS* entry;
int ii, id = event.GetId();
wxString dialogTitle;
PART_LIBS* libs = Prj().SchLibs();
switch( id )
// Container doing search-as-you-type.
COMPONENT_TREE_SEARCH_CONTAINER search_container( libs );
for( PART_LIB& lib : *libs )
{
case ID_LIBVIEW_SELECT_LIB:
SelectCurrentLibrary();
break;
search_container.AddLibrary( lib );
}
case ID_LIBVIEW_SELECT_PART:
SelectAndViewLibraryPart( NEW_PART );
break;
dialogTitle.Printf( _( "Choose Component (%d items loaded)" ),
search_container.GetComponentsCount() );
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, &search_container, m_convert );
case ID_LIBVIEW_NEXT:
SelectAndViewLibraryPart( NEXT_PART );
break;
if( dlg.ShowModal() == wxID_CANCEL )
return;
case ID_LIBVIEW_PREVIOUS:
SelectAndViewLibraryPart( PREVIOUS_PART );
break;
/// @todo: The unit selection gets reset to 1 by SetSelectedComponent() so the unit
/// selection feature of the choose symbol dialog doesn't work.
LIB_ALIAS* const alias = dlg.GetSelectedAlias( &m_unit );
case ID_LIBVIEW_VIEWDOC:
entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
if( !alias || !alias->GetLib() )
return;
if( m_libraryName == alias->GetLib()->GetName() )
{
if( m_entryName != alias->GetName() )
SetSelectedComponent( alias->GetName() );
}
else
{
m_entryName = alias->GetName();
SetSelectedLibrary( alias->GetLib()->GetName() );
}
}
void LIB_VIEW_FRAME::onSelectNextSymbol( wxCommandEvent& aEvent )
{
wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST );
int ii = m_cmpList->GetSelection();
// Select the next symbol or stop at the end of the list.
if( ii != wxNOT_FOUND || ii != (int)m_cmpList->GetCount() - 1 )
ii += 1;
m_cmpList->SetSelection( ii );
ProcessEvent( evt );
}
void LIB_VIEW_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent )
{
wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST );
int ii = m_cmpList->GetSelection();
// Select the previous symbol or stop at the beginning of list.
if( ii != wxNOT_FOUND && ii != 0 )
ii -= 1;
m_cmpList->SetSelection( ii );
ProcessEvent( evt );
}
void LIB_VIEW_FRAME::onViewSymbolDocument( wxCommandEvent& aEvent )
{
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
if( entry && !entry->GetDocFileName().IsEmpty() )
{
@ -80,35 +122,38 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetAssociatedDocument( this, entry->GetDocFileName(), lib_search );
}
break;
}
void LIB_VIEW_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
switch( id )
{
default:
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, true );
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, false );
m_convert = 1;
m_canvas->Refresh();
break;
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, false );
m_mainToolBar->ToggleTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, true );
m_convert = 2;
m_canvas->Refresh();
break;
case ID_LIBVIEW_SELECT_PART_NUMBER:
ii = m_selpartBox->GetCurrentSelection();
if( ii < 0 )
return;
m_unit = ii + 1;
m_canvas->Refresh();
break;
default:
msg << wxT( "LIB_VIEW_FRAME::Process_Special_Functions error: id = " ) << id;
DisplayError( this, msg );
break;
}
m_canvas->Refresh();
}
void LIB_VIEW_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent )
{
int ii = m_selpartBox->GetCurrentSelection();
if( ii < 0 )
return;
m_unit = ii + 1;
m_canvas->Refresh();
}
@ -131,126 +176,13 @@ void LIB_VIEW_FRAME::DisplayLibInfos()
{
PART_LIB* lib = libs->FindLibrary( m_libraryName );
wxString title = wxString::Format( L"Library Browser \u2014 %s",
wxString title = wxString::Format( "Library Browser \u2014 %s",
lib ? lib->GetFullFileName() : "no library selected" );
SetTitle( title );
}
}
void LIB_VIEW_FRAME::SelectCurrentLibrary()
{
PART_LIB* Lib;
Lib = SelectLibraryFromList();
if( Lib )
{
m_entryName.Empty();
m_libraryName = Lib->GetName();
DisplayLibInfos();
if( m_libList )
{
ReCreateListCmp();
m_canvas->Refresh();
DisplayLibInfos();
ReCreateHToolbar();
int id = m_libList->FindString( m_libraryName.GetData() );
if( id >= 0 )
m_libList->SetSelection( id );
}
}
}
void LIB_VIEW_FRAME::SelectAndViewLibraryPart( int option )
{
if( m_libraryName.IsEmpty() )
SelectCurrentLibrary();
if( m_libraryName.IsEmpty() )
return;
if( PART_LIBS* libs = Prj().SchLibs() )
{
if( PART_LIB* lib = libs->FindLibrary( m_libraryName ) )
{
if( m_entryName.IsEmpty() || option == NEW_PART )
{
ViewOneLibraryContent( lib, NEW_PART );
return;
}
if( lib->FindAlias( m_entryName ) )
{
if( option == NEXT_PART )
ViewOneLibraryContent( lib, NEXT_PART );
if( option == PREVIOUS_PART )
ViewOneLibraryContent( lib, PREVIOUS_PART );
}
}
}
}
void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag )
{
int NumOfParts = 0;
if( Lib )
NumOfParts = Lib->GetCount();
if( NumOfParts == 0 )
{
DisplayError( this, wxT( "No library or library is empty!" ) );
return;
}
LIB_ALIAS* entry;
wxString CmpName;
if( Flag == NEW_PART )
DisplayListComponentsInLib( Lib, CmpName, m_entryName );
if( Flag == NEXT_PART )
{
entry = Lib->GetNextEntry( m_entryName );
if( entry )
CmpName = entry->GetName();
}
if( Flag == PREVIOUS_PART )
{
entry = Lib->GetPreviousEntry( m_entryName );
if( entry )
CmpName = entry->GetName();
}
m_unit = 1;
m_convert = 1;
entry = Lib->FindAlias( CmpName );
m_entryName = CmpName;
DisplayLibInfos();
Zoom_Automatique( false );
m_canvas->Refresh( );
if( m_cmpList )
{
int id = m_cmpList->FindString( m_entryName.GetData() );
if( id >= 0 )
m_cmpList->SetSelection( id );
}
ReCreateHToolbar();
}
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );