From ea06ad14ae0025445dac5b85c56132c573ec09ed Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 25 Sep 2014 09:07:17 +0200 Subject: [PATCH] Pcbnew: fix Bug #1373468 (Non Copper Zones Properties dialog "Layer selection" empty) (Linux specific) --- pcbnew/dialogs/dialog_copper_zones.cpp | 6 ++--- .../dialog_non_copper_zones_properties.cpp | 22 ++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 0162921dfd..f0215ff6c5 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -284,11 +284,11 @@ void DIALOG_COPPER_ZONE::initDialog() // unfortunately this option does not work well both on // wxWidgets 2.8 ( column witdth too small), and // wxWidgets 2.9 ( column witdth too large) - ctrlWidth += LAYER_BITMAP_SIZE_X + 16; // Add bitmap width + margin between bitmap and text + ctrlWidth += LAYER_BITMAP_SIZE_X + 25; // Add bitmap width + margin between bitmap and text m_LayerSelectionCtrl->SetColumnWidth( 0, ctrlWidth ); - ctrlWidth += 4; // add small margin between text and window borders - + ctrlWidth += 25; // add small margin between text and window borders + // and room for vertical scroll bar m_LayerSelectionCtrl->SetMinSize( wxSize( ctrlWidth, -1 ) ); wxString netNameDoNotShowFilter = wxT( "Net-*" ); diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index 1108a03059..ed8c8412b0 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -143,13 +143,15 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::Init() wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y ); m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL ); - int ii = 0; int lyrSelect = ( (PCB_SCREEN*) m_parent->GetScreen() )->m_Active_Layer; if( m_zone ) lyrSelect = m_zone->GetLayer(); - for( LSEQ seq = LSET::AllNonCuMask().Seq(); seq; ++seq, ++ii ) + int ctrlWidth = 0; // Min width for m_LayerSelectionCtrl to show the layers names + int imgIdx = 0; + + for( LSEQ seq = LSET::AllNonCuMask().Seq(); seq; ++seq, ++imgIdx ) { LAYER_ID layer = *seq; @@ -160,11 +162,25 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::Init() msg.Trim(); int itemIndex = m_LayerSelectionCtrl->InsertItem( - m_LayerSelectionCtrl->GetItemCount(), msg, ii ); + m_LayerSelectionCtrl->GetItemCount(), msg, imgIdx ); if(lyrSelect == layer ) m_LayerSelectionCtrl->Select( itemIndex ); + + wxSize tsize( GetTextSize( msg, m_LayerSelectionCtrl ) ); + ctrlWidth = std::max( ctrlWidth, tsize.x ); } + + // The most easy way to ensure the right size is to use wxLIST_AUTOSIZE + // unfortunately this option does not work well both on + // wxWidgets 2.8 ( column witdth too small), and + // wxWidgets 2.9 ( column witdth too large) + ctrlWidth += LAYER_BITMAP_SIZE_X + 25; // Add bitmap width + margin between bitmap and text + m_LayerSelectionCtrl->SetColumnWidth( 0, ctrlWidth ); + + ctrlWidth += 25; // add small margin between text and window borders + // and room for vertical scroll bar + m_LayerSelectionCtrl->SetMinSize( wxSize( ctrlWidth, -1 ) ); }