From 96849d5a112504efca4f6ac203a32479a455fa85 Mon Sep 17 00:00:00 2001 From: charras Date: Sat, 19 Dec 2009 16:10:25 +0000 Subject: [PATCH] code cleaning --- common/copy_to_clipboard.cpp | 4 +- common/drawframe.cpp | 7 +-- common/drawpanel.cpp | 53 ++++++++++--------- .../dialog_edit_component_in_schematic.cpp | 3 +- eeschema/find.cpp | 12 ++--- eeschema/libframe.cpp | 4 +- eeschema/schedit.cpp | 4 +- eeschema/symbdraw.cpp | 10 ---- eeschema/tool_sch.cpp | 4 +- eeschema/viewlibs.cpp | 5 +- gerbview/edit.cpp | 7 +-- include/class_drawpanel.h | 8 ++- pcbnew/automove.cpp | 4 +- pcbnew/dialog_general_options.cpp | 8 +-- pcbnew/edit.cpp | 3 +- pcbnew/export_gencad.cpp | 4 +- pcbnew/files.cpp | 6 +-- pcbnew/globaleditpad.cpp | 3 +- pcbnew/modedit.cpp | 3 +- pcbnew/modedit_onclick.cpp | 7 +-- pcbnew/modeditoptions.cpp | 14 ++--- pcbnew/muwave_command.cpp | 4 +- pcbnew/onleftclick.cpp | 19 +++---- pcbnew/pcbnew_config.cpp | 4 +- pcbnew/surbrill.cpp | 4 +- 25 files changed, 75 insertions(+), 129 deletions(-) diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index f0425110ae..4e2ba3f1d5 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -39,9 +39,7 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event ) if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) { - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); } } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index d8732ef762..63cb9d9e95 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -340,9 +340,7 @@ void WinEDA_DrawFrame::ReDrawPanel() if( DrawPanel == NULL ) return; - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); DrawPanel->ReDraw( &dc ); } @@ -599,9 +597,8 @@ void WinEDA_DrawFrame::AdjustScrollBars() int x, y, scroll_x, scroll_y; double scale_x, scale_y; - wxClientDC DC( this ); + DrawPanel DC( this ); - DrawPanel->PrepareGraphicContext( &DC ); x = DC.LogicalToDeviceXRel( draw_size.GetWidth() ); y = DC.LogicalToDeviceYRel( draw_size.GetHeight() ); diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 1e49ad2cf3..b61d4ef99f 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -16,6 +16,26 @@ #define CURSOR_SIZE 12 // Cursor size in pixels +// Helper class to handle the client Device Context +KicadGraphicContext::KicadGraphicContext( WinEDA_DrawPanel * aDrawPanel ) + : wxClientDC(aDrawPanel) +{ + GRResetPenAndBrush( this ); + SetBackgroundMode( wxTRANSPARENT ); +#ifdef WX_ZOOM + double scale = aDrawPanel->GetScreen()->GetScalingFactor(); + SetUserScale( scale, scale ); + wxPoint origin = aDrawPanel->GetScreen()->m_DrawOrg; + SetLogicalOrigin( origin.x, origin.y ); +#endif + aDrawPanel->SetBoundaryBox(); +} + +KicadGraphicContext::~KicadGraphicContext( ) +{ +} + + /* Used to inhibit a response to a mouse left button release, after a * double click (when releasing the left button at the end of the second * click. Used in eeschema to inhibit a mouse left release command when @@ -172,19 +192,6 @@ wxRealPoint WinEDA_DrawPanel::GetGrid() } -void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) -{ - GRResetPenAndBrush( DC ); - DC->SetBackgroundMode( wxTRANSPARENT ); -#ifdef WX_ZOOM - double scale = GetScreen()->GetScalingFactor(); - DC->SetUserScale( scale, scale ); - wxPoint origin = GetScreen()->m_DrawOrg; - DC->SetLogicalOrigin( origin.x, origin.y ); -#endif - SetBoundaryBox(); -} - /** Calculate the cursor position in internal units. * @return position (in internal units) @@ -194,8 +201,8 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) { #ifdef WX_ZOOM wxCoord x, y; - wxClientDC DC( this ); - PrepareGraphicContext( &DC ); + KicadGraphicContext DC( this ); + x = DC.DeviceToLogicalX( ScreenPos.x ); y = DC.DeviceToLogicalY( ScreenPos.y ); return wxPoint( x, y ); @@ -304,8 +311,8 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition() { #ifdef WX_ZOOM wxCoord x, y; - wxClientDC DC( this ); - PrepareGraphicContext( &DC ); + KicadGraphicContext DC( this ); + x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x ); y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y ); return wxPoint( x, y ); @@ -332,8 +339,7 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) GetScreen()->Unscale( realpos ); #ifdef WX_ZOOM // wxCoord x, y; -// wxClientDC DC( this ); -// PrepareGraphicContext( &DC ); +// KicadGraphicContext DC( this ); // realpos.x = DC.DeviceToLogicalX( realpos.x ); // realpos.y = DC.DeviceToLogicalY( realpos.y ); #else @@ -567,7 +573,6 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) wxRect PaintClipBox; wxPoint org; - PrepareGraphicContext( &paintDC ); tmp = m_ClipBox; org = m_ClipBox.GetOrigin(); @@ -1010,11 +1015,11 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) screen->m_MousePosition = CursorRealPosition( screen->m_MousePositionInPixels ); - wxClientDC DC( this ); + KicadGraphicContext DC( this ); + int kbstat = 0; DC.SetBackground( *wxBLACK_BRUSH ); - PrepareGraphicContext( &DC ); g_KeyPressed = localkey; @@ -1259,10 +1264,10 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) if( event.ShiftDown() && (key > 256) ) localkey |= GR_KB_SHIFT; - wxClientDC DC( this ); + KicadGraphicContext DC( this ); + BASE_SCREEN* Screen = GetScreen(); - PrepareGraphicContext( &DC ); g_KeyPressed = localkey; diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp index 1430e54a7d..2311426c5e 100644 --- a/eeschema/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -722,8 +722,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) if( entry == NULL ) return; - wxClientDC dc( m_Parent->DrawPanel ); - m_Parent->DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( m_Parent->DrawPanel ); RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 0076b3f143..9b7a99ff82 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -179,9 +179,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindComponentAndItem( Recadre_Trace( mouseWarp ); else { - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOff( &dc ); @@ -356,9 +354,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType ) Recadre_Trace( TRUE ); else { - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOff( &dc ); DrawPanel->MouseTo( curpos ); @@ -581,9 +577,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( const wxString& pattern, Recadre_Trace( mouseWarp ); else { - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur ); DrawPanel->CursorOff( &dc ); diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp index 1b6644b453..20e614254f 100644 --- a/eeschema/libframe.cpp +++ b/eeschema/libframe.cpp @@ -604,12 +604,10 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) int id = event.GetId(); wxPoint pos; - wxClientDC dc( DrawPanel ); + KicadGraphicContext dc( DrawPanel ); DrawPanel->m_IgnoreMouseEvents = true; - DrawPanel->PrepareGraphicContext( &dc ); - wxGetMousePosition( &pos.x, &pos.y ); pos.y += 20; diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 0fdd2d0b08..65fe548906 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -22,11 +22,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); wxPoint pos; - wxClientDC dc( DrawPanel ); + KicadGraphicContext dc( DrawPanel ); SCH_SCREEN* screen = GetScreen(); - DrawPanel->PrepareGraphicContext( &dc ); - pos = wxGetMousePosition(); pos.y += 20; diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 2351044336..0409935126 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -72,13 +72,6 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) if( !( DrawItem->m_Flags & IS_NEW ) ) SaveCopyInUndoList( DrawItem->GetParent() ); - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); - - DrawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, - NULL, DefaultTransformMatrix ); - if( m_drawSpecificUnit ) DrawItem->m_Unit = GetUnit(); else @@ -98,9 +91,6 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) component->GetDrawItemList().sort(); GetScreen()->SetModify(); - DrawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, - NULL, DefaultTransformMatrix ); - DrawItem->DisplayInfo( this ); DrawPanel->Refresh(); } diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index 9a8726803f..6e8064b2c2 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -287,9 +287,7 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event ) return; int id = event.GetId(); - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); switch( id ) { diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index 99f0084366..81d1aa1571 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -189,9 +189,6 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ) int NumOfParts = 0; CMP_LIB_ENTRY* LibEntry; wxString CmpName; - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); if( Lib ) NumOfParts = Lib->GetCount(); @@ -234,7 +231,7 @@ void WinEDA_ViewlibFrame::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ) m_entryName = CmpName; DisplayLibInfos(); Zoom_Automatique( false ); - RedrawActiveWindow( &dc, true ); + DrawPanel->Refresh( ); if( m_CmpList ) { diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index a48c25b1e5..7290fe8948 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -75,9 +75,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) int layer = GetScreen()->m_Active_Layer; GERBER* gerber_layer = g_GERBER_List[layer]; wxPoint pos; - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); wxGetMousePosition( &pos.x, &pos.y ); @@ -263,9 +261,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) { EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); switch( m_ID_current_state ) { diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 7bcb4c0a12..aedf34b154 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -75,7 +75,6 @@ public: BASE_SCREEN* GetScreen(); - void PrepareGraphicContext( wxDC* DC ); bool IsPointOnDisplay( wxPoint ref_pos ); void OnPaint( wxPaintEvent& event ); void OnSize( wxSizeEvent& event ); @@ -181,5 +180,12 @@ public: DECLARE_EVENT_TABLE() }; +// Helper class to handle the client Device Context +class KicadGraphicContext : public wxClientDC +{ +public: + KicadGraphicContext( WinEDA_DrawPanel * aDrawPanel ); + ~KicadGraphicContext(); +}; #endif /* #ifndef PANEL_WXSTRUCT_H */ diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index f8263f334b..5c5e6a709b 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -36,14 +36,12 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) { int id = event.GetId(); wxPoint pos; - wxClientDC dc( DrawPanel ); + KicadGraphicContext dc( DrawPanel ); bool on_state; if( m_HToolBar == NULL ) return; - DrawPanel->PrepareGraphicContext( &dc ); - wxGetMousePosition( &pos.x, &pos.y ); switch( id ) diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index c01610b00e..49cf05115f 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -169,12 +169,8 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event ) case ID_TB_OPTIONS_SHOW_RATSNEST: g_Show_Ratsnest = m_OptionsToolBar->GetToolState( id ); - { - wxClientDC dc( DrawPanel ); - DrawPanel->PrepareGraphicContext( &dc ); - Ratsnest_On_Off( &dc ); - RedrawActiveWindow( &dc, true ); - } + Ratsnest_On_Off( NULL ); + DrawPanel->Refresh( ); break; case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST: diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 997a6d3881..a8f72141f5 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -32,8 +32,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) wxPoint pos; int itmp; - wxClientDC dc( DrawPanel ); - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); BOARD_ITEM* DrawStruct = GetCurItem(); DrawPanel->CursorOff( &dc ); diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index af5758d283..32abd33cd5 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -91,9 +91,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) offsetX = m_Auxiliary_Axis_Position.x; offsetY = m_Auxiliary_Axis_Position.y; - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); Compile_Ratsnest( &dc, TRUE ); /* Temporary modification of footprints that are flipped (i.e. on bottom diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index feba1eca57..cce8984e79 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -17,7 +17,7 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event ) { wxString fn; - wxClientDC dc( DrawPanel ); + KicadGraphicContext dc( DrawPanel ); fn = GetFileFromHistory( event.GetId(), _( "Printed circuit board" ) ); @@ -25,7 +25,6 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event ) { if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) { - DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); } @@ -52,8 +51,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event ) // If an edition is in progress, stop it if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) { - wxClientDC dc( DrawPanel ); - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); } SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 9e103e537e..43293f4fc6 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -80,9 +80,8 @@ void DIALOG_GLOBAL_PADS_EDITION::OnCancelClick( wxCommandEvent& event ) */ void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event ) { - wxClientDC dc( m_Parent->DrawPanel ); + KicadGraphicContext dc( m_Parent->DrawPanel ); - m_Parent->DrawPanel->PrepareGraphicContext( &dc ); m_Parent->DrawPanel->CursorOff( &dc ); m_Parent->InstallPadOptionsFrame( m_CurrentPad, &dc, wxDefaultPosition ); m_Parent->DrawPanel->CursorOn( &dc ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 53791daf34..7fdfe9114f 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -147,9 +147,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) wxPoint pos; bool redraw = false; - wxClientDC dc( DrawPanel ); + KicadGraphicContext dc( DrawPanel ); - DrawPanel->PrepareGraphicContext( &dc ); wxGetMousePosition( &pos.x, &pos.y ); pos.y += 20; diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 2450a91d64..0374ae11df 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -382,9 +382,6 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) { BOARD_ITEM* DrawStruct = GetCurItem(); wxPoint pos = GetPosition(); - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); switch( m_ID_current_state ) { @@ -403,7 +400,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) switch( DrawStruct->Type() ) { case TYPE_PAD: - InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos ); + InstallPadOptionsFrame( (D_PAD*) DrawStruct, DC, pos ); DrawPanel->MouseToCursorSchema(); break; @@ -420,7 +417,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) break; case TYPE_TEXTE_MODULE: - InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc ); + InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, DC ); DrawPanel->MouseToCursorSchema(); break; diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp index f0fc785140..3d4deecc67 100644 --- a/pcbnew/modeditoptions.cpp +++ b/pcbnew/modeditoptions.cpp @@ -18,15 +18,12 @@ void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event ) { int id = event.GetId(); - wxClientDC dc( DrawPanel ); - DrawPanel->CursorOff( &dc ); - DrawPanel->PrepareGraphicContext( &dc ); switch( id ) { case ID_TB_OPTIONS_SHOW_GRID: m_Draw_Grid = m_OptionsToolBar->GetToolState( id ); - DrawPanel->ReDraw( &dc, TRUE ); + DrawPanel->Refresh( ); break; case ID_TB_OPTIONS_SELECT_UNIT_MM: @@ -51,24 +48,24 @@ void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event ) case ID_TB_OPTIONS_SHOW_PADS_SKETCH: m_DisplayPadFill = !m_OptionsToolBar->GetToolState( id ); - DrawPanel->ReDraw( &dc, TRUE ); + DrawPanel->Refresh( ); break; case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: m_DisplayViaFill = !m_OptionsToolBar->GetToolState( id ); - DrawPanel->ReDraw( &dc, TRUE ); + DrawPanel->Refresh( ); break; case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: m_DisplayModText = m_OptionsToolBar->GetToolState( id ) ? SKETCH : FILLED; - DrawPanel->ReDraw( &dc, TRUE ); + DrawPanel->Refresh( ); break; case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: m_DisplayModEdge = m_OptionsToolBar->GetToolState( id ) ? SKETCH : FILLED; - DrawPanel->ReDraw( &dc, TRUE ); + DrawPanel->Refresh( ); break; default: @@ -78,5 +75,4 @@ void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event ) } SetToolbars(); - DrawPanel->CursorOn( &dc ); } diff --git a/pcbnew/muwave_command.cpp b/pcbnew/muwave_command.cpp index eab3bb56f3..aeb927fddd 100644 --- a/pcbnew/muwave_command.cpp +++ b/pcbnew/muwave_command.cpp @@ -20,9 +20,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event ) { int id = event.GetId(); wxPoint pos; - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); wxGetMousePosition( &pos.x, &pos.y ); diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index b8349fc8ee..23ab564e0a 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -388,9 +388,6 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) { BOARD_ITEM* DrawStruct = GetCurItem(); wxPoint pos = GetPosition(); - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); switch( m_ID_current_state ) { @@ -429,38 +426,38 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) break; case TYPE_PAD: - InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos ); + InstallPadOptionsFrame( (D_PAD*) DrawStruct, DC, pos ); DrawPanel->MouseToCursorSchema(); break; case TYPE_MODULE: - InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc ); + InstallModuleOptionsFrame( (MODULE*) DrawStruct, DC ); DrawPanel->MouseToCursorSchema(); break; case TYPE_MIRE: - InstallMireOptionsFrame( (MIREPCB*) DrawStruct, &dc, pos ); + InstallMireOptionsFrame( (MIREPCB*) DrawStruct, DC, pos ); DrawPanel->MouseToCursorSchema(); break; case TYPE_COTATION: - Install_Edit_Cotation( (COTATION*) DrawStruct, &dc, pos ); + Install_Edit_Cotation( (COTATION*) DrawStruct, DC, pos ); DrawPanel->MouseToCursorSchema(); break; case TYPE_TEXTE_MODULE: - InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc ); + InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, DC ); DrawPanel->MouseToCursorSchema(); break; case TYPE_DRAWSEGMENT: - InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) DrawStruct, &dc ); + InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) DrawStruct, DC ); break; case TYPE_ZONE_CONTAINER: if( DrawStruct->m_Flags ) break; - Edit_Zone_Params( &dc, (ZONE_CONTAINER*) DrawStruct ); + Edit_Zone_Params( DC, (ZONE_CONTAINER*) DrawStruct ); break; default: @@ -498,7 +495,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) } if( (DrawStruct->m_Flags & IS_NEW) ) { - End_Edge( (DRAWSEGMENT*) DrawStruct, &dc ); + End_Edge( (DRAWSEGMENT*) DrawStruct, DC ); DrawPanel->m_AutoPAN_Request = false; SetCurItem( NULL ); } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 9c490f4e3d..52ad64a0b9 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -30,12 +30,10 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) int id = event.GetId(); wxPoint pos; - wxClientDC dc( DrawPanel ); + KicadGraphicContext dc( DrawPanel ); wxFileName fn; - DrawPanel->PrepareGraphicContext( &dc ); - pos = GetPosition(); pos.x += 20; pos.y += 20; diff --git a/pcbnew/surbrill.cpp b/pcbnew/surbrill.cpp index 4806b83a9d..987cb296c4 100644 --- a/pcbnew/surbrill.cpp +++ b/pcbnew/surbrill.cpp @@ -72,9 +72,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event ) if( found ) { - wxClientDC dc( DrawPanel ); - - DrawPanel->PrepareGraphicContext( &dc ); + KicadGraphicContext dc( DrawPanel ); if( g_HightLigt_Status ) Hight_Light( &dc );