GalleryLineDragInfo Class Reference

A Line attribute drag, which was started from the line gallery. More...

#include <sgldrag.h>

Inheritance diagram for GalleryLineDragInfo:

BitmapDragInformation DragInformation CCObject SimpleCCObject List of all members.

Public Member Functions

 GalleryLineDragInfo ()
 Default constructor - do not call this constructor.
 GalleryLineDragInfo (LineAttrItem *pSourceItem, SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo, BOOL IsAdjust=FALSE)
 Constructor.
 ~GalleryLineDragInfo ()
 Destructor. Deletes the dragged bitmap.
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 SGDisplayLine, 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 Line Attr is dropped onto the page.
virtual INT32 GetDragTransparency ()
 Specifies how transparent a drag should be. A value of 0, will cause a normal solid blit. Any other value (between 0 and 100), will cause a masked blit.
virtual KernelBitmapGetSolidDragMask ()
 Makes a 1bpp KernelBitmap mask for the solid drag.
LineAttrItemGetDraggedLineAttr ()

Protected Member Functions

BOOL DropStartOrEndArrow (Path *, DocCoord, BOOL *)
 Checks to see whether the arrow was dropped nearer to the start or end of a path.
NodeAttributeMakeStartOrEndArrow (NodeAttribute *, BOOL)
 Makes a Start or End arrow depending on where the arrow was dropped.

Protected Attributes

LineAttrItemSourceItem
SGMouseInfo MouseInfo
SGMiscInfo MiscInfo
NodeAttributepAttr

Detailed Description

A Line attribute drag, which was started from the line gallery.

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

Definition at line 121 of file sgldrag.h.


Constructor & Destructor Documentation

GalleryLineDragInfo::GalleryLineDragInfo  ) 
 

Default constructor - do not call this constructor.

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

Definition at line 224 of file sgldrag.cpp.

00225 {
00226     ERROR3("Default GalleryLineDragInfo constructor called");   
00227 }

GalleryLineDragInfo::GalleryLineDragInfo LineAttrItem pSourceItem,
SGMouseInfo pMouseInfo,
SGMiscInfo pMiscInfo,
BOOL  IsAdjust = FALSE
 

Constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/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 249 of file sgldrag.cpp.

00252                       : BitmapDragInformation(NULL, 100,50,0,0,
00253                                                 IsAdjust)
00254 {
00255     SourceItem  = pSourceItem;  // Copy the source item pointer
00256 
00257     pAttr       = SourceItem->CreateNewAttribute(IsAdjust);
00258 
00259     MouseInfo   = *pMouseInfo;  // Duplicate the structures (they may cease to exist
00260     MiscInfo    = *pMiscInfo;   // soon after the drag is started)
00261 }

GalleryLineDragInfo::~GalleryLineDragInfo  ) 
 

Destructor. Deletes the dragged bitmap.

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

Definition at line 274 of file sgldrag.cpp.

00275 {
00276     if (TheBitmap != NULL)
00277     {
00278         delete TheBitmap;
00279         TheBitmap = NULL;
00280     }
00281 
00282     if (pAttr != NULL)
00283         delete pAttr;
00284 }


Member Function Documentation

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

Reimplemented from DragInformation.

Definition at line 138 of file sgldrag.h.

00138 { return TRUE; }

BOOL GalleryLineDragInfo::DropStartOrEndArrow Path pPathHit,
DocCoord  DropPos,
BOOL *  IsStart
[protected]
 

Checks to see whether the arrow was dropped nearer to the start or end of a path.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Returns:
-
See also:
-

Definition at line 609 of file sgldrag.cpp.

00611 {
00612     double NearestDist = -1;
00613     BOOL GotNearest = FALSE;
00614     BOOL NearestIsStart = FALSE;
00615 
00616     DocCoord* Coords = pPathHit->GetCoordArray();
00617     PathVerb* Verbs  = pPathHit->GetVerbArray();
00618     INT32 NumCoords   = pPathHit->GetNumCoords();
00619 
00620     DocCoord ArrowCentre;
00621     DocCoord ArrowDirection;
00622 
00623     INT32 PathIndex = 0;
00624 
00625     // Find the first position of an ArrowHead
00626     BOOL GotPos = ArrowRec::GetFirstArrowPos(TRUE,
00627                                              Coords, Verbs, NumCoords, 
00628                                              &PathIndex, &ArrowCentre, &ArrowDirection);
00629     while (GotPos)
00630     {
00631         double Dist = ArrowCentre.Distance(DropPos);
00632 
00633         if (NearestDist == -1 || Dist < NearestDist)
00634         {
00635             NearestDist = Dist;
00636             GotNearest = TRUE;
00637             NearestIsStart = TRUE;
00638         }
00639 
00640         // Find the next Arrow position (if there are any more subpaths)
00641         GotPos = ArrowRec::GetNextArrowPos(TRUE,
00642                                            Coords, Verbs, NumCoords, 
00643                                            &PathIndex, &ArrowCentre, &ArrowDirection);
00644     }
00645 
00646     // Now test all the end positions
00647     PathIndex = 0;
00648 
00649     // Find the first position of an ArrowHead
00650     GotPos = ArrowRec::GetFirstArrowPos(FALSE,
00651                                          Coords, Verbs, NumCoords, 
00652                                          &PathIndex, &ArrowCentre, &ArrowDirection);
00653     while (GotPos)
00654     {
00655         double Dist = ArrowCentre.Distance(DropPos);
00656 
00657         if (NearestDist == -1 || Dist < NearestDist)
00658         {
00659             NearestDist = Dist;
00660             GotNearest = TRUE;
00661             NearestIsStart = FALSE;
00662         }
00663 
00664         // Find the next Arrow position (if there are any more subpaths)
00665         GotPos = ArrowRec::GetNextArrowPos(FALSE,
00666                                            Coords, Verbs, NumCoords, 
00667                                            &PathIndex, &ArrowCentre, &ArrowDirection);
00668     }
00669 
00670     if (GotNearest)
00671         *IsStart = NearestIsStart;
00672 
00673     return GotNearest;
00674 }

UINT32 GalleryLineDragInfo::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Set cursor over this target.

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

Reimplemented from BitmapDragInformation.

Definition at line 320 of file sgldrag.cpp.

00321 {
00322     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00323     {
00324         PageDropInfo PageDropInfo;
00325         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00326 
00327         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00328         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00329 
00330         if (IS_A(pAttr, AttrStartArrow) || IS_A(pAttr, AttrEndArrow))
00331         {
00332             if (pObjectHit && pObjectHit->IS_KIND_OF(NodePath))
00333             {
00334                 Path* pPath = &((NodePath*)pObjectHit)->InkPath;
00335                 BOOL IsStart;
00336                 if (DropStartOrEndArrow(pPath, PageDropInfo.DropPos, &IsStart))
00337                 {
00338                     TargetHit = IsStart ? STARTCOL_TARGET : ENDCOL_TARGET;
00339                 }
00340             }
00341         }
00342 
00343         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00344         BOOL IsInside = ClickMods.Constrain;
00345 
00346         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00347         {
00348             TargetHit = MANY_TARGET;
00349         }
00350 
00351         switch (TargetHit)
00352         {
00353             case FILL_TARGET:
00354                 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00355             case LINE_TARGET:
00356                 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00357             case STARTCOL_TARGET:
00358                 return IsInside ? _R(IDC_DROPINSIDEONFILLSTART) : _R(IDC_CANDROPONFILLSTART);
00359             case ENDCOL_TARGET:
00360                 return IsInside ? _R(IDC_DROPINSIDEONFILLEND) : _R(IDC_CANDROPONFILLEND);
00361             case MANY_TARGET:
00362                 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00363 
00364             case NO_TARGET:
00365                 return _R(IDC_CANDROPONPAGE);
00366             default:
00367                 break;
00368         };
00369 
00370         return _R(IDC_CANDROPONPAGE);
00371     }
00372 
00373     return _R(IDC_CANTDROP);
00374 }

LineAttrItem* GalleryLineDragInfo::GetDraggedLineAttr  )  [inline]
 

Definition at line 144 of file sgldrag.h.

00144 { return(SourceItem); }

INT32 GalleryLineDragInfo::GetDragTransparency  )  [virtual]
 

Specifies how transparent a drag should be. A value of 0, will cause a normal solid blit. Any other value (between 0 and 100), will cause a masked blit.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Returns:
-
See also:
-

Reimplemented from BitmapDragInformation.

Definition at line 527 of file sgldrag.cpp.

00528 {
00529 //  if (IS_A(pAttr, AttrStartArrow) || IS_A(pAttr, AttrEndArrow))
00530 //      return 50;
00531 
00532     return 50;
00533 }

KernelBitmap * GalleryLineDragInfo::GetSolidDragMask  )  [virtual]
 

Makes a 1bpp KernelBitmap mask for the solid drag.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Returns:
-
See also:
-

Reimplemented from BitmapDragInformation.

Definition at line 547 of file sgldrag.cpp.

00548 {
00549     // Note we abuse this call (like our base class abuses this call) to create the bitmap
00550     // itself. We don't use DragMask itself anymore (i.e. it stays NULL)
00551     if (!DragMask && !TheBitmap)
00552     {
00553         DocView *View = DocView::GetCurrent();
00554         if (View == NULL)
00555         {
00556             return NULL;
00557         }
00558         
00559         Spread *pSpread = View->FindEnclosingSpread(OilCoord(0,0));
00560         if (pSpread == NULL)
00561         {
00562             return NULL;
00563         }
00564 
00565         // Find the size of the rendered item.
00566         DocRect ClipRegion(0,0, 750*100, 750*50);
00567 //      ClipRegion.lo.x = ClipRegion.lo.y = 0;
00568 //      SourceItem->GetSize(c_eLineAttrDragTextPos, &ClipRegion.hi.x, &ClipRegion.hi.y);
00569         Matrix ConvertMatrix;
00570         FIXED16 ViewScale = 1;
00571 
00572         wxScreenDC DisplayDC;
00573         double dpi = (double) OSRenderRegion::GetFixedDCPPI(DisplayDC).GetWidth();
00574 
00575         GRenderBitmap* pMaskRegion  = new GRenderBitmap(ClipRegion, ConvertMatrix, ViewScale, 
00576                                                         32, dpi);
00577 
00578         pMaskRegion->SetDoCompression(TRUE); // misnamed call to indicate we want transparency
00579         pMaskRegion->AttachDevice(View, &DisplayDC, pSpread);
00580 
00581         // Make a Mask Bitmap
00582         pMaskRegion->StartRender();
00583         SourceItem->Render(pMaskRegion, ClipRegion, c_eLineAttrDragTextPos);
00584         pMaskRegion->StopRender();
00585 
00586         OILBitmap* pOilMaskBmp = pMaskRegion->ExtractBitmap();
00587         TheBitmap = new KernelBitmap(pOilMaskBmp, TRUE);    
00588 
00589         delete pMaskRegion;
00590     }
00591 
00592     return BitmapDragInformation::GetSolidDragMask();
00593 }

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

provide status line text for this target

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

Reimplemented from BitmapDragInformation.

Definition at line 387 of file sgldrag.cpp.

00388 {
00389     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00390 
00391     if (TheBitmap == NULL || TheBitmap->ActualBitmap == NULL)
00392         return FALSE;
00393 
00394     String_256 DragString(_R(IDS_SGLDRAG_DRAG_LINE_ATTR)); // "Dragging line attribute"
00395     DragString += String_8(_R(IDS_SGDFONTS_STAT_COLON_SEP)); //" : ";
00396 
00397     if (pDragTarget && pDragTarget->IS_KIND_OF(ViewDragTarget))
00398     {
00399         PageDropInfo PageDropInfo;
00400         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00401 
00402         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00403         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00404 
00405         String_256 ObjectDesc = _R(IDS_SGLDRAG_THIS_OBJECT); // " this object";
00406 
00407         if (pObjectHit)
00408         {
00409             ObjectDesc = pObjectHit->Describe(FALSE);
00410         }
00411 
00412         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00413         BOOL IsInside = ClickMods.Constrain;
00414 
00415         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00416         {
00417             TargetHit = MANY_TARGET;
00418         }
00419 
00420         switch (TargetHit)
00421         {
00422             case FILL_TARGET:
00423             case LINE_TARGET:
00424             case STARTCOL_TARGET:
00425             case ENDCOL_TARGET:
00426                 DragString += String_64(_R(IDS_SGLDRAG_DROP_TO_APPLY)); // "Drop to apply this attribute to this ";
00427                 DragString += ObjectDesc;
00428                 if (IsInside)
00429                     DragString += String_64(_R(IDS_SGLDRAG_SPACE_ALONE)); // " alone";
00430                 break;
00431 
00432             case MANY_TARGET:
00433                 DragString += String_64(_R(IDS_SGLDRAG_DROP_TO_APPLY)); // "Drop to apply this attribute to this ";
00434                 DragString += ObjectDesc;
00435                 DragString += String_64(_R(IDS_SGLDRAG_CONTROL_DROP_INSIDE)); // "; Press 'Control' to drop 'Inside'";
00436                 break;
00437 
00438             case NO_TARGET:
00439                 DragString += String_64(_R(IDS_SGLDRAG_DROP_CURRENT_ATTRIBUTE)); // "Drop to set the Current Attribute";
00440                 break;
00441             default:
00442                 break;
00443         };
00444 
00445         *TheText = DragString;
00446         return TRUE;
00447     }
00448     
00449     return FALSE;
00450 }

NodeAttribute * GalleryLineDragInfo::MakeStartOrEndArrow NodeAttribute pArrowAttr,
BOOL  Start
[protected]
 

Makes a Start or End arrow depending on where the arrow was dropped.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Returns:
-
See also:
-

Definition at line 688 of file sgldrag.cpp.

00689 {
00690     ArrowRec Arrow;
00691     NodeAttribute* NewAttr;
00692 
00693     if (IS_A(pArrowAttr, AttrStartArrow))
00694     {
00695         Arrow = ((AttrStartArrow*)pArrowAttr)->Value.StartArrow;
00696     }
00697     else
00698     {
00699         Arrow = ((AttrEndArrow*)pArrowAttr)->Value.EndArrow;
00700     }
00701 
00702     if (Start)
00703     {
00704         NewAttr = new AttrStartArrow(); 
00705         ((AttrStartArrow*)NewAttr)->Value.StartArrow = Arrow;
00706     }
00707     else
00708     {
00709         NewAttr = new AttrEndArrow();   
00710         ((AttrEndArrow*)NewAttr)->Value.EndArrow = Arrow;
00711     }
00712 
00713     delete pArrowAttr;
00714     return NewAttr;
00715 }

void GalleryLineDragInfo::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 SGDisplayLine, to get it to handle the click.

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

Errors: -

See also:
-

Reimplemented from BitmapDragInformation.

Definition at line 303 of file sgldrag.cpp.

00304 {
00305     if (SourceItem != NULL)
00306         SourceItem->DragWasReallyAClick(&MouseInfo, &MiscInfo);
00307 }

BOOL GalleryLineDragInfo::OnPageDrop ViewDragTarget pDragTarget  )  [virtual]
 

Called when a Line Attr is dropped onto the page.

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

Errors: -

See also:
-

Reimplemented from DragInformation.

Definition at line 467 of file sgldrag.cpp.

00468 {
00469     PageDropInfo PageDropInfo;
00470     ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00471     NodeRenderableInk* pObjectHit = PageDropInfo.pObjectHit;
00472 
00473     NodeAttribute* Attrib = SourceItem->CreateNewAttribute(IsAnAdjustDrag());
00474 
00475     if (Attrib == NULL)
00476         return FALSE;
00477 
00478     if (pObjectHit && (IS_A(Attrib, AttrStartArrow) || IS_A(Attrib, AttrEndArrow)))
00479     {
00480         if (!pObjectHit->IS_KIND_OF(NodePath))
00481         {
00482             delete Attrib;
00483             return FALSE;
00484         }
00485 
00486         Path* pPath = &((NodePath*)pObjectHit)->InkPath;
00487         BOOL IsStart;
00488 
00489         if (!DropStartOrEndArrow(pPath, PageDropInfo.DropPos, &IsStart))
00490         {
00491             delete Attrib;
00492             return FALSE;
00493         }
00494 
00495         Attrib = MakeStartOrEndArrow(Attrib, IsStart);
00496     }
00497 
00498     if (pObjectHit) 
00499     {
00500         // Hit a Line Object, so apply attribute to it
00501         AttributeManager::ApplyAttribToNode(pObjectHit, Attrib);
00502     }
00503     else
00504     {
00505         // Didn't hit anything, so just set the current attribute
00506         AttributeManager::AttributeSelected(Attrib);
00507     }
00508 
00509     return TRUE;
00510 }


Member Data Documentation

SGMiscInfo GalleryLineDragInfo::MiscInfo [protected]
 

Definition at line 153 of file sgldrag.h.

SGMouseInfo GalleryLineDragInfo::MouseInfo [protected]
 

Definition at line 152 of file sgldrag.h.

NodeAttribute* GalleryLineDragInfo::pAttr [protected]
 

Definition at line 155 of file sgldrag.h.

LineAttrItem* GalleryLineDragInfo::SourceItem [protected]
 

Definition at line 151 of file sgldrag.h.


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