COptionTreeItem * COptionTree::FocusFirst() { // Declare variable COptionTreeItem *otiOld; // Set old to focus otiOld = m_otiFocus; // Set focused item SetFocusedItem(m_otiVisibleList); // Select items if (m_otiFocus != NULL) { SelectItems(NULL, FALSE); m_otiFocus->Select(); } // Notify of selection change if (otiOld != m_otiFocus) { SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus); } return m_otiFocus; }
CEGPropertyGridItem* CEGPropertyGrid::FocusNext() { CEGPropertyGridItem* pNext; CEGPropertyGridItem* pChange; pChange = m_pFocus; if (m_pFocus==NULL) pNext = m_pVisbleList; else if (m_pFocus->GetNextVisible()) pNext = m_pFocus->GetNextVisible(); else pNext = NULL; if (pNext) SetFocusedItem(pNext); if (m_pFocus) { SelectItems(NULL, FALSE); m_pFocus->Select(); } if (pChange!=m_pFocus) SendNotify(PTN_SELCHANGE, m_pFocus); return pNext; }
COptionTreeItem * COptionTree::FocusLast() { // Declare variables COptionTreeItem* otiNext; COptionTreeItem* otiChange; // Set pointers otiChange = m_otiFocus; otiNext = m_otiVisibleList; // Set focu on last if (otiNext != NULL) { while (otiNext->GetNextVisible()) { otiNext = otiNext->GetNextVisible(); } SetFocusedItem(otiNext); if (m_otiFocus != NULL) { SelectItems(NULL, FALSE); m_otiFocus->Select(); } } // Send notify to user if (otiChange != m_otiFocus) { SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus); } return otiNext; }
CEGPropertyGridItem* CEGPropertyGrid::FocusLast() { CEGPropertyGridItem* pNext; CEGPropertyGridItem* pChange; pChange = m_pFocus; pNext = m_pVisbleList; if (pNext) { while (pNext->GetNextVisible()) pNext = pNext->GetNextVisible(); SetFocusedItem(pNext); if (m_pFocus) { SelectItems(NULL, FALSE); m_pFocus->Select(); } } if (pChange!=m_pFocus) SendNotify(PTN_SELCHANGE, m_pFocus); return pNext; }
void CMusikSourcesCtrl::FocusNowPlaying() { KillFocus( false ); m_Libraries.at( 1 )->Select( TRUE ); SetFocusedItem( m_Libraries.at( 1 ) ); }
void CMusikSourcesCtrl::FocusLibrary() { KillFocus( false ); m_Libraries.at( 0 )->Select( TRUE ); SetFocusedItem( m_Libraries.at( 0 ) ); }
CEGPropertyGridItem* CEGPropertyGrid::FocusPrev() { CEGPropertyGridItem* pNext; CEGPropertyGridItem* pChange; pChange = m_pFocus; if (m_pFocus==NULL) { // get the last visible item pNext = m_pVisbleList; while (pNext && pNext->GetNextVisible()) pNext = pNext->GetNextVisible(); } else { pNext = m_pVisbleList; while (pNext && pNext->GetNextVisible()!=m_pFocus) pNext = pNext->GetNextVisible(); } if (pNext) SetFocusedItem(pNext); if (m_pFocus) { SelectItems(NULL, FALSE); m_pFocus->Select(); } if (pChange!=m_pFocus) SendNotify(PTN_SELCHANGE, m_pFocus); return pNext; }
void CXTPCoreTreeControl::OnItemRemoved(CXTPCoreTreeItem* pItem) { if (pItem == m_pFocusedItem) { SetFocusedItem(NULL); } if (pItem == m_pPressedItem) m_pPressedItem = NULL; }
void CMusikSourcesCtrl::KillFocus( bool redraw ) { CMusikPropTreeItem* pItem = GetFocusedItem(); if ( pItem ) { pItem->Select( FALSE ); SetFocusedItem( NULL ); if ( redraw ) Invalidate(); } }
void CXTPCoreTreeControl::OnLButtonDown(UINT nFlags, CPoint point) { SetFocus(); CXTPCoreTreeItem* pItem = HitTest(point); if (pItem != NULL) { m_ptPressed = point; point.y += GetScrollOffset(); if (pItem->HasChildren() && pItem->GetButtonRect().PtInRect(point)) { pItem->SetExpanded(!pItem->IsExpanded()); if (pItem->IsParent(m_pFocusedItem)) { SetFocusedItem(pItem); } } else if (pItem->GetCheckboxRect().PtInRect(point)) { SetFocusedItem(pItem); OnCheckClicked(pItem); } else { SetFocusedItem(pItem); SetCapture(); m_pPressedItem = pItem; } } CWnd::OnLButtonDown(nFlags, point); }
PropertyTreeItem* PropertyTree::FocusNext() { PropertyTreeItem* pItem = GetFocusedItem(); // Added check to prevent a crash when pressing the ESC key // following UP_ARROW key on the search box. // TODO: Probably should find a way to enable moving with the keyboard. if ( pItem && pItem->GetNext() ) { SetFocusedItem( pItem->GetNext() ); pItem->GetNext()->Select(); return pItem->GetNext(); } return NULL; }
COptionTreeItem * COptionTree::FocusPrev() { // Declare variables COptionTreeItem* otiNext; COptionTreeItem* otiChange; // Set pointers otiChange = m_otiFocus; // Get the last visible item if (m_otiFocus == NULL) { otiNext = m_otiVisibleList; while (otiNext && otiNext->GetNextVisible()) { otiNext = otiNext->GetNextVisible(); } } else { otiNext = m_otiVisibleList; while (otiNext && otiNext->GetNextVisible() != m_otiFocus) { otiNext = otiNext->GetNextVisible(); } } // Set focus items if (otiNext) { SetFocusedItem(otiNext); } // Select items if (m_otiFocus != NULL) { SelectItems(NULL, FALSE); m_otiFocus->Select(); } // Send notify to user if (otiChange != m_otiFocus) { SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus); } return otiNext; }
void CPropTree::Delete(CPropTreeItem* pItem) { if (pItem && pItem!=&m_Root && SendNotify(PTN_DELETEITEM, pItem)) return; // passing in a NULL item is the same as calling DeleteAllItems if (!pItem) pItem = &m_Root; // Clear the visible list before anything gets deleted ClearVisibleList(); // delete children CPropTreeItem* pIter; CPropTreeItem* pNext; pIter = pItem->GetChild(); while (pIter) { pNext = pIter->GetSibling(); DeleteItem(pIter); pIter = pNext; } // unlink from tree if (pItem->GetParent()) { if (pItem->GetParent()->GetChild()==pItem) pItem->GetParent()->SetChild(pItem->GetSibling()); else { pIter = pItem->GetParent()->GetChild(); while (pIter->GetSibling() && pIter->GetSibling()!=pItem) pIter = pIter->GetSibling(); if (pIter->GetSibling()) pIter->SetSibling(pItem->GetSibling()); } } if (pItem!=&m_Root) { if (pItem==GetFocusedItem()) SetFocusedItem(NULL); delete pItem; } }
void CEGPropertyGrid::Delete(CEGPropertyGridItem* pItem) { if (pItem && pItem!=&m_Root && SendNotify(PTN_DELETEITEM, pItem)) return; // passing in a NULL item is the same as calling DeleteAllItems if (!pItem) pItem = &m_Root; // delete children CEGPropertyGridItem* pIter; CEGPropertyGridItem* pNext; pIter = pItem->GetChild(); while (pIter) { pNext = pIter->GetSibling(); DeleteItem(pIter); pIter = pNext; } // unlink from tree if (pItem->GetParent()) { if (pItem->GetParent()->GetChild()==pItem) pItem->GetParent()->SetChild(pItem->GetSibling()); else { pIter = pItem->GetParent()->GetChild(); while (pIter->GetSibling() && pIter->GetSibling()!=pItem) pIter = pIter->GetSibling(); if (pIter->GetSibling()) pIter->SetSibling(pItem->GetSibling()); } } if (pItem!=&m_Root) { if (pItem==GetFocusedItem()) SetFocusedItem(NULL); delete pItem; } }
BOOL CXTPCoreTreeControl::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint /*point*/) { if (!m_pDragOverItem) return FALSE; CXTPCoreTreeItem* pDragOverItem = m_pDragOverItem; m_pDragOverItem = NULL; RedrawControl(); if (dropEffect != DROPEFFECT_COPY && dropEffect != DROPEFFECT_MOVE) return FALSE; if (!pDataObject || !pDataObject->IsDataAvailable(GetClipboardFormat())) return FALSE; CXTPCoreTreeItem* pItemDrop = CXTPCoreTreeItem::CreateFromOleData(pDataObject); if (!pItemDrop) return FALSE; if (m_nDropPosition == xtpCoreTreeDropAfter) { pDragOverItem->GetParentItems()->AddItemAfter(pItemDrop, pDragOverItem); } else if (m_nDropPosition == xtpCoreTreeDropBefore) { pDragOverItem->GetParentItems()->AddItemBefore(pItemDrop, pDragOverItem); } else if (m_nDropPosition == xtpCoreTreeDropChild) { pDragOverItem->GetChildren()->AddItemBefore(pItemDrop, NULL); pDragOverItem->SetExpanded(); } else { ASSERT(FALSE); } SetFocusedItem(pItemDrop); return TRUE; }
CEGPropertyGridItem* CEGPropertyGrid::FocusFirst() { CEGPropertyGridItem *pold; pold = m_pFocus; SetFocusedItem(m_pVisbleList); if (m_pFocus) { SelectItems(NULL, FALSE); m_pFocus->Select(); } if (pold!=m_pFocus) SendNotify(PTN_SELCHANGE, m_pFocus); return m_pFocus; }
void PropertyTree::Delete(PropertyTreeItem* pItem) { if (pItem) { if (pItem->GetChild()) { PropertyTreeItem* pChild = pItem->GetChild(); while (pChild) { PropertyTreeItem* pNext = pChild->GetNext(); Delete(pChild); pChild = pNext; } } if (GetFocusedItem() == pItem) { SetFocusedItem(NULL); } pItem->Detach(); delete pItem; } }
void PropertyTree::OnLButtonDblClk(UINT, CPoint point) { SendNotify(NM_DBLCLK); PropertyTreeItem* pItem; if ( (pItem = FindItem(point))!=NULL ) { if ( pItem->IsRootLevel() ) { if (pItem->GetChild() && !SendNotify(PTN_ITEMEXPANDING, pItem)) { pItem->Expand(!pItem->IsExpanded()); UpdateScrollbar(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); } return; } PropertyTreeItem* pOldFocus = GetFocusedItem(); SelectItems(NULL, FALSE); SetFocusedItem(pItem); pItem->Select(); Invalidate(); if ( !pItem->IsRootLevel() && pItem != pOldFocus ) SendNotify(PTN_SELCHANGE, pItem); } }
BOOL CXTPTabManager::PerformKeyDown(HWND hWnd, UINT nChar) { const int nCount = GetItemCount(); if (nCount < 1) return FALSE; if (nChar == VK_LEFT && (DWORD)GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL) nChar = VK_RIGHT; else if (nChar == VK_RIGHT && (DWORD)GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL) nChar = VK_LEFT; switch (nChar) { case VK_HOME: SetFocusedItem(FindNextFocusable(-1, +1)); return TRUE; case VK_END: SetFocusedItem(FindNextFocusable(nCount, -1)); return TRUE; case VK_LEFT: if (IsHorizontalPosition() && m_pSelected && m_pSelected->GetIndex() > 0) SetFocusedItem(FindNextFocusable(m_pSelected->GetIndex(), -1)); return TRUE; case VK_UP: if (!IsHorizontalPosition() && m_pSelected && m_pSelected->GetIndex() > 0) SetFocusedItem(FindNextFocusable(m_pSelected->GetIndex(), -1)); return TRUE; case VK_RIGHT: if (IsHorizontalPosition() && m_pSelected && m_pSelected->GetIndex() < nCount - 1) SetFocusedItem(FindNextFocusable(m_pSelected->GetIndex(), + 1)); return TRUE; case VK_DOWN: if (!IsHorizontalPosition() && m_pSelected && m_pSelected->GetIndex() < nCount - 1) SetFocusedItem(FindNextFocusable(m_pSelected->GetIndex(), + 1)); return TRUE; } return FALSE; }
void CXTPCoreTreeControl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { switch (nChar) { case VK_DOWN: { CXTPCoreTreeItem* pItem = GetNextFocusableItem(m_pFocusedItem); if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_UP: { CXTPCoreTreeItem* pItem = GetPrevFocusableItem(m_pFocusedItem); if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_LEFT: { if (m_pFocusedItem && m_pFocusedItem->HasChildren() && m_pFocusedItem->IsExpanded()) { m_pFocusedItem->SetExpanded(FALSE); } else { CXTPCoreTreeItem* pItem = m_pFocusedItem ? m_pFocusedItem->GetParentItem() : NULL; if (pItem != NULL) { SetFocusedItem(pItem); } } } break; case VK_BACK: { CXTPCoreTreeItem* pItem = m_pFocusedItem ? m_pFocusedItem->GetParentItem() : NULL; if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_RIGHT: { if (m_pFocusedItem && m_pFocusedItem->HasChildren()) { if (!m_pFocusedItem->IsExpanded()) { m_pFocusedItem->SetExpanded(TRUE); } else { CXTPCoreTreeItem* pItem = GetNextFocusableItem(m_pFocusedItem); if (pItem != NULL) { SetFocusedItem(pItem); } } } } break; case VK_HOME: { CXTPCoreTreeItem* pItem = GetNextFocusableItem(NULL); if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_END: { CXTPCoreTreeItem* pItem = GetPrevFocusableItem(NULL); if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_NEXT: { CXTPClientRect rc(this); int nItems = (rc.Height() / m_pPaintManager->GetItemHeight()) - 2; CXTPCoreTreeItem* pItem = m_pFocusedItem; for (int i = 0; i < nItems; i++) { CXTPCoreTreeItem* pNextItem = GetNextFocusableItem(pItem); if (!pNextItem) break; pItem = pNextItem; } if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_PRIOR: { CXTPClientRect rc(this); int nItems = (rc.Height() / m_pPaintManager->GetItemHeight()) - 2; CXTPCoreTreeItem* pItem = m_pFocusedItem; for (int i = 0; i < nItems; i++) { CXTPCoreTreeItem* pNextItem = GetPrevFocusableItem(pItem); if (!pNextItem) break; pItem = pNextItem; } if (pItem != NULL) { SetFocusedItem(pItem); } } break; case VK_SPACE: if (m_pFocusedItem && m_pFocusedItem->IsCheckboxVisible()) { OnCheckClicked(m_pFocusedItem); } break; case VK_ADD: if (m_pFocusedItem && m_pFocusedItem->HasChildren()) { m_pFocusedItem->SetExpanded(TRUE); } break; case VK_SUBTRACT: if (m_pFocusedItem && m_pFocusedItem->HasChildren()) { m_pFocusedItem->SetExpanded(FALSE); } break; case VK_MULTIPLY: if (m_pFocusedItem && m_pFocusedItem->HasChildren()) { SetLockRedraw(TRUE); m_pFocusedItem->SetExpanded(TRUE); ExpandeTreeItems(m_pFocusedItem->GetChildren()); SetLockRedraw(FALSE); } break; } CWnd::OnKeyDown(nChar, nRepCnt, nFlags); }
void PropertyTree::OnLButtonDown(UINT flags, CPoint point) { // // hide edit in place // if ( m_EditInPlace.IsVisible() ) m_EditInPlace.Cancel(); SendNotify(NM_CLICK); if (!IsWindowEnabled()) return; SetFocus(); LONG nHit = HitTest(point); PropertyTreeItem* pItem; CRect rc; switch (nHit) { case HTEXPAND: if ( flags != RTCLKITEM && (pItem = FindItem(point))!=NULL) { if (pItem->GetChild() && !SendNotify(PTN_ITEMEXPANDING, pItem)) { pItem->Expand(!pItem->IsExpanded()); UpdateScrollbar(); Invalidate(); UpdateWindow(); CheckVisibleFocus(); } } break; default: if ((pItem = FindItem(point))!=NULL) { PropertyTreeItem* pOldFocus = GetFocusedItem(); if ( pItem->IsRootLevel() ) return; SelectItems(NULL, FALSE); SetFocusedItem(pItem); pItem->Select(); Invalidate(); if ( flags == RTCLKITEM ) m_LastBtn = RTCLKITEM; else m_LastBtn = LFCLKITEM; // don't send a sel change event for removable devices if (pItem!=pOldFocus ) SendNotify(PTN_SELCHANGE, pItem); if (nHit==HTATTRIBUTE && !pItem->IsRootLevel()) { if (!SendNotify(PTN_PROPCLICK, pItem)) pItem->Activate(); } } break; } }
void CMusikSourcesCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { m_LockHover = true; // user pressed f2 to rename an entry if ( nChar == VK_F2 ) { CMusikPropTreeItem* pItem = GetFocusedItem(); if ( pItem ) { CPoint nPos = pItem->GetLocation(); CRect rcClient; GetClientRect( rcClient ); CRect rect( 20, nPos.y + 1, rcClient.Width(), nPos.y + PROPTREEITEM_DEFHEIGHT - 2 ); m_EditInPlace.SetString( pItem->GetLabelText() ); m_EditInPlace.ShowWindow( SW_SHOWDEFAULT ); m_EditInPlace.MoveWindow( rect ); m_EditInPlace.SetFocus(); } } // user requested playlist deletion if ( nChar == VK_DELETE ) { CMusikPropTreeItem* pItem = GetFocusedItem(); if ( pItem ) { // type was standard playlist... if ( pItem->GetPlaylistType() == MUSIK_PLAYLIST_TYPE_STANDARD ) { int nID = pItem->GetPlaylistID(); int nPos = -1; int nNextPos = -1; // find the position... for ( size_t i = 0; i < m_StdPlaylists.size(); i++ ) { if ( m_StdPlaylists.at( i ) == pItem ) { nPos = i; if ( nPos == m_StdPlaylists.size() - 1 ) nNextPos = nPos - 1; else nNextPos = nPos; break; } } // if the position is valid, then delete it // and reload the playlists... if ( nPos != -1 ) { m_Library->DeleteStdPlaylist( nID ); LoadStdPlaylists(); // now select the next entry in the // list... if -1 select the library... KillFocus( false ); if ( nNextPos == -1 ) { m_Libraries.at( 0 )->Select( TRUE ); SetFocusedItem( m_Libraries.at( 0 ) ); int WM_SOURCESLIBRARY = RegisterWindowMessage( "SOURCESLIBRARY" ); m_Parent->SendMessage( WM_SOURCESLIBRARY, NULL ); } else { m_StdPlaylists.at( nNextPos )->Select( TRUE ); SetFocusedItem( m_StdPlaylists.at( nNextPos ) ); int WM_SOURCESSTDPLAYLIST = RegisterWindowMessage( "SOURCESSTDPLAYLIST" ); m_Parent->SendMessage( WM_SOURCESSTDPLAYLIST, NULL ); } Invalidate(); } } } } m_LockHover = false; }
void CMusikSourcesCtrl::OnDropFiles(HDROP hDropInfo) { // set cursor back to hour glass SetCursor( LoadCursor( NULL, IDC_WAIT ) ); // see if the drag landed on an existing // playlist, if it did, we'll append CPoint pos; ::GetCursorPos( &pos ); ScreenToClient( &pos ); CMusikPropTreeItem* pItem = FindItem( pos ); // make sure the item isn't root if ( pItem != NULL && pItem->IsRootLevel() ) return; if ( pItem ) { KillFocus(); pItem->Select( TRUE ); SetFocusedItem( pItem ); } // dnd stuff size_t nNumFiles; TCHAR szNextFile [MAX_PATH]; SHFILEINFO rFileInfo; nNumFiles = DragQueryFile ( hDropInfo, -1, NULL, 0 ); CStdStringArray files; CStdString sTemp; for ( size_t i = 0; i < nNumFiles; i++ ) { if ( DragQueryFile( hDropInfo, i, szNextFile, MAX_PATH ) > 0 ) { // get the filetype. if its a directory // that was dropped, we'll want to // recurse it and add all the supported // media files... SHGetFileInfo( szNextFile, 0, &rFileInfo, sizeof( rFileInfo ), SHGFI_ATTRIBUTES ); if ( rFileInfo.dwAttributes & SFGAO_FOLDER ) { sTemp = szNextFile; sTemp += "\\*.*"; m_Dir.m_Dir = sTemp; m_Dir.m_Threaded = false; m_Dir.m_Target = &files; m_Dir.Run(); } // otherwise it was just a file... add it... else files.push_back( szNextFile ); } } DragFinish( hDropInfo ); // did we actually hit an item? if ( pItem ) { // standard playlist if ( pItem->GetPlaylistType() == MUSIK_PLAYLIST_TYPE_STANDARD ) m_Library->AppendStdPlaylist( pItem->GetPlaylistID(), files ); // hit now playing? else if ( pItem->GetPlaylistType() == MUSIK_SOURCES_TYPE_NOWPLAYING ) { m_Library->BeginTransaction(); CMusikSong song; for ( size_t i = 0; i < files.size(); i++ ) { // add song (if necessary) m_Library->AddSong( files.at( i ) ); m_Library->GetSongFromFilename( files.at( i ), song ); m_Player->GetPlaylist()->Add( song ); } m_Library->EndTransaction(); } } // else make a new playlist else { CStdString playlist_str; playlist_str.Format( _T( "New Playlist %d" ), m_StdPlaylists.size() ); m_Library->CreateStdPlaylist( playlist_str.c_str(), files ); LoadStdPlaylists(); } // didn't hit an item, a new // playlist was created, so it // was pushed to the back of the list if ( !pItem ) { pItem = m_StdPlaylists.at( m_StdPlaylists.size() - 1 ); // focus KillFocus(); pItem->Select( TRUE ); SetFocusedItem( pItem ); } if ( pItem ) SendNotify( PTN_SELCHANGE, pItem ); }
void COptionTree::Delete(COptionTreeItem *otiItem) { // Declare variables COptionTreeItem* otiIter; COptionTreeItem* otiNext; // Clear visible list ClearVisibleList(); // Send notify to user SendNotify(OT_NOTIFY_DELETEITEM, otiItem); // Passing in a NULL deletes frm root if (otiItem == NULL) { otiItem = &m_otiRoot; } // Delete children otiIter = otiItem->GetChild(); while (otiIter != NULL) { // -- Get sibling otiNext = otiIter->GetSibling(); // -- Delete DeleteItem(otiIter); // -- Get next otiIter = otiNext; } // Unlink from tree if (otiItem->GetParent() != NULL) { if (otiItem->GetParent()->GetChild() == otiItem) { otiItem->GetParent()->SetChild(otiItem->GetSibling()); } else { otiIter = otiItem->GetParent()->GetChild(); while (otiIter->GetSibling() && otiIter->GetSibling() != otiItem) { otiIter = otiIter->GetSibling(); } if (otiIter->GetSibling()) { otiIter->SetSibling(otiItem->GetSibling()); } } } // Delete item if (otiItem != &m_otiRoot) { if (otiItem == GetFocusedItem()) { SetFocusedItem(NULL); } otiItem->CleanDestroyWindow(); delete otiItem; } }