From 75d2dc731142055212dc126bcd369f0f2d583d38 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 28 Feb 2012 21:14:17 +0100 Subject: [PATCH] Pcbnew: Hight contrast mode: commit last patch from Miguel Angel Ajo Pelayo, which also fixes an old bug. All: prepare better compatibility with wxWidgets 2.9.4. Works fine with 2.8.x (I hope...) --- common/block_commande.cpp | 2 +- common/copy_to_clipboard.cpp | 2 +- eeschema/block.cpp | 2 +- eeschema/netlist_control.cpp | 6 +++--- eeschema/schedit.cpp | 2 +- eeschema/symbdraw.cpp | 2 +- gerbview/dialogs/dialog_print_using_printer.cpp | 4 ++-- gerbview/events_called_functions.cpp | 2 +- include/gr_basic.h | 1 + include/xnode.h | 5 +++++ pcbnew/class_drawsegment.cpp | 12 ++++++++++++ pcbnew/class_edge_mod.cpp | 14 ++++++++++++++ pcbnew/class_pad_draw_functions.cpp | 10 +++++++--- pcbnew/class_track.cpp | 2 +- pcbnew/edit.cpp | 2 +- pcbnew/find.cpp | 3 +-- pcbnew/tracepcb.cpp | 2 +- 17 files changed, 54 insertions(+), 19 deletions(-) diff --git a/common/block_commande.cpp b/common/block_commande.cpp index b0254615cc..0684106b5d 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -330,5 +330,5 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* Panel, wxDC* DC ) screen->m_BlockLocate.m_Command = BLOCK_IDLE; Panel->GetParent()->DisplayToolMsg( wxEmptyString ); - Panel->SetCursor( Panel->GetCurrentCursor() ); + Panel->SetCursor( (wxStockCursor) Panel->GetCurrentCursor() ); } diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index ad9225b1b0..e09e2a83a1 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -46,7 +46,7 @@ void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event ) if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD ) { if( GetScreen()->IsBlockActive() ) - m_canvas->SetCursor( wxCursor( m_canvas->GetDefaultCursor() ) ); + m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) ); m_canvas->EndMouseCapture(); } diff --git a/eeschema/block.cpp b/eeschema/block.cpp index d62b4d74bf..110fc7bdb6 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -399,7 +399,7 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) case BLOCK_ZOOM: /* Window Zoom */ m_canvas->CallEndMouseCapture( DC ); - m_canvas->SetCursor( m_canvas->GetDefaultCursor() ); + m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ); Window_Zoom( GetScreen()->m_BlockLocate ); break; diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index a0d5c98ab8..c95244c35d 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -299,7 +299,7 @@ void NETLIST_DIALOG::InstallPageSpice() page->m_LeftBoxSizer->Add( page->m_NetOption, 0, wxGROW | wxALL, 5 ); page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); page->m_CommandStringCtrl = new wxTextCtrl( page, -1, m_Parent->GetSimulatorCommand(), wxDefaultPosition, wxDefaultSize ); @@ -374,7 +374,7 @@ void NETLIST_DIALOG::InstallCustomPages() CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage, -1, _( "Netlist command:" ) ), 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); CurrPage->m_CommandStringCtrl = new wxTextCtrl( CurrPage, -1, Command, wxDefaultPosition, wxDefaultSize ); @@ -387,7 +387,7 @@ void NETLIST_DIALOG::InstallCustomPages() CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage, -1, _( "Title:" ) ), 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); + wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); CurrPage->m_TitleStringCtrl = new wxTextCtrl( CurrPage, -1, title, wxDefaultPosition, wxDefaultSize ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 3f44b9ef34..fefb19b17f 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -437,7 +437,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) if( screen->IsBlockActive() ) { - m_canvas->SetCursor( wxCursor( m_canvas->GetDefaultCursor() ) ); + m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ); screen->ClearBlockCommand(); // Stop the current command (if any) but keep the current tool diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index a751de1159..6936e18d68 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -333,7 +333,7 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC ) if( GetToolId() != ID_NO_TOOL_SELECTED ) SetCursor( wxCURSOR_PENCIL ); else - SetCursor( m_canvas->GetDefaultCursor() ); + SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ); if( GetTempCopyComponent() ) // used when editing an existing item SaveCopyInUndoList( GetTempCopyComponent() ); diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index 636e891d16..e4928cc749 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -161,10 +161,10 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) m_BoxSelectLayer[ii]->SetValue( true ); if( ii < 16 ) m_leftLayersBoxSizer->Add( m_BoxSelectLayer[ii], - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE ); + wxGROW | wxLEFT | wxRIGHT | wxTOP ); else m_rightLayersBoxSizer->Add( m_BoxSelectLayer[ii], - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE ); + wxGROW | wxLEFT | wxRIGHT | wxTOP ); } diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 410ec6ac2d..d284747179 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -140,7 +140,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( GetToolId() == ID_NO_TOOL_SELECTED ) SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); else - m_canvas->SetCursor( m_canvas->GetCurrentCursor() ); + m_canvas->SetCursor( (wxStockCursor) m_canvas->GetCurrentCursor() ); break; default: diff --git a/include/gr_basic.h b/include/gr_basic.h index d7c9925ad4..ce0b607669 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -41,6 +41,7 @@ class EDA_RECT; #define GR_AND 0x04000000 #define GR_NXOR 0x08000000 #define GR_INVERT 0x10000000 +#define GR_ALLOW_HIGHCONTRAST 0x20000000 #define GR_HIGHLIGHT 0x80000000 diff --git a/include/xnode.h b/include/xnode.h index 3b7fc38a0a..ed58bdb779 100644 --- a/include/xnode.h +++ b/include/xnode.h @@ -34,6 +34,9 @@ #include +#if wxCHECK_VERSION( 2, 9, 0 ) +#define wxXmlProperty wxXmlAttribute +#endif /** * Class XNODE @@ -78,6 +81,7 @@ public: */ virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) throw( IO_ERROR ); +#if !wxCHECK_VERSION( 2, 9, 0 ) // The following functions did not appear in the base class until recently. // Overload them even if they are present in base class, just to make sure // they are present in any older base class implementation. @@ -101,6 +105,7 @@ public: } //------------------------------------------------------------- +#endif }; #endif // _XATTR_H_ diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 7959322247..5dc0e7447b 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -189,6 +190,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx int l_trace; int color, mode; int radius; + int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD * brd = GetBoard( ); @@ -197,6 +199,16 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx color = brd->GetLayerColor( GetLayer() ); + if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) + { + if( !IsOnLayer( curr_layer ) ) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + + GRSetDrawMode( DC, draw_mode ); l_trace = m_Width >> 1; /* half trace width */ diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 2455224d34..4d168a6fe9 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ #include #include +#include EDGE_MODULE::EDGE_MODULE( MODULE* parent, STROKE_T aShape ) : DRAWSEGMENT( parent, PCB_MODULE_EDGE_T ) @@ -97,12 +99,14 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx int ux0, uy0, dx, dy, radius, StAngle, EndAngle; int color, type_trace; int typeaff; + int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; PCB_BASE_FRAME* frame; MODULE* module = (MODULE*) m_Parent; if( module == NULL ) return; + BOARD * brd = GetBoard( ); if( brd->IsLayerVisible( m_Layer ) == false ) @@ -110,6 +114,16 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx color = brd->GetLayerColor( m_Layer ); + if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) + { + if( !IsOnLayer( curr_layer ) ) + { + color &= ~MASKCOLOR; + color |= DARKDARKGRAY; + } + } + + frame = (PCB_BASE_FRAME*) panel->GetParent(); type_trace = m_Shape; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 828d4525dd..d314148b43 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -234,7 +234,9 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi } // if PAD_SMD pad and high contrast mode - if( ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && DisplayOpt.ContrastModeDisplay ) + if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && + ( GetAttribute() == PAD_SMD || GetAttribute() == PAD_CONN ) && + DisplayOpt.ContrastModeDisplay ) { // when routing tracks if( frame && frame->GetToolId() == ID_TRACK_BUTT ) @@ -301,7 +303,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi // if Contrast mode is ON and a technical layer active, show pads on this // layer so we can see pads on paste or solder layer and the size of the // mask - if( DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER ) + if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && + DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER ) { if( IsOnLayer( screen->m_Active_Layer ) ) { @@ -373,7 +376,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi // Display net names is restricted to pads that are on the active layer // in hight contrast mode display - if( !IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay ) + if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) && + !IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay ) drawInfo.m_Display_netname = false; DrawShape( aPanel->GetClipBox(), aDC, drawInfo ); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 743a9f2f19..626ee88cec 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -604,7 +604,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& return; #endif - if( DisplayOpt.ContrastModeDisplay ) + if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) { diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 34725ccc01..8190d503d2 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -160,7 +160,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( GetToolId() == ID_NO_TOOL_SELECTED ) SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); else - SetCursor( m_canvas->GetDefaultCursor() ); + SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ); break; diff --git a/pcbnew/find.cpp b/pcbnew/find.cpp index 1cf0ffaf76..0e75b9bfc3 100644 --- a/pcbnew/find.cpp +++ b/pcbnew/find.cpp @@ -240,8 +240,7 @@ void WinEDA_PcbFindFrame::CreateControls() 0 ); itemBoxSizer2->Add( itemStaticText3, 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, - 5 ); + wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_NewText = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index cfb277db69..2d05df8dc4 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -109,7 +109,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness ); - GetBoard()->Draw( m_canvas, DC, GR_OR ); + GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST); DrawGeneralRatsnest( DC );