KiCad PCB EDA Suite
dialog_choose_component.cpp File Reference
#include <dialog_choose_component.h>
#include <algorithm>
#include <set>
#include <wx/tokenzr.h>
#include <wx/utils.h>
#include <wx/artprov.h>
#include <wx/bitmap.h>
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/dataview.h>
#include <wx/html/htmlwin.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/splitter.h>
#include <wx/statbmp.h>
#include <wx/textctrl.h>
#include <wx/timer.h>
#include <class_library.h>
#include <generate_alias_info.h>
#include <sch_base_frame.h>
#include <template_fieldnames.h>
#include <widgets/footprint_preview_widget.h>
#include <widgets/footprint_select_widget.h>

Go to the source code of this file.

Functions

static wxDataViewItem GetPrevItem (const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
 
static wxDataViewItem GetNextItem (const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
 
static wxDataViewItem GetPrevSibling (const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
 
static wxDataViewItem GetNextSibling (const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
 

Function Documentation

static wxDataViewItem GetNextItem ( const wxDataViewCtrl &  ctrl,
const wxDataViewItem &  item 
)
static

Definition at line 550 of file dialog_choose_component.cpp.

References GetNextSibling().

Referenced by WIDGET_HOTKEY_LIST::CheckKeyConflicts(), DIALOG_CHOOSE_COMPONENT::OnQueryCharHook(), TWO_COLUMN_TREE_LIST::OnSize(), WIDGET_HOTKEY_LIST::TransferDataFromControl(), WIDGET_HOTKEY_LIST::TransferDefaultsToControl(), and WIDGET_HOTKEY_LIST::UpdateFromClientData().

551 {
552  wxDataViewItem nextItem;
553 
554  if( !item.IsOk() )
555  {
556  // No selection. Select the first.
557  wxDataViewItemArray children;
558  tree.GetModel()->GetChildren( item, children );
559  return children[0];
560  }
561 
562  if( tree.IsExpanded( item ) )
563  {
564  wxDataViewItemArray children;
565  tree.GetModel()->GetChildren( item, children );
566  nextItem = children[0];
567  }
568  else
569  {
570  // Walk up levels until we find one that has a next sibling.
571  for( wxDataViewItem walk = item; walk.IsOk(); walk = tree.GetModel()->GetParent( walk ) )
572  {
573  nextItem = GetNextSibling( tree, walk );
574 
575  if( nextItem.IsOk() )
576  break;
577  }
578  }
579 
580  return nextItem;
581 }
static wxDataViewItem GetNextSibling(const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
static wxDataViewItem GetNextSibling ( const wxDataViewCtrl &  ctrl,
const wxDataViewItem &  item 
)
static

Definition at line 607 of file dialog_choose_component.cpp.

Referenced by GetNextItem().

608 {
609  wxDataViewItemArray siblings;
610  wxDataViewItem invalid;
611  wxDataViewItem parent = tree.GetModel()->GetParent( item );
612 
613  tree.GetModel()->GetChildren( parent, siblings );
614 
615  for( size_t i = 0; i < siblings.size(); ++i )
616  {
617  if( siblings[i] == item )
618  {
619  if( i == siblings.size() - 1 )
620  return invalid;
621  else
622  return siblings[i + 1];
623  }
624  }
625 
626  return invalid;
627 }
static wxDataViewItem GetPrevItem ( const wxDataViewCtrl &  ctrl,
const wxDataViewItem &  item 
)
static

Definition at line 531 of file dialog_choose_component.cpp.

References GetPrevSibling().

Referenced by DIALOG_CHOOSE_COMPONENT::OnQueryCharHook().

532 {
533  auto prevItem = GetPrevSibling( tree, item );
534 
535  if( !prevItem.IsOk() )
536  {
537  prevItem = tree.GetModel()->GetParent( item );
538  }
539  else if( tree.IsExpanded( prevItem ) )
540  {
541  wxDataViewItemArray children;
542  tree.GetModel()->GetChildren( prevItem, children );
543  prevItem = children[children.size() - 1];
544  }
545 
546  return prevItem;
547 }
static wxDataViewItem GetPrevSibling(const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
static wxDataViewItem GetPrevSibling ( const wxDataViewCtrl &  ctrl,
const wxDataViewItem &  item 
)
static

Definition at line 584 of file dialog_choose_component.cpp.

Referenced by GetPrevItem().

585 {
586  wxDataViewItemArray siblings;
587  wxDataViewItem invalid;
588  wxDataViewItem parent = tree.GetModel()->GetParent( item );
589 
590  tree.GetModel()->GetChildren( parent, siblings );
591 
592  for( size_t i = 0; i < siblings.size(); ++i )
593  {
594  if( siblings[i] == item )
595  {
596  if( i == 0 )
597  return invalid;
598  else
599  return siblings[i - 1];
600  }
601  }
602 
603  return invalid;
604 }