Commit 7ab4a9bf authored by stambaughw's avatar stambaughw

Minor fixes and code cleaning.

* Remove redundant background redrawing RedrawActiveWindow.
* Remove redundant managed cursor callback in RedrawActiveWindow.
* Use refresh to redraw instead of directly calling RedrawActiveWindow.
* Remove unused SetDrawBgColor for drawframe.cpp.
* Fix compiler warning in cvpcb/cvframe.cpp.
* Fix menu spelling and syntax errors in pcbnew.
* Rename Trace_Curseur to DrawCursor in common/drawpanel.cpp.
parent f41cc301
...@@ -596,34 +596,6 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -596,34 +596,6 @@ void WinEDA_DrawFrame::AdjustScrollBars()
} }
/* Updates the background color for drawing panel. The only valid colors
* are BLACK and WHITE.
* XorMode the parameter is updated according to the background color
*/
void WinEDA_DrawFrame::SetDrawBgColor( int color_num )
{
if( ( color_num != WHITE ) && ( color_num != BLACK ) )
color_num = BLACK;
g_DrawBgColor = color_num;
if( color_num == WHITE )
{
g_XorMode = GR_NXOR;
g_GhostColor = BLACK;
}
else
{
g_XorMode = GR_XOR;
g_GhostColor = WHITE;
}
if( DrawPanel )
DrawPanel->SetBackgroundColour(
wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue ) );
}
void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
......
...@@ -121,32 +121,32 @@ BASE_SCREEN* WinEDA_DrawPanel::GetScreen() ...@@ -121,32 +121,32 @@ BASE_SCREEN* WinEDA_DrawPanel::GetScreen()
/* /*
* Draw the schematic cursor which is usually on grid * Draw the schematic cursor which is usually on grid
*/ */
void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) void WinEDA_DrawPanel::DrawCursor( wxDC* aDC, int aColor )
{ {
if( m_CursorLevel != 0 || DC == NULL ) if( m_CursorLevel != 0 || aDC == NULL )
return; return;
wxPoint Cursor = GetScreen()->m_Curseur; wxPoint Cursor = GetScreen()->m_Curseur;
GRSetDrawMode( DC, GR_XOR ); GRSetDrawMode( aDC, GR_XOR );
if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */ if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */
{ {
int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() ); int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() ); int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
GRLine( &m_ClipBox, DC, Cursor.x - dx, Cursor.y, GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y,
Cursor.x + dx, Cursor.y, 0, color ); // Y axis Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis
GRLine( &m_ClipBox, DC, Cursor.x, Cursor.y - dx, GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx,
Cursor.x, Cursor.y + dy, 0, color ); // X axis Cursor.x, Cursor.y + dy, 0, aColor ); // X axis
} }
else else
{ {
int len = GetScreen()->Unscale( CURSOR_SIZE ); int len = GetScreen()->Unscale( CURSOR_SIZE );
GRLine( &m_ClipBox, DC, Cursor.x - len, Cursor.y, GRLine( &m_ClipBox, aDC, Cursor.x - len, Cursor.y,
Cursor.x + len, Cursor.y, 0, color ); Cursor.x + len, Cursor.y, 0, aColor );
GRLine( &m_ClipBox, DC, Cursor.x, Cursor.y - len, GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - len,
Cursor.x, Cursor.y + len, 0, color ); Cursor.x, Cursor.y + len, 0, aColor );
} }
} }
...@@ -157,7 +157,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) ...@@ -157,7 +157,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
*/ */
void WinEDA_DrawPanel::CursorOff( wxDC* DC ) void WinEDA_DrawPanel::CursorOff( wxDC* DC )
{ {
Trace_Curseur( DC ); DrawCursor( DC );
--m_CursorLevel; --m_CursorLevel;
} }
...@@ -168,7 +168,7 @@ void WinEDA_DrawPanel::CursorOff( wxDC* DC ) ...@@ -168,7 +168,7 @@ void WinEDA_DrawPanel::CursorOff( wxDC* DC )
void WinEDA_DrawPanel::CursorOn( wxDC* DC ) void WinEDA_DrawPanel::CursorOn( wxDC* DC )
{ {
++m_CursorLevel; ++m_CursorLevel;
Trace_Curseur( DC ); DrawCursor( DC );
if( m_CursorLevel > 0 ) // Shouldn't happen, but just in case .. if( m_CursorLevel > 0 ) // Shouldn't happen, but just in case ..
m_CursorLevel = 0; m_CursorLevel = 0;
......
...@@ -200,7 +200,7 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, ...@@ -200,7 +200,7 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title,
if( m_FootprintList ) if( m_FootprintList )
m_auimgr.AddPane( m_FootprintList, m_auimgr.AddPane( m_FootprintList,
wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ). wxAuiPaneInfo( horiz ).Name( wxT( "m_FootprintList" ) ).
Right().BestSize( m_FrameSize.x * 0.36, m_FrameSize.y ) ); Right().BestSize( (int) ( m_FrameSize.x * 0.36 ), m_FrameSize.y ) );
m_auimgr.Update(); m_auimgr.Update();
#endif #endif
......
...@@ -297,7 +297,7 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -297,7 +297,7 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
{ {
flagcurseur = 2; flagcurseur = 2;
RedrawActiveWindow( DC, TRUE ); Refresh();
} }
if( oldpos != GetScreen()->m_Curseur ) if( oldpos != GetScreen()->m_Curseur )
......
...@@ -92,16 +92,14 @@ void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -92,16 +92,14 @@ void WinEDA_DisplayFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = (PCB_SCREEN*) GetScreen(); ActiveScreen = (PCB_SCREEN*) GetScreen();
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
GetBoard()->Draw( DrawPanel, DC, GR_COPY ); GetBoard()->Draw( DrawPanel, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
if ( Module ) if ( Module )
Module->DisplayInfo( this ); Module->DisplayInfo( this );
DrawPanel->Trace_Curseur( DC );
DrawPanel->DrawCursor( DC );
} }
......
...@@ -378,7 +378,8 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() ...@@ -378,7 +378,8 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings()
g_DrawBgColor = WHITE; g_DrawBgColor = WHITE;
else else
g_DrawBgColor = BLACK; g_DrawBgColor = BLACK;
m_Parent->SetDrawBgColor( g_DrawBgColor );
m_Parent->Refresh();
} }
......
...@@ -52,21 +52,6 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -52,21 +52,6 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
/* Reinit draw and pen parameters */
GRResetPenAndBrush( DC );
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
DrawPanel->CursorOff( DC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList, RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList,
...@@ -74,13 +59,12 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -74,13 +59,12 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
DrawPanel->CursorOn( DC ); GetScreen()->ClrRefreshReq();
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
GetScreen()->ClrRefreshReq(); DrawPanel->DrawCursor( DC );
// Display the sheet filename, and the sheet path, for non root sheets // Display the sheet filename, and the sheet path, for non root sheets
if( GetScreen()->m_FileName == m_DefaultSchematicFileName ) if( GetScreen()->m_FileName == m_DefaultSchematicFileName )
......
...@@ -305,7 +305,6 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName, ...@@ -305,7 +305,6 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
if( m_ComponentLibFiles.GetCount() == 0 ) if( m_ComponentLibFiles.GetCount() == 0 )
m_ComponentLibFiles.Add( wxT( "power" ) ); m_ComponentLibFiles.Add( wxT( "power" ) );
SetDrawBgColor( g_DrawBgColor );
LoadLibraries(); LoadLibraries();
GetBaseScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetBaseScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
......
...@@ -201,33 +201,19 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -201,33 +201,19 @@ void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
GRResetPenAndBrush( DC );
DrawPanel->CursorOff( DC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, false );
}
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( m_component ) if( m_component )
m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit,
m_convert, GR_DEFAULT_DRAWMODE ); m_convert, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC ); // redraw cursor GetScreen()->ClrRefreshReq();
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, false ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
}
GetScreen()->ClrRefreshReq(); DrawPanel->DrawCursor( DC );
DisplayLibInfos(); DisplayLibInfos();
UpdateStatusBar(); UpdateStatusBar();
} }
......
...@@ -266,14 +266,6 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -266,14 +266,6 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( entry == NULL ) if( entry == NULL )
return; return;
/* Forcage de la reinit de la brosse et plume courante */
GRResetPenAndBrush( DC );
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( entry->isAlias() ) if( entry->isAlias() )
...@@ -312,6 +304,9 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -312,6 +304,9 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_convert, component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), m_unit, m_convert,
GR_DEFAULT_DRAWMODE ); GR_DEFAULT_DRAWMODE );
/* Redraw the cursor */
DrawPanel->DrawCursor( DC );
if( !tmp.IsEmpty() ) if( !tmp.IsEmpty() )
component->SetName( tmp ); component->SetName( tmp );
...@@ -320,6 +315,4 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -320,6 +315,4 @@ void WinEDA_ViewlibFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
AppendMsgPanel( _( "Alias" ), msg, RED, 6 ); AppendMsgPanel( _( "Alias" ), msg, RED, 6 );
AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 ); AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 );
AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY ); AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY );
DrawPanel->Trace_Curseur( DC );
} }
...@@ -297,7 +297,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC ) ...@@ -297,7 +297,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
} }
} }
RedrawActiveWindow( DC, TRUE ); Refresh();
} }
......
...@@ -77,9 +77,6 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -77,9 +77,6 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = screen; ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
Trace_Gerber( DC, GR_COPY, -1 ); Trace_Gerber( DC, GR_COPY, -1 );
...@@ -88,7 +85,7 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -88,7 +85,7 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->Trace_Curseur( DC ); DrawPanel->DrawCursor( DC );
} }
/********************************************************************/ /********************************************************************/
......
...@@ -196,8 +196,20 @@ public: ...@@ -196,8 +196,20 @@ public:
void MouseTo( const wxPoint& Mouse ); void MouseTo( const wxPoint& Mouse );
/* Cursor functions */ /* Cursor functions */
// Draw the user cursor (grid cursor) /**
void Trace_Curseur( wxDC* DC, int color = WHITE ); * Draw the user cursor.
*
* The user cursor is not the mouse cursor although they may be at the
* same screen position. The mouse cursor is still render by the OS.
* This is a drawn cursor that is used to snap to grid when grid snapping
* is enabled. This is required because OSX does not allow moving the
* cursor programmatically.
*
* @param aDC - the device context to draw the cursor
* @param aColor - the color to draw the cursor
*/
void DrawCursor( wxDC* aDC, int aColor = WHITE );
// remove the grid cursor from the display // remove the grid cursor from the display
void CursorOff( wxDC* DC ); void CursorOff( wxDC* DC );
// display the grid cursor // display the grid cursor
......
...@@ -224,7 +224,6 @@ public: ...@@ -224,7 +224,6 @@ public:
void Affiche_Message( const wxString& message ); void Affiche_Message( const wxString& message );
void EraseMsgBox(); void EraseMsgBox();
void Process_PageSettings( wxCommandEvent& event ); void Process_PageSettings( wxCommandEvent& event );
void SetDrawBgColor( int color_num );
virtual void SetToolbars(); virtual void SetToolbars();
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
virtual void ReCreateHToolbar() = 0; virtual void ReCreateHToolbar() = 0;
......
...@@ -417,7 +417,7 @@ int BOARD::GetVisibleElementColor( int aPCB_VISIBLE ) ...@@ -417,7 +417,7 @@ int BOARD::GetVisibleElementColor( int aPCB_VISIBLE )
case RATSNEST_VISIBLE: color = m_BoardSettings->m_RatsnestColor; break; case RATSNEST_VISIBLE: color = m_BoardSettings->m_RatsnestColor; break;
case GRID_VISIBLE: color = g_GridColor; break; case GRID_VISIBLE: color = g_GridColor; break;
default: default:
wxLogDebug("BOARD::GetVisibleElementColor(): bad arg %d", aPCB_VISIBLE ); wxLogDebug( wxT( "BOARD::GetVisibleElementColor(): bad arg %d" ), aPCB_VISIBLE );
} }
return color; return color;
...@@ -442,7 +442,7 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, int aColor ) ...@@ -442,7 +442,7 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, int aColor )
case RATSNEST_VISIBLE: m_BoardSettings->m_RatsnestColor = aColor; break; case RATSNEST_VISIBLE: m_BoardSettings->m_RatsnestColor = aColor; break;
case GRID_VISIBLE: g_GridColor = aColor; break; case GRID_VISIBLE: g_GridColor = aColor; break;
default: default:
wxLogDebug("BOARD::SetVisibleElementColor(): bad arg %d", aPCB_VISIBLE ); wxLogDebug( wxT( "BOARD::SetVisibleElementColor(): bad arg %d" ), aPCB_VISIBLE );
} }
} }
......
This diff is collapsed.
...@@ -31,9 +31,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -31,9 +31,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = screen; ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0 ); TraceWorkSheet( DC, screen, 0 );
...@@ -43,13 +40,13 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -43,13 +40,13 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
module->Draw( DrawPanel, DC, GR_OR ); module->Draw( DrawPanel, DC, GR_OR );
} }
screen->ClrRefreshReq();
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* Redraw the cursor */ /* Redraw the cursor */
DrawPanel->Trace_Curseur( DC ); DrawPanel->DrawCursor( DC );
screen->ClrRefreshReq();
} }
...@@ -65,9 +62,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -65,9 +62,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
ActiveScreen = screen; ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
TraceWorkSheet( DC, GetScreen(), 0 ); TraceWorkSheet( DC, GetScreen(), 0 );
...@@ -82,7 +76,7 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -82,7 +76,7 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
// Redraw the cursor // Redraw the cursor
DrawPanel->Trace_Curseur( DC ); DrawPanel->DrawCursor( 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