diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 045bc1e8d0..cf3b2cced4 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -359,6 +359,7 @@ set( BMAPS_MID module_full_list module_options module_pin_filtered_list + module_library_list module_ratsnest module modview_icon diff --git a/bitmaps_png/cpp_26/module_library_list.cpp b/bitmaps_png/cpp_26/module_library_list.cpp new file mode 100644 index 0000000000..b4e6d3613c --- /dev/null +++ b/bitmaps_png/cpp_26/module_library_list.cpp @@ -0,0 +1,83 @@ + +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include + +static const unsigned char png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c, + 0xce, 0x00, 0x00, 0x00, 0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64, + 0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0d, 0xd7, 0x00, 0x00, 0x0d, + 0xd7, 0x01, 0x42, 0x28, 0x9b, 0x78, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, + 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, + 0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00, 0x00, 0x03, 0xd2, 0x49, + 0x44, 0x41, 0x54, 0x48, 0x89, 0xbd, 0x96, 0x5d, 0x48, 0x5b, 0x67, 0x18, 0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, 0xf1, 0xd4, 0x1d, 0x44, 0x8b, 0x8b, + 0x8b, 0x14, 0x14, 0x14, 0x60, 0xc2, 0x44, 0x39, 0xfa, 0xff, 0x60, 0x73, 0x73, 0x93, 0xc0, 0x52, + 0x80, 0x85, 0x85, 0x05, 0xfd, 0x9a, 0x70, 0xd8, 0xcf, 0xad, 0xfa, 0xfa, 0x7a, 0x1f, 0x70, 0x66, + 0x1f, 0xa9, 0xf7, 0x26, 0x26, 0x26, 0xec, 0x87, 0x36, 0x3a, 0xa8, 0xc4, 0x37, 0xe2, 0x02, 0xfc, + 0x0f, 0xfd, 0x66, 0x6b, 0x49, 0xc9, 0xd5, 0xed, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, + 0x44, 0xae, 0x42, 0x60, 0x82 +}; + +const BITMAP_OPAQUE module_library_list_xpm[1] = {{ png, sizeof( png ), "module_library_list_xpm" }}; + +//EOF diff --git a/bitmaps_png/sources/module_library_list.svg b/bitmaps_png/sources/module_library_list.svg new file mode 100644 index 0000000000..67f9812f0a --- /dev/null +++ b/bitmaps_png/sources/module_library_list.svg @@ -0,0 +1,172 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 58ff1b34f5..4cb273bf1f 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -34,6 +34,7 @@ set(CVPCB_SRCS class_components_listbox.cpp class_DisplayFootprintsFrame.cpp class_footprints_listbox.cpp + class_library_listbox.cpp cvframe.cpp cvpcb.cpp listboxes.cpp diff --git a/cvpcb/cfg.cpp b/cvpcb/cfg.cpp index dfc107a733..f6648a3b67 100644 --- a/cvpcb/cfg.cpp +++ b/cvpcb/cfg.cpp @@ -8,9 +8,10 @@ #include #include #include +#include + #include #include -#include #define GROUP wxT("/cvpcb") diff --git a/cvpcb/class_components_listbox.cpp b/cvpcb/class_components_listbox.cpp index 7f9b9a6e21..5f5db62d0a 100644 --- a/cvpcb/class_components_listbox.cpp +++ b/cvpcb/class_components_listbox.cpp @@ -113,13 +113,16 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event ) { case WXK_HOME: case WXK_END: - case WXK_UP: + case WXK_UP: case WXK_DOWN: case WXK_PAGEUP: case WXK_PAGEDOWN: + event.Skip(); + return; + case WXK_LEFT: case WXK_NUMPAD_LEFT: - event.Skip(); + GetParent()->m_LibraryList->SetFocus(); return; case WXK_RIGHT: diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 38421a34f7..9ec56b0075 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -233,7 +235,49 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredByPinCount( COMPONENT* aCompon Refresh(); } +void FOOTPRINTS_LISTBOX::SetFootprintFilteredByLibraryList( FOOTPRINT_LIST& list, + wxString SelectedLibrary ) { + wxString msg; + int oldSelection = GetSelection(); + bool hasItem = false; + wxFileName filename = SelectedLibrary; + filename.SetExt( LegacyFootprintLibPathExtension ); + wxString FullLibraryName = wxGetApp().FindLibraryPath( filename ); + + m_FilteredFootprintList.Clear(); + + for( unsigned ii = 0; ii < list.GetCount(); ii++ ) + { + FOOTPRINT_INFO& footprint = list.GetItem(ii); + wxString LibName = footprint.m_libPath; + if( LibName.Matches( FullLibraryName ) ) + { + msg.Printf( wxT( "%3d %s" ), m_FilteredFootprintList.GetCount() + 1, + footprint.m_Module.GetData() ); + m_FilteredFootprintList.Add( msg ); + hasItem = true; + } + } + + if( hasItem ) + SetActiveFootprintList( false ); + else + SetActiveFootprintList( true ); + + if( ( GetCount() == 0 ) || ( oldSelection >= GetCount() ) ) + SetSelection( 0, true ); + + Refresh(); +} + +/** Set the footprint list. We can have 2 footprint list: + * The full footprint list + * The filtered footprint list (if the current selected component has a + * filter for footprints) + * @param FullList true = full footprint list, false = filtered footprint list + * @param Redraw = true to redraw the window + */ void FOOTPRINTS_LISTBOX::SetActiveFootprintList( bool FullList, bool Redraw ) { bool old_selection = m_UseFootprintFullList; diff --git a/cvpcb/class_library_listbox.cpp b/cvpcb/class_library_listbox.cpp new file mode 100644 index 0000000000..bab3f69da9 --- /dev/null +++ b/cvpcb/class_library_listbox.cpp @@ -0,0 +1,227 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * 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 + */ + +/** + * @file class_library_listbox.cpp + * class to display used library and selecting it + */ + +#include +#include +#include + +#include +#include +#include + + +/***************************************/ +/* ListBox handling the library list */ +/***************************************/ + +LIBRARY_LISTBOX::LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, + wxWindowID id, const wxPoint& loc, + const wxSize& size, + int nbitems, wxString choice[] ) : + ITEMS_LISTBOX_BASE( parent, id, loc, size ) +{ + //ListLibraries(); +} + + +LIBRARY_LISTBOX::~LIBRARY_LISTBOX() +{ +} + + +/* + * Return number of items + */ +int LIBRARY_LISTBOX::GetCount() +{ + return m_LibraryList.Count(); +} + + +/* + * Change an item text + */ +void LIBRARY_LISTBOX::SetString( unsigned linecount, const wxString& text ) +{ + if( linecount >= m_LibraryList.Count() ) + linecount = m_LibraryList.Count() - 1; + if( linecount >= 0 ) + m_LibraryList[linecount] = text; +} + + +wxString LIBRARY_LISTBOX::GetSelectedLibrary() +{ + wxString libraryName; + int ii = GetFirstSelected(); + + if( ii >= 0 ) + { + libraryName = m_LibraryList[ii]; + } + + return libraryName; +} + + +void LIBRARY_LISTBOX::AppendLine( const wxString& text ) +{ + m_LibraryList.Add( text ); + SetItemCount( m_LibraryList.Count() ); +} + + +/* + * Overlaid function: MUST be provided in wxLC_VIRTUAL mode + * because real data is not handled by ITEMS_LISTBOX_BASE + */ +wxString LIBRARY_LISTBOX::OnGetItemText( long item, long column ) const +{ + return m_LibraryList.Item( item ); +} + +/* + * Enable or disable an item + */ +void LIBRARY_LISTBOX::SetSelection( unsigned index, bool State ) +{ + if( (int) index >= GetCount() ) + index = GetCount() - 1; + + if( (index >= 0) && (GetCount() > 0) ) + { +#ifndef __WXMAC__ + Select( index, State ); +#endif + EnsureVisible( index ); +#ifdef __WXMAC__ + Refresh(); +#endif + } +} + + +void LIBRARY_LISTBOX::SetLibraryList( wxArrayString list ) +{ + wxString msg; + int oldSelection = GetSelection(); + + m_LibraryList.Clear(); + + for( unsigned ii = 0; ii < list.GetCount(); ii++ ) + { + msg = list.Item(ii); + m_LibraryList.Add( msg ); + } + + SetItemCount(list.GetCount()); + + if( GetCount() == 0 || oldSelection < 0 || oldSelection >= GetCount() ) + SetSelection( 0, true ); + Refresh(); +} + + +/**************************************/ +/* Event table for the library list */ +/**************************************/ + +BEGIN_EVENT_TABLE( LIBRARY_LISTBOX, ITEMS_LISTBOX_BASE ) + EVT_SIZE( ITEMS_LISTBOX_BASE::OnSize ) + EVT_CHAR( LIBRARY_LISTBOX::OnChar ) +END_EVENT_TABLE() + + +/** + * Function OnChar + * called on a key pressed + * Call default handler for some special keys, + * and for "ascii" keys, select the first footprint + * that the name starts by the letter. + * This is the defaut behaviour of a listbox, but because we use + * virtual lists, the listbox does not know anything to what is displayed, + * we must handle this behaviour here. + * Furthermore the footprint name is not at the beginning of + * displayed lines (the first word is the line number) + */ +void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) +{ + int key = event.GetKeyCode(); + switch( key ) + { + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + GetParent()->m_ListCmp->SetFocus(); + return; + + case WXK_HOME: + case WXK_END: + case WXK_UP: + case WXK_DOWN: + case WXK_PAGEUP: + case WXK_PAGEDOWN: + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + event.Skip(); + return; + + default: + break; + } + // Search for an item name starting by the key code: + key = toupper(key); + for( unsigned ii = 0; ii < m_LibraryList.GetCount(); ii++ ) + { + wxString text = m_LibraryList.Item(ii); + /* search for the start char of the footprint name. + * we must skip the line number + */ + text.Trim(false); // Remove leading spaces in line + unsigned jj = 0; + for( ; jj < text.Len(); jj++ ) + { + // skip line number + if( text[jj] == ' ' ) + break; + } + + for( ; jj < text.Len(); jj++ ) + { // skip blanks + if( text[jj] != ' ' ) + break; + } + + int start_char = toupper( text[jj] ); + if( key == start_char ) + { + Focus( ii ); + SetSelection( ii, true ); // Ensure visible + break; + } + } +} diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index b0e57e6ad0..cac9ad702b 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -85,6 +85,8 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) CVPCB_MAINFRAME::OnSelectFilteringFootprint ) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, CVPCB_MAINFRAME::OnSelectFilteringFootprint ) + EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, + CVPCB_MAINFRAME::OnSelectFilteringFootprint ) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, CVPCB_MAINFRAME::OnSelectFilteringFootprint ) @@ -97,6 +99,7 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftClick ) EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, CVPCB_MAINFRAME::OnLeftDClick ) EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, CVPCB_MAINFRAME::OnSelectComponent ) + EVT_LIST_ITEM_SELECTED( ID_CVPCB_LIBRARY_LIST, CVPCB_MAINFRAME::OnSelectComponent ) EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave ) END_EVENT_TABLE() @@ -112,6 +115,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : m_ListCmp = NULL; m_FootprintList = NULL; + m_LibraryList = NULL; m_DisplayFootprintFrame = NULL; m_mainToolBar = NULL; m_modified = false; @@ -160,6 +164,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : // Create list of available modules and components of the schematic BuildCmpListBox(); BuildFOOTPRINTS_LISTBOX(); + BuildLIBRARY_LISTBOX(); m_auimgr.SetManagedWindow( this ); @@ -179,10 +184,15 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : m_auimgr.AddPane( m_ListCmp, wxAuiPaneInfo( horiz ).Name( wxT( "m_ListCmp" ) ).CentrePane() ); + if( m_LibraryList) + m_auimgr.AddPane( m_LibraryList, + wxAuiPaneInfo( info ).Name( wxT( "m_LibraryList" ) ). + Left().BestSize( (int) ( m_FrameSize.x * 0.20 ), m_FrameSize.y ) ); + if( m_FootprintList ) m_auimgr.AddPane( m_FootprintList, wxAuiPaneInfo( info ).Name( wxT( "m_FootprintList" ) ). - Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) ); + Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) ); m_auimgr.Update(); } @@ -523,9 +533,11 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) #define REDRAW_LIST true #define SELECT_FULL_LIST true int selection = -1; + wxString SelectedLibrary; if( !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) && !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) + && !m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) m_FootprintList->SetActiveFootprintList( SELECT_FULL_LIST, REDRAW_LIST ); @@ -548,6 +560,12 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) m_footprints ); } else + if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) ) + { + SelectedLibrary=m_LibraryList->GetSelectedLibrary(); + m_FootprintList->SetFootprintFilteredByLibraryList( m_footprints, SelectedLibrary ); + } + else { m_FootprintList->SetFootprintFilteredList( m_netlist.GetComponent( selection ), m_footprints ); @@ -610,14 +628,23 @@ void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event ) case ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST: m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, false ); break; case ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST: m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, false ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, false ); break; case ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST: + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, false ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, false ); + break; + + case ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST: + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, false ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, false ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, false ); break; diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index b556d198e5..c3f758e8c4 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -101,6 +101,7 @@ bool EDA_APP::OnInit() frame->LoadProjectFile( filename.GetFullPath() ); frame->Show( true ); frame->BuildFOOTPRINTS_LISTBOX(); + frame->BuildLIBRARY_LISTBOX(); if( filename.IsOk() && filename.FileExists() ) { diff --git a/cvpcb/cvpcb_id.h b/cvpcb/cvpcb_id.h index b2db5ea3d8..7ac8ce95ad 100644 --- a/cvpcb/cvpcb_id.h +++ b/cvpcb/cvpcb_id.h @@ -30,5 +30,7 @@ enum id_cvpcb_frm ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, - ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE + ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, + ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, + ID_CVPCB_LIBRARY_LIST }; diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index 8952e925dc..c72a3beb96 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -32,17 +32,18 @@ #include #include #include +#include #include #include #include -#include /* Forward declarations of all top-level window classes. */ class wxAuiToolBar; class FOOTPRINTS_LISTBOX; class COMPONENTS_LISTBOX; +class LIBRARY_LISTBOX; class DISPLAY_FOOTPRINTS_FRAME; @@ -55,6 +56,7 @@ public: bool m_KeepCvpcbOpen; FOOTPRINTS_LISTBOX* m_FootprintList; + LIBRARY_LISTBOX* m_LibraryList; COMPONENTS_LISTBOX* m_ListCmp; DISPLAY_FOOTPRINTS_FRAME* m_DisplayFootprintFrame; wxAuiToolBar* m_mainToolBar; @@ -156,6 +158,7 @@ public: void SetNewPkg( const wxString& aFootprintName ); void BuildCmpListBox(); void BuildFOOTPRINTS_LISTBOX(); + void BuildLIBRARY_LISTBOX(); /** * Create or Update the frame showing the current highlighted footprint diff --git a/cvpcb/cvstruct.h b/cvpcb/cvstruct.h index 6bfbf3c445..2335b75c0c 100644 --- a/cvpcb/cvstruct.h +++ b/cvpcb/cvstruct.h @@ -34,6 +34,7 @@ /* Forward declarations of all top-level window classes. */ class CVPCB_MAINFRAME; class COMPONENT; +class FOOTPRINT_LIST; /*********************************************************************/ @@ -82,6 +83,8 @@ public: FOOTPRINT_LIST& aList ); void SetFootprintFilteredByPinCount( COMPONENT* aComponent, FOOTPRINT_LIST& aList ); + void SetFootprintFilteredByLibraryList( FOOTPRINT_LIST& list, + wxString SelectedLibrary ); /** * Set the footprint list. We can have 2 footprint list: @@ -99,19 +102,39 @@ public: // Events functions: void OnLeftClick( wxListEvent& event ); void OnLeftDClick( wxListEvent& event ); + void OnChar( wxKeyEvent& event ); - /** - * Function OnChar - * called on a key pressed - * Call default handler for some special keys, - * and for "ascii" keys, select the first footprint - * that the name starts by the letter. - * This is the default behavior of a listbox, but because we use - * virtual lists, the listbox does not know anything to what is displayed, - * we must handle this behavior here. - * Furthermore the footprint name is not at the beginning of - * displayed lines (the first word is the line number) - */ + DECLARE_EVENT_TABLE() +}; + +/******************************************/ +/* ListBox showing the list of library */ +/******************************************/ + +class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE +{ +//private: + +public: + wxArrayString m_LibraryList; + +public: + LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id, + const wxPoint& loc, const wxSize& size, + int nbitems, wxString choice[] ); + ~LIBRARY_LISTBOX(); + + int GetCount(); + void SetSelection( unsigned index, bool State = true ); + void SetString( unsigned linecount, const wxString& text ); + void AppendLine( const wxString& text ); + void SetLibraryList( wxArrayString list ); + + wxString GetSelectedLibrary(); + wxString OnGetItemText( long item, long column ) const; + + // Events functions: + void OnLeftClick( wxListEvent& event ); void OnChar( wxKeyEvent& event ); DECLARE_EVENT_TABLE() diff --git a/cvpcb/dialogs/dialog_cvpcb_config.cpp b/cvpcb/dialogs/dialog_cvpcb_config.cpp index b9ca3946c7..44f263d23e 100644 --- a/cvpcb/dialogs/dialog_cvpcb_config.cpp +++ b/cvpcb/dialogs/dialog_cvpcb_config.cpp @@ -156,6 +156,7 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event ) m_Parent->LoadFootprintFiles(); m_Parent->BuildFOOTPRINTS_LISTBOX(); + m_Parent->BuildLIBRARY_LISTBOX(); } wxCommandEvent evt( ID_SAVE_PROJECT ); diff --git a/cvpcb/dialogs/dialog_display_options.cpp b/cvpcb/dialogs/dialog_display_options.cpp index 3d8d890615..e216e2b08a 100644 --- a/cvpcb/dialogs/dialog_display_options.cpp +++ b/cvpcb/dialogs/dialog_display_options.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/cvpcb/listboxes.cpp b/cvpcb/listboxes.cpp index 43e5ba7812..803ba01156 100644 --- a/cvpcb/listboxes.cpp +++ b/cvpcb/listboxes.cpp @@ -100,8 +100,6 @@ void CVPCB_MAINFRAME::BuildCmpListBox() m_ListCmp = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST, wxDefaultPosition, size, 0, NULL ); - m_ListCmp->SetBackgroundColour( wxColour( 225, 255, 255 ) ); - m_ListCmp->SetForegroundColour( wxColour( 0, 0, 0 ) ); m_ListCmp->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, @@ -140,8 +138,6 @@ void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() m_FootprintList = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST, wxDefaultPosition, size, 0, NULL ); - m_FootprintList->SetBackgroundColour( wxColour( 225, 255, 225 ) ); - m_FootprintList->SetForegroundColour( wxColour( 0, 0, 0 ) ); m_FootprintList->SetFont( wxFont( guiFont.GetPointSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, @@ -151,3 +147,26 @@ void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() m_FootprintList->SetFootprintFullList( m_footprints ); DisplayStatus(); } + +/* + * Create or update the library list. + */ +void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX() +{ + wxString msg; + wxSize size( 10, 10 ); + wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); + + if( m_LibraryList == NULL ) + { + m_LibraryList = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST, + wxDefaultPosition, size, + 0 , NULL ); + m_LibraryList->SetFont( wxFont( guiFont.GetPointSize(), + wxFONTFAMILY_MODERN, + wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_NORMAL ) ); + } + + m_LibraryList->SetLibraryList( m_ModuleLibNames ); +} diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index 162d1d00a2..3780dfd46a 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -124,6 +124,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() LoadProjectFile( m_NetlistFileName.GetFullPath() ); LoadFootprintFiles(); BuildFOOTPRINTS_LISTBOX(); + BuildLIBRARY_LISTBOX(); m_ListCmp->Clear(); m_undefinedComponentCnt = 0; diff --git a/cvpcb/tool_cvpcb.cpp b/cvpcb/tool_cvpcb.cpp index 6d8d7ce4c0..796351f165 100644 --- a/cvpcb/tool_cvpcb.cpp +++ b/cvpcb/tool_cvpcb.cpp @@ -104,6 +104,12 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() _( "Display the filtered footprint list by pin count for the current component" ), wxEmptyString ); + m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, + KiBitmap( module_library_list_xpm ), + wxNullBitmap, true, NULL, + _( "Display the footprint list from selected library" ), + wxEmptyString ); + m_mainToolBar->AddTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, KiBitmap( module_full_list_xpm ), wxNullBitmap, true, NULL, @@ -114,6 +120,7 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() { wxString key = wxT( FILTERFOOTPRINTKEY ); int opt = config->Read( key, (long) 1 ); + m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, opt == 3 ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, opt == 2 ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt == 1 ); m_mainToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, opt == 0 ); diff --git a/include/bitmaps.h b/include/bitmaps.h index 0e1fa85ed9..f841f87417 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -279,6 +279,7 @@ EXTERN_BITMAP( module_editor_xpm ) EXTERN_BITMAP( module_wizard_xpm ) EXTERN_BITMAP( module_filtered_list_xpm ) EXTERN_BITMAP( module_pin_filtered_list_xpm ) +EXTERN_BITMAP( module_library_list_xpm ) EXTERN_BITMAP( module_full_list_xpm ) EXTERN_BITMAP( module_options_xpm ) EXTERN_BITMAP( module_ratsnest_xpm ) diff --git a/include/footprint_info.h b/include/footprint_info.h index b52fcf997a..70678b24fa 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -45,10 +45,9 @@ class FP_LIB_TABLE; */ class FOOTPRINT_INFO { +public: wxString m_libName; ///< Name of the library containing this module excluding path and ext. wxString m_libPath; ///< The full library name and path associated the footprint. - -public: wxString m_Module; ///< Module name. int m_Num; ///< Order number in the display list. wxString m_Doc; ///< Footprint description.