GalleryBitmapDragInfo Class Reference

A bitmap drag, which was started from the bitmap gallery. More...

#include <sgbitmap.h>

Inheritance diagram for GalleryBitmapDragInfo:

BitmapDragInformation DragInformation CCObject SimpleCCObject List of all members.

Public Member Functions

 GalleryBitmapDragInfo ()
 Default constructor - do not call this constructor.
 GalleryBitmapDragInfo (SGDisplayKernelBitmap *pSourceItem, SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo, BOOL IsAdjust=FALSE)
 Constructor.
 ~GalleryBitmapDragInfo ()
 Destructor.
virtual void OnClick (INT32 Flags, POINT Point)
 This is called if a drag was attempted but never started because it was a click all along. It calls back the SourceItem SGDisplayBitmap, to get it to handle the click.
virtual UINT32 GetCursorID (DragTarget *pDragTarget)
 Set cursor over this target.
virtual BOOL GetStatusLineText (String_256 *TheText, DragTarget *pDragTarget)
 provide status line text for this target
virtual BOOL CanDropOnPage ()
virtual BOOL OnPageDrop (ViewDragTarget *)
 Called when a bitmap is dropped onto the page.
SGDisplayKernelBitmapGetDraggedBitmap ()

Protected Attributes

SGDisplayKernelBitmapSourceItem
SGMouseInfo MouseInfo
SGMiscInfo MiscInfo

Detailed Description

A bitmap drag, which was started from the bitmap gallery.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
See also:
BitmapDragInformation

Definition at line 130 of file sgbitmap.h.


Constructor & Destructor Documentation

GalleryBitmapDragInfo::GalleryBitmapDragInfo  ) 
 

Default constructor - do not call this constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95

Definition at line 284 of file sgbitmap.cpp.

00285 {
00286     ERROR3("Default GalleryBitmapDragInfo constructor called"); 
00287 }

GalleryBitmapDragInfo::GalleryBitmapDragInfo SGDisplayKernelBitmap pSourceItem,
SGMouseInfo pMouseInfo,
SGMiscInfo pMiscInfo,
BOOL  IsAdjust = FALSE
 

Constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
pSourceItem - The gallery item from which the drag originated [INPUTS] pMouseInfo - The mouse info which made the item start the drag pMiscInfo - The MiscInfo which accompanied the mouse event IsAdjust - TRUE if this is an adjust (line-Bitmap) drag

Definition at line 309 of file sgbitmap.cpp.

00312                     : BitmapDragInformation(pSourceItem->GetDisplayedKernelBitmap(),
00313                                             120, 0, 0, 0, IsAdjust)
00314 {
00315     SourceItem  = pSourceItem;  // Copy the source item pointer
00316 
00317     MouseInfo   = *pMouseInfo;  // Duplicate the structures (they may cease to exist
00318     MiscInfo    = *pMiscInfo;   // soon after the drag is started)
00319 }

GalleryBitmapDragInfo::~GalleryBitmapDragInfo  ) 
 

Destructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95

Definition at line 332 of file sgbitmap.cpp.

00333 {
00334 }


Member Function Documentation

virtual BOOL GalleryBitmapDragInfo::CanDropOnPage  )  [inline, virtual]
 

Reimplemented from DragInformation.

Definition at line 146 of file sgbitmap.h.

00146 { return TRUE; }

UINT32 GalleryBitmapDragInfo::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Set cursor over this target.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/95

Reimplemented from BitmapDragInformation.

Definition at line 371 of file sgbitmap.cpp.

00372 {
00373     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00374     {
00375         PageDropInfo PageDropInfo;
00376         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00377 
00378         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00379         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00380 
00381         if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
00382             TargetHit = NO_TARGET;              // Ignore NodeBitmap objects
00383 
00384         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00385         BOOL IsInside = ClickMods.Constrain;
00386 
00387         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00388         {
00389             TargetHit = MANY_TARGET;
00390         }
00391 
00392         UINT32 CanFill = IsInside ? _R(IDC_DROPINSIDEONFILL) : _R(IDC_CANDROPONFILL);
00393 
00394         switch (TargetHit)
00395         {
00396             case FILL_TARGET:
00397             case LINE_TARGET:
00398             case STARTCOL_TARGET:
00399             case ENDCOL_TARGET:
00400             case ENDCOL2_TARGET:
00401             case ENDCOL3_TARGET:
00402             case MANY_TARGET:
00403                 return CanFill;
00404 
00405             case NO_TARGET:
00406                 // bitmap gallery - drop = add bitmap, CTRL + drop = page fill
00407                 return IsInside ? _R(IDC_CANFILLPAGE) : _R(IDC_CANDROPONPAGE);
00408                 //return _R(IDC_CANDROPONPAGE);
00409         };
00410 
00411         return _R(IDC_CANDROPONPAGE);
00412     }
00413 
00414     return _R(IDC_CANTDROP);
00415 }

SGDisplayKernelBitmap* GalleryBitmapDragInfo::GetDraggedBitmap  )  [inline]
 

Definition at line 149 of file sgbitmap.h.

00149 { return(SourceItem); }

BOOL GalleryBitmapDragInfo::GetStatusLineText String_256 TheText,
DragTarget pDragTarget
[virtual]
 

provide status line text for this target

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/3/95
Returns:
Whether String is valid

Reimplemented from BitmapDragInformation.

Definition at line 428 of file sgbitmap.cpp.

00429 {
00430     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00431 
00432     if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00433         return FALSE;
00434 
00435     String_256 DragString;
00436     String_256 BmpName(TheBitmap->ActualBitmap->GetName());
00437     DragString.MakeMsg(_R(IDS_SGBITMAP_DRAGGING_BITMAP), (TCHAR *)BmpName); // "Dragging Bitmap 'Bitmap' : ");
00438 
00439     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00440     {
00441         PageDropInfo PageDropInfo;
00442         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00443 
00444         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00445         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00446 
00447         String_256 ObjectDesc = String_32(_R(IDS_SGBITMAP_THIS_OBJECT)); // " this object";
00448 
00449         if (pObjectHit)
00450         {
00451             ObjectDesc = pObjectHit->Describe(FALSE);
00452         }
00453 
00454         if (pObjectHit && pObjectHit->IS_KIND_OF(NodeBitmap))
00455             TargetHit = NO_TARGET;              // Ignore NodeBitmap objects
00456 
00457         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00458         BOOL IsInside = ClickMods.Constrain;
00459 
00460         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00461         {
00462             TargetHit = MANY_TARGET;
00463         }
00464 
00465         switch (TargetHit)
00466         {
00467             case FILL_TARGET:
00468             case LINE_TARGET:
00469             case STARTCOL_TARGET:
00470             case ENDCOL_TARGET:
00471             case ENDCOL2_TARGET:
00472             case ENDCOL3_TARGET:
00473                 DragString += String_256(_R(IDS_SGBITMAP_DROP_APPLY_FILL)); // "Drop to apply a Bitmap fill to this ";
00474                 DragString += ObjectDesc;
00475                 if (IsInside)
00476                     DragString += String_16(_R(IDS_SGBITMAP_ALONE)); // " alone";
00477                 break;
00478             case MANY_TARGET:
00479                 DragString += String_256(_R(IDS_SGBITMAP_DROP_APPLY_FILL)); // "Drop to apply a Bitmap fill to this ";
00480                 DragString += ObjectDesc;
00481                 DragString += String_256(_R(IDS_SGBITMAP_CONTROL_DROP_INSIDE)); // "; Press 'Control' to drop 'Inside'";
00482                 break;
00483             case NO_TARGET:
00484                 if (IsInside)
00485                 {
00486                     DragString += String_256(_R(IDS_DRAGBMP_DROP_SETPAGEBACKGROUND)); // "Drop to set the Bitmap fill of the page background";
00487                 }
00488                 else
00489                 {
00490                     DragString += String_256(_R(IDS_SGBITMAP_DROP_INSERT_BITMAP)); // "Drop to Insert a new Bitmap object on the Page";
00491                 }
00492                 break;
00493         };
00494 
00495         *TheText = DragString;
00496         return TRUE;
00497     }
00498     
00499     return FALSE;
00500 }

void GalleryBitmapDragInfo::OnClick INT32  Flags,
POINT  Point
[virtual]
 

This is called if a drag was attempted but never started because it was a click all along. It calls back the SourceItem SGDisplayBitmap, to get it to handle the click.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from BitmapDragInformation.

Definition at line 354 of file sgbitmap.cpp.

00355 {
00356     if (SourceItem != NULL)
00357         SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00358 }

BOOL GalleryBitmapDragInfo::OnPageDrop ViewDragTarget pDragTarget  )  [virtual]
 

Called when a bitmap is dropped onto the page.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from DragInformation.

Definition at line 517 of file sgbitmap.cpp.

00518 {
00519     PageDropInfo ThePageDropInfo;
00520     ((ViewDragTarget*)pDragTarget)->GetDropInfo(&ThePageDropInfo);
00521     NodeRenderableInk* pObjectHit = ThePageDropInfo.pObjectHit;
00522 
00523     // Find the bitmap to apply
00524     KernelBitmap* BitmapToApply = TheBitmap;
00525     TheBitmap = NULL;
00526 
00527     if(BitmapToApply == NULL)
00528         return FALSE;
00529 
00530     // See if the user dropped the bitmap onto an object(s) on the page
00531     // If so then try and apply that bitmap as a fill to that object(s).
00532     if (pObjectHit && !pObjectHit->IS_KIND_OF(NodeBitmap)) 
00533     {
00534         // Fill the object(s) with the dropped bitmap
00535         AttrBitmapColourFill* Attrib = new AttrBitmapColourFill;
00536         if (Attrib == NULL)
00537             return FALSE;
00538 
00539         Attrib->AttachBitmap(BitmapToApply);
00540 
00541         AttributeManager::ApplyAttribToNode(pObjectHit, Attrib);
00542     }
00543     else
00544     {
00545         // Not dropped onto an object on the page
00546         // See if the control key is pressed
00547         BOOL Constrain = KeyPress::IsConstrainPressed();
00548         if (Constrain)
00549         {
00550             // If the control key is pressed then apply the bitmap as a new background
00551             // We should use the document given to us by the page info class
00552             Document * pDocument = ThePageDropInfo.pDoc;
00553             if (pDocument == NULL)
00554                 return FALSE;
00555             OpBackgroundParam Param;
00556             Param.pBitmap = BitmapToApply;
00557             Param.pDoc = pDocument;         
00558             Param.pSpread = ThePageDropInfo.pSpread;
00559             
00560             // Obtain a pointer to the op descriptor for the create operation 
00561             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
00562 
00563             // Invoke the operation, passing in our parameters
00564             if (pOpDesc)
00565                 pOpDesc->Invoke(&Param);         
00566         }
00567         else
00568         {
00569             // Create a new bitmap on the page at the drop point
00570 
00571             // Obtain a pointer to the op descriptor for the create operation 
00572             OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
00573 
00574             if (OpDesc)
00575             {
00576                 // Invoke the operation, passing DocView and Pos as parameters
00577                 OpParam param((void *)BitmapToApply,(void *)&ThePageDropInfo);
00578                 OpDesc->Invoke(&param);      
00579             }
00580         }
00581     }
00582 
00583     return TRUE;
00584 }


Member Data Documentation

SGMiscInfo GalleryBitmapDragInfo::MiscInfo [protected]
 

Definition at line 154 of file sgbitmap.h.

SGMouseInfo GalleryBitmapDragInfo::MouseInfo [protected]
 

Definition at line 153 of file sgbitmap.h.

SGDisplayKernelBitmap* GalleryBitmapDragInfo::SourceItem [protected]
 

Definition at line 152 of file sgbitmap.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:54:41 2007 for Camelot by  doxygen 1.4.4