Commit 56615d16 authored by Dick Hollenbeck's avatar Dick Hollenbeck

FIX: work around for wx 2.8 bug affecting wxListCtrl column resizing.

parent 96c2bee8
...@@ -56,15 +56,39 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl ...@@ -56,15 +56,39 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
InsertItems( aItemList, 0 ); InsertItems( aItemList, 0 );
for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
m_listBox->SetColumnWidth( i, wxLIST_AUTOSIZE );
if( m_callBackFct == NULL ) if( m_callBackFct == NULL )
{ {
m_messages->Show( false ); m_messages->Show( false );
m_staticTextMsg->Show( false ); m_staticTextMsg->Show( false );
} }
for( unsigned col = 0; col < aItemHeaders.Count(); ++col )
{
m_listBox->SetColumnWidth( col, wxLIST_AUTOSIZE );
#if !wxCHECK_VERSION( 2, 9, 0 )
// include the column header in the width decision, wx 2.8 forgets this:
wxListItem col_info;
m_listBox->GetColumn( col, col_info );
wxString header = col_info.GetText();
int headerz = GetTextSize( header, m_listBox ).x;
// A reasonable column header has about 14 pixels of whitespace
// in addition to the width of the text itself.
headerz += 14;
if( headerz > col_info.GetWidth() )
{
col_info.SetWidth( headerz );
m_listBox->SetColumn( col, col_info );
}
#endif
}
#if !wxCHECK_VERSION( 2, 9, 0 ) #if !wxCHECK_VERSION( 2, 9, 0 )
// wx 2.8.x has bug in wxListCtrl WRT honoring the omission of wxHSCROLL, at least // wx 2.8.x has bug in wxListCtrl WRT honoring the omission of wxHSCROLL, at least
// on gtk2. Fix by setting minimum width so horizontal wxListCtrl scrolling is // on gtk2. Fix by setting minimum width so horizontal wxListCtrl scrolling is
...@@ -77,8 +101,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl ...@@ -77,8 +101,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
width += m_listBox->GetColumnWidth( col ) + 2; width += m_listBox->GetColumnWidth( col ) + 2;
} }
//width += 40; // vert scroll bar.
wxSize sz = m_listBox->GetSize(); wxSize sz = m_listBox->GetSize();
sz.SetWidth( width ); sz.SetWidth( width );
...@@ -112,11 +134,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl ...@@ -112,11 +134,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
} }
EDA_LIST_DIALOG::~EDA_LIST_DIALOG()
{
}
void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
{ {
wxString filter; wxString filter;
...@@ -143,22 +160,24 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) ...@@ -143,22 +160,24 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn ) wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
{ {
wxCHECK_MSG( aColumn < m_listBox->GetColumnCount(), wxEmptyString, wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString,
wxT( "Invalid list control column." ) ); wxT( "Invalid list control column." ) );
long item = m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
if( item >= 0 ) // if something is selected.
{
wxListItem info; wxListItem info;
wxString text;
long item = -1;
item = m_listBox->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
info.m_mask = wxLIST_MASK_TEXT; info.m_mask = wxLIST_MASK_TEXT;
info.m_itemId = item; info.m_itemId = item;
info.m_col = aColumn; info.m_col = aColumn;
if( !m_listBox->GetItem( info ) ) if( m_listBox->GetItem( info ) )
return wxEmptyString;
return info.m_text; return info.m_text;
}
return wxEmptyString;
} }
......
...@@ -74,7 +74,8 @@ public: ...@@ -74,7 +74,8 @@ public:
const wxString& aRefText, const wxString& aRefText,
void(*aCallBackFunction)(wxString& Text) = NULL, void(*aCallBackFunction)(wxString& Text) = NULL,
bool aSortList = false ); bool aSortList = false );
~EDA_LIST_DIALOG();
// ~EDA_LIST_DIALOG() {}
void Append( const wxArrayString& aItemStr ); void Append( const wxArrayString& aItemStr );
void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 ); void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment