Commit 2611a547 authored by stambaughw's avatar stambaughw

Convert global and embedded application pointers to wxGetApp()

parent 0745188d
......@@ -27,19 +27,21 @@
BEGIN_EVENT_TABLE( WinEDA3D_DrawFrame, wxFrame )
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA3D_DrawFrame::Process_Zoom )
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_MENU( wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG, WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG, WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_CLOSE( WinEDA3D_DrawFrame::OnCloseWindow )
EVT_MENU( wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG,
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG,
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_CLOSE( WinEDA3D_DrawFrame::OnCloseWindow )
END_EVENT_TABLE()
/*******************************************************************/
WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
WinEDA_App* app_parent, const wxString& title,
const wxString& title,
long style ) :
wxFrame( parent, DISPLAY3D_FRAME, title,
wxPoint( -1, -1 ), wxSize( -1, -1 ), style )
......@@ -48,7 +50,6 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
m_FrameName = wxT( "Frame3D" );
m_Canvas = NULL;
m_Parent = parent;
m_ParentAppl = app_parent;
m_HToolBar = NULL;
m_VToolBar = NULL;
m_InternalUnits = 10000; // Unites internes = 1/10000 inch
......@@ -104,21 +105,24 @@ void WinEDA3D_DrawFrame::GetSettings()
/******************************************/
{
wxString text;
wxConfig* Config = m_ParentAppl->m_EDA_Config; // Current config used by application
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by application
if( m_ParentAppl->m_EDA_Config )
if( config )
{
text = m_FrameName + wxT( "Pos_x" );
Config->Read( text, &m_FramePos.x );
config->Read( text, &m_FramePos.x );
text = m_FrameName + wxT( "Pos_y" );
Config->Read( text, &m_FramePos.y );
config->Read( text, &m_FramePos.y );
text = m_FrameName + wxT( "Size_x" );
Config->Read( text, &m_FrameSize.x, 600 );
config->Read( text, &m_FrameSize.x, 600 );
text = m_FrameName + wxT( "Size_y" );
Config->Read( text, &m_FrameSize.y, 400 );
Config->Read( wxT( "BgColor_Red" ), &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
Config->Read( wxT( "BgColor_Green" ), &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
Config->Read( wxT( "BgColor_Blue" ), &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
config->Read( text, &m_FrameSize.y, 400 );
config->Read( wxT( "BgColor_Red" ),
&g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
config->Read( wxT( "BgColor_Green" ),
&g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
config->Read( wxT( "BgColor_Blue" ),
&g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
}
#ifdef __WXMAC__
......@@ -134,7 +138,7 @@ void WinEDA3D_DrawFrame::SaveSettings()
/*******************************************/
{
wxString text;
wxConfig* Config = m_ParentAppl->m_EDA_Config; // Current config used by application
wxConfig* Config = wxGetApp().m_EDA_Config; // Current config used by application
if( !Config )
return;
......
......@@ -125,7 +125,6 @@ class WinEDA3D_DrawFrame: public wxFrame
{
public:
WinEDA_BasePcbFrame * m_Parent;
WinEDA_App * m_ParentAppl;
Pcb3D_GLCanvas * m_Canvas;
wxToolBar * m_HToolBar;
wxToolBar * m_VToolBar;
......@@ -138,8 +137,9 @@ private:
// It is "Frame3D"
public:
WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent, WinEDA_App *app_parent,
const wxString& title, long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
WinEDA3D_DrawFrame(WinEDA_BasePcbFrame * parent,
const wxString& title,
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
void Exit3DFrame(wxCommandEvent& event);
void OnCloseWindow(wxCloseEvent & Event);
......@@ -169,7 +169,7 @@ public:
void Set3DEco1OnOff();
void Set3DEco2OnOff();
DECLARE_EVENT_TABLE()
DECLARE_EVENT_TABLE()
};
void SetGLColor(int color);
......
......@@ -5,6 +5,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Dec-08 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++all
* Remove all instances of application pointers both global and embedded
member variables. Use wxGetApp() for improved readability and type
safety.
2008-Dec-6 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew & gerbview
......
......@@ -23,14 +23,14 @@
/*******************************************************/
WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, int idtype,
WinEDA_App* parent, const wxString& title,
const wxPoint& pos, const wxSize& size, long style ) :
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style ) :
wxFrame( father, -1, title, pos, size, style )
{
wxSize minsize;
m_Ident = idtype;
m_Parent = parent;
SetFont( *g_StdFont );
m_MenuBar = NULL; // menu du haut d'ecran
m_HToolBar = NULL;
......@@ -57,9 +57,9 @@ WinEDA_BasicFrame::WinEDA_BasicFrame( wxWindow* father, int idtype,
WinEDA_BasicFrame::~WinEDA_BasicFrame()
/******************************************/
{
if( m_Parent->m_HtmlCtrl )
delete m_Parent->m_HtmlCtrl;
m_Parent->m_HtmlCtrl = NULL;
if( wxGetApp().m_HtmlCtrl )
delete wxGetApp().m_HtmlCtrl;
wxGetApp().m_HtmlCtrl = NULL;
}
......@@ -78,17 +78,20 @@ void WinEDA_BasicFrame::GetSettings()
{
wxString text;
int Ypos_min;
wxConfig* config;
if( m_Parent->m_EDA_Config )
config = wxGetApp().m_EDA_Config;
if( config )
{
text = m_FrameName + wxT( "Pos_x" );
m_Parent->m_EDA_Config->Read( text, &m_FramePos.x );
config->Read( text, &m_FramePos.x );
text = m_FrameName + wxT( "Pos_y" );
m_Parent->m_EDA_Config->Read( text, &m_FramePos.y );
config->Read( text, &m_FramePos.y );
text = m_FrameName + wxT( "Size_x" );
m_Parent->m_EDA_Config->Read( text, &m_FrameSize.x, 600 );
config->Read( text, &m_FrameSize.x, 600 );
text = m_FrameName + wxT( "Size_y" );
m_Parent->m_EDA_Config->Read( text, &m_FrameSize.y, 400 );
config->Read( text, &m_FrameSize.y, 400 );
}
// Ensure Window title bar is visible
......@@ -109,24 +112,24 @@ void WinEDA_BasicFrame::SaveSettings()
/*****************************************/
{
wxString text;
wxConfig* config;
if( !m_Parent || !m_Parent->m_EDA_Config )
return;
config = wxGetApp().m_EDA_Config;
if( !m_Parent->m_EDA_Config || IsIconized() )
if( ( config == NULL ) || IsIconized() )
return;
m_FrameSize = GetSize();
m_FramePos = GetPosition();
text = m_FrameName + wxT( "Pos_x" );
m_Parent->m_EDA_Config->Write( text, (long) m_FramePos.x );
config->Write( text, (long) m_FramePos.x );
text = m_FrameName + wxT( "Pos_y" );
m_Parent->m_EDA_Config->Write( text, (long) m_FramePos.y );
config->Write( text, (long) m_FramePos.y );
text = m_FrameName + wxT( "Size_x" );
m_Parent->m_EDA_Config->Write( text, (long) m_FrameSize.x );
config->Write( text, (long) m_FrameSize.x );
text = m_FrameName + wxT( "Size_y" );
m_Parent->m_EDA_Config->Write( text, (long) m_FrameSize.y );
config->Write( text, (long) m_FrameSize.y );
}
......@@ -175,36 +178,28 @@ void WinEDA_BasicFrame::SetLastProject( const wxString& FullFileName )
return;
//suppression d'une ancienne trace eventuelle du meme fichier
for( ii = 0; ii < m_Parent->m_LastProject.GetCount(); )
for( ii = 0; ii < wxGetApp().m_LastProject.GetCount(); )
{
if( m_Parent->m_LastProject[ii].IsEmpty() )
if( wxGetApp().m_LastProject[ii].IsEmpty() )
break;
#ifdef __WINDOWS__
if( m_Parent->m_LastProject[ii].CmpNoCase( FullFileName ) == 0 )
if( wxGetApp().m_LastProject[ii].CmpNoCase( FullFileName ) == 0 )
#else
if( m_Parent->m_LastProject[ii] == FullFileName )
if( wxGetApp().m_LastProject[ii] == FullFileName )
#endif
{
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4 ) ) )
m_Parent->m_LastProject.Remove( ii );
#else
m_Parent->m_LastProject.RemoveAt( ii );
#endif
wxGetApp().m_LastProject.RemoveAt( ii );
}
else
ii++;
}
while( m_Parent->m_LastProject.GetCount() >= m_Parent->m_LastProjectMaxCount )
while( wxGetApp().m_LastProject.GetCount() >= wxGetApp().m_LastProjectMaxCount )
{
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4 ) ) )
files.Remove( files.GetCount() - 1 );
#else
m_Parent->m_LastProject.RemoveAt( m_Parent->m_LastProject.GetCount() - 1 );
#endif
wxGetApp().m_LastProject.RemoveAt( wxGetApp().m_LastProject.GetCount() - 1 );
}
m_Parent->m_LastProject.Insert( FullFileName, 0 );
wxGetApp().m_LastProject.Insert( FullFileName, 0 );
ReCreateMenuBar();
}
......@@ -216,9 +211,9 @@ wxString WinEDA_BasicFrame::GetLastProject( int rang )
{
if( rang < 0 )
rang = 0;
if( (unsigned) rang >= m_Parent->m_LastProject.GetCount() )
if( (unsigned) rang >= wxGetApp().m_LastProject.GetCount() )
return wxEmptyString;
return m_Parent->m_LastProject[rang];
return wxGetApp().m_LastProject[rang];
}
......@@ -227,30 +222,30 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/**************************************************************/
{
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
if( m_Parent->m_HtmlCtrl == NULL )
if( wxGetApp().m_HtmlCtrl == NULL )
{
m_Parent->InitOnLineHelp();
wxGetApp().InitOnLineHelp();
}
if( m_Parent->m_HtmlCtrl )
if( wxGetApp().m_HtmlCtrl )
{
m_Parent->m_HtmlCtrl->DisplayContents();
m_Parent->m_HtmlCtrl->Display( m_Parent->m_HelpFileName );
wxGetApp().m_HtmlCtrl->DisplayContents();
wxGetApp().m_HtmlCtrl->Display( wxGetApp().m_HelpFileName );
}
else
{
wxString msg;
msg.Printf( _( "Help file %s not found" ), m_Parent->m_HelpFileName.GetData() );
msg.Printf( _( "Help file %s not found" ), wxGetApp().m_HelpFileName.GetData() );
DisplayError( this, msg );
}
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
wxString fullfilename = FindKicadHelpPath() + m_Parent->m_HelpFileName;
wxString fullfilename = FindKicadHelpPath() + wxGetApp().m_HelpFileName;
if ( wxFileExists(fullfilename) )
GetAssociatedDocument( this, wxEmptyString, fullfilename );
else // Try to find file in English format:
{
fullfilename = FindKicadHelpPath() + wxT("../en/") + m_Parent->m_HelpFileName;;
fullfilename = FindKicadHelpPath() + wxT("../en/") + wxGetApp().m_HelpFileName;;
GetAssociatedDocument( this, wxEmptyString, fullfilename );
}
......
......@@ -14,14 +14,9 @@
#endif
#include "fctsys.h"
#include <wx/image.h>
#include "wx/html/htmlwin.h"
#include "wx/fs_zip.h"
#include "wxstruct.h"
#include "gr_basic.h"
#include "common.h"
#include "worksheet.h"
#include "id.h"
......@@ -53,8 +48,7 @@ struct LANGUAGE_DESCR
bool m_DoNotTranslate; // set to true if the m_Lang_Label must not be translated
};
#define LANGUAGE_DESCR_COUNT 16
static struct LANGUAGE_DESCR s_Language_List[LANGUAGE_DESCR_COUNT] =
static struct LANGUAGE_DESCR s_Language_List[] =
{
{
wxLANGUAGE_DEFAULT,
......@@ -155,6 +149,11 @@ static struct LANGUAGE_DESCR s_Language_List[LANGUAGE_DESCR_COUNT] =
}
};
/* Just add new languages to the list. This macro will properly recalculate
* the size of the array. */
#define LANGUAGE_DESCR_COUNT ( sizeof( s_Language_List ) / \
sizeof( struct LANGUAGE_DESCR ) )
/**************************/
/* WinEDA_App Constructor */
/**************************/
......@@ -162,15 +161,6 @@ static struct LANGUAGE_DESCR s_Language_List[LANGUAGE_DESCR_COUNT] =
WinEDA_App::WinEDA_App()
{
m_Checker = NULL;
m_MainFrame = NULL;
m_PcbFrame = NULL;
m_ModuleEditFrame = NULL; // Frame for footprint edition
m_SchematicFrame = NULL; // Frame for schematic edition
m_LibeditFrame = NULL; // Frame for component edition
m_ViewlibFrame = NULL; // Frame for browsing component libraries
m_CvpcbFrame = NULL;
m_GerberFrame = NULL; // Frame for the gerber viewer GERBVIEW
m_LastProjectMaxCount = 10;
m_HtmlCtrl = NULL;
m_EDA_CommonConfig = NULL;
......@@ -250,14 +240,18 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
g_MsgFontPointSize = FONT_DEFAULT_SIZE;
g_DialogFontPointSize = FONT_DEFAULT_SIZE;
g_FixedFontPointSize = FONT_DEFAULT_SIZE;
g_StdFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL );
g_MsgFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL );
g_DialogFont = new wxFont( g_DialogFontPointSize, wxFONTFAMILY_ROMAN, wxNORMAL, wxNORMAL );
g_StdFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN,
wxNORMAL, wxNORMAL );
g_MsgFont = new wxFont( g_StdFontPointSize, wxFONTFAMILY_ROMAN,
wxNORMAL, wxNORMAL );
g_DialogFont = new wxFont( g_DialogFontPointSize, wxFONTFAMILY_ROMAN,
wxNORMAL, wxNORMAL );
g_ItalicFont = new wxFont( g_DialogFontPointSize,
wxFONTFAMILY_ROMAN,
wxFONTSTYLE_ITALIC,
wxNORMAL );
g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL );
g_FixedFont = new wxFont( g_FixedFontPointSize, wxFONTFAMILY_MODERN,
wxNORMAL, wxNORMAL );
/* installation des gestionnaires de visu d'images (pour help) */
wxImage::AddHandler( new wxPNGHandler );
......@@ -271,14 +265,15 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
ReadPdfBrowserInfos();
// Internationalisation: loading the kicad suitable Dictionnary
m_EDA_CommonConfig->Read( wxT( "Language" ), &m_LanguageId, wxLANGUAGE_DEFAULT );
m_EDA_CommonConfig->Read( wxT( "Language" ), &m_LanguageId,
wxLANGUAGE_DEFAULT );
bool succes = SetLanguage( TRUE );
if( !succes )
{
}
SetLocaleTo_Default( ); // Set locale option for separator used in float numbers
SetLocaleTo_Default(); // Set locale option for separator used in float numbers
#ifdef KICAD_PYTHON
PyHandler::GetInstance()->SetAppName( name );
......@@ -300,8 +295,8 @@ void WinEDA_App::InitOnLineHelp()
fullfilename += wxT( "kicad.hhp" );
if( wxFileExists( fullfilename ) )
{
m_HtmlCtrl = new wxHtmlHelpController( wxHF_TOOLBAR |
wxHF_CONTENTS | wxHF_PRINT | wxHF_OPEN_FILES
m_HtmlCtrl = new wxHtmlHelpController( wxHF_TOOLBAR | wxHF_CONTENTS |
wxHF_PRINT | wxHF_OPEN_FILES
/*| wxHF_SEARCH */ );
m_HtmlCtrl->UseConfig( m_EDA_CommonConfig );
m_HtmlCtrl->SetTitleFormat( wxT( "Kicad Help" ) );
......@@ -396,7 +391,8 @@ void WinEDA_App::GetSettings()
if( m_EDA_CommonConfig )
{
m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ), wxLANGUAGE_DEFAULT );
m_LanguageId = m_EDA_CommonConfig->Read( wxT( "Language" ),
wxLANGUAGE_DEFAULT );
g_EditorName = m_EDA_CommonConfig->Read( wxT( "Editor" ) );
g_ConfigFileLocationChoice = m_EDA_CommonConfig->Read( HOTKEY_CFG_PATH_OPT, 0L );
}
......@@ -416,10 +412,14 @@ void WinEDA_App::GetSettings()
m_LastProject.Add( Line );
}
g_StdFontPointSize = m_EDA_Config->Read( wxT( "SdtFontSize" ), FONT_DEFAULT_SIZE );
g_MsgFontPointSize = m_EDA_Config->Read( wxT( "MsgFontSize" ), FONT_DEFAULT_SIZE );
g_DialogFontPointSize = m_EDA_Config->Read( wxT( "DialogFontSize" ), FONT_DEFAULT_SIZE );
g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ), FONT_DEFAULT_SIZE );
g_StdFontPointSize = m_EDA_Config->Read( wxT( "SdtFontSize" ),
FONT_DEFAULT_SIZE );
g_MsgFontPointSize = m_EDA_Config->Read( wxT( "MsgFontSize" ),
FONT_DEFAULT_SIZE );
g_DialogFontPointSize = m_EDA_Config->Read( wxT( "DialogFontSize" ),
FONT_DEFAULT_SIZE );
g_FixedFontPointSize = m_EDA_Config->Read( wxT( "FixedFontSize" ),
FONT_DEFAULT_SIZE );
Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString );
if( !Line.IsEmpty() )
......@@ -593,9 +593,11 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu )
for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
{
if( m_LanguageId == s_Language_List[ii].m_WX_Lang_Identifier )
m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, true );
m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier,
true );
else
m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier, false );
m_Language_Menu->Check( s_Language_List[ii].m_KI_Lang_Identifier,
false );
}
if( MasterMenu )
......
......@@ -4,22 +4,9 @@
/************************************************/
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/mimetype.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "fctsys.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "wx/mimetype.h"
#ifdef __WINDOWS__
#ifndef _MSC_VER
......@@ -27,9 +14,7 @@
#endif
#endif
#include "fctsys.h"
#include "common.h"
#include "wxstruct.h"
#include "macros.h"
/* List of default paths used to locate help files and kicad library files.
......@@ -114,7 +99,6 @@ static wxString s_KicadBinaryPathList[] = {
#endif
wxT( "end_list" ) // End of list symbol, do not change
};
extern WinEDA_App* g_EDA_Appl;
/***************************************************************************/
......@@ -402,12 +386,12 @@ wxString FindKicadHelpPath()
bool PathFound = FALSE;
/* find kicad/help/ */
tmp = g_EDA_Appl->m_BinDir;
tmp = wxGetApp().m_BinDir;
if( tmp.Last() == '/' )
tmp.RemoveLast();
FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/doc/help/" );
LocaleString = g_EDA_Appl->m_Locale->GetCanonicalName();
LocaleString = wxGetApp().m_Locale->GetCanonicalName();
wxString path_tmp = FullPath;
#ifdef __WINDOWS__
......@@ -420,9 +404,9 @@ wxString FindKicadHelpPath()
}
/* find kicad/help/ from environment variable KICAD */
if( !PathFound && g_EDA_Appl->m_Env_Defined )
if( !PathFound && wxGetApp().m_Env_Defined )
{
FullPath = g_EDA_Appl->m_KicadEnv + wxT( "/doc/help/" );
FullPath = wxGetApp().m_KicadEnv + wxT( "/doc/help/" );
if( wxDirExists( FullPath ) )
PathFound = TRUE;
}
......@@ -483,15 +467,15 @@ wxString FindKicadFile( const wxString& shortname )
/* test de la presence du fichier shortname dans le repertoire de
* des binaires de kicad */
FullFileName = g_EDA_Appl->m_BinDir + shortname;
FullFileName = wxGetApp().m_BinDir + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
/* test de la presence du fichier shortname dans le repertoire
* defini par la variable d'environnement KICAD */
if( g_EDA_Appl->m_Env_Defined )
if( wxGetApp().m_Env_Defined )
{
FullFileName = g_EDA_Appl->m_KicadEnv + shortname;
FullFileName = wxGetApp().m_KicadEnv + shortname;
if( wxFileExists( FullFileName ) )
return FullFileName;
}
......@@ -566,7 +550,7 @@ void SetRealLibraryPath( const wxString& shortlibname )
else
{
g_RealLibDirBuffer = ReturnKicadDatasPath();
if( g_EDA_Appl->m_Env_Defined ) // Chemin impose par la variable d'environnement
if( wxGetApp().m_Env_Defined ) // Chemin impose par la variable d'environnement
{
PathFound = TRUE;
}
......@@ -599,35 +583,36 @@ wxString ReturnKicadDatasPath()
bool PathFound = FALSE;
wxString data_path;
if( g_EDA_Appl->m_Env_Defined ) // Chemin impose par la variable d'environnement
if( wxGetApp().m_Env_Defined ) // Chemin impose par la variable d'environnement
{
data_path = g_EDA_Appl->m_KicadEnv;
data_path = wxGetApp().m_KicadEnv;
PathFound = TRUE;
}
else // Chemin cherche par le chemin des executables
{
// le chemin est bindir../
wxString tmp = g_EDA_Appl->m_BinDir;
wxString tmp = wxGetApp().m_BinDir;
#ifdef __WINDOWS__
tmp.MakeLower();
#endif
if( tmp.Contains( wxT( "kicad" ) ) )
{
#ifdef __WINDOWS__
tmp = g_EDA_Appl->m_BinDir;
tmp = wxGetApp().m_BinDir;
#endif
if( tmp.Last() == '/' )
tmp.RemoveLast();
data_path = tmp.BeforeLast( '/' ); // id cd ../
data_path += UNIX_STRING_DIR_SEP;
// Old versions of kicad use kicad/ as default for data
// and last versions kicad/share/
// So we search for kicad/share/ first
wxString old_path = data_path;
data_path += wxT("share/");
data_path += wxT( "share/" );
if( wxDirExists( data_path ) )
PathFound = TRUE;
else if ( wxDirExists( old_path ) )
else if( wxDirExists( old_path ) )
{
data_path = old_path;
PathFound = TRUE;
......@@ -693,17 +678,19 @@ wxString GetEditorName()
);
}
if( ( !editorname.IsEmpty() ) && g_EDA_Appl->m_EDA_CommonConfig )
if( ( !editorname.IsEmpty() ) && wxGetApp().m_EDA_CommonConfig )
{
g_EditorName = editorname;
g_EDA_Appl->m_EDA_CommonConfig->Write( wxT( "Editor" ), g_EditorName );
wxGetApp().m_EDA_CommonConfig->Write( wxT( "Editor" ), g_EditorName );
}
return g_EditorName;
}
/***********************************/
bool OpenPDF( const wxString& file )
/***********************************/
/** Function OpenPDF
* run the PDF viewer and display a PDF file
* @param file = PDF file to open
......@@ -715,11 +702,11 @@ bool OpenPDF( const wxString& file )
wxString type;
bool success = false;
g_EDA_Appl->ReadPdfBrowserInfos();
if( !g_EDA_Appl->m_PdfBrowserIsDefault ) // Run the prefered PDF Browser
wxGetApp().ReadPdfBrowserInfos();
if( !wxGetApp().m_PdfBrowserIsDefault ) // Run the prefered PDF Browser
{
AddDelimiterString( filename );
command = g_EDA_Appl->m_PdfBrowser + wxT( " " ) + filename;
command = wxGetApp().m_PdfBrowser + wxT( " " ) + filename;
}
else
{
......@@ -730,14 +717,15 @@ bool OpenPDF( const wxString& file )
success = filetype->GetOpenCommand( &command, params );
delete filetype;
#ifndef __WINDOWS__
// Bug ? under linux wxWidgets returns acroread as PDF viewer,even it not exists
if ( command.StartsWith(wxT("acroread")) ) // Workaround
if( command.StartsWith( wxT( "acroread" ) ) ) // Workaround
success = false;
#endif
if( success && !command.IsEmpty() )
{
success = ProcessExecute( command );
if ( success )
if( success )
return success;
}
......@@ -770,6 +758,7 @@ bool OpenPDF( const wxString& file )
break;
}
}
#endif
}
}
......@@ -777,17 +766,17 @@ bool OpenPDF( const wxString& file )
if( !command.IsEmpty() )
{
success = ProcessExecute( command );
if ( !success )
if( !success )
{
wxString msg = _("Problem while running the PDF viewer");
msg << _("\n command is ") << command;
wxString msg = _( "Problem while running the PDF viewer" );
msg << _( "\n command is " ) << command;
DisplayError( NULL, msg );
}
}
else
{
wxString msg = _("Unable to find a PDF viewer for");
msg << wxT(" ") << filename;
wxString msg = _( "Unable to find a PDF viewer for" );
msg << wxT( " " ) << filename;
DisplayError( NULL, msg );
success = false;
}
......@@ -795,6 +784,7 @@ bool OpenPDF( const wxString& file )
return success;
}
/*************************************/
void OpenFile( const wxString& file )
/*************************************/
......
......@@ -674,6 +674,8 @@ void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id )
*/
{
wxMenuBar* menu = frame->GetMenuBar();
wxConfig * config = wxGetApp().m_EDA_CommonConfig;
wxASSERT( config != NULL );
switch( id )
{
......@@ -683,8 +685,7 @@ void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id )
g_ConfigFileLocationChoice = 0;
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, true );
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, false );
frame->m_Parent->m_EDA_CommonConfig->Write( HOTKEY_CFG_PATH_OPT,
g_ConfigFileLocationChoice );
config->Write( HOTKEY_CFG_PATH_OPT, g_ConfigFileLocationChoice );
}
break;
......@@ -694,8 +695,7 @@ void HandleHotkeyConfigMenuSelection( WinEDA_DrawFrame* frame, int id )
g_ConfigFileLocationChoice = 1;
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_HOME, false );
menu->Check( ID_PREFERENCES_HOTKEY_PATH_IS_KICAD, true );
frame->m_Parent->m_EDA_CommonConfig->Write( HOTKEY_CFG_PATH_OPT,
g_ConfigFileLocationChoice );
config->Write( HOTKEY_CFG_PATH_OPT, g_ConfigFileLocationChoice );
}
break;
......
......@@ -14,7 +14,8 @@
/*********************************************************************/
static bool ReCreatePrjConfig( const wxString& local_config_filename,
const wxString& GroupName, bool ForceUseLocalConfig )
const wxString& GroupName,
bool ForceUseLocalConfig )
/*********************************************************************/
/* Cree ou recree la configuration locale de kicad (filename.pro)
......@@ -44,8 +45,10 @@ static bool ReCreatePrjConfig( const wxString& local_config_filename,
if( ForceUseLocalConfig || wxFileExists( g_Prj_Config_LocalFilename ) )
{
g_Prj_Default_Config_FullFilename.Empty();
g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString,
g_Prj_Config_LocalFilename, wxEmptyString,
g_Prj_Config = new wxFileConfig( wxEmptyString,
wxEmptyString,
g_Prj_Config_LocalFilename,
wxEmptyString,
wxCONFIG_USE_RELATIVE_PATH );
g_Prj_Config->DontCreateOnDemand();
......@@ -73,8 +76,10 @@ static bool ReCreatePrjConfig( const wxString& local_config_filename,
g_Prj_Config_Filename_ext;
// Recreate new config
g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString,
wxEmptyString, g_Prj_Default_Config_FullFilename,
g_Prj_Config = new wxFileConfig( wxEmptyString,
wxEmptyString,
wxEmptyString,
g_Prj_Default_Config_FullFilename,
wxCONFIG_USE_RELATIVE_PATH );
g_Prj_Config->DontCreateOnDemand();
......@@ -85,7 +90,8 @@ static bool ReCreatePrjConfig( const wxString& local_config_filename,
/***************************************************************************************/
void WinEDA_App::WriteProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, PARAM_CFG_BASE** List )
const wxString& GroupName,
PARAM_CFG_BASE** List )
/***************************************************************************************/
/* enregistrement de la config "projet"*/
{
......@@ -203,7 +209,8 @@ void WinEDA_App::WriteProjectConfig( const wxString& local_config_filename,
// We use indexlib+1 because first lib name is LibName1
cle_config << (indexlib + 1);
g_Prj_Config->Write( cle_config, libname_list->Item( indexlib ) );
g_Prj_Config->Write( cle_config,
libname_list->Item( indexlib ) );
}
break;
......@@ -227,7 +234,8 @@ void WinEDA_App::WriteProjectConfig( const wxString& local_config_filename,
/***************************************************************************************/
bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, PARAM_CFG_BASE** List,
const wxString& GroupName,
PARAM_CFG_BASE** List,
bool Load_Only_if_New )
/***************************************************************************************/
......@@ -238,8 +246,8 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
* return:
* TRUE si lue.
* Met a jour en plus:
* g_EDA_Appl->m_CurrentOptionFileDateAndTime
* g_EDA_Appl->m_CurrentOptionFile
* wxGetApp().m_CurrentOptionFileDateAndTime
* wxGetApp().m_CurrentOptionFile
*/
{
const PARAM_CFG_BASE* pt_cfg;
......@@ -253,22 +261,22 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP );
timestamp = g_Prj_Config->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) )
&& (timestamp == wxGetApp().m_CurrentOptionFileDateAndTime) )
{
return FALSE;
}
g_EDA_Appl->m_CurrentOptionFileDateAndTime = timestamp;
wxGetApp().m_CurrentOptionFileDateAndTime = timestamp;
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
g_EDA_Appl->m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
wxGetApp().m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
else
{
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
g_EDA_Appl->m_CurrentOptionFile =
wxGetApp().m_CurrentOptionFile =
wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename;
else
g_EDA_Appl->m_CurrentOptionFile = g_Prj_Config_LocalFilename;
wxGetApp().m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
for( ; *List != NULL; List++ )
......@@ -437,7 +445,8 @@ PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
int default_val, const wxChar* group ) :
int default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
{
m_Pt_param = ptparam;
......@@ -445,8 +454,11 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
}
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam,
int default_val, const wxChar* group ) :
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
const wxChar* ident,
int* ptparam,
int default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
{
m_Pt_param = ptparam;
......@@ -467,8 +479,12 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
}
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
double default_val, double min, double max,
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
const wxChar* ident,
double* ptparam,
double default_val,
double min,
double max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
{
......@@ -489,8 +505,11 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
}
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
int default_val, const wxChar* group ) :
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
const wxChar* ident,
bool* ptparam,
int default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
{
m_Pt_param = ptparam;
......@@ -500,7 +519,8 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
wxString* ptparam, const wxChar* group ) :
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
{
m_Pt_param = ptparam;
......@@ -508,7 +528,8 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
wxString* ptparam, const wxChar* group ) :
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
{
m_Pt_param = ptparam;
......@@ -517,7 +538,8 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
wxArrayString* ptparam, const wxChar* group ) :
wxArrayString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_LIBNAME_LIST, group )
{
m_Pt_param = ptparam;
......
......@@ -6,7 +6,6 @@
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "cvpcb.h"
#include "protos.h"
......@@ -36,7 +35,7 @@ void Read_Config( const wxString& FileName )
g_LibName_List.Clear();
g_ListName_Equ.Clear();
g_EDA_Appl->ReadProjectConfig( FullFileName,
wxGetApp().ReadProjectConfig( FullFileName,
GROUP, ParamCfgList, FALSE );
if( NetInExtBuffer.IsEmpty() )
......@@ -86,5 +85,5 @@ void Save_Config( wxWindow* parent )
return;
/* ecriture de la configuration */
g_EDA_Appl->WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
wxGetApp().WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
}
......@@ -6,7 +6,6 @@
#include <wx/fontdlg.h>
#include "cvpcb.h"
#include "gr_basic.h"
#include "pcbnew.h"
#include "bitmaps.h"
......@@ -21,10 +20,12 @@
/*******************************************************/
/* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */
/*******************************************************/
WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( WinEDA_App* parent, const wxString& title, long style ) :
WinEDA_BasicFrame( NULL, CVPCB_FRAME, parent, title, wxDefaultPosition, wxDefaultSize, style )
WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( const wxString& title, long style ) :
WinEDA_BasicFrame( NULL, CVPCB_FRAME, title, wxDefaultPosition,
wxDefaultSize, style )
{
m_FrameName = wxT( "CvpcbFrame" );
//m_AboutTitle = g_CvpcbAboutTitle;
m_ListCmp = NULL;
m_FootprintList = NULL;
......@@ -97,10 +98,13 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( WinEDA_App* parent, const wxString& title,
WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame()
/******************************************/
{
if( m_Parent->m_EDA_Config )
wxConfig* config = wxGetApp().m_EDA_Config;
if( config )
{
int state = m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
m_Parent->m_EDA_Config->Write( wxT( FILTERFOOTPRINTKEY ), state );
int state = m_HToolBar->GetToolState(
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
config->Write( wxT( FILTERFOOTPRINTKEY ), state );
}
}
......@@ -117,77 +121,74 @@ void WinEDA_CvpcbFrame::OnSize( wxSizeEvent& event )
/* Event table for WinEDA_CvpcbFrame */
/*************************************/
BEGIN_EVENT_TABLE( WinEDA_CvpcbFrame, wxFrame )
EVT_MENU_RANGE( ID_LOAD_PROJECT,
EVT_MENU_RANGE( ID_LOAD_PROJECT,
ID_LOAD_FILE_10,
WinEDA_CvpcbFrame::LoadNetList )
// Menu events
EVT_MENU( ID_SAVE_PROJECT,
EVT_MENU( ID_SAVE_PROJECT,
WinEDA_CvpcbFrame::SaveQuitCvpcb )
EVT_MENU( ID_CVPCB_QUIT,
EVT_MENU( ID_CVPCB_QUIT,
WinEDA_CvpcbFrame::OnQuit )
EVT_MENU( ID_CVPCB_DISPLAY_HELP,
EVT_MENU( ID_CVPCB_DISPLAY_HELP,
WinEDA_CvpcbFrame::GetKicadHelp )
EVT_MENU( ID_CVPCB_DISPLAY_LICENCE,
EVT_MENU( ID_CVPCB_DISPLAY_LICENCE,
WinEDA_CvpcbFrame::GetKicadAbout )
EVT_MENU( ID_CONFIG_REQ,
EVT_MENU( ID_CONFIG_REQ,
WinEDA_CvpcbFrame::ConfigCvpcb )
EVT_MENU( ID_CONFIG_SAVE,
EVT_MENU( ID_CONFIG_SAVE,
WinEDA_CvpcbFrame::Update_Config )
EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN,
EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN,
ID_PREFERENCES_FONT_END,
WinEDA_CvpcbFrame::ProcessFontPreferences )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE,
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE,
ID_LANGUAGE_CHOICE_END,
WinEDA_CvpcbFrame::SetLanguage )
// Toolbar events
EVT_TOOL( ID_CVPCB_QUIT,
EVT_TOOL( ID_CVPCB_QUIT,
WinEDA_CvpcbFrame::OnQuit )
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST,
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST,
WinEDA_CvpcbFrame::LoadNetList )
EVT_TOOL( ID_CVPCB_SAVEQUITCVPCB,
EVT_TOOL( ID_CVPCB_SAVEQUITCVPCB,
WinEDA_CvpcbFrame::SaveQuitCvpcb )
EVT_TOOL( ID_CVPCB_CREATE_CONFIGWINDOW,
EVT_TOOL( ID_CVPCB_CREATE_CONFIGWINDOW,
WinEDA_CvpcbFrame::ConfigCvpcb )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP,
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP,
WinEDA_CvpcbFrame::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA,
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA,
WinEDA_CvpcbFrame::ToFirstNA )
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA,
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA,
WinEDA_CvpcbFrame::ToPreviousNA )
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS,
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS,
WinEDA_CvpcbFrame::DelAssociations )
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE,
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE,
WinEDA_CvpcbFrame::AssocieModule )
EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE,
EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE,
WinEDA_CvpcbFrame::WriteStuffList )
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC,
EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC,
WinEDA_CvpcbFrame::DisplayDocFile )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
WinEDA_CvpcbFrame::OnSelectFilteringFootprint )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
WinEDA_CvpcbFrame::OnSelectFilteringFootprint )
// Frame events
EVT_CHAR_HOOK( WinEDA_CvpcbFrame::OnChar )
EVT_CLOSE( WinEDA_CvpcbFrame::OnCloseWindow )
EVT_SIZE( WinEDA_CvpcbFrame::OnSize )
EVT_CHAR_HOOK( WinEDA_CvpcbFrame::OnChar )
EVT_CLOSE( WinEDA_CvpcbFrame::OnCloseWindow )
EVT_SIZE( WinEDA_CvpcbFrame::OnSize )
// List item events
EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST,
EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST,
WinEDA_CvpcbFrame::OnLeftClick )
EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST,
EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST,
WinEDA_CvpcbFrame::OnLeftDClick )
EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST,
EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST,
WinEDA_CvpcbFrame::OnSelectComponent )
END_EVENT_TABLE()
/******************************************************/
void WinEDA_CvpcbFrame::OnQuit( wxCommandEvent& event )
/******************************************************/
......@@ -196,7 +197,6 @@ void WinEDA_CvpcbFrame::OnQuit( wxCommandEvent& event )
}
/**********************************************************/
void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
/**********************************************************/
......@@ -206,10 +206,10 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
if( modified )
{
unsigned ii;
wxMessageDialog dialog( this, _( "Net and component list modified.\n Save before exit ?" ),
wxMessageDialog dialog( this,
_( "Net and component list modified.\n Save before exit ?" ),
_( "Confirmation" ),
wxYES_NO | wxCANCEL |
wxICON_EXCLAMATION | wxYES_DEFAULT );
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT );
ii = dialog.ShowModal();
......@@ -229,7 +229,8 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
modified = 0;
else if( diag == 0 )
{
if( !IsOK( this, _( "Problem when saving files, exit anyway ?" ) ) )
if( !IsOK( this,
_( "Problem when saving files, exit anyway ?" ) ) )
{
Event.Veto();
return;
......@@ -240,10 +241,10 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
}
// Close the help frame
if( m_Parent->m_HtmlCtrl )
if( wxGetApp().m_HtmlCtrl )
{
if( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
m_Parent->m_HtmlCtrl->GetFrame()->Close( TRUE );
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
wxGetApp().m_HtmlCtrl->GetFrame()->Close( TRUE );
}
if( !NetInNameBuffer.IsEmpty() )
......@@ -372,7 +373,8 @@ void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event )
composants_non_affectes = nbcomp;
}
Line.Printf( _( "Componants: %d (free: %d)" ), nbcomp, composants_non_affectes );
Line.Printf( _( "Componants: %d (free: %d)" ), nbcomp,
composants_non_affectes );
SetStatusText( Line, 1 );
}
......@@ -486,8 +488,8 @@ void WinEDA_CvpcbFrame::SetLanguage( wxCommandEvent& event )
{
int id = event.GetId();
m_Parent->SetLanguageIdentifier( id );
m_Parent->SetLanguage();
wxGetApp().SetLanguageIdentifier( id );
wxGetApp().SetLanguage();
}
......@@ -497,12 +499,13 @@ void WinEDA_CvpcbFrame::DisplayDocFile( wxCommandEvent& event )
{
wxString DocModuleFileName, fullfilename;
DocModuleFileName = g_EDA_Appl->m_EDA_CommonConfig->Read( DOC_FOOTPRINTS_LIST_KEY,
DocModuleFileName = wxGetApp().m_EDA_CommonConfig->Read(
DOC_FOOTPRINTS_LIST_KEY,
DEFAULT_FOOTPRINTS_LIST_FILENAME );
if( wxIsAbsolutePath(DocModuleFileName) )
if( wxIsAbsolutePath( DocModuleFileName ) )
fullfilename = DocModuleFileName;
else
fullfilename = FindKicadHelpPath() + wxT("../") + DocModuleFileName;
fullfilename = FindKicadHelpPath() + wxT( "../" ) + DocModuleFileName;
GetAssociatedDocument( this, wxEmptyString, fullfilename );
}
......@@ -537,7 +540,8 @@ void WinEDA_CvpcbFrame::ProcessFontPreferences( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_DrawFrame::ProcessFontPreferences Internal Error" ) );
DisplayError( this,
wxT( "WinEDA_DrawFrame::ProcessFontPreferences Internal Error" ) );
break;
}
}
......
/*******************/
/* File: cvpcb.cpp */
/*******************/
/*******************/
/* File: cvpcb.cpp */
/*******************/
#define MAIN
#define eda_global
......@@ -9,7 +9,6 @@
#include "cvpcb.h"
#include "trigo.h"
#include "gr_basic.h"
#include "zones.h"
#include "bitmaps.h"
......@@ -18,77 +17,76 @@
#include "id.h"
wxString g_Main_Title = wxT("CVpcb");
wxString g_Main_Title = wxT( "CVpcb" );
// Create a new application object
IMPLEMENT_APP(WinEDA_App)
IMPLEMENT_APP( WinEDA_App )
/* fonctions locales */
/************************************/
/* Called to initialize the program */
/************************************/
/************************************/
/* Called to initialize the program */
/************************************/
bool WinEDA_App::OnInit()
{
wxString msg;
wxString currCWD = wxGetCwd();
wxString msg;
wxString currCWD = wxGetCwd();
WinEDA_CvpcbFrame* frame = NULL;
g_EDA_Appl = this;
InitEDA_Appl( wxT("cvpcb") );
InitEDA_Appl( wxT( "cvpcb" ) );
if ( m_Checker && m_Checker->IsAnotherRunning() )
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if ( ! IsOK(NULL, _("Cvpcb is already running, Continue?") ) )
if( !IsOK( NULL, _( "Cvpcb is already running, Continue?" ) ) )
return false;
}
GetSettings(); // read current setup
wxSetWorkingDirectory(currCWD); // mofifie par GetSetting
SetRealLibraryPath( wxT("modules") );
wxSetWorkingDirectory( currCWD ); // mofifie par GetSetting
SetRealLibraryPath( wxT( "modules" ) );
if(argc > 1 )
if( argc > 1 )
{
NetInNameBuffer = argv[1];
NetNameBuffer = argv[1];
}
if ( ! NetInNameBuffer.IsEmpty() )
wxSetWorkingDirectory( wxPathOnly(NetInNameBuffer) );
if( !NetInNameBuffer.IsEmpty() )
wxSetWorkingDirectory( wxPathOnly( NetInNameBuffer ) );
g_DrawBgColor = BLACK;
Read_Config(NetInNameBuffer);
Read_Config( NetInNameBuffer );
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion();
m_CvpcbFrame = new WinEDA_CvpcbFrame(this, Title);
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
frame = new WinEDA_CvpcbFrame( Title );
msg.Printf( wxT("Modules: %d"), nblib);
m_CvpcbFrame->SetStatusText(msg,2);
msg.Printf( wxT( "Modules: %d" ), nblib );
frame->SetStatusText( msg, 2 );
// Show the frame
SetTopWindow(m_CvpcbFrame);
SetTopWindow( frame );
m_CvpcbFrame->Show(TRUE);
frame->Show( TRUE );
listlib();
m_CvpcbFrame->BuildFootprintListBox();
frame->BuildFootprintListBox();
if( ! NetInNameBuffer.IsEmpty() ) /* nom de fichier passe a la commande */
if( !NetInNameBuffer.IsEmpty() ) /* nom de fichier passe a la commande */
{
FFileName = MakeFileName(NetDirBuffer,
NetInNameBuffer, NetInExtBuffer);
FFileName = MakeFileName( NetDirBuffer,
NetInNameBuffer, NetInExtBuffer );
m_CvpcbFrame->ReadNetListe();
frame->ReadNetListe();
}
else /* Mise a jour du titre de la fenetre principale */
{
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion();
msg.Printf( wxT("%s {%s%c} [no file]"),
Title.GetData(), wxGetCwd().GetData(), DIR_SEP);
m_CvpcbFrame->SetTitle(msg);
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
msg.Printf( wxT( "%s {%s%c} [no file]" ),
Title.GetData(), wxGetCwd().GetData(), DIR_SEP );
frame->SetTitle( msg );
}
return TRUE;
}
......@@ -39,7 +39,7 @@ private:
// Constructor and destructor
public:
WinEDA_CvpcbFrame( WinEDA_App * parent, const wxString &title,
WinEDA_CvpcbFrame( const wxString &title,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~WinEDA_CvpcbFrame();
......@@ -180,7 +180,7 @@ class WinEDA_DisplayFrame : public WinEDA_BasePcbFrame
public:
public:
WinEDA_DisplayFrame( wxWindow * father, WinEDA_App * parent,
WinEDA_DisplayFrame( wxWindow * father,
const wxString &title,
const wxPoint &pos, const wxSize &size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......
......@@ -72,7 +72,7 @@ wxString title;
m_DoUpdate = TRUE;
Create(parent, id, caption, pos, size, style);
title = _("from ") + g_EDA_Appl->m_CurrentOptionFile;
title = _("from ") + wxGetApp().m_CurrentOptionFile;
SetTitle(title);
}
......
......@@ -5,7 +5,6 @@
#include "fctsys.h"
#include "common.h"
#include "wxstruct.h"
#include "cvpcb.h"
#include "id.h"
#include "bitmaps.h"
......@@ -32,11 +31,11 @@ END_EVENT_TABLE()
/* WinEDA_DisplayFrame: the frame to display the current focused footprint */
/***************************************************************************/
WinEDA_DisplayFrame::WinEDA_DisplayFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_DisplayFrame::WinEDA_DisplayFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos,
const wxSize& size, long style ) :
WinEDA_BasePcbFrame( father, parent, CVPCB_DISPLAY_FRAME, title, pos,
WinEDA_BasePcbFrame( father, CVPCB_DISPLAY_FRAME, title, pos,
size, style )
{
m_FrameName = wxT( "CmpFrame" );
......@@ -73,7 +72,7 @@ WinEDA_DisplayFrame::~WinEDA_DisplayFrame()
delete m_Pcb;
m_Parent->m_CvpcbFrame->DrawFrame = NULL;
( (WinEDA_CvpcbFrame*) wxGetApp().GetTopWindow() )->DrawFrame = NULL;
}
......
/***************************************/
/** menucfg : configuration de CVPCB **/
/***************************************/
/***************************************/
/** menucfg : configuration de CVPCB **/
/***************************************/
/* cree et/ou affiche et modifie la configuration de CVPCB */
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "fctsys.h"
#include "common.h"
......@@ -24,19 +11,19 @@
#include "protos.h"
/*****************************************/
/* classe pour la frame de Configuration */
/*****************************************/
/*****************************************/
/* classe pour la frame de Configuration */
/*****************************************/
#include "dialog_cvpcb_config.cpp"
/***************************************************/
void WinEDA_CvpcbFrame::CreateConfigWindow()
/***************************************************/
/* Creation de la fenetre de configuration de CVPCB */
{
KiConfigCvpcbFrame * ConfigFrame = new KiConfigCvpcbFrame(this);
KiConfigCvpcbFrame* ConfigFrame = new KiConfigCvpcbFrame( this );
ConfigFrame->ShowModal(); ConfigFrame->Destroy();
}
......@@ -45,71 +32,94 @@ KiConfigCvpcbFrame * ConfigFrame = new KiConfigCvpcbFrame(this);
void KiConfigCvpcbFrame::SetDialogDatas()
/*********************************************/
{
m_ListLibr->InsertItems(g_LibName_List,0);
m_ListEquiv->InsertItems(g_ListName_Equ,0);
m_ListLibr->InsertItems( g_LibName_List, 0 );
m_ListEquiv->InsertItems( g_ListName_Equ, 0 );
m_LibDirCtrl = new WinEDA_EnterText(this,
_("Lib Dir:"), g_UserLibDirBuffer,
m_RightBoxSizer, wxDefaultSize);
m_LibDirCtrl = new WinEDA_EnterText( this,
_( "Lib Dir:" ), g_UserLibDirBuffer,
m_RightBoxSizer, wxDefaultSize );
m_NetInputExtCtrl = new WinEDA_EnterText(this,
_("Net Input Ext:"),NetInExtBuffer,
m_NetExtBoxSizer, wxDefaultSize);
m_NetInputExtCtrl = new WinEDA_EnterText( this,
_( "Net Input Ext:" ),
NetInExtBuffer,
m_NetExtBoxSizer, wxDefaultSize );
wxString DocModuleFileName =
g_EDA_Appl->m_EDA_CommonConfig->Read( DOC_FOOTPRINTS_LIST_KEY, DEFAULT_FOOTPRINTS_LIST_FILENAME);
m_TextHelpModulesFileName = new WinEDA_EnterText(this,
_("Module Doc File:"), DocModuleFileName,
m_RightBoxSizer, wxDefaultSize);
wxGetApp().m_EDA_CommonConfig->Read( DOC_FOOTPRINTS_LIST_KEY,
DEFAULT_FOOTPRINTS_LIST_FILENAME );
m_TextHelpModulesFileName = new WinEDA_EnterText( this,
_( "Module Doc File:" ),
DocModuleFileName,
m_RightBoxSizer,
wxDefaultSize );
/* Create info on Files ext */
wxStaticText * StaticText;
wxStaticText* StaticText;
wxString text;
text.Printf( wxT("%s %s"), _("Cmp ext:"), g_ExtCmpBuffer.GetData() );
StaticText = new wxStaticText(this, -1,text);
m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE);
text.Printf( wxT("%s %s"), _("Lib ext:"), LibExtBuffer.GetData());
StaticText = new wxStaticText(this, -1,text);
m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE);
text.Printf( wxT("%s %s"), _("NetOut ext:"), NetExtBuffer.GetData());
StaticText = new wxStaticText(this, -1,text);
m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE);
text.Printf( wxT("%s %s"), _("Equiv ext:"), g_EquivExtBuffer.GetData());
StaticText = new wxStaticText(this, -1,text);
m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE);
text.Printf( wxT("%s %s"), _("Retro ext:"), ExtRetroBuffer.GetData());
StaticText = new wxStaticText(this, -1,text);
m_FileExtList->Add(StaticText, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxADJUST_MINSIZE);
text.Printf( wxT( "%s %s" ), _( "Cmp ext:" ), g_ExtCmpBuffer.GetData() );
StaticText = new wxStaticText( this, -1, text );
m_FileExtList->Add(
StaticText,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
wxADJUST_MINSIZE );
text.Printf( wxT( "%s %s" ), _( "Lib ext:" ), LibExtBuffer.GetData() );
StaticText = new wxStaticText( this, -1, text );
m_FileExtList->Add(
StaticText,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
wxADJUST_MINSIZE );
text.Printf( wxT( "%s %s" ), _( "NetOut ext:" ), NetExtBuffer.GetData() );
StaticText = new wxStaticText( this, -1, text );
m_FileExtList->Add(
StaticText,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
wxADJUST_MINSIZE );
text.Printf( wxT( "%s %s" ), _( "Equiv ext:" ),
g_EquivExtBuffer.GetData() );
StaticText = new wxStaticText( this, -1, text );
m_FileExtList->Add(
StaticText,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
wxADJUST_MINSIZE );
text.Printf( wxT( "%s %s" ), _( "Retro ext:" ), ExtRetroBuffer.GetData() );
StaticText = new wxStaticText( this, -1, text );
m_FileExtList->Add(
StaticText,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM |
wxADJUST_MINSIZE );
}
/********************************************************/
void KiConfigCvpcbFrame::AcceptCfg(wxCommandEvent& event)
void KiConfigCvpcbFrame::AcceptCfg( wxCommandEvent& event )
/********************************************************/
{
Update();
Close();
}
/**********************************/
void KiConfigCvpcbFrame::Update()
/**********************************/
{
wxString msg;
wxString msg;
if ( ! m_DoUpdate ) return;
if( !m_DoUpdate )
return;
NetInExtBuffer = m_NetInputExtCtrl->GetValue();
g_EDA_Appl->m_EDA_CommonConfig->Write( DOC_FOOTPRINTS_LIST_KEY,
m_TextHelpModulesFileName->GetValue());
wxGetApp().m_EDA_CommonConfig->Write( DOC_FOOTPRINTS_LIST_KEY,
m_TextHelpModulesFileName->GetValue() );
msg = m_LibDirCtrl->GetValue();
if ( msg != g_UserLibDirBuffer )
if( msg != g_UserLibDirBuffer )
{
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") );
SetRealLibraryPath( wxT( "modules" ) );
listlib();
ListModIsModified = 1;
m_Parent->BuildFootprintListBox();
......@@ -118,26 +128,27 @@ wxString msg;
/****************************************************/
void KiConfigCvpcbFrame::SaveCfg(wxCommandEvent& event)
void KiConfigCvpcbFrame::SaveCfg( wxCommandEvent& event )
/****************************************************/
{
Update();
Save_Config(this);
Save_Config( this );
}
/******************************************************/
void KiConfigCvpcbFrame::ReadOldCfg(wxCommandEvent& event)
void KiConfigCvpcbFrame::ReadOldCfg( wxCommandEvent& event )
/******************************************************/
{
wxString line;
wxString line;
NetInNameBuffer.Replace(WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP);
NetInNameBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
wxString FullFileName = NetInNameBuffer.AfterLast('/');
wxString FullFileName = NetInNameBuffer.AfterLast( '/' );
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
FullFileName = EDA_FileSelector(_("Read config file"),
FullFileName = EDA_FileSelector( _( "Read config file" ),
wxGetCwd(), /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */
g_Prj_Config_Filename_ext, /* extension par defaut */
......@@ -146,164 +157,174 @@ wxString FullFileName = NetInNameBuffer.AfterLast('/');
wxFD_OPEN,
TRUE /* ne change pas de repertoire courant */
);
if ( FullFileName.IsEmpty() ) return;
if ( ! wxFileExists(FullFileName) )
if( FullFileName.IsEmpty() )
return;
if( !wxFileExists( FullFileName ) )
{
line.Printf( _("File %s not found"), FullFileName.GetData());
DisplayError(this, line); return;
line.Printf( _( "File %s not found" ), FullFileName.GetData() );
DisplayError( this, line ); return;
}
Read_Config( FullFileName );
m_DoUpdate = FALSE;
Close(TRUE);
Close( TRUE );
}
/*******************************************************/
void KiConfigCvpcbFrame::LibDelFct(wxCommandEvent& event)
void KiConfigCvpcbFrame::LibDelFct( wxCommandEvent& event )
/*******************************************************/
{
int ii;
int ii;
ii = m_ListLibr->GetSelection();
if ( ii < 0 ) return;
if( ii < 0 )
return;
ListModIsModified = 1;
g_LibName_List.RemoveAt(ii);
g_LibName_List.RemoveAt( ii );
/* suppression de la reference dans la liste des librairies */
m_ListLibr->Delete(ii);
m_ListLibr->Delete( ii );
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") );
SetRealLibraryPath( wxT( "modules" ) );
listlib();
m_Parent->BuildFootprintListBox();
}
/********************************************************/
void KiConfigCvpcbFrame::LibAddFct(wxCommandEvent& event)
void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event )
/********************************************************/
{
int ii;
wxString FullFileName, ShortLibName, mask;
int ii;
wxString FullFileName, ShortLibName, mask;
ii = m_ListLibr->GetSelection();
if ( event.GetId() == ADD_LIB ) /* Ajout apres selection */
if( event.GetId() == ADD_LIB ) /* Ajout apres selection */
{
ii ++;
ii++;
}
if ( ii < 0 ) ii = 0;
if( ii < 0 )
ii = 0;
Update();
mask = wxT("*") + LibExtBuffer;
mask = wxT( "*" ) + LibExtBuffer;
wxFileDialog FilesDialog(this, _("Library files:"), g_RealLibDirBuffer,
wxFileDialog FilesDialog( this, _( "Library files:" ), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetPaths(Filenames);
FilesDialog.GetPaths( Filenames );
if ( Filenames.GetCount() == 0 )
if( Filenames.GetCount() == 0 )
return;
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
FullFileName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,LibExtBuffer);
ShortLibName = MakeReducedFileName( FullFileName,
g_RealLibDirBuffer,
LibExtBuffer );
//Add or insert new library name
if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND)
if( g_LibName_List.Index( ShortLibName ) == wxNOT_FOUND )
{
ListModIsModified = 1;
g_LibName_List.Insert(ShortLibName, ii++);
g_LibName_List.Insert( ShortLibName, ii++ );
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _(
"Library already in use" );
DisplayError( this, msg );
}
}
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") );
SetRealLibraryPath( wxT( "modules" ) );
listlib();
m_Parent->BuildFootprintListBox();
m_ListLibr->Clear();
m_ListLibr->InsertItems(g_LibName_List, 0);
m_ListLibr->InsertItems( g_LibName_List, 0 );
}
/********************************************************/
void KiConfigCvpcbFrame::EquDelFct(wxCommandEvent& event)
void KiConfigCvpcbFrame::EquDelFct( wxCommandEvent& event )
/********************************************************/
{
int ii;
int ii;
ii = m_ListEquiv->GetSelection();
if ( ii < 0 ) return;
if( ii < 0 )
return;
g_ListName_Equ.RemoveAt(ii);
m_ListEquiv->Delete(ii);
g_ListName_Equ.RemoveAt( ii );
m_ListEquiv->Delete( ii );
}
/********************************************************/
void KiConfigCvpcbFrame::EquAddFct(wxCommandEvent& event)
void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event )
/********************************************************/
{
int ii;
wxString FullFileName, ShortLibName, mask;
int ii;
wxString FullFileName, ShortLibName, mask;
ii = m_ListEquiv->GetSelection();
if ( event.GetId() == ADD_EQU ) ii ++; /* Ajout apres selection */
if ( ii < 0 ) ii = 0;
if( event.GetId() == ADD_EQU )
ii++; /* Ajout apres selection */
if( ii < 0 )
ii = 0;
Update();
mask = wxT("*") + g_EquivExtBuffer;
mask = wxT( "*" ) + g_EquivExtBuffer;
wxFileDialog FilesDialog(this, _("Equiv Files:"), g_RealLibDirBuffer,
wxFileDialog FilesDialog( this, _( "Equiv Files:" ), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE );
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
FilesDialog.GetFilenames( Filenames );
if ( Filenames.GetCount() == 0 )
if( Filenames.GetCount() == 0 )
return;
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ )
{
FullFileName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,g_EquivExtBuffer);
ShortLibName = MakeReducedFileName( FullFileName,
g_RealLibDirBuffer,
g_EquivExtBuffer );
//Add or insert new equiv library name
if ( g_ListName_Equ.Index(ShortLibName) == wxNOT_FOUND)
if( g_ListName_Equ.Index( ShortLibName ) == wxNOT_FOUND )
{
g_ListName_Equ.Insert(ShortLibName, ii++);
g_ListName_Equ.Insert( ShortLibName, ii++ );
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
msg << wxT( "<" ) << ShortLibName << wxT( "> : " ) << _(
"Library already in use" );
DisplayError( this, msg );
}
}
/* Update display list */
g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") );
SetRealLibraryPath( wxT( "modules" ) );
listlib();
m_ListEquiv->Clear();
m_ListEquiv->InsertItems(g_ListName_Equ, 0);
m_ListEquiv->InsertItems( g_ListName_Equ, 0 );
}
......@@ -4,7 +4,6 @@
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "cvpcb.h"
#include "3d_viewer.h"
......@@ -28,9 +27,9 @@ void WinEDA_CvpcbFrame::CreateScreenCmp()
if( DrawFrame == NULL )
{
DrawFrame = new WinEDA_DisplayFrame( this, m_Parent, _( "Module" ),
wxPoint( 0, 0 ), wxSize( 600,
400 ),
DrawFrame = new WinEDA_DisplayFrame( this, _( "Module" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE |
wxFRAME_FLOAT_ON_PARENT );
IsNew = TRUE;
......
/***************************************************/
/* tool_cvpcb.cpp: construction du menu principal */
/***************************************************/
/***************************************************/
/* tool_cvpcb.cpp: construction du menu principal */
/***************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "cvpcb.h"
......@@ -12,8 +10,6 @@
#include "protos.h"
#define BITMAP wxBitmap
#include "bitmaps.h"
#include "id.h"
......@@ -23,64 +19,71 @@
void WinEDA_CvpcbFrame::ReCreateHToolbar()
/*********************************************/
{
if ( m_HToolBar != NULL ) return;
wxConfig* config = wxGetApp().m_EDA_Config;
m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE);
SetToolBar(m_HToolBar);
if( m_HToolBar != NULL )
return;
m_HToolBar->AddTool(ID_CVPCB_READ_INPUT_NETLIST, BITMAP(open_xpm),
_("Open a NetList file"));
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
SetToolBar( m_HToolBar );
m_HToolBar->AddTool(ID_CVPCB_SAVEQUITCVPCB, BITMAP(save_xpm),
_("Save NetList and Footprints List files"));
m_HToolBar->AddTool( ID_CVPCB_READ_INPUT_NETLIST, wxBitmap( open_xpm ),
_( "Open a NetList file" ) );
m_HToolBar->AddTool( ID_CVPCB_SAVEQUITCVPCB, wxBitmap( save_xpm ),
_( "Save NetList and Footprints List files" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_CVPCB_CREATE_CONFIGWINDOW, BITMAP(config_xpm),
_("Configuration"));
m_HToolBar->AddTool( ID_CVPCB_CREATE_CONFIGWINDOW, wxBitmap( config_xpm ),
_( "Configuration" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_CVPCB_CREATE_SCREENCMP, BITMAP(module_xpm),
_("View selected footprint"));
m_HToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxBitmap( module_xpm ),
_( "View selected footprint" ) );
m_HToolBar->AddTool(ID_CVPCB_AUTO_ASSOCIE, BITMAP(auto_associe_xpm),
_("Automatic Association"));
m_HToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxBitmap( auto_associe_xpm ),
_( "Automatic Association" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_CVPCB_GOTO_PREVIOUSNA, BITMAP(left_xpm),
_("Select previous free component"));
m_HToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxBitmap( left_xpm ),
_( "Select previous free component" ) );
m_HToolBar->AddTool(ID_CVPCB_GOTO_FIRSTNA, BITMAP(right_xpm),
_("Select next free component"));
m_HToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxBitmap( right_xpm ),
_( "Select next free component" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_CVPCB_DEL_ASSOCIATIONS, BITMAP(delete_association_xpm),
_("Delete all associations"));
m_HToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS,
wxBitmap( delete_association_xpm ),
_( "Delete all associations" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_CVPCB_CREATE_STUFF_FILE, BITMAP(save_cmpstuff_xpm),
_("Create stuff file (component/footprint list)"));
m_HToolBar->AddTool( ID_CVPCB_CREATE_STUFF_FILE,
wxBitmap( save_cmpstuff_xpm ),
_( "Create stuff file (component/footprint list)" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool(ID_PCB_DISPLAY_FOOTPRINT_DOC, BITMAP(file_footprint_xpm),
_("Display footprints list documentation"));
m_HToolBar->AddTool( ID_PCB_DISPLAY_FOOTPRINT_DOC,
wxBitmap( file_footprint_xpm ),
_( "Display footprints list documentation" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddSeparator();
m_HToolBar->AddRadioTool(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
wxEmptyString, BITMAP(module_filtered_list_xpm),
m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
wxEmptyString,
wxBitmap( module_filtered_list_xpm ),
wxNullBitmap,
_("Display the filtered footprint list for the current component"));
m_HToolBar->AddRadioTool(ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
wxEmptyString, BITMAP(module_full_list_xpm),
_( "Display the filtered footprint list for the current component" ) );
m_HToolBar->AddRadioTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
wxEmptyString, wxBitmap( module_full_list_xpm ),
wxNullBitmap,
_("Display the full footprint list (without filtering)"));
_( "Display the full footprint list (without filtering)" ) );
if( m_Parent->m_EDA_Config )
if( config )
{
wxString key = wxT(FILTERFOOTPRINTKEY);
int opt = m_Parent->m_EDA_Config->Read(key, (long)1);
m_HToolBar->ToggleTool(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt);
m_HToolBar->ToggleTool(ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, ! opt);
wxString key = wxT( FILTERFOOTPRINTKEY );
int opt = config->Read( key, (long) 1 );
m_HToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, opt );
m_HToolBar->ToggleTool( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, !opt );
}
// after adding the buttons to the toolbar, must call Realize() to reflect
......@@ -92,97 +95,104 @@ void WinEDA_CvpcbFrame::ReCreateHToolbar()
/*******************************************/
void WinEDA_CvpcbFrame::ReCreateMenuBar()
/*******************************************/
/* Creation des menus de la fenetre principale
*/
*/
{
int ii;
wxMenuBar * menuBar = GetMenuBar();
int ii;
wxMenuBar* menuBar = GetMenuBar();
if( menuBar == NULL )
{
menuBar = new wxMenuBar();
// Associate the menu bar with the frame
SetMenuBar(menuBar);
SetMenuBar( menuBar );
m_FilesMenu = new wxMenu;
wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_LOAD_PROJECT,
_("&Open"),
_("Open a NetList file") );
item->SetBitmap(open_xpm);
m_FilesMenu->Append(item);
wxMenuItem* item = new wxMenuItem( m_FilesMenu, ID_LOAD_PROJECT,
_( "&Open" ),
_( "Open a NetList file" ) );
item->SetBitmap( open_xpm );
m_FilesMenu->Append( item );
m_FilesMenu->AppendSeparator();
item = new wxMenuItem(m_FilesMenu, ID_SAVE_PROJECT,
_("&Save As..."),
_("Save New NetList and Footprints List files") );
item->SetBitmap(save_xpm);
m_FilesMenu->Append(item);
item = new wxMenuItem( m_FilesMenu, ID_SAVE_PROJECT,
_( "&Save As..." ),
_( "Save New NetList and Footprints List files" ) );
item->SetBitmap( save_xpm );
m_FilesMenu->Append( item );
m_FilesMenu->AppendSeparator();
item = new wxMenuItem(m_FilesMenu, ID_CVPCB_QUIT, _("E&xit"), _("Quit Cvpcb" ));
item->SetBitmap(exit_xpm);
m_FilesMenu->Append(item);
item = new wxMenuItem( m_FilesMenu, ID_CVPCB_QUIT, _( "E&xit" ),
_( "Quit Cvpcb" ) );
item->SetBitmap( exit_xpm );
m_FilesMenu->Append( item );
// Creation des selections des anciens fichiers
m_FilesMenu->AppendSeparator();
for ( ii = 0; ii < 10; ii++ )
for( ii = 0; ii < 10; ii++ )
{
if ( GetLastProject(ii).IsEmpty() ) break;
m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) );
if( GetLastProject( ii ).IsEmpty() )
break;
m_FilesMenu->Append( ID_LOAD_FILE_1 + ii, GetLastProject( ii ) );
}
// Menu Configuration:
wxMenu * configmenu = new wxMenu;
item = new wxMenuItem(configmenu, ID_CONFIG_REQ, _("&Configuration"),
_("Setting Libraries, Directories and others..."));
item->SetBitmap(config_xpm);
configmenu->Append(item);
wxMenu* configmenu = new wxMenu;
item = new wxMenuItem( configmenu, ID_CONFIG_REQ, _( "&Configuration" ),
_( "Setting Libraries, Directories and others..." ) );
item->SetBitmap( config_xpm );
configmenu->Append( item );
// Font selection and setup
AddFontSelectionMenu(configmenu);
AddFontSelectionMenu( configmenu );
m_Parent->SetLanguageList(configmenu);
wxGetApp().SetLanguageList( configmenu );
configmenu->AppendSeparator();
item = new wxMenuItem(configmenu, ID_CONFIG_SAVE,
_("&Save config"),
_("Save configuration in current dir"));
item->SetBitmap(save_setup_xpm);
configmenu->Append(item);
item = new wxMenuItem( configmenu, ID_CONFIG_SAVE,
_( "&Save config" ),
_( "Save configuration in current dir" ) );
item->SetBitmap( save_setup_xpm );
configmenu->Append( item );
// Menu Help:
wxMenu *helpMenu = new wxMenu;
item = new wxMenuItem(helpMenu , ID_CVPCB_DISPLAY_HELP, _("&Contents"),
_("Open the cvpcb manual"));
item->SetBitmap(help_xpm);
helpMenu->Append(item);
item = new wxMenuItem(helpMenu , ID_CVPCB_DISPLAY_LICENCE, _("&About cvpcb"),
_("About cvpcb schematic to pcb converter"));
item->SetBitmap(info_xpm);
helpMenu->Append(item);
menuBar->Append(m_FilesMenu, _("&File"));
menuBar->Append(configmenu, _("&Preferences"));
menuBar->Append(helpMenu, _("&Help"));
wxMenu* helpMenu = new wxMenu;
item = new wxMenuItem( helpMenu, ID_CVPCB_DISPLAY_HELP, _( "&Contents" ),
_( "Open the cvpcb manual" ) );
item->SetBitmap( help_xpm );
helpMenu->Append( item );
item =
new wxMenuItem( helpMenu, ID_CVPCB_DISPLAY_LICENCE,
_( "&About cvpcb" ),
_( "About cvpcb schematic to pcb converter" ) );
item->SetBitmap( info_xpm );
helpMenu->Append( item );
menuBar->Append( m_FilesMenu, _( "&File" ) );
menuBar->Append( configmenu, _( "&Preferences" ) );
menuBar->Append( helpMenu, _( "&Help" ) );
}
else // simple mise a jour de la liste des fichiers anciens
{
wxMenuItem * item;
int max_file = m_Parent->m_LastProjectMaxCount;
for ( ii = max_file-1; ii >=0 ; ii-- )
wxMenuItem* item;
int max_file = wxGetApp().m_LastProjectMaxCount;
for( ii = max_file - 1; ii >=0; ii-- )
{
if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) )
if( m_FilesMenu->FindItem( ID_LOAD_FILE_1 + ii ) )
{
item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii);
if ( item ) delete item;
item = m_FilesMenu->Remove( ID_LOAD_FILE_1 + ii );
if( item )
delete item;
}
}
for ( ii = 0; ii < max_file; ii++ )
for( ii = 0; ii < max_file; ii++ )
{
if ( GetLastProject(ii).IsEmpty() ) break;
m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) );
if( GetLastProject( ii ).IsEmpty() )
break;
m_FilesMenu->Append( ID_LOAD_FILE_1 + ii, GetLastProject( ii ) );
}
}
}
......@@ -4,7 +4,6 @@
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -19,17 +18,22 @@
/* Fonctions exportees */
/* Fonctions Locales */
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* screen,
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
wxDC* DC,
BASE_SCREEN* screen,
SCH_ITEM* DrawStruct );
static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position );
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
wxPoint& position );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static SCH_ITEM * SaveStructListForPaste( SCH_ITEM* DrawStruct );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct );
static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM * DrawStruct, wxPoint& Center );
static void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center );
SCH_ITEM* DrawStruct, wxPoint& Center );
static void MirrorOneStruct( SCH_ITEM* DrawStruct,
wxPoint& Center );
/*************************************************************************/
int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
......@@ -100,7 +104,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
bool err = FALSE;
DrawBlockStruct* block = &GetScreen()->BlockLocate;
SCH_ITEM * NewStruct = NULL;
SCH_ITEM* NewStruct = NULL;
if( DrawPanel->ManageCurseur == NULL )
{
......@@ -112,7 +116,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
{
wxString msg;
err = TRUE;
msg.Printf( wxT( "HandleBlockPLace() : m_BlockDrawStruct = NULL (cmd %d, state %d)" ),
msg.Printf( wxT( "HandleBlockPLace() : m_BlockDrawStruct = " \
"NULL (cmd %d, state %d)" ),
block->m_Command, block->m_State );
DisplayError( this, msg );
}
......@@ -130,9 +135,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
SaveCopyInUndoList( (SCH_ITEM*)block->m_BlockDrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) block->m_BlockDrawStruct, IS_CHANGED );
MoveStruct( DrawPanel, DC, (SCH_ITEM*)block->m_BlockDrawStruct );
MoveStruct( DrawPanel, DC, (SCH_ITEM*) block->m_BlockDrawStruct );
block->m_BlockDrawStruct = NULL;
DrawPanel->Refresh( TRUE );
break;
......@@ -142,10 +147,14 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
NewStruct = CopyStruct( DrawPanel, DC, GetScreen(), (SCH_ITEM*)block->m_BlockDrawStruct );
NewStruct = CopyStruct( DrawPanel, DC,
GetScreen(),
(SCH_ITEM*) block->m_BlockDrawStruct );
SaveCopyInUndoList( NewStruct,
(block->m_Command == BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW );
SaveCopyInUndoList(
NewStruct,
(block->m_Command ==
BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW );
block->m_BlockDrawStruct = NULL;
break;
......@@ -173,7 +182,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
/* clear struct.m_Flags */
SCH_ITEM* Struct;
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
......@@ -187,11 +198,14 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( block->m_BlockDrawStruct )
{
DisplayError( this, wxT( "HandleBlockPLace() error: DrawStruct != Null" ) );
DisplayError( this,
wxT( "HandleBlockPLace() error: DrawStruct != Null" ) );
block->m_BlockDrawStruct = NULL;
}
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
}
......@@ -267,7 +281,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
if( block->m_BlockDrawStruct != NULL )
{
ii = -1;
DeleteStruct( DrawPanel, DC, (SCH_ITEM*) block->m_BlockDrawStruct );
DeleteStruct( DrawPanel,
DC,
(SCH_ITEM*) block->m_BlockDrawStruct );
GetScreen()->SetModify();
}
block->m_BlockDrawStruct = NULL;
......@@ -283,8 +299,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{
wxPoint oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
SCH_ITEM * DrawStructCopy =
SaveStructListForPaste( (SCH_ITEM*)block->m_BlockDrawStruct );
SCH_ITEM* DrawStructCopy =
SaveStructListForPaste(
(SCH_ITEM*) block->m_BlockDrawStruct );
PlaceStruct( GetScreen(), DrawStructCopy );
GetScreen()->m_Curseur = oldpos;
ii = -1;
......@@ -316,7 +333,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
if( block->m_Command == BLOCK_ABORT )
{ /* clear struct.m_Flags */
EDA_BaseStruct* Struct;
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0;
}
......@@ -328,7 +347,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
}
if( zoom_command )
......@@ -414,7 +435,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
wxPoint oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = wxPoint( 0, 0 );
SCH_ITEM * DrawStructCopy =
SCH_ITEM* DrawStructCopy =
SaveStructListForPaste( (SCH_ITEM*) block->m_BlockDrawStruct );
PlaceStruct( GetScreen(), DrawStructCopy );
GetScreen()->m_Curseur = oldpos;
......@@ -424,7 +445,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_ZOOM: /* Window Zoom */
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
DrawPanel->SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
DrawPanel->SetCursor(
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
Window_Zoom( GetScreen()->BlockLocate );
break;
......@@ -438,13 +460,17 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL )
{
SaveCopyInUndoList( (SCH_ITEM*)block->m_BlockDrawStruct, IS_CHANGED );
SaveCopyInUndoList( (SCH_ITEM*) block->m_BlockDrawStruct,
IS_CHANGED );
ii = -1;
/* Compute the mirror centre and put it on grid */
wxPoint Center = block->Centre();
PutOnGrid( &Center );
MirrorStruct( DrawPanel, DC, (SCH_ITEM*)block->m_BlockDrawStruct, Center );
MirrorStruct( DrawPanel,
DC,
(SCH_ITEM*) block->m_BlockDrawStruct,
Center );
GetScreen()->SetModify();
}
TestDanglingEnds( GetScreen()->EEDrawList, DC );
......@@ -463,7 +489,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
}
}
......@@ -499,7 +527,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
{
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*)PickedList->m_PickedStruct,
(SCH_ITEM*) PickedList->m_PickedStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
PickedList = (DrawPickedStruct*) PickedList->Next();
......@@ -508,15 +536,17 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
else
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*)PtBlock->m_BlockDrawStruct,
(SCH_ITEM*) PtBlock->m_BlockDrawStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
}
/* Redessin nouvel affichage */
PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y;
PtBlock->m_MoveVector.x = screen->m_Curseur.x -
PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y = screen->m_Curseur.y -
PtBlock->m_BlockLastCursorPosition.y;
GRSetDrawMode( DC, g_XorMode );
PtBlock->Offset( PtBlock->m_MoveVector );
......@@ -532,7 +562,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
{
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*)PickedList->m_PickedStruct,
(SCH_ITEM*) PickedList->m_PickedStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
PickedList = (DrawPickedStruct*) PickedList->Next();
......@@ -541,7 +571,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
else
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*)PtBlock->m_BlockDrawStruct,
(SCH_ITEM*) PtBlock->m_BlockDrawStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
}
......@@ -565,7 +595,7 @@ bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
if( DC )
panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() );
PlaceStruct( panel->GetScreen(), pickedList); // Place it in its new position.
PlaceStruct( panel->GetScreen(), pickedList ); // Place it in its new position.
if( DC )
RedrawStructList( panel, DC, pickedList, GR_DEFAULT_DRAWMODE );
......@@ -576,7 +606,7 @@ bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
else
{
if( DC )
panel->PostDirtyRect( DrawStruct->GetBoundingBox());
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */
if( DC )
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
......@@ -594,7 +624,7 @@ static void MirrorYPoint( wxPoint& point, wxPoint& Center )
/**************************************************************/
void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
/**************************************************************/
/* Given a structure rotate it to 90 degrees refer to the Center point.
......@@ -612,10 +642,13 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
DrawNoConnectStruct* DrawNoConnect;
SCH_TEXT* DrawText;
wxPoint px;
WinEDA_SchematicFrame* frame;
if( !DrawStruct )
return;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
switch( DrawStruct->Type() )
{
case TYPE_NOT_INIT:
......@@ -684,7 +717,7 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
MirrorYPoint( px, Center );
px.x -= dx;
g_EDA_Appl->m_SchematicFrame->PutOnGrid( &px );
frame->PutOnGrid( &px );
DrawText->m_Pos.x = px.x;
break;
......@@ -700,23 +733,23 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
px = DrawText->m_Pos;
MirrorYPoint( px, Center );
g_EDA_Appl->m_SchematicFrame->PutOnGrid( &px );
frame->PutOnGrid( &px );
DrawText->m_Pos.x = px.x;
break;
case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
dx = DrawLibItem->m_Pos.x;
g_EDA_Appl->m_SchematicFrame->CmpRotationMiroir( DrawLibItem,
NULL, CMP_MIROIR_Y );
frame->CmpRotationMiroir( DrawLibItem, NULL, CMP_MIROIR_Y );
MirrorYPoint( DrawLibItem->m_Pos, Center );
dx -= DrawLibItem->m_Pos.x;
for( ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
/* move the fields to the new position because the component itself has moved */
DrawLibItem->GetField(ii)->m_Pos.x -= dx;
DrawLibItem->GetField( ii )->m_Pos.x -= dx;
}
break;
case DRAW_SHEET_STRUCT_TYPE:
......@@ -729,7 +762,8 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
{
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1;
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Next();
DrawSheetLabel =
(Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Next();
}
break;
......@@ -753,7 +787,10 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is *
* assumed, otherwise exactly one structure is assumed been picked. *
*****************************************************************************/
bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct, wxPoint& Center )
bool MirrorStruct( WinEDA_DrawPanel* panel,
wxDC* DC,
SCH_ITEM* DrawStruct,
wxPoint& Center )
{
if( !DrawStruct )
return FALSE;
......@@ -765,7 +802,7 @@ bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct, wxP
if( DC )
panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() );
for( DrawPickedStruct* cur = pickedList; cur; cur=cur->Next() )
for( DrawPickedStruct* cur = pickedList; cur; cur = cur->Next() )
{
MirrorOneStruct( (SCH_ITEM*) cur->m_PickedStruct, Center );
cur->m_PickedStruct->m_Flags = 0;
......@@ -795,8 +832,10 @@ bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct, wxP
/*****************************************************************************/
static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* screen,
SCH_ITEM * DrawStruct )
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
wxDC* DC,
BASE_SCREEN* screen,
SCH_ITEM* DrawStruct )
/*****************************************************************************/
/* Routine to copy a new entity of an object and reposition it.
......@@ -805,7 +844,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
* Return the new created struct
*/
{
SCH_ITEM * NewDrawStruct;
SCH_ITEM* NewDrawStruct;
DrawPickedStruct* PickedList = NULL;
if( !DrawStruct )
......@@ -829,7 +868,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
case TYPE_SCH_COMPONENT:
{
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation(NULL);
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
}
break;
......@@ -894,7 +933,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
case TYPE_SCH_COMPONENT:
( (SCH_COMPONENT*) NewDrawStruct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) NewDrawStruct )->ClearAnnotation(NULL);
( (SCH_COMPONENT*) NewDrawStruct )->ClearAnnotation( NULL );
break;
}
......@@ -917,7 +956,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
/*********************************************************************************/
void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct )
void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
/*********************************************************************************/
/* Routine to delete an object from global drawing object list.
......@@ -934,8 +973,11 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct )
{
/* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct*) DrawStruct )->GetParent(), IS_CHANGED );
frame->DeleteSheetLabel( DC ? true : false , (Hierarchical_PIN_Sheet_Struct*) DrawStruct );
frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct
*) DrawStruct )->GetParent(),
IS_CHANGED );
frame->DeleteSheetLabel( DC ? true : false,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct );
return;
}
......@@ -943,9 +985,11 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct )
{
// Unlink all picked structs from current EEDrawList
for( DrawPickedStruct* cur = (DrawPickedStruct*) DrawStruct; cur; cur=cur->Next() )
for( DrawPickedStruct* cur = (DrawPickedStruct*) DrawStruct;
cur;
cur = cur->Next() )
{
SCH_ITEM * item = cur->m_PickedStruct;
SCH_ITEM* item = cur->m_PickedStruct;
screen->RemoveFromDrawList( item );
panel->PostDirtyRect( item->GetBoundingBox() );
item->SetNext( 0 );
......@@ -977,7 +1021,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct )
/*****************************************************************/
SCH_ITEM * SaveStructListForPaste( SCH_ITEM * DrawStruct )
SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct )
/*****************************************************************/
/* Routine to Save an object from global drawing object list.
......@@ -987,7 +1031,7 @@ SCH_ITEM * SaveStructListForPaste( SCH_ITEM * DrawStruct )
*/
{
DrawPickedStruct* PickedList;
SCH_ITEM * DrawStructCopy;
SCH_ITEM* DrawStructCopy;
if( !DrawStruct )
return NULL;
......@@ -1027,7 +1071,7 @@ SCH_ITEM * SaveStructListForPaste( SCH_ITEM * DrawStruct )
*****************************************************************************/
void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
{
SCH_ITEM * DrawStruct;
SCH_ITEM* DrawStruct;
DrawPickedStruct* PickedList = NULL;
if( g_BlockSaveDataList == NULL )
......@@ -1051,7 +1095,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
if( Struct->Type() == TYPE_SCH_COMPONENT )
{
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation(NULL);
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
SetaParent( Struct, GetScreen() );
}
PickedList = (DrawPickedStruct*) PickedList->Next();
......@@ -1060,7 +1104,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; )
{
SCH_ITEM * Struct = PickedList->m_PickedStruct;
SCH_ITEM* Struct = PickedList->m_PickedStruct;
Struct->SetNext( GetScreen()->EEDrawList );
SetaParent( Struct, GetScreen() );
GetScreen()->EEDrawList = Struct;
......@@ -1075,7 +1119,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
{
( (SCH_COMPONENT*) DrawStruct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation(NULL);
( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation( NULL );
}
SetaParent( DrawStruct, GetScreen() );
RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
......@@ -1085,8 +1129,10 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
}
/* clear .m_Flags member for all items */
SCH_ITEM * Struct;
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
SCH_ITEM* Struct;
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0;
GetScreen()->SetModify();
......@@ -1098,7 +1144,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
/*****************************************************************************
* Routine to place a given object. *
*****************************************************************************/
bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM * DrawStruct )
bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct )
{
DrawPickedStruct* DrawStructs;
wxPoint move_vector;
......@@ -1149,7 +1195,7 @@ bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM * DrawStruct )
/**************************************************************************/
void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
/*************************************************************************/
/* Given a structure move it by Dx, Dy.
......@@ -1238,7 +1284,7 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
DrawLibItem->m_Pos += move_vector;
for( ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
{
DrawLibItem->GetField(ii)->m_Pos += move_vector;
DrawLibItem->GetField( ii )->m_Pos += move_vector;
}
break;
......@@ -1270,14 +1316,14 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
/************************************************************/
SCH_ITEM * DuplicateStruct( SCH_ITEM * DrawStruct )
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
/************************************************************/
/* Routine to create a new copy of given struct.
* The new object is not put in draw list (not linked)
*/
{
SCH_ITEM * NewDrawStruct = NULL;
SCH_ITEM* NewDrawStruct = NULL;
if( DrawStruct == NULL )
{
......@@ -1379,7 +1425,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/****************************************************/
{
DrawPickedStruct* DrawStructs, * FirstPicked;
SCH_ITEM * Struct;
SCH_ITEM* Struct;
EDA_DrawLineStruct* SegmStruct;
int ox, oy, fx, fy;
......@@ -1387,12 +1433,15 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct->m_Flags = 0;
if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
if( screen->BlockLocate.m_BlockDrawStruct->Type() ==
DRAW_SEGMENT_STRUCT_TYPE )
screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED;
else if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
else if( screen->BlockLocate.m_BlockDrawStruct->Type() ==
DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
DrawStructs =
(DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
while( DrawStructs )
{
Struct = DrawStructs->m_PickedStruct;
......@@ -1416,9 +1465,11 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Pour Drag Block: remise sous forme de liste de structure, s'il n'y
* a qu'un seul element ( pour homogeneiser les traitements ulterieurs */
if( screen->BlockLocate.m_BlockDrawStruct->Type() != DRAW_PICK_ITEM_STRUCT_TYPE )
if( screen->BlockLocate.m_BlockDrawStruct->Type() !=
DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawStructs = new DrawPickedStruct( (SCH_ITEM*) screen->BlockLocate.m_BlockDrawStruct );
DrawStructs = new DrawPickedStruct(
(SCH_ITEM*) screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = DrawStructs;
}
......@@ -1446,7 +1497,9 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
* fils et connexions hors bloc relies a des pins ou entries elles meme
* draggees */
FirstPicked = DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
FirstPicked = DrawStructs =
(DrawPickedStruct*) screen->BlockLocate.
m_BlockDrawStruct;
while( DrawStructs )
{
Struct = DrawStructs->m_PickedStruct;
......@@ -1458,7 +1511,8 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
while( DrawItem )
{
if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) )
if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy)
|| (pos.y > fy) )
AddPickedItem( screen, pos );
DrawItem = GetNextPinPosition( NULL, pos );
......@@ -1467,7 +1521,8 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
Hierarchical_PIN_Sheet_Struct* SLabel = ( (DrawSheetStruct*) Struct )->m_Label;
Hierarchical_PIN_Sheet_Struct* SLabel =
( (DrawSheetStruct*) Struct )->m_Label;
while( SLabel )
{
if( SLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
......@@ -1491,7 +1546,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
/******************************************************************/
{
DrawPickedStruct* DrawStructs;
SCH_ITEM * Struct;
SCH_ITEM* Struct;
/* Examen de la liste des elements deja selectionnes */
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
......@@ -1541,7 +1596,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
break;
case DRAW_SEGMENT_STRUCT_TYPE:
......@@ -1553,7 +1609,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~STARTPOINT;
}
......@@ -1561,7 +1618,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~ENDPOINT;
}
......@@ -1582,7 +1640,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED;
break;
......@@ -1596,7 +1655,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED;
break;
......@@ -1621,7 +1681,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED;
break;
......@@ -1634,7 +1695,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = (EDA_BaseStruct*) DrawStructs;
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED;
break;
......@@ -1661,7 +1723,8 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
if( DrawLibItem )
{
NextItem = NULL;
if( ( Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString,
if( ( Entry =
FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT ) ) == NULL )
return NULL;
DEntry = Entry->m_Drawings;
......@@ -1690,10 +1753,10 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* DrawLibItem,
orient = Pin->ReturnPinDrawOrient( TransMat );
/* Calcul de la position du point de reference */
position.x = PartX + (TransMat[0][0] * Pin->m_Pos.x)
+ (TransMat[0][1] * Pin->m_Pos.y);
position.y = PartY + (TransMat[1][0] * Pin->m_Pos.x)
+ (TransMat[1][1] * Pin->m_Pos.y);
position.x = PartX + (TransMat[0][0] *Pin->m_Pos.x)
+ (TransMat[0][1] *Pin->m_Pos.y);
position.y = PartY + (TransMat[1][0] *Pin->m_Pos.x)
+ (TransMat[1][1] *Pin->m_Pos.y);
NextItem = DEntry->Next();
return DEntry;
}
......
......@@ -3,7 +3,6 @@
/*****************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -14,16 +13,23 @@
/**********************************************************************************************/
void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
int aColor,
int aDrawMode,
void* aData,
int aTransformMatrix[2][2] )
/**********************************************************************************************/
{
// Invisibles pins are only drawn on request.
// But in libedit they are drawn in g_InvisibleItemColor because we must see them
WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
if( ( m_Attributs & PINNOTDRAW ) )
{
if ( g_EDA_Appl->m_LibeditFrame && g_EDA_Appl->m_LibeditFrame->IsActive() )
if( frame->m_LibeditFrame && frame->m_LibeditFrame->IsActive() )
aColor = g_InvisibleItemColor;
else if( !g_ShowAllPins )
return;
......@@ -53,8 +59,12 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffs
/********************************************************************************/
void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aPinPos, int aOrient, int aDrawMode, int aColor )
void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aPinPos,
int aOrient,
int aDrawMode,
int aColor )
/*******************************************************************************/
/* Draw the pin symbol (without texts)
......@@ -120,14 +130,34 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 + CLOCK_PIN_DIM );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 - MapX1 * CLOCK_PIN_DIM, y1, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1 - CLOCK_PIN_DIM, width, color );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1 - MapX1 * CLOCK_PIN_DIM,
y1,
width,
color );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1,
y1 - CLOCK_PIN_DIM,
width,
color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 + CLOCK_PIN_DIM, y1 );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1 - MapY1 * CLOCK_PIN_DIM, width, color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 - CLOCK_PIN_DIM, y1, width, color );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1,
y1 - MapY1 * CLOCK_PIN_DIM,
width,
color );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1 - CLOCK_PIN_DIM,
y1,
width,
color );
}
}
......@@ -136,8 +166,12 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2, y1 );
GRLineTo( &aPanel->m_ClipBox, aDC, x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM, width, color );
GRLineTo( &aPanel->m_ClipBox,
aDC,
x1 + MapX1 * IEEE_SYMBOL_PIN_DIM * 2,
y1 - IEEE_SYMBOL_PIN_DIM,
width,
color );
GRLineTo( &aPanel->m_ClipBox, aDC, x1, y1, width, color );
}
else /* MapX1 = 0 */
......@@ -176,7 +210,13 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/* Draw the pin end target (active end of the pin) */
if( !g_IsPrinting ) // Draw but do not print the pin end target 1 pixel width */
GRCircle( &aPanel->m_ClipBox, aDC, posX, posY, TARGET_PIN_DIAM, 0, color );
GRCircle( &aPanel->m_ClipBox,
aDC,
posX,
posY,
TARGET_PIN_DIAM,
0,
color );
}
......@@ -188,10 +228,15 @@ void LibDrawPin::DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC,
* If TextInside then the text is been put inside,otherwise all is drawn outside.
* Pin Name: substring beteween '~' is negated
*****************************************************************************/
void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName,
int Color, int DrawMode )
void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel,
wxDC* DC,
wxPoint& pin_pos,
int orient,
int TextInside,
bool DrawPinNum,
bool DrawPinName,
int Color,
int DrawMode )
/* DrawMode = GR_OR, XOR ... */
{
int ii, x, y, x1, y1, dx, dy, len;
......@@ -244,7 +289,8 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
{
if( *textsrc == '~' )
{
PinTextBarPos[PinTextBarCount++] = (int) (PinTxtLen * fPinTextPitch);
PinTextBarPos[PinTextBarCount++] =
(int) ( PinTxtLen * fPinTextPitch );
}
else
{
......@@ -255,7 +301,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
textsrc++;
}
PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
PinTxtLen = (int) ( fPinTextPitch * PinTxtLen );
PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'
if( PinText[0] == 0 )
......@@ -272,10 +318,13 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
DrawGraphicText( panel, DC, wxPoint( x,
y1 ), NameColor,
PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -285,16 +334,24 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
GRLineRel( &panel->m_ClipBox,
DC,
len,
0,
LineWidth,
NameColor );
}
}
else // Orient == PIN_LEFT
{
x = x1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x, y1 ), NameColor, PinText,
DrawGraphicText( panel, DC, wxPoint( x,
y1 ), NameColor,
PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -304,7 +361,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx - PinTxtLen, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
GRLineRel( &panel->m_ClipBox,
DC,
len,
0,
LineWidth,
NameColor );
}
}
}
......@@ -312,9 +374,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ), NumColor, StringPinNum,
wxPoint( (x1 + pin_pos.x) / 2,
y1 - TXTMARGE ), NumColor,
StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
}
}
else /* Its a vertical line. */
......@@ -326,9 +391,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
{
y = y1 + TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
DrawGraphicText( panel, DC, wxPoint( x1,
y ), NameColor,
PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -338,16 +406,24 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
GRLineRel( &panel->m_ClipBox,
DC,
0,
-len,
LineWidth,
NameColor );
}
}
else /* PIN_UP */
{
y = y1 - TextInside;
DrawGraphicText( panel, DC, wxPoint( x1, y ), NameColor, PinText,
DrawGraphicText( panel, DC, wxPoint( x1,
y ), NameColor,
PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -357,7 +433,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, -dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
GRLineRel( &panel->m_ClipBox,
DC,
0,
-len,
LineWidth,
NameColor );
}
}
}
......@@ -365,9 +446,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
if( DrawPinNum )
{
DrawGraphicText( panel, DC,
wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ), NumColor, StringPinNum,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ), NumColor,
StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
}
}
......@@ -379,10 +463,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
if( PinText && DrawPinName )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, y1 - TXTMARGE ),
DrawGraphicText( panel, DC, wxPoint( x,
y1 - TXTMARGE ),
NameColor, PinText,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -391,16 +477,23 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( dx, 0 );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, len, 0, LineWidth, NameColor );
GRLineRel( &panel->m_ClipBox,
DC,
len,
0,
LineWidth,
NameColor );
}
}
if( DrawPinNum )
{
x = (x1 + pin_pos.x) / 2;
DrawGraphicText( panel, DC, wxPoint( x, y1 + TXTMARGE ),
DrawGraphicText( panel, DC, wxPoint( x,
y1 + TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LineWidth );
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP,
LineWidth );
}
}
else /* Its a vertical line. */
......@@ -408,10 +501,12 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
if( PinText && DrawPinName )
{
y = (y1 + pin_pos.y) / 2;
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE, y ),
DrawGraphicText( panel, DC, wxPoint( x1 - TXTMARGE,
y ),
NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -420,16 +515,24 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, wxDC* DC,
dx = PinTextBarPos[ii++]; // Get the line pos
GRMoveRel( 0, PinTxtLen - dx );
len = PinTextBarPos[ii++] - dx; // Get the line length
GRLineRel( &panel->m_ClipBox, DC, 0, -len, LineWidth, NameColor );
GRLineRel( &panel->m_ClipBox,
DC,
0,
-len,
LineWidth,
NameColor );
}
}
if( DrawPinNum )
{
DrawGraphicText( panel, DC, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
DrawGraphicText( panel, DC,
wxPoint( x1 + TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER, LineWidth );
}
}
}
......@@ -448,8 +551,11 @@ extern void Move_Plume( wxPoint pos, int plume ); // see plot.cpp
* If TextInside then the text is been put inside (moving from x1, y1 in *
* the opposite direction to x2,y2), otherwise all is drawn outside. *
*****************************************************************************/
void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
int TextInside, bool DrawPinNum, bool DrawPinName )
void LibDrawPin::PlotPinTexts( wxPoint& pin_pos,
int orient,
int TextInside,
bool DrawPinNum,
bool DrawPinName )
{
int dx, len, start;
int ii, x, y, x1, y1, cte;
......@@ -461,7 +567,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
int PinTxtLen = 0;
wxSize PinNameSize = wxSize( m_PinNameSize, m_PinNameSize );
wxSize PinNumSize = wxSize( m_PinNumSize, m_PinNumSize );
bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt;
bool plot_color = (g_PlotFormat == PLOT_FORMAT_POST)
&& g_PlotPSColorOpt;
/* Get the num and name colors */
NameColor = plot_color ? ReturnLayerColor( LAYER_PINNAM ) : -1;
......@@ -495,7 +602,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
{
if( *textsrc == '~' )
{
PinTextBarPos[PinTextBarCount++] = (int) (fPinTextPitch * PinTxtLen);
PinTextBarPos[PinTextBarCount++] =
(int) ( fPinTextPitch * PinTxtLen );
}
else
{
......@@ -506,7 +614,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
textsrc++;
}
PinTxtLen = (int) (fPinTextPitch * PinTxtLen);
PinTxtLen = (int) ( fPinTextPitch * PinTxtLen );
PinTextBarPos[PinTextBarCount] = PinTxtLen; // Needed if no end '~'
if( PinText[0] == 0 )
......@@ -521,10 +629,13 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
if( orient == PIN_RIGHT )
{
x = x1 + TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ), NameColor, PinText,
PlotGraphicText( g_PlotFormat, wxPoint( x,
y1 ), NameColor,
PinText,
TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER );
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -538,10 +649,12 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
else // orient == PIN_LEFT
{
x = x1 - TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 ),
PlotGraphicText( g_PlotFormat, wxPoint( x,
y1 ),
NameColor, PinText, TEXT_ORIENT_HORIZ,
PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER );
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -556,10 +669,13 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat, wxPoint( (x1 + pin_pos.x) / 2, y1 - TXTMARGE ),
PlotGraphicText( g_PlotFormat,
wxPoint( (x1 + pin_pos.x) / 2,
y1 - TXTMARGE ),
NumColor, StringPinNum,
TEXT_ORIENT_HORIZ, PinNumSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM );
}
}
else /* Its a vertical line. */
......@@ -570,9 +686,12 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
{
y = y1 + TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, PinText,
PlotGraphicText( g_PlotFormat, wxPoint( x1,
y ), NameColor,
PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_TOP );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -587,9 +706,12 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
{
y = y1 - TextInside;
PlotGraphicText( g_PlotFormat, wxPoint( x1, y ), NameColor, PinText,
PlotGraphicText( g_PlotFormat, wxPoint( x1,
y ), NameColor,
PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -604,10 +726,13 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, (y1 + pin_pos.y) / 2 ),
PlotGraphicText( g_PlotFormat,
wxPoint( x1 - TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER );
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER );
}
}
}
......@@ -619,10 +744,12 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
if( PinText && DrawPinName )
{
x = (x1 + pin_pos.x) / 2;
PlotGraphicText( g_PlotFormat, wxPoint( x, y1 - TXTMARGE ),
PlotGraphicText( g_PlotFormat, wxPoint( x,
y1 - TXTMARGE ),
NameColor, PinText,
TEXT_ORIENT_HORIZ, PinNameSize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM );
GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_BOTTOM );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -648,10 +775,12 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
if( PinText && DrawPinName )
{
y = (y1 + pin_pos.y) / 2;
PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE, y ),
PlotGraphicText( g_PlotFormat, wxPoint( x1 - TXTMARGE,
y ),
NameColor, PinText,
TEXT_ORIENT_VERT, PinNameSize,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER );
GR_TEXT_HJUSTIFY_RIGHT,
GR_TEXT_VJUSTIFY_CENTER );
for( ii = 0; ii < PinTextBarCount; )
{
......@@ -666,17 +795,19 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient,
if( DrawPinNum )
{
PlotGraphicText( g_PlotFormat, wxPoint( x1 + TXTMARGE, (y1 + pin_pos.y) / 2 ),
PlotGraphicText( g_PlotFormat,
wxPoint( x1 + TXTMARGE,
(y1 + pin_pos.y) / 2 ),
NumColor, StringPinNum,
TEXT_ORIENT_VERT, PinNumSize,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER );
GR_TEXT_HJUSTIFY_LEFT,
GR_TEXT_VJUSTIFY_CENTER );
}
}
}
}
/***************************************************************/
LibDrawPin::LibDrawPin() : LibEDA_BaseStruct( COMPONENT_PIN_DRAW_TYPE )
/***************************************************************/
......@@ -780,7 +911,7 @@ void LibDrawPin::ReturnPinStringNum( wxString& buffer ) const
{
char ascii_buf[5];
memcpy(ascii_buf, &m_PinNum , 4);
memcpy( ascii_buf, &m_PinNum, 4 );
ascii_buf[4] = 0;
buffer = CONV_FROM_UTF8( ascii_buf );
......@@ -835,4 +966,3 @@ LibDrawPin* LibDrawPin::GenCopy()
return newpin;
}
......@@ -3,7 +3,6 @@
/*********************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -15,7 +14,8 @@
/* Routines locales */
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, EDA_DrawLineStruct* TstSegm );
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
EDA_DrawLineStruct* TstSegm );
/* Variable locales */
......@@ -33,6 +33,10 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
int flag;
bool Modify = FALSE;
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
DrawList = EEDrawList;
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
......@@ -63,7 +67,7 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
}
}
g_EDA_Appl->m_SchematicFrame->TestDanglingEnds( EEDrawList, DC );
frame->TestDanglingEnds( EEDrawList, DC );
return Modify;
}
......@@ -80,7 +84,8 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
if( Screen == NULL )
{
DisplayError( NULL, wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
DisplayError( NULL,
wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
return;
}
......@@ -149,7 +154,8 @@ DrawPickedStruct* BreakSegment( SCH_SCREEN* screen,
segment = (EDA_DrawLineStruct*) DrawList;
ox = segment->m_Start.x; oy = segment->m_Start.y;
fx = segment->m_End.x; fy = segment->m_End.y;
if( distance( fx - ox, fy - oy, breakpoint.x - ox, breakpoint.y - oy, 0 ) == 0 )
if( distance( fx - ox, fy - oy, breakpoint.x - ox, breakpoint.y -
oy, 0 ) == 0 )
break;
/* Segment connecte: doit etre coupe en 2 si px,py n'est
......@@ -256,10 +262,10 @@ static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
}
else
{
if( atan2( (double)(RefSegm->m_Start.x - RefSegm->m_End.x),
(double)(RefSegm->m_Start.y - RefSegm->m_End.y) ) ==
atan2( (double)(TstSegm->m_Start.x - TstSegm->m_End.x),
(double)(TstSegm->m_Start.y - TstSegm->m_End.y) ) )
if( atan2( (double) ( RefSegm->m_Start.x - RefSegm->m_End.x ),
(double) ( RefSegm->m_Start.y - RefSegm->m_End.y ) ) ==
atan2( (double) ( TstSegm->m_Start.x - TstSegm->m_End.x ),
(double) ( TstSegm->m_Start.y - TstSegm->m_End.y ) ) )
{
RefSegm->m_End = TstSegm->m_End;
return 1;
......
......@@ -36,8 +36,10 @@ void RemoteCommand( const char* cmdline )
char line[1024];
char* idcmd;
char* text;
WinEDA_SchematicFrame* frame = g_EDA_Appl->m_SchematicFrame;
wxString part_ref, msg;
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
strncpy( line, cmdline, sizeof(line) - 1 );
......@@ -109,14 +111,16 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT
{
if( LibItem == NULL )
break;
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField(REFERENCE)->m_Text ) );
sprintf( Line, "$PART: %s",
CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
SendCommand( MSG_TO_PCB, Line );
}
break;
case TYPE_SCH_COMPONENT:
LibItem = (SCH_COMPONENT*) objectToSync;
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
sprintf( Line, "$PART: %s",
CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
SendCommand( MSG_TO_PCB, Line );
break;
......@@ -133,7 +137,8 @@ void WinEDA_SchematicFrame::SendMessageToPCBNEW( EDA_BaseStruct* objectT
CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
}
else
sprintf( Line, "$PART: %s", CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
sprintf( Line, "$PART: %s",
CONV_TO_UTF8( LibItem->GetField( REFERENCE )->m_Text ) );
SendCommand( MSG_TO_PCB, Line );
break;
......
......@@ -3,7 +3,6 @@
/*******************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -24,8 +23,10 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
{
EDA_BaseStruct* DrawStruct;
EDA_BaseStruct* EEDrawList;
WinEDA_SchematicFrame* frame = g_EDA_Appl->m_SchematicFrame;
wxString msg;
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
if( FirstSheet == NULL )
return;
......@@ -59,7 +60,8 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
EEDrawList = EEDrawList->Next();
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DeleteSubHierarchy( (DrawSheetStruct*) DrawStruct, confirm_deletion );
DeleteSubHierarchy( (DrawSheetStruct*) DrawStruct,
confirm_deletion );
}
}
......
......@@ -132,12 +132,15 @@ WinEDA_Build_BOM_Frame::WinEDA_Build_BOM_Frame( WinEDA_DrawFrame* parent,
const wxSize& size,
long style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxASSERT( config != NULL );
m_Parent = parent;
/* Get options */
s_OutputFormOpt = m_Parent->m_Parent->m_EDA_Config->Read( OPTION_BOM_FORMAT, (long) 0 );
s_OutputSeparatorOpt = m_Parent->m_Parent->m_EDA_Config->Read( OPTION_BOM_SEPARATOR, (long) 0 );
long addfields = m_Parent->m_Parent->m_EDA_Config->Read( OPTION_BOM_ADD_FIELD, (long) 0 );
s_OutputFormOpt = config->Read( OPTION_BOM_FORMAT, (long) 0 );
s_OutputSeparatorOpt = config->Read( OPTION_BOM_SEPARATOR, (long) 0 );
long addfields = config->Read( OPTION_BOM_ADD_FIELD, (long) 0 );
for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ )
{
if( (addfields & bitmask) )
......@@ -491,6 +494,9 @@ void WinEDA_Build_BOM_Frame::OnApplyClick( wxCommandEvent& event )
void WinEDA_Build_BOM_Frame::SavePreferences()
/**************************************************/
{
wxConfig* config = wxGetApp().m_EDA_Config;
wxASSERT( config != NULL );
// Determine current settings of "List items" and "Options" checkboxes
// (NOTE: These 6 settings are restored when the dialog box is next
// invoked, but are *not* still saved after EESchema is next shut down.)
......@@ -519,8 +525,8 @@ void WinEDA_Build_BOM_Frame::SavePreferences()
s_Add_F8_state = m_AddField8->GetValue();
// Now save current settings of both radiobutton groups
m_Parent->m_Parent->m_EDA_Config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt );
m_Parent->m_Parent->m_EDA_Config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt );
config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt );
config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt );
// Now save current settings of all "Fields to add" checkboxes
long addfields = 0;
......@@ -531,5 +537,5 @@ void WinEDA_Build_BOM_Frame::SavePreferences()
bitmask <<= 1;
}
m_Parent->m_Parent->m_EDA_Config->Write( OPTION_BOM_ADD_FIELD, addfields );
config->Write( OPTION_BOM_ADD_FIELD, addfields );
}
......@@ -102,7 +102,7 @@ wxString msg;
Create(parent, id, caption, pos, size, style);
msg = _("from ") + g_EDA_Appl->m_CurrentOptionFile;
msg = _("from ") + wxGetApp().m_CurrentOptionFile;
SetTitle(msg);
SetFormatsNetListes();
m_ListLibr->InsertItems(g_LibName_List, 0);
......@@ -312,8 +312,8 @@ void KiConfigEeschemaFrame::OnCloseWindow(wxCloseEvent & event)
if ( m_LibListChanged )
{
LoadLibraries(m_Parent);
if ( m_Parent->m_Parent->m_ViewlibFrame )
m_Parent->m_Parent->m_ViewlibFrame->ReCreateListLib();
if ( m_Parent->m_ViewlibFrame )
m_Parent->m_ViewlibFrame->ReCreateListLib();
}
EndModal(0);
}
......
......@@ -10,7 +10,6 @@
#include "protos.h"
#include "eeconfig.h"
#include "worksheet.h"
#include "hotkeys_basic.h"
#include "hotkeys.h"
#include "id.h"
......@@ -44,7 +43,7 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
case ID_OPTIONS_SETUP:
DisplayOptionFrame( this, pos );
DrawPanel->Refresh(TRUE); // Redraw, because grid settings may have changed.
DrawPanel->Refresh( TRUE ); // Redraw, because grid settings may have changed.
break;
case ID_CONFIG_SAVE:
......@@ -93,7 +92,7 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
AddDelimiterString(FullFileName);
AddDelimiterString( FullFileName );
wxString editorname = GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, FullFileName );
......@@ -110,7 +109,9 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Config internal error" ) );
DisplayError( this,
wxT(
"WinEDA_SchematicFrame::Process_Config internal error" ) );
}
}
......@@ -123,11 +124,14 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
* Read the hotkey files config for eeschema and libedit
*/
{
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
wxString FullFileName = ReturnHotkeyConfigFilePath(
g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
frame->ReadHotkeyConfigFile( FullFileName, s_Eeschema_Hokeys_Descr, verbose );
frame->ReadHotkeyConfigFile( FullFileName,
s_Eeschema_Hokeys_Descr,
verbose );
return TRUE;
}
......@@ -148,6 +152,9 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig )
wxString FullFileName;
bool IsRead = TRUE;
wxArrayString liblist_tmp = g_LibName_List;
WinEDA_SchematicFrame* frame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
if( CfgFileName.IsEmpty() )
FullFileName = g_RootSheet->m_AssociatedScreen->m_FileName;
......@@ -155,8 +162,9 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig )
FullFileName = CfgFileName;
g_LibName_List.Clear();
if( !g_EDA_Appl->ReadProjectConfig( FullFileName,
GROUP, ParamCfgList, ForceRereadConfig ? FALSE : TRUE ) ) // Config non lue
if( !wxGetApp().ReadProjectConfig( FullFileName,
GROUP, ParamCfgList,
ForceRereadConfig ? FALSE : TRUE ) ) // Config non lue
{
g_LibName_List = liblist_tmp;
IsRead = FALSE;
......@@ -172,13 +180,13 @@ bool Read_Config( const wxString& CfgFileName, bool ForceRereadConfig )
g_LibName_List.Add( wxT( "device" ) );
}
if( g_EDA_Appl->m_SchematicFrame )
if( frame )
{
g_EDA_Appl->m_SchematicFrame->SetDrawBgColor( g_DrawBgColor );
g_EDA_Appl->m_SchematicFrame->m_Draw_Grid = g_ShowGrid;
frame->SetDrawBgColor( g_DrawBgColor );
frame->m_Draw_Grid = g_ShowGrid;
}
LoadLibraries( g_EDA_Appl->m_SchematicFrame );
LoadLibraries( frame );
return IsRead;
}
......@@ -210,5 +218,5 @@ void WinEDA_SchematicFrame::Save_Config( wxWindow* displayframe )
return;
/* ecriture de la configuration */
g_EDA_Appl->WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
wxGetApp().WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
}
......@@ -11,8 +11,6 @@
#include "fctsys.h"
#include <wx/image.h>
#include "common.h"
#include "program.h"
#include "libcmp.h"
......@@ -42,8 +40,7 @@ IMPLEMENT_APP( WinEDA_App )
bool WinEDA_App::OnInit()
{
wxString FFileName;
g_EDA_Appl = this;
WinEDA_SchematicFrame* frame = NULL;
g_DebugLevel = 0; // Debug level */
......@@ -61,44 +58,43 @@ bool WinEDA_App::OnInit()
/* init EESCHEMA */
GetSettings(); // read current setup
SeedLayers();
Read_Hotkey_Config( m_SchematicFrame, false ); /* Must be called before creating the main frame
* in order to display the real hotkeys in menus
Read_Hotkey_Config( frame, false ); /* Must be called before creating
* the main frame in order to
* display the real hotkeys in menus
* or tool tips */
// Create main frame (schematic frame) :
m_SchematicFrame = new WinEDA_SchematicFrame( NULL, this,
wxT( "EESchema" ),
frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
wxPoint( 0, 0 ), wxSize( 600, 400 ) );
SetTopWindow( m_SchematicFrame );
m_SchematicFrame->Show( TRUE );
SetTopWindow( frame );
frame->Show( TRUE );
if( CreateServer( m_SchematicFrame, KICAD_SCH_PORT_SERVICE_NUMBER ) )
if( CreateServer( frame, KICAD_SCH_PORT_SERVICE_NUMBER ) )
{
// RemoteCommand is in controle.cpp and is called when PCBNEW
// sends EESCHEMA a command
SetupServerFunction( RemoteCommand );
}
ActiveScreen = m_SchematicFrame->GetScreen();
m_SchematicFrame->Zoom_Automatique( TRUE );
ActiveScreen = frame->GetScreen();
frame->Zoom_Automatique( TRUE );
/* Load file specified in the command line. */
if( !FFileName.IsEmpty() )
{
ChangeFileNameExt( FFileName, g_SchExtBuffer );
wxSetWorkingDirectory( wxPathOnly( FFileName ) );
if( m_SchematicFrame->DrawPanel )
if( m_SchematicFrame->LoadOneEEProject( FFileName, FALSE ) <= 0 )
m_SchematicFrame->DrawPanel->Refresh( TRUE ); // File not found or error
if( frame->DrawPanel )
if( frame->LoadOneEEProject( FFileName, FALSE ) <= 0 )
frame->DrawPanel->Refresh( TRUE ); // File not found or error
}
else
{
Read_Config( wxEmptyString, TRUE ); // Read a default config file if no file to load
if( m_SchematicFrame->DrawPanel )
m_SchematicFrame->DrawPanel->Refresh( TRUE );
if( frame->DrawPanel )
frame->DrawPanel->Refresh( TRUE );
}
return TRUE;
}
......@@ -3,7 +3,6 @@
/*************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
......@@ -30,18 +29,17 @@ wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent )
wxString name;
WinEDA_ViewlibFrame* Viewer;
wxSemaphore semaphore( 0, 1 );
WinEDA_SchematicFrame* frame;
Viewer = parent->m_Parent->m_ViewlibFrame;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
Viewer = frame->m_ViewlibFrame;
/* Close the current Lib browser, if open, and open a new one, in "modal" mode */
if( Viewer )
Viewer->Destroy();
Viewer = parent->m_Parent->m_ViewlibFrame = new
WinEDA_ViewlibFrame(
parent->m_Parent->m_SchematicFrame,
parent->m_Parent,
NULL,
&semaphore );
Viewer = frame->m_ViewlibFrame =
new WinEDA_ViewlibFrame( frame, NULL, &semaphore );
Viewer->AdjustScrollBars();
// Show the library viewer frame until it is closed
......@@ -57,7 +55,7 @@ wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent )
/**************************************************************************/
SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component(wxDC* DC,
const wxString& libname,
wxArrayString& HistoryList,
bool UseLibBrowser )
......@@ -179,7 +177,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
DrawLibItem = new SCH_COMPONENT( GetScreen()->m_Curseur );
DrawLibItem->m_Multi = 1;/* Selection de l'unite 1 dans le boitier */
DrawLibItem->m_Multi = 1; /* Selection de l'unite 1 dans le boitier */
DrawLibItem->m_Convert = 1;
DrawLibItem->m_ChipName = Name;
DrawLibItem->m_TimeStamp = GetTimeStamp();
......@@ -203,7 +201,7 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
msg += wxT( "?" );
//update the reference -- just the prefix for now.
DrawLibItem->SetRef(GetSheet(), msg );
DrawLibItem->SetRef( GetSheet(), msg );
/* Init champ Reference */
DrawLibItem->GetField( REFERENCE )->m_Pos.x =
......@@ -213,9 +211,12 @@ SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
DrawLibItem->GetField( REFERENCE )->m_Orient = Entry->m_Prefix.m_Orient;
DrawLibItem->GetField( REFERENCE )->m_Size = Entry->m_Prefix.m_Size;
DrawLibItem->m_PrefixString = Entry->m_Prefix.m_Text;
DrawLibItem->GetField( REFERENCE )->m_Attributs = Entry->m_Prefix.m_Attributs;
DrawLibItem->GetField( REFERENCE )->m_HJustify = Entry->m_Prefix.m_HJustify;
DrawLibItem->GetField( REFERENCE )->m_VJustify = Entry->m_Prefix.m_VJustify;
DrawLibItem->GetField( REFERENCE )->m_Attributs =
Entry->m_Prefix.m_Attributs;
DrawLibItem->GetField( REFERENCE )->m_HJustify =
Entry->m_Prefix.m_HJustify;
DrawLibItem->GetField( REFERENCE )->m_VJustify =
Entry->m_Prefix.m_VJustify;
/* Init des autres champs si predefinis dans la librairie */
for( Field = Entry->Fields; Field != NULL; Field = Field->Next() )
......@@ -298,7 +299,7 @@ void WinEDA_SchematicFrame::CmpRotationMiroir(
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
{
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox());
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() );
}
}
......@@ -310,7 +311,9 @@ void WinEDA_SchematicFrame::CmpRotationMiroir(
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ),
GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn( DC );
}
......@@ -369,7 +372,8 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
if( DrawComponent == NULL )
return;
LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
LibEntry = FindLibPart(
DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( LibEntry == NULL )
return;
......@@ -399,7 +403,8 @@ void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds( GetScreen()->EEDrawList, DC );
GetScreen()->SetModify();
......@@ -417,7 +422,8 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
if( DrawComponent == NULL )
return;
LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
LibEntry = FindLibPart(
DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( LibEntry == NULL )
return;
......@@ -440,7 +446,8 @@ void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
if( DrawComponent->m_Flags & IS_MOVED )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
else
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
0 ), GR_DEFAULT_DRAWMODE );
TestDanglingEnds( GetScreen()->EEDrawList, DC );
GetScreen()->SetModify();
......@@ -487,7 +494,8 @@ void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component,
if( Component->m_Flags == 0 )
{
if( g_ItemToUndoCopy ){
if( g_ItemToUndoCopy )
{
SAFE_DELETE( g_ItemToUndoCopy );
}
g_ItemToUndoCopy = Component->GenCopy();
......@@ -504,6 +512,7 @@ void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component,
memcpy( OldTransMat, Component->m_Transform, sizeof(OldTransMat) );
#if 1
// switch from normal mode to xor mode for the duration of the move, first
// by erasing fully any "normal drawing mode" primitives with the PostDirtyRect(),
// then by drawing the first time in xor mode so that subsequent xor
......
......@@ -6,7 +6,6 @@
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -22,48 +21,46 @@
/* class WinEDA_LibeditFrame */
/*****************************/
BEGIN_EVENT_TABLE( WinEDA_LibeditFrame, wxFrame )
COMMON_EVENTS_DRAWFRAME EVT_CLOSE( WinEDA_LibeditFrame::OnCloseWindow )
EVT_SIZE( WinEDA_LibeditFrame::OnSize )
COMMON_EVENTS_DRAWFRAME
EVT_CLOSE( WinEDA_LibeditFrame::OnCloseWindow )
EVT_SIZE( WinEDA_LibeditFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA_LibeditFrame::Process_Zoom )
// Tools et boutons de Libedit:
/* Main horizontal toolbar */
EVT_TOOL_RANGE( ID_LIBEDIT_START_H_TOOL, ID_LIBEDIT_END_H_TOOL,
EVT_TOOL_RANGE( ID_LIBEDIT_START_H_TOOL, ID_LIBEDIT_END_H_TOOL,
WinEDA_LibeditFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_PART_NUMBER,
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_PART_NUMBER,
WinEDA_LibeditFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_ALIAS,
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_ALIAS,
WinEDA_LibeditFrame::Process_Special_Functions )
/* Right Vertical toolbar */
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL_RANGE( ID_LIBEDIT_START_V_TOOL, ID_LIBEDIT_END_V_TOOL,
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_LibeditFrame::Process_Special_Functions )
EVT_TOOL_RANGE( ID_LIBEDIT_START_V_TOOL, ID_LIBEDIT_END_V_TOOL,
WinEDA_LibeditFrame::Process_Special_Functions )
/* PopUp events and commands: */
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
WinEDA_LibeditFrame::Process_Special_Functions )
// Annulation de commande en cours
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_LibeditFrame::Process_Special_Functions )
// PopUp Menus pour Zooms trait�s dans drawpanel.cpp
END_EVENT_TABLE()
WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
WinEDA_App* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
WinEDA_DrawFrame( father, LIBEDITOR_FRAME, parent, title, pos, size, style )
WinEDA_DrawFrame( father, LIBEDITOR_FRAME, title, pos, size, style )
{
m_FrameName = wxT( "LibeditFrame" );
m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines
......@@ -89,7 +86,9 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
WinEDA_LibeditFrame::~WinEDA_LibeditFrame()
/**********************************************/
{
m_Parent->m_LibeditFrame = NULL;
WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->m_LibeditFrame = NULL;
}
......
......@@ -112,7 +112,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
// Create the list of last edited schematic files
m_FilesMenu->AppendSeparator();
int max_file = m_Parent->m_LastProjectMaxCount;
int max_file = wxGetApp().m_LastProjectMaxCount;
for( ii = 0; ii < max_file; ii++ )
{
if( GetLastProject( ii ).IsEmpty() )
......@@ -376,7 +376,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
// Font selection and setup
AddFontSelectionMenu( configmenu );
m_Parent->SetLanguageList( configmenu );
wxGetApp().SetLanguageList( configmenu );
configmenu->AppendSeparator();
item = new wxMenuItem( configmenu, ID_CONFIG_SAVE, _( "&Save preferences" ),
......@@ -417,7 +417,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
else // Update the list of last edited schematic files
{
wxMenuItem* item;
int max_file = m_Parent->m_LastProjectMaxCount;
int max_file = wxGetApp().m_LastProjectMaxCount;
for( ii = max_file - 1; ii >=0; ii-- )
{
if( m_FilesMenu->FindItem( ID_LOAD_FILE_1 + ii ) )
......
......@@ -53,35 +53,38 @@ wxString ReturnUserNetlistTypeName( bool first_item )
msg = CUSTOM_NETLIST_TITLE;
msg << index + 1;
if( g_EDA_Appl->m_EDA_Config )
name = g_EDA_Appl->m_EDA_Config->Read( msg );
if( wxGetApp().m_EDA_Config )
name = wxGetApp().m_EDA_Config->Read( msg );
return name;
}
BEGIN_EVENT_TABLE( WinEDA_NetlistFrame, wxDialog )
EVT_BUTTON( wxID_CANCEL, WinEDA_NetlistFrame::OnCancelClick )
EVT_BUTTON( ID_CREATE_NETLIST, WinEDA_NetlistFrame::GenNetlist )
EVT_BUTTON( ID_SETUP_PLUGIN, WinEDA_NetlistFrame::SetupPluginData )
EVT_BUTTON( ID_DELETE_PLUGIN, WinEDA_NetlistFrame::DeletePluginPanel )
EVT_BUTTON( ID_VALIDATE_PLUGIN, WinEDA_NetlistFrame::ValidatePluginPanel )
EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT, WinEDA_NetlistFrame::SelectNetlistType )
EVT_BUTTON( ID_RUN_SIMULATOR, WinEDA_NetlistFrame::RunSimulator )
EVT_BUTTON( wxID_CANCEL, WinEDA_NetlistFrame::OnCancelClick )
EVT_BUTTON( ID_CREATE_NETLIST, WinEDA_NetlistFrame::GenNetlist )
EVT_BUTTON( ID_SETUP_PLUGIN, WinEDA_NetlistFrame::SetupPluginData )
EVT_BUTTON( ID_DELETE_PLUGIN, WinEDA_NetlistFrame::DeletePluginPanel )
EVT_BUTTON( ID_VALIDATE_PLUGIN, WinEDA_NetlistFrame::ValidatePluginPanel )
EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT,
WinEDA_NetlistFrame::SelectNetlistType )
EVT_BUTTON( ID_RUN_SIMULATOR, WinEDA_NetlistFrame::RunSimulator )
END_EVENT_TABLE()
/*******************************/
/* Functions for these classes */
/*******************************/
/*****************************************************************************/
EDA_NoteBookPage::EDA_NoteBookPage( wxNotebook* parent, const wxString& title,
int id_NetType, int idCheckBox, int idCreateFile ) :
wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_SUNKEN )
EDA_NoteBookPage::EDA_NoteBookPage( wxNotebook* parent,
const wxString& title,
int id_NetType,
int idCheckBox,
int idCreateFile ) :
wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL |
wxBORDER_SUNKEN )
/*****************************************************************************/
/** Contructor to create a setup page for one netlist format.
......@@ -114,14 +117,18 @@ EDA_NoteBookPage::EDA_NoteBookPage( wxNotebook* parent, const wxString& title,
m_RightOptionsBoxSizer = new wxBoxSizer( wxVERTICAL );
UpperBoxSizer->Add( m_LeftBoxSizer, 0, wxGROW | wxALL, 5 );
UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
UpperBoxSizer->Add( m_RightOptionsBoxSizer,
0,
wxALIGN_CENTER_VERTICAL | wxALL,
5 );
if( idCheckBox )
{
wxStaticText* text = new wxStaticText( this, -1, _( "Options:" ) );
m_LeftBoxSizer->Add( text, 0, wxGROW | wxALL, 5 );
m_IsCurrentFormat = new wxCheckBox( this, idCheckBox, _( "Default format" ) );
m_IsCurrentFormat =
new wxCheckBox( this, idCheckBox, _( "Default format" ) );
m_LeftBoxSizer->Add( m_IsCurrentFormat, 0, wxGROW | wxALL, 5 );
if( g_NetFormat == m_IdNetType )
......@@ -195,20 +202,23 @@ WinEDA_NetlistFrame::WinEDA_NetlistFrame( WinEDA_SchematicFrame* parent ) :
// Add notebook pages:
// Add Panel FORMAT PCBNEW
m_PanelNetType[PANELPCBNEW] = new EDA_NoteBookPage( m_NoteBook, wxT(
"Pcbnew" ), NET_TYPE_PCBNEW,
m_PanelNetType[PANELPCBNEW] = new EDA_NoteBookPage( m_NoteBook,
wxT( "Pcbnew" ),
NET_TYPE_PCBNEW,
ID_CURRENT_FORMAT_IS_DEFAULT,
ID_CREATE_NETLIST );
// Add Panel FORMAT ORCADPCB2
m_PanelNetType[PANELORCADPCB2] = new EDA_NoteBookPage( m_NoteBook, wxT(
"OrcadPCB2" ), NET_TYPE_ORCADPCB2,
m_PanelNetType[PANELORCADPCB2] = new EDA_NoteBookPage( m_NoteBook,
wxT( "OrcadPCB2" ),
NET_TYPE_ORCADPCB2,
ID_CURRENT_FORMAT_IS_DEFAULT,
ID_CREATE_NETLIST );
// Add Panel FORMAT CADSTAR
m_PanelNetType[PANELCADSTAR] = new EDA_NoteBookPage( m_NoteBook, wxT(
"CadStar" ), NET_TYPE_CADSTAR,
m_PanelNetType[PANELCADSTAR] = new EDA_NoteBookPage( m_NoteBook,
wxT( "CadStar" ),
NET_TYPE_CADSTAR,
ID_CURRENT_FORMAT_IS_DEFAULT,
ID_CREATE_NETLIST );
......@@ -233,10 +243,13 @@ void WinEDA_NetlistFrame::InstallPageSpice()
wxButton* Button;
EDA_NoteBookPage* page;
page = m_PanelNetType[PANELSPICE] = new EDA_NoteBookPage( m_NoteBook, wxT(
"Spice" ), NET_TYPE_SPICE, 0, 0 );
page = m_PanelNetType[PANELSPICE] = new EDA_NoteBookPage( m_NoteBook,
wxT( "Spice" ),
NET_TYPE_SPICE,
0, 0 );
page->m_IsCurrentFormat = new wxCheckBox( page, ID_CURRENT_FORMAT_IS_DEFAULT,
page->m_IsCurrentFormat =
new wxCheckBox( page, ID_CURRENT_FORMAT_IS_DEFAULT,
_( "Default format" ) );
page->m_IsCurrentFormat->SetValue( g_NetFormat == NET_TYPE_SPICE );
page->m_LeftBoxSizer->Add( page->m_IsCurrentFormat, 0, wxGROW | wxALL, 5 );
......@@ -244,16 +257,17 @@ void WinEDA_NetlistFrame::InstallPageSpice()
wxString netlist_opt[2] = { _( "Use Net Names" ), _( "Use Net Numbers" ) };
m_UseNetNamesInNetlist = new wxRadioBox( page, -1, _( "Netlist Options:" ),
wxDefaultPosition, wxDefaultSize,
2, netlist_opt, 1, wxRA_SPECIFY_COLS );
2, netlist_opt, 1,
wxRA_SPECIFY_COLS );
if( !g_OptNetListUseNames )
m_UseNetNamesInNetlist->SetSelection( 1 );
page->m_LeftBoxSizer->Add( m_UseNetNamesInNetlist, 0, wxGROW | wxALL, 5 );
page->m_CommandStringCtrl = new WinEDA_EnterText( page,
_(
"Simulator command:" ),
_( "Simulator command:" ),
g_SimulatorCommandLine,
page->m_LowBoxSizer, wxDefaultSize );
page->m_LowBoxSizer,
wxDefaultSize );
// Add buttons
Button = new wxButton( page, ID_CREATE_NETLIST, _( "Netlist" ) );
......@@ -296,19 +310,23 @@ void WinEDA_NetlistFrame::InstallCustomPages()
if( title.IsEmpty() )
CurrPage =
m_PanelNetType[PANELCUSTOMBASE + ii] =
new EDA_NoteBookPage( m_NoteBook, _( "Add Plugin" ),
new EDA_NoteBookPage( m_NoteBook,
_( "Add Plugin" ),
NET_TYPE_CUSTOM1 + ii,
ID_CURRENT_FORMAT_IS_DEFAULT, ID_SETUP_PLUGIN );
ID_CURRENT_FORMAT_IS_DEFAULT,
ID_SETUP_PLUGIN );
else /* Install a plugin panel */
CurrPage =
m_PanelNetType[PANELCUSTOMBASE + ii] =
new EDA_NoteBookPage( m_NoteBook, title,
new EDA_NoteBookPage( m_NoteBook,
title,
NET_TYPE_CUSTOM1 + ii,
ID_CURRENT_FORMAT_IS_DEFAULT, ID_CREATE_NETLIST );
ID_CURRENT_FORMAT_IS_DEFAULT,
ID_CREATE_NETLIST );
msg = CUSTOM_NETLIST_COMMAND;
msg << ii + 1;
wxString Command = m_Parent->m_Parent->m_EDA_Config->Read( msg );
wxString Command = wxGetApp().m_EDA_Config->Read( msg );
CurrPage->m_CommandStringCtrl =
new WinEDA_EnterText( CurrPage,
_( "Netlist command:" ), Command,
......@@ -334,7 +352,7 @@ void WinEDA_NetlistFrame::SetupPluginData( wxCommandEvent& event )
wxString FullFileName, Mask, Path;
Mask = wxT( "*" );
Path = g_EDA_Appl->m_BinDir;
Path = wxGetApp().m_BinDir;
FullFileName = EDA_FileSelector( _( "Plugin files:" ),
Path, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */
......@@ -358,16 +376,16 @@ void WinEDA_NetlistFrame::SetupPluginData( wxCommandEvent& event )
wxString title = CurrPage->m_TitleStringCtrl->GetValue();
if( title.IsEmpty() )
DisplayInfo( this,
_(
"Do not forget to choose a title for this netlist control page" ) );
_( "Do not forget to choose a title for this netlist control page" ) );
}
/*****************************************************************/
void WinEDA_NetlistFrame::SelectNetlistType( wxCommandEvent& event )
/*****************************************************************/
/* Called when the check box "default format" is clicked
*/
*/
{
int ii;
EDA_NoteBookPage* CurrPage;
......@@ -450,7 +468,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
Mask = wxT( "*" ) + FileExt + wxT( "*" );
ChangeFileNameExt( FullFileName, FileExt );
FullFileName = FullFileName.AfterLast('/');
FullFileName = FullFileName.AfterLast( '/' );
FullFileName = EDA_FileSelector( _( "Netlist files:" ),
wxEmptyString, /* Defaut path */
FullFileName, /* Defaut filename */
......@@ -474,7 +492,9 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
/* Cleanup the entire hierarchy */
EDA_ScreenList ScreenList;
for( SCH_SCREEN* screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
for( SCH_SCREEN* screen = ScreenList.GetFirst();
screen != NULL;
screen = ScreenList.GetNext() )
{
bool ModifyWires;
ModifyWires = screen->SchematicCleanUp( NULL );
......@@ -559,6 +579,7 @@ void WinEDA_NetlistFrame::WriteCurrentNetlistSetup( void )
*/
{
wxString msg, Command;
wxConfig* config = wxGetApp().m_EDA_Config;
NetlistUpdateOpt();
......@@ -577,7 +598,7 @@ void WinEDA_NetlistFrame::WriteCurrentNetlistSetup( void )
{
msg = CUSTOM_NETLIST_TITLE;
msg << ii + 1;
m_Parent->m_Parent->m_EDA_Config->Write( msg, title );
config->Write( msg, title );
}
}
......@@ -586,7 +607,7 @@ void WinEDA_NetlistFrame::WriteCurrentNetlistSetup( void )
Command = CurrPage->m_CommandStringCtrl->GetValue();
msg = CUSTOM_NETLIST_COMMAND;
msg << ii + 1;
m_Parent->m_Parent->m_EDA_Config->Write( msg, Command );
config->Write( msg, Command );
}
}
}
......@@ -600,7 +621,8 @@ void WinEDA_NetlistFrame::DeletePluginPanel( wxCommandEvent& event )
* Remove a panel relative to a netlist plugin
*/
{
EDA_NoteBookPage* CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
EDA_NoteBookPage* CurrPage =
(EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
CurrPage->m_CommandStringCtrl->SetValue( wxEmptyString );
CurrPage->m_TitleStringCtrl->SetValue( wxEmptyString );
......@@ -622,7 +644,8 @@ void WinEDA_NetlistFrame::ValidatePluginPanel( wxCommandEvent& event )
* Validate the panel info relative to a new netlist plugin
*/
{
EDA_NoteBookPage* CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
EDA_NoteBookPage* CurrPage =
(EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
if( CurrPage->m_CommandStringCtrl->GetValue() == wxEmptyString )
{
......
......@@ -30,7 +30,8 @@
/*******************************/
BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, wxFrame )
COMMON_EVENTS_DRAWFRAME EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV,
COMMON_EVENTS_DRAWFRAME
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV,
WinEDA_DrawFrame::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest )
......@@ -128,13 +129,14 @@ END_EVENT_TABLE()
/****************/
WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
WinEDA_App* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
WinEDA_DrawFrame( father, SCHEMATIC_FRAME, parent, title, pos, size, style )
WinEDA_DrawFrame( father, SCHEMATIC_FRAME, title, pos, size, style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "SchematicFrame" );
m_Draw_Axis = FALSE; // TRUE to show axis
m_Draw_Grid = g_ShowGrid; // TRUE to show a grid
......@@ -143,7 +145,8 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
m_CurrentField = NULL;
m_Multiflag = 0;
m_TextFieldSize = DEFAULT_SIZE_TEXT;
m_LibeditFrame = NULL; // Component editor frame.
m_ViewlibFrame = NULL; // Frame for browsing component libraries
CreateScreens();
......@@ -159,11 +162,13 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
/* Get config */
GetSettings();
g_DrawMinimunLineWidth =
m_Parent->m_EDA_Config->Read( MINI_DRAW_LINE_WIDTH_KEY, (long) 0 );
g_PlotPSMinimunLineWidth =
m_Parent->m_EDA_Config->Read( MINI_PLOTPS_LINE_WIDTH_KEY, (long) 4 );
if( config )
{
g_DrawMinimunLineWidth = config->Read( MINI_DRAW_LINE_WIDTH_KEY,
(long) 0 );
g_PlotPSMinimunLineWidth = config->Read( MINI_PLOTPS_LINE_WIDTH_KEY,
(long) 4 );
}
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
......@@ -183,7 +188,6 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
{
m_Parent->m_SchematicFrame = NULL;
SAFE_DELETE( g_RootSheet );
SAFE_DELETE( m_CurrentSheet ); //a DrawSheetPath, on the heap.
m_CurrentSheet = NULL;
......@@ -290,10 +294,11 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
/*****************************************************************/
{
DrawSheetPath* sheet;
wxConfig* config = wxGetApp().m_EDA_Config;
if( m_Parent->m_LibeditFrame ) // Can close component editor ?
if( m_LibeditFrame ) // Can close component editor ?
{
if( !m_Parent->m_LibeditFrame->Close() )
if( !m_LibeditFrame->Close() )
return;
}
......@@ -349,10 +354,12 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
SaveSettings();
m_Parent->m_EDA_Config->Write( MINI_DRAW_LINE_WIDTH_KEY,
(long) g_DrawMinimunLineWidth );
m_Parent->m_EDA_Config->Write( MINI_PLOTPS_LINE_WIDTH_KEY,
if( config )
{
config->Write( MINI_DRAW_LINE_WIDTH_KEY, (long) g_DrawMinimunLineWidth );
config->Write( MINI_PLOTPS_LINE_WIDTH_KEY,
(long) g_PlotPSMinimunLineWidth );
}
Destroy();
}
......@@ -576,16 +583,14 @@ void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event )
void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
/*************************************************************************/
{
if( m_Parent->m_ViewlibFrame )
if( m_ViewlibFrame )
{
m_Parent->m_ViewlibFrame->Show( TRUE );
m_ViewlibFrame->Show( TRUE );
}
else
{
m_Parent->m_ViewlibFrame =
new WinEDA_ViewlibFrame( m_Parent->m_SchematicFrame,
m_Parent );
m_Parent->m_ViewlibFrame->AdjustScrollBars();
m_ViewlibFrame = new WinEDA_ViewlibFrame( this );
m_ViewlibFrame->AdjustScrollBars();
}
}
......@@ -593,20 +598,18 @@ void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
/*************************************************************************/
{
if( m_Parent->m_LibeditFrame )
if( m_LibeditFrame )
{
m_Parent->m_LibeditFrame->Show( TRUE );
m_LibeditFrame->Show( TRUE );
}
else
{
m_Parent->m_LibeditFrame =
new WinEDA_LibeditFrame( m_Parent->m_SchematicFrame,
m_Parent,
m_LibeditFrame = new WinEDA_LibeditFrame( this,
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
ActiveScreen = g_ScreenLib;
m_Parent->m_LibeditFrame->AdjustScrollBars();
m_LibeditFrame->AdjustScrollBars();
}
}
......
......@@ -6,7 +6,6 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......@@ -21,7 +20,9 @@
/* Routines locales */
static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre );
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos );
/* Variables locales */
......@@ -60,8 +61,12 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event )
m_Parent->DrawPanel->PrepareGraphicContext( &dc );
DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, wxPoint(0, 0),
CurrentDrawItem, g_XorMode );
DrawLibraryDrawStruct( m_Parent->DrawPanel,
&dc,
CurrentLibEntry,
wxPoint( 0, 0 ),
CurrentDrawItem,
g_XorMode );
if( g_FlDrawSpecificUnit )
CurrentDrawItem->m_Unit = CurrentUnit;
......@@ -77,22 +82,27 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event )
{
case COMPONENT_ARC_DRAW_TYPE:
( (LibDrawArc*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
( (LibDrawArc*) CurrentDrawItem )->m_Width = m_GraphicShapeWidthCtrl->GetValue();
( (LibDrawArc*) CurrentDrawItem )->m_Width =
m_GraphicShapeWidthCtrl->GetValue();
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
( (LibDrawCircle*) CurrentDrawItem )->m_Width = m_GraphicShapeWidthCtrl->GetValue();
( (LibDrawCircle*) CurrentDrawItem )->m_Width =
m_GraphicShapeWidthCtrl->GetValue();
break;
case COMPONENT_RECT_DRAW_TYPE:
( (LibDrawSquare*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
( (LibDrawSquare*) CurrentDrawItem )->m_Width = m_GraphicShapeWidthCtrl->GetValue();
( (LibDrawSquare*) CurrentDrawItem )->m_Width =
m_GraphicShapeWidthCtrl->GetValue();
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
( (LibDrawPolyline*) CurrentDrawItem )->m_Width = m_GraphicShapeWidthCtrl->
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill =
FlSymbol_Fill;
( (LibDrawPolyline*) CurrentDrawItem )->m_Width =
m_GraphicShapeWidthCtrl->
GetValue();
break;
......@@ -104,8 +114,12 @@ bodygraphics_PropertiesAccept( wxCommandEvent& event )
m_Parent->GetScreen()->SetModify();
DrawLibraryDrawStruct( m_Parent->DrawPanel, &dc, CurrentLibEntry, wxPoint(0, 0),
CurrentDrawItem, g_XorMode );
DrawLibraryDrawStruct( m_Parent->DrawPanel,
&dc,
CurrentLibEntry,
wxPoint( 0, 0 ),
CurrentDrawItem,
g_XorMode );
}
Close();
......@@ -127,7 +141,8 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC,
if( DrawItem == NULL )
return;
WinEDA_bodygraphics_PropertiesFrame* frame = new WinEDA_bodygraphics_PropertiesFrame( this );
WinEDA_bodygraphics_PropertiesFrame* frame =
new WinEDA_bodygraphics_PropertiesFrame( this );
frame->ShowModal(); frame->Destroy();
}
......@@ -150,7 +165,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->m_Parent->RedrawActiveWindow( DC, TRUE );
}
else
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, g_XorMode );
SAFE_DELETE( CurrentDrawItem );
}
......@@ -161,7 +176,7 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->GetScreen()->m_Curseur = StartCursor;
RedrawWhileMovingCursor( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = curpos;
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( Panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, GR_DEFAULT_DRAWMODE );
CurrentDrawItem->m_Flags = 0;
......@@ -303,7 +318,8 @@ LibEDA_BaseStruct* WinEDA_LibeditFrame::CreateGraphicItem( wxDC* DC )
else
{
StartMoveDrawSymbol( DC );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry,
wxPoint( 0, 0 ),
Text, g_XorMode );
}
}
......@@ -376,7 +392,9 @@ void WinEDA_LibeditFrame::GraphicItemBeginDraw( wxDC* DC )
/**************************************************************************/
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase )
/**************************************************************************/
/* Redraw the graphoc shape while moving
......@@ -441,7 +459,8 @@ void MoveLibDrawItemAt( LibEDA_BaseStruct* DrawItem, wxPoint newpos )
case COMPONENT_POLYLINE_DRAW_TYPE:
{
int ii, imax = ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount * 2;
int ii, imax =
( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount * 2;
int* ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
int dx = mx - ptpoly[0];
int dy = -my - ptpoly[1];
......@@ -495,7 +514,8 @@ void WinEDA_LibeditFrame::StartMoveDrawSymbol( wxDC* DC )
case COMPONENT_POLYLINE_DRAW_TYPE:
InitPosition.x = *( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
InitPosition.y = *( ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList + 1 );
InitPosition.y =
*( ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList + 1 );
break;
case COMPONENT_LINE_DRAW_TYPE:
......@@ -536,11 +556,18 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( StateDrawArc == 1 )
{
int Color = ReturnLayerColor( LAYER_DEVICE );
GRLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY, ArcEndX, -ArcEndY, 0, Color );
GRLine( &panel->m_ClipBox,
DC,
ArcStartX,
-ArcStartY,
ArcEndX,
-ArcEndY,
0,
Color );
}
else
{
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, DrawMode );
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
{
......@@ -575,7 +602,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
case COMPONENT_CIRCLE_DRAW_TYPE:
dx = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.x - mx;
dy = ( (LibDrawCircle*) CurrentDrawItem )->m_Pos.y + my;
( (LibDrawCircle*) CurrentDrawItem )->m_Rayon = (int) sqrt( ((double)dx * dx) + ((double)dy * dy) );
( (LibDrawCircle*) CurrentDrawItem )->m_Rayon =
(int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
( (LibDrawCircle*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
break;
......@@ -587,7 +615,8 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
case COMPONENT_POLYLINE_DRAW_TYPE:
ptpoly = ( (LibDrawPolyline*) CurrentDrawItem )->m_PolyList;
ptpoly += 2 * ( ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount - 1 );
ptpoly += 2 *
( ( (LibDrawPolyline*) CurrentDrawItem )->m_CornersCount - 1 );
ptpoly[0] = mx;
ptpoly[1] = -my;
( (LibDrawPolyline*) CurrentDrawItem )->m_Fill = FlSymbol_Fill;
......@@ -608,11 +637,18 @@ static void SymbolDisplayDraw( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( StateDrawArc == 1 )
{
int Color = ReturnLayerColor( LAYER_DEVICE );
GRLine( &panel->m_ClipBox, DC, ArcStartX, -ArcStartY, ArcEndX, -ArcEndY, 0, Color );
GRLine( &panel->m_ClipBox,
DC,
ArcStartX,
-ArcStartY,
ArcEndX,
-ArcEndY,
0,
Color );
}
else
{
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( panel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, DrawMode );
if( CurrentDrawItem->Type() == COMPONENT_ARC_DRAW_TYPE )
{
......@@ -710,7 +746,7 @@ void WinEDA_LibeditFrame::EndDrawGraphicItem( wxDC* DC )
MoveLibDrawItemAt( CurrentDrawItem, pos );
}
DrawLibEntry( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0), CurrentUnit,
DrawLibEntry( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ), CurrentUnit,
CurrentConvert, GR_DEFAULT_DRAWMODE );
CurrentDrawItem->m_Flags = 0;
......@@ -745,7 +781,7 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
/* calcul de cX et cY pour que l'arc passe par ArcStartX,Y et ArcEndX,Y */
dx = ArcEndX - ArcStartX; dy = ArcEndY - ArcStartY;
cX -= ArcStartX; cY -= ArcStartY;
angle = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);
angle = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
RotatePoint( &dx, &dy, angle ); /* Le segment dx, dy est horizontal */
/* -> dx = longueur, dy = 0 */
RotatePoint( &cX, &cY, angle );
......@@ -759,14 +795,14 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
dx = ArcStartX - DrawItem->m_Pos.x;
dy = ArcStartY - DrawItem->m_Pos.y;
DrawItem->m_Rayon = (int) sqrt( ((double)dx * dx) + ((double)dy * dy) );
DrawItem->m_Rayon = (int) sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
DrawItem->t1 = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);
DrawItem->t1 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
dx = ArcEndX - DrawItem->m_Pos.x;
dy = ArcEndY - DrawItem->m_Pos.y;
DrawItem->t2 = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);
DrawItem->t2 = (int) ( atan2( (double) dy, (double) dx ) * 1800 / M_PI );
DrawItem->m_ArcStart.x = ArcStartX;
DrawItem->m_ArcStart.y = ArcStartY;
......@@ -787,7 +823,9 @@ static void ComputeArc( LibDrawArc* DrawItem, wxPoint ArcCentre )
wxString msg;
angle = DrawItem->t2 - DrawItem->t1;
msg.Printf( _( "Arc %.1f deg" ), (float) angle / 10 );
g_EDA_Appl->m_LibeditFrame->PrintMsg( msg );
WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->m_LibeditFrame->PrintMsg( msg );
while( (DrawItem->t2 - DrawItem->t1) >= 1800 )
{
......@@ -821,7 +859,7 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
int* ptpoly;
LibDrawPolyline* Poly = (LibDrawPolyline*) CurrentDrawItem;
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, g_XorMode );
while( Poly->m_CornersCount > 2 ) // First segment is kept, only its end point is changed
......@@ -840,6 +878,6 @@ void WinEDA_LibeditFrame::DeleteDrawPoly( wxDC* DC )
int allocsize = 2 * sizeof(int) * Poly->m_CornersCount;
Poly->m_PolyList = (int*) realloc( Poly->m_PolyList, allocsize );
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
DrawLibraryDrawStruct( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentDrawItem, g_XorMode );
}
......@@ -41,10 +41,10 @@ END_EVENT_TABLE()
/******************************************************************************/
WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_ViewlibFrame::WinEDA_ViewlibFrame( wxWindow* father,
LibraryStruct* Library,
wxSemaphore* semaphore ) :
WinEDA_DrawFrame( father, VIEWER_FRAME, parent, _( "Library browser" ),
WinEDA_DrawFrame( father, VIEWER_FRAME, _( "Library browser" ),
wxDefaultPosition, wxDefaultSize )
/******************************************************************************/
{
......@@ -105,7 +105,9 @@ WinEDA_ViewlibFrame::~WinEDA_ViewlibFrame()
delete GetScreen();
SetBaseScreen( 0 );
m_Parent->m_ViewlibFrame = NULL;
WinEDA_SchematicFrame* frame =
(WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
frame->m_ViewlibFrame = NULL;
}
......
......@@ -22,99 +22,104 @@
/****************************************/
BEGIN_EVENT_TABLE( WinEDA_GerberFrame, wxFrame )
COMMON_EVENTS_DRAWFRAME EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
EVT_SIZE( WinEDA_GerberFrame::OnSize )
COMMON_EVENTS_DRAWFRAME
EVT_CLOSE( WinEDA_GerberFrame::OnCloseWindow )
EVT_SIZE( WinEDA_GerberFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA_GerberFrame::Process_Zoom )
EVT_TOOL( ID_LOAD_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_APPEND_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 )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_LOAD_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_APPEND_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 )
EVT_TOOL( ID_GERBVIEW_LOAD_DCODE_FILE, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_TOOL( ID_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
WinEDA_DrawFrame::ProcessFontPreferences )
// Menu Files:
EVT_MENU( ID_MENU_LOAD_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_SAVE_BOARD_AS, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW, WinEDA_GerberFrame::ExportDataInPcbnewFormat )
EVT_MENU_RANGE( ID_LOAD_FILE_1, ID_LOAD_FILE_10,
EVT_MENU( ID_MENU_LOAD_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_INC_LAYER_AND_APPEND_FILE, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_NEW_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_SAVE_BOARD, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_MENU_SAVE_BOARD_AS, WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_GEN_PLOT, WinEDA_GerberFrame::ToPlotter )
EVT_MENU( ID_GERBVIEW_EXPORT_TO_PCBNEW,
WinEDA_GerberFrame::ExportDataInPcbnewFormat )
EVT_MENU_RANGE( ID_LOAD_FILE_1, ID_LOAD_FILE_10,
WinEDA_GerberFrame::Files_io )
EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_EXIT, WinEDA_GerberFrame::Process_Special_Functions )
// menu Config
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START, ID_CONFIG_AND_PREFERENCES_END,
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
ID_CONFIG_AND_PREFERENCES_END,
WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_COLORS_SETUP, WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_OPTIONS_SETUP, WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_PCB_LOOK_SETUP, WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_COLORS_SETUP, WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_OPTIONS_SETUP, WinEDA_GerberFrame::Process_Config )
EVT_MENU( ID_PCB_LOOK_SETUP, WinEDA_GerberFrame::Process_Config )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_DrawFrame::SetLanguage )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE,
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE,
WinEDA_GerberFrame::Process_Special_Functions )
// menu Miscellaneous
EVT_MENU( ID_PCB_GLOBAL_DELETE, WinEDA_GerberFrame::Process_Special_Functions )
EVT_MENU( ID_PCB_GLOBAL_DELETE,
WinEDA_GerberFrame::Process_Special_Functions )
// Menu Help
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_GEN_PRINT, WinEDA_GerberFrame::ToPrinter )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_DRC_CONTROL, WinEDA_GerberFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_PCB_SELECT_LAYER,
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
EVT_TOOL( wxID_CUT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_GEN_PRINT, WinEDA_GerberFrame::ToPrinter )
EVT_TOOL( ID_FIND_ITEMS, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_DRC_CONTROL, WinEDA_GerberFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_PCB_SELECT_LAYER,
WinEDA_GerberFrame::Process_Special_Functions )
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBER_SELECT_TOOL,
EVT_KICAD_CHOICEBOX( ID_TOOLBARH_GERBER_SELECT_TOOL,
WinEDA_GerberFrame::Process_Special_Functions )
// Vertical toolbar:
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_TRACK_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_PCB_ZONES_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_PCB_DELETE_ITEM_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_NO_SELECT_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_TRACK_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_PCB_ZONES_BUTT, WinEDA_GerberFrame::Process_Special_Functions )
EVT_TOOL( ID_PCB_DELETE_ITEM_BUTT,
WinEDA_GerberFrame::Process_Special_Functions )
// Annulation de commande en cours
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_PcbFrame::Process_Special_Functions )
// Pop up menu
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS,
WinEDA_GerberFrame::Process_Special_Functions )
// Option toolbar
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_GerberFrame::OnSelectOptionToolbar )
// PopUp Menu trait�s dans drawpanel.cpp
END_EVENT_TABLE()
......@@ -123,14 +128,14 @@ END_EVENT_TABLE()
/****************/
WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
WinEDA_App* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
WinEDA_BasePcbFrame( father, parent, GERBER_FRAME, title, pos, size, style )
WinEDA_BasePcbFrame( father, GERBER_FRAME, title, pos, size, style )
{
m_FrameName = wxT( "GerberFrame" );
//m_AboutTitle = g_GerbviewAboutTitle;
m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines
m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee
......@@ -160,7 +165,6 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
WinEDA_GerberFrame::~WinEDA_GerberFrame()
{
m_Parent->m_GerberFrame = NULL;
SetBaseScreen( ScreenPcb );
}
......@@ -237,9 +241,11 @@ void WinEDA_GerberFrame::SetToolbars()
}
if( m_SelLayerBox->GetSelection() != ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer )
if( m_SelLayerBox->GetSelection() !=
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer )
{
m_SelLayerBox->SetSelection( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
m_SelLayerBox->SetSelection(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
}
if( gerber )
......@@ -264,8 +270,10 @@ void WinEDA_GerberFrame::SetToolbars()
if( m_OptionsToolBar )
{
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool(
ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric ==
MILLIMETRE ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : FALSE );
......
......@@ -7,7 +7,6 @@
#include "fctsys.h"
#include <wx/image.h>
#include <wx/file.h>
#include "common.h"
......@@ -25,16 +24,16 @@ IMPLEMENT_APP( WinEDA_App )
bool WinEDA_App::OnInit()
{
g_EDA_Appl = this;
WinEDA_GerberFrame* frame = NULL;
InitEDA_Appl( wxT( "gerbview" ) );
ScreenPcb = new PCB_SCREEN();
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
ActiveScreen = ScreenPcb;
GetSettings();
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) )
......@@ -43,31 +42,33 @@ bool WinEDA_App::OnInit()
g_DrawBgColor = BLACK;
Read_Hotkey_Config( m_PcbFrame, false ); /* Must be called before creating the main frame
Read_Hotkey_Config( frame, false ); /* Must be called before creating the main frame
* in order to display the real hotkeys
* in menus or tool tips */
m_GerberFrame = new WinEDA_GerberFrame( NULL, this, wxT( "GerbView" ),
wxPoint( 0, 0 ), wxSize( 600, 400 ) );
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ) );
/* Gerbview mainframe title */
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
m_GerberFrame->SetTitle( Title );
m_GerberFrame->m_Pcb = new BOARD( NULL, m_GerberFrame );
SetTopWindow( m_GerberFrame ); // Set GerbView mainframe on top
frame->SetTitle( Title );
frame->m_Pcb = new BOARD( NULL, frame );
m_GerberFrame->Show( TRUE ); // Show GerbView mainframe
m_GerberFrame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame
SetTopWindow( frame ); // Set GerbView mainframe on top
frame->Show( TRUE ); // Show GerbView mainframe
frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame
if( argc > 1 )
{
wxString fileName = MakeFileName( wxEmptyString, argv[1], g_PhotoFilenameExt );
wxString fileName = MakeFileName( wxEmptyString,
argv[1],
g_PhotoFilenameExt );
if( !fileName.IsEmpty() )
{
wxClientDC dc( m_GerberFrame->DrawPanel );
m_GerberFrame->DrawPanel->PrepareGraphicContext( &dc );
wxClientDC dc( frame->DrawPanel );
frame->DrawPanel->PrepareGraphicContext( &dc );
wxString path = wxPathOnly( fileName );
......@@ -77,14 +78,17 @@ bool WinEDA_App::OnInit()
Read_Config();
// Load all files specified on the command line.
for( int i=1; i<argc; ++i )
for( int i = 1; i<argc; ++i )
{
fileName = MakeFileName( wxEmptyString, argv[i], g_PhotoFilenameExt );
fileName = MakeFileName( wxEmptyString,
argv[i],
g_PhotoFilenameExt );
if( wxFileExists( fileName ) )
{
((PCB_SCREEN*)m_GerberFrame->GetScreen())->m_Active_Layer = i-1;
m_GerberFrame->LoadOneGerberFile( fileName, &dc, FALSE );
( (PCB_SCREEN*) frame->GetScreen() )->
m_Active_Layer = i - 1;
frame->LoadOneGerberFile( fileName, &dc, FALSE );
}
}
}
......
......@@ -10,7 +10,6 @@
#include "gerbview.h"
#include "pcbplot.h"
#include "id.h"
#include "hotkeys_basic.h"
#include "hotkeys.h"
#include "gerbview_config.h"
......@@ -76,7 +75,7 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
AddDelimiterString(FullFileName);
AddDelimiterString( FullFileName );
wxString editorname = GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, FullFileName );
......@@ -93,7 +92,8 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_GerberFrame::Process_Config internal error" ) );
DisplayError( this,
wxT( "WinEDA_GerberFrame::Process_Config internal error" ) );
}
}
......@@ -111,7 +111,8 @@ bool Read_Config()
*/
{
g_Prj_Config_Filename_ext = wxT( ".cnf" );
g_EDA_Appl->ReadProjectConfig( wxT( "gerbview" ), GROUP, ParamCfgList, FALSE );
wxGetApp().ReadProjectConfig( wxT( "gerbview" ), GROUP, ParamCfgList,
FALSE );
/* Inits autres variables */
if( ScreenPcb )
......@@ -136,9 +137,9 @@ void WinEDA_GerberFrame::Update_config()
*/
{
wxString FullFileName;
wxString mask( wxT( "*" ) ),
wxString mask( wxT( "*" ) );
g_Prj_Config_Filename_ext = wxT( ".cnf"; )
g_Prj_Config_Filename_ext = wxT( ".cnf" );
mask += g_Prj_Config_Filename_ext;
FullFileName = wxT( "gerbview" );
......@@ -157,7 +158,7 @@ void WinEDA_GerberFrame::Update_config()
return;
/* ecriture de la configuration */
g_EDA_Appl->WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
wxGetApp().WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
}
......@@ -169,9 +170,12 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
* Read the hotkey files config for pcbnew and module_edit
*/
{
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
wxString FullFileName = ReturnHotkeyConfigFilePath(
g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
return frame->ReadHotkeyConfigFile( FullFileName, s_Gerbview_Hokeys_Descr, verbose );
return frame->ReadHotkeyConfigFile( FullFileName,
s_Gerbview_Hokeys_Descr,
verbose );
}
......@@ -51,9 +51,9 @@ private:
};
/* Construction de la table des evenements pour WinEDA_ConfigFrame */
BEGIN_EVENT_TABLE( WinEDA_ConfigFrame, wxDialog )
EVT_BUTTON( ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg )
EVT_BUTTON( wxID_OK, WinEDA_ConfigFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_ConfigFrame::OnCancelClick )
EVT_BUTTON( ID_SAVE_CFG, WinEDA_ConfigFrame::SaveCfg )
EVT_BUTTON( wxID_OK, WinEDA_ConfigFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_ConfigFrame::OnCancelClick )
END_EVENT_TABLE()
......@@ -87,7 +87,7 @@ WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent,
SetFont( *g_DialogFont );
/* Shows the config filename currently used : */
title = _( "from " ) + g_EDA_Appl->m_CurrentOptionFile;
title = _( "from " ) + wxGetApp().m_CurrentOptionFile;
SetTitle( title );
LibModified = FALSE;
......@@ -117,15 +117,18 @@ WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent,
size.x = LEN_EXT;
size.y = -1;
TextDrillExt = new WinEDA_EnterText( this,
_( "Drill File Ext:" ), g_DrillFilenameExt,
_( "Drill File Ext:" ),
g_DrillFilenameExt,
LeftBoxSizer, size );
TextPhotoExt = new WinEDA_EnterText( this,
_( "Gerber File Ext:" ), g_PhotoFilenameExt,
_( "Gerber File Ext:" ),
g_PhotoFilenameExt,
LeftBoxSizer, size );
TextPenExt = new WinEDA_EnterText( this,
_( "D code File Ext:" ), g_PenFilenameExt,
_( "D code File Ext:" ),
g_PenFilenameExt,
LeftBoxSizer, size );
GetSizer()->Fit( this );
......
......@@ -10,8 +10,6 @@
#include "protos.h"
#define BITMAP wxBitmap
#include "bitmaps.h"
#include "id.h"
......@@ -116,7 +114,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
// Font selection and setup
AddFontSelectionMenu( configmenu );
m_Parent->SetLanguageList( configmenu );
wxGetApp().SetLanguageList( configmenu );
configmenu->AppendSeparator();
ADD_MENUITEM_WITH_HELP( configmenu, ID_CONFIG_SAVE, _( "&Save Setup" ),
......@@ -166,7 +164,7 @@ void WinEDA_GerberFrame::ReCreateMenuBar( void )
else // Only an update of the files list
{
wxMenuItem* item;
int max_file = m_Parent->m_LastProjectMaxCount;
int max_file = wxGetApp().m_LastProjectMaxCount;
for( ii = max_file - 1; ii >=0; ii-- )
{
if( m_FilesMenu->FindItem( ID_LOAD_FILE_1 + ii ) )
......@@ -210,24 +208,24 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
SetToolBar( m_HToolBar );
// Set up toolbar
m_HToolBar->AddTool( ID_NEW_BOARD, BITMAP( new_xpm ),
m_HToolBar->AddTool( ID_NEW_BOARD, wxBitmap( new_xpm ),
wxNullBitmap, FALSE,
-1, -1, (wxObject*) NULL,
_( "New World" ) );
m_HToolBar->AddTool( ID_LOAD_FILE, BITMAP( open_xpm ),
m_HToolBar->AddTool( ID_LOAD_FILE, wxBitmap( open_xpm ),
wxNullBitmap, FALSE,
-1, -1, (wxObject*) NULL,
_( "Open existing Layer" ) );
#if 0
m_HToolBar->AddTool( ID_SAVE_PROJECT, BITMAP( save_button ),
m_HToolBar->AddTool( ID_SAVE_PROJECT, wxBitmap( save_button ),
wxNullBitmap, FALSE,
-1, -1, (wxObject*) NULL,
_( "Save World" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_SHEET_SET, BITMAP( sheetset_xpm ),
m_HToolBar->AddTool( ID_SHEET_SET, wxBitmap( sheetset_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
......@@ -238,32 +236,32 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
m_HToolBar->AddSeparator();
#if 0
m_HToolBar->AddTool( wxID_CUT, BITMAP( cut_button ),
m_HToolBar->AddTool( wxID_CUT, wxBitmap( cut_button ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
_( "Cut selected item" ) );
m_HToolBar->AddTool( wxID_COPY, BITMAP( copy_button ),
m_HToolBar->AddTool( wxID_COPY, wxBitmap( copy_button ),
wxNullBitmap, FALSE,
-1, -1, (wxObject*) NULL,
_( "Copy selected item" ) );
m_HToolBar->AddTool( wxID_PASTE, BITMAP( paste_xpm ),
m_HToolBar->AddTool( wxID_PASTE, wxBitmap( paste_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
_( "Paste" ) );
#endif
m_HToolBar->AddTool( ID_UNDO_BUTT, BITMAP( undelete_xpm ),
m_HToolBar->AddTool( ID_UNDO_BUTT, wxBitmap( undelete_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
_( "Undelete" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_GEN_PRINT, BITMAP( print_button ),
m_HToolBar->AddTool( ID_GEN_PRINT, wxBitmap( print_button ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
......@@ -271,34 +269,34 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
m_HToolBar->AddSeparator();
msg = AddHotkeyName( _( "Zoom in" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_IN );
m_HToolBar->AddTool( ID_ZOOM_IN_BUTT, BITMAP( zoom_in_xpm ),
m_HToolBar->AddTool( ID_ZOOM_IN_BUTT, wxBitmap( zoom_in_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
msg );
msg = AddHotkeyName( _( "Zoom out" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_OUT );
m_HToolBar->AddTool( ID_ZOOM_OUT_BUTT, BITMAP( zoom_out_xpm ),
m_HToolBar->AddTool( ID_ZOOM_OUT_BUTT, wxBitmap( zoom_out_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
msg );
msg = AddHotkeyName( _( "Redraw view" ), s_Gerbview_Hokeys_Descr, HK_ZOOM_REDRAW );
m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, BITMAP( zoom_redraw_xpm ),
m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxBitmap( zoom_redraw_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
msg );
m_HToolBar->AddTool( ID_ZOOM_PAGE_BUTT, BITMAP( zoom_auto_xpm ),
m_HToolBar->AddTool( ID_ZOOM_PAGE_BUTT, wxBitmap( zoom_auto_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
_( "Zoom auto" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_FIND_ITEMS, BITMAP( find_xpm ),
m_HToolBar->AddTool( ID_FIND_ITEMS, wxBitmap( find_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
......@@ -354,7 +352,7 @@ create or update the right vertical toolbar
// Set up toolbar
m_VToolBar->AddTool( ID_NO_SELECT_BUTT,
BITMAP( cursor_xpm ),
wxBitmap( cursor_xpm ),
wxNullBitmap, TRUE,
-1, -1, (wxObject*) NULL );
m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );
......@@ -362,26 +360,26 @@ create or update the right vertical toolbar
#if 0
m_VToolBar->AddSeparator();
m_VToolBar->AddTool( ID_COMPONENT_BUTT,
BITMAP( component_button ),
wxBitmap( component_button ),
wxNullBitmap, TRUE,
-1, -1, (wxObject*) NULL,
_( "Add Flashes" ) );
m_VToolBar->AddTool( ID_BUS_BUTT,
BITMAP( bus_button ),
wxBitmap( bus_button ),
wxNullBitmap, TRUE,
-1, -1, (wxObject*) NULL,
_( "Add Lines" ) );
m_VToolBar->AddTool( ID_JUNCTION_BUTT,
BITMAP( junction_xpm ),
wxBitmap( junction_xpm ),
wxNullBitmap, TRUE,
-1, -1, (wxObject*) NULL,
_( "Add layer alignment target" ) );
m_VToolBar->AddSeparator();
m_VToolBar->AddTool( ID_TEXT_COMMENT_BUTT,
BITMAP( tool_text_xpm ),
wxBitmap( tool_text_xpm ),
wxNullBitmap, TRUE,
-1, -1, (wxObject*) NULL,
_( "Add Text" ) );
......@@ -389,7 +387,7 @@ create or update the right vertical toolbar
#endif
m_VToolBar->AddSeparator();
m_VToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT,
BITMAP( delete_body_xpm ),
wxBitmap( delete_body_xpm ),
wxNullBitmap, TRUE,
-1, -1, (wxObject*) NULL,
_( "Delete items" ) );
......@@ -412,27 +410,27 @@ create or update the left vertical toolbar (option toolbar
// creation du tool bar options
m_OptionsToolBar = new WinEDA_Toolbar( TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, BITMAP( grid_xpm ),
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxBitmap( grid_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
_( "Display Grid OFF" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, BITMAP( polar_coord_xpm ),
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxBitmap( polar_coord_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
_( "Display Polar Coord ON" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
BITMAP( unit_inch_xpm ),
wxBitmap( unit_inch_xpm ),
_( "Units in inches" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
BITMAP( unit_mm_xpm ),
wxBitmap( unit_mm_xpm ),
_( "Units in millimeters" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, BITMAP( cursor_shape_xpm ),
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxBitmap( cursor_shape_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
......@@ -440,28 +438,28 @@ create or update the left vertical toolbar (option toolbar
m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
BITMAP( pad_sketch_xpm ),
wxBitmap( pad_sketch_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
_( "Show Spots in Sketch Mode" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
BITMAP( showtrack_xpm ),
wxBitmap( showtrack_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
_( "Show Lines in Sketch Mode" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
BITMAP( opt_show_polygon_xpm ),
wxBitmap( opt_show_polygon_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
_( "Show Polygons in Sketch Mode" ) );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_DCODES,
BITMAP( show_dcodenumber_xpm ),
wxBitmap( show_dcodenumber_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
......
......@@ -24,14 +24,6 @@ class WinEDA_App : public wxApp
public:
wxString m_Project;
wxSingleInstanceChecker* m_Checker;
WinEDA_MainFrame* m_MainFrame;
WinEDA_PcbFrame* m_PcbFrame;
WinEDA_ModuleEditFrame* m_ModuleEditFrame;
WinEDA_GerberFrame* m_GerberFrame;
WinEDA_SchematicFrame* m_SchematicFrame; // Edition des Schemas
WinEDA_LibeditFrame* m_LibeditFrame; // Edition des composants
WinEDA_ViewlibFrame* m_ViewlibFrame; // Visualisation des composants
WinEDA_CvpcbFrame* m_CvpcbFrame;
wxPoint m_HelpPos;
wxSize m_HelpSize;
......@@ -46,9 +38,10 @@ public:
* (utilis si KICAD non dfini)*/
wxArrayString m_LastProject; /* liste des derniers projets chargs */
unsigned int m_LastProjectMaxCount; /* Max histhory file length */
wxString m_KicadEnv; /* Chemin de kicad dfini dans la variable
* d'environnement KICAD,
* typiquement /usr/local/kicad ou c:\kicad */
wxString m_KicadEnv; /* Chemin de kicad dfini dans la
* variable d'environnement KICAD,
* typiquement /usr/local/kicad ou
* c:\kicad */
bool m_Env_Defined; // TRUE si variable d'environnement KICAD definie
wxLocale* m_Locale; // Gestion de la localisation
......
......@@ -276,9 +276,6 @@ COMMON_GLOBL wxString g_ProductName
#endif
;
COMMON_GLOBL WinEDA_App* g_EDA_Appl; /* this is the main application */
/* Gestion des librairies */
COMMON_GLOBL wxString g_RealLibDirBuffer; // Chemin reel des librairies de module
// = UserLibDirBuffer si non vide
......
......@@ -52,6 +52,8 @@ public:
DrawSheetPath* m_CurrentSheet; ///< which sheet we are presently working on.
int m_Multiflag;
wxPoint m_OldPos;
WinEDA_LibeditFrame* m_LibeditFrame;
WinEDA_ViewlibFrame* m_ViewlibFrame;
private:
......@@ -62,7 +64,7 @@ private:
public:
WinEDA_SchematicFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_SchematicFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......@@ -362,7 +364,7 @@ public:
WinEDAChoiceBox* m_SelAliasBox;
public:
WinEDA_LibeditFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_LibeditFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......@@ -473,7 +475,7 @@ public:
wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog
public:
WinEDA_ViewlibFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_ViewlibFrame( wxWindow* father,
LibraryStruct* Library = NULL,
wxSemaphore* semaphore = NULL );
......
......@@ -61,13 +61,14 @@ public:
int m_DisplayModText; // How show module texts
bool m_DisplayPcbTrackFill; /* FALSE : tracks are show in sketch mode, TRUE = filled */
WinEDA3D_DrawFrame* m_Draw3DFrame;
WinEDA_ModuleEditFrame* m_ModuleEditFrame;
protected:
GENERAL_COLLECTOR* m_Collector;
public:
WinEDA_BasePcbFrame( wxWindow* father, WinEDA_App* parent, int idtype,
WinEDA_BasePcbFrame( wxWindow* father, int idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......@@ -327,7 +328,7 @@ private:
void createPopUpBlockMenu( wxMenu* menu );
public:
WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, const wxString& title,
WinEDA_PcbFrame( wxWindow* father, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......@@ -743,7 +744,7 @@ private:
wxMenu* m_FilesMenu;
public:
WinEDA_GerberFrame( wxWindow* father, WinEDA_App* parent, const wxString& title,
WinEDA_GerberFrame( wxWindow* father, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......@@ -869,7 +870,7 @@ public:
wxString m_CurrentLib;
public:
WinEDA_ModuleEditFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_ModuleEditFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......
......@@ -123,7 +123,6 @@ class WinEDA_BasicFrame : public wxFrame
{
public:
int m_Ident; // Id Type (pcb, schematic, library..)
WinEDA_App* m_Parent;
wxPoint m_FramePos;
wxSize m_FrameSize;
int m_MsgFrameHeight;
......@@ -138,7 +137,7 @@ public:
public:
// Constructor and destructor
WinEDA_BasicFrame( wxWindow* father, int idtype, WinEDA_App* parent,
WinEDA_BasicFrame( wxWindow* father, int idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE);
......@@ -216,7 +215,7 @@ protected:
public:
// Constructor and destructor
WinEDA_DrawFrame( wxWindow* father, int idtype, WinEDA_App* parent,
WinEDA_DrawFrame( wxWindow* father, int idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
......
/*****************************************************************************/
/**
* @file buildmnu.cpp
* @brief TODO
......@@ -8,105 +9,99 @@
#include "wx/spinctrl.h"
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "kicad.h"
#include "macros.h"
#define BITMAP wxBitmap
#include "bitmaps.h" // Common bitmaps
#include "id.h"
/*****************************************************************************/
BEGIN_EVENT_TABLE(WinEDA_MainFrame, WinEDA_BasicFrame)
BEGIN_EVENT_TABLE( WinEDA_MainFrame, WinEDA_BasicFrame )
/*****************************************************************************/
/* Window events */
EVT_SIZE(WinEDA_MainFrame::OnSize)
EVT_CLOSE(WinEDA_MainFrame::OnCloseWindow)
/* Sash drag events */
EVT_SASH_DRAGGED(ID_LEFT_FRAME,
WinEDA_MainFrame::OnSashDrag)
EVT_SASH_DRAGGED(ID_BOTTOM_FRAME,
WinEDA_MainFrame::OnSashDrag)
EVT_SASH_DRAGGED(ID_MAIN_COMMAND,
WinEDA_MainFrame::OnSashDrag)
/* Toolbar events */
EVT_TOOL(ID_NEW_PROJECT,
WinEDA_MainFrame::Process_Files)
EVT_TOOL(ID_LOAD_PROJECT,
WinEDA_MainFrame::Process_Files)
EVT_TOOL(ID_SAVE_PROJECT,
WinEDA_MainFrame::Process_Files)
EVT_TOOL(ID_SAVE_AND_ZIP_FILES,
WinEDA_MainFrame::Process_Files)
/* Menu events */
EVT_MENU(ID_SAVE_PROJECT,
WinEDA_MainFrame::Process_Files)
EVT_MENU(ID_EXIT,
WinEDA_MainFrame::Process_Special_Functions)
EVT_MENU(ID_TO_EDITOR,
WinEDA_MainFrame::Process_Fct)
EVT_MENU(ID_BROWSE_AN_SELECT_FILE,
WinEDA_MainFrame::Process_Fct)
EVT_MENU(ID_SELECT_PREFERED_EDITOR,
WinEDA_MainFrame::Process_Preferences)
EVT_MENU(ID_SELECT_DEFAULT_PDF_BROWSER,
WinEDA_MainFrame::Process_Preferences)
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER,
WinEDA_MainFrame::Process_Preferences)
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME,
WinEDA_MainFrame::Process_Preferences)
EVT_MENU(ID_SAVE_AND_ZIP_FILES,
WinEDA_MainFrame::Process_Files)
EVT_MENU(ID_READ_ZIP_ARCHIVE,
WinEDA_MainFrame::Process_Files)
EVT_MENU(ID_PROJECT_TREE_REFRESH,
WinEDA_MainFrame::OnRefresh)
EVT_MENU(ID_PREFERENCES_FONT_INFOSCREEN,
WinEDA_MainFrame::Process_Preferences)
EVT_MENU(ID_GENERAL_HELP,
WinEDA_MainFrame::GetKicadHelp)
EVT_MENU(ID_KICAD_ABOUT,
WinEDA_MainFrame::GetKicadAbout)
/* Range menu events */
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE,
/* Window events */
EVT_SIZE( WinEDA_MainFrame::OnSize )
EVT_CLOSE( WinEDA_MainFrame::OnCloseWindow )
/* Sash drag events */
EVT_SASH_DRAGGED( ID_LEFT_FRAME,
WinEDA_MainFrame::OnSashDrag )
EVT_SASH_DRAGGED( ID_BOTTOM_FRAME,
WinEDA_MainFrame::OnSashDrag )
EVT_SASH_DRAGGED( ID_MAIN_COMMAND,
WinEDA_MainFrame::OnSashDrag )
/* Toolbar events */
EVT_TOOL( ID_NEW_PROJECT,
WinEDA_MainFrame::Process_Files )
EVT_TOOL( ID_LOAD_PROJECT,
WinEDA_MainFrame::Process_Files )
EVT_TOOL( ID_SAVE_PROJECT,
WinEDA_MainFrame::Process_Files )
EVT_TOOL( ID_SAVE_AND_ZIP_FILES,
WinEDA_MainFrame::Process_Files )
/* Menu events */
EVT_MENU( ID_SAVE_PROJECT,
WinEDA_MainFrame::Process_Files )
EVT_MENU( ID_EXIT,
WinEDA_MainFrame::Process_Special_Functions )
EVT_MENU( ID_TO_EDITOR,
WinEDA_MainFrame::Process_Fct )
EVT_MENU( ID_BROWSE_AN_SELECT_FILE,
WinEDA_MainFrame::Process_Fct )
EVT_MENU( ID_SELECT_PREFERED_EDITOR,
WinEDA_MainFrame::Process_Preferences )
EVT_MENU( ID_SELECT_DEFAULT_PDF_BROWSER,
WinEDA_MainFrame::Process_Preferences )
EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER,
WinEDA_MainFrame::Process_Preferences )
EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER_NAME,
WinEDA_MainFrame::Process_Preferences )
EVT_MENU( ID_SAVE_AND_ZIP_FILES,
WinEDA_MainFrame::Process_Files )
EVT_MENU( ID_READ_ZIP_ARCHIVE,
WinEDA_MainFrame::Process_Files )
EVT_MENU( ID_PROJECT_TREE_REFRESH,
WinEDA_MainFrame::OnRefresh )
EVT_MENU( ID_PREFERENCES_FONT_INFOSCREEN,
WinEDA_MainFrame::Process_Preferences )
EVT_MENU( ID_GENERAL_HELP,
WinEDA_MainFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT,
WinEDA_MainFrame::GetKicadAbout )
/* Range menu events */
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE,
ID_LANGUAGE_CHOICE_END,
WinEDA_MainFrame::SetLanguage)
WinEDA_MainFrame::SetLanguage )
EVT_MENU_RANGE(ID_LOAD_PROJECT,
EVT_MENU_RANGE( ID_LOAD_PROJECT,
ID_LOAD_FILE_10,
WinEDA_MainFrame::Process_Files)
WinEDA_MainFrame::Process_Files )
/* Button events */
EVT_BUTTON(ID_TO_PCB,
WinEDA_MainFrame::Process_Fct)
EVT_BUTTON(ID_TO_CVPCB,
WinEDA_MainFrame::Process_Fct)
EVT_BUTTON(ID_TO_EESCHEMA,
WinEDA_MainFrame::Process_Fct)
EVT_BUTTON(ID_TO_GERBVIEW,
WinEDA_MainFrame::Process_Fct)
/* Button events */
EVT_BUTTON( ID_TO_PCB,
WinEDA_MainFrame::Process_Fct )
EVT_BUTTON( ID_TO_CVPCB,
WinEDA_MainFrame::Process_Fct )
EVT_BUTTON( ID_TO_EESCHEMA,
WinEDA_MainFrame::Process_Fct )
EVT_BUTTON( ID_TO_GERBVIEW,
WinEDA_MainFrame::Process_Fct )
#ifdef KICAD_PYTHON
EVT_BUTTON(ID_RUN_PYTHON, WinEDA_MainFrame::Process_Fct)
EVT_BUTTON( ID_RUN_PYTHON, WinEDA_MainFrame::Process_Fct )
#endif
/*****************************************************************************/
END_EVENT_TABLE()
/*****************************************************************************/
/**
* @brief TODO
*/
......@@ -115,7 +110,7 @@ void WinEDA_MainFrame::ReCreateMenuBar()
/*****************************************************************************/
{
int ii, jj;
wxMenuBar *menuBar = GetMenuBar() ;
wxMenuBar* menuBar = GetMenuBar();
// Check if menubar is empty
if( menuBar == NULL )
......@@ -125,30 +120,30 @@ void WinEDA_MainFrame::ReCreateMenuBar()
// Open project
wxMenuItem *item = new wxMenuItem(m_FilesMenu,
wxMenuItem* item = new wxMenuItem( m_FilesMenu,
ID_LOAD_PROJECT,
_("&Open"),
_("Open an existing project") );
item->SetBitmap(open_project_xpm);
m_FilesMenu->Append(item);
_( "&Open" ),
_( "Open an existing project" ) );
item->SetBitmap( open_project_xpm );
m_FilesMenu->Append( item );
// New project
item = new wxMenuItem(m_FilesMenu,
item = new wxMenuItem( m_FilesMenu,
ID_NEW_PROJECT,
_("&New"),
_("Start a new project") );
item->SetBitmap(new_project_xpm);
m_FilesMenu->Append(item);
_( "&New" ),
_( "Start a new project" ) );
item->SetBitmap( new_project_xpm );
m_FilesMenu->Append( item );
// Save project
item = new wxMenuItem(m_FilesMenu,
item = new wxMenuItem( m_FilesMenu,
ID_SAVE_PROJECT,
_("&Save"),
_("Save current project") );
item->SetBitmap(save_project_xpm);
m_FilesMenu->Append(item);
_( "&Save" ),
_( "Save current project" ) );
item->SetBitmap( save_project_xpm );
m_FilesMenu->Append( item );
// Separator
......@@ -156,21 +151,21 @@ void WinEDA_MainFrame::ReCreateMenuBar()
// Archive project
item = new wxMenuItem(m_FilesMenu,
item = new wxMenuItem( m_FilesMenu,
ID_SAVE_AND_ZIP_FILES,
_("&Archive"),
_("Archive project files in zip archive") );
item->SetBitmap(zip_xpm);
m_FilesMenu->Append(item);
_( "&Archive" ),
_( "Archive project files in zip archive" ) );
item->SetBitmap( zip_xpm );
m_FilesMenu->Append( item );
// Unarchive project
item = new wxMenuItem(m_FilesMenu,
item = new wxMenuItem( m_FilesMenu,
ID_READ_ZIP_ARCHIVE,
_("&Unarchive"),
_("Unarchive project files from zip file") );
item->SetBitmap(unzip_xpm);
m_FilesMenu->Append(item);
_( "&Unarchive" ),
_( "Unarchive project files from zip file" ) );
item->SetBitmap( unzip_xpm );
m_FilesMenu->Append( item );
// Separator
......@@ -178,181 +173,177 @@ void WinEDA_MainFrame::ReCreateMenuBar()
// Exit
item = new wxMenuItem(m_FilesMenu,
item = new wxMenuItem( m_FilesMenu,
ID_EXIT,
_("E&xit"),
_("Quit kicad") );
item->SetBitmap(exit_xpm);
m_FilesMenu->Append(item);
_( "E&xit" ),
_( "Quit kicad" ) );
item->SetBitmap( exit_xpm );
m_FilesMenu->Append( item );
// Create last 10 project entries
m_FilesMenu->AppendSeparator();
for ( ii = 0; ii < 10; ii++ )
for( ii = 0; ii < 10; ii++ )
{
m_MenuBar = menuBar = new wxMenuBar();
if ( GetLastProject(ii).IsEmpty() )
if( GetLastProject( ii ).IsEmpty() )
break;
m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) );
m_FilesMenu->Append( ID_LOAD_FILE_1 + ii, GetLastProject( ii ) );
}
/*************************************************************************/
wxMenu *browseMenu = new wxMenu();
wxMenu* browseMenu = new wxMenu();
/*************************************************************************/
// Editor
item = new wxMenuItem(browseMenu, // Entry in menu
item = new wxMenuItem( browseMenu, // Entry in menu
ID_TO_EDITOR, // Entry ID
_("Text E&ditor"), // Entry text
_("Open prefered text editor") ); // Status bar text
item->SetBitmap(editor_xpm); // Entry XPM Bitmap
browseMenu->Append(item); // Append wxMenuItem to menu
_( "Text E&ditor" ), // Entry text
_( "Open prefered text editor" ) ); // Status bar text
item->SetBitmap( editor_xpm ); // Entry XPM Bitmap
browseMenu->Append( item ); // Append wxMenuItem to menu
// Browse files
item = new wxMenuItem(browseMenu,
item = new wxMenuItem( browseMenu,
ID_BROWSE_AN_SELECT_FILE,
_("&Browse Files"),
_("Read or edit files with text editor") );
item->SetBitmap(browse_files_xpm);
browseMenu->Append(item);
_( "&Browse Files" ),
_( "Read or edit files with text editor" ) );
item->SetBitmap( browse_files_xpm );
browseMenu->Append( item );
/*************************************************************************/
wxMenu *PreferencesMenu = new wxMenu;
wxMenu* PreferencesMenu = new wxMenu;
/*************************************************************************/
// Fonts
item = new wxMenuItem(PreferencesMenu,
item = new wxMenuItem( PreferencesMenu,
ID_PREFERENCES_FONT_INFOSCREEN,
_("Fonts"),
_("Font preferences"));
item->SetBitmap(fonts_xpm);
PreferencesMenu->Append(item);
_( "Fonts" ),
_( "Font preferences" ) );
item->SetBitmap( fonts_xpm );
PreferencesMenu->Append( item );
// Prefered text editor
item = new wxMenuItem(PreferencesMenu,
item = new wxMenuItem( PreferencesMenu,
ID_SELECT_PREFERED_EDITOR,
_("&Text Editor"),
_("Select your prefered text editor") );
item->SetBitmap(editor_xpm);
PreferencesMenu->Append(item);
_( "&Text Editor" ),
_( "Select your prefered text editor" ) );
item->SetBitmap( editor_xpm );
PreferencesMenu->Append( item );
// Submenu Pdf Browser selection: system browser or user
// selected browser (and its name)
/*************************************************************************/
wxMenu *SubMenuPdfBrowserChoice = new wxMenu;
wxMenu* SubMenuPdfBrowserChoice = new wxMenu;
/*************************************************************************/
// Default PDF viewer
item = new wxMenuItem(SubMenuPdfBrowserChoice,
item = new wxMenuItem( SubMenuPdfBrowserChoice,
ID_SELECT_DEFAULT_PDF_BROWSER,
_("Default PDF Viewer"),
_("Use the default (system) PDF viewer used to browse datasheets"),
wxITEM_CHECK);
SETBITMAPS(datasheet_xpm);
SubMenuPdfBrowserChoice->Append(item);
SubMenuPdfBrowserChoice->Check(ID_SELECT_DEFAULT_PDF_BROWSER,
g_EDA_Appl->m_PdfBrowserIsDefault);
_( "Default PDF Viewer" ),
_( "Use the default (system) PDF viewer used to browse datasheets" ),
wxITEM_CHECK );
SETBITMAPS( datasheet_xpm );
SubMenuPdfBrowserChoice->Append( item );
SubMenuPdfBrowserChoice->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
wxGetApp().m_PdfBrowserIsDefault );
// Favourite PDF viewer
item = new wxMenuItem(SubMenuPdfBrowserChoice,
item = new wxMenuItem( SubMenuPdfBrowserChoice,
ID_SELECT_PREFERED_PDF_BROWSER,
_("Favourite PDF Viewer"),
_("Use your favourite PDF viewer used to browse datasheets"),
wxITEM_CHECK);
SETBITMAPS(preference_xpm);
SubMenuPdfBrowserChoice->Append(item);
_( "Favourite PDF Viewer" ),
_( "Use your favourite PDF viewer used to browse datasheets" ),
wxITEM_CHECK );
SETBITMAPS( preference_xpm );
SubMenuPdfBrowserChoice->Append( item );
SubMenuPdfBrowserChoice->AppendSeparator();
SubMenuPdfBrowserChoice->Check(ID_SELECT_PREFERED_PDF_BROWSER,
!g_EDA_Appl->m_PdfBrowserIsDefault);
SubMenuPdfBrowserChoice->Check( ID_SELECT_PREFERED_PDF_BROWSER,
!wxGetApp().m_PdfBrowserIsDefault );
item = new wxMenuItem(SubMenuPdfBrowserChoice,
item = new wxMenuItem( SubMenuPdfBrowserChoice,
ID_SELECT_PREFERED_PDF_BROWSER_NAME,
_("Select Pdf Viewer"),
_("Select your favourite PDF viewer used to browse datasheets"));
item->SetBitmap(datasheet_xpm);
SubMenuPdfBrowserChoice->Append(item);
_( "Select Pdf Viewer" ),
_( "Select your favourite PDF viewer used to browse datasheets" ) );
item->SetBitmap( datasheet_xpm );
SubMenuPdfBrowserChoice->Append( item );
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(PreferencesMenu,
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( PreferencesMenu,
SubMenuPdfBrowserChoice,
-1, _("Pdf Viewer"),
_("Pdf viewer preferences"),
datasheet_xpm);
-1, _( "Pdf Viewer" ),
_( "Pdf viewer preferences" ),
datasheet_xpm );
PreferencesMenu->AppendSeparator();
m_Parent->SetLanguageList(PreferencesMenu);
wxGetApp().SetLanguageList( PreferencesMenu );
/*************************************************************************/
wxMenu *helpMenu = new wxMenu;
wxMenu* helpMenu = new wxMenu;
/*************************************************************************/
// Contents
item = new wxMenuItem(helpMenu ,
item = new wxMenuItem( helpMenu,
ID_GENERAL_HELP,
_("&Contents"),
_("Open the kicad manual"));
item->SetBitmap(help_xpm);
helpMenu->Append(item);
_( "&Contents" ),
_( "Open the kicad manual" ) );
item->SetBitmap( help_xpm );
helpMenu->Append( item );
// About Kicad
item = new wxMenuItem(helpMenu ,
item = new wxMenuItem( helpMenu,
ID_KICAD_ABOUT,
_("&About"),
_("About kicad project manager"));
item->SetBitmap(info_xpm);
helpMenu->Append(item);
_( "&About" ),
_( "About kicad project manager" ) );
item->SetBitmap( info_xpm );
helpMenu->Append( item );
// Append menus to menuBar
menuBar->Append(m_FilesMenu, _("&File"));
menuBar->Append(browseMenu, _("&Browse"));
menuBar->Append(PreferencesMenu, _("&Preferences"));
menuBar->Append(helpMenu, _("&Help"));
menuBar->Append( m_FilesMenu, _( "&File" ) );
menuBar->Append( browseMenu, _( "&Browse" ) );
menuBar->Append( PreferencesMenu, _( "&Preferences" ) );
menuBar->Append( helpMenu, _( "&Help" ) );
// Associate the menu bar with the frame
SetMenuBar(menuBar);
SetMenuBar( menuBar );
}
else // TODO (ENGLISH!) simple mise a jour de la liste des fichiers anciens
{
wxMenuItem * item;
int max_file = m_Parent->m_LastProjectMaxCount;
wxMenuItem* item;
int max_file = wxGetApp().m_LastProjectMaxCount;
for ( ii = max_file-1; ii >=0 ; ii-- )
for( ii = max_file - 1; ii >=0; ii-- )
{
if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) )
if( m_FilesMenu->FindItem( ID_LOAD_FILE_1 + ii ) )
{
item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii);
item = m_FilesMenu->Remove( ID_LOAD_FILE_1 + ii );
if ( item )
if( item )
delete item;
}
}
for ( jj = 0, ii = 0; ii < max_file; ii++ )
for( jj = 0, ii = 0; ii < max_file; ii++ )
{
if (GetLastProject(ii).IsEmpty() )
if( GetLastProject( ii ).IsEmpty() )
break;
m_FilesMenu->Append(ID_LOAD_FILE_1 + jj, GetLastProject(ii) );
m_FilesMenu->Append( ID_LOAD_FILE_1 + jj, GetLastProject( ii ) );
jj++;
}
}
}
/**
* @brief TODO
*/
......@@ -361,41 +352,41 @@ void WinEDA_MainFrame::RecreateBaseHToolbar()
/*****************************************************************************/
{
// Check if toolbar is not already set
if ( m_HToolBar != NULL )
if( m_HToolBar != NULL )
return;
// Allocate memory for m_HToolBar
m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE);
SetToolBar(m_HToolBar);
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
SetToolBar( m_HToolBar );
// Set up toolbar
m_HToolBar->AddTool(ID_NEW_PROJECT, // Entry ID
BITMAP(new_project_xpm), // XPM Bitmap
m_HToolBar->AddTool( ID_NEW_PROJECT, // Entry ID
wxBitmap( new_project_xpm ), // XPM Bitmap
wxNullBitmap,
FALSE,
-1, -1,
(wxObject *) NULL,
_("Start a new project")); // Tooltip
(wxObject*) NULL,
_( "Start a new project" ) ); // Tooltip
// Load project
m_HToolBar->AddTool(ID_LOAD_PROJECT, // Entry ID
BITMAP(open_project_xpm), // XPM Bitmap
m_HToolBar->AddTool( ID_LOAD_PROJECT, // Entry ID
wxBitmap( open_project_xpm ), // XPM Bitmap
wxNullBitmap,
FALSE,
-1, -1, (wxObject *) NULL,
_("Load existing project")); // Tooltip
-1, -1, (wxObject*) NULL,
_( "Load existing project" ) ); // Tooltip
// Save project
m_HToolBar->AddTool(ID_SAVE_PROJECT, // Entry ID
BITMAP(save_project_xpm), // XPM Bitmap
m_HToolBar->AddTool( ID_SAVE_PROJECT, // Entry ID
wxBitmap( save_project_xpm ), // XPM Bitmap
wxNullBitmap,
FALSE,
-1, -1,
(wxObject *) NULL,
_( "Save current project" )); // Tooltip
(wxObject*) NULL,
_( "Save current project" ) ); // Tooltip
// Separator
......@@ -403,12 +394,12 @@ void WinEDA_MainFrame::RecreateBaseHToolbar()
// Save and archive files
m_HToolBar->AddTool(ID_SAVE_AND_ZIP_FILES, // Entry ID
BITMAP(zip_xpm), // XPM Bitmap
m_HToolBar->AddTool( ID_SAVE_AND_ZIP_FILES, // Entry ID
wxBitmap( zip_xpm ), // XPM Bitmap
wxNullBitmap,
FALSE,
-1, -1, (wxObject *) NULL,
_("Archive all project files")); // Tooltip
-1, -1, (wxObject*) NULL,
_( "Archive all project files" ) ); // Tooltip
// Separator
......@@ -416,12 +407,12 @@ void WinEDA_MainFrame::RecreateBaseHToolbar()
// Refresh project tree
m_HToolBar->AddTool(ID_PROJECT_TREE_REFRESH, // Entry ID
BITMAP(reload_xpm), // XPM Bitmap
m_HToolBar->AddTool( ID_PROJECT_TREE_REFRESH, // Entry ID
wxBitmap( reload_xpm ), // XPM Bitmap
wxNullBitmap,
FALSE,
-1, -1, (wxObject *) NULL,
_("Refresh project tree")); // Tooltip
-1, -1, (wxObject*) NULL,
_( "Refresh project tree" ) ); // Tooltip
m_HToolBar->Realize(); // Create m_HToolBar
......
......@@ -144,7 +144,8 @@ static void Create_NewPrj_Config( const wxString PrjFullFileName )
g_BoardFileName = wxFileNameFromPath( PrjFullFileName );
ChangeFileNameExt( g_BoardFileName, g_BoardExtBuffer );
g_EDA_Appl->WriteProjectConfig( PrjFullFileName, wxT( "/general" ), CfgParamList );
wxGetApp().WriteProjectConfig( PrjFullFileName, wxT( "/general" ),
CfgParamList );
}
......@@ -176,7 +177,8 @@ void WinEDA_MainFrame::UnZipArchive( const wxString FullFileName )
PrintMsg( msg );
wxString target_dirname = wxDirSelector( _( "Target Directory" ),
wxEmptyString, 0, wxDefaultPosition, this );
wxEmptyString, 0,
wxDefaultPosition, this );
if( target_dirname.IsEmpty() )
return;
......
/*****************************************************************************/
/**
* @file kicad.cpp
* @brief Main kicad library manager file
......@@ -6,7 +7,6 @@
/*****************************************************************************/
#ifdef __GNUG__
#pragma implementation
#endif
......@@ -16,17 +16,12 @@
#include "fctsys.h"
#include <wx/image.h>
#ifdef USE_SPLASH_IMAGE
#define SPLASH_IMAGE logo_kicad.png
#include "wx/splash.h"
#include "wx/mediactrl.h"
#endif
#include <wx/button.h>
#include "wxstruct.h"
#include "common.h"
#include "bitmaps.h"
#include "kicad.h"
......@@ -39,16 +34,17 @@
/* Export functions */
/* Import functions */
char *GetFileName(char *FullPathName);
void ShowLogo(char * FonteFileName);
char* GetFileName( char* FullPathName );
void ShowLogo( char* FonteFileName );
/* Local functions */
/************************************/
/* Called to initialize the program */
/************************************/
// Create a new application object
IMPLEMENT_APP(WinEDA_App)
IMPLEMENT_APP( WinEDA_App )
#ifdef KICAD_PYTHON
......@@ -56,36 +52,69 @@ using namespace boost::python;
/*****************************************************************************/
// Global functions:
/*****************************************************************************/
static WinEDA_MainFrame& GetMainFrame() { return *( wxGetApp().m_MainFrame ); }
static void WinEDAPrint( str msg ) { GetMainFrame().PrintMsg( PyHandler::MakeStr( msg ) + wxT("\n") ); }
static void WinEDAClear() { GetMainFrame().ClearMsg(); }
static object GetTypeExt( enum TreeFileType type ) { return PyHandler::Convert( WinEDA_PrjFrame::GetFileExt( type ) ); }
static WinEDA_MainFrame& GetMainFrame()
{
return *( wxGetApp().m_MainFrame );
}
static void WinEDAPrint( str msg )
{
GetMainFrame().PrintMsg( PyHandler::MakeStr( msg ) + wxT( "\n" ) );
}
static void WinEDAClear()
{
GetMainFrame().ClearMsg();
}
static object GetTypeExt( enum TreeFileType type )
{
return PyHandler::Convert( WinEDA_PrjFrame::GetFileExt( type ) );
}
/*****************************************************************************/
// WinEDA_MainFrame Special binding functions:
// (one line functions are simple wrappers)
/*****************************************************************************/
object WinEDA_MainFrame::GetPrjName() const { return PyHandler::Convert( m_PrjFileName ); }
object WinEDA_MainFrame::ToWx() { return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); }
WinEDA_PrjFrame* WinEDA_MainFrame::GetTree() const { return m_LeftWin; }
object WinEDA_MainFrame::GetPrjName() const
{
return PyHandler::Convert( m_PrjFileName );
}
object WinEDA_MainFrame::ToWx()
{
return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) );
}
WinEDA_PrjFrame* WinEDA_MainFrame::GetTree() const
{
return m_LeftWin;
}
/**
* @brief TODO
*/
/*****************************************************************************/
void WinEDA_MainFrame::AddFastLaunchPy( object & button )
void WinEDA_MainFrame::AddFastLaunchPy( object& button )
/*****************************************************************************/
{
wxBitmapButton * btn;
wxBitmapButton* btn;
bool success = wxPyConvertSwigPtr( button.ptr(),
(void**) &btn, _T( "wxBitmapButton" ) );
bool success = wxPyConvertSwigPtr( button.ptr(), (void**)&btn, _T("wxBitmapButton"));
if(!success)
if( !success )
return;
Py_INCREF( button.ptr() );
......@@ -94,59 +123,70 @@ void WinEDA_MainFrame::AddFastLaunchPy( object & button )
}
/*****************************************************************************/
// WinEDA_PrjFrame Special binding functions:
// (one line functions are simple wrappers)
/*****************************************************************************/
// TODO To WxWidgets ?
object WinEDA_PrjFrame::ToWx()
{ return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); }
{
return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) );
}
// TODO Get ?
object WinEDA_PrjFrame::GetFtExPy( enum TreeFileType type ) const
{ return PyHandler::Convert( GetFileExt( type ) ); }
{
return PyHandler::Convert( GetFileExt( type ) );
}
// Get python menu
object WinEDA_PrjFrame::GetMenuPy( enum TreeFileType type )
{ return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) ); }
{
return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) );
}
// Get tree control
object WinEDA_PrjFrame::GetTreeCtrl()
{ return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) ); }
{
return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) );
}
// Get current menu
object WinEDA_PrjFrame::GetCurrentMenu()
{ return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) ); }
{
return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) );
}
/**
* @brief TODO
*/
/*****************************************************************************/
void WinEDA_PrjFrame::NewFilePy( const str & name,
void WinEDA_PrjFrame::NewFilePy( const str& name,
enum TreeFileType type,
object & id )
object& id )
/*****************************************************************************/
{
wxTreeItemId root;
if (! wxPyConvertSwigPtr( id.ptr(), (void**)&root, _T("wxTreeItemId") ) ) return;
if( !wxPyConvertSwigPtr( id.ptr(), (void**) &root, _T( "wxTreeItemId" ) ) )
return;
NewFile( PyHandler::MakeStr( name ), type, root );
}
/**
* @brief Add a file to the tree under root, or m_root if conversion is wrong
*/
/*****************************************************************************/
void WinEDA_PrjFrame::AddFilePy( const str & file, object & root )
void WinEDA_PrjFrame::AddFilePy( const str& file, object& root )
/*****************************************************************************/
{
wxTreeItemId * theroot = &m_root;
wxTreeItemId* theroot = &m_root;
if ( !wxPyConvertSwigPtr( root.ptr(), (void**)&root, _T("wxTreeItemId") ) )
if( !wxPyConvertSwigPtr( root.ptr(), (void**) &root, _T( "wxTreeItemId" ) ) )
{
theroot = &m_root;
}
......@@ -155,46 +195,53 @@ void WinEDA_PrjFrame::AddFilePy( const str & file, object & root )
}
/**
* @brief convert wxTreeItem into TreePrjItemData
*/
/*****************************************************************************/
TreePrjItemData * WinEDA_PrjFrame::GetItemData( const object & item )
TreePrjItemData* WinEDA_PrjFrame::GetItemData( const object& item )
/*****************************************************************************/
{
wxTreeItemId *id = NULL;
wxTreeItemId* id = NULL;
if (!wxPyConvertSwigPtr( item.ptr(), (void**)&id, _T("wxTreeItemId")))
if( !wxPyConvertSwigPtr( item.ptr(), (void**) &id, _T( "wxTreeItemId" ) ) )
{
return NULL;
}
return dynamic_cast<TreePrjItemData *>( m_TreeProject->GetItemData( *id ) );
return dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData( *id ) );
}
/*****************************************************************************/
// TreePrjItemData Special binding functions
// (one line functions are simple wrappers)
/*****************************************************************************/
// Python rename
bool TreePrjItemData::RenamePy( const str & newname, bool check )
{ return Rename( PyHandler::MakeStr(newname), check ); }
bool TreePrjItemData::RenamePy( const str& newname, bool check )
{
return Rename( PyHandler::MakeStr( newname ), check );
}
// Get python directory
object TreePrjItemData::GetDirPy() const
{ return PyHandler::Convert( GetDir() ); }
{
return PyHandler::Convert( GetDir() );
}
// Get python filename
object TreePrjItemData::GetFileNamePy() const
{ return PyHandler::Convert( GetFileName() ); }
{
return PyHandler::Convert( GetFileName() );
}
// Get python menu
object TreePrjItemData::GetMenuPy()
{ return object( handle<>( borrowed( wxPyMake_wxObject( &m_fileMenu, false ) ) ) ); }
{
return object( handle<>( borrowed( wxPyMake_wxObject( &m_fileMenu, false ) ) ) );
}
/**
......@@ -205,16 +252,19 @@ object TreePrjItemData::GetMenuPy()
static void py_kicad_init()
/*****************************************************************************/
{
def( "GetMainFrame", &GetMainFrame, return_value_policy< reference_existing_object >() );
def( "GetMainFrame", &GetMainFrame,
return_value_policy< reference_existing_object >() );
def( "GetTypeExtension", &GetTypeExt );
class_<TreePrjItemData>( "PrjItem" )
// Internal data:
.def( "GetFileName", &TreePrjItemData::GetFileNamePy )
.def( "GetDir", &TreePrjItemData::GetDirPy )
.def( "GetType", &TreePrjItemData::GetType )
.def( "GetId", &TreePrjItemData::GetIdPy )
.def( "GetMenu", &TreePrjItemData::GetMenuPy )
// Item control
.def( "SetState", &TreePrjItemData::SetState )
.def( "Rename", &TreePrjItemData::RenamePy )
......@@ -238,16 +288,20 @@ static void py_kicad_init()
class_<WinEDA_PrjFrame>( "TreeWindow" )
// wx Interface
.def( "ToWx", &WinEDA_PrjFrame::ToWx )
// common features
.def( "GetContextMenu", &WinEDA_PrjFrame::GetMenuPy )
.def( "GetFileExtension", &WinEDA_PrjFrame::GetFtExPy )
// file filters control
.def( "AddFilter", &WinEDA_PrjFrame::AddFilter )
.def( "ClearFilters", &WinEDA_PrjFrame::ClearFilters )
.def( "RemoveFilter", &WinEDA_PrjFrame::RemoveFilterPy )
.def( "GetFilters", &WinEDA_PrjFrame::GetFilters, return_value_policy < copy_const_reference >() )
.def( "GetFilters", &WinEDA_PrjFrame::GetFilters,
return_value_policy < copy_const_reference >() )
.def( "GetCurrentMenu", &WinEDA_PrjFrame::GetCurrentMenu )
......@@ -283,18 +337,19 @@ static void py_kicad_init()
class_<WinEDA_MainFrame>( "MainFrame" )
// Wx interface
.def( "ToWx", &WinEDA_MainFrame::ToWx )
// Common controls
.def( "AddFastLaunch", &WinEDA_MainFrame::AddFastLaunchPy )
.def( "Refresh", &WinEDA_MainFrame::OnRefreshPy )
.def( "GetProjectName", &WinEDA_MainFrame::GetPrjName )
.def( "GetProjectWindow", &WinEDA_MainFrame::GetTree, return_value_policy< reference_existing_object >() );
.def( "GetProjectWindow", &WinEDA_MainFrame::GetTree,
return_value_policy< reference_existing_object >() );
}
/**
* @brief Common python module init
*/
......@@ -305,74 +360,77 @@ static void py_common_init()
def( "Print", &WinEDAPrint );
def( "Clear", &WinEDAClear );
}
#endif
#endif
/*****************************************************************************/
bool WinEDA_App::OnInit()
/*****************************************************************************/
{
wxImage::AddHandler(new wxPNGHandler);
WinEDA_MainFrame* frame;
g_EDA_Appl = this;
InitEDA_Appl( wxT("KiCad"));
InitEDA_Appl( wxT( "KiCad" ) );
/* init kicad */
GetSettings(); // read current setup
/* Make nameless project translatable */
wxString project_ext = _T(".pro");
wxString nameless_project = _("noname") + project_ext;
wxString project_ext = _T( ".pro" );
wxString nameless_project = _( "noname" ) + project_ext;
m_MainFrame = new WinEDA_MainFrame(this, NULL, wxT("KiCad"),
wxPoint(30,20), wxSize(600,400) );
frame = new WinEDA_MainFrame( NULL, wxT( "KiCad" ),
wxPoint( 30, 20 ), wxSize( 600, 400 ) );
if(argc > 1 )
m_MainFrame->m_PrjFileName = argv[1];
else if ( m_EDA_Config )
if( argc > 1 )
frame->m_PrjFileName = argv[1];
else if( m_EDA_Config )
{
m_MainFrame->m_PrjFileName = m_EDA_Config->Read(wxT("LastProject"),
frame->m_PrjFileName = m_EDA_Config->Read( wxT( "LastProject" ),
nameless_project );
}
else
m_MainFrame->m_PrjFileName = nameless_project;
frame->m_PrjFileName = nameless_project;
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion();
Title += wxT(" ") + m_MainFrame->m_PrjFileName;
m_MainFrame->SetTitle(Title);
m_MainFrame->ReCreateMenuBar();
m_MainFrame->RecreateBaseHToolbar();
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
Title += wxT( " " ) + frame->m_PrjFileName;
frame->SetTitle( Title );
frame->ReCreateMenuBar();
frame->RecreateBaseHToolbar();
m_MainFrame->m_LeftWin->ReCreateTreePrj();
SetTopWindow(m_MainFrame);
frame->m_LeftWin->ReCreateTreePrj();
SetTopWindow( frame );
/* Splash screen logo */
#ifdef USE_SPLASH_IMAGE
wxString logoname( wxString(m_BinDir) + _T("logokicad.png") );
wxString logoname( wxString( m_BinDir ) + _T( "logokicad.png" ) );
wxBitmap splash_screen;
if ( splash_screen.LoadFile( logoname, wxBITMAP_TYPE_PNG ) )
if( splash_screen.LoadFile( logoname, wxBITMAP_TYPE_PNG ) )
{
wxSplashScreen *splash = new wxSplashScreen(splash_screen,
wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
3000, m_MainFrame, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxSIMPLE_BORDER|wxSTAY_ON_TOP);
wxSplashScreen* splash = new wxSplashScreen( splash_screen,
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT,
3000,
frame,
wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
wxSIMPLE_BORDER | wxSTAY_ON_TOP );
}
#endif /* USE_SPLASH_IMAGE */
m_MainFrame->Show(TRUE);
m_MainFrame->Raise();
frame->Show( TRUE );
frame->Raise();
if( wxFileExists(m_MainFrame->m_PrjFileName) )
if( wxFileExists( frame->m_PrjFileName ) )
{
m_MainFrame->Load_Prj_Config();
frame->Load_Prj_Config();
}
#ifdef KICAD_PYTHON
PyHandler::GetInstance()->AddToModule( wxT("kicad"), &py_kicad_init );
PyHandler::GetInstance()->AddToModule( wxT("common"), &py_common_init );
PyHandler::GetInstance()->AddToModule( wxT( "kicad" ), &py_kicad_init );
PyHandler::GetInstance()->AddToModule( wxT( "common" ), &py_common_init );
#endif
return TRUE;
......
......@@ -52,7 +52,7 @@ private:
public:
// Constructor and destructor
WinEDA_MainFrame( WinEDA_App* eda_app, wxWindow* parent, const wxString& title,
WinEDA_MainFrame( wxWindow* parent, const wxString& title,
const wxPoint& pos, const wxSize& size );
~WinEDA_MainFrame();
......
......@@ -24,17 +24,17 @@
// Constructor
/*****************************************************************************/
WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
wxWindow* parent,
WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size ) :
WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, eda_app, title, pos, size )
WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, title, pos, size )
/*****************************************************************************/
{
wxString msg;
wxString line;
wxSize clientsize;
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "KicadFrame" );
m_VToolBar = NULL;
......@@ -45,12 +45,11 @@ WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, eda_app, title, pos, size )
m_CommandWin_Height = 82;
GetSettings();
if( m_Parent->m_EDA_Config )
if( config )
{
m_Parent->m_EDA_Config->Read( wxT( "LeftWinWidth" ),
&m_LeftWin_Width );
m_Parent->m_EDA_Config->Read( wxT( "CommandWinWidth" ),
&m_CommandWin_Height );
config->Read( wxT( "LeftWinWidth" ), &m_LeftWin_Width );
config->Read( wxT( "CommandWinWidth" ), &m_CommandWin_Height );
}
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
......@@ -118,12 +117,14 @@ WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, eda_app, title, pos, size )
WinEDA_MainFrame::~WinEDA_MainFrame()
/*****************************************************************************/
{
if( m_Parent->m_EDA_Config )
wxConfig* config = wxGetApp().m_EDA_Config;
if( config )
{
m_LeftWin_Width = m_LeftWin->GetSize().x;
m_CommandWin_Height = m_CommandWin->GetSize().y;
m_Parent->m_EDA_Config->Write( wxT( "LeftWinWidth" ), m_LeftWin_Width );
m_Parent->m_EDA_Config->Write( wxT( "CommandWinWidth" ), m_CommandWin_Height );
config->Write( wxT( "LeftWinWidth" ), m_LeftWin_Width );
config->Write( wxT( "CommandWinWidth" ), m_CommandWin_Height );
}
}
......@@ -246,11 +247,11 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event )
SaveSettings();
// Close the help frame
if( m_Parent->m_HtmlCtrl )
if( wxGetApp().m_HtmlCtrl )
{
if( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
m_Parent->m_HtmlCtrl->GetFrame()->Close( TRUE );
m_Parent->m_HtmlCtrl = NULL;
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
wxGetApp().m_HtmlCtrl->GetFrame()->Close( TRUE );
wxGetApp().m_HtmlCtrl = NULL;
}
m_LeftWin->Show(false);
......@@ -287,7 +288,8 @@ void WinEDA_MainFrame::Process_Special_Functions( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_MainFrame::Process_Special_Functions error" ) );
DisplayError( this,
wxT( "WinEDA_MainFrame::Process_Special_Functions error" ) );
break;
}
}
......@@ -383,7 +385,8 @@ void WinEDA_MainFrame::Process_Fct( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_MainFrame::Process_Fct Internal Error" ) );
DisplayError( this,
wxT( "WinEDA_MainFrame::Process_Fct Internal Error" ) );
break;
}
}
......
/******************************************************************/
/* mdiframe.cpp - fonctions de la classe du type WinEDA_MainFrame */
/******************************************************************/
/******************************************************************/
/* mdiframe.cpp - fonctions de la classe du type WinEDA_MainFrame */
/******************************************************************/
#ifdef __GNUG__
#pragma implementation
......@@ -19,19 +19,21 @@
#include <wx/fontdlg.h>
static bool ChoosePdfBrowser(WinEDA_MainFrame * parent_frame)
static bool ChoosePdfBrowser( WinEDA_MainFrame* parent_frame )
/* routine to choose the prefered Pdf browser
*/
*/
{
wxString mask(wxT("*"));
wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__
mask += wxT(".exe");
mask += wxT( ".exe" );
#endif
g_EDA_Appl->ReadPdfBrowserInfos();
wxString FullFileName = g_EDA_Appl->m_PdfBrowser;
FullFileName = EDA_FileSelector( _("Prefered Pdf Browser:"),
wxPathOnly(FullFileName), /* Default path */
wxGetApp().ReadPdfBrowserInfos();
wxString FullFileName = wxGetApp().m_PdfBrowser;
FullFileName = EDA_FileSelector( _( "Prefered Pdf Browser:" ),
wxPathOnly( FullFileName ), /* Default path */
FullFileName, /* default filename */
wxEmptyString, /* default filename extension */
mask, /* filter for filename list */
......@@ -39,63 +41,68 @@ mask += wxT(".exe");
wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/
TRUE /* true = keep the current path */
);
if ( ! FullFileName.IsEmpty() && (g_EDA_Appl->m_PdfBrowser != FullFileName) )
if( !FullFileName.IsEmpty() && (wxGetApp().m_PdfBrowser != FullFileName) )
{
g_EDA_Appl->m_PdfBrowser = FullFileName;
g_EDA_Appl->WritePdfBrowserInfos();
wxGetApp().m_PdfBrowser = FullFileName;
wxGetApp().WritePdfBrowserInfos();
return TRUE;
}
return FALSE;
}
/****************************************************************/
void WinEDA_MainFrame::Process_Preferences(wxCommandEvent& event)
void WinEDA_MainFrame::Process_Preferences( wxCommandEvent& event )
/*****************************************************************/
{
int id = event.GetId();
wxString FullFileName;
wxString mask(wxT("*"));
int id = event.GetId();
wxString FullFileName;
wxString mask( wxT( "*" ) );
#ifdef __WINDOWS__
mask += wxT(".exe");
mask += wxT( ".exe" );
#endif
switch (id)
switch( id )
{
case ID_SELECT_DEFAULT_PDF_BROWSER:
g_EDA_Appl->m_PdfBrowserIsDefault = TRUE;
GetMenuBar()->Check(ID_SELECT_DEFAULT_PDF_BROWSER, g_EDA_Appl->m_PdfBrowserIsDefault);
GetMenuBar()->Check(ID_SELECT_PREFERED_PDF_BROWSER, !g_EDA_Appl->m_PdfBrowserIsDefault);
g_EDA_Appl->WritePdfBrowserInfos();
wxGetApp().m_PdfBrowserIsDefault = TRUE;
GetMenuBar()->Check( ID_SELECT_DEFAULT_PDF_BROWSER,
wxGetApp().m_PdfBrowserIsDefault );
GetMenuBar()->Check( ID_SELECT_PREFERED_PDF_BROWSER,
!wxGetApp().m_PdfBrowserIsDefault );
wxGetApp().WritePdfBrowserInfos();
break;
case ID_SELECT_PREFERED_PDF_BROWSER:
if ( g_EDA_Appl->m_PdfBrowser.IsEmpty() )
if( wxGetApp().m_PdfBrowser.IsEmpty() )
{
DisplayError(this, _("You must choose a PDF viewer before use this option"));
ChoosePdfBrowser(this);
DisplayError( this,
_( "You must choose a PDF viewer before use this option" ) );
ChoosePdfBrowser( this );
}
if ( g_EDA_Appl->m_PdfBrowser.IsEmpty() )
if( wxGetApp().m_PdfBrowser.IsEmpty() )
{
g_EDA_Appl->m_PdfBrowserIsDefault = TRUE;
GetMenuBar()->Check(ID_SELECT_DEFAULT_PDF_BROWSER, TRUE);
GetMenuBar()->Check(ID_SELECT_PREFERED_PDF_BROWSER, FALSE);
wxGetApp().m_PdfBrowserIsDefault = TRUE;
GetMenuBar()->Check( ID_SELECT_DEFAULT_PDF_BROWSER, TRUE );
GetMenuBar()->Check( ID_SELECT_PREFERED_PDF_BROWSER, FALSE );
}
else
{
g_EDA_Appl->m_PdfBrowserIsDefault = FALSE;
GetMenuBar()->Check(ID_SELECT_DEFAULT_PDF_BROWSER, FALSE);
GetMenuBar()->Check(ID_SELECT_PREFERED_PDF_BROWSER, TRUE);
wxGetApp().m_PdfBrowserIsDefault = FALSE;
GetMenuBar()->Check( ID_SELECT_DEFAULT_PDF_BROWSER, FALSE );
GetMenuBar()->Check( ID_SELECT_PREFERED_PDF_BROWSER, TRUE );
}
g_EDA_Appl->WritePdfBrowserInfos();
wxGetApp().WritePdfBrowserInfos();
break;
case ID_SELECT_PREFERED_PDF_BROWSER_NAME:
ChoosePdfBrowser(this);
ChoosePdfBrowser( this );
break;
case ID_SELECT_PREFERED_EDITOR:
FullFileName = EDA_FileSelector( _("Prefered Editor:"),
wxPathOnly(g_EditorName), /* Default path */
FullFileName = EDA_FileSelector( _( "Prefered Editor:" ),
wxPathOnly( g_EditorName ), /* Default path */
g_EditorName, /* default filename */
wxEmptyString, /* default filename extension */
mask, /* filter for filename list */
......@@ -103,17 +110,18 @@ mask += wxT(".exe");
wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/
TRUE /* true = keep the current path */
);
if ( ( !FullFileName.IsEmpty() ) && g_EDA_Appl->m_EDA_CommonConfig)
if( ( !FullFileName.IsEmpty() ) && wxGetApp().m_EDA_CommonConfig )
{
g_EditorName = FullFileName;
g_EDA_Appl->m_EDA_CommonConfig->Write(wxT("Editor"), g_EditorName);
wxGetApp().m_EDA_CommonConfig->Write( wxT( "Editor" ),
g_EditorName );
}
break;
case ID_PREFERENCES_FONT_INFOSCREEN:
{
wxFont font = wxGetFontFromUser(this, *g_StdFont);
if ( font.Ok() )
wxFont font = wxGetFontFromUser( this, *g_StdFont );
if( font.Ok() )
{
int pointsize = font.GetPointSize();
*g_StdFont = font;
......@@ -121,24 +129,26 @@ mask += wxT(".exe");
g_DialogFontPointSize = pointsize;
g_FixedFontPointSize = pointsize;
m_LeftWin->ReCreateTreePrj();
m_DialogWin->SetFont(* g_StdFont);
m_DialogWin->SetFont( *g_StdFont );
m_DialogWin->Refresh();
}
break;
}
default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Preferences Internal Error") );
default:
DisplayError( this,
wxT( "WinEDA_MainFrame::Process_Preferences Internal Error" ) );
break;
}
}
/********************************************************/
void WinEDA_MainFrame::SetLanguage(wxCommandEvent& event)
void WinEDA_MainFrame::SetLanguage( wxCommandEvent& event )
/********************************************************/
{
int id = event.GetId();
int id = event.GetId();
m_Parent->SetLanguageIdentifier(id );
m_Parent->SetLanguage();
wxGetApp().SetLanguageIdentifier( id );
wxGetApp().SetLanguage();
}
......@@ -6,6 +6,7 @@
#ifdef KICAD_PYTHON
#include <pyhandler.h>
#endif
#include "fctsys.h"
#include "common.h"
#include "kicad.h"
......@@ -22,13 +23,15 @@ void WinEDA_MainFrame::Load_Prj_Config()
{
if( !wxFileExists( m_PrjFileName ) )
{
wxString msg = _( "Project File <" ) + m_PrjFileName + _( "> not found" );
wxString msg = _( "Project File <" ) + m_PrjFileName +
_( "> not found" );
DisplayError( this, msg );
return;
}
wxSetWorkingDirectory( wxPathOnly( m_PrjFileName ) );
SetTitle( g_Main_Title + wxT( " " ) + GetBuildVersion() + wxT( " " ) + m_PrjFileName );
SetTitle( g_Main_Title + wxT( " " ) + GetBuildVersion() + wxT( " " ) +
m_PrjFileName );
ReCreateMenuBar();
m_LeftWin->ReCreateTreePrj();
......@@ -70,8 +73,6 @@ void WinEDA_MainFrame::Save_Prj_Config()
return;
/* ecriture de la configuration */
g_EDA_Appl->WriteProjectConfig( FullFileName, wxT( "/general" ), CfgParamList );
wxGetApp().WriteProjectConfig( FullFileName, wxT( "/general" ),
CfgParamList );
}
// vim: set tabstop=4 : noexpandtab :
......@@ -23,11 +23,10 @@
/*******************************/
BEGIN_EVENT_TABLE( WinEDA_BasePcbFrame, WinEDA_DrawFrame )
COMMON_EVENTS_DRAWFRAME EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START,
COMMON_EVENTS_DRAWFRAME
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START,
ID_POPUP_PCB_ITEM_SELECTION_END,
WinEDA_BasePcbFrame::ProcessItemSelection )
END_EVENT_TABLE()
......@@ -36,13 +35,12 @@ END_EVENT_TABLE()
/****************/
WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
WinEDA_App* parent,
int idtype,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style) :
WinEDA_DrawFrame( father, idtype, parent, title, pos, size, style )
WinEDA_DrawFrame( father, idtype, title, pos, size, style )
{
m_InternalUnits = 10000; // Internal unit = 1/10000 inch
m_Pcb = NULL;
......@@ -54,6 +52,7 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
m_DisplayModText = FILLED; // How to show module texts
m_DisplayPcbTrackFill = TRUE; /* FALSE = sketch , TRUE = filled */
m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
m_ModuleEditFrame = NULL; // Frame for footprint edition
m_Collector = new GENERAL_COLLECTOR();
}
......@@ -174,10 +173,10 @@ void WinEDA_BasePcbFrame::Show3D_Frame( wxCommandEvent& event )
}
#ifdef CVPCB
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, m_Parent, _( "3D Viewer" ),
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ),
KICAD_DEFAULT_3D_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
#else
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, m_Parent, _( "3D Viewer" ) );
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
#endif
// Show the frame
m_Draw3DFrame->Show( TRUE );
......
......@@ -4,7 +4,6 @@
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
......@@ -23,7 +22,9 @@
/* Fonctions exportees */
/* Fonctions Locales */
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static int MarkItemsInBloc( MODULE* module,
EDA_Rect& Rect );
......@@ -193,7 +194,9 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
DrawPanel->Refresh( TRUE );
}
......@@ -278,7 +281,9 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
SetCurItem( NULL );
DrawPanel->Refresh( TRUE );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
}
......@@ -295,7 +300,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
BASE_SCREEN* screen = panel->GetScreen();
BOARD_ITEM* item;
wxPoint move_offset;
MODULE* Currentmodule = g_EDA_Appl->m_ModuleEditFrame->m_Pcb->m_Modules;
MODULE* Currentmodule =
( (WinEDA_BasePcbFrame*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->m_Pcb->m_Modules;
PtBlock = &screen->BlockLocate;
GRSetDrawMode( DC, g_XorMode );
......@@ -340,8 +346,10 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
}
/* Redessin nouvel affichage */
PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y;
PtBlock->m_MoveVector.x = screen->m_Curseur.x -
PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y = screen->m_Curseur.y -
PtBlock->m_BlockLastCursorPosition.y;
GRSetDrawMode( DC, g_XorMode );
PtBlock->Offset( PtBlock->m_MoveVector );
......@@ -413,7 +421,7 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() )
{
case TYPE_TEXTE_MODULE:
TEXTE_MODULE* textm;
TEXTE_MODULE * textm;
textm = new TEXTE_MODULE( module );
textm->Copy( (TEXTE_MODULE*) item );
textm->m_Selected = IS_SELECTED;
......@@ -421,7 +429,7 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
break;
case TYPE_EDGE_MODULE:
EDGE_MODULE* edge;
EDGE_MODULE * edge;
edge = new EDGE_MODULE( module );
edge->Copy( (EDGE_MODULE*) item );
edge->m_Selected = IS_SELECTED;
......@@ -429,7 +437,8 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
break;
default:
DisplayError( NULL, wxT( "Internal Err: CopyMarkedItems: type indefini" ) );
DisplayError( NULL,
wxT( "Internal Err: CopyMarkedItems: type indefini" ) );
break;
}
}
......@@ -570,15 +579,19 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
{
case TYPE_EDGE_MODULE:
SETMIRROR( ( (EDGE_MODULE*) item )->m_Start.x );
( (EDGE_MODULE*) item )->m_Start0.x = ( (EDGE_MODULE*) item )->m_Start.x;
( (EDGE_MODULE*) item )->m_Start0.x =
( (EDGE_MODULE*) item )->m_Start.x;
SETMIRROR( ( (EDGE_MODULE*) item )->m_End.x );
( (EDGE_MODULE*) item )->m_End0.x = ( (EDGE_MODULE*) item )->m_End.x;
( (EDGE_MODULE*) item )->m_Angle = -( (EDGE_MODULE*) item )->m_Angle;
( (EDGE_MODULE*) item )->m_End0.x =
( (EDGE_MODULE*) item )->m_End.x;
( (EDGE_MODULE*) item )->m_Angle =
-( (EDGE_MODULE*) item )->m_Angle;
break;
case TYPE_TEXTE_MODULE:
SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x );
( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x;
( (TEXTE_MODULE*) item )->m_Pos0.x =
( (TEXTE_MODULE*) item )->GetPosition().x;
break;
default:
......@@ -624,14 +637,16 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
{
case TYPE_EDGE_MODULE:
ROTATE( ( (EDGE_MODULE*) item )->m_Start );
( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start;
( (EDGE_MODULE*) item )->m_Start0 =
( (EDGE_MODULE*) item )->m_Start;
ROTATE( ( (EDGE_MODULE*) item )->m_End );
( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End;
break;
case TYPE_TEXTE_MODULE:
ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() );
( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Pos0 =
( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Orient += 900;
break;
......
......@@ -3,6 +3,7 @@
/*****************************************************************/
/* cross-probing.cpp */
/** Handle messages between pcbnew and eeschema via a socket,
* the port number is
* KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) (eeschema to pcbnew)
......@@ -40,7 +41,7 @@ void RemoteCommand( const char* cmdline )
char* idcmd;
char* text;
MODULE* module = 0;
WinEDA_PcbFrame* frame = g_EDA_Appl->m_PcbFrame;
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*)wxGetApp().GetTopWindow();
strncpy( line, cmdline, sizeof(line) - 1 );
......@@ -86,6 +87,7 @@ void RemoteCommand( const char* cmdline )
if( pad )
{
netcode = pad->GetNet();
// put cursor on the pad:
frame->GetScreen()->m_Curseur = pad->GetPosition();
}
......@@ -105,12 +107,14 @@ void RemoteCommand( const char* cmdline )
msg.Printf( _( "%s not found" ), modName.GetData() );
else if( pad == NULL )
{
msg.Printf( _( "%s pin %s not found" ), modName.GetData(), pinName.GetData() );
msg.Printf( _( "%s pin %s not found" ),
modName.GetData(), pinName.GetData() );
frame->SetCurItem( module );
}
else
{
msg.Printf( _( "%s pin %s found" ), modName.GetData(), pinName.GetData() );
msg.Printf( _( "%s pin %s found" ),
modName.GetData(), pinName.GetData() );
frame->SetCurItem( pad );
}
......
......@@ -40,7 +40,7 @@ dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* z
/************************************************************************************************/
{
m_Parent = parent;
m_Config = m_Parent->m_Parent->m_EDA_Config;
m_Config = wxGetApp().m_EDA_Config;
m_Zone_Setting = zone_setting;
m_NetSorting = 1; // 0 = alphabetic sort, 1 = pad count sort, and filtering net names
if( m_Config )
......
......@@ -227,7 +227,7 @@ void dialog_freeroute_exchange::CreateControls()
////@end dialog_freeroute_exchange content construction
wxString msg;
m_Parent->m_Parent->m_EDA_Config->Read( FREEROUTE_URL_KEY, &msg );
wxGetApp().m_EDA_Config->Read( FREEROUTE_URL_KEY, &msg );
if( msg.IsEmpty() )
m_FreerouteURLName->SetValue( wxT( "http://www.freerouting.net/" ) );
else
......@@ -348,7 +348,7 @@ void dialog_freeroute_exchange::OnCloseWindow( wxCloseEvent& event )
if( m_FreeRouteSetupChanged ) // Save new config
{
m_Parent->m_Parent->m_EDA_Config->Write( FREEROUTE_URL_KEY,
wxGetApp().m_EDA_Config->Write( FREEROUTE_URL_KEY,
m_FreerouteURLName->GetValue() );
}
......
......@@ -94,11 +94,11 @@ wxString title;
Create(parent, id, caption, pos, size, style);
title = _("from ") + g_EDA_Appl->m_CurrentOptionFile;
title = _("from ") + wxGetApp().m_CurrentOptionFile;
SetTitle(title);
m_ListLibr->InsertItems(g_LibName_List, 0);
wxString DocModuleFileName =
g_EDA_Appl->m_EDA_CommonConfig->Read( wxT("module_doc_file"),
wxGetApp().m_EDA_CommonConfig->Read( wxT("module_doc_file"),
wxT("pcbnew/footprints.pdf"));
m_TextHelpModulesFileName->SetValue(DocModuleFileName);
}
......@@ -318,7 +318,7 @@ void KiConfigPcbnewFrame::SetNewOptions()
/********************************************/
{
g_UserLibDirBuffer = m_TextLibDir->GetValue();
g_EDA_Appl->m_EDA_CommonConfig->Write( wxT("module_doc_file"),
wxGetApp().m_EDA_CommonConfig->Write( wxT("module_doc_file"),
m_TextHelpModulesFileName->GetValue());
SetRealLibraryPath( wxT("modules") );
}
......
......@@ -4,8 +4,6 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "autorout.h"
......@@ -174,19 +172,18 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_OPEN_MODULE_EDITOR:
if( m_Parent->m_ModuleEditFrame == NULL )
if( m_ModuleEditFrame == NULL )
{
m_Parent->m_ModuleEditFrame =
m_ModuleEditFrame =
new WinEDA_ModuleEditFrame( this,
m_Parent, _( "Module Editor" ),
wxPoint( -1,
-1 ),
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
m_Parent->m_ModuleEditFrame->Show( TRUE );
m_Parent->m_ModuleEditFrame->Zoom_Automatique( TRUE );
m_ModuleEditFrame->Show( TRUE );
m_ModuleEditFrame->Zoom_Automatique( TRUE );
}
else
m_Parent->m_ModuleEditFrame->Iconize( FALSE );
m_ModuleEditFrame->Iconize( FALSE );
break;
case ID_NEW_PROJECT:
......@@ -382,7 +379,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_PLACE_MICROVIA:
if ( ! ((PCB_SCREEN*)GetScreen())->IsMicroViaAcceptable() )
if( !( (PCB_SCREEN*) GetScreen() )->IsMicroViaAcceptable() )
break;
case ID_POPUP_PCB_PLACE_VIA:
......@@ -399,7 +396,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
g_DesignSettings.m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay )
((PCB_SCREEN*)GetScreen())->SetRefreshReq();
( (PCB_SCREEN*) GetScreen() )->SetRefreshReq();
}
break;
......@@ -493,7 +490,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->m_CornerSelection, false );
Start_Move_Zone_Corner( &dc,
zone_cont,
zone_cont->m_CornerSelection,
false );
break;
}
......@@ -501,7 +501,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->m_CornerSelection );
Start_Move_Zone_Drag_Outline_Edge( &dc,
zone_cont,
zone_cont->m_CornerSelection );
break;
}
......@@ -524,10 +526,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
* and start move the new corner
*/
zone_cont->Draw( DrawPanel, &dc, GR_XOR );
zone_cont->m_Poly->InsertCorner( zone_cont->m_CornerSelection, pos.x, pos.y );
zone_cont->m_Poly->InsertCorner( zone_cont->m_CornerSelection,
pos.x,
pos.y );
zone_cont->m_CornerSelection++;
zone_cont->Draw( DrawPanel, &dc, GR_XOR );
Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->m_CornerSelection, true );
Start_Move_Zone_Corner( &dc,
zone_cont,
zone_cont->m_CornerSelection,
true );
break;
}
......@@ -542,15 +549,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ALL_ZONES:
DrawPanel->MouseToCursorSchema();
Fill_All_Zones( );
Fill_All_Zones();
break;
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE:
if ( ( GetCurItem())->Type() == TYPE_ZONE_CONTAINER)
if( ( GetCurItem() )->Type() == TYPE_ZONE_CONTAINER )
{
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER* )GetCurItem();
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
zone_container->m_FilledPolysList.clear();
test_1_net_connexion( NULL, zone_container->GetNet( ));
test_1_net_connexion( NULL, zone_container->GetNet() );
GetScreen()->SetModify();
DrawPanel->Refresh();
}
......@@ -563,6 +570,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
ZONE_CONTAINER* zone_container = m_Pcb->GetArea( ii );
zone_container->m_FilledPolysList.clear();;
}
test_connexions( NULL );
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links */
GetScreen()->SetModify();
......@@ -572,7 +580,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ZONE:
DrawPanel->MouseToCursorSchema();
Fill_Zone( NULL, (ZONE_CONTAINER*) GetCurItem() );
test_1_net_connexion( NULL, ((ZONE_CONTAINER* )GetCurItem())->GetNet( ));
test_1_net_connexion( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
DrawPanel->Refresh();
break;
......@@ -733,9 +741,10 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_LAYER:
itmp = SelectLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer, -1, -1 );
itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1, -1 );
if( itmp >= 0 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = itmp;
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
DrawPanel->MouseToCursorSchema();
break;
......@@ -744,16 +753,21 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
itmp = SelectLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer, FIRST_NO_COPPER_LAYER, -1 );
itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer,
FIRST_NO_COPPER_LAYER,
-1 );
if( itmp >= 0 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = itmp;
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
DrawPanel->MouseToCursorSchema();
break;
case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer, -1, LAST_COPPER_LAYER );
itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1,
LAST_COPPER_LAYER );
if( itmp >= 0 )
((PCB_SCREEN*)GetScreen())->m_Active_Layer = itmp;
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
break;
case ID_POPUP_PCB_SELECT_LAYER_PAIR:
......@@ -763,7 +777,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_TOOLBARH_PCB_SELECT_LAYER:
itmp = m_SelLayerBox->GetChoice();
((PCB_SCREEN*)GetScreen())->m_Active_Layer = (int) ( (size_t) m_SelLayerBox->GetClientData( itmp ) );
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer =
(int) ( (size_t) m_SelLayerBox->GetClientData( itmp ) );
if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh( TRUE );
break;
......@@ -870,7 +885,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_AUX_TOOLBAR_PCB_TRACK_WIDTH:
{
int ii = m_SelTrackWidthBox->GetChoice();
g_DesignSettings.m_CurrentTrackWidth = g_DesignSettings.m_TrackWidthHistory[ii];
g_DesignSettings.m_CurrentTrackWidth =
g_DesignSettings.m_TrackWidthHistory[ii];
DisplayTrackSettings();
m_SelTrackWidthBox_Changed = FALSE;
m_SelViaSizeBox_Changed = FALSE;
......@@ -890,13 +906,15 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
g_DesignSettings.m_UseConnectedTrackWidth = false;
{
int ii = id - ID_POPUP_PCB_SELECT_WIDTH1;
g_DesignSettings.m_CurrentTrackWidth = g_DesignSettings.m_TrackWidthHistory[ii];
g_DesignSettings.m_CurrentTrackWidth =
g_DesignSettings.m_TrackWidthHistory[ii];
DisplayTrackSettings();
}
break;
case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH:
g_DesignSettings.m_UseConnectedTrackWidth = not g_DesignSettings.m_UseConnectedTrackWidth;
g_DesignSettings.m_UseConnectedTrackWidth =
not g_DesignSettings.m_UseConnectedTrackWidth;
break;
case ID_POPUP_PCB_SELECT_AUTO_WIDTH:
......@@ -910,7 +928,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_AUX_TOOLBAR_PCB_VIA_SIZE:
{
int ii = m_SelViaSizeBox->GetChoice();
g_DesignSettings.m_CurrentViaSize = g_DesignSettings.m_ViaSizeHistory[ii];
g_DesignSettings.m_CurrentViaSize =
g_DesignSettings.m_ViaSizeHistory[ii];
DisplayTrackSettings();
m_SelTrackWidthBox_Changed = FALSE;
m_SelViaSizeBox_Changed = FALSE;
......@@ -989,7 +1008,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DISPLAY_FOOTPRINT_DOC:
{
wxString msg = FindKicadHelpPath();
msg += g_EDA_Appl->m_EDA_CommonConfig->Read( wxT( "module_doc_file" ),
msg += wxGetApp().m_EDA_CommonConfig->Read( wxT( "module_doc_file" ),
wxT( "pcbnew/footprints.pdf" ) );
GetAssociatedDocument( this, wxEmptyString, msg );
}
......@@ -1004,7 +1023,8 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_PcbFrame::Process_Special_Functions() id error" ) );
DisplayError( this,
wxT( "WinEDA_PcbFrame::Process_Special_Functions() id error" ) );
break;
}
......
......@@ -4,7 +4,6 @@
/************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
......@@ -26,35 +25,35 @@ bool GoToEditor = FALSE;
/*******************************************************************/
void WinEDA_BasePcbFrame::InstallModuleOptionsFrame( MODULE* Module,
wxDC* DC, const wxPoint& pos )
wxDC* DC,
const wxPoint& pos )
/*******************************************************************/
/* Fonction relai d'installation de la frame d'dition des proprietes
* du module*/
{
WinEDA_ModulePropertiesFrame* frame = new WinEDA_ModulePropertiesFrame( this,
Module, DC, pos );
WinEDA_ModulePropertiesFrame* frame =
new WinEDA_ModulePropertiesFrame( this, Module, DC, pos );
frame->ShowModal(); frame->Destroy();
if( GoToEditor && GetScreen()->GetCurItem() )
{
if( m_Parent->m_ModuleEditFrame == NULL )
if( m_ModuleEditFrame == NULL )
{
m_Parent->m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
m_Parent, _( "Module Editor" ),
wxPoint( -1,
-1 ),
m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
}
m_Parent->m_ModuleEditFrame->Load_Module_Module_From_BOARD(
m_ModuleEditFrame->Load_Module_Module_From_BOARD(
(MODULE*) GetScreen()->GetCurItem() );
SetCurItem( NULL );
GoToEditor = FALSE;
m_Parent->m_ModuleEditFrame->Show( TRUE );
m_Parent->m_ModuleEditFrame->Iconize( FALSE );
m_ModuleEditFrame->Show( TRUE );
m_ModuleEditFrame->Iconize( FALSE );
}
}
......@@ -75,7 +74,8 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod, wxDC* DC )
if( pt_mod == NULL )
return;
pt_mod->DrawAncre( DrawPanel, DC, wxPoint( 0, 0 ), DIM_ANCRE_MODULE, GR_XOR );
pt_mod->DrawAncre( DrawPanel, DC, wxPoint( 0, 0 ),
DIM_ANCRE_MODULE, GR_XOR );
deltaX = pt_mod->m_Pos.x - GetScreen()->m_Curseur.x;
deltaY = pt_mod->m_Pos.y - GetScreen()->m_Curseur.y;
......
......@@ -207,7 +207,7 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
/* This function displays and deletes the dialog frame for drill tools
*/
{
wxConfig* Config = m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( Config )
{
......@@ -233,7 +233,7 @@ void WinEDA_DrillFrame::UpdateConfig()
{
SetParams();
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( Config )
{
Config->Write( ZerosFormatKey, s_Zeros_Format );
......
......@@ -5,7 +5,6 @@
/* Fichier LIBRAIRI.CPP */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
......@@ -52,7 +51,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
bool Footprint_Is_GPCB_Format = false;
wxString mask = wxT("*.*;"); mask += EXT_CMP_MASK;
wxString LastOpenedPathForLoading;
wxConfig* Config = m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( Config )
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
......@@ -154,7 +153,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
char Line[1025];
FILE* dest;
wxString msg, path;
wxConfig* Config = m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( ptmod == NULL )
return;
......
......@@ -43,17 +43,14 @@ void WinEDA_ModuleEditFrame::Load_Module_Module_From_BOARD( MODULE* Module )
/***************************************************************************/
{
MODULE* NewModule;
WinEDA_BasePcbFrame* parent = (WinEDA_BasePcbFrame*) GetParent();
if( Module == NULL )
{
if( m_Parent->m_PcbFrame == NULL )
return;
if( m_Parent->m_PcbFrame->m_Pcb == NULL )
return;
if( m_Parent->m_PcbFrame->m_Pcb->m_Modules == NULL )
if( parent->m_Pcb == NULL || parent->m_Pcb->m_Modules == NULL )
return;
Module = Select_1_Module_From_BOARD( m_Parent->m_PcbFrame->m_Pcb );
Module = Select_1_Module_From_BOARD( parent->m_Pcb );
}
if( Module == NULL )
......
......@@ -167,7 +167,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
// Creation des selections des anciens fichiers
m_FilesMenu->AppendSeparator();
int max_file = m_Parent->m_LastProjectMaxCount;
int max_file = wxGetApp().m_LastProjectMaxCount;
for ( ii = 0; ii < max_file; ii++ )
{
if ( GetLastProject(ii).IsEmpty() ) break;
......@@ -201,7 +201,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
// Font selection and setup
AddFontSelectionMenu(configmenu);
m_Parent->SetLanguageList(configmenu);
wxGetApp().SetLanguageList(configmenu);
configmenu->AppendSeparator();
item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, _("&Save Preferences"),
......@@ -327,7 +327,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
else // simple mise a jour de la liste des fichiers anciens
{
wxMenuItem * item;
int max_file = m_Parent->m_LastProjectMaxCount;
int max_file = wxGetApp().m_LastProjectMaxCount;
for ( ii = max_file-1; ii >=0 ; ii-- )
{
if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) )
......
......@@ -247,7 +247,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{
// update module in the current board,
// not just add it to the board with total disregard for the netlist...
WinEDA_PcbFrame* pcbframe = m_Parent->m_PcbFrame;
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) GetParent();
BOARD* mainpcb = pcbframe->m_Pcb;
MODULE* source_module = NULL;
MODULE* module_in_edit = m_Pcb->m_Modules;
......
......@@ -146,14 +146,15 @@ END_EVENT_TABLE()
/****************/
WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
WinEDA_App* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
WinEDA_BasePcbFrame( father, parent, MODULE_EDITOR_FRAME,
WinEDA_BasePcbFrame( father, MODULE_EDITOR_FRAME,
wxEmptyString, pos, size, style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "ModEditFrame" );
m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines
m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee
......@@ -183,11 +184,11 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
GetSettings();
wxSize GridSize( 500, 500 );
if( m_Parent && m_Parent->m_EDA_Config )
if( config )
{
long SizeX, SizeY;
if( m_Parent->m_EDA_Config->Read( wxT( "ModEditGrid_X" ), &SizeX )
&& m_Parent->m_EDA_Config->Read( wxT( "ModEditGrid_Y" ), &SizeY ) )
if( config->Read( wxT( "ModEditGrid_X" ), &SizeX )
&& config->Read( wxT( "ModEditGrid_Y" ), &SizeY ) )
{
GridSize.x = SizeX;
GridSize.y = SizeY;
......@@ -211,7 +212,8 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
/****************************************************/
{
m_Parent->m_ModuleEditFrame = NULL;
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*)GetParent();
frame->m_ModuleEditFrame = NULL;
SetBaseScreen( ScreenPcb );
}
......@@ -220,6 +222,8 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
/**************************************************************/
{
wxConfig* config = wxGetApp().m_EDA_Config;
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Module Editor: Module modified! Continue?" ) ) )
......@@ -229,13 +233,11 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
}
SaveSettings();
if( m_Parent && m_Parent->m_EDA_Config )
if( config )
{
wxSize GridSize = GetScreen()->GetGrid();
m_Parent->m_EDA_Config->Write( wxT( "ModEditGrid_X" ),
(long) GridSize.x );
m_Parent->m_EDA_Config->Write( wxT( "ModEditGrid_Y" ),
(long) GridSize.y );
config->Write( wxT( "ModEditGrid_X" ), (long) GridSize.x );
config->Write( wxT( "ModEditGrid_Y" ), (long) GridSize.y );
}
Destroy();
}
......@@ -247,6 +249,7 @@ void WinEDA_ModuleEditFrame::SetToolbars()
{
size_t i;
bool active, islib = TRUE;
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) wxGetApp().GetTopWindow();
if( m_HToolBar == NULL )
return;
......@@ -269,8 +272,7 @@ void WinEDA_ModuleEditFrame::SetToolbars()
MODULE* module_in_edit = m_Pcb->m_Modules;
if( module_in_edit && module_in_edit->m_Link ) // this is not a new module ...
{
WinEDA_PcbFrame* pcbframe = m_Parent->m_PcbFrame;
BOARD* mainpcb = pcbframe->m_Pcb;
BOARD* mainpcb = frame->m_Pcb;
MODULE* source_module = mainpcb->m_Modules;
// search if the source module was not deleted:
......@@ -303,7 +305,7 @@ void WinEDA_ModuleEditFrame::SetToolbars()
m_HToolBar->EnableTool( ID_MODEDIT_REDO, GetScreen()->m_RedoList && active );
}
if( m_Parent->m_PcbFrame->m_Pcb->m_Modules )
if( frame->m_Pcb->m_Modules )
{
m_HToolBar->EnableTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, TRUE );
}
......
......@@ -12,7 +12,6 @@
#include "pcbcfg.h"
#include "worksheet.h"
#include "id.h"
#include "hotkeys_basic.h"
#include "hotkeys.h"
#include "protos.h"
......@@ -92,7 +91,9 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
WriteHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, true );
WriteHotkeyConfigFile( FullFileName,
s_Pcbnew_Editor_Hokeys_Descr,
true );
break;
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
......@@ -104,7 +105,7 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
AddDelimiterString(FullFileName);
AddDelimiterString( FullFileName );
wxString editorname = GetEditorName();
if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, FullFileName );
......@@ -121,7 +122,8 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
break;
default:
DisplayError( this, wxT( "WinEDA_PcbFrame::Process_Config internal error" ) );
DisplayError( this,
wxT( "WinEDA_PcbFrame::Process_Config internal error" ) );
}
}
......@@ -134,11 +136,14 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
* Read the hotkey files config for pcbnew and module_edit
*/
{
wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
wxString FullFileName = ReturnHotkeyConfigFilePath(
g_ConfigFileLocationChoice );
FullFileName += HOTKEY_FILENAME;
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
return frame->ReadHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose );
return frame->ReadHotkeyConfigFile( FullFileName,
s_Pcbnew_Editor_Hokeys_Descr,
verbose );
}
......@@ -164,7 +169,7 @@ bool Read_Config( const wxString& project_name )
/* Init des valeurs par defaut */
g_LibName_List.Clear();
g_EDA_Appl->ReadProjectConfig( FullFileName,
wxGetApp().ReadProjectConfig( FullFileName,
GROUP, ParamCfgList, FALSE );
/* Traitement des variables particulieres: */
......@@ -177,8 +182,10 @@ bool Read_Config( const wxString& project_name )
ScreenPcb->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER );
}
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
g_DesignSettings.m_TrackWidthHistory[0] =
g_DesignSettings.m_CurrentTrackWidth;
g_DesignSettings.m_ViaSizeHistory[0] =
g_DesignSettings.m_CurrentViaSize;
for( ii = 1; ii < HISTORY_NUMBER; ii++ )
{
g_DesignSettings.m_TrackWidthHistory[ii] = 0;
......@@ -216,5 +223,6 @@ void WinEDA_PcbFrame::Update_config( wxWindow* displayframe )
Pcbdiv_grille = GetScreen()->m_Diviseur_Grille;
/* ecriture de la configuration */
g_EDA_Appl->WriteProjectConfig( FullFileName, wxT( "/pcbnew" ), ParamCfgList );
wxGetApp().WriteProjectConfig( FullFileName, wxT( "/pcbnew" ),
ParamCfgList );
}
......@@ -191,12 +191,14 @@ END_EVENT_TABLE()
/* Constructeur */
/****************/
WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style ) :
WinEDA_BasePcbFrame( father, parent, PCB_FRAME, title, pos, size, style )
WinEDA_BasePcbFrame( father, PCB_FRAME, title, pos, size, style )
{
wxConfig* config = wxGetApp().m_EDA_Config;
m_FrameName = wxT( "PcbFrame" );
//m_AboutTitle = g_PcbnewAboutTitle;
m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines
......@@ -230,11 +232,10 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent,
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
wxSize GridSize( 500, 500 );
wxConfig * config = NULL;
if( m_Parent && m_Parent->m_EDA_Config )
if( config )
{
long SizeX, SizeY;
config = m_Parent->m_EDA_Config;
if( config->Read( wxT( "PcbEditGrid_X" ), &SizeX )
&& config->Read( wxT( "PcbEditGrid_Y" ), &SizeY ) )
......@@ -268,7 +269,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent,
WinEDA_PcbFrame::~WinEDA_PcbFrame()
/************************************/
{
m_Parent->m_PcbFrame = NULL;
SetBaseScreen( ScreenPcb );
delete m_drc;
......@@ -283,6 +283,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
/********************************************************/
{
PCB_SCREEN* screen;
wxConfig * config = wxGetApp().m_EDA_Config;
DrawPanel->m_AbortRequest = TRUE;
......@@ -331,9 +332,8 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
SetBaseScreen( ActiveScreen = ScreenPcb );
SaveSettings();
if( m_Parent && m_Parent->m_EDA_Config )
if( config )
{
wxConfig * config = m_Parent->m_EDA_Config;
wxSize GridSize = GetScreen()->GetGrid();
config->Write( wxT( "PcbEditGrid_X" ), (long) GridSize.x );
config->Write( wxT( "PcbEditGrid_Y" ), (long) GridSize.y );
......
......@@ -7,7 +7,6 @@
#include "fctsys.h"
#include <wx/image.h>
#include <wx/file.h>
#include "common.h"
......@@ -35,8 +34,8 @@ bool WinEDA_App::OnInit()
/****************************/
{
wxString FFileName;
WinEDA_PcbFrame* frame = NULL;
g_EDA_Appl = this;
InitEDA_Appl( wxT( "pcbnew" ) );
if( m_Checker && m_Checker->IsAnotherRunning() )
......@@ -56,9 +55,9 @@ bool WinEDA_App::OnInit()
Read_Config( FFileName );
g_DrawBgColor = BLACK;
Read_Hotkey_Config( m_PcbFrame, false ); /* Must be called before creating the main frame
* in order to display the real hotkeys
* in menus or tool tips */
Read_Hotkey_Config( frame, false ); /* Must be called before creating the
* main frame in order to display the
* real hotkeys in menus or tool tips */
/* allocation de la memoire pour le fichier et autres buffers: */
......@@ -72,29 +71,29 @@ bool WinEDA_App::OnInit()
printf( "No Memory, Fatal err Memory alloc\n" );
return FALSE;
}
m_PcbFrame = new WinEDA_PcbFrame( NULL, this, wxT( "PcbNew" ),
frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ),
wxPoint( 0, 0 ), wxSize( 600, 400 ) );
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
m_PcbFrame->SetTitle( Title );
frame->SetTitle( Title );
ActiveScreen = ScreenPcb;
SetTopWindow( m_PcbFrame );
m_PcbFrame->Show( TRUE );
SetTopWindow( frame );
frame->Show( TRUE );
if( CreateServer( m_PcbFrame, KICAD_PCB_PORT_SERVICE_NUMBER ) )
if( CreateServer( frame, KICAD_PCB_PORT_SERVICE_NUMBER ) )
{
SetupServerFunction( RemoteCommand );
}
m_PcbFrame->Zoom_Automatique( TRUE );
frame->Zoom_Automatique( TRUE );
/* Load file specified in the command line. */
if( !FFileName.IsEmpty() )
{
m_PcbFrame->LoadOnePcbFile( FFileName, FALSE );
frame->LoadOnePcbFile( FFileName, FALSE );
// update the layer names in the listbox
m_PcbFrame->ReCreateLayerBox( NULL );
frame->ReCreateLayerBox( NULL );
}
return TRUE;
......
......@@ -3,7 +3,6 @@
/***********************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "plot_common.h"
......@@ -166,7 +165,7 @@ void WinEDA_PlotFrame::OnInitDialog( wxInitDialogEvent& event )
BOARD* board = m_Parent->m_Pcb;
wxConfig* config = m_Parent->m_Parent->m_EDA_Config; // Current config used by application
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by application
SetFont( *g_DialogFont );
......@@ -607,7 +606,8 @@ void WinEDA_PlotFrame::SaveOptPlot( wxCommandEvent& event )
m_XScaleAdjust = m_FineAdjustXscaleOpt->GetValue();
m_YScaleAdjust = m_FineAdjustYscaleOpt->GetValue();
wxConfig* config = m_Parent->m_Parent->m_EDA_Config;
wxConfig* config = wxGetApp().m_EDA_Config;
if( config )
{
config->Write( OPTKEY_EDGELAYER_GERBER, g_Exclude_Edges_Pcb );
......
......@@ -6,7 +6,6 @@
#include <algorithm> // sort
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
......
......@@ -534,9 +534,9 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
zone->SetNetNameFromNetCode( );
}
m_Parent->m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefGapValue );
m_Parent->m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefCopperBridgeValue );
dialog_copper_zone* frame = new dialog_copper_zone( this, &g_Zone_Default_Setting );
......
......@@ -134,9 +134,9 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event )
break;
}
if( m_Parent->m_Parent->m_EDA_Config )
if( wxGetApp().m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
wxGetApp().m_EDA_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) g_Zone_Default_Setting.m_Zone_HatchingStyle );
}
......
......@@ -61,7 +61,7 @@ WinEDA_PrintFrame::WinEDA_PrintFrame( WinEDA_DrawFrame* parent, wxWindowID id, c
m_Parent = parent;
m_XScaleAdjust = m_YScaleAdjust = 1.0;
m_PagesOption = NULL;
wxConfig * Config = m_Parent->m_Parent->m_EDA_Config;
wxConfig * Config = wxGetApp().m_EDA_Config;
if ( Config )
{
Config->Read(wxT("PrintPenWidth"), &s_PrintPenMinWidth);
......
......@@ -39,10 +39,10 @@
/*******************************************************/
WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
WinEDA_App* parent, const wxString& title,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style ) :
WinEDA_BasicFrame( father, idtype, parent, title, pos, size, style )
WinEDA_BasicFrame( father, idtype, title, pos, size, style )
{
wxSize minsize;
......@@ -119,7 +119,7 @@ WinEDA_DrawFrame::~WinEDA_DrawFrame()
/****************************************/
{
if( DrawPanel ) // Required: in WinEDA3D_DrawFrame, DrawPanel == NULL !
m_Parent->m_EDA_Config->Write( wxT( "AutoPAN" ),
wxGetApp().m_EDA_Config->Write( wxT( "AutoPAN" ),
DrawPanel->m_AutoPAN_Enable );
}
......@@ -869,8 +869,8 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event )
{
int id = event.GetId();
m_Parent->SetLanguageIdentifier( id );
m_Parent->SetLanguage();
wxGetApp().SetLanguageIdentifier( id );
wxGetApp().SetLanguage();
}
......
......@@ -137,7 +137,7 @@ WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent,
{
m_Parent = parent;
m_ImageXSize_mm = 270;
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( Config )
{
Config->Read( PLOTSVGPENWIDTH_KEY, &s_SVGPenMinWidth );
......@@ -519,7 +519,7 @@ void WinEDA_PrintSVGFrame::OnCancelClick( wxCommandEvent& event )
void WinEDA_PrintSVGFrame::OnCloseWindow( wxCloseEvent& event )
{
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( Config )
{
......
......@@ -183,7 +183,7 @@ void WinEDA_PrintFrame::SetOthersDatas()
#endif
#if defined (PCBNEW)
wxConfig* config = m_Parent->m_Parent->m_EDA_Config; // Current config used by application
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by application
#endif
m_FineAdjustXscaleOpt->SetToolTip( _( "Set X scale adjust for exact scale plotting" ) );
......@@ -307,7 +307,7 @@ void WinEDA_PrintFrame::OnClosePrintDialog()
/* called when WinEDA_PrintFrame is closed
*/
{
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
wxConfig* Config = wxGetApp().m_EDA_Config;
if( Config )
{
......
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