#include <ccolbar.h>
Inheritance diagram for ColourLineDragTarget:
Public Member Functions | |
ColourLineDragTarget (wxWindow *TheWindow, wxRect *ClientArea=NULL) | |
virtual UINT32 | GetCursorID () |
Base Method to set cursor over this target. | |
virtual BOOL | GetStatusLineText (String_256 *TheText) |
provide status line text for this target | |
Protected Member Functions | |
BOOL | ProcessEvent (DragEventType Event, DragInformation *pDragInfo, wxPoint *pMousePos, KeyPress *pKeyPress) |
Event Handler for Edit Drag - see the base class for details. | |
Friends | |
class | DragManagerOp |
To remove a drag target at any time, destruct it - it automatically deregisters and cleans up.
Definition at line 186 of file ccolbar.h.
|
Definition at line 557 of file ccolbar.cpp. 00558 : OilDragTarget(TheWindow, ClientArea) 00559 { 00560 // TRACEUSER("Gerry", _T("ColourLineDragTarget created")); 00561 }
|
|
Base Method to set cursor over this target.
Reimplemented from DragTarget. Definition at line 692 of file ccolbar.cpp. 00693 { 00694 // TRACEUSER("Gerry", _T("ColourLineDragTarget::GetCursorID")); 00695 00696 DragInformation * pDragInfo = DragManagerOp::GetCurrentDragInfo(); 00697 if (pDragInfo != NULL && KeyPress::IsConstrainPressed()) 00698 { 00699 if (pDragInfo->IsKindOf(CC_RUNTIME_CLASS(ColourDragInformation))) 00700 { 00701 IndexedColour *Col = ((ColourDragInformation *) pDragInfo)->GetInitiallyDraggedColour(); 00702 00703 if (Col != NULL) 00704 { 00705 if (CColourBar::TheColourBar != NULL) 00706 { 00707 BOOL CanDrop = FALSE; 00708 00709 // Determine if the mouse cursor should be "insert on left" or 00710 // insert on right" of the colour under the pointer 00711 BOOL ToLeft = FALSE; 00712 wxPoint MousePos = wxGetMousePosition(); 00713 MousePos = CColourBar::TheColourBar->ScreenToClient(MousePos); 00714 00715 INT32 CellIndex = CColourBar::TheColourBar->WhereIsMouse(MousePos, NULL, &ToLeft); 00716 if (CellIndex >= 0) 00717 { 00718 // The pointer is over a legal colour cell 00719 ColourList *TheList = CColourBar::TheColourBar->m_pCurrentColourList; 00720 ERROR3IF(TheList == NULL, _T("No current colour list!")); 00721 00722 IndexedColour *Target = (IndexedColour *) TheList->GetUndeletedHead(); 00723 while (CellIndex > 0 && Target != NULL) 00724 { 00725 Target = (IndexedColour *) TheList->GetUndeletedNext(Target); 00726 CellIndex--; 00727 } 00728 00729 // Now, check that it is a position in which the colour can be dropped. 00730 // We disallow any drop which will leave the colour where it was. 00731 if (Target != NULL && Target != Col) 00732 { 00733 if (ToLeft) 00734 CanDrop = (TheList->GetUndeletedNext(Col) != Target); 00735 else 00736 CanDrop = (TheList->GetUndeletedNext(Target) != Col); 00737 } 00738 00739 // If we are sure it's OK to drop here, we return the cursor to use 00740 if (CanDrop) 00741 { 00742 if (ToLeft) 00743 return _R(IDC_DROPLEFT); 00744 00745 return _R(IDC_DROPRIGHT); 00746 } 00747 00748 // else drop out to "no-drop" cursor 00749 } 00750 } 00751 } 00752 } 00753 } 00754 00755 // Ask for "can't drop here" cursor. Really ought to rename this resource ID soon! 00756 return _R(IDC_DRAGGING_COLOUR); 00757 }
|
|
provide status line text for this target
Reimplemented from DragTarget. Definition at line 772 of file ccolbar.cpp. 00773 { 00774 // TRACEUSER("Gerry", _T("ColourLineDragTarget::GetStatusLineText")); 00775 00776 ERROR2IF(TheText==NULL,FALSE,_T("NULL string in GetStatusLineText()")); 00777 00778 DragInformation * pDragInfo = DragManagerOp::GetCurrentDragInfo(); 00779 00780 if (pDragInfo != NULL && CColourBar::TheColourBar != NULL) 00781 { 00782 if (pDragInfo->IsKindOf(CC_RUNTIME_CLASS(ColourDragInformation))) 00783 { 00784 if (((ColourDragInformation *) pDragInfo)->GetInitiallyDraggedColour() != NULL) 00785 { 00786 // If we are sure it's OK to drop here, we return the cursor to use 00787 String_256 DragString(_R(IDS_COLBAR_REARRANGE)); 00788 *TheText = DragString; 00789 return TRUE; 00790 } 00791 } 00792 } 00793 00794 return FALSE; 00795 }
|
|
Event Handler for Edit Drag - see the base class for details.
Reimplemented from OilDragTarget. Definition at line 580 of file ccolbar.cpp. 00583 { 00584 // TRACEUSER("Gerry", _T("ColourLineDragTarget::ProcessEvent")); 00585 00586 // Not a colour drag? That is kindof unexpected, but lets exit before 00587 // we embarrass ourselves 00588 if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(ColourDragInformation))) 00589 return(FALSE); 00590 00591 CColourBar *pColourLine = CColourBar::TheColourBar; 00592 00593 switch(Event) 00594 { 00595 case DRAGEVENT_COMPLETED: 00596 if (KeyPress::IsConstrainPressed() && 00597 pColourLine != NULL && pColourLine->m_pCurrentColourList != NULL) 00598 { 00599 IndexedColour *Col = ((ColourDragInformation *) pDragInfo)->GetInitiallyDraggedColour(); 00600 00601 // Check that the colour being dragged is in the current colour list 00602 if (Col != NULL && pColourLine->m_pCurrentColourList->FindPosition(Col) < 0) 00603 Col = NULL; 00604 00605 // If it's NULL, then it's "no colour", a library colour, or a colour we couldn't 00606 // find in the current colour line display, so we ignore it 00607 if (Col != NULL) 00608 { 00609 // The Colour 'Col' has been dragged and dropped into the colour line 00610 // with the 'constrain' key held down. In this case, the user wants 00611 // to rearrange the colour line, so we detect which colour the pointer 00612 // is over, and insert 'Col' before/after that colour. 00613 00614 BOOL ToLeft = FALSE; 00615 INT32 CellIndex = pColourLine->WhereIsMouse(*pMousePos, NULL, &ToLeft); 00616 00617 if (CellIndex >= 0) 00618 { 00619 // The colour was dropped onto a legal colour cell - move it 00620 ColourList *TheList = pColourLine->m_pCurrentColourList; 00621 ERROR3IF(TheList == NULL, _T("No current colour list!")); 00622 00623 IndexedColour *Target = (IndexedColour *) TheList->GetUndeletedHead(); 00624 while (CellIndex > 0 && Target) 00625 { 00626 Target = (IndexedColour *) TheList->GetUndeletedNext(Target); 00627 CellIndex--; 00628 } 00629 00630 // Now move the item into the appropriate position 00631 if (Target != NULL && Target != Col) 00632 { 00633 if (ToLeft) 00634 { 00635 if (TheList->GetUndeletedNext(Col) != Target) 00636 { 00637 TheList->RemoveItem(Col); 00638 TheList->InsertBefore(Target, Col); 00639 00640 // And inform the world (colour line, gallery, etc) of the change 00641 ColourManager::ColourListHasChanged(TheList); 00642 } 00643 } 00644 else 00645 { 00646 if (TheList->GetUndeletedNext(Target) != Col) 00647 { 00648 TheList->RemoveItem(Col); 00649 TheList->InsertAfter(Target, Col); 00650 00651 // And inform the world (colour line, gallery, etc) of the change 00652 ColourManager::ColourListHasChanged(TheList); 00653 } 00654 } 00655 } 00656 } 00657 } 00658 00659 return(TRUE); 00660 } 00661 break; 00662 00663 00664 case DRAGEVENT_MOUSESTOPPED: 00665 case DRAGEVENT_MOUSEMOVED: 00666 case DRAGEVENT_MOUSEIDLE: 00667 // Return TRUE to claim the mouse while over our target area, so that 00668 // our cursor shape is used 00669 return(TRUE); 00670 00671 default: 00672 break; 00673 } 00674 00675 // Allow unknown/unwanted events to pass on to other targets 00676 return(FALSE); 00677 }
|
|
Reimplemented from OilDragTarget. |