Commit ea40d26a authored by jean-pierre charras's avatar jean-pierre charras
Browse files

code cleaning.Minor enhancements. Fixed issues in microwave tools.

finished replacement of Get_Message (not very useful) by wxTextEntryDialog
parents 42022cfc 3c372703
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -639,7 +639,8 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
        if( wxTheClipboard->Open() )
        {
            if( !wxTheClipboard->SetData( dobjBmp ) )
                wxLogError( _T( "Failed to copy image to clipboard" ) );
                wxMessageBox( _( "Failed to copy image to clipboard" ) );

            wxTheClipboard->Flush();    /* the data in clipboard will stay
                                         * available after the
                                         * application exits */
@@ -653,7 +654,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
        if( !image.SaveFile( FullFileName,
                             fmt_is_jpeg ? wxBITMAP_TYPE_JPEG :
                             wxBITMAP_TYPE_PNG ) )
            wxLogError( wxT( "Can't save file" ) );
            wxMessageBox( _( "Can't save file" ) );

        image.Destroy();
    }
+0 −29
Original line number Diff line number Diff line
@@ -114,32 +114,3 @@ bool IsOK( wxWindow* parent, const wxString& text )
    return FALSE;
}

/* Get a text from user
 * Title = title to display
 * Buffer: enter text by user
 * Leading and trailing spaces are removed
 * Buffer is the initial text displayed, anr the returned text
 * Return:
 * 0 if OK
 * 1 if CANCEL
 */
int Get_Message( const wxString& title,           // The question
                 const wxString& frame_caption,   // The frame caption
                 wxString& buffer,                // String input/return buffer
                 wxWindow* frame )
{
    wxString message;

    message = wxGetTextFromUser( title, frame_caption,
                                 buffer, frame );
    if( !message.IsEmpty() )
    {
        message.Trim( FALSE );      // Remove blanks at beginning
        message.Trim( TRUE );       // Remove blanks at end
        buffer = message;
        return 0;
    }

    return 1;
}
+1 −1
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
    if( m_ListLibr->GetCount() > 0 && selections.GetCount() > 0 )
    {
        int pos = selections[selections.GetCount()-1];
        if( pos == m_ListLibr->GetCount() )
        if( pos == (int)m_ListLibr->GetCount() )
            pos = m_ListLibr->GetCount() - 1;
        m_ListLibr->SetSelection( pos );
    }
+17 −11
Original line number Diff line number Diff line
@@ -228,7 +228,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
 *  New name cannot be the root name, and must not exists
 */
{
    wxString Line;
    wxString aliasname;
    LIB_COMPONENT* component = m_Parent->GetComponent();
    CMP_LIBRARY* library = m_Parent->GetLibrary();
@@ -236,12 +235,15 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
    if( component == NULL )
        return;

    if( Get_Message( _( "New alias:" ),
                     _( "Component Alias" ), Line, this ) != 0 )
        return;
    wxTextEntryDialog dlg( this, _( "New alias:" ), _( "Component Alias" ), aliasname );
    if( dlg.ShowModal() != wxID_OK )
        return; // cancelled by user

    Line.Replace( wxT( " " ), wxT( "_" ) );
    aliasname = Line;
    aliasname = dlg.GetValue( );

    aliasname.Replace( wxT( " " ), wxT( "_" ) );
    if( aliasname.IsEmpty() )
        return;

    if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND
        || library->FindEntry( aliasname ) != NULL )
@@ -405,8 +407,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter(
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************************/

/* Add a new name to the alias list box
 *  New name cannot be the root name, and must not exists
/* Add a new name to the footprint filter list box
 * Obvioulsy, cannot be void
 */
{
    wxString Line;
@@ -415,12 +417,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
    if( component == NULL )
        return;

    if( Get_Message( _( "Add Footprint Filter" ), _( "Footprint Filter" ),
                     Line, this ) != 0 )
        return;
    wxTextEntryDialog dlg( this, _( "Add Footprint Filter" ), _( "Footprint Filter" ), Line );
    if( dlg.ShowModal() != wxID_OK )
        return; // cancelled by user

    Line = dlg.GetValue( );
    Line.Replace( wxT( " " ), wxT( "_" ) );

    if( Line.IsEmpty() )
        return;

    /* test for an existing name: */
    int index = m_FootprintFilterListBox->FindString( Line );

+31 −6
Original line number Diff line number Diff line
@@ -128,9 +128,17 @@ modified!\nYou must create a new power" ) );

    wxString newtext = Field->m_Text;
    DrawPanel->m_IgnoreMouseEvents = TRUE;
    Get_Message( Field->m_Name, _( "Component field text" ), newtext, this );

    wxTextEntryDialog dlg( this, Field->m_Name, _( "Component field text" ), newtext );
    int diag = dlg.ShowModal();
    newtext = dlg.GetValue( );
    newtext.Trim( true );
    newtext.Trim( false );

    DrawPanel->MouseToCursorSchema();
    DrawPanel->m_IgnoreMouseEvents = FALSE;
    if ( diag != wxID_OK )
        return;  // cancelled by user

    Field->m_AddExtraText = flag;
    Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
@@ -295,7 +303,13 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
        flag = 1;

    wxString ref = Cmp->GetRef( GetSheet() );
    Get_Message( _( "Reference" ), _( "Component reference" ), ref, this );
    wxTextEntryDialog dlg( this, _( "Reference" ), _( "Component reference" ), ref );
    if( dlg.ShowModal() != wxID_OK )
        return; // cancelled by user

    ref = dlg.GetValue( );
    ref.Trim( true );
    ref.Trim( false );

    if( !ref.IsEmpty() ) // New text entered
    {
@@ -335,8 +349,14 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
    SCH_FIELD* TextField = Cmp->GetField( VALUE );

    message = TextField->m_Text;
    if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
        message.Empty();  //allow the user to remove the value.

    wxTextEntryDialog dlg( this,  _( "Value" ), _( "Component value" ), message );
    if( dlg.ShowModal() != wxID_OK )
        return; // cancelled by user

    message = dlg.GetValue( );
    message.Trim( true );
    message.Trim( false );

    if( !message.IsEmpty() )
    {
@@ -371,8 +391,13 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
    SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT );
    message = TextField->m_Text;

    if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message, this ) )
        return;    // edition cancelled by user.
    wxTextEntryDialog dlg( this, _( "Footprint" ), _( "Component footprint" ), message );
    if( dlg.ShowModal() != wxID_OK )
        return; // cancelled by user

    message = dlg.GetValue( );
    message.Trim( true );
    message.Trim( false );

    bool wasEmpty = false;
    if( TextField->m_Text.IsEmpty() )
Loading