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