Commit 292c1f09 authored by jean-pierre charras's avatar jean-pierre charras

Kicad: bug fix in menubar when changing the selected locale.

fctsys.h: remove useless define.
Fix minor issues and add minor enhancements.
parent f3cc32f9
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#ifndef KICAD_BUILD_VERSION #ifndef KICAD_BUILD_VERSION
#if defined KICAD_GOST #if defined KICAD_GOST
# define KICAD_BUILD_VERSION "(2011-nov-30 GOST)" # define KICAD_BUILD_VERSION "(2012-oct-18 GOST)"
#else #else
# define KICAD_BUILD_VERSION "(2011-nov-30)" # define KICAD_BUILD_VERSION "(2012-oct-18)"
#endif #endif
#endif #endif
......
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project> <wxFormBuilder_Project>
<FileVersion major="1" minor="10" /> <FileVersion major="1" minor="11" />
<object class="Project" expanded="1"> <object class="Project" expanded="1">
<property name="class_decoration" /> <property name="class_decoration" />
<property name="code_generation">C++</property> <property name="code_generation">C++</property>
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010) // C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{ {
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
...@@ -35,6 +35,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow ...@@ -35,6 +35,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
bSizerLeft->Add( m_historyList, 1, wxALL|wxEXPAND, 5 ); bSizerLeft->Add( m_historyList, 1, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerLeft, 1, wxEXPAND, 5 ); bSizerMain->Add( bSizerLeft, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerRight; wxBoxSizer* bSizerRight;
...@@ -56,8 +57,10 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow ...@@ -56,8 +57,10 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
m_buttonBrowse = new wxButton( this, ID_EXTRA_TOOL, _("Select by Browser"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonBrowse = new wxButton( this, ID_EXTRA_TOOL, _("Select by Browser"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerRight->Add( m_buttonBrowse, 0, wxALL|wxEXPAND, 5 ); bSizerRight->Add( m_buttonBrowse, 0, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); bSizerMain->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL, 5 );
this->SetSizer( bSizerMain ); this->SetSizer( bSizerMain );
this->Layout(); this->Layout();
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010) // C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_get_component_base__ #ifndef __DIALOG_GET_COMPONENT_BASE_H__
#define __dialog_get_component_base__ #define __DIALOG_GET_COMPONENT_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
...@@ -32,7 +34,7 @@ ...@@ -32,7 +34,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_GET_COMPONENT_BASE /// Class DIALOG_GET_COMPONENT_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_GET_COMPONENT_BASE : public wxDialog class DIALOG_GET_COMPONENT_BASE : public DIALOG_SHIM
{ {
private: private:
...@@ -55,9 +57,9 @@ class DIALOG_GET_COMPONENT_BASE : public wxDialog ...@@ -55,9 +57,9 @@ class DIALOG_GET_COMPONENT_BASE : public wxDialog
public: public:
DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 375,210 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 375,210 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_GET_COMPONENT_BASE(); ~DIALOG_GET_COMPONENT_BASE();
}; };
#endif //__dialog_get_component_base__ #endif //__DIALOG_GET_COMPONENT_BASE_H__
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#include <fctsys.h> #include <fctsys.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <gr_basic.h>
#include <common.h>
#include <macros.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
...@@ -30,7 +27,7 @@ END_EVENT_TABLE() ...@@ -30,7 +27,7 @@ END_EVENT_TABLE()
EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
const wxArrayString& aItemList, const wxString& aRefText, const wxArrayString& aItemList, const wxString& aRefText,
void(* aCallBackFunction)(wxString& Text), wxPoint aPos ) : void(* aCallBackFunction)(wxString& Text), wxPoint aPos ) :
wxDialog( aParent, wxID_ANY, aTitle, aPos, wxDefaultSize, DIALOG_SHIM( aParent, wxID_ANY, aTitle, aPos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER ) wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
{ {
m_callBackFct = aCallBackFunction; m_callBackFct = aCallBackFunction;
...@@ -41,18 +38,30 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl ...@@ -41,18 +38,30 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
SetSizer( GeneralBoxSizer ); SetSizer( GeneralBoxSizer );
m_listBox = new wxListBox( this, ID_LISTBOX_LIST, wxDefaultPosition, m_listBox = new wxListBox( this, ID_LISTBOX_LIST, wxDefaultPosition,
wxSize( 300, 200 ), 0, NULL, wxDefaultSize, 0, NULL,
wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL ); wxLB_NEEDED_SB | wxLB_SINGLE | wxLB_HSCROLL );
m_listBox->SetMinSize( wxSize( 200, 200 ) );
GeneralBoxSizer->Add( m_listBox, 2, wxGROW | wxALL, 5 ); GeneralBoxSizer->Add( m_listBox, 2, wxGROW | wxALL, 5 );
InsertItems( aItemList, 0 ); InsertItems( aItemList, 0 );
if( !aRefText.IsEmpty() ) // try to select the item matching aRefText
{
for( unsigned ii = 0; ii < aItemList.GetCount(); ii++ )
if( aItemList[ii] == aRefText )
{
m_listBox->SetSelection( ii );
break;
}
}
if( m_callBackFct ) if( m_callBackFct )
{ {
m_messages = new wxTextCtrl( this, -1, wxEmptyString, m_messages = new wxTextCtrl( this, -1, wxEmptyString,
wxDefaultPosition, wxSize( -1, 60 ), wxDefaultPosition, wxDefaultSize,
wxTE_READONLY | wxTE_MULTILINE ); wxTE_READONLY | wxTE_MULTILINE );
m_messages->SetMinSize( wxSize( -1, 60 ) );
GeneralBoxSizer->Add( m_messages, 1, wxGROW | wxALL, 5 ); GeneralBoxSizer->Add( m_messages, 1, wxGROW | wxALL, 5 );
} }
......
...@@ -256,8 +256,10 @@ wxString EDA_FileSelector( const wxString& Title, ...@@ -256,8 +256,10 @@ wxString EDA_FileSelector( const wxString& Title,
wxString defaultpath = Path; wxString defaultpath = Path;
wxString dotted_Ext = wxT(".") + Ext; wxString dotted_Ext = wxT(".") + Ext;
defaultname.Replace( wxT( "/" ), STRING_DIR_SEP ); #ifdef __WINDOWS__
defaultpath.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultname.Replace( wxT( "/" ), wxT( "\\" ) );
defaultpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
if( defaultpath.IsEmpty() ) if( defaultpath.IsEmpty() )
defaultpath = wxGetCwd(); defaultpath = wxGetCwd();
...@@ -421,7 +423,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para ...@@ -421,7 +423,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
FullFileName = FindKicadFile( ExecFile ); FullFileName = FindKicadFile( ExecFile );
#ifdef __WXMAC__ #ifdef __WXMAC__
if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) ) if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) )
{ {
ProcessExecute( wxGetApp().GetExecutablePath() + wxT("/") + ExecFile + wxT(" ") + param ); ProcessExecute( wxGetApp().GetExecutablePath() + wxT("/") + ExecFile + wxT(" ") + param );
} else { } else {
......
...@@ -298,7 +298,8 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, ...@@ -298,7 +298,8 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
else else
{ {
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() ) if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename; m_CurrentOptionFile = wxGetCwd() + wxFileName::GetPathSeparator()
+ g_Prj_Config_LocalFilename;
else else
m_CurrentOptionFile = g_Prj_Config_LocalFilename; m_CurrentOptionFile = g_Prj_Config_LocalFilename;
} }
...@@ -352,7 +353,8 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, ...@@ -352,7 +353,8 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
else else
{ {
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() ) if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename; m_CurrentOptionFile = wxGetCwd() + wxFileName::GetPathSeparator()
+ g_Prj_Config_LocalFilename;
else else
m_CurrentOptionFile = g_Prj_Config_LocalFilename; m_CurrentOptionFile = g_Prj_Config_LocalFilename;
} }
......
...@@ -16,11 +16,10 @@ ...@@ -16,11 +16,10 @@
CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame ) CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame )
{ {
static wxString OldLibName; static wxString OldLibName;
wxString msg;
wxArrayString libNamesList; wxArrayString libNamesList;
int count = CMP_LIBRARY::GetLibraryCount();
CMP_LIBRARY* Lib = NULL; CMP_LIBRARY* Lib = NULL;
int count = CMP_LIBRARY::GetLibraryCount();
if( count == 0 ) if( count == 0 )
{ {
DisplayError( frame, _( "No component libraries are loaded." ) ); DisplayError( frame, _( "No component libraries are loaded." ) );
...@@ -29,22 +28,20 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame ) ...@@ -29,22 +28,20 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame )
libNamesList = CMP_LIBRARY::GetLibraryNames(); libNamesList = CMP_LIBRARY::GetLibraryNames();
msg.Printf( _( " Select 1 of %d libraries." ), count ); EDA_LIST_DIALOG dlg( frame, _( "Select Library" ), libNamesList, OldLibName );
wxSingleChoiceDialog dlg( frame, msg, _( "Select Library" ), libNamesList ); if( dlg.ShowModal() != wxID_OK )
return NULL;
int index = libNamesList.Index( OldLibName );
if( index != wxNOT_FOUND ) wxString libname = dlg.GetTextSelection();
dlg.SetSelection( index );
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() ) if( libname.IsEmpty() )
return NULL; return NULL;
Lib = CMP_LIBRARY::FindLibrary( dlg.GetStringSelection() ); Lib = CMP_LIBRARY::FindLibrary( libname );
if( Lib != NULL ) if( Lib != NULL )
OldLibName = dlg.GetStringSelection(); OldLibName = libname;
return Lib; return Lib;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <common.h> // EDA_UNITS_T #include <common.h> // EDA_UNITS_T
#include <dialog_shim.h>
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
...@@ -21,7 +22,7 @@ class EDA_DRAW_FRAME; ...@@ -21,7 +22,7 @@ class EDA_DRAW_FRAME;
* Used to display a list of elements for selection, and an help of info line * Used to display a list of elements for selection, and an help of info line
* about the selected item. * about the selected item.
*/ */
class EDA_LIST_DIALOG : public wxDialog class EDA_LIST_DIALOG : public DIALOG_SHIM
{ {
private: private:
wxListBox* m_listBox; wxListBox* m_listBox;
......
...@@ -26,19 +26,7 @@ ...@@ -26,19 +26,7 @@
#endif #endif
/** /**
* @note Shouldn't we be using wxFileName::GetPathSeparator() instead of the following code * @note Do we really need these defined?
* for improved portability?
*/
#ifdef __WINDOWS__
#define DIR_SEP '\\'
#define STRING_DIR_SEP wxT( "\\" )
#else
#define DIR_SEP '/'
#define STRING_DIR_SEP wxT( "/" )
#endif
/**
* @note Do we really need these defined again?
*/ */
#define UNIX_STRING_DIR_SEP wxT( "/" ) #define UNIX_STRING_DIR_SEP wxT( "/" )
#define WIN_STRING_DIR_SEP wxT( "\\" ) #define WIN_STRING_DIR_SEP wxT( "\\" )
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <kicad.h> #include <kicad.h>
#include <menus_helpers.h> #include <menus_helpers.h>
/* Menubar and toolbar event table */ /* Menubar and toolbar event table */
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
/* Window events */ /* Window events */
...@@ -91,6 +90,9 @@ END_EVENT_TABLE() ...@@ -91,6 +90,9 @@ END_EVENT_TABLE()
*/ */
void KICAD_MANAGER_FRAME::ReCreateMenuBar() void KICAD_MANAGER_FRAME::ReCreateMenuBar()
{ {
static wxMenu* openRecentMenu; // Open Recent submenu,
// static to remember this menu
// Create and try to get the current menubar // Create and try to get the current menubar
wxMenuItem* item; wxMenuItem* item;
wxMenuBar* menuBar = GetMenuBar(); wxMenuBar* menuBar = GetMenuBar();
...@@ -102,6 +104,12 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() ...@@ -102,6 +104,12 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
// This allows language changes of the menu text on the fly. // This allows language changes of the menu text on the fly.
menuBar->Freeze(); menuBar->Freeze();
// Before deleting, remove the menus managed by m_fileHistory
// (the file history will be updated when adding/removing files in history)
if( openRecentMenu )
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
// Delete all existing menus
while( menuBar->GetMenuCount() ) while( menuBar->GetMenuCount() )
delete menuBar->Remove( 0 ); delete menuBar->Remove( 0 );
...@@ -117,14 +125,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() ...@@ -117,14 +125,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
_( "Open an existing project" ), _( "Open an existing project" ),
KiBitmap( open_project_xpm ) ); KiBitmap( open_project_xpm ) );
// Open Recent submenu // File history
static wxMenu* openRecentMenu;
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu(); openRecentMenu = new wxMenu();
wxGetApp().GetFileHistory().UseMenu( openRecentMenu ); wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
wxGetApp().GetFileHistory().AddFilesToMenu( ); wxGetApp().GetFileHistory().AddFilesToMenu( );
...@@ -135,7 +136,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() ...@@ -135,7 +136,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
KiBitmap( open_project_xpm ) ); KiBitmap( open_project_xpm ) );
// New // New
static wxMenu* newMenu = new wxMenu(); wxMenu* newMenu = new wxMenu();
AddMenuItem( newMenu, ID_NEW_PROJECT, AddMenuItem( newMenu, ID_NEW_PROJECT,
_( "&Blank\tCtrl+N" ), _( "&Blank\tCtrl+N" ),
_( "Start a blank project" ), _( "Start a blank project" ),
...@@ -147,7 +148,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() ...@@ -147,7 +148,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
KiBitmap( new_project_with_template_xpm ) ); KiBitmap( new_project_with_template_xpm ) );
AddMenuItem( fileMenu, newMenu, AddMenuItem( fileMenu, newMenu,
wxID_ANY, wxID_ANY,
_( "New" ), _( "New" ),
_( "Start a new project" ), _( "Start a new project" ),
KiBitmap( new_project_xpm ) ); KiBitmap( new_project_xpm ) );
......
...@@ -133,11 +133,10 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -133,11 +133,10 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
case ID_NEW_BOARD: case ID_NEW_BOARD:
{ {
Clear_Pcb( true ); Clear_Pcb( true );
wxString newFilename; wxFileName fn( wxT( "noname" ) );
newFilename.Printf( wxT( "%s%cnoname%s" ), fn.AssignCwd();
GetChars( wxGetCwd() ), DIR_SEP, fn.SetExt( PcbFileExtension );
GetChars( PcbFileExtension ) ); GetBoard()->SetFileName( fn.GetFullPath() );
GetBoard()->SetFileName( newFilename );
UpdateTitle(); UpdateTitle();
ReCreateLayerBox( NULL ); ReCreateLayerBox( NULL );
} }
......
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