SGNameDrag Class Reference

A Wix ObjectName attribute drag, which was started from the Name gallery. More...

#include <ngdrag.h>

Inheritance diagram for SGNameDrag:

BitmapDragInformation DragInformation CCObject SimpleCCObject List of all members.

Public Member Functions

 SGNameDrag ()
 Default constructor, required for dynamic creation.
 SGNameDrag (SGNameItem *pSourceItem, SGMouseInfo *pMouseInfo, SGMiscInfo *pMiscInfo)
virtual ~SGNameDrag ()
 Destroys a SGNameDrag object.
virtual void OnClick (INT32 nFlags, POINT ptClick)
 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 *pText, DragTarget *pDragTarget)
 provide status line text for this drag
virtual BOOL CanDropOnPage ()
 Called by the kernel dragging code to test whether a dragged name item can be dropped on a view onto a document.
virtual BOOL OnPageDrop (ViewDragTarget *)
 Called when a Name gallery item is dropped onto the page.
virtual INT32 GetDragTransparency ()
 Specifies how transparent a drag should be.
virtual KernelBitmapGetSolidDragMask ()
 Renders an image of the dragged item into monochrome bitmap to use as an XOR mask for rendering the dragged Name gallery item.
virtual BOOL OnDrawSolidDrag (wxPoint ptOrigin, wxDC *pDC)
 allows the drag to draw into a Device Context - DragManager will look after painting the background etc.
SGNameItemGetDraggedNameAttr ()

Protected Member Functions

virtual KernelBitmapMakeImage (UINT32 nDepth=0)

Protected Attributes

SGNameItemm_pSourceItem
SGMouseInfo m_MouseInfo
SGMiscInfo m_MiscInfo

Private Member Functions

 CC_DECLARE_DYNCREATE (SGNameDrag)

Detailed Description

A Wix ObjectName attribute drag, which was started from the Name gallery.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
See also:
BitmapDragInformation

Definition at line 124 of file ngdrag.h.


Constructor & Destructor Documentation

SGNameDrag::SGNameDrag  ) 
 

Default constructor, required for dynamic creation.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99

Definition at line 157 of file ngdrag.cpp.

00158   : m_pSourceItem(0)
00159 {
00160     // Empty.
00161 }

SGNameDrag::SGNameDrag SGNameItem pSourceItem,
SGMouseInfo pMouseInfo,
SGMiscInfo pMiscInfo
 

Definition at line 177 of file ngdrag.cpp.

00179   : BitmapDragInformation(
00180             0,
00181             SG_DefaultNameText,
00182             SG_DefaultSmallIcon * NameGallery::Instance()->GetSelectedItemCount(),
00183             0, 0, pMouseInfo->MenuClick),
00184     m_pSourceItem(pSourceItem),
00185     m_MouseInfo(*pMouseInfo),
00186     m_MiscInfo(*pMiscInfo)
00187 {
00188     // Empty.
00189 }

SGNameDrag::~SGNameDrag  )  [virtual]
 

Destroys a SGNameDrag object.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99

Definition at line 201 of file ngdrag.cpp.

00202 {
00203     // Tidy up (why doesn't the base class do this?)
00204     delete TheBitmap;
00205     TheBitmap = 0;
00206 }


Member Function Documentation

BOOL SGNameDrag::CanDropOnPage  )  [virtual]
 

Called by the kernel dragging code to test whether a dragged name item can be dropped on a view onto a document.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
Returns:
TRUE if the a name item can be dropped on a page (ie. a document view).

Reimplemented from DragInformation.

Definition at line 309 of file ngdrag.cpp.

00310 {
00311     return TRUE;
00312 }

SGNameDrag::CC_DECLARE_DYNCREATE SGNameDrag   )  [private]
 

UINT32 SGNameDrag::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Set cursor over this target.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
Parameters:
pDragTarget --- the drag target to set the cursor for [INPUTS]

Reimplemented from BitmapDragInformation.

Definition at line 239 of file ngdrag.cpp.

00240 {
00241     // Only allow drops on the document view.
00242     if (pDragTarget == 0 || !pDragTarget->IS_KIND_OF(ViewDragTarget))
00243         return _R(IDC_CANTDROP);
00244 
00245     // If there's an object below the cursor then show the "can drop" cursor, otherwise
00246     // show the "can't drop" cursor.
00247     PageDropInfo pdInfo;
00248     ((ViewDragTarget*) pDragTarget)->GetDropInfo(&pdInfo);
00249     return (pdInfo.pObjectHit != 0) ? _R(IDC_CANDROPONPAGE) : _R(IDC_CANTDROP);
00250 }

SGNameItem * SGNameDrag::GetDraggedNameAttr  ) 
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/2/95
Returns:
A pointer to the NameGallery display item being dragged,

Definition at line 480 of file ngdrag.cpp.

00481 {
00482     return m_pSourceItem;
00483 }

INT32 SGNameDrag::GetDragTransparency  )  [virtual]
 

Specifies how transparent a drag should be.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
Returns:
A transparency value, in this case, 0%

Reimplemented from BitmapDragInformation.

Definition at line 354 of file ngdrag.cpp.

00355 {
00356 //  return 0;
00357     return 100;
00358 }

KernelBitmap * SGNameDrag::GetSolidDragMask  )  [virtual]
 

Renders an image of the dragged item into monochrome bitmap to use as an XOR mask for rendering the dragged Name gallery item.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
Returns:
A pointer to a KernelBitmap to use as a 1bpp mask for the dragged item, or 0 for failure.
See also:
SGNameDrag::MakeImage

Reimplemented from BitmapDragInformation.

Definition at line 374 of file ngdrag.cpp.

00375 {
00376     // If the mask already exists then return it else else make it by rendering the
00377     // dragged item into a 1 bpp bitmap, and then return it.
00378     return (DragMask != 0) ? DragMask : DragMask = MakeImage(1);
00379 }

BOOL SGNameDrag::GetStatusLineText String_256 pText,
DragTarget pDragTarget
[virtual]
 

provide status line text for this drag

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Parameters:
TheText - If it returns TRUE, this is filled in with status line text [OUTPUTS]
Returns:
Whether String is valid

Reimplemented from BitmapDragInformation.

Definition at line 265 of file ngdrag.cpp.

00266 {
00267     // Validate outputs and object state.
00268     ERROR3IF(pText == 0, "SGNameDrag::GetStatusLineText: no output parameter");
00269     if (TheBitmap == 0 || TheBitmap->ActualBitmap == 0) return FALSE;
00270 
00271     // Only provide status-line help for drops on the document view.
00272     if (pDragTarget == 0 || !pDragTarget->IS_KIND_OF(ViewDragTarget))
00273         return FALSE;
00274 
00275     // Get the name and type of the item being dragged.
00276     String_256 strName;
00277     m_pSourceItem->GetNameText(&strName);
00278     String strTypeDesc(((SGNameGroup*) m_pSourceItem->GetParent())->GetTypeID());
00279 
00280     // Describe the object the mouse is over, if any.
00281     PageDropInfo pdInfo;
00282     ((ViewDragTarget*) pDragTarget)->GetDropInfo(&pdInfo);
00283     NodeRenderableInk* pObjectHit = pdInfo.pObjectHit;
00284     if (pObjectHit == 0)
00285         pText->MakeMsg(_R(IDST_NAMEOP_CANT_DROP), &strName, &strTypeDesc);
00286     else
00287     {
00288         String_64 strObjectDesc;
00289         strObjectDesc = pObjectHit->Describe(FALSE); 
00290         pText->MakeMsg(_R(IDST_NAMEOP_DROP_TO_APPLY),
00291                             &strName, &strTypeDesc, &strObjectDesc, &strTypeDesc, &strName);
00292     }
00293 
00294     return TRUE;
00295 }

KernelBitmap * SGNameDrag::MakeImage UINT32  nDepth = 0  )  [protected, virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Parameters:
nDepth --- depth of bitmap to render into (default is screen [INPUTS] depth)
Returns:
A pointer to the rendered image of an item in a KernelBitmap of the given depth, or 0 for failure.
See also:
SGNameDrag::OnDrawSolidDrag; SGNameDrag::GetSolidDragMask

Definition at line 415 of file ngdrag.cpp.

00416 {
00417     // If there's no current View, or no Spread, then fail.
00418     DocView* pView = DocView::GetCurrent();
00419     if (pView == 0) return 0;
00420     Spread* pSpread = pView->FindEnclosingSpread(OilCoord(0, 0));
00421     if (pSpread == 0) return 0;
00422 
00423     // Create a device context for the display.
00424     CDC sdc;
00425     sdc.CreateDC("DISPLAY", 0, 0, 0); 
00426 
00427     // Calculate the size of the rendering and set up the rendering matrix etc.
00428     Matrix matConvert;
00429     FIXED16 fxScale = 1;
00430     INT32 nSel = NameGallery::Instance()->GetSelectedItemCount();
00431     DocRect drClip(0, 0, SG_DefaultNameText, nSel * SG_DefaultSmallIcon);
00432 
00433     // Work out the destination bitmap's characteristics.
00434     double dpi = (double) GetDeviceCaps(sdc.m_hDC, LOGPIXELSX);
00435     if (nDepth == 0)
00436             nDepth = GetDeviceCaps(sdc.m_hDC, BITSPIXEL) * GetDeviceCaps(sdc.m_hDC, PLANES);
00437 
00438     // Create a render region with the given properties of the display etc.
00439     GRenderBitmap* pRenderer = new GRenderBitmap(drClip, matConvert, fxScale, nDepth, dpi);
00440     ERRORIF(pRenderer == 0, _R(IDE_NOMORE_MEMORY), 0);
00441     pRenderer->AttachDevice(pView, &sdc, pSpread);
00442     pRenderer->StartRender();
00443     pRenderer->SaveContext();
00444 
00445     // Blank the background.
00446     pRenderer->SetLineWidth(0);
00447     pRenderer->SetLineColour(COLOUR_WHITE);
00448     pRenderer->SetFillColour(COLOUR_WHITE);
00449     pRenderer->DrawRect(&drClip);
00450 
00451     // Render the item's name.
00452     DocColour dcText(COLOUR_BLACK), dcBack(COLOUR_WHITE);
00453     pRenderer->SetFixedSystemTextColours(&dcText, &dcBack);
00454 
00455     String_256 strName;
00456     m_pSourceItem->GetNameText(&strName);
00457     pRenderer->DrawFixedSystemText(&strName, drClip);
00458 
00459     // Create a kernel bitmap from the OIL bitmap and return it.
00460     pRenderer->RestoreContext();
00461     pRenderer->StopRender();
00462     OILBitmap* pOilMaskBmp = pRenderer->ExtractBitmap();
00463     delete pRenderer;
00464 
00465     KernelBitmap* pkb = new KernelBitmap(pOilMaskBmp, TRUE);
00466     ERRORIF(pkb == 0, _R(IDE_NOMORE_MEMORY), 0);
00467     return pkb;
00468 }

void SGNameDrag::OnClick INT32  nFlags,
POINT  ptClick
[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:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
Parameters:
nFlags --- which keys are depressed during the drag [INPUTS] ptClick --- the position of the mosue click

Reimplemented from BitmapDragInformation.

Definition at line 222 of file ngdrag.cpp.

00223 {
00224     if (m_pSourceItem != 0)
00225             m_pSourceItem->DragWasReallyAClick(&m_MouseInfo, &m_MiscInfo);
00226 }

virtual BOOL SGNameDrag::OnDrawSolidDrag wxPoint  ptOrigin,
wxDC *  pDC
[virtual]
 

allows the drag to draw into a Device Context - DragManager will look after painting the background etc.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
TheDC - pointer to a DC ready to draw into. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from BitmapDragInformation.

BOOL SGNameDrag::OnPageDrop ViewDragTarget pDragTarget  )  [virtual]
 

Called when a Name gallery item is dropped onto the page.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/7/99
Parameters:
pDragTarget --- the drag target representing the view onto [INPUTS] a document (the "page").
Returns:
TRUE if successful.

Reimplemented from DragInformation.

Definition at line 327 of file ngdrag.cpp.

00328 {
00329     // Extract the address of the object dropped on and apply the dragged name
00330     // attribute to it.
00331     PageDropInfo pdInfo;
00332     pDragTarget->GetDropInfo(&pdInfo);
00333     if (pdInfo.pObjectHit != 0)
00334     {
00335         OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLY_NAMES_TO_ONE);
00336         ERROR3IF(pDesc == 0, "SGNameDrag::OnPageDrop: no descriptor");
00337         pDesc->Invoke(&OpParam((INT32) (Node*) pdInfo.pObjectHit, 0));
00338     }
00339 
00340     return TRUE;
00341 }


Member Data Documentation

SGMiscInfo SGNameDrag::m_MiscInfo [protected]
 

Definition at line 156 of file ngdrag.h.

SGMouseInfo SGNameDrag::m_MouseInfo [protected]
 

Definition at line 155 of file ngdrag.h.

SGNameItem* SGNameDrag::m_pSourceItem [protected]
 

Definition at line 154 of file ngdrag.h.


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