Commit b707a833 authored by dickelbeck's avatar dickelbeck
Browse files

OnLeftClick() test case

parent b128acfc
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -4,6 +4,19 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with 
email address.


2007-Sep-26 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+ all
    test case for OnLeftClick() handling from a release circumstance.
    a few simple changes to void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ),
    but they affect all programs in a subtle way.

+ pcbnew
    GENERAL_COLLECTOR::GetCount() returns int, not unsigned.  Was tired of the
    compiler complaining when using an int ndx.


2007-Sep-25 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
+3 −3
Original line number Diff line number Diff line
@@ -83,9 +83,9 @@ public:
     * Function GetCount
     * returns the number of objects in the list
     */
    unsigned GetCount() const
    int GetCount() const
    {
        return m_List.size();
        return (int) m_List.size();
    }

    
@@ -127,7 +127,7 @@ public:
     */
    EDA_BaseStruct* operator[]( int ndx ) const
    {
        if( (unsigned)ndx < GetCount() )
        if( (unsigned)ndx < (unsigned)GetCount() )  // (unsigned) excludes ndx<0 also
            return m_List[ ndx ];
        return NULL;
    }
+19 −13
Original line number Diff line number Diff line
@@ -161,14 +161,15 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )

    GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();

    // Assign to scanList the proper item types desired based on tool type.
    // May need to pass a hot key code to this function to support hot keys too.
    // Assign to scanList the proper item types desired based on tool type
    // or hotkey that is in play.

    const KICAD_T* scanList;

    if( aHotKeyCode )
    {
        // switch here
        // @todo: add switch here and add calls to PcbGeneralLocateAndDisplay( int aHotKeyCode )
        // when searching is needed from a hotkey handler
    }
    else if( m_ID_current_state == 0 )
    {
@@ -212,7 +213,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )

#if 0    
    // debugging: print out the collected items, showing their priority order too.
    for( unsigned i=0; i<m_Collector->GetCount();  ++i )
    for( int i=0; i<m_Collector->GetCount();  ++i )
        (*m_Collector)[i]->Show( 0, std::cout );
#endif    

@@ -221,8 +222,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
     */
    unsigned long timestampzone = 0;
    
    int limit = m_Collector->GetCount();
    for( int ii = 0;  ii < limit; ii++ )
    for( int ii = 0;  ii < m_Collector->GetCount(); ii++ )
    {
        item = (*m_Collector)[ii];
        if( item->Type() != TYPEZONE )
@@ -233,7 +233,6 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
        {
            m_Collector->Remove( ii );
            ii--;
			limit = m_Collector->GetCount();
        }
        else
            timestampzone = item->m_TimeStamp;
@@ -244,22 +243,23 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
        item = (*m_Collector)[0];
        SetCurItem( item );
    }
    
    // If the count is 2, and first item is a pad or moduletext, and the 2nd item is its parent module:
    else if( m_Collector->GetCount() == 2
             && ( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() ==
                 TYPETEXTEMODULE )
             && (*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()==
             (*m_Collector)[1] )
     && ( (*m_Collector)[0]->Type() == TYPEPAD || (*m_Collector)[0]->Type() == TYPETEXTEMODULE )
     && (*m_Collector)[1]->Type() == TYPEMODULE && (*m_Collector)[0]->GetParent()== (*m_Collector)[1] )
    {
        item = (*m_Collector)[0];
        SetCurItem( item );
    }
    
    // if all are modules, find the smallest one amoung the primary choices
    else if( ( item = AllAreModulesAndReturnSmallestIfSo( m_Collector ) ) != NULL )
    {
        SetCurItem( item );
    }
    else    // show a popup menu
    
    else    // we can't figure out which item user wants, do popup menu so user can choose
    {
        wxMenu itemMenu;

@@ -280,7 +280,13 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
            ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + i, text, xpm );
        }

        /* @todo: rather than assignment to TRUE, these should be increment and decrement operators throughout _everywhere_.
            That way we can handle nesting.
            But I tried that and found there cases where the assignment to TRUE (converted to a m_IgnoreMouseEvents++ )
            was not balanced with the -- (now m_IgnoreMouseEvents=FALSE), so I had to revert.  
            Somebody should track down these and make them balanced.
        DrawPanel->m_IgnoreMouseEvents = TRUE;
        */

        // this menu's handler is void WinEDA_BasePcbFrame::ProcessItemSelection()
        // and it calls SetCurItem() which in turn calls Display_Infos() on the item.
@@ -288,7 +294,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )

        DrawPanel->MouseToCursorSchema();

        DrawPanel->m_IgnoreMouseEvents = FALSE;
//        DrawPanel->m_IgnoreMouseEvents = FALSE;

        // The function ProcessItemSelection() has set the current item, return it.
        item = GetCurItem();
+11 −17
Original line number Diff line number Diff line
@@ -89,17 +89,15 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
                }
            }
        }
        else
        {
			if ( ! wxGetKeyState(WXK_SHIFT) && ! wxGetKeyState(WXK_ALT) &&
				! wxGetKeyState(WXK_CONTROL) && ! wxGetKeyState(WXK_TAB))
        
        else /* if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
                !wxGetKeyState(WXK_CONTROL) && !wxGetKeyState(WXK_TAB) ) */
        {
            DrawStruct = PcbGeneralLocateAndDisplay();
            if( DrawStruct )
                SendMessageToEESCHEMA( DrawStruct );
        }            
    }
    }
       
    switch( m_ID_current_state )
    {
@@ -1275,8 +1273,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
            }
            else if( DrawStruct->m_Flags == 0 )
            {
                Edit_TrackSegm_Width( DC,
                                      (TRACK*) DrawStruct );
                Edit_TrackSegm_Width( DC, (TRACK*) DrawStruct );
            }
            break;

@@ -1287,14 +1284,12 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
            break;

        case TYPEPAD:
            InstallPadOptionsFrame(
                (D_PAD*) DrawStruct, &dc, pos );
            InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos );
            DrawPanel->MouseToCursorSchema();
            break;

        case TYPEMODULE:
            InstallModuleOptionsFrame( (MODULE*) DrawStruct,
                                      &dc, pos );
            InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc, pos );
            DrawPanel->MouseToCursorSchema();
            break;

@@ -1304,8 +1299,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
            break;

        case TYPETEXTEMODULE:
            InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct,
                                       &dc, pos );
            InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos );
            DrawPanel->MouseToCursorSchema();
            break;

+7 −4
Original line number Diff line number Diff line
@@ -845,7 +845,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
    if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) )
        m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels );

    else if( event.LeftDown() )
    else if( event.LeftUp() &&  screen->BlockLocate.m_State==STATE_NO_BLOCK )
        m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );

    if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) )
@@ -902,12 +902,15 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
            if( screen->BlockLocate.m_State == STATE_NO_BLOCK )
            {
                int cmd_type = kbstat;
                
                if( event.MiddleIsDown() )
                    cmd_type |= MOUSE_MIDDLE;
                
                if( !m_Parent->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos ) )
                {   // error
                    m_Parent->DisplayToolMsg( wxT( "WinEDA_DrawPanel::OnMouseEvent() Block Error" )
                                              );
                {   
                    // error
                    m_Parent->DisplayToolMsg( 
                     wxT( "WinEDA_DrawPanel::OnMouseEvent() Block Error" ) );
                }
                else
                {