Commit 0b41d484 authored by charras's avatar charras

code cleaning

parent c2ea4a0a
...@@ -37,11 +37,7 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event ) ...@@ -37,11 +37,7 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event )
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor ) ); DrawPanel->m_PanelDefaultCursor ) );
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) DrawPanel->UnManageCursor( );
{
KicadGraphicContext dc( DrawPanel );
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
} }
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "kicad_device_context.h"
#define CURSOR_SIZE 12 // Cursor size in pixels #define CURSOR_SIZE 12 // Cursor size in pixels
...@@ -69,6 +70,7 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, ...@@ -69,6 +70,7 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
wxBORDER | wxNO_FULL_REPAINT_ON_RESIZE ) wxBORDER | wxNO_FULL_REPAINT_ON_RESIZE )
{ {
m_Parent = parent; m_Parent = parent;
wxASSERT( m_Parent );
m_ScrollButt_unit = 40; m_ScrollButt_unit = 40;
SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red, SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
...@@ -201,7 +203,7 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) ...@@ -201,7 +203,7 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos )
{ {
#ifdef WX_ZOOM #ifdef WX_ZOOM
wxCoord x, y; wxCoord x, y;
KicadGraphicContext DC( this ); INSTALL_DC( DC, this );
x = DC.DeviceToLogicalX( ScreenPos.x ); x = DC.DeviceToLogicalX( ScreenPos.x );
y = DC.DeviceToLogicalY( ScreenPos.y ); y = DC.DeviceToLogicalY( ScreenPos.y );
...@@ -311,7 +313,7 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition() ...@@ -311,7 +313,7 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition()
{ {
#ifdef WX_ZOOM #ifdef WX_ZOOM
wxCoord x, y; wxCoord x, y;
KicadGraphicContext DC( this ); INSTALL_DC ( DC, this );
x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x ); x = DC.LogicalToDeviceX( GetScreen()->m_Curseur.x );
y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y ); y = DC.LogicalToDeviceY( GetScreen()->m_Curseur.y );
...@@ -339,7 +341,7 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) ...@@ -339,7 +341,7 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
GetScreen()->Unscale( realpos ); GetScreen()->Unscale( realpos );
#ifdef WX_ZOOM #ifdef WX_ZOOM
// wxCoord x, y; // wxCoord x, y;
// KicadGraphicContext DC( this ); // INSTALL_DC( DC, this );
// realpos.x = DC.DeviceToLogicalX( realpos.x ); // realpos.x = DC.DeviceToLogicalX( realpos.x );
// realpos.y = DC.DeviceToLogicalY( realpos.y ); // realpos.y = DC.DeviceToLogicalY( realpos.y );
#else #else
...@@ -567,7 +569,11 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -567,7 +569,11 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
// Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187 // Fix for pixel offset bug http://trac.wxwidgets.org/ticket/4187
paintDC.GetGraphicsContext()->Translate(0.5, 0.5); paintDC.GetGraphicsContext()->Translate(0.5, 0.5);
#else #else
#ifdef KICAD_USE_BUFFERED_DC
wxBufferedPaintDC paintDC( this );
#else
wxPaintDC paintDC( this ); wxPaintDC paintDC( this );
#endif
#endif #endif
EDA_Rect tmp; EDA_Rect tmp;
wxRect PaintClipBox; wxRect PaintClipBox;
...@@ -1015,7 +1021,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1015,7 +1021,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
screen->m_MousePosition = screen->m_MousePosition =
CursorRealPosition( screen->m_MousePositionInPixels ); CursorRealPosition( screen->m_MousePositionInPixels );
KicadGraphicContext DC( this ); INSTALL_DC( DC, this );
int kbstat = 0; int kbstat = 0;
...@@ -1264,7 +1270,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) ...@@ -1264,7 +1270,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
if( event.ShiftDown() && (key > 256) ) if( event.ShiftDown() && (key > 256) )
localkey |= GR_KB_SHIFT; localkey |= GR_KB_SHIFT;
KicadGraphicContext DC( this ); INSTALL_DC(DC, this );
BASE_SCREEN* Screen = GetScreen(); BASE_SCREEN* Screen = GetScreen();
...@@ -1345,18 +1351,15 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event ) ...@@ -1345,18 +1351,15 @@ void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
void WinEDA_DrawPanel::UnManageCursor( int id, int cursor, void WinEDA_DrawPanel::UnManageCursor( int id, int cursor,
const wxString& title ) const wxString& title )
{ {
wxClientDC dc( this );
if( ManageCurseur && ForceCloseManageCurseur ) if( ManageCurseur && ForceCloseManageCurseur )
{ {
INSTALL_DC( dc, this );
ForceCloseManageCurseur( this, &dc ); ForceCloseManageCurseur( this, &dc );
m_AutoPAN_Request = false; m_AutoPAN_Request = false;
}
if( id != -1 && cursor != -1 ) if( id != -1 && cursor != -1 )
{ {
wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX ); wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );
m_Parent->SetToolID( id, cursor, title ); m_Parent->SetToolID( id, cursor, title );
} }
}
} }
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "kicad_device_context.h"
/** Compute draw offset (scroll bars and draw parameters) /** Compute draw offset (scroll bars and draw parameters)
* in order to have the current graphic cursor position at the screen center * in order to have the current graphic cursor position at the screen center
...@@ -27,7 +28,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) ...@@ -27,7 +28,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
{ {
PutOnGrid( &(GetBaseScreen()->m_Curseur) ); PutOnGrid( &(GetBaseScreen()->m_Curseur) );
AdjustScrollBars(); AdjustScrollBars();
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel ) ;
DrawPanel->ReDraw( &dc ); DrawPanel->ReDraw( &dc );
/* Move the mouse cursor to the on grid graphic cursor position */ /* Move the mouse cursor to the on grid graphic cursor position */
...@@ -130,7 +131,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) ...@@ -130,7 +131,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
// DrawPanel->Refresh(); usually good, // DrawPanel->Refresh(); usually good,
// but does not work under linux, when called from here (wxGTK bug ?) // but does not work under linux, when called from here (wxGTK bug ?)
{ {
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
DrawPanel->ReDraw( &dc ); DrawPanel->ReDraw( &dc );
} }
break; break;
......
...@@ -707,6 +707,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -707,6 +707,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
chipnameTextCtrl->SetValue( m_Cmp->m_ChipName ); chipnameTextCtrl->SetValue( m_Cmp->m_ChipName );
} }
#include "kicad_device_context.h"
/* reinitialise components parametres to default values found in lib /* reinitialise components parametres to default values found in lib
*/ */
...@@ -722,7 +723,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -722,7 +723,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
if( entry == NULL ) if( entry == NULL )
return; return;
KicadGraphicContext dc( m_Parent->DrawPanel ); INSTALL_DC( dc, m_Parent->DrawPanel );
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode ); RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, g_XorMode );
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"
#include "kicad_device_context.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -179,7 +181,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindComponentAndItem( ...@@ -179,7 +181,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindComponentAndItem(
Recadre_Trace( mouseWarp ); Recadre_Trace( mouseWarp );
else else
{ {
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
...@@ -354,7 +356,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType ) ...@@ -354,7 +356,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType )
Recadre_Trace( TRUE ); Recadre_Trace( TRUE );
else else
{ {
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
DrawPanel->MouseTo( curpos ); DrawPanel->MouseTo( curpos );
...@@ -577,7 +579,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( const wxString& pattern, ...@@ -577,7 +579,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( const wxString& pattern,
Recadre_Trace( mouseWarp ); Recadre_Trace( mouseWarp );
else else
{ {
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur ); EXCHG( old_cursor_position, Sheet->LastScreen()->m_Curseur );
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "libeditfrm.h" #include "libeditfrm.h"
#include "class_library.h" #include "class_library.h"
#include "kicad_device_context.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -604,8 +606,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -604,8 +606,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
KicadGraphicContext dc( DrawPanel );
DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true;
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
...@@ -621,7 +621,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -621,7 +621,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_COPY_BLOCK: case ID_POPUP_COPY_BLOCK:
...@@ -632,18 +631,23 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -632,18 +631,23 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT: case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
break; break;
case ID_POPUP_LIBEDIT_DELETE_ITEM: case ID_POPUP_LIBEDIT_CANCEL_EDITING:
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->UnManageCursor( );
else
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
break;
case ID_POPUP_LIBEDIT_DELETE_ITEM:
DrawPanel->UnManageCursor( );
break; break;
default: default:
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW, wxEmptyString );
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
} }
INSTALL_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
case ID_LIBEDIT_SELECT_CURRENT_LIB: case ID_LIBEDIT_SELECT_CURRENT_LIB:
...@@ -673,13 +677,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -673,13 +677,6 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
} }
break; break;
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
else
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break;
case ID_NO_SELECT_BUTT: case ID_NO_SELECT_BUTT:
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
#include "eeschema_id.h" #include "eeschema_id.h"
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"
#include "kicad_device_context.h"
void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
KicadGraphicContext dc( DrawPanel );
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
pos = wxGetMousePosition(); pos = wxGetMousePosition();
...@@ -123,10 +123,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -123,10 +123,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel-> DrawPanel->
m_PanelDefaultCursor ) ); m_PanelDefaultCursor ) );
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) // Stop the current command (if any) but keep the current tool
{ DrawPanel->UnManageCursor( );
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
/* Should not be executed, except bug. */ /* Should not be executed, except bug. */
if( screen->m_BlockLocate.m_Command != BLOCK_IDLE ) if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
...@@ -139,25 +137,19 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -139,25 +137,19 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_CMP: case ID_POPUP_SCH_DELETE_CMP:
case ID_POPUP_SCH_DELETE: case ID_POPUP_SCH_DELETE:
// Stop the current command but keep the current tool // Stop the current command (if any) but keep the current tool
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) DrawPanel->UnManageCursor( );
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
break; break;
default: default:
// Stop the current command and deselect the current tool // Stop the current command and deselect the current tool
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor =
wxCURSOR_ARROW; wxCURSOR_ARROW;
SetToolID( 0, DrawPanel->m_PanelCursor, wxEmptyString ); DrawPanel->UnManageCursor( 0, DrawPanel->m_PanelCursor );
break; break;
} }
INSTALL_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
case ID_HIERARCHY: case ID_HIERARCHY:
......
...@@ -287,7 +287,6 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -287,7 +287,6 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event )
return; return;
int id = event.GetId(); int id = event.GetId();
KicadGraphicContext dc( DrawPanel );
switch( id ) switch( id )
{ {
...@@ -309,14 +308,13 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -309,14 +308,13 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event )
break; break;
case ID_TB_OPTIONS_SELECT_CURSOR: case ID_TB_OPTIONS_SELECT_CURSOR:
DrawPanel->CursorOff( &dc );
m_CursorShape = m_OptionsToolBar->GetToolState( id ); m_CursorShape = m_OptionsToolBar->GetToolState( id );
DrawPanel->CursorOn( &dc ); DrawPanel->Refresh( );
break; break;
case ID_TB_OPTIONS_HIDDEN_PINS: case ID_TB_OPTIONS_HIDDEN_PINS:
m_ShowAllPins = m_OptionsToolBar->GetToolState( id ); m_ShowAllPins = m_OptionsToolBar->GetToolState( id );
DrawPanel->ReDraw( &dc, TRUE ); DrawPanel->Refresh( );
break; break;
case ID_TB_OPTIONS_BUS_WIRES_ORIENT: case ID_TB_OPTIONS_BUS_WIRES_ORIENT:
......
...@@ -282,7 +282,16 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -282,7 +282,16 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
LIB_ALIAS* alias = (LIB_ALIAS*) entry; LIB_ALIAS* alias = (LIB_ALIAS*) entry;
component = alias->GetComponent(); component = alias->GetComponent();
wxASSERT( component != NULL && component->isComponent() ); if( component == NULL ) // Should not occur
{
wxASSERT( component != NULL );
return;
}
if( ! component->isComponent() )
{
wxASSERT( component->isComponent() );
return;
}
msg = alias->GetName(); msg = alias->GetName();
......
...@@ -464,7 +464,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems() ...@@ -464,7 +464,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
} }
void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC ) void WinEDA_GerberFrame::Liste_D_Codes( )
{ {
int ii, jj; int ii, jj;
D_CODE* pt_D_code; D_CODE* pt_D_code;
...@@ -523,13 +523,4 @@ void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC ) ...@@ -523,13 +523,4 @@ void WinEDA_GerberFrame::Liste_D_Codes( wxDC* DC )
List->Destroy(); List->Destroy();
if( ii < 0 ) if( ii < 0 )
return; return;
#if 0
// Highlight segment corresponding to dCode selected.
if( Etat_Surbrillance )
Hight_Light( DrawPanel, DC );
net_code_Surbrillance = (GetScreen()->m_Active_Layer << 16) + ii;
Hight_Light( DrawPanel, DC );
#endif
} }
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "gerbview.h" #include "gerbview.h"
#include "pcbplot.h" #include "pcbplot.h"
#include "protos.h" #include "protos.h"
#include "kicad_device_context.h"
/* Process the command triggered by the left button of the mouse when a tool /* Process the command triggered by the left button of the mouse when a tool
...@@ -61,7 +62,6 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -61,7 +62,6 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
default: default:
DisplayError( this, wxT( "WinEDA_GerberFrame::ProcessCommand error" ) ); DisplayError( this, wxT( "WinEDA_GerberFrame::ProcessCommand error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
} }
} }
...@@ -75,7 +75,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -75,7 +75,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
int layer = GetScreen()->m_Active_Layer; int layer = GetScreen()->m_Active_Layer;
GERBER* gerber_layer = g_GERBER_List[layer]; GERBER* gerber_layer = g_GERBER_List[layer];
wxPoint pos; wxPoint pos;
KicadGraphicContext dc( DrawPanel );
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
...@@ -95,11 +94,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -95,11 +94,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( DrawPanel->ManageCurseur DrawPanel->UnManageCursor( );
&& DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
/* Should not be executed, except bug */ /* Should not be executed, except bug */
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
...@@ -114,15 +109,11 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -114,15 +109,11 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
default: default:
if( DrawPanel->ManageCurseur DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW, wxEmptyString );
&& DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
} }
INSTALL_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
case ID_EXIT: case ID_EXIT:
...@@ -194,7 +185,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -194,7 +185,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_GERBVIEW_SHOW_LIST_DCODES: case ID_GERBVIEW_SHOW_LIST_DCODES:
Liste_D_Codes( &dc ); Liste_D_Codes( );
break; break;
case ID_GERBVIEW_SHOW_SOURCE: case ID_GERBVIEW_SHOW_SOURCE:
......
...@@ -54,97 +54,6 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -54,97 +54,6 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
} }
void WinEDA_GerberFrame::Erase_Zones( bool query )
{
if( query && !IsOK( this, _( "Delete zones?" ) ) )
return;
GetBoard()->m_Zone.DeleteAll();
ScreenPcb->SetModify();
}
void WinEDA_GerberFrame::Erase_Segments_Pcb( bool all_layers, bool query )
{
int layer = GetScreen()->m_Active_Layer;
if( all_layers )
layer = -1;
BOARD_ITEM* next;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = next )
{
next = item->Next();
switch( item->Type() )
{
case TYPE_DRAWSEGMENT:
case TYPE_TEXTE:
case TYPE_COTATION:
case TYPE_MIRE:
if( item->GetLayer() == layer || layer < 0 )
GetBoard()->Delete( item );
break;
default:
DisplayError( this, wxT( "Draw type unknown." ) );
break;
}
}
ScreenPcb->SetModify();
}
/* Delete track segments.
* masque_type mask options selection:
* SEGM_FIXE, SEGM_AR
* If a bit is 1, segment is not erased.
*/
void WinEDA_GerberFrame::Erase_Pistes( int masque_type, bool query )
{
TRACK* pt_segm;
BOARD_ITEM* PtNext;
if( query && !IsOK( this, _( "Delete tracks?" ) ) )
return;
/* Mark tracks to clear. */
for( pt_segm = GetBoard()->m_Track;
pt_segm != NULL;
pt_segm = (TRACK*) PtNext )
{
PtNext = pt_segm->Next();
if( pt_segm->GetState( SEGM_FIXE | SEGM_AR ) & masque_type )
continue;
pt_segm->DeleteStructure();
}
ScreenPcb->SetModify();
}
void WinEDA_GerberFrame::Erase_Textes_Pcb( bool query )
{
BOARD_ITEM* PtStruct;
BOARD_ITEM* PtNext;
if( query && !IsOK( this, _( "Delete pcb text?" ) ) )
return;
PtStruct = GetBoard()->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtNext )
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPE_TEXTE )
PtStruct->DeleteStructure();
}
ScreenPcb->SetModify();
}
void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
{ {
int layer = GetScreen()->m_Active_Layer; int layer = GetScreen()->m_Active_Layer;
......
...@@ -195,30 +195,15 @@ public: ...@@ -195,30 +195,15 @@ public:
*/ */
int Read_D_Code_File( const wxString& D_Code_FullFileName ); int Read_D_Code_File( const wxString& D_Code_FullFileName );
void CopyDCodesSizeToItems(); void CopyDCodesSizeToItems();
void Liste_D_Codes( wxDC* DC ); void Liste_D_Codes( );
void Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer ); void Trace_Gerber( wxDC* DC, int draw_mode, int printmasklayer );
// Copper texts
void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
TEXTE_PCB* Create_Texte_Pcb( wxDC* DC );
void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
void StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC );
void Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
// PCB handling // PCB handling
bool Clear_Pcb( bool query ); bool Clear_Pcb( bool query );
void Erase_Current_Layer( bool query ); void Erase_Current_Layer( bool query );
void Erase_Zones( bool query );
void Erase_Segments_Pcb( bool is_edges, bool query );
void Erase_Pistes( int masque_type, bool query );
void Erase_Textes_Pcb( bool query );
void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ); void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number );
TRACK* Begin_Route( TRACK* track, wxDC* DC );
void End_Route( TRACK* track, wxDC* DC );
TRACK* Delete_Segment( wxDC* DC, TRACK* Track ); TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
int Edit_TrackSegm_Width( wxDC* DC, TRACK* segm );
// Conversion function // Conversion function
void ExportDataInPcbnewFormat( wxCommandEvent& event ); void ExportDataInPcbnewFormat( wxCommandEvent& event );
......
...@@ -180,12 +180,4 @@ public: ...@@ -180,12 +180,4 @@ public:
DECLARE_EVENT_TABLE() 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 */ #endif /* #ifndef PANEL_WXSTRUCT_H */
/**
* a helper to handle the real device context used in kicad
* @file kicad_device_context.h
*/
#ifndef __KICAD_DEVICE_CONTEXT_H__
#define __KICAD_DEVICE_CONTEXT_H__
// Comment this line to use the standard wxClientDC
// and uncomment to use buffered DC
// #define KICAD_USE_BUFFERED_DC // Currently for tests
#ifdef KICAD_USE_BUFFERED_DC
#include <wx/dcbuffer.h>
#endif
// Helper class to handle the client Device Context
class KicadGraphicContext : public wxClientDC
{
public:
KicadGraphicContext( WinEDA_DrawPanel * aDrawPanel );
~KicadGraphicContext();
};
// Macro used to declare a device context in kicad:
#ifdef KICAD_USE_BUFFERED_DC
#define INSTALL_DC(name,parent) \
KicadGraphicContext _cDC( parent );\
wxBufferedDC name(&_cDC, _cDC.GetSize() );
#else
#define INSTALL_DC(name,parent) KicadGraphicContext name( parent );
#endif
#endif // __KICAD_DEVICE_CONTEXT_H__
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
#include "protos.h" #include "protos.h"
#include "kicad_device_context.h"
typedef enum { typedef enum {
FIXE_MODULE, FIXE_MODULE,
...@@ -36,7 +37,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) ...@@ -36,7 +37,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
bool on_state; bool on_state;
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
...@@ -59,12 +60,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) ...@@ -59,12 +60,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
break; break;
default: // Abort a current command (if any) default: // Abort a current command (if any)
if( DrawPanel->ManageCurseur DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
&& DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
} }
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "autorout.h" #include "autorout.h"
#include "protos.h" #include "protos.h"
#include "kicad_device_context.h"
#include "dialog_global_edit_tracks_and_vias.h" #include "dialog_global_edit_tracks_and_vias.h"
// Uncomment following line to enable wxBell() command (which beeps speaker) // Uncomment following line to enable wxBell() command (which beeps speaker)
...@@ -32,7 +34,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -32,7 +34,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos; wxPoint pos;
int itmp; int itmp;
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
......
...@@ -91,8 +91,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) ...@@ -91,8 +91,7 @@ void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
offsetX = m_Auxiliary_Axis_Position.x; offsetX = m_Auxiliary_Axis_Position.x;
offsetY = m_Auxiliary_Axis_Position.y; offsetY = m_Auxiliary_Axis_Position.y;
KicadGraphicContext dc( DrawPanel ); Compile_Ratsnest( NULL, TRUE );
Compile_Ratsnest( &dc, TRUE );
/* Temporary modification of footprints that are flipped (i.e. on bottom /* Temporary modification of footprints that are flipped (i.e. on bottom
* layer) to convert them to non flipped footprints. * layer) to convert them to non flipped footprints.
......
...@@ -17,23 +17,16 @@ ...@@ -17,23 +17,16 @@
void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event ) void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event )
{ {
wxString fn; wxString fn;
KicadGraphicContext dc( DrawPanel );
fn = GetFileFromHistory( event.GetId(), _( "Printed circuit board" ) ); fn = GetFileFromHistory( event.GetId(), _( "Printed circuit board" ) );
if( fn != wxEmptyString ) if( fn != wxEmptyString )
{ {
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
::wxSetWorkingDirectory( ::wxPathOnly( fn ) ); ::wxSetWorkingDirectory( ::wxPathOnly( fn ) );
LoadOnePcbFile( fn, false ); LoadOnePcbFile( fn, false );
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( &dc );
} }
} }
...@@ -49,12 +42,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event ) ...@@ -49,12 +42,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
// If an edition is in progress, stop it // If an edition is in progress, stop it
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
{
KicadGraphicContext dc( DrawPanel );
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
switch( id ) switch( id )
{ {
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "protos.h" #include "protos.h"
#include "kicad_device_context.h"
#include "dialog_edit_module_for_Modedit.h" #include "dialog_edit_module_for_Modedit.h"
#include "collectors.h" #include "collectors.h"
...@@ -147,7 +149,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -147,7 +149,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos; wxPoint pos;
bool redraw = false; bool redraw = false;
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "pcbnew_id.h" #include "pcbnew_id.h"
#include "kicad_device_context.h"
#include "protos.h" #include "protos.h"
...@@ -20,7 +21,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event ) ...@@ -20,7 +21,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
...@@ -32,12 +33,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event ) ...@@ -32,12 +33,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event )
break; break;
default: // End block command in progress. default: // End block command in progress.
if( DrawPanel->ManageCurseur DrawPanel->UnManageCursor( );
&& DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break; break;
} }
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "collectors.h" #include "collectors.h"
#include "kicad_device_context.h"
#define Pad_fill (Pad_Fill_Item.State == RUN) #define Pad_fill (Pad_Fill_Item.State == RUN)
...@@ -72,7 +74,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event ) ...@@ -72,7 +74,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
if( found ) if( found )
{ {
KicadGraphicContext dc( DrawPanel ); INSTALL_DC( dc, DrawPanel );
if( g_HightLigt_Status ) if( g_HightLigt_Status )
Hight_Light( &dc ); Hight_Light( &dc );
......
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