OnLeftClick() test case

This commit is contained in:
dickelbeck 2007-09-26 20:10:12 +00:00
parent b128acfc17
commit b707a8336f
5 changed files with 53 additions and 37 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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();

View File

@ -89,16 +89,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
}
}
else
else /* if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
!wxGetKeyState(WXK_CONTROL) && !wxGetKeyState(WXK_TAB) ) */
{
if ( ! wxGetKeyState(WXK_SHIFT) && ! wxGetKeyState(WXK_ALT) &&
! wxGetKeyState(WXK_CONTROL) && ! wxGetKeyState(WXK_TAB))
{
DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
}
}
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;

View File

@ -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
{