long SjColumnMixer::DelInsSelection(bool delPressed) { long numDeletedTracks = 0; int m; // remember the first selection position on delete // (the new item at the same position will be restored after deletion) long oldColIndex, oldRowIndex; wxString oldUrl; if( delPressed ) { GetSelectionAnchor(oldColIndex, oldRowIndex); SjCol* col = GetMaskedCol(oldColIndex); if( col ) { oldUrl = col->m_url; delete col; } } // delete the selection for( m = 0; m < m_moduleCount; m++ ) { numDeletedTracks += m_modules[m]->DelInsSelection(delPressed); } if( numDeletedTracks ) { // recalculate internals SetColCount__(); // set a new selection if( delPressed ) { int i; if( GetMaskedColIndexByColUrl(oldUrl) == -1 ) { // complete column deleted if( oldColIndex >= GetMaskedColCount() ) oldColIndex = GetMaskedColCount()-1; for( i = 0; i<=4; i++ ) { if( SetSelection(oldColIndex, i) ) // find selectable row from top of column break; } } else { // row deleted for( i=0; i<=2; i++ ) { if( SetSelection(oldColIndex, oldRowIndex-i) ) // find selectable row from old pos. upwards break; } } } } return numDeletedTracks; }
int wxMacDataBrowserListControl::ListGetSelection() const { wxMacDataItemPtr first, last; GetSelectionAnchor( &first, &last ); if ( first != NULL ) { return GetLineFromItem( first ); } return -1; }
void SjColumnMixer::SelectShifted(SjRow* rowClicked) { // Function selects all rows from the "currently selected" row // up to the given row. All other rows are deselected. // The "currently selected" row is the first selected row or a stored anchor. wxASSERT( rowClicked ); wxASSERT( rowClicked->IsSelectable()==2 ); long rowClickedColIndex, rowClickedRowIndex; // If there is no selected row/no anchor, we cannot shift to the given row; // simply select the given row in this case. if( !GetSelectionAnchor(rowClickedColIndex/*dummy*/, rowClickedRowIndex/*dummy*/) ) { rowClicked->Select(TRUE); return; // Done. } // find out "shift to" column and row index if( GetMaskedColIndexByRow(rowClicked, rowClickedColIndex, rowClickedRowIndex) ) { // okay, now we have the first and the last selected row index // and the index of the row to shift to -- see what to do if( rowClickedColIndex > m_selAnchorColIndex || (rowClickedColIndex == m_selAnchorColIndex && rowClickedRowIndex > m_selAnchorRowIndex) ) { // select from the first selected row up to the shifted row SetSelectionRange(m_selAnchorColIndex, m_selAnchorRowIndex, rowClickedColIndex, rowClickedRowIndex, TRUE); } else { // select from the shifted row up to the first selected row; SetSelectionRange(rowClickedColIndex, rowClickedRowIndex, m_selAnchorColIndex, m_selAnchorRowIndex, TRUE); } } }
bool SjColumnMixer::SelectShifted(int keyPressed/*-1=up, +1=down*/, long& retScopeColIndex, long& retScopeRowIndex) { long firstSelColIndex, firstSelRowIndex, lastSelColIndex, lastSelRowIndex; bool prevNextOk; // get selection anchor and the first/last selected row if( !GetSelectionAnchor(firstSelColIndex/*dummy*/, firstSelRowIndex/*dummy*/) || !GetSelectionRange(firstSelColIndex, firstSelRowIndex, &lastSelColIndex, &lastSelRowIndex) ) { return FALSE; // no anchor, the caller should preform a "simple" selection } // calculate the new selection... if( firstSelColIndex == lastSelColIndex && firstSelRowIndex == lastSelRowIndex ) { if( keyPressed == -1 ) { // ...initial selection from anchor to top prevNextOk = PrevNextRow(firstSelColIndex, firstSelRowIndex, -1); retScopeColIndex = firstSelColIndex; retScopeRowIndex = firstSelRowIndex; } else { // ...initial selection from anchor to bottom prevNextOk = PrevNextRow(lastSelColIndex, lastSelRowIndex, +1); retScopeColIndex = lastSelColIndex; retScopeRowIndex = lastSelRowIndex; } } else if( firstSelColIndex < m_selAnchorColIndex || (firstSelColIndex == m_selAnchorColIndex && firstSelRowIndex < m_selAnchorRowIndex) ) { // ...selected stuff above the anchor... prevNextOk = PrevNextRow(firstSelColIndex, firstSelRowIndex, keyPressed); retScopeColIndex = firstSelColIndex; retScopeRowIndex = firstSelRowIndex; } else { // ...select stuff below the anchor... prevNextOk = PrevNextRow(lastSelColIndex, lastSelRowIndex, keyPressed); retScopeColIndex = lastSelColIndex; retScopeRowIndex = lastSelRowIndex; } if( prevNextOk ) { // set the new selection SetSelectionRange(firstSelColIndex, firstSelRowIndex, lastSelColIndex, lastSelRowIndex, TRUE); // make sure, the anchor is always selected SjCol* col = GetMaskedCol(m_selAnchorColIndex); if( col ) { if( m_selAnchorRowIndex >= 0 && m_selAnchorRowIndex < col->m_rowCount ) { col->m_rows[m_selAnchorRowIndex]->Select(TRUE); } delete col; } } return TRUE; }