Move Edit Symbol References to standard text/button control.

This commit is contained in:
Jeff Young 2018-09-29 17:18:55 +01:00
parent b49ca04355
commit 3c2aafd7b7
8 changed files with 115 additions and 87 deletions

View File

@ -149,6 +149,51 @@ void GRID_CELL_TEXT_BUTTON::Reset()
}
/**
* Symbol Picker
*/
class TEXT_BUTTON_SYMBOL_CHOOSER : public wxComboCtrl
{
public:
TEXT_BUTTON_SYMBOL_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 compid = GetValue();
KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, m_dlg );
if( frame->ShowModal( &compid, m_dlg ) )
SetValue( compid );
frame->Destroy();
}
DIALOG_SHIM* m_dlg;
};
void GRID_CELL_SYMBOL_ID_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler )
{
m_control = new TEXT_BUTTON_SYMBOL_CHOOSER( aParent, m_dlg );
wxGridCellEditor::Create(aParent, aId, aEventHandler);
}
/**
* Footprint Picker
*/
@ -185,8 +230,8 @@ protected:
};
void GRID_CELL_FOOTPRINT_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler )
void GRID_CELL_FOOTPRINT_ID_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler )
{
m_control = new TEXT_BUTTON_FP_CHOOSER( aParent, m_dlg );

View File

@ -39,6 +39,7 @@
#include <dialog_edit_components_libid_base.h>
#include <wx/tokenzr.h>
#include <widgets/grid_text_button_helpers.h>
#define COL_REFS 0
#define COL_CURR_LIBID 1
@ -303,8 +304,8 @@ public:
bool IsSchematicModified() { return m_isModified; }
private:
SCH_EDIT_FRAME* m_parent;
bool m_isModified; // set to true if the schematic is modified
SCH_EDIT_FRAME* m_parent;
bool m_isModified; // set to true if the schematic is modified
std::vector<int> m_OrphansRowIndexes; // list of rows containing orphan lib_id
std::vector<CMP_CANDIDATE> m_components;
@ -376,6 +377,8 @@ DIALOG_EDIT_COMPONENTS_LIBID::DIALOG_EDIT_COMPONENTS_LIBID( SCH_EDIT_FRAME* aPar
m_parent = aParent;
m_autoWrapRenderer = new GRIDCELL_AUTOWRAP_STRINGRENDERER;
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
initDlg();
FinishDialogSettings();
@ -384,6 +387,9 @@ DIALOG_EDIT_COMPONENTS_LIBID::DIALOG_EDIT_COMPONENTS_LIBID( SCH_EDIT_FRAME* aPar
DIALOG_EDIT_COMPONENTS_LIBID::~DIALOG_EDIT_COMPONENTS_LIBID()
{
// Delete the GRID_TRICKS.
m_grid->PopEventHandler( true );
m_autoWrapRenderer->DecRef();
}
@ -541,6 +547,11 @@ void DIALOG_EDIT_COMPONENTS_LIBID::AddRowToGrid( bool aMarkRow, const wxString&
// (fixed in 2014, but didn't get in to wxWidgets 3.0.2)
wxClientDC dc( this );
m_grid->SetRowSize( row, m_autoWrapRenderer->GetHeight( dc, m_grid, row, COL_REFS ) );
// set new libid column browse button
wxGridCellAttr* attr = new wxGridCellAttr;
attr->SetEditor( new GRID_CELL_SYMBOL_ID_EDITOR( this ) );
m_grid->SetColAttr( COL_NEW_LIBID, attr );
}
@ -816,9 +827,31 @@ void DIALOG_EDIT_COMPONENTS_LIBID::AdjustGridColumns( int aWidth )
// Account for scroll bars
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
m_grid->SetColSize( 0, aWidth / 3 );
m_grid->SetColSize( 1, aWidth / 3 );
m_grid->SetColSize( 2, aWidth - m_grid->GetColSize( 0 ) - m_grid->GetColSize( 1 ) );
int colWidth = aWidth / 3;
m_grid->SetColSize( COL_REFS, colWidth );
aWidth -= colWidth;
colWidth = 0;
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
{
wxString cellValue = m_grid->GetCellValue( row, COL_CURR_LIBID );
colWidth = std::max( colWidth, GetTextSize( cellValue, m_grid ).x );
}
colWidth += 20;
m_grid->SetColSize( COL_CURR_LIBID, colWidth );
aWidth -= colWidth;
colWidth = 0;
for( int row = 0; row < m_grid->GetNumberRows(); ++row )
{
wxString cellValue = m_grid->GetCellValue( row, COL_NEW_LIBID );
colWidth = std::max( colWidth, GetTextSize( cellValue, m_grid ).x );
}
colWidth += 20;
m_grid->SetColSize( COL_NEW_LIBID, std::max( colWidth, aWidth ) );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -93,7 +93,7 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow*
bSizerButtons->Add( m_sdbSizer, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( bSizerButtons, 0, wxEXPAND, 5 );
bSizerMain->Add( bSizerButtons, 0, wxEXPAND|wxLEFT, 5 );
this->SetSizer( bSizerMain );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="14" />
<FileVersion major="1" minor="13" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,7 +14,6 @@
<property name="file">dialog_edit_components_libid_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_edit_components_libid_base</property>
<property name="namespace"></property>
@ -55,20 +54,13 @@
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiPaneActivated"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -83,23 +75,17 @@
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMaximize"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnMove"></event>
<event name="OnMoveEnd"></event>
<event name="OnMoveStart"></event>
<event name="OnMoving"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnShow"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
@ -193,14 +179,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
@ -299,7 +278,6 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Warning: changes made from this dialog cannot be undone after closing it.</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -325,14 +303,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@ -372,31 +343,25 @@
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Undo Changes</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -411,8 +376,6 @@
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
@ -427,15 +390,8 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnButtonClick">onUndoChangesButton</event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@ -518,14 +474,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@ -552,7 +501,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
@ -574,31 +523,25 @@
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Map Orphans</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -613,8 +556,6 @@
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
@ -629,15 +570,8 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnButtonClick">onClickOrphansButton</event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -21,9 +21,6 @@ class WX_GRID;
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/stattext.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statline.h>

View File

@ -704,7 +704,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent
// set footprint column browse button
attr = new wxGridCellAttr;
attr->SetEditor( new GRID_CELL_FOOTPRINT_EDITOR( this ) );
attr->SetEditor( new GRID_CELL_FOOTPRINT_ID_EDITOR( this ) );
m_grid->SetColAttr( FOOTPRINT, attr );
// set datasheet column viewer button

View File

@ -75,7 +75,7 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
m_valueAttr->SetEditor( valueEditor );
m_footprintAttr = new wxGridCellAttr;
m_footprintAttr->SetEditor( new GRID_CELL_FOOTPRINT_EDITOR( aDialog ) );
m_footprintAttr->SetEditor( new GRID_CELL_FOOTPRINT_ID_EDITOR( aDialog ) );
m_urlAttr = new wxGridCellAttr;
m_urlAttr->SetEditor( new GRID_CELL_URL_EDITOR( aDialog ) );

View File

@ -57,16 +57,35 @@ protected:
};
class GRID_CELL_FOOTPRINT_EDITOR : public GRID_CELL_TEXT_BUTTON
class GRID_CELL_SYMBOL_ID_EDITOR : public GRID_CELL_TEXT_BUTTON
{
public:
GRID_CELL_FOOTPRINT_EDITOR( DIALOG_SHIM* aParent ) :
GRID_CELL_SYMBOL_ID_EDITOR( DIALOG_SHIM* aParent ) :
m_dlg( aParent )
{ }
wxGridCellEditor* Clone() const override
{
return new GRID_CELL_FOOTPRINT_EDITOR( m_dlg );
return new GRID_CELL_SYMBOL_ID_EDITOR( m_dlg );
}
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
protected:
DIALOG_SHIM* m_dlg;
};
class GRID_CELL_FOOTPRINT_ID_EDITOR : public GRID_CELL_TEXT_BUTTON
{
public:
GRID_CELL_FOOTPRINT_ID_EDITOR( DIALOG_SHIM* aParent ) :
m_dlg( aParent )
{ }
wxGridCellEditor* Clone() const override
{
return new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dlg );
}
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;