Add pin number summary

Below the pin table, display which pins are currently defined, in order to
find gaps.
This commit is contained in:
Simon Richter 2016-01-13 14:17:54 -05:00 committed by Chris Pavlina
parent f7c7920b0b
commit 3c5a4a3505
7 changed files with 148 additions and 0 deletions

View File

@ -43,6 +43,8 @@ public:
void CalculateGrouping();
void Refresh();
PinNumbers GetAllPinNumbers();
#ifdef REASSOCIATE_HACK
void SetWidget( wxDataViewCtrl* aWidget ) { m_Widget = aWidget; }
#endif
@ -176,6 +178,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent,
m_Pins->AppendColumn( col2 );
m_Pins->AppendColumn( col3 );
UpdateSummary();
GetSizer()->SetSizeHints(this);
Centre();
}
@ -186,6 +190,14 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
}
void DIALOG_LIB_EDIT_PIN_TABLE::UpdateSummary()
{
PinNumbers pins = m_Model->GetAllPinNumbers();
m_Summary->SetValue( pins.GetSummary() );
}
void DIALOG_LIB_EDIT_PIN_TABLE::OnColumnHeaderRightClicked( wxDataViewEvent& event )
{
m_Model->SetGroupingColumn( event.GetDataViewColumn()->GetModelColumn() );
@ -377,6 +389,21 @@ void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Refresh()
}
PinNumbers DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::GetAllPinNumbers()
{
PinNumbers ret;
for( std::list<Pin>::const_iterator i = m_Pins.begin(); i != m_Pins.end(); ++i )
{
wxVariant var;
i->GetValue( var, PIN_NUMBER );
ret.insert( var.GetString() );
}
return ret;
}
void DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Group::GetValue( wxVariant& aValue,
unsigned int aCol ) const
{

View File

@ -9,6 +9,8 @@ public:
DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, LIB_PART& aPart );
~DIALOG_LIB_EDIT_PIN_TABLE();
void UpdateSummary();
virtual void OnColumnHeaderRightClicked( wxDataViewEvent& aEvent );
private:

View File

@ -21,6 +21,9 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
top_sizer->Add( m_Pins, 1, wxALL|wxEXPAND, 5 );
m_Summary = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxNO_BORDER );
top_sizer->Add( m_Summary, 0, wxALL|wxEXPAND, 5 );
m_Buttons = new wxStdDialogButtonSizer();
m_ButtonsOK = new wxButton( this, wxID_OK );
m_Buttons->AddButton( m_ButtonsOK );

View File

@ -161,6 +161,97 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></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="default_pane">0</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="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Summary</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxTE_READONLY</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxNO_BORDER</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></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="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>

View File

@ -20,6 +20,7 @@ class DIALOG_SHIM;
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -36,6 +37,7 @@ class DIALOG_LIB_EDIT_PIN_TABLE_BASE : public DIALOG_SHIM
protected:
wxDataViewCtrl* m_Pins;
wxTextCtrl* m_Summary;
wxStdDialogButtonSizer* m_Buttons;
wxButton* m_ButtonsOK;

View File

@ -67,6 +67,27 @@ wxString GetNextComponent( const wxString& str, wxString::size_type& cursor )
}
wxString PinNumbers::GetSummary() const
{
wxString ret;
const_iterator i = begin();
if( i == end() )
return ret;
ret = *i;
++i;
for( ; i != end(); ++i )
{
ret += ',';
ret += *i;
}
return ret;
}
int PinNumbers::Compare( const PinNumber& lhs, const PinNumber& rhs )
{
wxString::size_type cursor1 = 0;

View File

@ -34,6 +34,8 @@ typedef wxString PinNumber;
class PinNumbers
{
public:
wxString GetSummary() const;
static int Compare( PinNumber const &lhs, PinNumber const &rhs );
private: