Commit 60b16714 authored by Henner Zeller's avatar Henner Zeller Committed by jean-pierre charras

Eeschema: Better naming for private struct: public fields uppercase.

* make some more fields 'const' that can.
* Instead of previous/next _visible_ element, Go through
      previous and next element. Otherwise the cursor stops moving
      if the item is only partially visible.
parent 31fea1e7
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
#include <component_tree_search_container.h> #include <component_tree_search_container.h>
#include <sch_base_frame.h> #include <sch_base_frame.h>
// Work-around broken implementation in wxWidgets <=2.8 tree. // Tree navigation helpers.
static wxTreeItemId fixedGetPrevVisible( const wxTreeCtrl& tree, const wxTreeItemId& item ); static wxTreeItemId GetPrevItem( const wxTreeCtrl& tree, const wxTreeItemId& item );
static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& item );
// Combine descriptions of all aliases from given component. // Combine descriptions of all aliases from given component.
static wxString combineDescriptions( LIB_COMPONENT* aComponent ) static wxString combineDescriptions( LIB_COMPONENT* aComponent )
...@@ -132,11 +133,11 @@ void DIALOG_CHOOSE_COMPONENT::OnInterceptSearchBoxKey( wxKeyEvent& aKeyStroke ) ...@@ -132,11 +133,11 @@ void DIALOG_CHOOSE_COMPONENT::OnInterceptSearchBoxKey( wxKeyEvent& aKeyStroke )
switch ( aKeyStroke.GetKeyCode() ) switch ( aKeyStroke.GetKeyCode() )
{ {
case WXK_UP: case WXK_UP:
SelectIfValid( fixedGetPrevVisible( *m_libraryComponentTree, sel ) ); SelectIfValid( GetPrevItem( *m_libraryComponentTree, sel ) );
break; break;
case WXK_DOWN: case WXK_DOWN:
SelectIfValid( m_libraryComponentTree->GetNextVisible( sel ) ); SelectIfValid( GetNextItem( *m_libraryComponentTree, sel ) );
break; break;
default: default:
...@@ -230,46 +231,29 @@ void DIALOG_CHOOSE_COMPONENT::updateSelection() ...@@ -230,46 +231,29 @@ void DIALOG_CHOOSE_COMPONENT::updateSelection()
m_componentDetails->SetInsertionPoint( 0 ); // scroll up. m_componentDetails->SetInsertionPoint( 0 ); // scroll up.
} }
static wxTreeItemId GetPrevItem( const wxTreeCtrl& tree, const wxTreeItemId& item )
// The GetPrevVisible() method is broken in at least 2.8 wxWidgets. This is mostly copied
// verbatim from the latest 3.x source in which this is fixed.
// ( wxWidgets/src/generic/treectlg.cpp )
static wxTreeItemId fixedGetPrevVisible( const wxTreeCtrl& tree, const wxTreeItemId& item )
{ {
#if wxCHECK_VERSION( 3, 0, 0 ) wxTreeItemId prevItem = tree.GetPrevSibling( item );
return tree.GetPrevVisible(item);
#else
// find out the starting point
wxTreeItemId prevItem = tree.GetPrevSibling(item);
if ( !prevItem.IsOk() ) if ( !prevItem.IsOk() )
{ {
prevItem = tree.GetItemParent(item); const wxTreeItemId parent = tree.GetItemParent( item );
prevItem = tree.GetLastChild( tree.GetPrevSibling( parent ) );
} }
// find the first visible item after it return prevItem;
while ( prevItem.IsOk() && !tree.IsVisible(prevItem) ) }
{
prevItem = tree.GetNext(prevItem);
if ( !prevItem.IsOk() || prevItem == item ) static wxTreeItemId GetNextItem( const wxTreeCtrl& tree, const wxTreeItemId& item )
{ {
// there are no visible items before item wxTreeItemId nextItem = tree.GetNextSibling( item );
return wxTreeItemId();
}
}
// from there we must be able to navigate until this item if ( !nextItem.IsOk() )
while ( prevItem.IsOk() )
{ {
const wxTreeItemId nextItem = tree.GetNextVisible(prevItem); const wxTreeItemId parent = tree.GetItemParent( item );
wxTreeItemIdValue dummy;
if ( !nextItem.IsOk() || nextItem == item ) nextItem = tree.GetFirstChild( tree.GetNextSibling( parent ), dummy );
break;
prevItem = nextItem;
} }
return prevItem; return nextItem;
#endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment