Loading CHANGELOG.txt +17 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,23 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with email address. email address. 2009-Jan-11 UPDATE Wayne Stambaugh <stambaughw@verizon.net> ================================================================================ ++All * Replace Kicad file history implementation with wxFileHistory. * Laid groundwork for search paths using wxPathList in EDA_Appl. * Made ReCreateMenuBar actually recreate the menu bar. Now language updates to menus can be changed without restarting program. * Lots of general housekeeping, simplification, and code beautifying. ++EESchema * Fix zoom and pan bug in library viewer panel due to incorrect DrawPanel rectangle. * Add zoom accelerator keys to library viewer (works in GTK, not Windows). * Add Postscript header to new print dialog so Linux build works. ++PcbNew * Add Postscript header to new print dialog so Linux build works. 2009-Jan-17 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2009-Jan-17 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ================================================================================ ++All: ++All: Loading common/basicframe.cpp +27 −36 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,6 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, int idtype, m_Ident = idtype; m_Ident = idtype; SetFont( *g_StdFont ); SetFont( *g_StdFont ); m_MenuBar = NULL; // menu du haut d'ecran m_HToolBar = NULL; m_HToolBar = NULL; m_FrameIsActive = TRUE; m_FrameIsActive = TRUE; m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT; m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT; Loading Loading @@ -169,48 +168,40 @@ void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName ) /* Met a jour la liste des anciens projets /* Met a jour la liste des anciens projets */ */ { { unsigned ii; wxGetApp().m_fileHistory.AddFileToHistory( FullFileName ); ReCreateMenuBar(); } if( FullFileName.IsEmpty() ) return; //suppression d'une ancienne trace eventuelle du meme fichier /** for( ii = 0; ii < wxGetApp().m_LastProject.GetCount(); ) * Fetch the file name from the file history list. { */ if( wxGetApp().m_LastProject[ii].IsEmpty() ) wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId, break; const wxString& type ) #ifdef __WINDOWS__ if( wxGetApp().m_LastProject[ii].CmpNoCase( FullFileName ) == 0 ) #else if( wxGetApp().m_LastProject[ii] == FullFileName ) #endif { { wxGetApp().m_LastProject.RemoveAt( ii ); wxString fn, msg; } size_t i; else int baseId = wxGetApp().m_fileHistory.GetBaseId(); ii++; } while( wxGetApp().m_LastProject.GetCount() >= wxGetApp().m_LastProjectMaxCount ) wxASSERT( cmdId >= baseId { && cmdId < baseId + ( int )wxGetApp().m_fileHistory.GetCount() ); wxGetApp().m_LastProject.RemoveAt( wxGetApp().m_LastProject.GetCount() - 1 ); } wxGetApp().m_LastProject.Insert( FullFileName, 0 ); i = ( size_t )( cmdId - baseId ); if( i < wxGetApp().m_fileHistory.GetCount() ) { fn = wxGetApp().m_fileHistory.GetHistoryFile( i ); if( !wxFileName::FileExists( fn ) ) { msg = type + _( " file <" ) + fn + _( "> was not found." ); DisplayError( this, msg ); wxGetApp().m_fileHistory.RemoveFileFromHistory( i ); fn = wxEmptyString; ReCreateMenuBar(); ReCreateMenuBar(); } } } return fn; /**************************************************/ wxString WinEDA_BasicFrame::GetLastProject( int rang ) /**************************************************/ { if( rang < 0 ) rang = 0; if( (unsigned) rang >= wxGetApp().m_LastProject.GetCount() ) return wxEmptyString; return wxGetApp().m_LastProject[rang]; } } Loading common/drawframe.cpp +20 −33 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, DrawPanel = NULL; DrawPanel = NULL; MsgPanel = NULL; MsgPanel = NULL; m_CurrentScreen = NULL; m_CurrentScreen = NULL; m_MenuBar = NULL; // main meun frame m_ID_current_state = 0; m_ID_current_state = 0; m_HTOOL_current_state = 0; m_HTOOL_current_state = 0; m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines Loading @@ -60,10 +59,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, // Internal units per inch // Internal units per inch // = 1000 for schema, = 10000 for PCB // = 1000 for schema, = 10000 for PCB m_InternalUnits = EESCHEMA_INTERNAL_UNIT; m_InternalUnits = EESCHEMA_INTERNAL_UNIT; if( ( m_Ident == PCB_FRAME ) || ( m_Ident == GERBER_FRAME ) || ( m_Ident == CVPCB_DISPLAY_FRAME ) || ( m_Ident == MODULE_EDITOR_FRAME ) ) m_InternalUnits = PCB_INTERNAL_UNIT; minsize.x = 470; minsize.x = 470; minsize.y = 350 + m_MsgFrameHeight; minsize.y = 350 + m_MsgFrameHeight; Loading Loading @@ -91,18 +86,13 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, m_FramePos.x = m_FramePos.y = 0; m_FramePos.x = m_FramePos.y = 0; m_FrameSize.y -= m_MsgFrameHeight; m_FrameSize.y -= m_MsgFrameHeight; if( m_Ident != DISPLAY3D_FRAME ) DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ), m_FrameSize ); { DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ), m_FrameSize ); MsgPanel = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ), MsgPanel = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ), wxSize( m_FrameSize.x, wxSize( m_FrameSize.x, m_MsgFrameHeight ) ); m_MsgFrameHeight ) ); MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red, MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red, ColorRefs[LIGHTGRAY].m_Green, ColorRefs[LIGHTGRAY].m_Green, ColorRefs[LIGHTGRAY].m_Blue ) ); ColorRefs[LIGHTGRAY].m_Blue ) ); } } } /****************************************/ /****************************************/ Loading Loading @@ -588,22 +578,16 @@ void WinEDA_DrawFrame::AdjustScrollBars() int zoom = screen->GetZoom(); int zoom = screen->GetZoom(); int xUnit, yUnit; int xUnit, yUnit; if( screen == NULL ) if( screen == NULL || DrawPanel == NULL ) return; if( DrawPanel == NULL ) return; return; draw_size = screen->ReturnPageSize(); // La zone d'affichage est reglee a une taille double de la feuille de travail: // La zone d'affichage est reglee a une taille double de la feuille de travail: draw_size.x *= 2; draw_size.y *= 2; draw_size = screen->ReturnPageSize() * 2; // On utilise le centre de l'ecran comme position de reference, donc // On utilise le centre de l'ecran comme position de reference, donc // la surface de trace doit etre augmentee // la surface de trace doit etre augmentee panel_size = DrawPanel->GetClientSize(); panel_size = DrawPanel->GetClientSize() * zoom; panel_size.x *= zoom; panel_size.y *= zoom; draw_size += panel_size / 2; draw_size.x += panel_size.x / 2; draw_size.y += panel_size.y / 2; if( screen->m_Center ) if( screen->m_Center ) Loading @@ -622,8 +606,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() screen->m_DrawOrg.y -= screen->m_DrawOrg.y % 256; screen->m_DrawOrg.y -= screen->m_DrawOrg.y % 256; // Calcul du nombre de scrolls (en unites de scrool ) // Calcul du nombre de scrolls (en unites de scrool ) scrollbar_number.x = draw_size.x / (DrawPanel->m_Scroll_unit * zoom); scrollbar_number = draw_size / (DrawPanel->m_Scroll_unit * zoom); scrollbar_number.y = draw_size.y / (DrawPanel->m_Scroll_unit * zoom); xUnit = yUnit = DrawPanel->m_Scroll_unit; xUnit = yUnit = DrawPanel->m_Scroll_unit; Loading @@ -631,13 +614,12 @@ void WinEDA_DrawFrame::AdjustScrollBars() xUnit = 1; xUnit = 1; if( yUnit <= 1 ) if( yUnit <= 1 ) yUnit = 1; yUnit = 1; xUnit *= zoom; yUnit *= zoom; xUnit *= zoom; yUnit *= zoom; // Calcul de la position, curseur place au centre d'ecran // Calcul de la position, curseur place au centre d'ecran scrollbar_pos = screen->m_Curseur; scrollbar_pos = screen->m_Curseur; scrollbar_pos -= screen->m_DrawOrg; scrollbar_pos.x -= screen->m_DrawOrg.x; scrollbar_pos.y -= screen->m_DrawOrg.y; scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.y -= panel_size.y / 2; scrollbar_pos.y -= panel_size.y / 2; Loading Loading @@ -698,7 +680,12 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) int id = event.GetId(); int id = event.GetId(); wxGetApp().SetLanguageIdentifier( id ); wxGetApp().SetLanguageIdentifier( id ); wxGetApp().SetLanguage(); if ( wxGetApp().SetLanguage() ) { wxLogDebug( wxT( "Recreating menu bar due to language change." ) ); ReCreateMenuBar(); Refresh(); } } } Loading common/drawpanel.cpp +41 −95 Original line number Original line Diff line number Diff line Loading @@ -97,12 +97,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) * Draw the schematic cursor which is usually on grid * Draw the schematic cursor which is usually on grid */ */ { { if( m_CursorLevel != 0 ) if( m_CursorLevel != 0 || DC == NULL ) { return; } if( DC == NULL ) return; return; wxPoint Cursor = GetScreen()->m_Curseur; wxPoint Cursor = GetScreen()->m_Curseur; Loading Loading @@ -201,36 +196,6 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) } } /*********************************************************************/ wxPoint WinEDA_DrawPanel::CalcAbsolutePosition( const wxPoint& rel_pos ) /*********************************************************************/ /** Function CalcAbsolutePosition * @return absolute position in pixels, considering the scroll amount * @param rel_pos = relative position (screen position) in pixel * ( relative position = position in the panel draw area on screen ) */ { wxPoint pos; #ifdef WX_ZOOM CalcUnscrolledPosition( rel_pos.x, rel_pos.y, &pos.x, &pos.y ); #else int ii, jj; GetViewStart( &pos.x, &pos.y ); // pos is the origin in scroll units GetScrollPixelsPerUnit( &ii, &jj ); pos.x *= ii; pos.y *= jj; // pos is the origin in pixel units pos.x += rel_pos.x; pos.y += rel_pos.y; #endif return pos; } /**********************************************************************/ /**********************************************************************/ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) /**********************************************************************/ /**********************************************************************/ Loading @@ -240,9 +205,7 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) * @param ScreenPos = absolute position in pixels * @param ScreenPos = absolute position in pixels */ */ { { wxPoint curpos = GetScreen()->CursorRealPosition( ScreenPos ); return GetScreen()->CursorRealPosition( ScreenPos ); return curpos; } } Loading @@ -268,13 +231,12 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN ); display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN ); // Conversion en coord physiques // Conversion en coord physiques pos = CalcAbsolutePosition( display_rect.GetPosition() ); pos = CalcUnscrolledPosition( display_rect.GetPosition() ); pos.x *= GetZoom(); pos.x *= GetZoom(); pos.y *= GetZoom(); pos.y *= GetZoom(); pos.x += GetScreen()->m_DrawOrg.x; pos += GetScreen()->m_DrawOrg; pos.y += GetScreen()->m_DrawOrg.y; display_rect.SetX( pos.x ); display_rect.SetX( pos.x ); display_rect.SetY( pos.y ); display_rect.SetY( pos.y ); Loading Loading @@ -385,18 +347,13 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) wxSize size; wxSize size; wxPoint realpos; wxPoint realpos; size = GetClientSize(); size = GetClientSize() / 2; realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) ); size.x /= 2; size.y /= 2; realpos = CalcAbsolutePosition( wxPoint( size.x, size.y ) ); realpos.x *= GetZoom(); realpos.x *= GetZoom(); realpos.y *= GetZoom(); realpos.y *= GetZoom(); realpos.x += GetScreen()->m_DrawOrg.x; realpos += GetScreen()->m_DrawOrg; realpos.y += GetScreen()->m_DrawOrg.y; return realpos; return realpos; } } Loading Loading @@ -428,11 +385,9 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse ) #ifdef WX_ZOOM #ifdef WX_ZOOM CalcScrolledPosition( Mouse.x, Mouse.y, &mouse.x, &mouse.y ); CalcScrolledPosition( Mouse.x, Mouse.y, &mouse.x, &mouse.y ); #else #else mouse = Mouse; mouse = Mouse - GetScreen()->m_StartVisu; mouse.x -= GetScreen()->m_StartVisu.x; mouse.y -= GetScreen()->m_StartVisu.y; #endif #endif GRMouseWarp( this, mouse ); WarpPointer( mouse.x, mouse.y ); } } Loading Loading @@ -543,11 +498,9 @@ void WinEDA_DrawPanel::SetBoundaryBox() #ifdef WX_ZOOM #ifdef WX_ZOOM m_ClipBox.m_Pos.x *= GetZoom(); m_ClipBox.m_Pos.x *= GetZoom(); m_ClipBox.m_Pos.y *= GetZoom(); m_ClipBox.m_Pos.y *= GetZoom(); m_ClipBox.m_Size.x *= GetZoom(); m_ClipBox.m_Size *= GetZoom(); m_ClipBox.m_Size.y *= GetZoom(); #else #else m_ClipBox.m_Pos.x -= GetScreen()->m_StartVisu.x; m_ClipBox.m_Pos -= GetScreen()->m_StartVisu; m_ClipBox.m_Pos.y -= GetScreen()->m_StartVisu.y; #endif #endif m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4; m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4; Loading Loading @@ -767,13 +720,9 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) org.x *= zoom; org.x *= zoom; org.y *= zoom; org.y *= zoom; org.x += screen->m_DrawOrg.x; org += screen->m_DrawOrg; org.y += screen->m_DrawOrg.y; size = GetClientSize(); size.x *= zoom; size = GetClientSize() * zoom; size.y *= zoom; pasx = screen->m_Grid.x * m_Parent->m_InternalUnits; pasx = screen->m_Grid.x * m_Parent->m_InternalUnits; pasy = screen->m_Grid.y * m_Parent->m_InternalUnits; pasy = screen->m_Grid.y * m_Parent->m_InternalUnits; Loading Loading @@ -868,8 +817,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event ) wxPoint pos; wxPoint pos; wxMenu MasterMenu; wxMenu MasterMenu; pos.x = event.GetX(); pos = event.GetPosition(); pos.y = event.GetY(); if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) return false; return false; Loading Loading @@ -921,13 +869,20 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event ) { { wxRect rect = GetRect(); wxRect rect = GetRect(); wxLogDebug( wxT( "OnMouseWheel() cursor position: (%d, %d)." ), /* This fixes a bad rectangle horizontal position returned by the event.m_x, event.m_y ); * schematic library veiwer panel. It may have something to do with * the sash window. */ rect.Offset( -rect.x, -rect.y ); /* Ignore scroll events if the cursor is outside the drawing area. */ /* Ignore scroll events if the cursor is outside the drawing area. */ if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled() if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled() || !rect.Contains( event.GetPosition() ) ) || !rect.Contains( event.GetPosition() ) ) { { wxLogDebug( wxT( "OnMouseWheel() position(%d, %d) " \ "rectangle(%d, %d, %d, %d)" ), event.GetPosition().x, event.GetPosition().y, rect.x, rect.y, rect.width, rect.height ); event.Skip(); event.Skip(); return; return; } } Loading Loading @@ -1029,7 +984,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) localrealbutt |= localbutt; /* compensation defaut wxGTK */ localrealbutt |= localbutt; /* compensation defaut wxGTK */ /* Compute absolute m_MousePosition in pixel units: */ /* Compute absolute m_MousePosition in pixel units: */ screen->m_MousePositionInPixels = CalcAbsolutePosition( wxPoint( event.GetX(), event.GetY() ) ); screen->m_MousePositionInPixels = CalcUnscrolledPosition( event.GetPosition() ); /* Compute absolute m_MousePosition in user units: */ /* Compute absolute m_MousePosition in user units: */ screen->m_MousePosition = CursorRealPosition( screen->m_MousePositionInPixels ); screen->m_MousePosition = CursorRealPosition( screen->m_MousePositionInPixels ); Loading Loading @@ -1247,6 +1202,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) { { long key, localkey; long key, localkey; bool escape = FALSE; bool escape = FALSE; wxPoint pos; key = localkey = event.GetKeyCode(); key = localkey = event.GetKeyCode(); Loading Loading @@ -1295,27 +1251,17 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) } } } } /* some key commands use the mouse position: refresh it */ /* Some key commands use the current mouse position: refresh it */ #if wxCHECK_VERSION( 2, 8, 0 ) pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() ); wxPoint mouse_pos = wxGetMousePosition(); // Get the mouse position on screen wxPoint win_pos = GetScreenPosition(); // get the draw area (panel)position on screen mouse_pos -= win_pos; // mouse_pos = is the mouse position relative to the panel /* Compute absolute m_MousePosition in pixel units (i.e. considering the current scrool) : */ Screen->m_MousePositionInPixels = CalcAbsolutePosition( mouse_pos ); /* Compute absolute m_MousePosition in user units: */ Screen->m_MousePosition = CursorRealPosition( Screen->m_MousePositionInPixels ); #else /* Compute absolute mouse position in pixel units (i.e. considering the current scrool) : */ Screen->m_MousePositionInPixels = pos; /* if wxGetMousePosition() does not exist, /* Compute absolute mouse position in user units: */ * m_Cursor should be ok, use it to calculate the cursor position on screen Screen->m_MousePosition = CursorRealPosition( pos ); */ Screen->m_MousePositionInPixels = CursorScreenPosition(); #endif m_Parent->GeneralControle( &DC, Screen->m_MousePositionInPixels ); m_Parent->GeneralControle( &DC, pos ); #if 0 #if 0 event.Skip(); // Allow menu shortcut processing event.Skip(); // Allow menu shortcut processing Loading common/edaappl.cpp +112 −90 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,10 @@ #include "fctsys.h" #include "fctsys.h" #include "wx/html/htmlwin.h" #include "wx/html/htmlwin.h" #include "wx/fs_zip.h" #include "wx/fs_zip.h" #include <wx/dir.h> #include <wx/filename.h> #include <wx/filename.h> #include <wx/stdpaths.h> #include <wx/apptrait.h> #include "common.h" #include "common.h" #include "worksheet.h" #include "worksheet.h" Loading Loading @@ -212,13 +215,11 @@ static struct LANGUAGE_DESCR s_Language_List[] = WinEDA_App::WinEDA_App() WinEDA_App::WinEDA_App() { { m_Checker = NULL; m_Checker = NULL; m_LastProjectMaxCount = 10; m_HtmlCtrl = NULL; m_HtmlCtrl = NULL; m_EDA_CommonConfig = NULL; m_EDA_CommonConfig = NULL; m_EDA_Config = NULL; m_EDA_Config = NULL; m_Env_Defined = FALSE; m_Env_Defined = FALSE; m_LanguageId = wxLANGUAGE_DEFAULT; m_LanguageId = wxLANGUAGE_DEFAULT; m_Language_Menu = NULL; m_Locale = NULL; m_Locale = NULL; m_PdfBrowserIsDefault = TRUE; m_PdfBrowserIsDefault = TRUE; } } Loading Loading @@ -281,7 +282,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) /* Init parameters for configuration */ /* Init parameters for configuration */ SetVendorName( wxT( "kicad" ) ); SetVendorName( wxT( "kicad" ) ); SetAppName( name ); SetAppName( name.Lower() ); m_EDA_Config = new wxConfig( name ); m_EDA_Config = new wxConfig( name ); m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); Loading Loading @@ -314,6 +315,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) // Analyse the command line & init binary path // Analyse the command line & init binary path SetBinDir(); SetBinDir(); SetDefaultSearchPaths(); ReadPdfBrowserInfos(); ReadPdfBrowserInfos(); // Internationalisation: loading the kicad suitable Dictionnary // Internationalisation: loading the kicad suitable Dictionnary Loading Loading @@ -438,9 +440,57 @@ bool WinEDA_App::SetBinDir() while( m_BinDir.Last() != '/' ) while( m_BinDir.Last() != '/' ) m_BinDir.RemoveLast(); m_BinDir.RemoveLast(); wxLogDebug( wxT( "Executable path the Kicad way: " ) + m_BinDir ); wxLogDebug( wxT( "Executable path the wxWidgets way: " ) + GetTraits()->GetStandardPaths().GetExecutablePath() ); return TRUE; return TRUE; } } /** * Set search paths for libraries, modules, internationalization files, etc. */ void WinEDA_App::SetDefaultSearchPaths( void ) { size_t i; wxString path; wxFileName fn( m_BinDir, wxEmptyString ); /* User environment variable path. */ if( ::wxGetEnv( wxT( "KICAD_SEARCH_PATH" ), NULL ) ) m_searchPaths.AddEnvList( wxT( "KICAD_SEARCH_PATH" ) ); /* Hard coded path defined by the application. */ m_searchPaths.Add( ReturnKicadDatasPath() ); /* Standard application data path if it is different from the binary * path. */ if( fn.GetPath() != GetTraits()->GetStandardPaths().GetDataDir() ) m_searchPaths.Add( GetTraits()->GetStandardPaths().GetDataDir() ); /* Up on level relative to binary path with "share" appended. */ fn.RemoveLastDir(); fn.AppendDir( wxT( "share" ) ); #ifndef __WXMSW__ fn.AppendDir( wxT( "kicad" ) ); #endif m_searchPaths.Add( fn.GetPath() ); /* Remove all non-existant paths from the list. */ for( i = 0; i < m_searchPaths.GetCount(); i++ ) { wxLogDebug( wxT( "Checking if search path <" ) + m_searchPaths[i] + wxT( "> exists." ) ); if( !wxFileName::IsDirReadable( m_searchPaths[i] ) ) { wxLogDebug( wxT( "Removing non-existant path <" ) + m_searchPaths[i] + wxT( "> from search path list." ) ); m_searchPaths.RemoveAt( i ); i -= 1; } } } /** /** * Get application settings * Get application settings Loading @@ -450,7 +500,7 @@ bool WinEDA_App::SetBinDir() void WinEDA_App::GetSettings() void WinEDA_App::GetSettings() /*********************************/ /*********************************/ { { wxString Line, Ident; wxString Line, entry; unsigned ii; unsigned ii; m_HelpSize.x = 500; m_HelpSize.x = 500; Loading @@ -468,16 +518,27 @@ void WinEDA_App::GetSettings() if( !m_EDA_Config ) if( !m_EDA_Config ) return; return; /* Last 10 project settings */ m_fileHistory.Load( *m_EDA_Config ); for( ii = 0; ii < 10; ii++ ) { Ident = wxT( "LastProject" ); if( ii ) /* Load the last file history settings from legacy version if this is the Ident << ii; * first time wxFileHistory was used to manage the file history. */ if( m_fileHistory.GetCount() == ( size_t )0 ) { for( ii = 0; ii < ( unsigned )m_fileHistory.GetMaxFiles(); ii++ ) { entry = wxT( "LastProject" ); if( ii != 0 ) entry << ii; if( m_EDA_Config->Read( Ident, &Line ) ) if( m_EDA_Config->Read( entry, &Line ) ) m_LastProject.Add( Line ); { if( Line != wxEmptyString && wxFileName::FileExists( Line ) ) m_fileHistory.AddFileToHistory( Line ); else m_EDA_Config->Write( entry, wxEmptyString ); Line = wxEmptyString; } } } } /* Set default font sizes */ /* Set default font sizes */ Loading Loading @@ -550,8 +611,6 @@ void WinEDA_App::GetSettings() void WinEDA_App::SaveSettings() void WinEDA_App::SaveSettings() /**********************************/ /**********************************/ { { unsigned int i; if( m_EDA_Config == NULL ) if( m_EDA_Config == NULL ) return; return; Loading Loading @@ -580,18 +639,8 @@ void WinEDA_App::SaveSettings() m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() ); m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() ); /* Save last 10 project list */ /* Save the file history list */ for( i = 0; i < 10; i++ ) m_fileHistory.Save( *m_EDA_Config ); { wxString msg = wxT( "LastProject" ); if( i ) msg << i; if( i < m_LastProject.GetCount() ) m_EDA_Config->Write( msg, m_LastProject[i] ); else m_EDA_Config->Write( msg, wxEmptyString ); } } } Loading @@ -607,52 +656,34 @@ void WinEDA_App::SaveSettings() bool WinEDA_App::SetLanguage( bool first_time ) bool WinEDA_App::SetLanguage( bool first_time ) /*********************************************/ /*********************************************/ { { size_t i; wxString path; bool retv = true; // dictionary file name without extend (full name is kicad.mo) // dictionary file name without extend (full name is kicad.mo) wxString DictionaryName( wxT( "kicad" ) ); wxString DictionaryName( wxT( "kicad" ) ); // Real path is kicad/internat/xx_XX or kicad/internat/xx wxString BaseDictionaryPath( wxT( "internat" ) ); wxString dic_path; bool retv = true; if( m_Locale != NULL ) if( m_Locale != NULL ) delete m_Locale; delete m_Locale; m_Locale = new wxLocale(); m_Locale = new wxLocale(); dic_path = ReturnKicadDatasPath() + BaseDictionaryPath; /* Add defined search paths to locale paths */ if( !m_searchPaths.IsEmpty() ) wxLogDebug( wxT( "Adding prefix <" ) + dic_path + wxT( "> to language lookup path." ) ); m_Locale->AddCatalogLookupPathPrefix( dic_path ); /* * Add binary path minus the current subdirectory ( typically /bin ) to * the locale search path. This way the locales can be found when using * custom CMake install paths. * * FIXME: This should be changed when configurable data path support is * added to Kicad. */ if( !m_BinDir.IsEmpty() ) { { wxFileName fn( m_BinDir, wxEmptyString ); for( i = 0; i < m_searchPaths.GetCount(); i++ ) dic_path = fn.GetPath(); int n = dic_path.Find( wxFileName::GetPathSeparator(), true ); if( n != wxNOT_FOUND ) { { dic_path = dic_path( 0, n ); wxFileName fn( m_searchPaths[i], wxEmptyString ); fn.AppendDir( wxT( "internat" ) ); path = fn.GetPath(); wxLogDebug( wxT( "Adding locale lookup path: " ) + path ); m_Locale->AddCatalogLookupPathPrefix( path ); } } wxLogDebug( wxT( "Adding prefix <" ) + dic_path + wxT( "> to language lookup path." ) ); m_Locale->AddCatalogLookupPathPrefix( dic_path ); } } if( !m_Locale->Init( m_LanguageId, wxLOCALE_CONV_ENCODING ) ) if( !m_Locale->Init( m_LanguageId, wxLOCALE_CONV_ENCODING ) ) { { wxLogDebug( wxT( "Failed to initialize " ) + m_Locale->GetName() ); wxLogDebug( wxT( "Failed to initialize " ) + wxLocale::GetLanguageInfo( m_LanguageId )->Description ); delete m_Locale; delete m_Locale; m_Locale = new wxLocale(); m_Locale = new wxLocale(); Loading @@ -661,11 +692,8 @@ bool WinEDA_App::SetLanguage( bool first_time ) retv = false; retv = false; } } if( !first_time ) if( !first_time && m_EDA_CommonConfig ) { if( m_EDA_CommonConfig ) m_EDA_CommonConfig->Write( wxT( "Language" ), m_LanguageId ); m_EDA_CommonConfig->Write( wxT( "Language" ), m_LanguageId ); } if( !m_Locale->IsLoaded( DictionaryName ) ) if( !m_Locale->IsLoaded( DictionaryName ) ) m_Locale->AddCatalog( DictionaryName ); m_Locale->AddCatalog( DictionaryName ); Loading Loading @@ -712,51 +740,45 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id ) wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) /*********************************************************/ /*********************************************************/ { { wxMenu* menu; wxMenuItem* item; wxMenuItem* item; unsigned int ii; unsigned int ii; if( m_Language_Menu == NULL ) item = MasterMenu->FindItem( ID_LANGUAGE_CHOICE ); if( item == NULL ) { { m_Language_Menu = new wxMenu; menu = new wxMenu; for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) { { wxString MenuLabel = s_Language_List[ii].m_DoNotTranslate ? wxString label = s_Language_List[ii].m_DoNotTranslate ? s_Language_List[ii].m_Lang_Label : s_Language_List[ii].m_Lang_Label : wxGetTranslation( wxGetTranslation( s_Language_List[ii].m_Lang_Label ); s_Language_List[ii].m_Lang_Label ); item = new wxMenuItem( m_Language_Menu, item = new wxMenuItem( menu, s_Language_List[ii].m_KI_Lang_Identifier, s_Language_List[ii].m_KI_Lang_Identifier, MenuLabel, label, wxEmptyString, wxITEM_CHECK ); wxEmptyString, wxITEM_CHECK ); SETBITMAPS( s_Language_List[ii].m_Lang_Icon ); SETBITMAPS( s_Language_List[ii].m_Lang_Icon ); m_Language_Menu->Append( item ); menu->Append( item ); } } ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu, menu, ID_LANGUAGE_CHOICE, _( "Language" ), _( "Select application language (only for testing!)" ), language_xpm ); } } for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) { { if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier ) if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier ) m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, true ); true ); else else m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, false ); false ); } if( MasterMenu ) { ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu, m_Language_Menu, ID_LANGUAGE_CHOICE, _( "Language" ), _( "Select application language (only for testing!)" ), language_xpm ); } } return m_Language_Menu; return menu; } } Loading Loading
CHANGELOG.txt +17 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,23 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with email address. email address. 2009-Jan-11 UPDATE Wayne Stambaugh <stambaughw@verizon.net> ================================================================================ ++All * Replace Kicad file history implementation with wxFileHistory. * Laid groundwork for search paths using wxPathList in EDA_Appl. * Made ReCreateMenuBar actually recreate the menu bar. Now language updates to menus can be changed without restarting program. * Lots of general housekeeping, simplification, and code beautifying. ++EESchema * Fix zoom and pan bug in library viewer panel due to incorrect DrawPanel rectangle. * Add zoom accelerator keys to library viewer (works in GTK, not Windows). * Add Postscript header to new print dialog so Linux build works. ++PcbNew * Add Postscript header to new print dialog so Linux build works. 2009-Jan-17 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2009-Jan-17 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> ================================================================================ ================================================================================ ++All: ++All: Loading
common/basicframe.cpp +27 −36 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,6 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, int idtype, m_Ident = idtype; m_Ident = idtype; SetFont( *g_StdFont ); SetFont( *g_StdFont ); m_MenuBar = NULL; // menu du haut d'ecran m_HToolBar = NULL; m_HToolBar = NULL; m_FrameIsActive = TRUE; m_FrameIsActive = TRUE; m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT; m_MsgFrameHeight = MSG_PANEL_DEFAULT_HEIGHT; Loading Loading @@ -169,48 +168,40 @@ void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName ) /* Met a jour la liste des anciens projets /* Met a jour la liste des anciens projets */ */ { { unsigned ii; wxGetApp().m_fileHistory.AddFileToHistory( FullFileName ); ReCreateMenuBar(); } if( FullFileName.IsEmpty() ) return; //suppression d'une ancienne trace eventuelle du meme fichier /** for( ii = 0; ii < wxGetApp().m_LastProject.GetCount(); ) * Fetch the file name from the file history list. { */ if( wxGetApp().m_LastProject[ii].IsEmpty() ) wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId, break; const wxString& type ) #ifdef __WINDOWS__ if( wxGetApp().m_LastProject[ii].CmpNoCase( FullFileName ) == 0 ) #else if( wxGetApp().m_LastProject[ii] == FullFileName ) #endif { { wxGetApp().m_LastProject.RemoveAt( ii ); wxString fn, msg; } size_t i; else int baseId = wxGetApp().m_fileHistory.GetBaseId(); ii++; } while( wxGetApp().m_LastProject.GetCount() >= wxGetApp().m_LastProjectMaxCount ) wxASSERT( cmdId >= baseId { && cmdId < baseId + ( int )wxGetApp().m_fileHistory.GetCount() ); wxGetApp().m_LastProject.RemoveAt( wxGetApp().m_LastProject.GetCount() - 1 ); } wxGetApp().m_LastProject.Insert( FullFileName, 0 ); i = ( size_t )( cmdId - baseId ); if( i < wxGetApp().m_fileHistory.GetCount() ) { fn = wxGetApp().m_fileHistory.GetHistoryFile( i ); if( !wxFileName::FileExists( fn ) ) { msg = type + _( " file <" ) + fn + _( "> was not found." ); DisplayError( this, msg ); wxGetApp().m_fileHistory.RemoveFileFromHistory( i ); fn = wxEmptyString; ReCreateMenuBar(); ReCreateMenuBar(); } } } return fn; /**************************************************/ wxString WinEDA_BasicFrame::GetLastProject( int rang ) /**************************************************/ { if( rang < 0 ) rang = 0; if( (unsigned) rang >= wxGetApp().m_LastProject.GetCount() ) return wxEmptyString; return wxGetApp().m_LastProject[rang]; } } Loading
common/drawframe.cpp +20 −33 Original line number Original line Diff line number Diff line Loading @@ -47,7 +47,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, DrawPanel = NULL; DrawPanel = NULL; MsgPanel = NULL; MsgPanel = NULL; m_CurrentScreen = NULL; m_CurrentScreen = NULL; m_MenuBar = NULL; // main meun frame m_ID_current_state = 0; m_ID_current_state = 0; m_HTOOL_current_state = 0; m_HTOOL_current_state = 0; m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines m_Draw_Axis = FALSE; // TRUE pour avoir les axes dessines Loading @@ -60,10 +59,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, // Internal units per inch // Internal units per inch // = 1000 for schema, = 10000 for PCB // = 1000 for schema, = 10000 for PCB m_InternalUnits = EESCHEMA_INTERNAL_UNIT; m_InternalUnits = EESCHEMA_INTERNAL_UNIT; if( ( m_Ident == PCB_FRAME ) || ( m_Ident == GERBER_FRAME ) || ( m_Ident == CVPCB_DISPLAY_FRAME ) || ( m_Ident == MODULE_EDITOR_FRAME ) ) m_InternalUnits = PCB_INTERNAL_UNIT; minsize.x = 470; minsize.x = 470; minsize.y = 350 + m_MsgFrameHeight; minsize.y = 350 + m_MsgFrameHeight; Loading Loading @@ -91,18 +86,13 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype, m_FramePos.x = m_FramePos.y = 0; m_FramePos.x = m_FramePos.y = 0; m_FrameSize.y -= m_MsgFrameHeight; m_FrameSize.y -= m_MsgFrameHeight; if( m_Ident != DISPLAY3D_FRAME ) DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ), m_FrameSize ); { DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ), m_FrameSize ); MsgPanel = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ), MsgPanel = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ), wxSize( m_FrameSize.x, wxSize( m_FrameSize.x, m_MsgFrameHeight ) ); m_MsgFrameHeight ) ); MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red, MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red, ColorRefs[LIGHTGRAY].m_Green, ColorRefs[LIGHTGRAY].m_Green, ColorRefs[LIGHTGRAY].m_Blue ) ); ColorRefs[LIGHTGRAY].m_Blue ) ); } } } /****************************************/ /****************************************/ Loading Loading @@ -588,22 +578,16 @@ void WinEDA_DrawFrame::AdjustScrollBars() int zoom = screen->GetZoom(); int zoom = screen->GetZoom(); int xUnit, yUnit; int xUnit, yUnit; if( screen == NULL ) if( screen == NULL || DrawPanel == NULL ) return; if( DrawPanel == NULL ) return; return; draw_size = screen->ReturnPageSize(); // La zone d'affichage est reglee a une taille double de la feuille de travail: // La zone d'affichage est reglee a une taille double de la feuille de travail: draw_size.x *= 2; draw_size.y *= 2; draw_size = screen->ReturnPageSize() * 2; // On utilise le centre de l'ecran comme position de reference, donc // On utilise le centre de l'ecran comme position de reference, donc // la surface de trace doit etre augmentee // la surface de trace doit etre augmentee panel_size = DrawPanel->GetClientSize(); panel_size = DrawPanel->GetClientSize() * zoom; panel_size.x *= zoom; panel_size.y *= zoom; draw_size += panel_size / 2; draw_size.x += panel_size.x / 2; draw_size.y += panel_size.y / 2; if( screen->m_Center ) if( screen->m_Center ) Loading @@ -622,8 +606,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() screen->m_DrawOrg.y -= screen->m_DrawOrg.y % 256; screen->m_DrawOrg.y -= screen->m_DrawOrg.y % 256; // Calcul du nombre de scrolls (en unites de scrool ) // Calcul du nombre de scrolls (en unites de scrool ) scrollbar_number.x = draw_size.x / (DrawPanel->m_Scroll_unit * zoom); scrollbar_number = draw_size / (DrawPanel->m_Scroll_unit * zoom); scrollbar_number.y = draw_size.y / (DrawPanel->m_Scroll_unit * zoom); xUnit = yUnit = DrawPanel->m_Scroll_unit; xUnit = yUnit = DrawPanel->m_Scroll_unit; Loading @@ -631,13 +614,12 @@ void WinEDA_DrawFrame::AdjustScrollBars() xUnit = 1; xUnit = 1; if( yUnit <= 1 ) if( yUnit <= 1 ) yUnit = 1; yUnit = 1; xUnit *= zoom; yUnit *= zoom; xUnit *= zoom; yUnit *= zoom; // Calcul de la position, curseur place au centre d'ecran // Calcul de la position, curseur place au centre d'ecran scrollbar_pos = screen->m_Curseur; scrollbar_pos = screen->m_Curseur; scrollbar_pos -= screen->m_DrawOrg; scrollbar_pos.x -= screen->m_DrawOrg.x; scrollbar_pos.y -= screen->m_DrawOrg.y; scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.x -= panel_size.x / 2; scrollbar_pos.y -= panel_size.y / 2; scrollbar_pos.y -= panel_size.y / 2; Loading Loading @@ -698,7 +680,12 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) int id = event.GetId(); int id = event.GetId(); wxGetApp().SetLanguageIdentifier( id ); wxGetApp().SetLanguageIdentifier( id ); wxGetApp().SetLanguage(); if ( wxGetApp().SetLanguage() ) { wxLogDebug( wxT( "Recreating menu bar due to language change." ) ); ReCreateMenuBar(); Refresh(); } } } Loading
common/drawpanel.cpp +41 −95 Original line number Original line Diff line number Diff line Loading @@ -97,12 +97,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color ) * Draw the schematic cursor which is usually on grid * Draw the schematic cursor which is usually on grid */ */ { { if( m_CursorLevel != 0 ) if( m_CursorLevel != 0 || DC == NULL ) { return; } if( DC == NULL ) return; return; wxPoint Cursor = GetScreen()->m_Curseur; wxPoint Cursor = GetScreen()->m_Curseur; Loading Loading @@ -201,36 +196,6 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC ) } } /*********************************************************************/ wxPoint WinEDA_DrawPanel::CalcAbsolutePosition( const wxPoint& rel_pos ) /*********************************************************************/ /** Function CalcAbsolutePosition * @return absolute position in pixels, considering the scroll amount * @param rel_pos = relative position (screen position) in pixel * ( relative position = position in the panel draw area on screen ) */ { wxPoint pos; #ifdef WX_ZOOM CalcUnscrolledPosition( rel_pos.x, rel_pos.y, &pos.x, &pos.y ); #else int ii, jj; GetViewStart( &pos.x, &pos.y ); // pos is the origin in scroll units GetScrollPixelsPerUnit( &ii, &jj ); pos.x *= ii; pos.y *= jj; // pos is the origin in pixel units pos.x += rel_pos.x; pos.y += rel_pos.y; #endif return pos; } /**********************************************************************/ /**********************************************************************/ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) /**********************************************************************/ /**********************************************************************/ Loading @@ -240,9 +205,7 @@ wxPoint WinEDA_DrawPanel::CursorRealPosition( const wxPoint& ScreenPos ) * @param ScreenPos = absolute position in pixels * @param ScreenPos = absolute position in pixels */ */ { { wxPoint curpos = GetScreen()->CursorRealPosition( ScreenPos ); return GetScreen()->CursorRealPosition( ScreenPos ); return curpos; } } Loading @@ -268,13 +231,12 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN ); display_rect.Inflate( -PIXEL_MARGIN, -PIXEL_MARGIN ); // Conversion en coord physiques // Conversion en coord physiques pos = CalcAbsolutePosition( display_rect.GetPosition() ); pos = CalcUnscrolledPosition( display_rect.GetPosition() ); pos.x *= GetZoom(); pos.x *= GetZoom(); pos.y *= GetZoom(); pos.y *= GetZoom(); pos.x += GetScreen()->m_DrawOrg.x; pos += GetScreen()->m_DrawOrg; pos.y += GetScreen()->m_DrawOrg.y; display_rect.SetX( pos.x ); display_rect.SetX( pos.x ); display_rect.SetY( pos.y ); display_rect.SetY( pos.y ); Loading Loading @@ -385,18 +347,13 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void ) wxSize size; wxSize size; wxPoint realpos; wxPoint realpos; size = GetClientSize(); size = GetClientSize() / 2; realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) ); size.x /= 2; size.y /= 2; realpos = CalcAbsolutePosition( wxPoint( size.x, size.y ) ); realpos.x *= GetZoom(); realpos.x *= GetZoom(); realpos.y *= GetZoom(); realpos.y *= GetZoom(); realpos.x += GetScreen()->m_DrawOrg.x; realpos += GetScreen()->m_DrawOrg; realpos.y += GetScreen()->m_DrawOrg.y; return realpos; return realpos; } } Loading Loading @@ -428,11 +385,9 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse ) #ifdef WX_ZOOM #ifdef WX_ZOOM CalcScrolledPosition( Mouse.x, Mouse.y, &mouse.x, &mouse.y ); CalcScrolledPosition( Mouse.x, Mouse.y, &mouse.x, &mouse.y ); #else #else mouse = Mouse; mouse = Mouse - GetScreen()->m_StartVisu; mouse.x -= GetScreen()->m_StartVisu.x; mouse.y -= GetScreen()->m_StartVisu.y; #endif #endif GRMouseWarp( this, mouse ); WarpPointer( mouse.x, mouse.y ); } } Loading Loading @@ -543,11 +498,9 @@ void WinEDA_DrawPanel::SetBoundaryBox() #ifdef WX_ZOOM #ifdef WX_ZOOM m_ClipBox.m_Pos.x *= GetZoom(); m_ClipBox.m_Pos.x *= GetZoom(); m_ClipBox.m_Pos.y *= GetZoom(); m_ClipBox.m_Pos.y *= GetZoom(); m_ClipBox.m_Size.x *= GetZoom(); m_ClipBox.m_Size *= GetZoom(); m_ClipBox.m_Size.y *= GetZoom(); #else #else m_ClipBox.m_Pos.x -= GetScreen()->m_StartVisu.x; m_ClipBox.m_Pos -= GetScreen()->m_StartVisu; m_ClipBox.m_Pos.y -= GetScreen()->m_StartVisu.y; #endif #endif m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4; m_ScrollButt_unit = MIN( Screen->m_SizeVisu.x, Screen->m_SizeVisu.y ) / 4; Loading Loading @@ -767,13 +720,9 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) org.x *= zoom; org.x *= zoom; org.y *= zoom; org.y *= zoom; org.x += screen->m_DrawOrg.x; org += screen->m_DrawOrg; org.y += screen->m_DrawOrg.y; size = GetClientSize(); size.x *= zoom; size = GetClientSize() * zoom; size.y *= zoom; pasx = screen->m_Grid.x * m_Parent->m_InternalUnits; pasx = screen->m_Grid.x * m_Parent->m_InternalUnits; pasy = screen->m_Grid.y * m_Parent->m_InternalUnits; pasy = screen->m_Grid.y * m_Parent->m_InternalUnits; Loading Loading @@ -868,8 +817,7 @@ bool WinEDA_DrawPanel::OnRightClick( wxMouseEvent& event ) wxPoint pos; wxPoint pos; wxMenu MasterMenu; wxMenu MasterMenu; pos.x = event.GetX(); pos = event.GetPosition(); pos.y = event.GetY(); if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) if( !m_Parent->OnRightClick( pos, &MasterMenu ) ) return false; return false; Loading Loading @@ -921,13 +869,20 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event ) { { wxRect rect = GetRect(); wxRect rect = GetRect(); wxLogDebug( wxT( "OnMouseWheel() cursor position: (%d, %d)." ), /* This fixes a bad rectangle horizontal position returned by the event.m_x, event.m_y ); * schematic library veiwer panel. It may have something to do with * the sash window. */ rect.Offset( -rect.x, -rect.y ); /* Ignore scroll events if the cursor is outside the drawing area. */ /* Ignore scroll events if the cursor is outside the drawing area. */ if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled() if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled() || !rect.Contains( event.GetPosition() ) ) || !rect.Contains( event.GetPosition() ) ) { { wxLogDebug( wxT( "OnMouseWheel() position(%d, %d) " \ "rectangle(%d, %d, %d, %d)" ), event.GetPosition().x, event.GetPosition().y, rect.x, rect.y, rect.width, rect.height ); event.Skip(); event.Skip(); return; return; } } Loading Loading @@ -1029,7 +984,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) localrealbutt |= localbutt; /* compensation defaut wxGTK */ localrealbutt |= localbutt; /* compensation defaut wxGTK */ /* Compute absolute m_MousePosition in pixel units: */ /* Compute absolute m_MousePosition in pixel units: */ screen->m_MousePositionInPixels = CalcAbsolutePosition( wxPoint( event.GetX(), event.GetY() ) ); screen->m_MousePositionInPixels = CalcUnscrolledPosition( event.GetPosition() ); /* Compute absolute m_MousePosition in user units: */ /* Compute absolute m_MousePosition in user units: */ screen->m_MousePosition = CursorRealPosition( screen->m_MousePositionInPixels ); screen->m_MousePosition = CursorRealPosition( screen->m_MousePositionInPixels ); Loading Loading @@ -1247,6 +1202,7 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) { { long key, localkey; long key, localkey; bool escape = FALSE; bool escape = FALSE; wxPoint pos; key = localkey = event.GetKeyCode(); key = localkey = event.GetKeyCode(); Loading Loading @@ -1295,27 +1251,17 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event ) } } } } /* some key commands use the mouse position: refresh it */ /* Some key commands use the current mouse position: refresh it */ #if wxCHECK_VERSION( 2, 8, 0 ) pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() ); wxPoint mouse_pos = wxGetMousePosition(); // Get the mouse position on screen wxPoint win_pos = GetScreenPosition(); // get the draw area (panel)position on screen mouse_pos -= win_pos; // mouse_pos = is the mouse position relative to the panel /* Compute absolute m_MousePosition in pixel units (i.e. considering the current scrool) : */ Screen->m_MousePositionInPixels = CalcAbsolutePosition( mouse_pos ); /* Compute absolute m_MousePosition in user units: */ Screen->m_MousePosition = CursorRealPosition( Screen->m_MousePositionInPixels ); #else /* Compute absolute mouse position in pixel units (i.e. considering the current scrool) : */ Screen->m_MousePositionInPixels = pos; /* if wxGetMousePosition() does not exist, /* Compute absolute mouse position in user units: */ * m_Cursor should be ok, use it to calculate the cursor position on screen Screen->m_MousePosition = CursorRealPosition( pos ); */ Screen->m_MousePositionInPixels = CursorScreenPosition(); #endif m_Parent->GeneralControle( &DC, Screen->m_MousePositionInPixels ); m_Parent->GeneralControle( &DC, pos ); #if 0 #if 0 event.Skip(); // Allow menu shortcut processing event.Skip(); // Allow menu shortcut processing Loading
common/edaappl.cpp +112 −90 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,10 @@ #include "fctsys.h" #include "fctsys.h" #include "wx/html/htmlwin.h" #include "wx/html/htmlwin.h" #include "wx/fs_zip.h" #include "wx/fs_zip.h" #include <wx/dir.h> #include <wx/filename.h> #include <wx/filename.h> #include <wx/stdpaths.h> #include <wx/apptrait.h> #include "common.h" #include "common.h" #include "worksheet.h" #include "worksheet.h" Loading Loading @@ -212,13 +215,11 @@ static struct LANGUAGE_DESCR s_Language_List[] = WinEDA_App::WinEDA_App() WinEDA_App::WinEDA_App() { { m_Checker = NULL; m_Checker = NULL; m_LastProjectMaxCount = 10; m_HtmlCtrl = NULL; m_HtmlCtrl = NULL; m_EDA_CommonConfig = NULL; m_EDA_CommonConfig = NULL; m_EDA_Config = NULL; m_EDA_Config = NULL; m_Env_Defined = FALSE; m_Env_Defined = FALSE; m_LanguageId = wxLANGUAGE_DEFAULT; m_LanguageId = wxLANGUAGE_DEFAULT; m_Language_Menu = NULL; m_Locale = NULL; m_Locale = NULL; m_PdfBrowserIsDefault = TRUE; m_PdfBrowserIsDefault = TRUE; } } Loading Loading @@ -281,7 +282,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) /* Init parameters for configuration */ /* Init parameters for configuration */ SetVendorName( wxT( "kicad" ) ); SetVendorName( wxT( "kicad" ) ); SetAppName( name ); SetAppName( name.Lower() ); m_EDA_Config = new wxConfig( name ); m_EDA_Config = new wxConfig( name ); m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); Loading Loading @@ -314,6 +315,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) // Analyse the command line & init binary path // Analyse the command line & init binary path SetBinDir(); SetBinDir(); SetDefaultSearchPaths(); ReadPdfBrowserInfos(); ReadPdfBrowserInfos(); // Internationalisation: loading the kicad suitable Dictionnary // Internationalisation: loading the kicad suitable Dictionnary Loading Loading @@ -438,9 +440,57 @@ bool WinEDA_App::SetBinDir() while( m_BinDir.Last() != '/' ) while( m_BinDir.Last() != '/' ) m_BinDir.RemoveLast(); m_BinDir.RemoveLast(); wxLogDebug( wxT( "Executable path the Kicad way: " ) + m_BinDir ); wxLogDebug( wxT( "Executable path the wxWidgets way: " ) + GetTraits()->GetStandardPaths().GetExecutablePath() ); return TRUE; return TRUE; } } /** * Set search paths for libraries, modules, internationalization files, etc. */ void WinEDA_App::SetDefaultSearchPaths( void ) { size_t i; wxString path; wxFileName fn( m_BinDir, wxEmptyString ); /* User environment variable path. */ if( ::wxGetEnv( wxT( "KICAD_SEARCH_PATH" ), NULL ) ) m_searchPaths.AddEnvList( wxT( "KICAD_SEARCH_PATH" ) ); /* Hard coded path defined by the application. */ m_searchPaths.Add( ReturnKicadDatasPath() ); /* Standard application data path if it is different from the binary * path. */ if( fn.GetPath() != GetTraits()->GetStandardPaths().GetDataDir() ) m_searchPaths.Add( GetTraits()->GetStandardPaths().GetDataDir() ); /* Up on level relative to binary path with "share" appended. */ fn.RemoveLastDir(); fn.AppendDir( wxT( "share" ) ); #ifndef __WXMSW__ fn.AppendDir( wxT( "kicad" ) ); #endif m_searchPaths.Add( fn.GetPath() ); /* Remove all non-existant paths from the list. */ for( i = 0; i < m_searchPaths.GetCount(); i++ ) { wxLogDebug( wxT( "Checking if search path <" ) + m_searchPaths[i] + wxT( "> exists." ) ); if( !wxFileName::IsDirReadable( m_searchPaths[i] ) ) { wxLogDebug( wxT( "Removing non-existant path <" ) + m_searchPaths[i] + wxT( "> from search path list." ) ); m_searchPaths.RemoveAt( i ); i -= 1; } } } /** /** * Get application settings * Get application settings Loading @@ -450,7 +500,7 @@ bool WinEDA_App::SetBinDir() void WinEDA_App::GetSettings() void WinEDA_App::GetSettings() /*********************************/ /*********************************/ { { wxString Line, Ident; wxString Line, entry; unsigned ii; unsigned ii; m_HelpSize.x = 500; m_HelpSize.x = 500; Loading @@ -468,16 +518,27 @@ void WinEDA_App::GetSettings() if( !m_EDA_Config ) if( !m_EDA_Config ) return; return; /* Last 10 project settings */ m_fileHistory.Load( *m_EDA_Config ); for( ii = 0; ii < 10; ii++ ) { Ident = wxT( "LastProject" ); if( ii ) /* Load the last file history settings from legacy version if this is the Ident << ii; * first time wxFileHistory was used to manage the file history. */ if( m_fileHistory.GetCount() == ( size_t )0 ) { for( ii = 0; ii < ( unsigned )m_fileHistory.GetMaxFiles(); ii++ ) { entry = wxT( "LastProject" ); if( ii != 0 ) entry << ii; if( m_EDA_Config->Read( Ident, &Line ) ) if( m_EDA_Config->Read( entry, &Line ) ) m_LastProject.Add( Line ); { if( Line != wxEmptyString && wxFileName::FileExists( Line ) ) m_fileHistory.AddFileToHistory( Line ); else m_EDA_Config->Write( entry, wxEmptyString ); Line = wxEmptyString; } } } } /* Set default font sizes */ /* Set default font sizes */ Loading Loading @@ -550,8 +611,6 @@ void WinEDA_App::GetSettings() void WinEDA_App::SaveSettings() void WinEDA_App::SaveSettings() /**********************************/ /**********************************/ { { unsigned int i; if( m_EDA_Config == NULL ) if( m_EDA_Config == NULL ) return; return; Loading Loading @@ -580,18 +639,8 @@ void WinEDA_App::SaveSettings() m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() ); m_EDA_Config->Write( wxT( "WorkingDir" ), wxGetCwd() ); /* Save last 10 project list */ /* Save the file history list */ for( i = 0; i < 10; i++ ) m_fileHistory.Save( *m_EDA_Config ); { wxString msg = wxT( "LastProject" ); if( i ) msg << i; if( i < m_LastProject.GetCount() ) m_EDA_Config->Write( msg, m_LastProject[i] ); else m_EDA_Config->Write( msg, wxEmptyString ); } } } Loading @@ -607,52 +656,34 @@ void WinEDA_App::SaveSettings() bool WinEDA_App::SetLanguage( bool first_time ) bool WinEDA_App::SetLanguage( bool first_time ) /*********************************************/ /*********************************************/ { { size_t i; wxString path; bool retv = true; // dictionary file name without extend (full name is kicad.mo) // dictionary file name without extend (full name is kicad.mo) wxString DictionaryName( wxT( "kicad" ) ); wxString DictionaryName( wxT( "kicad" ) ); // Real path is kicad/internat/xx_XX or kicad/internat/xx wxString BaseDictionaryPath( wxT( "internat" ) ); wxString dic_path; bool retv = true; if( m_Locale != NULL ) if( m_Locale != NULL ) delete m_Locale; delete m_Locale; m_Locale = new wxLocale(); m_Locale = new wxLocale(); dic_path = ReturnKicadDatasPath() + BaseDictionaryPath; /* Add defined search paths to locale paths */ if( !m_searchPaths.IsEmpty() ) wxLogDebug( wxT( "Adding prefix <" ) + dic_path + wxT( "> to language lookup path." ) ); m_Locale->AddCatalogLookupPathPrefix( dic_path ); /* * Add binary path minus the current subdirectory ( typically /bin ) to * the locale search path. This way the locales can be found when using * custom CMake install paths. * * FIXME: This should be changed when configurable data path support is * added to Kicad. */ if( !m_BinDir.IsEmpty() ) { { wxFileName fn( m_BinDir, wxEmptyString ); for( i = 0; i < m_searchPaths.GetCount(); i++ ) dic_path = fn.GetPath(); int n = dic_path.Find( wxFileName::GetPathSeparator(), true ); if( n != wxNOT_FOUND ) { { dic_path = dic_path( 0, n ); wxFileName fn( m_searchPaths[i], wxEmptyString ); fn.AppendDir( wxT( "internat" ) ); path = fn.GetPath(); wxLogDebug( wxT( "Adding locale lookup path: " ) + path ); m_Locale->AddCatalogLookupPathPrefix( path ); } } wxLogDebug( wxT( "Adding prefix <" ) + dic_path + wxT( "> to language lookup path." ) ); m_Locale->AddCatalogLookupPathPrefix( dic_path ); } } if( !m_Locale->Init( m_LanguageId, wxLOCALE_CONV_ENCODING ) ) if( !m_Locale->Init( m_LanguageId, wxLOCALE_CONV_ENCODING ) ) { { wxLogDebug( wxT( "Failed to initialize " ) + m_Locale->GetName() ); wxLogDebug( wxT( "Failed to initialize " ) + wxLocale::GetLanguageInfo( m_LanguageId )->Description ); delete m_Locale; delete m_Locale; m_Locale = new wxLocale(); m_Locale = new wxLocale(); Loading @@ -661,11 +692,8 @@ bool WinEDA_App::SetLanguage( bool first_time ) retv = false; retv = false; } } if( !first_time ) if( !first_time && m_EDA_CommonConfig ) { if( m_EDA_CommonConfig ) m_EDA_CommonConfig->Write( wxT( "Language" ), m_LanguageId ); m_EDA_CommonConfig->Write( wxT( "Language" ), m_LanguageId ); } if( !m_Locale->IsLoaded( DictionaryName ) ) if( !m_Locale->IsLoaded( DictionaryName ) ) m_Locale->AddCatalog( DictionaryName ); m_Locale->AddCatalog( DictionaryName ); Loading Loading @@ -712,51 +740,45 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id ) wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) /*********************************************************/ /*********************************************************/ { { wxMenu* menu; wxMenuItem* item; wxMenuItem* item; unsigned int ii; unsigned int ii; if( m_Language_Menu == NULL ) item = MasterMenu->FindItem( ID_LANGUAGE_CHOICE ); if( item == NULL ) { { m_Language_Menu = new wxMenu; menu = new wxMenu; for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) { { wxString MenuLabel = s_Language_List[ii].m_DoNotTranslate ? wxString label = s_Language_List[ii].m_DoNotTranslate ? s_Language_List[ii].m_Lang_Label : s_Language_List[ii].m_Lang_Label : wxGetTranslation( wxGetTranslation( s_Language_List[ii].m_Lang_Label ); s_Language_List[ii].m_Lang_Label ); item = new wxMenuItem( m_Language_Menu, item = new wxMenuItem( menu, s_Language_List[ii].m_KI_Lang_Identifier, s_Language_List[ii].m_KI_Lang_Identifier, MenuLabel, label, wxEmptyString, wxITEM_CHECK ); wxEmptyString, wxITEM_CHECK ); SETBITMAPS( s_Language_List[ii].m_Lang_Icon ); SETBITMAPS( s_Language_List[ii].m_Lang_Icon ); m_Language_Menu->Append( item ); menu->Append( item ); } } ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu, menu, ID_LANGUAGE_CHOICE, _( "Language" ), _( "Select application language (only for testing!)" ), language_xpm ); } } for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) { { if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier ) if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier ) m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, true ); true ); else else m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, false ); false ); } if( MasterMenu ) { ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu, m_Language_Menu, ID_LANGUAGE_CHOICE, _( "Language" ), _( "Select application language (only for testing!)" ), language_xpm ); } } return m_Language_Menu; return menu; } } Loading