SGColourDragTarget Class Reference

An instantiation of this class is created by each entity which wishes to provide a 'destination' to which the mouse can go to complete a drag. More...

#include <sgcolour.h>

Inheritance diagram for SGColourDragTarget:

SGListDragTarget KernelDragTarget DragTarget ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 SGColourDragTarget (DialogOp *TheDialog, CGadgetID TheGadget=NULL)
 Constructor.

Protected Member Functions

virtual BOOL ProcessEvent (DragEventType Event, DragInformation *pDragInfo, OilCoord *pMousePos, KeyPress *pKeyPress)
 Event Handler for SuperGallery listitem drag events. Overrides the base class handler to enable it to sort out the node being dragged for colour drags.

Friends

class DragManagerOp

Detailed Description

An instantiation of this class is created by each entity which wishes to provide a 'destination' to which the mouse can go to complete a drag.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/3/95
This particular target is used for handling drags of ColourSGalllery items within their displayed list. It automatically handles drags with draginfo derived from ColourDragInformation.

Notes: Drag targets are destructed automatically when a drag finishes by the drag manager with which they were registered.

To remove a drag target at any time, destruct it - it automatically deregisters and cleans up.

See also:
DragManagerOp::StartDrag; DragInformation; DragTarget; SGColourDragTarget::ProcessEvent
Documentation: Docs.doc; Docs.doc

Definition at line 192 of file sgcolour.h.


Constructor & Destructor Documentation

SGColourDragTarget::SGColourDragTarget DialogOp TheDialog,
CGadgetID  TheGadget = NULL
 

Constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/3/95
Parameters:
TheDialog - The kernel dialog in which the target exists [INPUTS] TheGadget - The gadget within that dialogue which is the target

Definition at line 271 of file sgcolour.cpp.

00272                     : SGListDragTarget(TheDialog, TheGadget)
00273 {
00274     ERROR3IF(!TheDialog->IsKindOf(CC_RUNTIME_CLASS(ColourSGallery)),
00275             "You can only use SGColourDragTargets with ColourSGallery dialogues!");
00276 }


Member Function Documentation

BOOL SGColourDragTarget::ProcessEvent DragEventType  Event,
DragInformation pDragInfo,
OilCoord pMousePos,
KeyPress pKeyPress
[protected, virtual]
 

Event Handler for SuperGallery listitem drag events. Overrides the base class handler to enable it to sort out the node being dragged for colour drags.

BOOL SGColourDragTarget::ProcessEvent(DragEventType Event, DragInformation *pDragInfo, OilCoord *pMousePos, KeyPress* pKeyPress)

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/3/95
Parameters:
Event - Indicates what has happened [INPUTS] pDragInfo - points to drag information describing this drag. This should be a ColourDragInformation or derivation thereof pMousePos - points to information on the current mouse position, in OIL coords pKeyPress - NULL, or if for a keypress event, keypress information
Returns:
TRUE to claim the event, FALSE to let it through to other targets

Reimplemented from SGListDragTarget.

Definition at line 301 of file sgcolour.cpp.

00303 {
00304     if (!pDragInfo->IsKindOf(CC_RUNTIME_CLASS(ColourDragInformation)))
00305         return(FALSE);
00306 
00307     SGDisplayNode *DraggedNode = NULL;
00308     BOOL IsSimpleColourDrag = FALSE;
00309 
00310     if (IS_A(pDragInfo, ColourDragInformation))
00311     {
00312         ColourDragInformation *ColourDragInfo = (ColourDragInformation *) pDragInfo;
00313 
00314         SuperGallery *ParentGallery = (SuperGallery *)TargetDialog;
00315 
00316         IsSimpleColourDrag = TRUE;
00317 
00318         // Search the display tree for an item which displays the dragged IndexedColour
00319         IndexedColour *DraggedColour = ColourDragInfo->GetInitiallyDraggedColour();
00320 
00321         // If the colour is NULL, it's "no colour" (or possibly some weird library colour which
00322         // we didn't start the drag of, because we'd use a GalleryColourDragInfo), so ignore it
00323         if (DraggedColour == NULL)
00324             return(FALSE);
00325 
00326         SGDisplayRoot *DisplayTree = ParentGallery->GetDisplayTree();
00327         if (DisplayTree == NULL)        // No tree?!
00328             return(FALSE);
00329 
00330         // Scan the display tree for the document in which the colour resides, to find
00331         // the display item that references the colour. If we weren't given a parent
00332         // document, then we'll scan the entire thing.
00333         // If we find it, we exit this bit with DraggedNode pointing at the relevant
00334         // SGDisplayNode item for it, and drop through to the regular handler
00335         BOOL Found = FALSE;
00336 
00337         SGDisplayNode *TheGroup = NULL;     // Find an appropriate group to start searching
00338         if (ColourDragInfo->GetParentDoc() != NULL)
00339         {
00340             TheGroup = DisplayTree->FindSubtree(ParentGallery,
00341                                 ((ColourDragInformation *) pDragInfo)->GetParentDoc(), NULL);
00342         }
00343         else
00344             TheGroup = DisplayTree->GetChild();
00345 
00346         DocColour *TheDocCol;
00347         while (TheGroup != NULL && !Found)
00348         {
00349             DraggedNode = TheGroup->GetChild();
00350             while (DraggedNode != NULL)
00351             {
00352                 TheDocCol = ((SGDisplayColour *)DraggedNode)->GetDisplayedColour();
00353                 if (TheDocCol != NULL && TheDocCol->FindParentIndexedColour() == DraggedColour)
00354                 {
00355                     Found = TRUE;
00356                     break;
00357                 }
00358 
00359                 DraggedNode = DraggedNode->GetNext();
00360             }
00361 
00362             TheGroup = TheGroup->GetNext();
00363         }
00364 
00365         if (!Found)         // No colour matching that description is in the gallery
00366             return(FALSE);
00367     }
00368     else if (IS_A(pDragInfo, GalleryColourDragInfo))
00369     {
00370         DraggedNode = ((GalleryColourDragInfo *)pDragInfo)->GetDraggedColour();
00371     }
00372     // else ignore the drag (as DraggedNode will still be NULL)
00373 
00374     if (DraggedNode != NULL)
00375     {
00376         switch(Event)
00377         {
00378             case DRAGEVENT_COMPLETED:
00379                 HandleDragCompleted((SuperGallery *) TargetDialog,
00380                                     DraggedNode, pMousePos, IsSimpleColourDrag);
00381                 return(TRUE);
00382 
00383 
00384             case DRAGEVENT_MOUSESTOPPED:
00385             case DRAGEVENT_MOUSEMOVED:
00386             case DRAGEVENT_MOUSEIDLE:
00387                 // Call a subroutine to work out and set our current cursor shape
00388                 return(DetermineCursorShape((SuperGallery *) TargetDialog,
00389                                             DraggedNode, pMousePos));
00390             default:
00391                 break;
00392         }
00393     }
00394 
00395     // Otherwise, we aren't interested in the event, so we don't claim it
00396     return(FALSE);
00397 }


Friends And Related Function Documentation

friend class DragManagerOp [friend]
 

Reimplemented from SGListDragTarget.

Definition at line 194 of file sgcolour.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:00:56 2007 for Camelot by  doxygen 1.4.4