more EDA_LIST_DIALOG usability enhancements, compiler warning, coding standards
This commit is contained in:
parent
7cf3467851
commit
300a047ffe
|
@ -30,6 +30,8 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
|
||||||
bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 );
|
bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL|wxALWAYS_SHOW_SB|wxVSCROLL );
|
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL|wxALWAYS_SHOW_SB|wxVSCROLL );
|
||||||
|
m_listBox->SetMinSize( wxSize( -1,200 ) );
|
||||||
|
|
||||||
bSizerMain->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
bSizerMain->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||||
|
|
||||||
m_staticTextMsg = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_staticTextMsg = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
|
|
@ -387,7 +387,7 @@
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size"></property>
|
||||||
<property name="min_size"></property>
|
<property name="min_size"></property>
|
||||||
<property name="minimize_button">0</property>
|
<property name="minimize_button">0</property>
|
||||||
<property name="minimum_size">-1,-1</property>
|
<property name="minimum_size">-1,200</property>
|
||||||
<property name="moveable">1</property>
|
<property name="moveable">1</property>
|
||||||
<property name="name">m_listBox</property>
|
<property name="name">m_listBox</property>
|
||||||
<property name="pane_border">1</property>
|
<property name="pane_border">1</property>
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
|
EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
|
||||||
const wxArrayString& aItemHeaders,
|
const wxArrayString& aItemHeaders,
|
||||||
const std::vector<wxArrayString>& aItemList,
|
const std::vector<wxArrayString>& aItemList,
|
||||||
const wxString& aRefText,
|
const wxString& aSelection,
|
||||||
void(*aCallBackFunction)(wxString& Text),
|
void( *aCallBackFunction )( wxString& ),
|
||||||
bool aSortList ) :
|
bool aSortList ) :
|
||||||
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
|
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
|
||||||
{
|
{
|
||||||
|
@ -47,29 +47,15 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
|
||||||
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
|
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
|
||||||
{
|
{
|
||||||
wxListItem column;
|
wxListItem column;
|
||||||
|
|
||||||
column.SetId( i );
|
column.SetId( i );
|
||||||
column.SetText( aItemHeaders.Item( i ) );
|
column.SetText( aItemHeaders.Item( i ) );
|
||||||
|
|
||||||
m_listBox->InsertColumn( i, column );
|
m_listBox->InsertColumn( i, column );
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertItems( aItemList, 0 );
|
InsertItems( aItemList, 0 );
|
||||||
|
|
||||||
if( !aRefText.IsEmpty() ) // try to select the item matching aRefText
|
|
||||||
{
|
|
||||||
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
|
|
||||||
{
|
|
||||||
if( aItemList[ii][0] == aRefText )
|
|
||||||
{
|
|
||||||
m_listBox->SetItemState( ii, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DIALOG_SHIM needs a unique hash_key because classname is not sufficient
|
|
||||||
// because so many dialogs share this same class.
|
|
||||||
m_hash_key = TO_UTF8( aTitle );
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
|
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
|
||||||
m_listBox->SetColumnWidth( i, wxLIST_AUTOSIZE );
|
m_listBox->SetColumnWidth( i, wxLIST_AUTOSIZE );
|
||||||
|
|
||||||
|
@ -79,9 +65,27 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
|
||||||
m_staticTextMsg->Show( false );
|
m_staticTextMsg->Show( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_filterBox->SetFocus();
|
|
||||||
|
|
||||||
Fit();
|
Fit();
|
||||||
|
|
||||||
|
if( !!aSelection )
|
||||||
|
{
|
||||||
|
for( unsigned row = 0; row < aItemList.size(); ++row )
|
||||||
|
{
|
||||||
|
if( aItemList[row][0] == aSelection )
|
||||||
|
{
|
||||||
|
m_listBox->SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
||||||
|
m_listBox->EnsureVisible( row );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DIALOG_SHIM needs a unique hash_key because classname is not sufficient
|
||||||
|
// because so many dialogs share this same class, with different numbers of
|
||||||
|
// columns, different column names, and column widths.
|
||||||
|
m_hash_key = TO_UTF8( aTitle );
|
||||||
|
|
||||||
|
m_filterBox->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -470,11 +470,13 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
||||||
const wxString& aKeyWord,
|
const wxString& aKeyWord,
|
||||||
FP_LIB_TABLE* aTable )
|
FP_LIB_TABLE* aTable )
|
||||||
{
|
{
|
||||||
static wxString OldName; // Save the name of the last module loaded.
|
static wxString oldName; // Save the name of the last module loaded.
|
||||||
wxString CmpName;
|
|
||||||
wxString msg;
|
wxString fpname;
|
||||||
wxArrayString libraries;
|
wxString msg;
|
||||||
FP_LIB_TABLE libTable;
|
wxArrayString libraries;
|
||||||
|
FP_LIB_TABLE libTable;
|
||||||
|
|
||||||
std::vector< wxArrayString > rows;
|
std::vector< wxArrayString > rows;
|
||||||
|
|
||||||
#if !defined( USE_FP_LIB_TABLE )
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
|
@ -581,33 +583,33 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
||||||
|
|
||||||
msg.Printf( _( "Modules [%d items]" ), (int) rows.size() );
|
msg.Printf( _( "Modules [%d items]" ), (int) rows.size() );
|
||||||
|
|
||||||
EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, OldName, DisplayCmpDoc );
|
EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, oldName, DisplayCmpDoc );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
CmpName = dlg.GetTextSelection();
|
fpname = dlg.GetTextSelection();
|
||||||
|
|
||||||
#if defined( USE_FP_LIB_TABLE )
|
#if defined( USE_FP_LIB_TABLE )
|
||||||
CmpName = dlg.GetTextSelection( 1 ) + wxT( ":" ) + CmpName;
|
fpname = dlg.GetTextSelection( 1 ) + wxT( ":" ) + fpname;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SkipNextLeftButtonReleaseEvent();
|
SkipNextLeftButtonReleaseEvent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CmpName.Empty();
|
fpname.Empty();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayError( aWindow, _( "No footprint found." ) );
|
DisplayError( aWindow, _( "No footprint found." ) );
|
||||||
CmpName.Empty();
|
fpname.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( CmpName != wxEmptyString )
|
if( fpname != wxEmptyString )
|
||||||
OldName = CmpName;
|
oldName = fpname;
|
||||||
|
|
||||||
wxLogDebug( wxT( "Footprint '%s' was selected." ), GetChars( CmpName ) );
|
wxLogDebug( wxT( "Footprint '%s' was selected." ), GetChars( fpname ) );
|
||||||
|
|
||||||
return CmpName;
|
return fpname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -628,27 +630,29 @@ static void DisplayCmpDoc( wxString& Name )
|
||||||
|
|
||||||
MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprint( BOARD* aPcb )
|
MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprint( BOARD* aPcb )
|
||||||
{
|
{
|
||||||
MODULE* module;
|
static wxString oldName; // Save name of last module selected.
|
||||||
static wxString OldName; // Save name of last module selected.
|
|
||||||
wxString CmpName, msg;
|
|
||||||
|
|
||||||
wxArrayString listnames;
|
wxString fpname;
|
||||||
|
wxString msg;
|
||||||
|
wxArrayString listnames;
|
||||||
|
MODULE* module = aPcb->m_Modules;
|
||||||
|
|
||||||
module = aPcb->m_Modules;
|
for( ; module; module = module->Next() )
|
||||||
|
|
||||||
for( ; module != NULL; module = (MODULE*) module->Next() )
|
|
||||||
listnames.Add( module->GetReference() );
|
listnames.Add( module->GetReference() );
|
||||||
|
|
||||||
msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() );
|
msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() );
|
||||||
|
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
|
|
||||||
headers.Add( _( "Module" ) );
|
headers.Add( _( "Module" ) );
|
||||||
|
|
||||||
std::vector<wxArrayString> itemsToDisplay;
|
std::vector<wxArrayString> itemsToDisplay;
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
// Conversion from wxArrayString to vector of ArrayString
|
||||||
for( unsigned i = 0; i < listnames.GetCount(); i++ )
|
for( unsigned i = 0; i < listnames.GetCount(); i++ )
|
||||||
{
|
{
|
||||||
wxArrayString item;
|
wxArrayString item;
|
||||||
|
|
||||||
item.Add( listnames[i] );
|
item.Add( listnames[i] );
|
||||||
itemsToDisplay.push_back( item );
|
itemsToDisplay.push_back( item );
|
||||||
}
|
}
|
||||||
|
@ -656,17 +660,17 @@ MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprint( BOARD* aPcb )
|
||||||
EDA_LIST_DIALOG dlg( this, msg, headers, itemsToDisplay, wxEmptyString, NULL, SORT_LIST );
|
EDA_LIST_DIALOG dlg( this, msg, headers, itemsToDisplay, wxEmptyString, NULL, SORT_LIST );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
CmpName = dlg.GetTextSelection();
|
fpname = dlg.GetTextSelection();
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
OldName = CmpName;
|
oldName = fpname;
|
||||||
|
|
||||||
module = aPcb->m_Modules;
|
module = aPcb->m_Modules;
|
||||||
|
|
||||||
for( ; module != NULL; module = (MODULE*) module->Next() )
|
for( ; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
if( CmpName == module->GetReference() )
|
if( fpname == module->GetReference() )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,9 @@ void SELECTION_TOOL::Reset()
|
||||||
|
|
||||||
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
|
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
BOARD* board = getModel<BOARD>( PCB_T );
|
VIEW* view = getView();
|
||||||
VIEW* view = getView();
|
|
||||||
assert( board != NULL );
|
assert( getModel<BOARD>( PCB_T ) != NULL );
|
||||||
|
|
||||||
view->Add( m_selection.group );
|
view->Add( m_selection.group );
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ void SELECTION_TOOL::selectItem( BOARD_ITEM* aItem )
|
||||||
{
|
{
|
||||||
SELECTION& s;
|
SELECTION& s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
selectBase_( SELECTION& s_ ) : s( s_ ) {}
|
selectBase_( SELECTION& s_ ) : s( s_ ) {}
|
||||||
|
|
||||||
void operator()( BOARD_ITEM* item )
|
void operator()( BOARD_ITEM* item )
|
||||||
|
|
Loading…
Reference in New Issue