From bd90341e9102697a69d8a075529f93a10f606648 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 20 Jul 2018 16:03:43 +0100 Subject: [PATCH] Add Footprint & Datasheet buttons to Edit Symbol dialog. --- bitmaps_png/CMakeLists.txt | 2 + bitmaps_png/cpp_16/small_library.cpp | 52 +++++ bitmaps_png/cpp_16/www.cpp | 41 ++++ bitmaps_png/sources/small_library.svg | 175 +++++++++++++++++ bitmaps_png/sources/www.svg | 61 ++++++ common/CMakeLists.txt | 1 + common/widgets/grid_text_button_helpers.cpp | 179 ++++++++++++++++++ .../dialog_edit_component_in_schematic.cpp | 4 +- ...ialog_edit_component_in_schematic_base.cpp | 4 +- ...ialog_edit_component_in_schematic_base.fbp | 4 +- .../dialog_edit_libentry_fields_in_lib.cpp | 2 +- eeschema/fields_grid_table.cpp | 25 ++- eeschema/fields_grid_table.h | 4 +- include/bitmaps.h | 2 + include/widgets/grid_text_button_helpers.h | 97 ++++++++++ pcbnew/dialogs/dialog_exchange_footprints.cpp | 4 +- .../dialog_exchange_footprints_base.cpp | 8 +- .../dialog_exchange_footprints_base.fbp | 4 +- 18 files changed, 653 insertions(+), 16 deletions(-) create mode 100644 bitmaps_png/cpp_16/small_library.cpp create mode 100644 bitmaps_png/cpp_16/www.cpp create mode 100644 bitmaps_png/sources/small_library.svg create mode 100644 bitmaps_png/sources/www.svg create mode 100644 common/widgets/grid_text_button_helpers.cpp create mode 100644 include/widgets/grid_text_button_helpers.h diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 1d6fcae2f1..320df94c53 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -102,11 +102,13 @@ set( BMAPS_SMALL refresh small_down small_edit + small_library small_plus small_up trash tree_nosel tree_sel + www ) diff --git a/bitmaps_png/cpp_16/small_library.cpp b/bitmaps_png/cpp_16/small_library.cpp new file mode 100644 index 0000000000..2e081948e6 --- /dev/null +++ b/bitmaps_png/cpp_16/small_library.cpp @@ -0,0 +1,52 @@ + +/* 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, 0x10, 0x00, 0x00, 0x00, 0x0f, 0x08, 0x06, 0x00, 0x00, 0x00, 0xed, 0x73, 0x4f, + 0x2f, 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, 0x09, 0x16, 0x00, 0x00, 0x09, + 0x16, 0x01, 0xb9, 0x3b, 0x3c, 0xa9, 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, 0x01, 0xe2, 0x49, + 0x44, 0x41, 0x54, 0x28, 0x91, 0xa5, 0xd0, 0xcf, 0x8b, 0x12, 0x61, 0x18, 0x07, 0xf0, 0xaf, 0x35, + 0xfe, 0x7a, 0x61, 0x67, 0x74, 0x3c, 0x08, 0xea, 0xec, 0x61, 0x24, 0x10, 0x04, 0x2b, 0x64, 0x85, + 0x05, 0x4f, 0x8a, 0x8a, 0x07, 0x0f, 0x06, 0x76, 0xeb, 0xe6, 0x41, 0xe8, 0x20, 0x1e, 0xfc, 0x2b, + 0x22, 0x10, 0x8c, 0x2e, 0xe2, 0x69, 0xa9, 0x9b, 0x07, 0xaf, 0xba, 0x08, 0x22, 0x1e, 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 0xd8, 0x6c, 0x36, 0x01, 0x1d, + 0x58, 0x2c, 0x16, 0xeb, 0x52, 0xa9, 0xf4, 0x19, 0x00, 0x64, 0x59, 0x36, 0xd4, 0xeb, 0x75, 0x79, + 0x30, 0x18, 0x48, 0x8a, 0xa2, 0x30, 0xbb, 0xdd, 0x6e, 0xfb, 0xcb, 0x38, 0x8c, 0xc7, 0xe3, 0x7e, + 0x34, 0x1a, 0xfd, 0xaa, 0x69, 0xda, 0xd5, 0x7e, 0xbf, 0x7f, 0xf3, 0x8f, 0xff, 0xfb, 0x7b, 0x7e, + 0x02, 0x93, 0x47, 0xb2, 0xd0, 0xa1, 0x6d, 0x79, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, + 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +const BITMAP_OPAQUE small_library_xpm[1] = {{ png, sizeof( png ), "small_library_xpm" }}; + +//EOF diff --git a/bitmaps_png/cpp_16/www.cpp b/bitmaps_png/cpp_16/www.cpp new file mode 100644 index 0000000000..bea05c559a --- /dev/null +++ b/bitmaps_png/cpp_16/www.cpp @@ -0,0 +1,41 @@ + +/* 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, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, + 0x61, 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, 0x09, 0xd8, 0x00, 0x00, 0x09, + 0xd8, 0x01, 0xc7, 0xa0, 0xb9, 0xad, 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, 0x01, 0x2f, 0x49, + 0x44, 0x41, 0x54, 0x38, 0x8d, 0xa5, 0xd3, 0xbb, 0x2e, 0x44, 0x51, 0x14, 0x06, 0xe0, 0xcf, 0xd0, + 0x1a, 0x12, 0x3a, 0x05, 0x05, 0x89, 0x4b, 0x29, 0x9e, 0x40, 0x29, 0x41, 0x3c, 0x00, 0x46, 0x29, + 0x12, 0x85, 0x77, 0xe0, 0x29, 0xc4, 0x25, 0x2e, 0x89, 0x8a, 0x7a, 0xa2, 0x9d, 0x4e, 0x21, 0x08, + 0x12, 0x8d, 0x82, 0x42, 0x22, 0x44, 0x33, 0x1a, 0x46, 0x71, 0xd6, 0x96, 0x33, 0xc3, 0x90, 0xf0, + 0x27, 0x3b, 0xd9, 0xeb, 0xf2, 0xaf, 0xeb, 0xde, 0xfc, 0x13, 0x2d, 0x4d, 0xf4, 0x23, 0x98, 0xc2, + 0x40, 0xc8, 0xd7, 0x38, 0xc2, 0xe5, 0x6f, 0x01, 0x3b, 0xb0, 0x8f, 0x77, 0xd4, 0xf0, 0x1a, 0xa7, + 0x16, 0xba, 0x1d, 0x14, 0x7f, 0x22, 0x9f, 0xe1, 0x0e, 0xb3, 0x78, 0xc2, 0x2a, 0xd6, 0xe2, 0x3e, + 0x1b, 0xb6, 0xd3, 0x66, 0x41, 0xf6, 0xc2, 0xa1, 0x17, 0x0b, 0x91, 0xb9, 0x0b, 0xdd, 0x71, 0x2f, + 0x85, 0xed, 0x1e, 0xdb, 0x89, 0x94, 0x66, 0x30, 0x8c, 0xf3, 0xe8, 0xf1, 0x02, 0xa3, 0xe8, 0xc4, + 0x71, 0xd8, 0xc7, 0xf1, 0x8c, 0x13, 0xd9, 0x7c, 0x86, 0x82, 0x73, 0x55, 0x08, 0x87, 0x69, 0xbc, + 0x04, 0x19, 0x7a, 0x70, 0x9b, 0xab, 0xee, 0x36, 0x74, 0xc2, 0xe7, 0x25, 0x38, 0x9f, 0xd8, 0x40, + 0x39, 0x27, 0x57, 0xa3, 0xe7, 0x84, 0xb9, 0xd0, 0x25, 0x94, 0xb1, 0x0e, 0xa9, 0x82, 0x9a, 0x7a, + 0xd4, 0xd4, 0xaf, 0xb8, 0x45, 0xb6, 0x85, 0x46, 0x1f, 0x6d, 0x21, 0xdc, 0x60, 0x06, 0x07, 0x21, + 0x17, 0xb0, 0x8c, 0x89, 0x90, 0xfb, 0xd1, 0x9a, 0xb3, 0x8f, 0x89, 0xf9, 0xa4, 0x0a, 0x0e, 0x65, + 0xab, 0x19, 0x09, 0x39, 0x6d, 0x23, 0xa1, 0x37, 0x74, 0xc2, 0xa7, 0x3d, 0x38, 0x75, 0xd8, 0xcd, + 0x11, 0x4b, 0xbe, 0xae, 0x71, 0x1e, 0x7d, 0xb2, 0x35, 0x6e, 0x25, 0x52, 0x21, 0x17, 0x60, 0x11, + 0x8f, 0xa8, 0x44, 0xbf, 0x55, 0xac, 0xc4, 0xa9, 0x46, 0xcf, 0x15, 0x3c, 0x60, 0xa9, 0x31, 0x7b, + 0x42, 0x51, 0xf6, 0x5c, 0xbf, 0x7b, 0xca, 0x6f, 0xd8, 0x8c, 0xf2, 0x3f, 0xd1, 0xec, 0x33, 0x0d, + 0x61, 0x12, 0x83, 0x41, 0xbe, 0x92, 0x7d, 0xa6, 0xeb, 0x66, 0x99, 0xff, 0x8c, 0x0f, 0xf2, 0xa4, + 0x50, 0xe9, 0xcf, 0x13, 0x86, 0x90, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, + 0x60, 0x82, +}; + +const BITMAP_OPAQUE www_xpm[1] = {{ png, sizeof( png ), "www_xpm" }}; + +//EOF diff --git a/bitmaps_png/sources/small_library.svg b/bitmaps_png/sources/small_library.svg new file mode 100644 index 0000000000..f58ddc76e0 --- /dev/null +++ b/bitmaps_png/sources/small_library.svg @@ -0,0 +1,175 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bitmaps_png/sources/www.svg b/bitmaps_png/sources/www.svg new file mode 100644 index 0000000000..f676ca66b2 --- /dev/null +++ b/bitmaps_png/sources/www.svg @@ -0,0 +1,61 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2a0c417796..34aefa7749 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -183,6 +183,7 @@ set( COMMON_WIDGET_SRCS widgets/gal_options_panel.cpp widgets/grid_combobox.cpp widgets/grid_icon_text_helpers.cpp + widgets/grid_text_button_helpers.cpp widgets/indicator_icon.cpp widgets/mathplot.cpp widgets/paged_dialog.cpp diff --git a/common/widgets/grid_text_button_helpers.cpp b/common/widgets/grid_text_button_helpers.cpp new file mode 100644 index 0000000000..8608f757be --- /dev/null +++ b/common/widgets/grid_text_button_helpers.cpp @@ -0,0 +1,179 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018 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 + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + + +//-------- Renderer --------------------------------------------------------------------- +// None required; just render as normal text. + + + +//-------- Editor Base Class ------------------------------------------------------------ +// +// Note: this implementation is an adaptation of wxGridCellChoiceEditor + + +wxString GRID_CELL_TEXT_BUTTON::GetValue() const +{ + return Combo()->GetValue(); +} + +void GRID_CELL_TEXT_BUTTON::SetSize( const wxRect& aRect ) +{ + wxRect rect( aRect ); + rect.Inflate( -1 ); + +#if defined( __WXMAC__ ) + rect.Inflate( 3 ); // no FOCUS_RING, even on Mac +#endif + + Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE ); +} + + +void GRID_CELL_TEXT_BUTTON::BeginEdit( int aRow, int aCol, wxGrid* aGrid ) +{ + auto evtHandler = static_cast( m_control->GetEventHandler() ); + + // Don't immediately end if we get a kill focus event within BeginEdit + evtHandler->SetInSetFocus( true ); + + m_value = aGrid->GetTable()->GetValue( aRow, aCol ); + + Combo()->SetValue( m_value ); + Combo()->SetFocus(); +} + + +bool GRID_CELL_TEXT_BUTTON::EndEdit( int , int , const wxGrid* , const wxString& , wxString *aNewVal ) +{ + const wxString value = Combo()->GetValue(); + + if( value == m_value ) + return false; + + m_value = value; + + if( aNewVal ) + *aNewVal = value; + + return true; +} + + +void GRID_CELL_TEXT_BUTTON::ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) +{ + aGrid->GetTable()->SetValue( aRow, aCol, m_value ); +} + + +void GRID_CELL_TEXT_BUTTON::Reset() +{ +} + + +class TEXT_BUTTON_FP_CHOOSER : public wxComboCtrl +{ +public: + TEXT_BUTTON_FP_CHOOSER( wxWindow* aParent, DIALOG_SHIM* aParentDlg ) : + wxComboCtrl( aParent ), + m_dlg( aParentDlg ) + { + SetButtonBitmaps( KiBitmap( small_library_xpm ) ); + } + +protected: + void DoSetPopupControl( wxComboPopup* popup ) override + { + m_popup = nullptr; + } + + void OnButtonClick() override + { + // pick a footprint using the footprint picker. + wxString fpid = GetValue(); + KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true, m_dlg ); + + if( frame->ShowModal( &fpid, m_dlg ) ) + SetValue( fpid ); + + frame->Destroy(); + } + + DIALOG_SHIM* m_dlg; +}; + + +void GRID_CELL_FOOTPRINT_EDITOR::Create( wxWindow* aParent, wxWindowID aId, + wxEvtHandler* aEventHandler ) +{ + m_control = new TEXT_BUTTON_FP_CHOOSER( aParent, m_dlg ); + + wxGridCellEditor::Create(aParent, aId, aEventHandler); +} + + +class TEXT_BUTTON_URL : public wxComboCtrl +{ +public: + TEXT_BUTTON_URL( wxWindow* aParent, DIALOG_SHIM* aParentDlg ) : + wxComboCtrl( aParent ), + m_dlg( aParentDlg ) + { + SetButtonBitmaps( KiBitmap( www_xpm ) ); + } + +protected: + void DoSetPopupControl( wxComboPopup* popup ) override + { + m_popup = nullptr; + } + + void OnButtonClick() override + { + wxString uri = ResolveUriByEnvVars( GetValue() ); + GetAssociatedDocument( m_dlg, uri ); + } + + DIALOG_SHIM* m_dlg; +}; + + +void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, + wxEvtHandler* aEventHandler ) +{ + m_control = new TEXT_BUTTON_URL( aParent, m_dlg ); + + wxGridCellEditor::Create(aParent, aId, aEventHandler); +} + + diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 102d0c8b63..fd2028946c 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -140,7 +140,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT m_cmp = aComponent; m_part = GetParent()->GetLibPart( m_cmp->GetLibId(), true ); - m_fields = new FIELDS_GRID_TABLE( false, GetUserUnits(), m_part ); + m_fields = new FIELDS_GRID_TABLE( this, false, m_part ); m_delayedFocusRow = REFERENCE; m_delayedFocusColumn = FDC_VALUE; @@ -171,7 +171,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT m_stdDialogButtonSizerOK->SetDefault(); // Configure button logos - m_buttonBrowseLibrary->SetBitmap( KiBitmap( library_browse_xpm ) ); + m_buttonBrowseLibrary->SetBitmap( KiBitmap( small_library_xpm ) ); m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) ); m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) ); m_bpMoveUp->SetBitmap( KiBitmap( small_up_xpm ) ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp index f9b779fb5b..ae1a34f251 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp @@ -130,9 +130,11 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_libraryNameTextCtrl = new wxTextCtrl( sbSizerLibraryReference->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_libraryNameTextCtrl->SetToolTip( _("Name of the symbol in the library to which this symbol is linked") ); - bLibraryReferenceSizer->Add( m_libraryNameTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bLibraryReferenceSizer->Add( m_libraryNameTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); m_buttonBrowseLibrary = new wxBitmapButton( sbSizerLibraryReference->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + m_buttonBrowseLibrary->SetMinSize( wxSize( 29,29 ) ); + bLibraryReferenceSizer->Add( m_buttonBrowseLibrary, 0, wxALIGN_CENTER_VERTICAL, 5 ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp index 490464348a..f3ef8b0b21 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp @@ -864,7 +864,7 @@ none 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT 1 1 @@ -996,7 +996,7 @@ 0 - -1,-1 + 29,29 1 m_buttonBrowseLibrary 1 diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index d566aad116..1efd636ecd 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -123,7 +123,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT m_parent = aParent; m_libEntry = aLibEntry; - m_fields = new FIELDS_GRID_TABLE( true, GetUserUnits(), m_libEntry ); + m_fields = new FIELDS_GRID_TABLE( this, true, m_libEntry ); m_delayedFocusRow = REFERENCE; m_delayedFocusColumn = FDC_VALUE; diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index b0100a086f..3d21d0e741 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "eda_doc.h" @@ -43,8 +44,8 @@ enum template -FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( bool aInLibEdit, EDA_UNITS_T aUserUnits, LIB_PART* aPart ) : - m_userUnits( aUserUnits ), +FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, bool aInLibEdit, LIB_PART* aPart ) : + m_userUnits( aDialog->GetUserUnits() ), m_part( aPart ), m_inLibEdit( aInLibEdit ), m_valueValidator( aInLibEdit, REFERENCE ) @@ -59,6 +60,12 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( bool aInLibEdit, EDA_UNITS_T aUserUnits textEditor->SetValidator( m_valueValidator ); m_valueColAttr->SetEditor( textEditor ); + m_footprintAttr = new wxGridCellAttr; + m_footprintAttr->SetEditor( new GRID_CELL_FOOTPRINT_EDITOR( aDialog ) ); + + m_urlAttr = new wxGridCellAttr; + m_urlAttr->SetEditor( new GRID_CELL_URL_EDITOR( aDialog ) ); + m_boolColAttr = new wxGridCellAttr; m_boolColAttr->SetRenderer( new wxGridCellBoolRenderer() ); m_boolColAttr->SetEditor( new wxGridCellBoolEditor() ); @@ -95,6 +102,8 @@ FIELDS_GRID_TABLE::~FIELDS_GRID_TABLE() m_readOnlyAttr->DecRef(); m_boolColAttr->DecRef(); m_valueColAttr->DecRef(); + m_footprintAttr->DecRef(); + m_urlAttr->DecRef(); m_vAlignColAttr->DecRef(); m_hAlignColAttr->DecRef(); m_orientationColAttr->DecRef(); @@ -187,6 +196,16 @@ wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAtt m_readOnlyAttr->IncRef(); return m_readOnlyAttr; } + else if( aRow == FOOTPRINT ) + { + m_footprintAttr->IncRef(); + return m_footprintAttr; + } + else if( aRow == DATASHEET ) + { + m_urlAttr->IncRef(); + return m_urlAttr; + } else { // Some fields have different validation semantics. Make sure the @@ -423,7 +442,7 @@ void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event ) if( event.GetId() == MYID_SELECT_FOOTPRINT ) { // pick a footprint using the footprint picker. - wxString fpid; + wxString fpid = m_grid->GetCellValue( FOOTPRINT, FDC_VALUE ); KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true, m_dlg ); if( frame->ShowModal( &fpid, m_dlg ) ) diff --git a/eeschema/fields_grid_table.h b/eeschema/fields_grid_table.h index 6e6fe46f2b..f191fe5817 100644 --- a/eeschema/fields_grid_table.h +++ b/eeschema/fields_grid_table.h @@ -68,7 +68,7 @@ template class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector { public: - FIELDS_GRID_TABLE( bool aInLibEdit, EDA_UNITS_T userUnits, LIB_PART* aPart ); + FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, bool aInLibEdit, LIB_PART* aPart ); ~FIELDS_GRID_TABLE(); int GetNumberRows() override { return (int) this->size(); } @@ -100,6 +100,8 @@ private: wxGridCellAttr* m_readOnlyAttr; wxGridCellAttr* m_valueColAttr; + wxGridCellAttr* m_footprintAttr; + wxGridCellAttr* m_urlAttr; wxGridCellAttr* m_boolColAttr; wxGridCellAttr* m_vAlignColAttr; wxGridCellAttr* m_hAlignColAttr; diff --git a/include/bitmaps.h b/include/bitmaps.h index f0eeecddf6..16b0f2002f 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -501,6 +501,7 @@ EXTERN_BITMAP( show_zone_disable_xpm ) EXTERN_BITMAP( show_zone_outline_only_xpm ) EXTERN_BITMAP( small_down_xpm ) EXTERN_BITMAP( small_edit_xpm ) +EXTERN_BITMAP( small_library_xpm ) EXTERN_BITMAP( small_plus_xpm ) EXTERN_BITMAP( small_up_xpm ) EXTERN_BITMAP( spreadsheet_xpm ) @@ -543,6 +544,7 @@ EXTERN_BITMAP( width_track_xpm ) EXTERN_BITMAP( width_vias_xpm ) EXTERN_BITMAP( wizard_add_fplib_icon_xpm ) EXTERN_BITMAP( wizard_add_fplib_small_xpm ) +EXTERN_BITMAP( www_xpm ) EXTERN_BITMAP( zip_tool_xpm ) EXTERN_BITMAP( zip_xpm ) EXTERN_BITMAP( zone_duplicate_xpm ) diff --git a/include/widgets/grid_text_button_helpers.h b/include/widgets/grid_text_button_helpers.h new file mode 100644 index 0000000000..634f1be980 --- /dev/null +++ b/include/widgets/grid_text_button_helpers.h @@ -0,0 +1,97 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2018 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 + */ + +#ifndef GRID_TEXT_BUTTON_HELPERS_H +#define GRID_TEXT_BUTTON_HELPERS_H + +#include +#include +#include + + +class wxGrid; +class DIALOG_SHIM; + + +class GRID_CELL_TEXT_BUTTON : public wxGridCellEditor +{ +public: + GRID_CELL_TEXT_BUTTON() {}; + + wxString GetValue() const override; + + void SetSize( const wxRect& aRect ) override; + + void BeginEdit( int aRow, int aCol, wxGrid* aGrid ) override; + bool EndEdit( int , int , const wxGrid* , const wxString& , wxString *aNewVal ) override; + void ApplyEdit( int aRow, int aCol, wxGrid* aGrid ) override; + void Reset() override; + +protected: + wxComboCtrl* Combo() const { return static_cast( m_control ); } + + wxString m_value; + + wxDECLARE_NO_COPY_CLASS( GRID_CELL_TEXT_BUTTON ); +}; + + +class GRID_CELL_FOOTPRINT_EDITOR : public GRID_CELL_TEXT_BUTTON +{ +public: + GRID_CELL_FOOTPRINT_EDITOR( DIALOG_SHIM* aParent ) : + m_dlg( aParent ) + { } + + wxGridCellEditor* Clone() const override + { + return new GRID_CELL_FOOTPRINT_EDITOR( m_dlg ); + } + + void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override; + +protected: + DIALOG_SHIM* m_dlg; +}; + + +class GRID_CELL_URL_EDITOR : public GRID_CELL_TEXT_BUTTON +{ +public: + GRID_CELL_URL_EDITOR( DIALOG_SHIM* aParent ) : + m_dlg( aParent ) + { } + + wxGridCellEditor* Clone() const override + { + return new GRID_CELL_URL_EDITOR( m_dlg ); + } + + void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override; + +protected: + DIALOG_SHIM* m_dlg; +}; + + +#endif // GRID_TEXT_BUTTON_HELPERS_H diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index 349e032b17..68d64366a8 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -82,7 +82,7 @@ DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS( PCB_EDIT_FRAME* aParent, else SetInitialFocus( m_specifiedRef ); - m_newIDBrowseButton->SetBitmap( KiBitmap( library_browse_xpm ) ); + m_newIDBrowseButton->SetBitmap( KiBitmap( small_library_xpm ) ); } if( m_currentModule ) @@ -117,7 +117,7 @@ DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS( PCB_EDIT_FRAME* aParent, if( m_currentModule ) m_specifiedID->AppendText( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) ); - m_specifiedIDBrowseButton->SetBitmap( KiBitmap( library_browse_xpm ) ); + m_specifiedIDBrowseButton->SetBitmap( KiBitmap( small_library_xpm ) ); m_upperSizer->SetEmptyCellSize( wxSize( 0, 0 ) ); m_upperSizer->RecalcSizes(); diff --git a/pcbnew/dialogs/dialog_exchange_footprints_base.cpp b/pcbnew/dialogs/dialog_exchange_footprints_base.cpp index e86683022a..e147915f0f 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints_base.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints_base.cpp @@ -59,7 +59,9 @@ DIALOG_EXCHANGE_FOOTPRINTS_BASE::DIALOG_EXCHANGE_FOOTPRINTS_BASE( wxWindow* pare bSizer4->Add( m_specifiedID, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); m_specifiedIDBrowseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); - bSizer4->Add( m_specifiedIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_specifiedIDBrowseButton->SetMinSize( wxSize( 29,29 ) ); + + bSizer4->Add( m_specifiedIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 2 ); m_mainSizer->Add( bSizer4, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); @@ -84,7 +86,9 @@ DIALOG_EXCHANGE_FOOTPRINTS_BASE::DIALOG_EXCHANGE_FOOTPRINTS_BASE( wxWindow* pare bSizer3->Add( m_newID, 1, wxALIGN_CENTER_VERTICAL, 5 ); m_newIDBrowseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); - bSizer3->Add( m_newIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_newIDBrowseButton->SetMinSize( wxSize( 29,29 ) ); + + bSizer3->Add( m_newIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 2 ); m_changeSizer->Add( bSizer3, 1, wxEXPAND|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints_base.fbp b/pcbnew/dialogs/dialog_exchange_footprints_base.fbp index 1e72d35df0..ac294372ae 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints_base.fbp +++ b/pcbnew/dialogs/dialog_exchange_footprints_base.fbp @@ -987,7 +987,7 @@ 0 - + 29,29 1 m_specifiedIDBrowseButton 1 @@ -1355,7 +1355,7 @@ 0 - + 29,29 1 m_newIDBrowseButton 1