| 563 | } |
| 564 | |
| 565 | void ExpandingToolBar::UpdateMoving() |
| 566 | { |
| 567 | if (!mAreaParent || !mSavedArrangement || !mDragImage) |
| 568 | return; |
| 569 | |
| 570 | wxPoint cursorPos = mAreaParent->ScreenToClient(wxGetMousePosition()); |
| 571 | wxRect prevTarget = mDropTarget; |
| 572 | int best_dist_sq = 99999; |
| 573 | int i; |
| 574 | |
| 575 | for(i = 0; i < (int)mDropTargets.size(); i++) { |
| 576 | int x = (mDropTargets[i].x + (mDropTargets[i].width/2))-cursorPos.x; |
| 577 | int y = (mDropTargets[i].y + (mDropTargets[i].height/2))-cursorPos.y; |
| 578 | int dist_sq = (x*x) + (y*y); |
| 579 | |
| 580 | if (dist_sq < best_dist_sq) { |
| 581 | best_dist_sq = dist_sq; |
| 582 | mDropTarget = mDropTargets[i]; |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | if (!mAreaParent->GetRect().Contains(cursorPos)) |
| 587 | mDropTarget = kDummyRect; |
| 588 | |
| 589 | if (mDropTarget != prevTarget) { |
| 590 | mDragImage->Hide(); |
| 591 | |
| 592 | wxRect r = mDropTarget; |
| 593 | r.Inflate(4, 4); |
| 594 | mTargetPanel->SetSize(r); |
| 595 | |
| 596 | #if 0 |
| 597 | wxClientDC dc(mAreaParent); |
| 598 | dc.DestroyClippingRegion(); |
| 599 | dc.SetLogicalFunction(wxINVERT); |
| 600 | wxRect r = prevTarget; |
| 601 | r.Inflate(4, 4); |
| 602 | dc.DrawRectangle(r); |
| 603 | r = mDropTarget; |
| 604 | r.Inflate(4, 4); |
| 605 | dc.DrawRectangle(r); |
| 606 | #endif |
| 607 | |
| 608 | // This gives time for wx to finish redrawing the window that way. |
| 609 | // HACK: why do we need to do it so many times??? |
| 610 | for(i=0; i<500; i++) |
| 611 | ::wxSafeYield(); |
| 612 | |
| 613 | mDragImage->Show(); |
| 614 | mDragImage->Move(ScreenToClient(wxGetMousePosition())); |
| 615 | } |
| 616 | else |
| 617 | mDragImage->Move(ScreenToClient(wxGetMousePosition())); |
| 618 | } |
| 619 | |
| 620 | void ExpandingToolBar::FinishMoving() |
| 621 | { |