SGDisplayColour Class Reference

This DisplayTree node is used by the Colour SuperGallery It is responsible for providing the ability to handle/redraw one IndexedColour displayed in said gallery. More...

#include <sgcolour.h>

Inheritance diagram for SGDisplayColour:

SGDisplayItem SGDisplayNode CCObject SimpleCCObject SGDisplayLibColour List of all members.

Public Member Functions

 SGDisplayColour ()
 SGDisplayColour constructor DON'T call this constructor. Call the other constructor.
 SGDisplayColour (IndexedColour *ColourToDisplay)
 SGDisplayColour constructor.
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
virtual void DragWasReallyAClick (SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
 Handles a mouse click event. This is a callback function - drags of colours from galleries will call this function back if the drag turns out to just be a click.
virtual void GetNameText (String_256 *Result)
 To determine a name string for this node. Generally, this is used for a simple mechanism which searches for display items whose names match given search parameters in some way. It is also used in libraries to provide default redraw methods.
virtual void GetFullInfoText (String_256 *Result)
 To determine a full-info string for this node. Generally, this is used for a simple mechanism which searches for display items whose info matches given search parameters in some way. It is also used in libraries to provide default redraw methods.
virtual BOOL GetBubbleHelp (DocCoord *MousePos, String_256 *Result)
 Called by the parent gallery when bubble help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.
virtual BOOL GetStatusLineHelp (DocCoord *MousePos, String_256 *Result)
 Called by the parent gallery when status line help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.
virtual void MoveAfter (SGDisplayNode *NodeToMove)
 MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.
virtual void MoveBefore (SGDisplayNode *NodeToMove)
 MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.
virtual INT32 CompareTo (SGDisplayNode *Other, INT32 SortKey)
 Compares this node to the 'other' node, to determine their relative positions in the display tree. Returns a value which usually indicates that the other node should be inserted before (-1, or 0) or after (+1) this item.
virtual BOOL IsALibraryColour (void) const
 Proper virtual-function method for differentiating between IndexedColour and library DocColour gallery display items.
virtual BOOL IsASpotColour (void)
 Determine if the displayed colour is a normal or spot colour.
DocColourGetDisplayedColour (void)
 To find out the colour this object is responsible for displaying.

Protected Member Functions

virtual void CalculateMyRect (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
 Shared code for colour items to calculate where they will appear in the grand scheme of things.
virtual void HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
 SGDisplayColour item redraw method - removed from the main HandleEvent method merely to make the code tidier.

Protected Attributes

DocColour TheColour

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayColour)

Detailed Description

This DisplayTree node is used by the Colour SuperGallery It is responsible for providing the ability to handle/redraw one IndexedColour displayed in said gallery.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/10/94
See also:
ColourSGallery; SuperGallery; SGDisplayItem

Definition at line 226 of file sgcolour.h.


Constructor & Destructor Documentation

SGDisplayColour::SGDisplayColour  ) 
 

SGDisplayColour constructor DON'T call this constructor. Call the other constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/94

Definition at line 545 of file sgcolour.cpp.

00546 {
00547     // We don't like people calling this constructor, but we have to put up with it
00548     // now that we have a derived class.
00549 }

SGDisplayColour::SGDisplayColour IndexedColour ColourToDisplay  ) 
 

SGDisplayColour constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/94
Parameters:
ColourToDisplay - The colour this item will display [INPUTS]

Definition at line 566 of file sgcolour.cpp.

00567 {
00568     TheColour.MakeRefToIndexedColour(ColourToDisplay);
00569 }


Member Function Documentation

void SGDisplayColour::CalculateMyRect SGFormatInfo FormatInfo,
SGMiscInfo MiscInfo
[protected, virtual]
 

Shared code for colour items to calculate where they will appear in the grand scheme of things.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/1/95
Parameters:
FormatInfo - The formatting info from which to calculate my position/size [INPUTS] MiscInfo - The MiscInfo, as usual
member variable FormatRect - is returned filled in with the size/position of [OUTPUTS] this colour item's display area. This is dependent upon the current display mode and format state
Scope: private (to sgcolour.cpp, for use of SGDisplayColour class only)

Definition at line 945 of file sgcolour.cpp.

00946 {
00947     const INT32 SGC_FullInfoWidth = SG_InfiniteWidth; //300000;
00948 
00949     INT32 XSize;
00950     INT32 YSize;
00951 
00952     // Note: The text is usually something like 9 point, so a minimum Y size to fit text
00953     // in is going to be around 12 point (12000 millipoints)
00954 
00955     switch (MiscInfo->DisplayMode)
00956     {
00957         case 1:                     // 1 - Full Info
00958             XSize = GridLock(MiscInfo, SGC_FullInfoWidth);
00959             YSize = GridLock(MiscInfo, SG_DefaultSmallIcon);
00960             break;
00961 
00962         case 2:                     // 2 - Icon only, no text at all
00963             XSize = YSize = GridLock(MiscInfo, SG_DefaultLargeIcon);
00964             break;
00965 
00966         default:                    // 0 (Default) - Small icon with name
00967             XSize = GridLock(MiscInfo, SG_ColourNameWidth);
00968             YSize = GridLock(MiscInfo, SG_DefaultSmallIcon);
00969             break;
00970     }
00971 
00972     CalculateFormatRect(FormatInfo, MiscInfo, XSize, YSize);
00973 }

SGDisplayColour::CC_DECLARE_DYNAMIC SGDisplayColour   )  [private]
 

INT32 SGDisplayColour::CompareTo SGDisplayNode Other,
INT32  SortKey
[virtual]
 

Compares this node to the 'other' node, to determine their relative positions in the display tree. Returns a value which usually indicates that the other node should be inserted before (-1, or 0) or after (+1) this item.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/10/94
Parameters:
Other - the node to compare this node to [INPUTS] SortKey - An integer identifying how to compare the items 0 = No sorting (always returns 0) 1 = Sort-by-name Other values will return 0, unless the derived class overrides this method in order to provide other sort modes.
Returns:
negative (I am lesser), 0 (we are equal), or positive (I am greater)
See also:
SGDisplayNode::AddItem

Reimplemented from SGDisplayNode.

Reimplemented in SGDisplayLibColour.

Definition at line 602 of file sgcolour.cpp.

00603 {
00604     ERROR3IF(Other == NULL, "Illegal NULL parameter");
00605 
00606     ERROR3IF(!Other->IsKindOf(CC_RUNTIME_CLASS(SGDisplayColour)),
00607                 "SGDisplayColour::CompareTo - The other item's not a colour!");
00608 
00609     DocColour *OtherCol = ((SGDisplayColour *)Other)->GetDisplayedColour();
00610     DocColour *ThisCol  = GetDisplayedColour();
00611 
00612     switch (SortKey)
00613     {
00614         case SGSORTKEY_BYNAME:
00615             {
00616                 IndexedColour *OtherColIx = OtherCol->FindParentIndexedColour();
00617                 IndexedColour *ThisColIx  = ThisCol->FindParentIndexedColour();
00618 
00619                 // Safety check - if either colour is NULL, then return "equal"
00620                 if (OtherColIx == NULL || ThisColIx == NULL)
00621                     return(0);
00622 
00623                 // We override the base class name comparison, because it is forced to
00624                 // actually copy the names first! This one just compares them in-place
00625                 return(ThisColIx->GetName()->CompareTo( (TCHAR *) (*(OtherColIx->GetName())) ) );
00626             }
00627             break;
00628 
00629 
00630         case SGSORTKEY_BYHUE:
00631         {
00632             ColourContextHSVT   *ColContext;
00633             ColourHSVT  ResultCol;
00634             ColourValue Hue1;
00635 
00636             Document *ParentDoc = ((SGDisplayGroup *)GetParent())->GetParentDocument();
00637 
00638             // Get a default context, or if ParentDoc != NULL, the current context for the doc.
00639             ColContext = (ColourContextHSVT *) ColourManager::GetColourContext(COLOURMODEL_HSVT, ParentDoc);
00640             if (ColContext == NULL)
00641                 return(0);
00642 
00643             // Convert the 2 colours to HSV and compare their Hue values
00644             ColContext->ConvertColour(ThisCol, (ColourGeneric *) &ResultCol);
00645             Hue1 = ResultCol.Hue;
00646 
00647             ColContext->ConvertColour(OtherCol, (ColourGeneric *) &ResultCol);
00648 
00649             if (Hue1 < ResultCol.Hue)
00650                 return(-1);
00651 
00652             return((Hue1 == ResultCol.Hue) ? 0 : 1);
00653         }
00654 
00655 
00656         case SGSORTKEY_BYINTENSITY:
00657         {
00658             ColourContextGreyT  *ColContext;
00659             ColourGreyT         ResultCol;
00660             ColourValue         Intensity1;
00661 
00662             Document *ParentDoc = ((SGDisplayGroup *)GetParent())->GetParentDocument();
00663 
00664             // Get a default context, or if ParentDoc != NULL, the current context for the doc.
00665             ColContext = (ColourContextGreyT *) ColourManager::GetColourContext(COLOURMODEL_GREYT, ParentDoc);
00666             if (ColContext == NULL)
00667                 return(0);
00668 
00669             // Convert the 2 colours to Greyscale and compare their intensity values
00670             ColContext->ConvertColour(ThisCol, (ColourGeneric *) &ResultCol);
00671             Intensity1 = ResultCol.Intensity;
00672 
00673             ColContext->ConvertColour(OtherCol, (ColourGeneric *) &ResultCol);
00674 
00675             if (Intensity1 < ResultCol.Intensity)
00676                 return(-1);
00677 
00678             return((Intensity1 == ResultCol.Intensity) ? 0 : 1);
00679         }
00680 
00681 
00682         case SGSORTKEY_BYMODEL:
00683             return((INT32)ThisCol->GetColourModel() - (INT32)OtherCol->GetColourModel());
00684     }
00685 
00686     // No sorting (SGSORTKEY_NONE - 0), or unknown
00687     return(SGDisplayItem::CompareTo(Other, SortKey));
00688 }

void SGDisplayColour::DragWasReallyAClick SGMouseInfo Mouse,
SGMiscInfo MiscInfo
[virtual]
 

Handles a mouse click event. This is a callback function - drags of colours from galleries will call this function back if the drag turns out to just be a click.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
Parameters:
Mouse - The mouse info passed to the original click handler [INPUTS] MiscInfo - The misc info passed to the original click handler
See also:
SGDisplayColour::HandleEvent; GalleryColourDragInfo::OnClick

Reimplemented from SGDisplayNode.

Definition at line 1218 of file sgcolour.cpp.

01219 {
01220     // Just get default selection action to be applied for this click.
01221     // The TRUE indicates that this is a drag-click, and we previously called 
01222     // the DefaultPreDragHandler - we don't want it to do those same actions twice!
01223     DefaultClickHandler(Mouse, MiscInfo, TRUE);
01224 }

BOOL SGDisplayColour::GetBubbleHelp DocCoord MousePos,
String_256 Result
[virtual]
 

Called by the parent gallery when bubble help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/95
Parameters:
MousePos - The current mouse position. This will generally be expected [INPUTS] to lie inside this item's FormatRect. With it, this item can provide help on specific areas of an item.
On exit, if the return value is TRUE, the string pointed at by Result [OUTPUTS] will contain a bubble help string for this item
Returns:
TRUE if it filled in the string, FALSE if it did not
Notes: The base class returns FALSE (i.e. provides no help) If you can provide help, then override the base class method to do so.

See also:
SGDisplayNode::GetStatusLineHelp

Reimplemented from SGDisplayNode.

Definition at line 1560 of file sgcolour.cpp.

01561 {
01562     ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01563 
01564     return(FALSE);
01565 }

DocColour * SGDisplayColour::GetDisplayedColour void   )  [inline]
 

To find out the colour this object is responsible for displaying.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/1/95
Returns:
A pointer to the colour which this Display Item is used to display.

Definition at line 301 of file sgcolour.h.

00302 {
00303     return(&TheColour);
00304 }

void SGDisplayColour::GetFullInfoText String_256 Result  )  [virtual]
 

To determine a full-info string for this node. Generally, this is used for a simple mechanism which searches for display items whose info matches given search parameters in some way. It is also used in libraries to provide default redraw methods.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/95
Parameters:
On exit, the string pointed at by Result will contain either a blank [OUTPUTS] string, or the full-information text associated with this item (if any)
See also:
SGDisplayColour::GetNameText

Reimplemented from SGDisplayNode.

Definition at line 743 of file sgcolour.cpp.

00744 {
00745     ERROR3IF(Result == NULL, "Illegal NULL param");
00746 
00747     *Result = TEXT("");     // Set a safe default
00748 
00749     // Generate an info string of the form:
00750     // <ColModel> (<components>) [, <tint/link/spot information>] [, not in use]
00751     // e.g.     "HSV(324, 80, 75), Linked to Red"
00752 
00753     String_256 Info(TEXT(""));
00754 
00755     ColourContext *cc = ColourContext::GetGlobalDefault(TheColour.GetColourModel());
00756     ERROR3IF(cc == NULL, "Default colour context is NULL!?");
00757 
00758     ColourGeneric col;
00759     TheColour.GetSourceColour(&col);
00760     cc->GetModelName(&Info);
00761 
00762     String_128  TempStr(TEXT("("));
00763     String_16   CompStr;
00764     if (cc->GetComponentName(1, NULL))
00765     {
00766         double CompVal;
00767         if (TheColour.GetColourModel() == COLOURMODEL_HSVT)
00768             CompVal = (col.Component1.MakeDouble()) * 360.0;
00769         else
00770             CompVal = (col.Component1.MakeDouble()) * 100.0;
00771 
00772         // Convert it to a string rounded to 1 decimal place accuracy
00773         Convert::DoubleToString(CompVal, &CompStr, 1);
00774 
00775         TempStr += CompStr;
00776     }
00777 
00778     if (cc->GetComponentName(2, NULL))
00779     {
00780         Convert::DoubleToString(col.Component2.MakeDouble() * 100.0, &CompStr, 1);
00781         TempStr += TEXT(", ");
00782         TempStr += CompStr;
00783     }
00784 
00785     if (cc->GetComponentName(3, NULL))
00786     {
00787         Convert::DoubleToString(col.Component3.MakeDouble() * 100.0, &CompStr, 1);
00788         TempStr += TEXT(", ");
00789         TempStr += CompStr;
00790     }
00791 
00792     if (cc->GetComponentName(4, NULL))
00793     {
00794         Convert::DoubleToString(col.Component4.MakeDouble() * 100.0, &CompStr, 1);
00795         TempStr += TEXT(", ");
00796         TempStr += CompStr;
00797     }
00798 
00799     TempStr += TEXT(")");
00800     Info    += TempStr;
00801 
00802     IndexedColour *ParentCol = TheColour.FindParentIndexedColour();     // If this refs an IndexedColour...
00803     if (ParentCol != NULL)
00804     {
00805         switch(ParentCol->GetType())
00806         {
00807             case COLOURTYPE_SPOT:
00808                 TempStr.MakeMsg(_R(IDS_COLGAL_ISPOT));
00809                 Info += TempStr;
00810                 break;
00811 
00812             case COLOURTYPE_TINT:
00813                 {
00814                     ERROR3IF(ParentCol->FindLinkedParent() == NULL,
00815                             "A tint without a parent colour? Oh bums!");
00816 
00817                     if (ParentCol->TintIsShade())
00818                     {
00819                         TempStr.MakeMsg(_R(IDS_COLGAL_ISHADE),
00820                                         (TCHAR *) *(ParentCol->FindLinkedParent()->GetName()));
00821                     }
00822                     else
00823                     {
00824                         TempStr.MakeMsg(_R(IDS_COLGAL_ITINT),
00825                                         (INT32) ((ParentCol->GetTintValue().MakeDouble() + 0.005)*100),
00826                                         (TCHAR *) *(ParentCol->FindLinkedParent()->GetName()));
00827                     }
00828                     Info += TempStr;
00829                 }
00830                 break;
00831 
00832             case COLOURTYPE_LINKED:
00833                 {
00834                     ERROR3IF(ParentCol->FindLinkedParent() == NULL,
00835                             "A linked colour without a parent colour? Oh bums!");
00836 
00837                     TempStr.MakeMsg(_R(IDS_COLGAL_ILINKED),
00838                         (TCHAR *) *(ParentCol->FindLinkedParent()->GetName()));
00839                     Info += TempStr;
00840                 }
00841                 break;
00842 
00843             default:
00844                 break;
00845         }
00846 
00847 
00848         SGDisplayGroup *DocumentGroup = (SGDisplayGroup *) GetParent();
00849         ERROR3IF(DocumentGroup == NULL, "SGallery DisplayTree linkage corruption detected");
00850 
00851         Document *ScopeDoc = DocumentGroup->GetParentDocument();
00852         ERROR3IF(ScopeDoc == NULL, "SGallery group is not for a document! Unimplemented! Eek!");
00853 
00854         ColourList *ParentColList = ScopeDoc->GetIndexedColours();
00855         ERROR3IF(ParentColList == NULL, "A document with no colour list? Now I've seen it all");
00856 
00857         if (!ParentColList->IsColourInUseInDoc(ParentCol, TRUE))
00858         {
00859             // Add ' (not in use)' for any colour not currently used in the
00860             // document, or as a linked-colour parent
00861             TempStr.MakeMsg(_R(IDS_COLGAL_INOTUSED));
00862             Info += TempStr;
00863         }
00864     }
00865 
00866     *Result = Info;
00867 }

void SGDisplayColour::GetNameText String_256 Result  )  [virtual]
 

To determine a name string for this node. Generally, this is used for a simple mechanism which searches for display items whose names match given search parameters in some way. It is also used in libraries to provide default redraw methods.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/95
Parameters:
On exit, the string pointed at by Result will contain either a blank [OUTPUTS] string, or the name text associated with this item (if any)
See also:
SGDisplayColour::GetFullInfoText

Reimplemented from SGDisplayNode.

Reimplemented in SGDisplayLibColour.

Definition at line 711 of file sgcolour.cpp.

00712 {
00713     ERROR3IF(Result == NULL, "Illegal NULL param");
00714 
00715     IndexedColour *ParentCol = TheColour.FindParentIndexedColour();
00716     if (ParentCol != NULL)
00717         *Result = *(ParentCol->GetName());
00718     else
00719         Result->MakeMsg(_R(IDS_UNNAMEDCOLOUR));
00720 }

BOOL SGDisplayColour::GetStatusLineHelp DocCoord MousePos,
String_256 Result
[virtual]
 

Called by the parent gallery when status line help is needed. The parent gallery will do a hit test to determine which node contains the pointer, and will then ask that node to supply bubble/status-line help.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/95
Parameters:
MousePos - The current mouse position. This will generally be expected [INPUTS] to lie inside this item's FormatRect. With it, this item can provide help on specific areas of an item.
On exit, if the return value is TRUE, the string pointed at by Result [OUTPUTS] will contain a status line help string for this item
Returns:
TRUE if it filled in the string, FALSE if it did not
Notes: The base class returns FALSE (i.e. provides no help) If you can provide help, then override the base class method to do so.

See also:
SGDisplayNode::GetBubbleHelp

Reimplemented from SGDisplayNode.

Definition at line 1596 of file sgcolour.cpp.

01597 {
01598     ERROR3IF(MousePos == NULL || Result == NULL, "Invalid NULL params");
01599 
01600     *Result = TEXT("");         // Empty the string, just to be safe
01601     GetNameText(Result);        // Start the string with the colour name
01602     *Result += TEXT("; ");
01603 
01604     String_64 Temp;
01605     if (IsSelected())
01606         Temp = _R(IDS_SGCOLOUR_CTRL_CLICK);         // TEXT("Ctrl-click to deselect;");
01607     else
01608         Temp = _R(IDS_SGCOLOUR_CLICK);              // TEXT("Click to select;");
01609 
01610     *Result += Temp;
01611     *Result += String_64(_R(IDS_SGCOLOUR_DOUBLE_CLICK)); // TEXT(" Double-click to apply this colour; Or drag and drop");
01612 
01613     return(TRUE);
01614 }

BOOL SGDisplayColour::HandleEvent SGEventType  EventType,
void *  EventInfo,
SGMiscInfo MiscInfo
[virtual]
 

Handles a SuperGallery DisplayTree event.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/10/94
Parameters:
EventType - An enumerated value describing what type of event is to be processed [INPUTS]
EventInfo - A structure describing the event (may be NULL). The exact thing pointed at by this pointer depends upon the event type:

MonoOn Event Thing EventInfo points at SGEVENT_FORMAT (SGFormatInfo *) SGEVENT_REDRAW (SGRedrawInfo *) SGEVENT_MOUSECLICK (SGMouseInfo *) MonoOff Use the provided SGDisplayNode::Get[Format]Info() inlines to retrieve this information - they provide useful error/type checking, and hide the cast

MiscInfo - always provided. Contains a few useful bits of info that may be needed for all event types.

Parameters:
FormatInfo is updated as appropriate [OUTPUTS]
Returns:
TRUE if the event was handled successfully FALSE if it was not
Notes: This overrides the pure virtual SGDisplayNode::HandleEvent method

A node need not handle a specific event - if it does not handle it, it should return FALSE.

Redraw and Formatting handlers should never return TRUE, as this will prevent the event from continuing through the tree.

Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order to pass the event dow the tree. THIS node is a leaf-node, so it doesn't.

See also:
SGDisplayNode::HandleEvent

Reimplemented from SGDisplayItem.

Reimplemented in SGDisplayLibColour.

Definition at line 1275 of file sgcolour.cpp.

01277 {
01278     switch (EventType)
01279     {
01280         case SGEVENT_FORMAT:
01281             {
01282                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
01283                 CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
01284             }
01285             break;
01286 
01287 
01288         case SGEVENT_REDRAW:
01289             {
01290                 DocRect MyRect(FormatRect);     // Rely on FormatRect being cached from above
01291                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
01292 
01293                 if (IMustRedraw(RedrawInfo))
01294                     HandleRedraw(RedrawInfo, MiscInfo);
01295             }
01296             break;      // exit and return FALSE to pass the redraw event on
01297 
01298 
01299         case SGEVENT_MOUSECLICK:
01300             {
01301                 SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
01302 
01303                 if (FormatRect.ContainsCoord(Mouse->Position))
01304                 {
01305                     // If the colour is in the selected document, then it is safe to
01306                     // do a colour drag - for now, it will only allow drags for the
01307                     // selected doc.
01308                     // Otherwise, the normal click action takes place.
01309                     // If the drag fails (turns into a click) then the normal click action
01310                     // takes place, passed on by the GalleryColourDragInfo::OnClick handler
01311                     SGDisplayGroup *Parent = (SGDisplayGroup *) GetParent();
01312 
01313                     if (Mouse->DoubleClick) // || Parent->GetParentDocument() != Document::GetSelected())
01314                     {
01315                         // Use the default click handler.
01316                         // However, because we assign a very special meaning to adjust-double-click (apply
01317                         // line colour) we don't want the default action (apply & close gallery) to take
01318                         // effect, so we pass in FALSE as the last parameter.
01319                         DefaultClickHandler(Mouse, MiscInfo, FALSE, FALSE);
01320                     }
01321                     else
01322                     {
01323                         DefaultPreDragHandler(Mouse, MiscInfo);
01324 
01325                         // Start a drag, but only if there are selected documents around
01326                         if (Document::GetSelected() != NULL)
01327                         {
01328                             GalleryColourDragInfo *DragCol;
01329                             DragCol = new GalleryColourDragInfo(Parent->GetParentDocument(),
01330                                                                 this, Mouse, MiscInfo,
01331                                                                 Mouse->MenuClick);
01332 
01333                             if (DragCol != NULL)
01334                                 DragManagerOp::StartDrag(DragCol, GetListWindow());
01335                         }
01336                     }
01337 
01338                     return(TRUE);       // Claim this event - nobody else can own this click
01339                 }
01340             }
01341             break;
01342 
01343 
01344         default:
01345             return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
01346     }
01347 
01348     // Default return value: We do not claim this event, so it will be passed on to others
01349     return(FALSE);
01350 }

void SGDisplayColour::HandleRedraw SGRedrawInfo RedrawInfo,
SGMiscInfo MiscInfo
[protected, virtual]
 

SGDisplayColour item redraw method - removed from the main HandleEvent method merely to make the code tidier.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/1/95
Parameters:
RedrawInfo - The information on the kernel-rendered redraw area [INPUTS] FormatInfo - The formatting information structure
member variable FormatRect should be set up (before calling this method) to be the rectangle in which to draw this item

Scope: private

Definition at line 1052 of file sgcolour.cpp.

01053 {
01054     StartRendering(RedrawInfo, MiscInfo);
01055 
01056     DocRect MyRect(FormatRect);
01057 
01058     RenderRegion *Renderer = RedrawInfo->Renderer;
01059 
01060     INT32 OnePixel  = (INT32) DevicePixels(MiscInfo, 1);
01061     INT32 TwoPixels = (INT32) DevicePixels(MiscInfo, 2);
01062 
01063     DocRect IconRect(MyRect);       // Create a square icon at the left end of our rectangle
01064     IconRect.hi.x = IconRect.lo.x + IconRect.Height();
01065     MyRect.lo.x = IconRect.hi.x + TwoPixels;
01066 
01067     // Redraw the icon
01068     GridLockRect(MiscInfo, &IconRect);  
01069 
01070     Renderer->SetLineWidth(0);
01071     Renderer->SetLineColour(RedrawInfo->Transparent);
01072 
01073     // If selected, we have a 3-pixel-thick selection border
01074     // Otherwise (as is now the case) we have a single-pixel black border
01075     // We draw border "lines" using rectangle fills, else it screws pixel alignment
01076     if (!Flags.Selected)
01077         IconRect.Inflate(-TwoPixels);
01078 
01079     IndexedColour *IxCol = TheColour.FindParentIndexedColour();
01080 
01081     // Draw (selection border and) border
01082     // The patch is normally a square (process colour), but for spot colours
01083     // is drawn as a circle, in order to make the distinction more obvious
01084     //
01085     // WEBSTER - markn 23/1/97
01086     // No Circles required.
01087     //
01088     DocColour black(COLOUR_BLACK);
01089     Renderer->SetFillColour(black);
01090 #ifndef WEBSTER
01091     if (IsASpotColour())
01092     {
01093         IconRect.Inflate(-OnePixel);
01094         DrawCircle(Renderer, IconRect);
01095     }
01096     else
01097 #endif // WEBSTER
01098         Renderer->DrawRect(&IconRect);              // And draw it
01099 
01100     // Now deflate further, to get inside the selection & border...
01101     IconRect.Inflate((Flags.Selected)  ? -(TwoPixels+OnePixel) : -OnePixel);
01102 
01103     // Draw the colour patch (icon)
01104     // Save and restore the context while using TheColour to fill with. This is so that
01105     // the renderer no longer references the IndexedColour, so that GetFullInfoText will
01106     // put the text '(not in use)' on the end of colours which aren't used in the document!
01107     Renderer->SaveContext();
01108     Renderer->SetFillColour(TheColour);         // Fill with colour to display
01109 
01110     // The patch is normally a square (process colour), but for spot colours
01111     // is drawn as a circle, in order to make the distinction more obvious
01112     //
01113     // WEBSTER - markn 23/1/97
01114     // No Circles required.
01115     //
01116 #ifndef WEBSTER
01117     if (IsASpotColour())
01118         DrawCircle(Renderer, IconRect);
01119     else
01120 #endif // WEBSTER
01121         Renderer->DrawRect(&IconRect);              // And draw it
01122     Renderer->RestoreContext();
01123 
01124     // Redraw the name text, if there is room to the right of the icon
01125     if (MyRect.lo.x < MyRect.hi.x)
01126     {
01127         GridLockRect(MiscInfo, &MyRect);
01128 
01129 //      IndexedColour *ParentCol = TheColour.FindParentIndexedColour();
01130 
01131         if (Flags.Selected)
01132         {
01133             // Fill the entire background with the 'selected' colour, so we don't
01134             // get gaps between bits of text or uneven rectangles in multiple selections
01135             Renderer->SetFillColour(RedrawInfo->SelBackground);
01136             Renderer->DrawRect(&MyRect);
01137 
01138             Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
01139 
01140             if (IxCol != NULL)  // Only do this for IndexedColours (i.e. not derived class Library colours)
01141             {
01142                 // If this item represents the current line colour, then place a vertical line between the icon
01143                 // and the text to indicate this fact.
01144                 DocColour *LineCol;
01145                 ColourManager::GetCurrentLineAndFillColours(&LineCol, NULL);
01146 
01147                 if (LineCol != NULL && LineCol->FindParentIndexedColour() == TheColour.FindParentIndexedColour())
01148                 {
01149                     // This item is selected and is the current line colour. Put a mark in to indicate this
01150                     DocColour black(COLOUR_BLACK);
01151                     Renderer->SetLineColour(black);
01152                     Renderer->SetLineWidth(TwoPixels);
01153                     Renderer->DrawLine(MyRect.lo, DocCoord(MyRect.lo.x, MyRect.hi.y));
01154                 }
01155             }
01156         }
01157         else
01158             Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &RedrawInfo->Background);
01159 
01160         MyRect.lo.x += SG_GapBeforeText;    // Leave a small gap before text begins
01161 
01162         String_256 Name;
01163         GetNameText(&Name);                 // Get the name string
01164 
01165         if (MiscInfo->DisplayMode == 1)     // If in Full Info mode...
01166         {
01167             DocRect TextRect(MyRect);
01168 
01169             // Reserve space for the name (clip it if it won't fit)
01170             if (TextRect.hi.x - TextRect.lo.x > SG_ColourNameWidth)
01171                 TextRect.hi.x = TextRect.lo.x + SG_ColourNameWidth;
01172 
01173             // Draw the name text next to the icon
01174             Renderer->DrawFixedSystemText(&Name, TextRect);
01175             
01176             // Move to the right, to fill the remaining space with information
01177             // (Leave a 6-pixel gap in case the name didn't all fit in the available space)
01178             TextRect.lo.x = TextRect.hi.x + DevicePixels(MiscInfo, 6);
01179             TextRect.hi.x = MyRect.hi.x;
01180             if (TextRect.lo.x < TextRect.hi.x)      // If any room left for info...
01181             {
01182                 // Get the full info description, and render it
01183                 GetFullInfoText(&Name);
01184                 Renderer->DrawFixedSystemText(&Name, TextRect);
01185             }
01186         }
01187         else
01188         {
01189             // Not full-info mode, so we only render the colour name next to the patch
01190             Renderer->DrawFixedSystemText(&Name, MyRect);
01191         }
01192     }
01193 
01194     StopRendering(RedrawInfo, MiscInfo);
01195 }

BOOL SGDisplayColour::IsALibraryColour void   )  const [virtual]
 

Proper virtual-function method for differentiating between IndexedColour and library DocColour gallery display items.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/8/96
Parameters:
- [INPUTS]
Returns:
FALSE if this is a base-class SGDisplayColour (IndexedColour) TRUE if this is a derived class SGDisplayLibColour (library DocColour)
Notes: Always returns FALSE

Reimplemented in SGDisplayLibColour.

Definition at line 889 of file sgcolour.cpp.

00890 {
00891     return(FALSE);
00892 }

BOOL SGDisplayColour::IsASpotColour void   )  [virtual]
 

Determine if the displayed colour is a normal or spot colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/9/96
Parameters:
- [INPUTS]
Returns:
FALSE if this is a normal colour TRUE if this is a spot colour

Reimplemented in SGDisplayLibColour.

Definition at line 911 of file sgcolour.cpp.

00912 {
00913     if (TheColour.FindParentIndexedColour() != NULL)
00914     {
00915         if (TheColour.FindParentIndexedColour()->IsSpotOrTintOfSpot())
00916             return(TRUE);
00917     }
00918 
00919     return(FALSE);
00920 }

void SGDisplayColour::MoveAfter SGDisplayNode NodeToMove  )  [virtual]
 

MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/3/95
Parameters:
NodeToMove - the node to move [INPUTS]
Notes: This base class method simply delinks the item and relinks it elsewhere in the display tree. However, derived classes will override this method so that moving display items can have a further effect of also rearranging the displayed "real" items. Before/After moving the real item, the derived class can then call this baseclass method to complete the action.

Take care when moving items between groups (e.g. if an item is "moved" from one docuemnt to another, it could be a bad thing, so be very careful in derived classes to take appropriate action)

Any attempt to move an item after *itself* is queitly ignored

Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayColour::InsertAfter; SGDisplayColour::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1385 of file sgcolour.cpp.

01386 {
01387     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01388 
01389     if (NodeToMove == this)
01390         return;
01391 
01392     if (IsALibraryColour())
01393         LibraryHasBeenSorted = TRUE;
01394 
01395     DocColour *DocColToMove = ((SGDisplayColour *) NodeToMove)->GetDisplayedColour();
01396     ERROR3IF(DocColToMove == NULL, "NULL displayed colour?!");
01397 
01398     IndexedColour *ColToMove = DocColToMove->FindParentIndexedColour();
01399 
01400     IndexedColour *TargetColour = TheColour.FindParentIndexedColour();
01401     if (ColToMove == NULL || TargetColour == NULL)
01402     {
01403         // If either colour is a library colour, then no need to move colours in the
01404         // document colour list, so just move the display nodes appropriately and return.
01405         SGDisplayNode::MoveAfter(NodeToMove);
01406         return;
01407     }
01408 
01409     Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01410     ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01411 
01412     if ( ((SGDisplayGroup *) ( ((SGDisplayColour *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01413             ScopeDoc)
01414     {
01415         ERROR2RAW("Attempt to MOVE a colour between documents!");
01416         InformError();
01417         return;
01418     }
01419 
01420     ColourList *ColList = ScopeDoc->GetIndexedColours();
01421     ERROR3IF(ColList == NULL, "A document with no colour list?!");
01422     
01423     ColList->RemoveItem(ColToMove);
01424     ColList->InsertAfter(TargetColour, ColToMove);
01425 
01426     SGDisplayNode::MoveAfter(NodeToMove);
01427 
01428 // We do not need to do the following - the parent gallery will do it when it is called
01429 // with SuperGallery::AllItemsCopied. This allows us to be called many times in a row
01430 // without generating more than one broadcast.
01431 
01432 //  // Inform the world, and lock out changes in the colour gallery
01433 //  ColourSGallery *ParentGallery = (ColourSGallery *)GetParentGallery();
01434 //  BOOL OldSentState = ParentGallery->ISentTheMessage;
01435 //  ParentGallery->ISentTheMessage = TRUE;
01436 //  
01437 //  ColourManager::ColourListHasChanged(ColList);
01438 //  
01439 //  ParentGallery->ISentTheMessage = OldSentState;
01440 }

void SGDisplayColour::MoveBefore SGDisplayNode NodeToMove  )  [virtual]
 

MOVES the given node (to a different position in the DisplayTree) as the previous (left) sibling of this node. If the node is not linked into a tree, it is effectively just inserted.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/3/95
Parameters:
NodeToMove - the node to move [INPUTS]
Notes: This base class method simply delinks the item and relinks it elsewhere in the display tree. However, derived classes will override this method so that moving display items can have a further effect of also rearranging the displayed "real" items. Before/After moving the real item, the derived class can then call this baseclass method to complete the action.

Take care when moving items between groups (e.g. if an item is "moved" from one docuemnt to another, it could be a bad thing, so be very careful in derived classes to take appropriate action)

Any attempt to move an item before *itself* is queitly ignored

Returns:
Errors: ERROR3 and quiet exit if NodeToMove == NULL
See also:
SuperGallery; SGDisplayColour::InsertBefore; SGDisplayColour::AddItem

Reimplemented from SGDisplayNode.

Definition at line 1475 of file sgcolour.cpp.

01476 {
01477     ERROR3IF(NodeToMove == NULL, "Illegal NULL param");
01478 
01479     if (NodeToMove == this)
01480         return;
01481 
01482     if (IsALibraryColour())
01483         LibraryHasBeenSorted = TRUE;
01484 
01485     DocColour *DocColToMove = ((SGDisplayColour *) NodeToMove)->GetDisplayedColour();
01486     ERROR3IF(DocColToMove == NULL, "NULL displayed colour?!");
01487     IndexedColour *ColToMove = DocColToMove->FindParentIndexedColour();
01488 
01489     IndexedColour *TargetColour = TheColour.FindParentIndexedColour();
01490     if (ColToMove == NULL || TargetColour == NULL)
01491     {
01492         // If either colour is a library colour, then no need to move colours in the
01493         // document colour list, so just move the display nodes appropriately and return.
01494         SGDisplayNode::MoveBefore(NodeToMove);
01495         return;
01496     }
01497 
01498     Document *ScopeDoc = ((SGDisplayGroup *) GetParent())->GetParentDocument();
01499     ERROR3IF(ScopeDoc == NULL, "No parent document?!");
01500 
01501     if ( ((SGDisplayGroup *) ( ((SGDisplayColour *)NodeToMove)->GetParent() ) )->GetParentDocument() !=
01502             ScopeDoc)
01503     {
01504         ERROR2RAW("Attempt to MOVE a colour between documents!");
01505         InformError();
01506         return;
01507     }
01508 
01509     ColourList *ColList = ScopeDoc->GetIndexedColours();
01510     ERROR3IF(ColList == NULL, "A document with no colour list?!");
01511     
01512     ColList->RemoveItem(ColToMove);
01513     ColList->InsertBefore(TargetColour, ColToMove);
01514 
01515     SGDisplayNode::MoveBefore(NodeToMove);
01516 
01517 // We do not need to do the following - the parent gallery will do it when it is called
01518 // with SuperGallery::AllItemsCopied. This allows us to be called many times in a row
01519 // without generating more than one broadcast.
01520 
01521 //  // Inform the world, and lock out changes in the colour gallery
01522 //  ColourSGallery *ParentGallery = (ColourSGallery *)GetParentGallery();
01523 //  BOOL OldSentState = ParentGallery->ISentTheMessage;
01524 //  ParentGallery->ISentTheMessage = TRUE;
01525 //  
01526 //  ColourManager::ColourListHasChanged(ColList);
01527 //  
01528 //  ParentGallery->ISentTheMessage = OldSentState;
01529 }


Member Data Documentation

DocColour SGDisplayColour::TheColour [protected]
 

Definition at line 283 of file sgcolour.h.


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