Commit 991926d3 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

Modular-Kicad milestone B), major portions:

*) Rework the set language support, simplify it by using KIWAY.  Now any major
   frame with a "change language" menu can change the language for all KIWAY_PLAYERs
   in the whole KIWAY.  Multiple KIWAYs are not supported yet.

*) Simplify "modal wxFrame" support, and add that support exclusively to
   KIWAY_PLAYER where it is inherited by all derivatives.  The function
   KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.

*) Remove the requirements and assumptions that the wxFrame hierarchy always
   had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
   and editors. This is no longer the case, nor required.

*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
   KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
   quickly.  It also gives control to the KIWAY as to frame hierarchical
   relationships.

*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
   the single KIWAY_PLAYER, see bullet immediately above.

*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
   gives the KIFACEs a chance to save their final configuration dope to disk.

*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
   these modal frames are distinctly different than their non-modal equivalents.
   KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
   so this is another important reason for having a dedicated FRAME_T for each
   modal wxFrame.

On balance, more lines were deleted than were added to achieve all this.
parent 5688a872
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ set( BITMAP2COMPONENT_SRCS
    )

set_source_files_properties( ../common/single_top.cpp PROPERTIES
    COMPILE_DEFINITIONS     "TOP_FRAME=0"
    COMPILE_DEFINITIONS     "TOP_FRAME=FRAME_BM2CMP"
    )
set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
    COMPILE_DEFINITIONS     "COMPILING_DLL"
+1 −29
Original line number Diff line number Diff line
@@ -169,12 +169,8 @@ void EDA_BASE_FRAME::ReCreateMenuBar()
}


void EDA_BASE_FRAME::SetLanguage( wxCommandEvent& event )
void EDA_BASE_FRAME::ShowChangedLanguage()
{
    int id = event.GetId();

    Pgm().SetLanguageIdentifier( id );
    Pgm().SetLanguage();
    ReCreateMenuBar();
    GetMenuBar()->Refresh();
}
@@ -717,27 +713,3 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
    }
}

void EDA_BASE_FRAME::SetModalMode( bool aModal )
{
    // Disable all other windows
#if wxCHECK_VERSION(2, 9, 4)
    if( IsTopLevel() )
    {
        wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();

        while( node )
        {
            wxWindow* win = node->GetData();

            if( win != this )
                win->Enable( !aModal );

            node = node->GetNext();
        }
    }
#else
    // Deprecated since wxWidgets 2.9.4
    MakeModal( aModal );
#endif
}
+1 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
    // First easy thing: a black gives always the other colour
    if( aColor1 == BLACK )
        return aColor2;

    if( aColor2 == BLACK)
        return aColor1;

+0 −6
Original line number Diff line number Diff line
@@ -556,12 +556,6 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
}


void EDA_DRAW_FRAME::SetLanguage( wxCommandEvent& event )
{
    EDA_BASE_FRAME::SetLanguage( event );
}


void EDA_DRAW_FRAME::UpdateStatusBar()
{
    wxString        Line;
+14 −27
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ const char* EndsWithRev( const char* start, const char* tail, char separator )
}


#if 0   // Not used
int RevCmp( const char* s1, const char* s2 )
{
    int r = strncmp( s1, s2, 3 );
@@ -76,6 +77,7 @@ int RevCmp( const char* s1, const char* s2 )

    return -(rnum1 - rnum2);    // swap the sign, higher revs first
}
#endif

//----<Policy and field test functions>-------------------------------------

@@ -116,7 +118,7 @@ void FPID::clear()
}


int FPID::Parse( const std::string& aId )
int FPID::Parse( const UTF8& aId )
{
    clear();

@@ -171,12 +173,6 @@ int FPID::Parse( const std::string& aId )
}


int FPID::Parse( const wxString& aId )
{
    return Parse( std::string( TO_UTF8( aId ) ) );
}


FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
{
    int offset = Parse( aId );
@@ -194,14 +190,14 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )

FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
{
    std::string id = TO_UTF8( aId );
    UTF8 id = aId;

    int offset = Parse( id );

    if( offset != -1 )
    {
        THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
                           wxString::FromUTF8( id.c_str() ),
                           aId,
                           id.c_str(),
                           0,
                           offset );
@@ -209,7 +205,7 @@ FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
}


int FPID::SetLibNickname( const std::string& aLogical )
int FPID::SetLibNickname( const UTF8& aLogical )
{
    int offset = okLogical( aLogical );

@@ -222,13 +218,7 @@ int FPID::SetLibNickname( const std::string& aLogical )
}


int FPID::SetLibNickname( const wxString& aLogical )
{
    return SetLibNickname( std::string( TO_UTF8( aLogical ) ) );
}


int FPID::SetFootprintName( const std::string& aFootprintName )
int FPID::SetFootprintName( const UTF8& aFootprintName )
{
    int separation = int( aFootprintName.find_first_of( "/" ) );

@@ -246,13 +236,7 @@ int FPID::SetFootprintName( const std::string& aFootprintName )
}


int FPID::SetFootprintName( const wxString& aFootprintName )
{
    return SetFootprintName( std::string( TO_UTF8( aFootprintName ) ) );
}


int FPID::SetRevision( const std::string& aRevision )
int FPID::SetRevision( const UTF8& aRevision )
{
    int offset = okRevision( aRevision );

@@ -301,8 +285,10 @@ UTF8 FPID::GetFootprintNameAndRev() const
}


UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprintName,
                          const std::string& aRevision )
#if 0   // this is broken, it does not output aFootprintName for some reason

UTF8 FPID::Format( const UTF8& aLogicalLib, const UTF8& aFootprintName,
                          const UTF8& aRevision )
    throw( PARSE_ERROR )
{
    UTF8    ret;
@@ -344,6 +330,7 @@ UTF8 FPID::Format( const std::string& aLogicalLib, const std::string& aFootprint

    return ret;
}
#endif


int FPID::compare( const FPID& aFPID ) const
Loading