Commit 2611a547 authored by stambaughw's avatar stambaughw
Browse files

Convert global and embedded application pointers to wxGetApp()

parent 0745188d
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -32,14 +32,16 @@ EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
    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_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;
+5 −5
Original line number Diff line number Diff line
@@ -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);
+8 −0
Original line number Diff line number Diff line
@@ -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
+41 −46
Original line number Diff line number Diff line
@@ -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 );
    }

+52 −50
Original line number Diff line number Diff line
@@ -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,7 +265,8 @@ 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 )
@@ -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 )
Loading