void cbBarHintsPlugin::OnMotion( cbMotionEvent& event ) { if ( mBtnPressed ) { wxPoint inFrame = event.mPos; mpPane->PaneToFrame( &inFrame.x, &inFrame.y ); mpPane = event.mpPane; int i; for ( i = 0; i != BOXES_IN_HINT; ++i ) { mBoxes[i]->OnMotion( inFrame ); } } else event.Skip(); }
// 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, } }
void cbBarDragPlugin::OnMouseMove( cbMotionEvent& event ) { // calculate postion in frame's coordiantes if ( !mBarDragStarted ) { event.Skip(); // pass event to the next plugin return; } wxPoint mousePos = event.mPos; event.mpPane->PaneToFrame( &mousePos.x, &mousePos.y ); bool prevIsInClient = ( mpCurPane == 0 ); AdjustHintRect( mousePos ); // if the hint-rect is not "tempted" to any pane yet if ( mpCurPane == NULL ) { cbDockPane* pPane = HitTestPanes( mHintRect ); // enable sticking again, if we've left the pane completely if ( !pPane ) mCanStick = true; if ( mCanStick && pPane && GetDistanceToPane( pPane, mousePos ) < GetBarHeightInPane( pPane ) ) StickToPane( pPane, mousePos ); else if ( pPane && HitTestPanes( mousePos ) == pPane && 0 ) // FOR NOW:: disabled StickToPane( pPane, mousePos ); } else { // otherwise, when rect is now sticked to some of the panes // check if it should still remain in this pane mCanStick = true; bool mouseInOther = IsInOtherPane( mousePos ); if ( mouseInOther ) { cbDockPane* pPane = HitTestPanes( mousePos ); StickToPane( pPane, mousePos ); } else { if ( IsInClientArea( mousePos ) ) { cbDockPane* pPane = HitTestPanes( mHintRect ); if ( pPane && pPane != mpCurPane && GetDistanceToPane( pPane, mousePos ) < GetBarHeightInPane( pPane ) ) StickToPane( pPane, mousePos ); else if ( !pPane ) { UnstickFromPane( mpCurPane, mousePos ); // FOR NOW:: disabled, would cause some mess // mCanStick = false; // prevents from sticking to this // pane again, flag is reset when hint-rect // leaves the pane completely } else if ( GetDistanceToPane( pPane, mousePos ) > GetBarHeightInPane( pPane ) ) { if ( !HitsPane( mpCurPane, mHintRect ) ) { UnstickFromPane( mpCurPane, mousePos ); // FOR NOW:: disabled, would cause some mess // mCanStick = false; // prevents from sticking to this // pane again, flag is reset when hint-rect // leaves the pane completely } } } } } ShowHint( prevIsInClient ); wxCursor* pPrevCurs = mpCurCursor; if ( mpCurPane ) { mpCurCursor = mpLayout->mpNormalCursor; } else { // if floating is off, and we are in the client // area, the cursor will be invalid, otherwise // it will be the normal cursor if (mpLayout->mFloatingOn) { mpCurCursor = mpLayout->mpNormalCursor; } else { mpCurCursor = mpLayout->mpNECursor; } } if ( pPrevCurs != mpCurCursor ) mpLayout->GetParentFrame().SetCursor( *mpCurCursor ); }