From 141d5b5f3cd40cdb7d60f00696ae97dcb3487b74 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 27 Jul 2010 14:47:08 +0200 Subject: [PATCH] fixed somes issues with wxWidgets 2.9.1 --- common/selcolor.cpp | 2 +- eeschema/eelayer.cpp | 2 +- eeschema/eelayer.h | 4 +-- gerbview/gerberframe.cpp | 61 ++++++++++++++++++++++------------------ gerbview/gerbview.cpp | 1 - gerbview/tool_gerber.cpp | 16 +++++++++-- pcbnew/tool_pcb.cpp | 10 +++++++ 7 files changed, 61 insertions(+), 35 deletions(-) diff --git a/common/selcolor.cpp b/common/selcolor.cpp index bf31eaee7a..8be6bd0e41 100644 --- a/common/selcolor.cpp +++ b/common/selcolor.cpp @@ -164,7 +164,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor ) iconDC.DrawRoundedRectangle( 0, 0, w, h, (double) h / 3 ); BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap, - wxDefaultPosition, wxSize( w, h ) ); + wxDefaultPosition, wxSize( w+8, h+6 ) ); FlexColumnBoxSizer->Add( BitmapButton, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxBOTTOM, 5 ); diff --git a/eeschema/eelayer.cpp b/eeschema/eelayer.cpp index ac125e0ec0..f09debc1e6 100644 --- a/eeschema/eelayer.cpp +++ b/eeschema/eelayer.cpp @@ -199,7 +199,7 @@ void WinEDA_SetColorsFrame::CreateControls() BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition, - wxSize( BUTT_SIZE_X, BUTT_SIZE_Y ) ); + wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) ); RowBoxSizer->Add( BitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, diff --git a/eeschema/eelayer.h b/eeschema/eelayer.h index 2f26d2efcd..b04091777f 100644 --- a/eeschema/eelayer.h +++ b/eeschema/eelayer.h @@ -38,8 +38,8 @@ enum col_sel_id { #endif // Specify the width and height of every (color-displaying / bitmap) button -const int BUTT_SIZE_X = 30; -const int BUTT_SIZE_Y = 20; +const int BUTT_SIZE_X = 16; +const int BUTT_SIZE_Y = 16; // Macro utile : #define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer]) diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index f901e9c785..35ee3d2b12 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -131,10 +131,13 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, m_show_layer_manager_tools = true; m_Draw_Axis = true; // true to show X and Y axis on screen - m_Draw_Sheet_Ref = FALSE; // TRUE for reference drawings. + m_Draw_Sheet_Ref = false; // true for reference drawings. m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr; + m_SelLayerBox = NULL; + m_SelLayerTool = NULL; + if( DrawPanel ) - DrawPanel->m_Block_Enable = TRUE; + DrawPanel->m_Block_Enable = true; // Give an icon #ifdef __WINDOWS__ @@ -238,7 +241,8 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) */ void WinEDA_GerberFrame::SetToolbars() { - int layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; + PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen(); + int layer = screen->m_Active_Layer; GERBER* gerber = g_GERBER_List[layer]; if( m_HToolBar == NULL ) @@ -246,40 +250,41 @@ void WinEDA_GerberFrame::SetToolbars() if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE ) { - m_HToolBar->EnableTool( wxID_CUT, TRUE ); - m_HToolBar->EnableTool( wxID_COPY, TRUE ); + m_HToolBar->EnableTool( wxID_CUT, true ); + m_HToolBar->EnableTool( wxID_COPY, true ); } else { - m_HToolBar->EnableTool( wxID_CUT, FALSE ); - m_HToolBar->EnableTool( wxID_COPY, FALSE ); + m_HToolBar->EnableTool( wxID_CUT, false ); + m_HToolBar->EnableTool( wxID_COPY, false ); } - if( m_SelLayerBox->GetSelection() != - ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ) + if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != screen->m_Active_Layer) ) { - m_SelLayerBox->SetSelection( - ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); + m_SelLayerBox->SetSelection( screen->m_Active_Layer ); } - if( gerber ) + if( m_SelLayerTool ) { - int sel_index; - m_SelLayerTool->Enable( TRUE ); - if( gerber->m_Selected_Tool < FIRST_DCODE ) // No tool selected - sel_index = 0; - else - sel_index = gerber->m_Selected_Tool - FIRST_DCODE + 1; - - if( sel_index != m_SelLayerTool->GetSelection() ) + if( gerber ) { - m_SelLayerTool->SetSelection( sel_index ); + int sel_index; + m_SelLayerTool->Enable( true ); + if( gerber->m_Selected_Tool < FIRST_DCODE ) // No tool selected + sel_index = 0; + else + sel_index = gerber->m_Selected_Tool - FIRST_DCODE + 1; + + if( sel_index != m_SelLayerTool->GetSelection() ) + { + m_SelLayerTool->SetSelection( sel_index ); + } + } + else + { + m_SelLayerTool->SetSelection( 0 ); + m_SelLayerTool->Enable( false ); } - } - else - { - m_SelLayerTool->SetSelection( 0 ); - m_SelLayerTool->Enable( FALSE ); } if( m_OptionsToolBar ) @@ -287,9 +292,9 @@ void WinEDA_GerberFrame::SetToolbars() m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, g_UserUnit == - MILLIMETRES ? TRUE : FALSE ); + MILLIMETRES ? true : false ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, - g_UserUnit == INCHES ? TRUE : FALSE ); + g_UserUnit == INCHES ? true : false ); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, DisplayOpt.DisplayPolarCood ); diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index ca995ded2e..5a8f681e69 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -105,7 +105,6 @@ bool WinEDA_App::OnInit() * main frame in order to display the * real hotkeys in menus or tool tips */ - frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); diff --git a/gerbview/tool_gerber.cpp b/gerbview/tool_gerber.cpp index c551e62789..130262cbcc 100644 --- a/gerbview/tool_gerber.cpp +++ b/gerbview/tool_gerber.cpp @@ -3,6 +3,8 @@ /***************************************************/ #include "fctsys.h" +#include "wx/wupdlock.h" + #include "appl_wxstruct.h" #include "common.h" #include "macros.h" @@ -16,6 +18,8 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void ) { + wxWindowUpdateLocker dummy(this); + wxMenuBar *menuBar = GetMenuBar(); /* Destroy the existing menu bar so it can be rebuilt. This allows @@ -143,6 +147,10 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) if( m_HToolBar != NULL ) return; + // we create m_SelLayerTool that have a lot of items, + // so create a wxWindowUpdateLocker is a good idea + wxWindowUpdateLocker dummy(this); + if( GetScreen() ) { layer = GetScreen()->m_Active_Layer; @@ -214,11 +222,12 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ID_TOOLBARH_GERBVIEW_SELECT_LAYER, wxDefaultPosition, wxSize( 150, -1 ), choices ); - m_SelLayerBox->SetSelection( getActiveLayer() ); m_HToolBar->AddControl( m_SelLayerBox ); m_HToolBar->AddSeparator(); choices.Clear(); + + choices.Alloc(MAX_TOOLS+1); choices.Add( _( "No tool" ) ); for( ii = 0; ii < MAX_TOOLS; ii++ ) @@ -227,7 +236,6 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) msg = _( "Tool " ); msg << ii + FIRST_DCODE; choices.Add( msg ); } - m_SelLayerTool = new WinEDAChoiceBox( m_HToolBar, ID_TOOLBARH_GERBER_SELECT_TOOL, wxDefaultPosition, wxSize( 150, -1 ), @@ -250,6 +258,8 @@ void WinEDA_GerberFrame::ReCreateVToolbar( void ) if( m_VToolBar ) return; + wxWindowUpdateLocker dummy(this); + m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE ); // Set up toolbar @@ -274,6 +284,8 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void ) if( m_OptionsToolBar ) return; + wxWindowUpdateLocker dummy(this); + // creation of tool bar options m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE ); diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index abc0b4c7ee..73c709b4a7 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -3,6 +3,7 @@ /***************************************/ #include "fctsys.h" +#include "wx/wupdlock.h" #include "common.h" #include "pcbnew.h" @@ -180,6 +181,7 @@ void WinEDA_PcbFrame::ReCreateHToolbar() return; } + wxWindowUpdateLocker dummy(this); m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, true ); m_HToolBar->SetRows( 1 ); @@ -295,6 +297,8 @@ void WinEDA_PcbFrame::ReCreateOptToolbar() if( m_OptionsToolBar ) return; + wxWindowUpdateLocker dummy(this); + m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE ); @@ -396,6 +400,8 @@ void WinEDA_PcbFrame::ReCreateVToolbar() if( m_VToolBar ) return; + wxWindowUpdateLocker dummy(this); + m_VToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE ); // Set up toolbar @@ -481,6 +487,8 @@ void WinEDA_PcbFrame::ReCreateMicrowaveVToolbar() if( m_AuxVToolBar ) return; + wxWindowUpdateLocker dummy(this); + m_AuxVToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this, ID_MICROWAVE_V_TOOLBAR, FALSE ); @@ -528,6 +536,8 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar() size_t i; wxString msg; + wxWindowUpdateLocker dummy(this); + if( m_AuxiliaryToolBar == NULL ) { m_AuxiliaryToolBar = new WinEDA_Toolbar( TOOLBAR_AUX, this,