ptrdiff_t CodeVerifierBase::GetRowOffset( char const * text, Term::StreamId stream, IConfiguration const & config, ITermTable const & termTable, IShard const & shard) { Term term(text, stream, config); RowId row = GetFirstRow(termTable, term); return shard.GetRowOffset(row); }
bool RegionOfRows::GetIntersection(const RegionOfRows& RegionOI,RegionOfRows& Intersection) const { Intersection.Reset(); // Regions are defined ? if (!IsDefined()) return false; if (!RegionOI.IsDefined()) return false; // Regions are defined, do the have common rows ? const ClosedInterval<unsigned int>* Region1Rows = GetRows(); const ClosedInterval<unsigned int>* Region2Rows = RegionOI.GetRows(); ClosedInterval<unsigned int> RowsOI; if (!Region1Rows->GetOverlap(*Region2Rows,RowsOI)) return false; // no rows in common unsigned int RowStart = RowsOI.GetStart(); unsigned int RowEnd = RowsOI.GetEnd(); const ClosedInterval<unsigned int>* Columns1 = GetColumns(); const ClosedInterval<unsigned int>* Columns2 = RegionOI.GetColumns(); // Adjust offets Columns1 += RowStart - GetFirstRow(); Columns2 += RowStart - RegionOI.GetFirstRow(); for (unsigned int Row = RowStart;Row <= RowEnd;Row++) { ClosedInterval<unsigned int> ColumnsOI; if (Columns1->GetOverlap(*Columns2,ColumnsOI)) { // Rows and columns in common => intersection Intersection.Add(Row,ColumnsOI.GetStart(),ColumnsOI.GetEnd()); } else if (Intersection.IsDefined()) break; // Convex region ! Columns1++; Columns2++; } // Any intersection ? return Intersection.IsDefined(); }
void cbRowDragPlugin::OnDrawPaneBackground ( cbDrawPaneDecorEvent& event ) { mpPane = event.mpPane; // FIXME:: this may harm operation of other plugins if ( GetNextHandler() && mpPane->GetRowList().GetCount() ) { // first, let other plugins add their decorations now GetNextHandler()->ProcessEvent( event ); event.Skip(false); } wxClientDC dc( &mpLayout->GetParentFrame() ); dc.SetClippingRegion( mpPane->mBoundsInParent.x, mpPane->mBoundsInParent.y, mpPane->mBoundsInParent.width, mpPane->mBoundsInParent.height ); int cnt = GetHRowsCountForPane( event.mpPane ); if ( cnt > 0 ) DrawCollapsedRowsBorder( dc ); if ( mpPane->GetRowList().GetCount() ) DrawRowsDragHintsBorder( dc ); cbRowInfo* pRow = GetFirstRow(); while( pRow ) { DrawRowDragHint( pRow, dc, false ); pRow = pRow->mpNext; } for( int i = 0; i != cnt; ++i ) DrawCollapsedRowIcon(i, dc, false ); }
void cbRowDragPlugin::OnLButtonUp ( cbLeftUpEvent& event ) { if ( !mDragStarted && !mDecisionMode ) { event.Skip(); return; } mpPane = event.mpPane; if ( mDecisionMode ) { cbDockPane* pPane = mpPane; SetMouseCapture( false ); mDecisionMode = false; mDragStarted = false; wxPoint frmPos = event.mPos; pPane->PaneToFrame( &frmPos.x, &frmPos.y ); if ( mpRowInFocus ) { CollapseRow( mpRowInFocus ); mpRowInFocus = 0; } else { ExpandRow( mCollapsedIconInFocus ); mCollapsedIconInFocus = -1; } mpRowInFocus = NULL; mpPane = pPane; pPane->FrameToPane( &frmPos.x, &frmPos.y ); // give it another try after relayouting bars cbMotionEvent moveEvt( frmPos, pPane ); this->OnMouseMove( moveEvt ); // this plugin has "eaten" the mouse-up event return; } else { // otherwise, the dragged row was dropped, determine // where to insert it // restore initial pane appearence ShowPaneImage(); FinishOnScreenDraw(); cbRowInfo* pRow = GetFirstRow(); mpLayout->GetUpdatesManager().OnStartChanges(); pRow->mUMgrData.SetDirty(true); cbBarInfo* pBar = mpRowInFocus->mBars[0]; while ( pBar ) { pBar->mUMgrData.SetDirty(true); if ( pBar->mpBarWnd ) { // do complete refresh pBar->mpBarWnd->Show(false); pBar->mpBarWnd->Show(true); } pBar = pBar->mpNext; } while( pRow ) { if ( mCurDragOfs < pRow->mRowY ) { InsertDraggedRowBefore( pRow ); break; } pRow = pRow->mpNext; } if ( pRow == NULL ) InsertDraggedRowBefore( NULL ); mpRowInFocus = NULL; mpLayout->RecalcLayout(false); // finish change "transaction" mpLayout->GetUpdatesManager().OnFinishChanges(); mpLayout->GetUpdatesManager().UpdateNow(); // finish drag action SetMouseCapture( false ); mDragStarted = false; } }
// handlers for plugin events void cbRowDragPlugin::OnMouseMove( cbMotionEvent& event ) { // short-cuts wxPoint pos = event.mPos; mpPane = event.mpPane; mpPane->PaneToFrame( &pos.x, &pos.y ); if ( !mDragStarted ) { if ( mDecisionMode && mpRowInFocus ) { int ofs; if ( mpPane->IsHorizontal() ) ofs = pos.y - mDragOrigin.y; else ofs = pos.x - mDragOrigin.x; // check if the item was dragged sufficeintly // far, enough to consider that user really intends // to drag it if ( ofs >= MINIMAL_ROW_DRAG_OFS || ofs <= -MINIMAL_ROW_DRAG_OFS ) { // DBG:: //.wxPoint pos = event.mPos; //wxPoint drg = mDragOrigin; //int dif = event.mPos.x - mDragOrigin.x; mDragStarted = true; mDecisionMode = false; mDragOrigin = pos; PrepareForRowDrag(); return; } // this plugin "eats" all mouse input while item is dragged, return; } cbRowInfo* pRow = GetFirstRow(); bool focusFound = false; while( pRow ) { if ( HitTestRowDragHint( pRow, pos ) ) { CheckPrevItemInFocus( pRow, -1 ); SetMouseCapture( true ); focusFound = true; mpRowInFocus = pRow; mCollapsedIconInFocus = -1; break; } pRow = pRow->mpNext; } if ( !focusFound ) { int hrCnt = GetHRowsCountForPane( event.mpPane ); for( int i = 0; i != hrCnt; ++i ) { if ( HitTestCollapsedRowIcon( i, pos ) ) { CheckPrevItemInFocus( NULL, i ); SetMouseCapture( true ); focusFound = true; mCollapsedIconInFocus = i; mpRowInFocus = NULL; break; } } } if ( !focusFound && ItemIsInFocus() ) { // kill focus from item previously been in focus UnhighlightItemInFocus(); mpRowInFocus = NULL; mCollapsedIconInFocus = -1; SetMouseCapture( false ); } if ( !ItemIsInFocus() ) // delegate it to other plugins event.Skip(); } else { // otherwise mouse pointer moves, when dragging is started if ( mpPane->IsHorizontal() ) { // row is dragged up or down; ShowDraggedRow( pos.y - mDragOrigin.y ); } else { // row is dragged left or right ShowDraggedRow( pos.x - mDragOrigin.x ); } // this plugin "eats" all mouse input while item is dragged, } }
float NoteData::GetFirstBeat() const { return NoteRowToBeat( GetFirstRow() ); }