KiCad PCB EDA Suite
NET_SELECTOR_COMBOPOPUP Class Reference
Inheritance diagram for NET_SELECTOR_COMBOPOPUP:

Public Member Functions

 NET_SELECTOR_COMBOPOPUP ()
 
bool Create (wxWindow *aParent) override
 
wxWindow * GetControl () override
 
void SetStringValue (const wxString &aNetName) override
 
wxString GetStringValue () const override
 
void SetNetInfo (NETINFO_LIST *aNetInfoList)
 
void SetIndeterminateLabel (const wxString &aIndeterminateLabel)
 
void SetBoard (BOARD *aBoard)
 
void SetIndeterminate ()
 
bool IsIndeterminate ()
 
void SetSelectedNetcode (int aNetcode)
 
int GetSelectedNetcode ()
 
void SetSelectedNet (const wxString &aNetname)
 
wxString GetSelectedNetname ()
 
wxSize GetAdjustedSize (int aMinWidth, int aPrefHeight, int aMaxHeight) override
 
void OnPopup () override
 
void OnStartingKey (wxKeyEvent &aEvent)
 
void Accept ()
 

Protected Member Functions

wxSize updateSize ()
 
void rebuildList ()
 
void onIdle (wxIdleEvent &aEvent)
 
void onMouseMoved (const wxPoint aScreenPos)
 
void onMouseClick (wxMouseEvent &aEvent)
 
void onKeyDown (wxKeyEvent &aEvent)
 
void onEnter (wxCommandEvent &aEvent)
 
void onFilterEdit (wxCommandEvent &aEvent)
 
void doStartingKey (wxKeyEvent &aEvent)
 
void doSetFocus (wxWindow *aWindow)
 

Protected Attributes

wxTextValidator * m_filterValidator
 
wxTextCtrl * m_filterCtrl
 
wxListBox * m_listBox
 
int m_minPopupWidth
 
int m_maxPopupHeight
 
NETINFO_LISTm_netinfoList
 
wxString m_indeterminateLabel
 
BOARDm_board
 
int m_selectedNetcode
 
std::map< wxString, wxString > m_unescapedNetNameMap
 
wxEvtHandler * m_focusHandler
 

Detailed Description

Definition at line 62 of file net_selector.cpp.

Constructor & Destructor Documentation

◆ NET_SELECTOR_COMBOPOPUP()

NET_SELECTOR_COMBOPOPUP::NET_SELECTOR_COMBOPOPUP ( )
inline

Definition at line 65 of file net_selector.cpp.

65  :
66  m_filterValidator( nullptr ),
67  m_filterCtrl( nullptr ),
68  m_listBox( nullptr ),
69  m_minPopupWidth( -1 ),
70  m_maxPopupHeight( 1000 ),
71  m_netinfoList( nullptr ),
72  m_board( nullptr ),
73  m_selectedNetcode( 0 ),
74  m_focusHandler( nullptr )
75  { }
wxTextValidator * m_filterValidator
wxEvtHandler * m_focusHandler
NETINFO_LIST * m_netinfoList

Member Function Documentation

◆ Accept()

void NET_SELECTOR_COMBOPOPUP::Accept ( )
inline

Definition at line 198 of file net_selector.cpp.

199  {
200  wxString selectedNetName;
201  wxString escapedNetName;
202  wxString remainingName;
203  int selection = m_listBox->GetSelection();
204  wxString prefix = CREATE_NET;
205 
206  if( selection >= 0 )
207  selectedNetName = m_listBox->GetString( (unsigned) selection );
208 
209  auto it = m_unescapedNetNameMap.find( selectedNetName );
210 
211  if( it != m_unescapedNetNameMap.end() )
212  escapedNetName = it->second;
213  else // shouldn't happen....
214  escapedNetName = selectedNetName;
215 
216  Dismiss();
217 
218  if( escapedNetName.IsEmpty() || escapedNetName == m_indeterminateLabel )
219  {
220  m_selectedNetcode = -1;
221  GetComboCtrl()->SetValue( m_indeterminateLabel );
222  }
223  else if( escapedNetName == NO_NET )
224  {
225  m_selectedNetcode = 0;
226  GetComboCtrl()->SetValue( NO_NET );
227  }
228  else if( escapedNetName.StartsWith( CREATE_NET, &remainingName ) &&
229  !remainingName.IsEmpty() )
230  {
231  // Remove the first character ':' and all whitespace
232  remainingName = remainingName.Mid( 1 ).Trim().Trim( false );
233 
234  BOARD* board = m_netinfoList->GetParent();
235  NETINFO_ITEM *newnet = new NETINFO_ITEM( m_board, remainingName, 0 );
236 
237  // add the new netinfo through the board's function so that
238  // board listeners get notified and things stay in sync.
239  if( board != nullptr )
240  board->Add( newnet );
241  else
242  m_netinfoList->AppendNet( newnet );
243 
244  rebuildList();
245 
246  if( newnet->GetNetCode() > 0 )
247  {
248  m_selectedNetcode = newnet->GetNetCode();
249  GetComboCtrl()->SetValue( UnescapeString( remainingName ) );
250  }
251  else
252  {
253  // This indicates that the NETINFO_ITEM was not successfully appended
254  // to the list for unknown reasons
255  if( board != nullptr )
256  board->Remove( newnet );
257  else
258  m_netinfoList->RemoveNet( newnet );
259 
260  delete newnet;
261  }
262  }
263  else
264  {
265  NETINFO_ITEM* netInfo = m_netinfoList->GetNetItem( escapedNetName );
266 
267  if( netInfo == nullptr || netInfo->GetNetCode() == 0 )
268  {
269  m_selectedNetcode = 0;
270  GetComboCtrl()->SetValue( NO_NET );
271  }
272  else
273  {
274  m_selectedNetcode = netInfo->GetNetCode();
275  GetComboCtrl()->SetValue( UnescapeString( escapedNetName ) );
276  }
277  }
278 
279  wxCommandEvent changeEvent( NET_SELECTED );
280  wxPostEvent( GetComboCtrl(), changeEvent );
281  }
#define CREATE_NET
BOARD * GetParent() const
Definition: netinfo.h:454
NETINFO_LIST * m_netinfoList
std::map< wxString, wxString > m_unescapedNetNameMap
void AppendNet(NETINFO_ITEM *aNewElement)
Add aNewElement to the end of the net list.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
void RemoveNet(NETINFO_ITEM *aNet)
Remove a net from the net list.
#define NO_NET
wxString UnescapeString(const wxString &aSource)
Handle the data for a net.
Definition: netinfo.h:66
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:710
NETINFO_ITEM * GetNetItem(int aNetCode) const
int GetNetCode() const
Definition: netinfo.h:120

References BOARD::Add(), NETINFO_LIST::AppendNet(), CREATE_NET, NETINFO_ITEM::GetNetCode(), NETINFO_LIST::GetNetItem(), NETINFO_LIST::GetParent(), m_board, m_indeterminateLabel, m_listBox, m_netinfoList, m_selectedNetcode, m_unescapedNetNameMap, NO_NET, rebuildList(), BOARD::Remove(), NETINFO_LIST::RemoveNet(), and UnescapeString().

Referenced by onEnter(), onKeyDown(), and onMouseClick().

◆ Create()

bool NET_SELECTOR_COMBOPOPUP::Create ( wxWindow *  aParent)
inlineoverride

Definition at line 77 of file net_selector.cpp.

78  {
79  wxPanel::Create( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER );
80 
81  wxBoxSizer* mainSizer;
82  mainSizer = new wxBoxSizer( wxVERTICAL );
83 
84  wxStaticText* filterLabel = new wxStaticText( this, wxID_ANY, _( "Filter:" ) );
85  mainSizer->Add( filterLabel, 0, wxEXPAND, 0 );
86 
87  m_filterCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition,
88  wxDefaultSize, wxTE_PROCESS_ENTER );
89  m_filterValidator = new wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST );
90  m_filterValidator->SetCharExcludes( " " );
91  m_filterCtrl->SetValidator( *m_filterValidator );
92  mainSizer->Add( m_filterCtrl, 0, wxEXPAND, 0 );
93 
94  m_listBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr,
95  wxLB_SINGLE|wxLB_NEEDED_SB );
96  mainSizer->Add( m_listBox, 0, wxEXPAND|wxTOP, 2 );
97 
98  SetSizer( mainSizer );
99  Layout();
100 
101  Connect( wxEVT_IDLE, wxIdleEventHandler( NET_SELECTOR_COMBOPOPUP::onIdle ), nullptr, this );
102  Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( NET_SELECTOR_COMBOPOPUP::onKeyDown ), nullptr, this );
103  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( NET_SELECTOR_COMBOPOPUP::onMouseClick ), nullptr, this );
104  m_listBox->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( NET_SELECTOR_COMBOPOPUP::onMouseClick ), nullptr, this );
105  m_filterCtrl->Connect( wxEVT_TEXT, wxCommandEventHandler( NET_SELECTOR_COMBOPOPUP::onFilterEdit ), nullptr, this );
106  m_filterCtrl->Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( NET_SELECTOR_COMBOPOPUP::onEnter ), nullptr, this );
107 
108  // <enter> in a ListBox comes in as a double-click on GTK
109  m_listBox->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( NET_SELECTOR_COMBOPOPUP::onEnter ), nullptr, this );
110 
111  return true;
112  }
void onIdle(wxIdleEvent &aEvent)
void onFilterEdit(wxCommandEvent &aEvent)
wxTextValidator * m_filterValidator
void onKeyDown(wxKeyEvent &aEvent)
#define _(s)
void onEnter(wxCommandEvent &aEvent)
void onMouseClick(wxMouseEvent &aEvent)

References _, m_filterCtrl, m_filterValidator, m_listBox, onEnter(), onFilterEdit(), onIdle(), onKeyDown(), and onMouseClick().

◆ doSetFocus()

void NET_SELECTOR_COMBOPOPUP::doSetFocus ( wxWindow *  aWindow)
inlineprotected

Definition at line 531 of file net_selector.cpp.

532  {
533  KIPLATFORM::UI::ForceFocus( aWindow );
534  }
void ForceFocus(wxWindow *aWindow)
Pass the current focus to the window.
Definition: gtk/ui.cpp:44

References KIPLATFORM::UI::ForceFocus().

Referenced by onKeyDown(), onMouseMoved(), and OnStartingKey().

◆ doStartingKey()

void NET_SELECTOR_COMBOPOPUP::doStartingKey ( wxKeyEvent &  aEvent)
inlineprotected

Definition at line 498 of file net_selector.cpp.

499  {
500  if( aEvent.GetKeyCode() == WXK_BACK )
501  {
502  const long pos = m_filterCtrl->GetLastPosition();
503  m_filterCtrl->Remove( pos - 1, pos );
504  }
505  else
506  {
507  bool isPrintable;
508  int ch = aEvent.GetUnicodeKey();
509 
510  if( ch != WXK_NONE )
511  isPrintable = true;
512  else
513  {
514  ch = aEvent.GetKeyCode();
515  isPrintable = ch > WXK_SPACE && ch < WXK_START;
516  }
517 
518  if( isPrintable )
519  {
520  wxString text( static_cast<wxChar>( ch ) );
521 
522  // wxCHAR_HOOK chars have been converted to uppercase.
523  if( !aEvent.ShiftDown() )
524  text.MakeLower();
525 
526  m_filterCtrl->AppendText( text );
527  }
528  }
529  }

References m_filterCtrl, and text.

Referenced by onKeyDown(), and OnStartingKey().

◆ GetAdjustedSize()

wxSize NET_SELECTOR_COMBOPOPUP::GetAdjustedSize ( int  aMinWidth,
int  aPrefHeight,
int  aMaxHeight 
)
inlineoverride

Definition at line 171 of file net_selector.cpp.

172  {
173  // Called when the popup is first shown. Stash the minWidth and maxHeight so we
174  // can use them later when refreshing the sizes after filter changes.
175  m_minPopupWidth = aMinWidth;
176  m_maxPopupHeight = aMaxHeight;
177 
178  return updateSize();
179  }

References m_maxPopupHeight, m_minPopupWidth, and updateSize().

◆ GetControl()

wxWindow* NET_SELECTOR_COMBOPOPUP::GetControl ( )
inlineoverride

Definition at line 114 of file net_selector.cpp.

114 { return this; }

◆ GetSelectedNetcode()

int NET_SELECTOR_COMBOPOPUP::GetSelectedNetcode ( )
inline

Definition at line 155 of file net_selector.cpp.

References m_selectedNetcode.

Referenced by NET_SELECTOR::GetSelectedNetcode().

◆ GetSelectedNetname()

wxString NET_SELECTOR_COMBOPOPUP::GetSelectedNetname ( )
inline

Definition at line 163 of file net_selector.cpp.

164  {
167  else
168  return wxEmptyString;
169  }
NETINFO_LIST * m_netinfoList
const wxString & GetNetname() const
Definition: netinfo.h:126
NETINFO_ITEM * GetNetItem(int aNetCode) const

References NETINFO_LIST::GetNetItem(), NETINFO_ITEM::GetNetname(), m_netinfoList, and m_selectedNetcode.

Referenced by NET_SELECTOR::GetSelectedNetname().

◆ GetStringValue()

wxString NET_SELECTOR_COMBOPOPUP::GetStringValue ( ) const
inlineoverride

Definition at line 121 of file net_selector.cpp.

122  {
123  if( m_selectedNetcode == -1 )
124  return m_indeterminateLabel;
125 
127 
128  if( netInfo && netInfo->GetNetCode() > 0 )
129  return netInfo->GetNetname();
130 
131  return NO_NET;
132  }
NETINFO_LIST * m_netinfoList
const wxString & GetNetname() const
Definition: netinfo.h:126
#define NO_NET
Handle the data for a net.
Definition: netinfo.h:66
NETINFO_ITEM * GetNetItem(int aNetCode) const
int GetNetCode() const
Definition: netinfo.h:120

References NETINFO_ITEM::GetNetCode(), NETINFO_LIST::GetNetItem(), NETINFO_ITEM::GetNetname(), m_indeterminateLabel, m_netinfoList, m_selectedNetcode, and NO_NET.

Referenced by NET_SELECTOR::SetSelectedNet(), and NET_SELECTOR::SetSelectedNetcode().

◆ IsIndeterminate()

bool NET_SELECTOR_COMBOPOPUP::IsIndeterminate ( )
inline

Definition at line 152 of file net_selector.cpp.

152 { return m_selectedNetcode == -1; }

References m_selectedNetcode.

Referenced by NET_SELECTOR::IsIndeterminate().

◆ onEnter()

void NET_SELECTOR_COMBOPOPUP::onEnter ( wxCommandEvent &  aEvent)
inlineprotected

Definition at line 484 of file net_selector.cpp.

485  {
486  Accept();
487  }

References Accept().

Referenced by Create().

◆ onFilterEdit()

void NET_SELECTOR_COMBOPOPUP::onFilterEdit ( wxCommandEvent &  aEvent)
inlineprotected

Definition at line 489 of file net_selector.cpp.

490  {
491  rebuildList();
492  updateSize();
493 
494  if( m_listBox->GetCount() > 0 )
495  m_listBox->SetSelection( 0 );
496  }

References m_listBox, rebuildList(), and updateSize().

Referenced by Create().

◆ onIdle()

void NET_SELECTOR_COMBOPOPUP::onIdle ( wxIdleEvent &  aEvent)
inlineprotected

Definition at line 361 of file net_selector.cpp.

362  {
363  // Generate synthetic (but reliable) MouseMoved events
364  static wxPoint lastPos;
365  wxPoint screenPos = wxGetMousePosition();
366 
367  if( screenPos != lastPos )
368  {
369  lastPos = screenPos;
370  onMouseMoved( screenPos );
371  }
372 
373  if( m_focusHandler )
374  {
375  m_filterCtrl->PushEventHandler( m_focusHandler );
376  m_focusHandler = nullptr;
377  }
378  }
wxEvtHandler * m_focusHandler
void onMouseMoved(const wxPoint aScreenPos)

References m_filterCtrl, m_focusHandler, and onMouseMoved().

Referenced by Create().

◆ onKeyDown()

void NET_SELECTOR_COMBOPOPUP::onKeyDown ( wxKeyEvent &  aEvent)
inlineprotected

Definition at line 427 of file net_selector.cpp.

428  {
429  switch( aEvent.GetKeyCode() )
430  {
431  // Control keys go to the parent combobox
432  case WXK_TAB:
433  Dismiss();
434 
435  m_parent->NavigateIn( ( aEvent.ShiftDown() ? 0 : wxNavigationKeyEvent::IsForward ) |
436  ( aEvent.ControlDown() ? wxNavigationKeyEvent::WinChange : 0 ) );
437  break;
438 
439  case WXK_ESCAPE:
440  Dismiss();
441  break;
442 
443  case WXK_RETURN:
444  Accept();
445  break;
446 
447  // Arrows go to the list box
448  case WXK_DOWN:
449  case WXK_NUMPAD_DOWN:
451  m_listBox->SetSelection( std::min( m_listBox->GetSelection() + 1, (int) m_listBox->GetCount() - 1 ) );
452  break;
453 
454  case WXK_UP:
455  case WXK_NUMPAD_UP:
457  m_listBox->SetSelection( std::max( m_listBox->GetSelection() - 1, 0 ) );
458  break;
459 
460  // Everything else goes to the filter textbox
461  default:
462  if( !m_filterCtrl->HasFocus() )
463  {
465 
466  // Because we didn't have focus we missed our chance to have the native widget
467  // handle the keystroke. We'll have to do the first character ourselves.
468  doStartingKey( aEvent );
469  }
470  else
471  {
472  // On some platforms a wxComboFocusHandler will have been pushed which
473  // unhelpfully gives the event right back to the popup. Make sure the filter
474  // control is going to get the event.
475  if( m_filterCtrl->GetEventHandler() != m_filterCtrl )
476  m_focusHandler = m_filterCtrl->PopEventHandler();
477 
478  aEvent.Skip();
479  }
480  break;
481  }
482  }
wxEvtHandler * m_focusHandler
void doStartingKey(wxKeyEvent &aEvent)
void doSetFocus(wxWindow *aWindow)

References Accept(), doSetFocus(), doStartingKey(), m_filterCtrl, m_focusHandler, and m_listBox.

Referenced by Create().

◆ onMouseClick()

void NET_SELECTOR_COMBOPOPUP::onMouseClick ( wxMouseEvent &  aEvent)
inlineprotected

Definition at line 399 of file net_selector.cpp.

400  {
401  // Accept a click event from anywhere. Different platform implementations have
402  // different foibles with regard to transient popups and their children.
403 
404  if( aEvent.GetEventObject() == m_listBox )
405  {
406  m_listBox->SetSelection( m_listBox->HitTest( aEvent.GetPosition() ) );
407  Accept();
408  return;
409  }
410 
411  wxWindow* window = dynamic_cast<wxWindow*>( aEvent.GetEventObject() );
412 
413  if( window )
414  {
415  wxPoint screenPos = window->ClientToScreen( aEvent.GetPosition() );
416 
417  if( m_listBox->GetScreenRect().Contains( screenPos ) )
418  {
419  wxPoint localPos = m_listBox->ScreenToClient( screenPos );
420 
421  m_listBox->SetSelection( m_listBox->HitTest( localPos ) );
422  Accept();
423  }
424  }
425  }

References Accept(), and m_listBox.

Referenced by Create().

◆ onMouseMoved()

void NET_SELECTOR_COMBOPOPUP::onMouseMoved ( const wxPoint  aScreenPos)
inlineprotected

Definition at line 381 of file net_selector.cpp.

382  {
383  if( m_listBox->GetScreenRect().Contains( aScreenPos ) )
384  {
386 
387  wxPoint relativePos = m_listBox->ScreenToClient( aScreenPos );
388  int item = m_listBox->HitTest( relativePos );
389 
390  if( item >= 0 )
391  m_listBox->SetSelection( item );
392  }
393  else if( m_filterCtrl->GetScreenRect().Contains( aScreenPos ) )
394  {
396  }
397  }
void doSetFocus(wxWindow *aWindow)

References doSetFocus(), m_filterCtrl, and m_listBox.

Referenced by onIdle().

◆ OnPopup()

void NET_SELECTOR_COMBOPOPUP::OnPopup ( )
inlineoverride

Definition at line 181 of file net_selector.cpp.

182  {
183  // While it can sometimes be useful to keep the filter, it's always unexpected.
184  // Better to clear it.
185  m_filterCtrl->Clear();
186 
187  // The updateSize() call in GetAdjustedSize() leaves the height off-by-one for
188  // some reason, so do it again.
189  updateSize();
190  }

References m_filterCtrl, and updateSize().

◆ OnStartingKey()

void NET_SELECTOR_COMBOPOPUP::OnStartingKey ( wxKeyEvent &  aEvent)
inline

Definition at line 192 of file net_selector.cpp.

193  {
195  doStartingKey( aEvent );
196  }
void doStartingKey(wxKeyEvent &aEvent)
void doSetFocus(wxWindow *aWindow)

References doSetFocus(), doStartingKey(), and m_filterCtrl.

Referenced by NET_SELECTOR::onKeyDown().

◆ rebuildList()

void NET_SELECTOR_COMBOPOPUP::rebuildList ( )
inlineprotected

Definition at line 313 of file net_selector.cpp.

314  {
315  wxArrayString netNames;
316  wxString netstring = m_filterCtrl->GetValue().Trim().Trim( false );
317  wxString filter = netstring.Lower();
318 
319  m_unescapedNetNameMap.clear();
320 
321  if( !filter.IsEmpty() )
322  filter = wxT( "*" ) + filter + wxT( "*" );
323 
324  for( NETINFO_ITEM* netinfo : *m_netinfoList )
325  {
326  if( netinfo->GetNetCode() > 0 && netinfo->IsCurrent() )
327  {
328  wxString netname = UnescapeString( netinfo->GetNetname() );
329 
330  if( filter.IsEmpty() || wxString( netname ).MakeLower().Matches( filter ) )
331  {
332  netNames.push_back( netname );
333  m_unescapedNetNameMap[ netname ] = netinfo->GetNetname();
334  }
335  }
336  }
337 
338  std::sort( netNames.begin(), netNames.end(),
339  []( const wxString& lhs, const wxString& rhs )
340  {
341  return StrNumCmp( lhs, rhs, true /* ignore case */ ) < 0;
342  } );
343 
344 
345  // Special handling for <no net>
346  if( filter.IsEmpty() || wxString( NO_NET ).MakeLower().Matches( filter ) )
347  netNames.insert( netNames.begin(), NO_NET );
348 
349  if( !filter.IsEmpty() && !m_netinfoList->GetNetItem( netstring ) )
350  {
351  wxString newnet = wxString::Format( "%s: %s", CREATE_NET, netstring );
352  netNames.insert( netNames.end(), newnet );
353  }
354 
355  if( !m_indeterminateLabel.IsEmpty() )
356  netNames.push_back( m_indeterminateLabel );
357 
358  m_listBox->Set( netNames );
359  }
#define CREATE_NET
NETINFO_LIST * m_netinfoList
std::map< wxString, wxString > m_unescapedNetNameMap
#define NO_NET
wxString UnescapeString(const wxString &aSource)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Handle the data for a net.
Definition: netinfo.h:66
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
NETINFO_ITEM * GetNetItem(int aNetCode) const

References CREATE_NET, filter, Format(), NETINFO_LIST::GetNetItem(), m_filterCtrl, m_indeterminateLabel, m_listBox, m_netinfoList, m_unescapedNetNameMap, NO_NET, StrNumCmp(), and UnescapeString().

Referenced by Accept(), onFilterEdit(), SetIndeterminateLabel(), and SetNetInfo().

◆ SetBoard()

void NET_SELECTOR_COMBOPOPUP::SetBoard ( BOARD aBoard)
inline

Definition at line 146 of file net_selector.cpp.

147  {
148  m_board = aBoard;
149  }

References m_board.

Referenced by NET_SELECTOR::SetBoard().

◆ SetIndeterminate()

void NET_SELECTOR_COMBOPOPUP::SetIndeterminate ( )
inline

Definition at line 151 of file net_selector.cpp.

References m_selectedNetcode.

Referenced by NET_SELECTOR::SetIndeterminate().

◆ SetIndeterminateLabel()

void NET_SELECTOR_COMBOPOPUP::SetIndeterminateLabel ( const wxString &  aIndeterminateLabel)
inline

Definition at line 140 of file net_selector.cpp.

141  {
142  m_indeterminateLabel = aIndeterminateLabel;
143  rebuildList();
144  }

References m_indeterminateLabel, and rebuildList().

Referenced by NET_SELECTOR::SetIndeterminateString().

◆ SetNetInfo()

void NET_SELECTOR_COMBOPOPUP::SetNetInfo ( NETINFO_LIST aNetInfoList)
inline

Definition at line 134 of file net_selector.cpp.

135  {
136  m_netinfoList = aNetInfoList;
137  rebuildList();
138  }
NETINFO_LIST * m_netinfoList

References m_netinfoList, and rebuildList().

Referenced by NET_SELECTOR::SetNetInfo().

◆ SetSelectedNet()

void NET_SELECTOR_COMBOPOPUP::SetSelectedNet ( const wxString &  aNetname)
inline

Definition at line 157 of file net_selector.cpp.

158  {
159  if( m_netinfoList && m_netinfoList->GetNetItem( aNetname ) )
161  }
NETINFO_LIST * m_netinfoList
NETINFO_ITEM * GetNetItem(int aNetCode) const
int GetNetCode() const
Definition: netinfo.h:120

References NETINFO_ITEM::GetNetCode(), NETINFO_LIST::GetNetItem(), m_netinfoList, and m_selectedNetcode.

Referenced by NET_SELECTOR::SetSelectedNet().

◆ SetSelectedNetcode()

void NET_SELECTOR_COMBOPOPUP::SetSelectedNetcode ( int  aNetcode)
inline

Definition at line 154 of file net_selector.cpp.

154 { m_selectedNetcode = aNetcode; }

References m_selectedNetcode.

Referenced by NET_SELECTOR::SetSelectedNetcode().

◆ SetStringValue()

void NET_SELECTOR_COMBOPOPUP::SetStringValue ( const wxString &  aNetName)
inlineoverride

Definition at line 116 of file net_selector.cpp.

117  {
118  // shouldn't be here (combo is read-only)
119  }

◆ updateSize()

wxSize NET_SELECTOR_COMBOPOPUP::updateSize ( )
inlineprotected

Definition at line 284 of file net_selector.cpp.

285  {
286  int listTop = m_listBox->GetRect().y;
287  int itemHeight = KIUI::GetTextSize( wxT( "Xy" ), this ).y + LIST_ITEM_PADDING;
288  int listHeight = m_listBox->GetCount() * itemHeight + LIST_PADDING;
289 
290  if( listTop + listHeight >= m_maxPopupHeight )
291  listHeight = m_maxPopupHeight - listTop - 1;
292 
293  int listWidth = m_minPopupWidth;
294 
295  for( size_t i = 0; i < m_listBox->GetCount(); ++i )
296  {
297  int itemWidth = KIUI::GetTextSize( m_listBox->GetString( i ), m_listBox ).x;
298  listWidth = std::max( listWidth, itemWidth + LIST_PADDING * 3 );
299  }
300 
301  wxSize listSize( listWidth, listHeight );
302  wxSize popupSize( listWidth, listTop + listHeight );
303 
304  SetSize( popupSize ); // us
305  GetParent()->SetSize( popupSize ); // the window that wxComboCtrl put us in
306 
307  m_listBox->SetMinSize( listSize );
308  m_listBox->SetSize( listSize );
309 
310  return popupSize;
311  }
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:70
#define LIST_ITEM_PADDING
#define LIST_PADDING

References KIUI::GetTextSize(), LIST_ITEM_PADDING, LIST_PADDING, m_listBox, m_maxPopupHeight, and m_minPopupWidth.

Referenced by GetAdjustedSize(), onFilterEdit(), and OnPopup().

Member Data Documentation

◆ m_board

BOARD* NET_SELECTOR_COMBOPOPUP::m_board
protected

Definition at line 545 of file net_selector.cpp.

Referenced by Accept(), and SetBoard().

◆ m_filterCtrl

wxTextCtrl* NET_SELECTOR_COMBOPOPUP::m_filterCtrl
protected

◆ m_filterValidator

wxTextValidator* NET_SELECTOR_COMBOPOPUP::m_filterValidator
protected

Definition at line 537 of file net_selector.cpp.

Referenced by Create().

◆ m_focusHandler

wxEvtHandler* NET_SELECTOR_COMBOPOPUP::m_focusHandler
protected

Definition at line 551 of file net_selector.cpp.

Referenced by onIdle(), and onKeyDown().

◆ m_indeterminateLabel

wxString NET_SELECTOR_COMBOPOPUP::m_indeterminateLabel
protected

Definition at line 544 of file net_selector.cpp.

Referenced by Accept(), GetStringValue(), rebuildList(), and SetIndeterminateLabel().

◆ m_listBox

wxListBox* NET_SELECTOR_COMBOPOPUP::m_listBox
protected

◆ m_maxPopupHeight

int NET_SELECTOR_COMBOPOPUP::m_maxPopupHeight
protected

Definition at line 541 of file net_selector.cpp.

Referenced by GetAdjustedSize(), and updateSize().

◆ m_minPopupWidth

int NET_SELECTOR_COMBOPOPUP::m_minPopupWidth
protected

Definition at line 540 of file net_selector.cpp.

Referenced by GetAdjustedSize(), and updateSize().

◆ m_netinfoList

NETINFO_LIST* NET_SELECTOR_COMBOPOPUP::m_netinfoList
protected

◆ m_selectedNetcode

int NET_SELECTOR_COMBOPOPUP::m_selectedNetcode
protected

◆ m_unescapedNetNameMap

std::map<wxString, wxString> NET_SELECTOR_COMBOPOPUP::m_unescapedNetNameMap
protected

Definition at line 549 of file net_selector.cpp.

Referenced by Accept(), and rebuildList().


The documentation for this class was generated from the following file: