ColourDragInformation Class Reference

Contains all information about a colour being dragged. More...

#include <dragcol.h>

Inheritance diagram for ColourDragInformation:

DragInformation CCObject SimpleCCObject ColEditorDragInfo GalleryColourDragInfo List of all members.

Public Member Functions

 ColourDragInformation ()
 Conmstructor - do not call this default constructor.
 ColourDragInformation (IndexedColour *Colour, BOOL IsAdjust, Document *pParent)
 Constructor Use this for "docuemnt colours" i.e. IndexedColours which already exist inside a document. See the other constructor for library colours.
 ColourDragInformation (DocColour *Colour, BOOL IsAdjust, StringBase *pColourName, BOOL IsSpot)
 Constructor Use this for "library colours" i.e. Colours which DON'T already exist inside a document. See the other constructor for document colours.
BOOL IsLibraryColour (void)
 To determine if the dragged colour is from a library or a document.
DocumentGetParentDoc (void)
 To determine the document (if any) from which a colour is being dragged.
IndexedColourGetColourForDocument (Document *pDestDoc=NULL)
 To copy/merge the dragged colour into the given document. The returned pointer is a colour which is contained in the given document, and can be safely used within that document.
void ApplyColourToSelection (void)
 Applies the dragged colour to the current selection (including copying/merging the colour into the destination document if necessary).
IndexedColourGetInitiallyDraggedColour (void)
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 UINT32 GetCursorID (void)
 Determines what cursor to display during a colour drag.
virtual BOOL GetStatusLineText (String_256 *TheText)
 provide status line text for this drag
virtual void OnClick (INT32 Flags, CNativePoint Point)
 This is called if a drag was attempted but never started because it was a click all along. In the base class, the default action is to make the colour bar think that the dragged colour has been clicked.
virtual BOOL OnDrawSolidDrag (wxPoint Origin, wxDC *TheDC)
 allows the drag to draw into a Device Context - DragManager will look after painting the background etc.
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 BOOL CanDropOnPage ()
virtual BOOL OnPageDrop (ViewDragTarget *pDragTarget)
 Called when a colour is dropped on an Object.

Static Public Member Functions

static BOOL Init ()
 Initialise any Colour Drag stuff. (eg. ini file preferences).

Protected Member Functions

void InitObject (void)
 Shared code for initialising the object - called by all constructors.

Protected Attributes

DocColour TheColour
DocumentpParentDoc
String_64 ColourName
BOOL LibColIsSpot

Static Protected Attributes

static INT32 DragTransparency = 0

Detailed Description

Contains all information about a colour being dragged.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com> (upgraded by Jason)
Date:
05/05/94 (8/8/96)

Definition at line 123 of file dragcol.h.


Constructor & Destructor Documentation

ColourDragInformation::ColourDragInformation  ) 
 

Conmstructor - do not call this default constructor.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95

Definition at line 188 of file dragcol.cpp.

00189 {
00190     ERROR3("Default ColourDragInformation constructor called"); 
00191     InitObject();
00192 }

ColourDragInformation::ColourDragInformation IndexedColour Colour,
BOOL  IsAdjust,
Document pParent
 

Constructor Use this for "docuemnt colours" i.e. IndexedColours which already exist inside a document. See the other constructor for library colours.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
Colour - The IndexedColour being dragged [INPUTS] May not be NULL
IsAdjust - TRUE if this is an adjust-drag, FALSE if a select-drag

pParent - Points to the parent document for the dragged colour.

Definition at line 217 of file dragcol.cpp.

00219                         : DragInformation(IsAdjust)
00220 {
00221     ERROR3IF(pParent == NULL, "Illegal NULL param");
00222 
00223     InitObject();
00224 
00225     // The IndexedColour we are dragging - if it's NULL, we're dragging "no colour"
00226     if (Colour != NULL)
00227         TheColour.MakeRefToIndexedColour(Colour);
00228 
00229     // The Parent document of the colour we are dragging
00230     pParentDoc = pParent;
00231 }

ColourDragInformation::ColourDragInformation DocColour Colour,
BOOL  IsAdjust,
StringBase pColourName,
BOOL  IsSpot
 

Constructor Use this for "library colours" i.e. Colours which DON'T already exist inside a document. See the other constructor for document colours.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
Colour - The Colour being dragged [INPUTS] May not be NULL
IsAdjust - TRUE if this is an adjust-drag, FALSE if a select-drag

pColourName - Should not be NULL (but it won't ERROR3, because of GalleryColourDragInfo constructor technical reasons) The name of the colour being dragged

IsSpot - TRUE if this library colour is a spot colour

When the drag finishes, the user will ask this object for a colour, at which point, an IndexedColour will be created for them from the given DocColour and Name string. See GetLibraryColourForDocument()

Definition at line 264 of file dragcol.cpp.

00266                         : DragInformation(IsAdjust)
00267 {
00268     ERROR3IF(Colour == NULL, "Illegal NULL param");
00269 
00270     InitObject();
00271 
00272     TheColour = *Colour;
00273     LibColIsSpot = IsSpot;
00274     
00275     if (pColourName != NULL)
00276         ColourName = *pColourName;
00277 }


Member Function Documentation

void ColourDragInformation::ApplyColourToSelection void   ) 
 

Applies the dragged colour to the current selection (including copying/merging the colour into the destination document if necessary).

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Notes: Assumes that the selection will be in the Selected Document!

Definition at line 434 of file dragcol.cpp.

00435 {
00436 // WEBSTER-ranbirr-12/11/96 No colour bar stuff in webster
00437 // Neville 23/5/97 Now has a Browser palette in the colour line
00438     IndexedColour *ColToUse = GetColourForDocument(NULL);
00439 
00440     // ColourToApply now references a safe colour to use, or NULL (in which case it is
00441     // used as 'no colour' by the colour bar, which is exactly what we wanted. Fabby)
00442     CColourBar::TheColourBar->ApplyColour(ColToUse, IsAdjustDrag);
00443 }

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

Reimplemented from DragInformation.

Definition at line 179 of file dragcol.h.

00179 { return TRUE; }

IndexedColour * ColourDragInformation::GetColourForDocument Document pDestDoc = NULL  ) 
 

To copy/merge the dragged colour into the given document. The returned pointer is a colour which is contained in the given document, and can be safely used within that document.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/96
Parameters:
pDestDoc - NULL, to copy the colour into the Selected document, or [INPUTS] a pointer to the document to copy the colour into
Returns:
NULL if the colour is transparent (no colour), or A pointer to a safe colour to be used in the given document
See also:
ColourDragInformation::IsLibraryColour

Definition at line 371 of file dragcol.cpp.

00372 {
00373     // If no document supplied, assume the selected docuemnt is the destination
00374     if (pDestDoc == NULL)
00375         pDestDoc = Document::GetSelected();
00376 
00377     // If there is no destination document, or if the colour is transparent, return NULL
00378     if (pDestDoc == NULL || TheColour.IsTransparent())
00379         return(NULL);
00380 
00381     // If it's a document colour and already in the destination document, return it
00382     if (pParentDoc == pDestDoc)
00383         return(TheColour.FindParentIndexedColour());
00384 
00385     // Copy the dragged colour into a temporary DocColour
00386     DocColour Temp = TheColour;
00387     IndexedColour *TempIxCol = NULL;
00388 
00389     // Check if we've got an IndexedColour to use...
00390     if (Temp.FindParentIndexedColour() == NULL)
00391     {
00392         // It's a library colour, so we must create a new IndexedColour to use
00393         TempIxCol = new IndexedColour(Temp);
00394         if (TempIxCol == NULL)
00395             return(NULL);           // Failure - return "no colour"
00396 
00397         TempIxCol->SetName(ColourName);
00398 
00399         if (LibColIsSpot)           // If a spot colour, make it so
00400             TempIxCol->SetLinkedParent(TempIxCol->FindLastLinkedParent(), COLOURTYPE_SPOT);
00401 
00402         // And make the DocColour reference it
00403         Temp.MakeRefToIndexedColour(TempIxCol);
00404     }
00405 
00406     // Ensure the colour (or a safe equivalent) is in the dest doc, by copying/merging it
00407     ColourManager::EnsureColourIsInDocument(pParentDoc, pDestDoc, &Temp);
00408 
00409     // And delete any temporary IndexedColour we created
00410     if (TempIxCol != NULL)
00411         delete TempIxCol;
00412 
00413     // And finally, return the resulting colour
00414     return(Temp.FindParentIndexedColour());
00415 }

UINT32 ColourDragInformation::GetCursorID void   )  [virtual]
 

Determines what cursor to display during a colour drag.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/1/95
Returns:
a cursor ID to set during this drag

Reimplemented from DragInformation.

Definition at line 632 of file dragcol.cpp.

00633 {
00634     return(_R(IDC_DRAGGING_COLOUR));
00635 }

UINT32 ColourDragInformation::GetCursorID DragTarget pDragTarget  )  [virtual]
 

Set cursor over this target.

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

Reimplemented from DragInformation.

Definition at line 458 of file dragcol.cpp.

00459 {
00460     if (pDragTarget->IS_KIND_OF(ViewDragTarget))
00461     {
00462         PageDropInfo PageDropInfo;
00463         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00464 
00465 //      NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00466         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00467 
00468         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00469         BOOL IsInside = ClickMods.Constrain;
00470 
00471 //      Removed by Will 23/1/96
00472 //      This code was needed originally, but is no longer needed as the
00473 //      colour drop testing code is much smarter and copes with the case
00474 //      that this code is testing for.
00475 
00476 //      if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00477 //      {
00478 //          TargetHit = MANY_TARGET;
00479 //      }
00480 
00481         switch (TargetHit)
00482         {
00483             case FILL_TARGET:
00484                 return IsInside ? _R(IDC_DROPINSIDEONFILL) : _R(IDC_CANDROPONFILL);
00485             case LINE_TARGET:
00486                 return IsInside ? _R(IDC_DROPINSIDEONLINE) : _R(IDC_CANDROPONLINE);
00487             case STARTCOL_TARGET:
00488                 return IsInside ? _R(IDC_DROPINSIDEONFILLSTART) : _R(IDC_CANDROPONFILLSTART);
00489             case ENDCOL_TARGET:
00490                 return IsInside ? _R(IDC_DROPINSIDEONFILLEND) : _R(IDC_CANDROPONFILLEND);
00491             case ENDCOL2_TARGET:
00492                 return IsInside ? _R(IDC_DROPINSIDEONFILLEND2) : _R(IDC_CANDROPONFILLEND2);
00493             case ENDCOL3_TARGET:
00494                 return IsInside ? _R(IDC_DROPINSIDEONFILLEND3) : _R(IDC_CANDROPONFILLEND3);
00495             case MANY_TARGET:
00496                 return IsInside ? _R(IDC_DROPINSIDEONFILL) : _R(IDC_CANDROPONFILL);
00497 
00498             case NO_TARGET:
00499                 // colour drag - drop = page fill, CTRL + drop = set current fill
00500                 return IsInside ? _R(IDC_CANFILLPAGE) : _R(IDC_CANDROPONPAGE);
00501                 //return _R(IDC_CANDROPONPAGE);
00502         };
00503 
00504         return _R(IDC_CANDROPONPAGE);
00505     }
00506 
00507     return 0;
00508 }

INT32 ColourDragInformation::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:
19/3/95
Returns:
-
See also:
-

Reimplemented from DragInformation.

Definition at line 834 of file dragcol.cpp.

00835 {
00836     return ColourDragInformation::DragTransparency;
00837 }

IndexedColour* ColourDragInformation::GetInitiallyDraggedColour void   )  [inline]
 

Definition at line 159 of file dragcol.h.

00159 { return(TheColour.FindParentIndexedColour()); }

Document * ColourDragInformation::GetParentDoc void   ) 
 

To determine the document (if any) from which a colour is being dragged.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/96
Returns:
NULL (if this is a "library colour" (has no parent document)), or a pointer to the Source Document from which the colour has been dragged.
See also:
ColourDragInformation::IsLibraryColour

Definition at line 343 of file dragcol.cpp.

00344 {
00345     return(pParentDoc);
00346 }

BOOL ColourDragInformation::GetStatusLineText String_256 TheText  )  [virtual]
 

provide status line text for this drag

Author:
Chris_Snook (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 DragInformation.

Definition at line 653 of file dragcol.cpp.

00654 {
00655     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00656     String_32 LineString(_R(IDS_DRAGCOL_DRAGGING_LINE_COLOUR)); // "Dragging line colour : ");
00657     String_32 FillString(_R(IDS_DRAGCOL_DRAGGING_FILL_COLOUR)); // "Dragging fill colour : ");
00658     String_256 DragString;
00659 
00660     if(IsAdjustDrag)
00661         DragString = LineString;
00662     else
00663         DragString = FillString;
00664 
00665     if (TheColour.IsTransparent())
00666         DragString = _R(IDS_DRAGCOL_DRAGGING_NO_COLOUR);    //"Dragging 'no colour'";
00667     else
00668     {
00669         IndexedColour *TheIxCol = GetInitiallyDraggedColour();
00670         if (TheIxCol != NULL)
00671             DragString += *(TheIxCol->GetName());       // Document IndexedColour
00672         else
00673             DragString += ColourName;                   // Library colour
00674     }
00675 
00676     *TheText = DragString;
00677 
00678     return TRUE;
00679 }

BOOL ColourDragInformation::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 DragInformation.

Definition at line 523 of file dragcol.cpp.

00524 {
00525     ERROR2IF(TheText==NULL,FALSE,"NULL string in GetStatusLineText()");
00526 
00527     String_256 DragString(_R(IDS_DRAGCOL_DRAGGING_COLOUR)); // "Dragging colour '");
00528 
00529     if (TheColour.IsTransparent())
00530         DragString = _R(IDS_DRAGCOL_DRAGGING_NO_COLOUR);    // "Dragging 'no colour' : ";
00531     else
00532     {
00533         IndexedColour *TheIxCol = GetInitiallyDraggedColour();
00534         if (TheIxCol != NULL)
00535             DragString += *(TheIxCol->GetName());       // Document IndexedColour
00536         else
00537             DragString += ColourName;                   // Library colour
00538 
00539         DragString += String_16(_R(IDS_DRAGCOL_DRAGGING_COLOUR_RIGHT_BIT)); // "' : ";
00540     }
00541 
00542     if (pDragTarget->IS_KIND_OF(ViewDragTarget))
00543     {
00544         PageDropInfo PageDropInfo;
00545         ((ViewDragTarget*)pDragTarget)->GetDropInfo(&PageDropInfo);
00546 
00547         NodeRenderableInk* pObjectHit   = PageDropInfo.pObjectHit;
00548         ObjectDragTarget TargetHit      = PageDropInfo.TargetHit;
00549 
00550         String_256 ObjectDesc = _R(IDS_DRAGCOL_THIS_OBJECT); //" this object";
00551 
00552         if (pObjectHit)
00553         {
00554             ObjectDesc = pObjectHit->Describe(FALSE);
00555         }
00556 
00557         ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00558         BOOL IsInside = ClickMods.Constrain;
00559 
00560         if (!IsInside && pObjectHit && pObjectHit->IsCompound())
00561         {
00562             TargetHit = MANY_TARGET;
00563         }
00564 
00565         switch (TargetHit)
00566         {
00567             case FILL_TARGET:
00568                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL)); // "Drop to set the fill colour of this ";
00569                 DragString += ObjectDesc;
00570                 if (IsInside)
00571                     DragString += String_64(_R(IDS_DRAGCOL_ALONE)); // " alone";
00572                 break;
00573             case LINE_TARGET:
00574                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_LINE)); //"Drop to set the line colour of this ";
00575                 DragString += ObjectDesc;
00576                 if (IsInside)
00577                     DragString += String_64(_R(IDS_DRAGCOL_ALONE)); // " alone";
00578                 break;
00579             case STARTCOL_TARGET:
00580                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_START)); //"Drop to set the fill start colour of this ";
00581                 DragString += ObjectDesc;
00582                 break;
00583             case ENDCOL_TARGET:
00584                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_END)); //"Drop to set the fill end colour of this ";
00585                 DragString += ObjectDesc;
00586                 break;
00587             case ENDCOL2_TARGET:
00588                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_END2)); //"Drop to set the fill end colour of this ";
00589                 DragString += ObjectDesc;
00590                 break;
00591             case ENDCOL3_TARGET:
00592                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL_END3)); //"Drop to set the fill end colour of this ";
00593                 DragString += ObjectDesc;
00594                 break;
00595             case MANY_TARGET:
00596                 DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_FILL)); //"Drop to set the fill colour of this ";
00597                 DragString += ObjectDesc;
00598                 DragString += String_64(_R(IDS_DRAGCOL_PRESS_CONTROL)); // "; Press 'Control' to drop 'Inside'";
00599                 break;
00600 
00601             case NO_TARGET:
00602                 if (IsInside)
00603                 {
00604                     DragString += String_256(_R(IDS_DRAGCOL_DROP_SETPAGEBACKGROUND)); // "Drop to set the fill colour of the page background";
00605                 }
00606                 else
00607                 {
00608                     DragString += String_64(_R(IDS_DRAGCOL_DROP_SET_CURRENT_FILL_COLOUR)); // "Drop to set the 'current fill colour' attribute";
00609                 }
00610                 break;
00611         };
00612 
00613         *TheText = DragString;
00614         return TRUE;
00615     }
00616     
00617     return FALSE;
00618 }

BOOL ColourDragInformation::Init void   )  [static]
 

Initialise any Colour Drag stuff. (eg. ini file preferences).

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

Reimplemented from SimpleCCObject.

Definition at line 293 of file dragcol.cpp.

00294 {
00295     // Setup preference for drag transparency
00296     if (GetApplication()->DeclareSection(_T("Dragging"), 1))
00297         GetApplication()->DeclarePref( NULL, _T("ColourDragTransparency"), &DragTransparency, 0, 100);
00298 
00299     return TRUE;
00300 }

void ColourDragInformation::InitObject void   )  [protected]
 

Shared code for initialising the object - called by all constructors.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/96

Definition at line 155 of file dragcol.cpp.

00156 {
00157     // Init member variables
00158     TheColour = DocColour(COLOUR_TRANS);
00159     pParentDoc = NULL;
00160     ColourName = TEXT("");
00161     LibColIsSpot = FALSE;
00162 
00163     // Set up a few things about this drag
00164     DoesSolidDrag = TRUE;
00165     
00166     // offset of colour swatch from the pointer
00167     SolidDragOffset.x = -14;
00168     SolidDragOffset.y = 4;     
00169     
00170     // size of the solid drag redraw
00171     SolidDragSize.x = CellSize;
00172     SolidDragSize.y = CellSize;
00173 }

BOOL ColourDragInformation::IsLibraryColour void   ) 
 

To determine if the dragged colour is from a library or a document.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/96
Returns:
TRUE if this is a "library colour" (has no parent document), or FALSE if the dragged colour resides in a document
See also:
ColourDragInformation::GetParentDoc

Definition at line 320 of file dragcol.cpp.

00321 {
00322     return(GetParentDoc() == NULL);
00323 }

void ColourDragInformation::OnClick INT32  Flags,
CNativePoint  Point
[virtual]
 

This is called if a drag was attempted but never started because it was a click all along. In the base class, the default action is to make the colour bar think that the dragged colour has been clicked.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
[INPUTS] 

Reimplemented from DragInformation.

Definition at line 697 of file dragcol.cpp.

00698 {
00699 //  WEBSTER-ranbirr-27/03/97 No colour bar stuff in webster
00700 // Neville 23/5/97 Now has a Browser palette in the colour line
00701 
00702     if (KeyPress::IsAdjustPressed())
00703         Flags = -1;
00704 
00705     wxRect RectMouseIsIn;
00706     Point = CColourBar::TheColourBar->ScreenToClient(Point);
00707     UINT32 MousePos = CColourBar::TheColourBar->WhereIsMouse(Point, &RectMouseIsIn);
00708 
00709     CColourBar::TheColourBar->CellClicked(MousePos, (Flags < 0));
00710 }

BOOL ColourDragInformation::OnDrawSolidDrag wxPoint  Origin,
wxDC *  TheDC
[virtual]
 

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

Author:
Chris_Snook (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 DragInformation.

Definition at line 730 of file dragcol.cpp.

00731 {
00732     // set up gbrush
00733 //  CPalette * OldPal = NULL;
00734 //  if (PaletteManager::UsePalette())
00735 //  {
00736 //      OldPal = PaletteManager::StartPaintPalette( TheDC );
00737 //  }
00738 
00739     GBrush GDrawBrush;
00740     GDrawBrush.Init(TheDC);
00741     GDrawBrush.Start();
00742 
00743     // get a gbrush brush
00744     Document *ScopeDoc = Document::GetSelected();
00745     ERROR2IF(ScopeDoc == NULL, FALSE, "No Selected Doc !");
00746 
00747     wxBrush* pDragBrush = new wxBrush;
00748     
00749     BOOL BrushCreate = TRUE;
00750 
00751     if (pDragBrush != NULL )
00752     {
00753         if (TheColour.IsTransparent())
00754         {
00755 //          TheDC->SetBkColor(RGB(255,255,255));        // ensure white background
00756             pDragBrush->SetStyle(wxCROSSDIAG_HATCH);
00757             pDragBrush->SetColour(wxColour(0,0,0));     // Fill with black/white cross hatch
00758         }
00759         else
00760         {
00761             DWORD ScreenWord;
00762 
00763             ColourContextRGBT *CCrgbt = (ColourContextRGBT *)
00764                         ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
00765             ScreenWord = ConvertColourToScreenWord(CCrgbt, &TheColour);
00766 
00767             // create the Brush and Pen
00768             if (GDrawBrush.Available())
00769             {
00770                 GDrawBrush.GetLogBrush((COLORREF)ScreenWord, pDragBrush);
00771             }
00772             else
00773                 pDragBrush->SetColour((COLORREF)ScreenWord);
00774         }
00775 
00776         wxPen MyPen(wxColour(0,0,0));
00777 
00778         // Set the brush origin so the dither (or Hatch) patterns
00779         // don't move around as you drag.
00780 //      TheDC->SetBrushOrg(Origin.x, Origin.y);
00781         
00782         //the rectangle to draw into
00783         wxRect DrawRect(Origin.x, Origin.y, SolidDragSize.x-1, SolidDragSize.y-1);
00784 
00785         // select brushes and pens ..
00786         TheDC->SetBrush(*pDragBrush);
00787         TheDC->SetPen(MyPen);
00788 
00789         // draw the thingy. In this case, it's a colour patch, circular for a spot colour, else a square
00790 #ifndef WEBSTER // don't distinguish spots in Webster Martin 15/07/97
00791         if (!TheColour.IsTransparent() && TheColour.GetSpotParent() != NULL)
00792             TheDC->DrawEllipse(DrawRect);
00793         else
00794 #endif // WEBSTER
00795             TheDC->DrawRectangle(DrawRect);
00796                                     
00797         // clean up the dc
00798         TheDC->SetBrush(wxNullBrush);
00799         TheDC->SetPen(wxNullPen);
00800 
00801         // delete the objects
00802         delete pDragBrush;
00803     }
00804     else
00805         BrushCreate = FALSE;
00806     
00807     // Finish with GBrush
00808     GDrawBrush.Stop();
00809 //  if (OldPal)
00810 //      PaletteManager::StopPaintPalette(TheDC, OldPal);
00811     
00812     // problems !!!
00813     ERROR2IF(!BrushCreate, FALSE, "Failed to make a solid drag brush!");
00814 
00815     return TRUE;
00816 }

BOOL ColourDragInformation::OnPageDrop ViewDragTarget pDragTarget  )  [virtual]
 

Called when a colour is dropped on an Object.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/95
Returns:
TRUE if it succeeds, FALSE if there is an error
Notes: This routine assumes that the destination document is the SELECTED doc

Reimplemented from DragInformation.

Definition at line 855 of file dragcol.cpp.

00856 {
00857     PageDropInfo ThePageDropInfo;
00858     ((ViewDragTarget*)pDragTarget)->GetDropInfo(&ThePageDropInfo);
00859 
00860     DocCoord DragPos            = ThePageDropInfo.DropPos;
00861     ObjectDragTarget TargetType = ThePageDropInfo.TargetHit;
00862     NodeRenderableInk* ThisNode = ThePageDropInfo.pObjectHit;
00863 
00864     // DMc 4/10/99
00865     // test for dragging & dropping onto a bevel/shadow/other compound node which
00866     // is grouped
00867     if (ThisNode)
00868     {
00869         if (ThisNode->FindParent())
00870         {
00871             if (!ThisNode->FindParent()->PromoteHitTestOnChildrenToMe())
00872             {
00873                 // any compounds with their 'promotehittest' stuff set above me ?
00874                 Node * pNode = ThisNode->FindParent();
00875                 
00876                 while (pNode)
00877                 {
00878                     if (pNode->IsAnObject())
00879                     {
00880                         if (pNode->PromoteHitTestOnChildrenToMe())
00881                         {
00882                             ThisNode = (NodeRenderableInk *)pNode;
00883                         }
00884                     }
00885                     
00886                     pNode = pNode->FindParent();
00887                 }
00888             }
00889         }
00890     }
00891 
00892     NodeAttribute *Attrib = NULL;
00893     
00894     // Get a colour to apply to the Selected doc
00895     IndexedColour *IxColToApply = GetColourForDocument(NULL);
00896 
00897     // And make a DocColour to apply
00898     DocColour ColourToApply(COLOUR_TRANS);
00899     if (IxColToApply != NULL)
00900         ColourToApply.MakeRefToIndexedColour(IxColToApply);
00901 
00902 
00903     if (TargetType == LINE_TARGET) // apply a stroke colour
00904     {
00905         // Apply a stroke colour to the object(s) we have been dropped onto
00906         Attrib = new AttrStrokeColourChange;
00907         if (Attrib == NULL)
00908             return FALSE;
00909 
00910         ((AttrStrokeColourChange *)Attrib)->SetStartColour(&ColourToApply);
00911         AttributeManager::ApplyAttribToNode(ThisNode, Attrib);
00912     }
00913     else          
00914     {
00915         // Apply a fill colour to the object(s) we have been dropped onto
00916         // This always used to be the case. If there were no objects then we
00917         // just set the current fill colour to be the new one.
00918         // Now, if no objects are the target then apply a page background colour
00919         // otherwise if control is held down set the current fill colour.
00920         
00921         BOOL Constrain = FALSE;
00922 
00923         // get object bounds
00924         DocRect pSimpleBounds;
00925         if (ThisNode)
00926             pSimpleBounds = ThisNode->GetBoundingRect();
00927         else
00928         {
00929             pSimpleBounds.MakeEmpty();
00930             // See if the control key is pressed
00931             Constrain = KeyPress::IsConstrainPressed();
00932         }
00933 
00934         // No node(s) are targetted so see if the constrain key is pressed or not
00935         if (ThisNode == NULL && Constrain)
00936         {
00937             // Use the colour to set the background
00938             // We should use the document given to us by the page info class
00939             OpBackgroundParam Param;
00940             Param.pDocColour = &ColourToApply;
00941             Param.pDoc = ThePageDropInfo.pDoc;          
00942             Param.pSpread = ThePageDropInfo.pSpread;
00943             
00944             // Obtain a pointer to the op descriptor for the create operation 
00945             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_BACKGROUND);
00946 
00947             // Invoke the operation, passing in our parameters
00948             pOpDesc->Invoke(&Param);
00949         }
00950         else
00951         {
00952             // Apply the colour either to the targetted node(s) or as the current
00953             // fill colour, if no nodes are targetted.
00954             Attrib = new AttrColourDrop(DragPos, pSimpleBounds, ColourToApply);
00955             if (Attrib == NULL)
00956                 return FALSE;
00957 
00958             if (ThisNode)
00959                 ((AttrColourDrop*)Attrib)->SetObjectDroppedOn(ThisNode);
00960 
00961             AttributeManager::ApplyAttribToNode(ThisNode, Attrib);
00962         }
00963     }
00964 
00965     return TRUE;
00966 }


Member Data Documentation

String_64 ColourDragInformation::ColourName [protected]
 

Definition at line 190 of file dragcol.h.

INT32 ColourDragInformation::DragTransparency = 0 [static, protected]
 

Definition at line 185 of file dragcol.h.

BOOL ColourDragInformation::LibColIsSpot [protected]
 

Definition at line 192 of file dragcol.h.

Document* ColourDragInformation::pParentDoc [protected]
 

Definition at line 189 of file dragcol.h.

DocColour ColourDragInformation::TheColour [protected]
 

Definition at line 187 of file dragcol.h.


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