/** * Finds the previous item to play * * \param p_playlist the playlist * \param p_root the root node * \param p_item the previous item (NULL if none ) * \return the next item to play, or NULL if none found */ playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed ) { PL_ASSERT_LOCKED; playlist_item_t *p_prev; PL_DEBUG2( "finding previous of %s within %s", PLI_NAME( p_item ), PLI_NAME( p_root ) ); assert( p_root && p_root->i_children != -1 ); /* Now, walk the tree until we find a suitable previous item */ p_prev = p_item; while( 1 ) { bool b_ena_ok = true, b_unplayed_ok = true; p_prev = GetPrevItem( p_playlist, p_root, p_prev ); if( !p_prev || p_prev == p_root ) break; if( p_prev->i_children == -1 ) { if( b_ena && p_prev->i_flags & PLAYLIST_DBL_FLAG ) b_ena_ok = false; if( b_unplayed && p_prev->p_input->i_nb_played != 0 ) b_unplayed_ok = false; if( b_ena_ok && b_unplayed_ok ) break; } } if( p_prev == NULL ) PL_DEBUG2( "at beginning of node" ); return p_prev; }
HTREEITEM CTreeCtrl::FindItem(LPCWSTR pText,BOOL bBackwardDirection,BOOL bPartial,HTREEITEM hItem,HTREEITEM hEnd) const { TV_ITEMW ti; WCHAR szBuffer[1000]; ti.mask=TVIF_TEXT; ti.hItem=hItem; ti.pszText=szBuffer; ti.cchTextMax=1000; LPWSTR pTextMod; if (bPartial) { int iStrLen=istrlen(pText); pTextMod=new WCHAR[iStrLen+3]; if (pText[0]!='*') { pTextMod[0]='*'; MemCopyW(pTextMod+1,pText,iStrLen++); } else MemCopyW(pTextMod,pText,iStrLen); if (pTextMod[iStrLen-1]!='*') pTextMod[iStrLen++]='*'; pTextMod[iStrLen]='\0'; MakeLower(pTextMod); } while ((ti.hItem=bBackwardDirection?GetPrevItem(ti.hItem):GetNextItem(ti.hItem))!=NULL) { // Get next item if (ti.hItem==hEnd) return NULL; // Check text if (!GetItem(&ti)) continue; if (bPartial) { MakeLower(szBuffer); if (ContainString(szBuffer,pTextMod)) { delete[] pTextMod; return ti.hItem; } } else if (_wcsicmp(szBuffer,pText)==0) return ti.hItem; } if (bPartial) delete[] pTextMod; return NULL; }
void DIALOG_CHOOSE_COMPONENT::OnInterceptSearchBoxKey( wxKeyEvent& aKeyStroke ) { // Cursor up/down and partiallyi cursor are use to do tree navigation operations. // This is done by intercepting some navigational keystrokes that normally would go to // the text search box (which has the focus by default). That way, we are mostly keyboard // operable. // (If the tree has the focus, it can handle that by itself). const wxTreeItemId sel = m_libraryComponentTree->GetSelection(); switch( aKeyStroke.GetKeyCode() ) { case WXK_UP: selectIfValid( GetPrevItem( *m_libraryComponentTree, sel ) ); break; case WXK_DOWN: selectIfValid( GetNextItem( *m_libraryComponentTree, sel ) ); break; // The following keys we can only hijack if they are not needed by the textbox itself. case WXK_LEFT: if( m_searchBox->GetInsertionPoint() == 0 ) m_libraryComponentTree->Collapse( sel ); else aKeyStroke.Skip(); // Use for original purpose: move cursor. break; case WXK_RIGHT: if( m_searchBox->GetInsertionPoint() >= (long) m_searchBox->GetLineText( 0 ).length() ) m_libraryComponentTree->Expand( sel ); else aKeyStroke.Skip(); // Use for original purpose: move cursor. break; default: aKeyStroke.Skip(); // Any other key: pass on to search box directly. break; } }