Commit 9e46a779 authored by dickelbeck's avatar dickelbeck

SetToolbars() fixes

parent c25e5c31
...@@ -6,6 +6,18 @@ Please add newer entries at the top, list the date and your name with ...@@ -6,6 +6,18 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Apr-29 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
* Added WinEDA_PcbFrame::UpdateToolbarLayerInfo() by factoring it out of
ReCreateLayerBox().
* Changed call in void WinEDA_PcbFrame::SetToolbars() from ReCreateLayerBox()
to UpdateToolbarLayerInfo().
* Removed calls to SetToolbars() from:
> share/drawpanel.cpp's void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
> void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
2008-Apr-28 UPDATE Dick Hollenbeck <dick@softplc.com> 2008-Apr-28 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+pcbnew +pcbnew
......
...@@ -350,6 +350,14 @@ public: ...@@ -350,6 +350,14 @@ public:
void ReCreateOptToolbar(); void ReCreateOptToolbar();
void ReCreateMenuBar(); void ReCreateMenuBar();
WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent ); WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent );
/**
* Function UpdateToolbarLayerInfo
* updates the currently selected layer in the layer listbox and
* the colored icon in the toolbar.
*/
void UpdateToolbarLayerInfo();
void PrepareLayerIndicator(); void PrepareLayerIndicator();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
......
...@@ -660,6 +660,7 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -660,6 +660,7 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
RedrawActiveWindow( DC, TRUE ); RedrawActiveWindow( DC, TRUE );
} }
SetToolbars(); // SetToolbars();
Affiche_Status_Box(); /* Display new cursor coordinates */ Affiche_Status_Box(); /* Display new cursor coordinates */
} }
...@@ -315,6 +315,8 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) ...@@ -315,6 +315,8 @@ bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
Via->Display_Infos( this ); Via->Display_Infos( this );
Affiche_Status_Box(); Affiche_Status_Box();
D(printf("Other_Layer_Route\n");)
SetToolbars(); SetToolbars();
return true; return true;
......
...@@ -559,7 +559,8 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -559,7 +559,8 @@ void WinEDA_PcbFrame::SetToolbars()
} }
} }
ReCreateLayerBox( NULL ); UpdateToolbarLayerInfo();
PrepareLayerIndicator(); PrepareLayerIndicator();
DisplayUnitsMsg(); DisplayUnitsMsg();
......
...@@ -225,6 +225,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -225,6 +225,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_FilesMenu->Append( ID_LOAD_FILE_1 + ii, GetLastProject( ii ) ); m_FilesMenu->Append( ID_LOAD_FILE_1 + ii, GetLastProject( ii ) );
} }
D(printf("ReCreateHToolbar\n");)
SetToolbars(); SetToolbars();
return; return;
} }
...@@ -232,6 +233,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -232,6 +233,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE ); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
m_HToolBar->SetRows( 1 ); m_HToolBar->SetRows( 1 );
SetToolBar( m_HToolBar ); SetToolBar( m_HToolBar );
// Set up toolbar // Set up toolbar
...@@ -295,6 +297,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -295,6 +297,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
_( "Pcb Design Rules Check" ) ); _( "Pcb Design Rules Check" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
ReCreateLayerBox( m_HToolBar ); ReCreateLayerBox( m_HToolBar );
PrepareLayerIndicator(); // Initialise the bitmap with current active layer colors for the next tool PrepareLayerIndicator(); // Initialise the bitmap with current active layer colors for the next tool
m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString, *LayerPairBitmap, m_HToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString, *LayerPairBitmap,
...@@ -318,6 +321,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() ...@@ -318,6 +321,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar()
m_HToolBar->Realize(); m_HToolBar->Realize();
D(printf("ReCreateHToolbar\n");)
SetToolbars(); SetToolbars();
} }
...@@ -392,6 +396,7 @@ void WinEDA_PcbFrame::ReCreateOptToolbar() ...@@ -392,6 +396,7 @@ void WinEDA_PcbFrame::ReCreateOptToolbar()
m_OptionsToolBar->Realize(); m_OptionsToolBar->Realize();
D(printf("ReCreateOptToolbar\n");)
SetToolbars(); SetToolbars();
} }
...@@ -472,6 +477,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar() ...@@ -472,6 +477,7 @@ void WinEDA_PcbFrame::ReCreateVToolbar()
m_VToolBar->Realize(); m_VToolBar->Realize();
D(printf("ReCreateVToolbar\n");)
SetToolbars(); SetToolbars();
} }
...@@ -524,6 +530,7 @@ void WinEDA_PcbFrame::ReCreateAuxVToolbar() ...@@ -524,6 +530,7 @@ void WinEDA_PcbFrame::ReCreateAuxVToolbar()
m_AuxVToolBar->Realize(); m_AuxVToolBar->Realize();
D(printf("ReCreateAuxVToolbar\n");)
SetToolbars(); SetToolbars();
} }
...@@ -626,12 +633,38 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() ...@@ -626,12 +633,38 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
} }
/**************************************************************************/
void WinEDA_PcbFrame::UpdateToolbarLayerInfo()
/**************************************************************************/
{
wxASSERT( m_SelLayerBox );
// Activation de l'affichage sur la bonne couche
// Pour eviter la reentrance (Bug wxGTK version Linux?), la selection n'est faite que si
// elle est mauvaise (Pb corrige sur wxGTK 2.6.0)
int count = m_SelLayerBox->GetCount();
int choice = m_SelLayerBox->GetChoice();
int layer = GetScreen()->m_Active_Layer;
for( int listNdx=0; listNdx<count; ++listNdx )
{
if( (int) (size_t) m_SelLayerBox->GetClientData( listNdx ) == layer )
{
if( listNdx != choice )
m_SelLayerBox->SetSelection( listNdx );
break;
}
}
}
/**************************************************************************/ /**************************************************************************/
WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
/**************************************************************************/ /**************************************************************************/
{ {
int ii, jj, ll; // wxASSERT("ReCreateLayerBox"==""); // get a stack trace, who is calling me and from where
unsigned length = 0;
if( m_SelLayerBox == NULL ) if( m_SelLayerBox == NULL )
{ {
if( parent == NULL ) if( parent == NULL )
...@@ -658,30 +691,11 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ...@@ -658,30 +691,11 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
layer_mask |= ALL_NO_CU_LAYERS; layer_mask |= ALL_NO_CU_LAYERS;
unsigned length = 0;
// This is commented out because testing the number of layer is no longer
// sufficient since the layer names may also have changed. And the time
// required to test layer names is probably longer than the time required
// to simply reconstruct the list.
#if 0
// Test if reconstruction of the list is necessary
int current_layer_mask = 0;
for( ii = 0; ii < (int) m_SelLayerBox->GetCount(); ii++ )
{
jj = (int) ( (size_t) m_SelLayerBox->GetClientData( ii ) );
current_mask_layer |= g_TabOneLayerMask[jj];
}
bool rebuild = FALSE;
if( current_layer_mask != layer_mask )
rebuild = TRUE;
// Construction de la liste
if( rebuild )
#endif
{
m_SelLayerBox->Clear(); m_SelLayerBox->Clear();
int ii, jj;
for( ii = 0, jj = 0; ii <= EDGE_N; ii++ ) for( ii = 0, jj = 0; ii <= EDGE_N; ii++ )
{ {
// List to append hotkeys in layer box selection // List to append hotkeys in layer box selection
...@@ -715,27 +729,9 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent ) ...@@ -715,27 +729,9 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
} }
} }
// Test me:
// int lchar = m_SelLayerBox->GetFont().GetPointSize();
// m_SelLayerBox->SetSize(wxSize(length * lchar,-1));
m_SelLayerBox->SetToolTip( _( "+/- to switch" ) ); m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
}
// Activation de l'affichage sur la bonne couche UpdateToolbarLayerInfo();
// Pour eviter la reentrance (Bug wxGTK version Linux?), la selection n'est faite que si
// elle est mauvaise (Pb corrige sur wxGTK 2.6.0)
jj = m_SelLayerBox->GetCount();
ll = m_SelLayerBox->GetChoice();
for( ii = 0; ii < jj; ii++ )
{
if( (int) ( (size_t) m_SelLayerBox->GetClientData( ii ) ) == ((PCB_SCREEN*)GetScreen())->m_Active_Layer )
{
if( ii != ll )
m_SelLayerBox->SetSelection( ii );
break;
}
}
return m_SelLayerBox; return m_SelLayerBox;
} }
...@@ -1178,7 +1178,11 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1178,7 +1178,11 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#endif #endif
LastPanel = this; LastPanel = this;
/* @todo: move this to where it is really needed, obviously not here in
response to every mouse move event:
m_Parent->SetToolbars(); m_Parent->SetToolbars();
*/
} }
......
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