Commit c02d90e9 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Use wxUpdateUIEvent in CVPcb and other minor changes.

* CVPcb now uses wxUpdateUIEvent instead of set toolbars.
* Removed duplicate event handlers in CVPcb that were factored into
  EDA_DRAW_FRAME.
* Fix definition of GeneralControle() in CVPcb that prevented it from being
  called.
* Remove rarely used and scary refresh code GeneralControle() method in all
  main frame windows.
* Factor zoom menu and tool bar command IDs down to EDA_DRAW_FRAME.
parent cbee2477
......@@ -62,11 +62,11 @@ void BASE_SCREEN::InitDatas()
SetCurItem( NULL );
m_FlagRefreshReq = 0; /* Redraw screen request flag */
m_FlagModified = 0; // Set when any change is made on broad
m_FlagSave = 1; // Used in auto save: set when an auto save is made
}
/**
* Get screen units scalar.
*
......
......@@ -261,7 +261,7 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings(wxCommandEvent& event)
#endif
m_Screen->SetModify();
m_Screen->SetRefreshReq();
m_Parent->DrawPanel->Refresh();
}
......
......@@ -40,6 +40,7 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, EDA_BASE_FRAME )
EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
EVT_MENU_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
......
This diff is collapsed.
......@@ -8,12 +8,9 @@
class DISPLAY_FOOTPRINTS_FRAME : public WinEDA_BasePcbFrame
{
public:
public:
DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~DISPLAY_FOOTPRINTS_FRAME();
......@@ -26,30 +23,32 @@ public:
void OnSelectOptionToolbar( wxCommandEvent& event );
void OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent );
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
virtual bool IsGridVisible();
virtual bool IsGridVisible();
/**
* Function SetGridVisibility() , virtual
* It may be overloaded by derived classes
* if you want to store/retrieve the grid visiblity in configuration.
* if you want to store/retrieve the grid visibility in configuration.
* @param aVisible = true if the grid must be shown
*/
virtual void SetGridVisibility(bool aVisible);
virtual void SetGridVisibility( bool aVisible );
/**
* Function GetGridColor() , virtual
* @return the color of the grid
*/
virtual int GetGridColor();
virtual int GetGridColor();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
void SetToolbars();
void GeneralControle( wxDC* DC, wxPoint Mouse );
void GeneralControle( wxDC* DC, const wxPoint& aPosition );
void InstallOptionsDisplay( wxCommandEvent& event );
MODULE* Get_Module( const wxString& CmpName );
......@@ -86,4 +85,3 @@ public:
DECLARE_EVENT_TABLE()
};
......@@ -281,12 +281,6 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
// Update cursor position.
screen->SetCrossHairPosition( pos );
if( screen->IsRefreshReq() )
{
DrawPanel->Refresh();
wxSafeYield();
}
if( oldpos != screen->GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
......@@ -362,12 +356,6 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
// Update the cursor position.
screen->SetCrossHairPosition( pos );
if( screen->IsRefreshReq() )
{
DrawPanel->Refresh( );
wxSafeYield();
}
if( oldpos != screen->GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
......@@ -443,12 +431,6 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
// Update cursor position.
screen->SetCrossHairPosition( pos );
if( screen->IsRefreshReq() )
{
DrawPanel->Refresh( );
wxSafeYield();
}
if( oldpos != screen->GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
......
......@@ -56,8 +56,6 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
GetScreen()->ClrRefreshReq();
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
......
......@@ -214,8 +214,6 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
Field->m_Text = fieldText;
}
GetScreen()->ClrRefreshReq();
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
......
......@@ -80,7 +80,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate )
/* Main horizontal toolbar. */
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, LIB_EDIT_FRAME::OnZoom )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::SaveActiveLibrary )
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
......
......@@ -251,7 +251,7 @@ void SCH_SCREEN::ReplaceWires( SCH_ITEM* aWireList )
bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
{
SCH_ITEM* DrawList, * TstDrawList;
bool Modify = FALSE;
bool Modify = false;
DrawList = GetDrawItems();
......@@ -273,9 +273,9 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
* segment can be flagged */
DrawList->m_Flags |= TstDrawList->m_Flags;
EraseStruct( TstDrawList, this );
SetRefreshReq();
aCanvas->Refresh();
TstDrawList = GetDrawItems();
Modify = TRUE;
Modify = true;
}
else
{
......@@ -308,18 +308,18 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0
|| fprintf( aFile, " date %s\n", CONV_TO_UTF8( DateAndTime() ) ) < 0 )
return FALSE;
return false;
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{
if( fprintf( aFile, "LIBS:%s\n", CONV_TO_UTF8( lib.GetName() ) ) < 0 )
return FALSE;
return false;
}
if( fprintf( aFile, "EELAYER %2d %2d\n", g_LayerDescr.NumberOfLayers,
g_LayerDescr.CurrentLayer ) < 0
|| fprintf( aFile, "EELAYER END\n" ) < 0 )
return FALSE;
return false;
/* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for
* SheetNumber and Sheet Count in a complex hierarchy, but useful in
......@@ -339,18 +339,18 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
|| fprintf( aFile, "Comment3 \"%s\"\n", CONV_TO_UTF8( m_Commentaire3 ) ) < 0
|| fprintf( aFile, "Comment4 \"%s\"\n", CONV_TO_UTF8( m_Commentaire4 ) ) < 0
|| fprintf( aFile, "$EndDescr\n" ) < 0 )
return FALSE;
return false;
for( SCH_ITEM* item = GetDrawItems(); item; item = item->Next() )
{
if( !item->Save( aFile ) )
return FALSE;
return false;
}
if( fprintf( aFile, "$EndSCHEMATC\n" ) < 0 )
return FALSE;
return false;
return TRUE;
return true;
}
......
......@@ -78,8 +78,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, SCH_EDIT_FRAME::SetLanguage )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, SCH_EDIT_FRAME::OnZoom )
EVT_TOOL( ID_TO_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
......
......@@ -49,7 +49,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
EVT_TOOL_RANGE( ID_LIBVIEW_NEXT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
LIB_VIEW_FRAME::Process_Special_Functions )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, LIB_VIEW_FRAME::OnZoom )
EVT_TOOL( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC,
LIB_VIEW_FRAME::ExportToSchematicLibraryPart )
EVT_KICAD_CHOICEBOX( ID_LIBVIEW_SELECT_PART_NUMBER,
......
......@@ -17,21 +17,6 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
pos = GetScreen()->GetNearestGridPosition( pos );
if( GetScreen()->IsRefreshReq() )
{
DrawPanel->Refresh( );
wxSafeYield();
// We must return here, instead of proceeding.
// If we let the cursor move during a refresh request,
// the cursor be displayed in the wrong place
// during delayed repaint events that occur when
// you move the mouse when a message dialog is on
// the screen, and then you dismiss the dialog by
// typing the Enter key.
return;
}
oldpos = GetScreen()->GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
......@@ -87,11 +72,5 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
OnHotKey( aDC, hotkey, NULL );
}
if( GetScreen()->IsRefreshReq() )
{
DrawPanel->Refresh( );
wxSafeYield();
}
UpdateStatusBar();
}
......@@ -261,8 +261,6 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
delete layerBitmap;
delete screenBitmap;
}
m_PcbFrame->GetScreen()->ClrRefreshReq();
}
/* Function DrawItemsDCodeID
......
......@@ -176,7 +176,6 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
}
Zoom_Automatique( true );
GetScreen()->SetRefreshReq();
g_SaveTime = time( NULL );
// Synchronize layers tools with actual active layer:
......@@ -220,5 +219,5 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileNa
frame->Read_D_Code_File( fn.GetFullPath() );
frame->CopyDCodesSizeToItems();
frame->GetScreen()->SetRefreshReq();
frame->Refresh();
}
......@@ -29,8 +29,6 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
EVT_SIZE( WinEDA_GerberFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, WinEDA_GerberFrame::OnZoom )
EVT_TOOL( wxID_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_GERBVIEW_LOAD_DRILL_FILE, WinEDA_GerberFrame::Files_io )
......
......@@ -81,6 +81,6 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
}
ScreenPcb->SetModify();
ScreenPcb->SetRefreshReq();
DrawPanel->Refresh();
syncLayerBox();
}
......@@ -248,14 +248,11 @@ public:
}
void SetRefreshReq() { m_FlagRefreshReq = 1; }
void ClrRefreshReq() { m_FlagRefreshReq = 0; }
void SetModify() { m_FlagModified = 1; m_FlagSave = 0; }
void ClrModify() { m_FlagModified = 0; m_FlagSave = 1; }
void SetSave() { m_FlagSave = 1; }
void ClrSave() { m_FlagSave = 0; }
int IsModify() { return m_FlagModified & 1; }
int IsRefreshReq() { return m_FlagRefreshReq & 1; }
int IsSave() { return m_FlagSave & 1; }
......
......@@ -216,7 +216,7 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
GetScreen()->m_Active_Layer = layer;
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
DrawPanel->Refresh();
}
......
......@@ -370,11 +370,5 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, const wxPoint& aPosition )
OnHotKey( aDC, hotkey, aPosition );
}
if( GetScreen()->IsRefreshReq() )
{
DrawPanel->Refresh( );
wxSafeYield();
}
UpdateStatusBar(); /* Display new cursor coordinates */
}
......@@ -317,8 +317,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA; // place micro via and switch layer
Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay )
( (PCB_SCREEN*) GetScreen() )->SetRefreshReq();
DrawPanel->Refresh();
}
break;
......@@ -1168,7 +1169,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
{
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
DrawPanel->Refresh();
}
// if the via was allowed by DRC, then the layer swap has already
// been done by Other_Layer_Route(). if via not allowed, then
......@@ -1186,7 +1187,7 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
setActiveLayer( layer );
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
DrawPanel->Refresh();
}
......
......@@ -39,8 +39,6 @@ BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, WinEDA_BasePcbFrame )
EVT_KICAD_CHOICEBOX( ID_ON_ZOOM_SELECT, WinEDA_ModuleEditFrame::OnSelectZoom )
EVT_KICAD_CHOICEBOX( ID_ON_GRID_SELECT, WinEDA_ModuleEditFrame::OnSelectGrid )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, WinEDA_ModuleEditFrame::OnZoom )
EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_DELETE_PART, WinEDA_ModuleEditFrame::Process_Special_Functions )
......@@ -339,20 +337,6 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPositio
int hotkey = 0;
wxPoint pos = aPosition;
if( GetScreen()->IsRefreshReq() )
{
DrawPanel->Refresh();
// We must return here, instead of proceeding.
// If we let the cursor move during a refresh request,
// the cursor be displayed in the wrong place
// during delayed repaint events that occur when
// you move the mouse when a message dialog is on
// the screen, and then you dismiss the dialog by
// typing the Enter key.
return;
}
pos = GetScreen()->GetNearestGridPosition( aPosition );
oldpos = GetScreen()->GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
......@@ -409,12 +393,6 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, const wxPoint& aPositio
OnHotKey( aDC, hotkey, aPosition );
}
if( GetScreen()->IsRefreshReq() )
{
DrawPanel->Refresh();
wxSafeYield();
}
UpdateStatusBar();
}
......
......@@ -194,7 +194,7 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
pcbframe->DrawGeneralRatsnest( DC );
#ifdef __WXMAC__
pcbframe->GetScreen()->SetRefreshReq();
Panel->Refresh();
#endif
}
......
......@@ -74,8 +74,6 @@ BEGIN_EVENT_TABLE( WinEDA_PcbFrame, WinEDA_BasePcbFrame )
EVT_CLOSE( WinEDA_PcbFrame::OnCloseWindow )
EVT_SIZE( WinEDA_PcbFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, WinEDA_PcbFrame::OnZoom )
EVT_TOOL( ID_LOAD_FILE, WinEDA_PcbFrame::Files_io )
EVT_TOOL( ID_MENU_READ_LAST_SAVED_VERSION_BOARD, WinEDA_PcbFrame::Files_io )
EVT_TOOL( ID_MENU_RECOVER_BOARD, WinEDA_PcbFrame::Files_io )
......
......@@ -62,8 +62,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
}
#endif
screen->ClrRefreshReq();
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
......@@ -100,8 +98,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
}
#endif
GetScreen()->ClrRefreshReq();
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
......
......@@ -79,7 +79,7 @@ void WinEDA_PcbFrame::Delete_Zone_Fill( SEGZONE* aZone, long aTimestamp )
if( modify )
{
OnModify();
GetScreen()->SetRefreshReq();
DrawPanel->Refresh();
}
}
......
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