Commit cb647737 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Improve handling of tool bar command IDs.

* Make EDA_DRAW_FRAME current tool ID member variable private.
* Added global no tool selected ID to replace application specific no
  tool selected IDs.
* Change SetToolID to prevent setting the tool ID to anything less than
  the new global no tool selected ID and assert on debug builds.
* Change command and update user interface command event handlers to use
  new global no tool selected ID.
* Fixed schematic library editor add pin hot key handler.
parent c303d3f8
Loading
Loading
Loading
Loading
+6 −17
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
    DrawPanel             = NULL;
    MsgPanel              = NULL;
    m_currentScreen       = NULL;
    m_ID_current_state    = 0;
    m_ID_last_state       = 0;
    m_toolId              = ID_NO_TOOL_SELECTED;
    m_ID_last_state       = ID_NO_TOOL_SELECTED;
    m_HTOOL_current_state = 0;
    m_Draw_Axis           = FALSE;  // TRUE to draw axis.
    m_Draw_Sheet_Ref      = FALSE;  // TRUE to display reference sheet.
@@ -434,20 +434,6 @@ void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
}


/**
 * Function SetToolID
 * Enables the icon of the selected tool in the vertical toolbar.
 * (Or tool ID_NO_SELECT_BUTT default if no new selection)
 * @param aId = new m_ID_current_state value (if aId >= 0)
 * @param aCursor = the new cursor shape (0 = default cursor)
 * @param aToolMsg = tool message in status bar
 * if (aId >= 0)
 * Updates all variables related:
 *      m_ID_current_state, cursor shape and message in status bar
 * If (aId < 0)
 *      Only updates the cursor shape and message in status bar
 *      (does not the current m_ID_current_state value
 */
void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
{
    // Keep default cursor in toolbars
@@ -462,7 +448,10 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
    if( aId < 0 )
        return;

    m_ID_current_state = aId;
    wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
                  wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );

    m_toolId = aId;
}


+2 −1
Original line number Diff line number Diff line
@@ -1108,7 +1108,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
        if( IsMouseCaptured() )
            EndMouseCapture( -1, m_defaultCursor );
        else
            EndMouseCapture( 0, m_cursor, wxEmptyString );
            EndMouseCapture( ID_NO_TOOL_SELECTED, m_cursor, wxEmptyString );

        break;
    }
@@ -1206,6 +1206,7 @@ void EDA_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title
        INSTALL_UNBUFFERED_DC( dc, this );
        m_endMouseCaptureCallback( this, &dc );
    }

    m_mouseCaptureCallback = NULL;
    m_endMouseCaptureCallback = NULL;
    m_AutoPAN_Request = false;
+3 −3
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
    }

    DrawPanel->SetMouseCapture( NULL, NULL );
    SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
    SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
    DrawPanel->Refresh();
}

@@ -317,7 +317,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
        block->m_Command = BLOCK_IDLE;
        GetScreen()->SetCurItem( NULL );
        DrawPanel->SetMouseCapture( NULL, NULL );
        SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
        SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
    }

    if( zoom_command )
@@ -479,7 +479,7 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
        block->Clear();
        GetScreen()->SetCurItem( NULL );
        DrawPanel->SetMouseCapture( NULL, NULL );
        SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
        SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
    }
}

+2 −2
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
        GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
        GetScreen()->SetCurItem( NULL );
        DrawPanel->SetMouseCapture( NULL, NULL );
        SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
        SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
        DrawPanel->Refresh( true );
    }

@@ -269,7 +269,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
    GetScreen()->SetCurItem( NULL );
    DrawPanel->SetMouseCapture( NULL, NULL );
    DrawPanel->Refresh( true );
    SetToolID( m_ID_current_state, DrawPanel->GetDefaultCursor(), wxEmptyString );
    SetToolID( GetToolId(), DrawPanel->GetDefaultCursor(), wxEmptyString );
}


+2 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include "confirm.h"
#include "class_drawpanel.h"
#include "wxEeschemaStruct.h"
#include "id.h"

#include "general.h"
#include "protos.h"
@@ -109,7 +110,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
    if( m_component == NULL )
        return;

    DrawPanel->EndMouseCapture( 0, DrawPanel->GetDefaultCursor() );
    DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );

    DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component );

Loading