SGDisplayItem Class Reference

This DisplayTree node is used by the SuperGallery It is responsible for providing the ability to redraw one item displayed in the gallery, and remembering information on that item (such as its selection state, etc). More...

#include <sgtree.h>

Inheritance diagram for SGDisplayItem:

SGDisplayNode CCObject SimpleCCObject LineAttrItem SGDisplayColour SGDisplayDATATYPE SGDisplayKernelBitmap SGDisplayLayer SGDisplayPreviewFonts SGLibDisplayItem SGNameItem SGNameItem List of all members.

Public Member Functions

 SGDisplayItem ()
 DisplayItem constructor.
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
virtual BOOL DefaultPreDragHandler (SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
 Provides part 1 of the default selection model for clicks on gallery display items. Should be called by all derived gallery DisplayItems to handle clicks upon them, when multiple-selection support is desired.
virtual BOOL DefaultClickHandler (SGMouseInfo *Mouse, SGMiscInfo *MiscInfo, BOOL AfterDrag=FALSE, BOOL AdjustDoubleClick=TRUE)
 Provides the default selection model for clicks on gallery display items. Should be called by all derived gallery DisplayItems to handle clicks upon them, when multiple-selection support is desired.
virtual void RemoveFromTree (void)
 De-links this node/subtree from the DisplayTree. This DOES NOT DELETE the node, just unlinks it in preparation for being deleted.
virtual void AddItem (SGDisplayNode *NodeToInsert, SGSortKey *SortInfo=NULL)
 OVERRIDES the DisplayNode action, and gives an ERROR3 - DisplayItems are only allowed to be leaf-nodes, and hence you cannot insert items as children of them.

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayItem)

Detailed Description

This DisplayTree node is used by the SuperGallery It is responsible for providing the ability to redraw one item displayed in the gallery, and remembering information on that item (such as its selection state, etc).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/10/94
Generally, SGDisplayItems should only occur as leaf-nodes - this base class overrides the methods of SGDisplayNodes in order to discourage any attempt to make these nodes non-leaf-nodes.

This class should be used to derive new DisplayItem classes from for each of the SuperGalleries. For example, the Froodle SuperGallery might provide two types of SGDisplayItem: MonoOn FroodleSGDisplayItem (which holds a pointer to a Froodle in a document) LibFroodleSGDisplayItem (which holds the information on a Froodle in an open FroodleLibrary file) MonoOff

See also:
SuperGallery; SGDisplayNode; SGDisplayRoot; SGDisplayGroup

Definition at line 1509 of file sgtree.h.


Constructor & Destructor Documentation

SGDisplayItem::SGDisplayItem  ) 
 

DisplayItem constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/95

Definition at line 5434 of file sgtree.cpp.

05435 {
05436     // Items can be selected
05437     Flags.CanSelect = TRUE;
05438 }


Member Function Documentation

void SGDisplayItem::AddItem SGDisplayNode NodeToInsert,
SGSortKey SortInfo = NULL
[virtual]
 

OVERRIDES the DisplayNode action, and gives an ERROR3 - DisplayItems are only allowed to be leaf-nodes, and hence you cannot insert items as children of them.

Parameters:
NodeToInsert - the node/subtree to be inserted [INPUTS] SortInfo - NULL, or an array of MaxSGSortKeys sort key structures, which describes the sort mode to be used for determining the position of the insertion.
See also:
SuperGallery; SGDisplayNode::InsertAfter; SGDisplayNode::InsertBefore

Reimplemented from SGDisplayNode.

Definition at line 5556 of file sgtree.cpp.

05557 {
05558     ERROR3("You can't SGDisplayItem::AddItem() - DisplayItems are supposed to be leaf nodes");
05559 }

SGDisplayItem::CC_DECLARE_DYNAMIC SGDisplayItem   )  [private]
 

BOOL SGDisplayItem::DefaultClickHandler SGMouseInfo Mouse,
SGMiscInfo MiscInfo,
BOOL  AfterDrag = FALSE,
BOOL  AdjustDoubleClick = TRUE
[virtual]
 

Provides the default selection model for clicks on gallery display items. Should be called by all derived gallery DisplayItems to handle clicks upon them, when multiple-selection support is desired.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/2/94
Parameters:
Mouse - Information on the mouse state for this click [INPUTS] MiscInfo - the normal info as passed to event handlers AfterDrag - TRUE if this is being called when a drag turns into a click, and you called DefaultPreDragHandler before the drag started
AdjustDoubleClick - Override for derived classes to enable/disable the default adjust-double-click action (which closes the gallery after apply). The colour gallery has a special meaning for adjust-double-click, so overrides this variable to pass in FALSE and disable default action.

Returns:
TRUE if the click caused any action to be taken (selection state to change) FALSE if the click was ignored for whatever reason
Notes: The code for this has now been moved into the SGDisplayNode base class since group selection is now also required.

See also:
SuperGallery; SGDisplayNode::InsertAfter; SGDisplayNode::InsertBefore

Reimplemented from SGDisplayNode.

Definition at line 5661 of file sgtree.cpp.

05663 {
05664     return(SGDisplayNode::DefaultClickHandler(Mouse, MiscInfo, AfterDrag, AdjustDoubleClick));
05665 }

BOOL SGDisplayItem::DefaultPreDragHandler SGMouseInfo Mouse,
SGMiscInfo MiscInfo
[virtual]
 

Provides part 1 of the default selection model for clicks on gallery display items. Should be called by all derived gallery DisplayItems to handle clicks upon them, when multiple-selection support is desired.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/95
Parameters:
Mouse - Information on the mouse state for this click [INPUTS] MiscInfo - the normal info as passed to event handlers
Returns:
TRUE if the click caused any action to be taken (selection state to change) FALSE if the click was ignored for whatever reason
You should call this method immediately prior to starting a drag as a result of a click event. Note that it is paired with DefaultClickHandler (which should be called when the drag you start turns out to be a click, if you want multiple-selection capability).

See the SGDisplayColour (kernel.cpp) for an example of use

Notes: The code for this has now been moved into the SGDisplayNode base class since group selection is now also required.

See also:
SGDisplayItem::DefaultClickHandler; SGDisplayColour::HandleEvent

Reimplemented from SGDisplayNode.

Definition at line 5621 of file sgtree.cpp.

05622 {
05623     return(SGDisplayNode::DefaultPreDragHandler(Mouse, MiscInfo));
05624 }

BOOL SGDisplayItem::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:
See SGDisplayNode::HandleEvent [INPUTS]
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.

ClaimPoint handlers should always return FALSE, unless they contain the given point, in which case they should return TRUE.

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.

Derived DisplayItem classes should call this base class method if they wish to handle CLAIMPOINT broadcasts to provide drag-target detection.

See also:
SGDisplayNode::HandleEvent; SGDisplayRoot::HandleEvent; SGDisplayGroup::HandleEvent

Reimplemented from SGDisplayNode.

Reimplemented in SGNameItem, SGDisplayDATATYPE, SGDisplayKernelBitmap, SGDisplayColour, SGDisplayLibColour, SGDisplayFrame, SGDisplayLayer, SGClipartItem, SGFillsItem, SGLibDisplayItem, LineAttrItem, SGNameItem, SGDisplayPreviewFonts, and SGLibFontItem.

Definition at line 5479 of file sgtree.cpp.

05481 {
05482     switch(EventType)
05483     {
05484         case SGEVENT_CLAIMPOINT:
05485             {
05486                 SGClaimPointInfo *PointInfo = GetClaimPointInfo(EventType, EventInfo);
05487 
05488                 // If the point hit us, we must claim the event so that the caller
05489                 // knows which tree item contains the point.
05490                 if (FormatRect.ContainsCoord(PointInfo->Position))
05491                 {
05492                     PointInfo->ClosestSoFar = 0;
05493                     PointInfo->Claimant = this;     // Let 'em know it was me!
05494                     return(TRUE);
05495                 }
05496 
05497                 // OK, we don't OWN the point, but are we closer to it than anyone else
05498                 // checked so far? If so, we update ClosestSoFar and Claimant, but we
05499                 // do not claim the event (so others can check if they are closer)
05500                 
05501                 // Find the distance to the 2 closest edges of the rectangle. Then
05502                 // the approx. distance to the rectangle is the larger of the two.
05503                 INT32 XDist = 0;
05504                 if (FormatRect.lo.x > PointInfo->Position.x)
05505                     XDist = FormatRect.lo.x - PointInfo->Position.x;
05506                 else if (FormatRect.hi.x < PointInfo->Position.x)
05507                     XDist = PointInfo->Position.x - FormatRect.lo.x;
05508 
05509                 INT32 YDist = 0;
05510                 if (FormatRect.lo.y > PointInfo->Position.y)
05511                     YDist = FormatRect.lo.y - PointInfo->Position.y;
05512                 else if (FormatRect.hi.y < PointInfo->Position.y)
05513                     YDist = PointInfo->Position.y - FormatRect.lo.y;
05514 
05515                 XDist = max(XDist, YDist);  // XDist is now approx the dist to the point
05516 
05517                 if (XDist < PointInfo->ClosestSoFar)
05518                 {
05519                     PointInfo->Claimant = this;
05520                     PointInfo->ClosestSoFar = XDist;
05521                     // drop through to pass the event on...
05522                 }
05523             }
05524             break;
05525 
05526 
05527         default:
05528             return(SGDisplayNode::HandleEvent(EventType, EventInfo, MiscInfo));
05529     }
05530 
05531     return(FALSE);
05532 }

void SGDisplayItem::RemoveFromTree void   )  [virtual]
 

De-links this node/subtree from the DisplayTree. This DOES NOT DELETE the node, just unlinks it in preparation for being deleted.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/2/95
Notes: This method calls SGDisplayNode::RemoveFromTree to do all the work. It is overridden simply so that display items can deselect themselves and inform the parent gallery if they were the selected node, so that pointers to removed nodes are not kept lying around.

See also:
SGDisplayNode::RemoveFromTree

Reimplemented from SGDisplayNode.

Definition at line 5582 of file sgtree.cpp.

05583 {
05584 //  SetSelected(FALSE);
05585     SGDisplayNode::RemoveFromTree();
05586 }


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