#include <sgtree.h>
Inheritance diagram for SGDisplayRoot:
Public Member Functions | |
SGDisplayRoot (SuperGallery *ParentGal) | |
SGDisplayRoot constructor (makes root nodes invisible by default). | |
virtual SGDisplayNode * | GetChild (void) const |
Finds the child of this DisplayTree Node. Returns NULL if you have reached the boundary of the tree. | |
virtual SuperGallery * | GetParentGallery (void) const |
Returns the SuperGallery which 'owns' this node (and its subtree). | |
virtual void | InsertAfter (SGDisplayNode *NodeToInsert) |
OVERRIDES SGDisplayNode::InsertAfter. | |
virtual void | InsertBefore (SGDisplayNode *NodeToInsert) |
OVERRIDES SGDisplayNode::InsertBefore. | |
virtual void | RemoveFromTree (void) |
OVERRIDES SGDisplayNode::RemoveFromTree The root node cannot be removed from the tree - it returns quietly, taking no action (this allows the generic treatment of DestroyTree to work without having to take special action for delinking the root node). | |
virtual void | DestroySubtree (BOOL IncludingThisNode=TRUE) |
DESTROYS the subtree starting at this root node. This does a depth-first recursive scan of the subtree, delinking each item, and then CALLING EACH ITEMS DESTRUCTOR. | |
virtual void | InitFormatInfo (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo) |
Resets the formatting info structure to default values for the start of a formatting pass. Must be called before SGDisplayRoot::Redraw. | |
virtual BOOL | HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo) |
Handles a SuperGallery DisplayTree event. | |
virtual INT32 | CalculateListExtent (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo) |
Causes the entire subtree from this node to format themselves, and returns the 'height' of the entire list display, in millipoints. | |
virtual INT32 | GetCachedListExtent (void) |
Returns the 'height' of the entire list display, in millipoints. This return value is only valid after the tree has been formatted (including a previous call to CalculateListExtent), so long as the cached tree format is still valid. Use with care. | |
virtual void | SetScrollOffset (INT32 NewOffset, SGMiscInfo *MiscInfo) |
Changes the scroll offset, and if necessary, redraws the scroll bar. | |
virtual INT32 | GetScrollOffset (void) |
virtual void | RedrawScrollBar (SGMiscInfo *MiscInfo) |
Causes the scroll bar, if any, to be redrawn. In the base class, this method does nothing. | |
virtual SGDisplayItem * | FindNextSelectedItem (SGDisplayNode *CurrentItem=NULL, BOOL *SkipGroup=NULL) |
Scanning the selection within a Display Tree - this will scan over multiple documents/libraries without blinking an eyelid. | |
virtual INT32 | GetSelectedItemCount (void) |
To determine how many eaf items of this tree are selected. | |
virtual SGDisplayGroup * | FindNextSelectedGroup (SGDisplayNode *CurrentGroup=NULL) |
Scanning the group-selection within a Display Tree. | |
virtual INT32 | GetSelectedGroupCount (void) |
To determine how many eaf Groups of this tree are selected. | |
virtual void | SelectRange (SGDisplayNode *PrimeNode, SGDisplayNode *AnchorNode) |
Selects the PrimeNode, and if possible, all sibling nodes between it and the Anchor node. If Anchor == NULL or is not found, only PrimeNode is selected. Does not deselect any nodes - you should call SelectItems first to clear the seln. | |
Static Public Member Functions | |
static SGDisplayNode * | FindNextItemInTree (SGDisplayNode *StartItem) |
Given an item in the tree, find the next one. | |
Protected Member Functions | |
SGDisplayRoot () | |
Dumps TRACE output to the debugger showing the layout of the tree THIS FUNCTION IS ONLY PRESENT IN DEBUG BUILDS (ifdef _DEBUG) It will also only produce debug output if your UserName is "Jason"SGDisplayRoot constructor (makes root nodes invisible by default). | |
virtual void | SetChild (SGDisplayNode *NewChild) |
Sets the child of this DisplayTree Node. Overrides to base class method to allow the child to be set. | |
Protected Attributes | |
SGDisplayNode * | Child |
SuperGallery * | ParentGallery |
INT32 | ScrollExtent |
Private Member Functions | |
CC_DECLARE_DYNAMIC (SGDisplayRoot) |
If the root node has no children, it becomes visible, redrawing itself as a piece of grey text reading 'No items' or similar.
Definition at line 1157 of file sgtree.h.
|
Dumps TRACE output to the debugger showing the layout of the tree THIS FUNCTION IS ONLY PRESENT IN DEBUG BUILDS (ifdef _DEBUG) It will also only produce debug output if your UserName is "Jason"SGDisplayRoot constructor (makes root nodes invisible by default).
Definition at line 2896 of file sgtree.cpp. 02897 { 02898 Child = NULL; 02899 02900 Flags.Invisible = TRUE; // The root node is always invisible 02901 ParentGallery = NULL; 02902 ScrollExtent = 0; 02903 02904 ERROR3("SGDisplayRoot constructed in an illegal manner"); 02905 }
|
|
SGDisplayRoot constructor (makes root nodes invisible by default).
Definition at line 2924 of file sgtree.cpp. 02925 { 02926 Child = NULL; 02927 02928 Flags.Invisible = TRUE; // The root node is always invisible 02929 ParentGallery = ParentGal; 02930 ScrollExtent = 0; 02931 }
|
|
Causes the entire subtree from this node to format themselves, and returns the 'height' of the entire list display, in millipoints.
Definition at line 3298 of file sgtree.cpp. 03299 { 03300 if (GetChild() == NULL) 03301 return(0); 03302 03303 // Ask ourself to handle a FORMAT event. This recursively formats the tree, and returns 03304 // with FormatInfo indicating the state at the end of formatting (FormatInfo->LinePos 03305 // is at the end position of the list, and hence gives us the extent) 03306 HandleEvent(SGEVENT_FORMAT, FormatInfo, MiscInfo); 03307 return(ScrollExtent); 03308 }
|
|
|
|
DESTROYS the subtree starting at this root node. This does a depth-first recursive scan of the subtree, delinking each item, and then CALLING EACH ITEMS DESTRUCTOR.
Reimplemented from SGDisplayNode. Definition at line 3108 of file sgtree.cpp. 03109 { 03110 // Destroy all our children, but DO NOT delete 'this' node! 03111 SGDisplayNode::DestroySubtree(FALSE); 03112 }
|
|
Given an item in the tree, find the next one.
Definition at line 3718 of file sgtree.cpp. 03719 { 03720 ERROR3IF(StartItem == NULL, "SGDisplayRoot::FindNextItemInTree given a NULL StartItem - bad"); 03721 if(StartItem == NULL) return NULL; 03722 03723 SGDisplayNode *Item = StartItem; 03724 03725 // If this is the last item in the group, skip to the next group 03726 if (Item->GetNext() == NULL) 03727 { 03728 ERROR3IF(Item->GetParent() == NULL, "Tree linkage corruption"); 03729 03730 // Check if we're the last group 03731 if (Item->GetParent()->GetNext() != NULL) 03732 { 03733 SGDisplayNode *TmpItem = Item->GetParent()->GetNext(); 03734 03735 // Jump over any virtualised groups 03736 while(TmpItem != NULL && TmpItem->GetChild() == NULL) 03737 TmpItem = TmpItem->GetNext(); 03738 03739 // Check if gone over last group 03740 if(TmpItem == NULL) 03741 Item = NULL; 03742 else 03743 Item = TmpItem->GetChild(); 03744 } 03745 else 03746 Item = NULL; 03747 } 03748 else 03749 Item = Item->GetNext(); // Get next sibling item 03750 03751 return Item; 03752 }
|
|
Scanning the group-selection within a Display Tree.
Warning: It may be possible for groups AND items to be selected at one time. This essentially filters Items out of the selection scan.
Definition at line 3629 of file sgtree.cpp. 03630 { 03631 // Find the current group node - my first child, or the the current Group's parent. 03632 if (CurrentGroup != NULL) 03633 CurrentGroup = ((SGDisplayGroup *) CurrentGroup)->GetNext(); 03634 else 03635 CurrentGroup = (SGDisplayGroup *) GetChild(); 03636 03637 ERROR3IF(CurrentGroup != NULL && !CurrentGroup->IsKindOf(CC_RUNTIME_CLASS(SGDisplayGroup)), 03638 "The gallery displaytree seems to have mutated- " 03639 "where have my lovely groups gone?"); 03640 03641 // Search each sibling group in turn until we find another selected leaf Group 03642 while (CurrentGroup != NULL) 03643 { 03644 if (CurrentGroup->IsSelected()) // Found a selected group - return it 03645 return((SGDisplayGroup *)CurrentGroup); 03646 03647 CurrentGroup = ((SGDisplayGroup *) CurrentGroup)->GetNext(); 03648 } 03649 03650 // No more selected groups 03651 return(NULL); 03652 }
|
|
Scanning the selection within a Display Tree - this will scan over multiple documents/libraries without blinking an eyelid.
Notes: This method relies heavily on the flat (root/group/item) structure of current display trees - it will fail horribly if this simple layout is changed. Warning: It may be possible for groups AND items to be selected at one time. This essentially filters Groups out of the selection scan.
Definition at line 3457 of file sgtree.cpp. 03459 { 03460 BOOL ReturnSkip = (CurrentItem == NULL); 03461 SGDisplayItem *ReturnItem = NULL; 03462 03463 // Find the current group node - my first child, or the the current item's parent. 03464 SGDisplayGroup *CurrentGroup; 03465 if (CurrentItem != NULL) 03466 CurrentGroup = (SGDisplayGroup *) CurrentItem->GetParent(); 03467 else 03468 CurrentGroup = (SGDisplayGroup *) GetChild(); 03469 03470 ERROR3IF(CurrentGroup != NULL && !CurrentGroup->IsKindOf(CC_RUNTIME_CLASS(SGDisplayGroup)), 03471 "The gallery displaytree seems to have mutated- " 03472 "where have my lovely groups gone?"); 03473 03474 // Search each sibling group in turn until we find another selected leaf item 03475 while (CurrentGroup != NULL && ReturnItem == NULL) 03476 { 03477 ReturnItem = CurrentGroup->FindNextSelectedItem((SGDisplayItem *)CurrentItem); 03478 if (ReturnItem == NULL) 03479 { 03480 // No more selected items in this group - skip onto the next group, and flag 03481 // the fact that we had to skip to a different group 03482 ReturnSkip = TRUE; 03483 CurrentGroup = (SGDisplayGroup *) CurrentGroup->GetNext(); 03484 CurrentItem = NULL; 03485 } 03486 } 03487 03488 // Return the SkipGroup output 03489 if (SkipGroup != NULL) 03490 *SkipGroup = ReturnSkip; 03491 03492 03493 // And return NULL or the next selected node 03494 return(ReturnItem); 03495 }
|
|
Returns the 'height' of the entire list display, in millipoints. This return value is only valid after the tree has been formatted (including a previous call to CalculateListExtent), so long as the cached tree format is still valid. Use with care.
Definition at line 3330 of file sgtree.cpp. 03331 { 03332 return(ScrollExtent); 03333 }
|
|
Finds the child of this DisplayTree Node. Returns NULL if you have reached the boundary of the tree.
Reimplemented from SGDisplayNode. Definition at line 2951 of file sgtree.cpp. 02952 { 02953 return(Child); 02954 }
|
|
Returns the SuperGallery which 'owns' this node (and its subtree).
Reimplemented from SGDisplayNode. Definition at line 2997 of file sgtree.cpp. 02998 { 02999 ERROR3IF(ParentGallery == NULL, "I have no parent gallery! This is not right!"); 03000 03001 return(ParentGallery); 03002 }
|
|
Reimplemented in SGDisplayRootScroll. Definition at line 3383 of file sgtree.cpp.
|
|
To determine how many eaf Groups of this tree are selected.
This method relies heavily on the flat (root/group/Group) structure of current display trees - it will fail horribly if this simple layout is changed.
Definition at line 3678 of file sgtree.cpp. 03679 { 03680 INT32 Count = 0; 03681 03682 SGDisplayGroup *Ptr = (SGDisplayGroup *) GetChild(); 03683 while (Ptr != NULL) 03684 { 03685 if (Ptr->IsSelected()) 03686 Count++; 03687 03688 Ptr = (SGDisplayGroup *) Ptr->GetNext(); 03689 } 03690 03691 return(Count); 03692 }
|
|
To determine how many eaf items of this tree are selected.
This method relies heavily on the flat (root/group/item) structure of current display trees - it will fail horribly if this simple layout is changed.
Definition at line 3522 of file sgtree.cpp. 03523 { 03524 INT32 Count = 0; 03525 03526 SGDisplayGroup *Ptr = (SGDisplayGroup *) GetChild(); 03527 while (Ptr != NULL) 03528 { 03529 Count += Ptr->GetSelectedItemCount(); 03530 Ptr = (SGDisplayGroup *) Ptr->GetNext(); 03531 } 03532 03533 return(Count); 03534 }
|
|
Handles a SuperGallery DisplayTree event.
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 down the tree.
Reimplemented from SGDisplayNode. Reimplemented in SGDisplayRootScroll. Definition at line 3185 of file sgtree.cpp. 03187 { 03188 switch (EventType) 03189 { 03190 case SGEVENT_FORMAT: 03191 // Do nothing, but ensure we don't use the 'default:' case. 03192 break; 03193 03194 case SGEVENT_REDRAW: 03195 { 03196 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo); 03197 03198 // This line is to stop the white flicker when backgrounding the items 03199 // Hmmm... There are a few problems which need sorting out though ! 03200 if (BkgEraseMode == TRUE) 03201 { 03202 StartRendering(RedrawInfo, MiscInfo); 03203 03204 RenderRegion *pRender = RedrawInfo->Renderer; 03205 03206 // Set default background colour 03207 pRender->SetFillColour(RedrawInfo->Background); 03208 pRender->SetLineColour(COLOUR_TRANS); //RedrawInfo->Background); 03209 03210 // Work out height first to avoid ENSURE in DocRect ctor 03211 INT32 height=ScrollExtent; 03212 // Extend the rect if necessary to ensure entire window bg is filled 03213 if (ScrollExtent < MiscInfo->WindowHeight) 03214 height = MiscInfo->WindowHeight; 03215 03216 if ((height>=0) && (MiscInfo->MaxWidth>=0)) 03217 { 03218 // Fill entire display window background with bg colour 03219 DocRect WindowBG(0, -height, MiscInfo->MaxWidth, 0); 03220 pRender->DrawRect(&WindowBG); 03221 } 03222 03223 StopRendering(RedrawInfo, MiscInfo); 03224 } 03225 else 03226 BkgEraseMode = TRUE; 03227 03228 if (GetChild() == NULL) // We have no children (empty tree) 03229 { 03230 // Redraw ourself as 'No Items' indicator 03231 // ERROR3("SGDisplayRoot::Redraw - I have no children to draw"); 03232 return(TRUE); // Might as well return TRUE - there is nobody else! 03233 } 03234 } 03235 break; 03236 03237 03238 default: 03239 return(SGDisplayNode::HandleEvent(EventType, EventInfo, MiscInfo)); 03240 } 03241 03242 // We have children, so recursively call them all with this event 03243 BOOL result = GiveEventToMyChildren(EventType, EventInfo, MiscInfo); 03244 03245 // If we've just reformatted the tree, remember the new list extent 03246 if (EventType == SGEVENT_FORMAT) 03247 { 03248 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo); 03249 03250 ScrollExtent = (ABS(FormatInfo->LinePos)); 03251 SetScrollOffset(GetScrollOffset(), MiscInfo); // Ensure not scrolled off end! 03252 03253 if (FormatInfo->LastInvalidNode != NULL) 03254 { 03255 // The immediately previous (final) node had invalid bounds. 03256 // We'd better include the blank part of the list below it in the 03257 // invalid bounds, to ensure we don't leave little bits of stuff past the end 03258 // of the list if it has got smaller. 03259 03260 ERROR3IF(FormatInfo->InvalidBounds.hi.y > 0, 03261 "Gallery display formatting error - LastInvalidNode should be NULL " 03262 "if there haven't been any invalid nodes yet"); 03263 03264 FormatInfo->InvalidBounds.lo.y = FormatInfo->LinePos - MiscInfo->WindowHeight; 03265 } 03266 } 03267 03268 return(result); 03269 }
|
|
Resets the formatting info structure to default values for the start of a formatting pass. Must be called before SGDisplayRoot::Redraw.
Definition at line 3136 of file sgtree.cpp. 03137 { 03138 MiscInfo->MaxWidth = GridLock(MiscInfo, MiscInfo->MaxWidth); // Maximum width of formatting lines 03139 03140 FormatInfo->LinePos = 0; // Start at the top of the list 03141 FormatInfo->LineHeight = 0; // The current line is 0 height so far 03142 FormatInfo->AvailableWidth = MiscInfo->MaxWidth; // The full line is left to allocate 03143 FormatInfo->IndentLevel = 0; // Initially we are not indented 03144 03145 FormatInfo->AccumulateBounds = FALSE; // By default, don't accumulate bounds 03146 FormatInfo->LastInvalidNode = NULL; // For the group dragging redraw fix 03147 FormatInfo->InvalidBounds = DocRect(0, 1, MiscInfo->MaxWidth, 2); 03148 }
|
|
OVERRIDES SGDisplayNode::InsertAfter.
Reimplemented from SGDisplayNode. Definition at line 3025 of file sgtree.cpp. 03026 { 03027 AddItem(NodeToInsert); 03028 }
|
|
OVERRIDES SGDisplayNode::InsertBefore.
Reimplemented from SGDisplayNode. Definition at line 3051 of file sgtree.cpp. 03052 { 03053 AddItem(NodeToInsert); 03054 }
|
|
Causes the scroll bar, if any, to be redrawn. In the base class, this method does nothing.
Reimplemented in SGDisplayRootScroll. Definition at line 3407 of file sgtree.cpp.
|
|
OVERRIDES SGDisplayNode::RemoveFromTree The root node cannot be removed from the tree - it returns quietly, taking no action (this allows the generic treatment of DestroyTree to work without having to take special action for delinking the root node).
Reimplemented from SGDisplayNode. Definition at line 3074 of file sgtree.cpp.
|
|
Selects the PrimeNode, and if possible, all sibling nodes between it and the Anchor node. If Anchor == NULL or is not found, only PrimeNode is selected. Does not deselect any nodes - you should call SelectItems first to clear the seln.
Note: The code to do the selection is now sub-contracted out to SelectRangeGroups and SelectRangeItems, depending on the type of the two given nodes. If prime node is an item and the other a group, nothing will be selected... If prime node is an item and the null, the item will be selected... Definition at line 3562 of file sgtree.cpp. 03563 { 03564 ERROR3IF(PrimeNode == NULL, "SGDisplayRoot::SelectRange - PrimeNode must be non-NULL"); 03565 03566 if (AnchorNode == NULL || PrimeNode->GetParent() != AnchorNode->GetParent()) 03567 { 03568 // There is no anchor, or the prime/anchor nodes are not siblings, so 03569 // we cannot select a range - select PrimeNode, deselect all others 03570 ParentGallery->SelectItems(FALSE); 03571 ParentGallery->SelectGroups(FALSE); 03572 03573 // Paint the list now to reduce the chance of large redraws if the 03574 // old/new selections are far apart. 03575 ParentGallery->PaintListNow(); 03576 03577 PrimeNode->SetSelected(TRUE); 03578 ParentGallery->PaintListNow(); 03579 } 03580 else if (PrimeNode->IS_KIND_OF(SGDisplayItem) && (AnchorNode == NULL || AnchorNode->IS_KIND_OF(SGDisplayItem))) 03581 { 03582 // We are selecting a range of items so deselect all groups first 03583 ParentGallery->SelectGroups(FALSE); // Deselect all groups 03584 SelectRangeItems((SGDisplayItem *)PrimeNode, (SGDisplayItem *)AnchorNode); 03585 } 03586 else if (PrimeNode->IS_KIND_OF(SGDisplayGroup) && (AnchorNode == NULL || AnchorNode->IS_KIND_OF(SGDisplayGroup))) 03587 { 03588 // We are selecting a range of groups so deselect all items first 03589 ParentGallery->SelectItems(FALSE); // Deselect all items 03590 SelectRangeGroups((SGDisplayGroup *)PrimeNode, (SGDisplayGroup *)AnchorNode); 03591 } 03592 03593 // And ensure the gallery updates itself appropriately 03594 ParentGallery->SelectionHasChanged(); 03595 }
|
|
Sets the child of this DisplayTree Node. Overrides to base class method to allow the child to be set.
Reimplemented from SGDisplayNode. Definition at line 2975 of file sgtree.cpp. 02976 { 02977 Child = NewChild; 02978 }
|
|
Changes the scroll offset, and if necessary, redraws the scroll bar.
In the base class, no scrollbar is supplied; this method does nothing
Reimplemented in SGDisplayRootScroll. Definition at line 3357 of file sgtree.cpp.
|
|
|
|
|
|
|