SGDisplayGroup Class Reference

This DisplayTree node type is used by the SuperGallery The top level(s) of the DisplayTree are made up of a number of SGDisplayGroup nodes, which divide the tree up into categories (and, potentially hierarchical groups within categories). More...

#include <sgtree.h>

Inheritance diagram for SGDisplayGroup:

SGDisplayNode CCObject SimpleCCObject LineAttrGroup SGDisplayColourGroup SGFontsGroup SGLayerGroup SGLibGroup SGNameGroup SGNameGroup SGDisplayLibColGroup SGFrameGroup SGUsedBitmaps SGUsedColours SGUsedFonts SGUsedNames SGUsedBitmaps SGUsedColours SGUsedFonts SGUsedNames List of all members.

Public Member Functions

 SGDisplayGroup ()
 SGDisplayGroup constructor. NOTE that to initialise the parent gallery, document, and library pointers, you should use the other constructor.
 SGDisplayGroup (SuperGallery *ParentGal, Document *ParentDoc=NULL, Library *ParentLib=NULL)
 SGDisplayGroup constructor. Initialises the Group's parent pointers to point at its parent(s). Note that generally speaking, one of ParentDoc, ParentLib will be NULL, and the other will be non-NULL. (This is not the case, however, for the Font gallery!).
virtual SGDisplayNodeGetChild (void) const
 Finds the child of this DisplayTree Node. Returns NULL if you have reached the boundary of the tree.
DocumentGetParentDocument (void)
 Returns the document which this node (and its subtree) references.
LibraryGetParentLibrary (void)
 Returns the Library which this node (and its subtree) references.
virtual SuperGalleryGetParentGallery (void) const
 Returns the SuperGallery which 'owns' this node (and its subtree).
virtual void DragWasReallyAClick (SGMouseInfo *Mouse, SGMiscInfo *MiscInfo)
 Handles a mouse click event. This is a callback function - drags of items from galleries will call this function back if the drag turns out to just be a click.
virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event.
virtual void ForceRedrawOfMyselfAndChildren (void)
 Uses the cached FormatRect to force-redraw the appropriate part of the SuperGallery display window to cause myself to be redrawn. Also redraws the entire area that my children will occupy, thus redrawing this entire category.
virtual SGDisplayItemFindNextSelectedItem (SGDisplayItem *CurrentItem=NULL)
 Scanning the selection within a Group (document/library). Use after finding the subtree for a given doc/lib with FindSubtree, to scan through items in the selection.
virtual INT32 GetSelectedItemCount (void)
 To determine how many child items of this group are selected.
virtual void SelectItems (BOOL SelectThem, BOOL Exclusive=FALSE, Document *ParentDocument=NULL, Library *ParentLibrary=NULL)
 To select/deselect groups of display items in this Gallery display. Do not call this method - use the SuperGallery version.
virtual void SelectGroups (BOOL SelectThem, BOOL Exclusive, Document *ParentDocument, Library *ParentLibrary)
 To select/deselect sets of display groups in this Gallery display. All groups whose state changes will force redraw themselves.
virtual BOOL SetFoldedState (BOOL NewState, BOOL ForceRedraw=TRUE)
 Folds or unfolds a display group.
void GetChildArea (DocRect *Result)
 Retrieves the display list rectangle of this group's children. This is a bounding rectangle which entirely contains the children of this group.
virtual BOOL CanVirtualise (void)
 Most groups shouldn't need to be virtualised out. Really it's just library groups - SGLibGroup - that should be.
virtual BOOL Virtualise (void)
 Virtualise a group out of memory, or rather, vape the items and entire tree associcated with the group, leaving a memory-minimal shell.
virtual BOOL DeVirtualise (void)
 Virtualise a group back into memory, or rather, add the items associated with the group to the group so we can display them, etc.
void SetVirtualisedState (BOOL NewValue)
BOOL IsVirtualised (void)
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)
 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.

Protected Member Functions

virtual void SetChild (SGDisplayNode *NewChild)
 Sets the child of this DisplayTree Node. Overrides to base class method to allow the child to be set.
virtual void ReadGroupTitle (void)
 Reads the title text for this Group from its parent document/library This information is cached, but at present it is re-read on each redraw request to ensure it is kept up to date.

Protected Attributes

SGDisplayNodeChild
String_64 TitleText
DocumentParentDocument
LibraryParentLibrary
SuperGalleryParentGallery
DocRect ChildArea

Private Member Functions

 CC_DECLARE_DYNAMIC (SGDisplayGroup)

Detailed Description

This DisplayTree node type is used by the SuperGallery The top level(s) of the DisplayTree are made up of a number of SGDisplayGroup nodes, which divide the tree up into categories (and, potentially hierarchical groups within categories).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/10/94
Groups have special properties, including a Title, which they will redraw, and pointers to their parent Document, Library, and SuperGallery.

See also:
SuperGallery; SGDisplayNode; SGDisplayRoot; SGDisplayItem

Definition at line 1332 of file sgtree.h.


Constructor & Destructor Documentation

SGDisplayGroup::SGDisplayGroup  ) 
 

SGDisplayGroup constructor. NOTE that to initialise the parent gallery, document, and library pointers, you should use the other constructor.

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

Definition at line 4411 of file sgtree.cpp.

04412 {
04413     Child = NULL;
04414 
04415     ParentGallery  = NULL;
04416     ParentDocument = NULL;
04417     ParentLibrary  = NULL;
04418 
04419     ChildArea.MakeEmpty();
04420 
04421     TRACE( _T("Warning: Using default constructor for SGDisplayGroup is silly\n"));
04422 }

SGDisplayGroup::SGDisplayGroup SuperGallery ParentGal,
Document ParentDoc = NULL,
Library ParentLib = NULL
 

SGDisplayGroup constructor. Initialises the Group's parent pointers to point at its parent(s). Note that generally speaking, one of ParentDoc, ParentLib will be NULL, and the other will be non-NULL. (This is not the case, however, for the Font gallery!).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/10/94
Parameters:
ParentGal - points to the SuperGallery object which 'owns' this node [INPUTS] ParentDoc - NULL, or a pointer to the document this group references ParentLib - NULL, or a pointer to the library this group references

Definition at line 4445 of file sgtree.cpp.

04447 {
04448     // Sanity checks
04449     ERROR3IF(ParentGal == NULL, "SGDisplayGroup needs a parent gallery!");
04450     ERROR3IF(ParentDoc != NULL && ParentLib != NULL,
04451                 "SGDisplayGroup cannot have BOTH a doc and lib for parents!");
04452 
04453     Child = NULL;
04454 
04455     ParentGallery  = ParentGal;
04456     ParentDocument = ParentDoc;
04457     ParentLibrary  = ParentLib;
04458 
04459     if (ParentLibrary != NULL)      // Library groups (which come off disc) default to folded
04460         Flags.Folded = TRUE;
04461 
04462     ChildArea.MakeEmpty();
04463 
04464     ReadGroupTitle();
04465 }


Member Function Documentation

BOOL SGDisplayGroup::CanVirtualise void   )  [virtual]
 

Most groups shouldn't need to be virtualised out. Really it's just library groups - SGLibGroup - that should be.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/95
Returns:
TRUE if it can

Reimplemented in SGDisplayLibColGroup, SGLibGroup, and SGFontsGroup.

Definition at line 5345 of file sgtree.cpp.

05346 {
05347     return FALSE;
05348 }

SGDisplayGroup::CC_DECLARE_DYNAMIC SGDisplayGroup   )  [private]
 

BOOL SGDisplayGroup::DefaultClickHandler SGMouseInfo Mouse,
SGMiscInfo MiscInfo,
BOOL  AfterDrag = FALSE
[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
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

Definition at line 5324 of file sgtree.cpp.

05326 {
05327     return(SGDisplayNode::DefaultClickHandler(Mouse, MiscInfo, AfterDrag));
05328 }

BOOL SGDisplayGroup::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 5290 of file sgtree.cpp.

05291 {
05292     return(SGDisplayNode::DefaultPreDragHandler(Mouse, MiscInfo));
05293 }

BOOL SGDisplayGroup::DeVirtualise void   )  [virtual]
 

Virtualise a group back into memory, or rather, add the items associated with the group to the group so we can display them, etc.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/95
Returns:
TRUE if it devirtualised back in OK (or already had)

Reimplemented in SGDisplayLibColGroup, and SGLibGroup.

Definition at line 5401 of file sgtree.cpp.

05402 {
05403     if(!IsVirtualised())
05404         return TRUE;
05405 
05406 #ifdef _DEBUG
05407     ForceRedrawOfMyselfAndChildren();
05408 #endif
05409 
05410     // Might need some help with this one - override and implement
05411 
05412     return FALSE;
05413 }

void SGDisplayGroup::DragWasReallyAClick SGMouseInfo MouseInfo,
SGMiscInfo MiscInfo
[virtual]
 

Handles a mouse click event. This is a callback function - drags of items 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:
15/3/95
Parameters:
MouseInfo - The mouse info passed to the original click handler [INPUTS] MiscInfo - The misc info passed to the original click handler
Notes: SELECTABLE groups override this method to call DefaultClickHandler when drags on them turn into clicks

Documentation: docs.doc

See also:
SGDisplayGroup::HandleEvent; SGDisplayNode::DefaultClickHandler

Reimplemented from SGDisplayNode.

Definition at line 4925 of file sgtree.cpp.

04926 {
04927     // Just get default selection action to be applied for this click.
04928     // The TRUE indicates that this is a drag-click, and we previously called 
04929     // the DefaultPreDragHandler - we don't want it to do those same actions twice!
04930 
04931     // But we only do anything at all if we're a selectable group
04932     if (Flags.CanSelect)
04933         DefaultClickHandler(MouseInfo, MiscInfo, TRUE);
04934 }

SGDisplayItem * SGDisplayGroup::FindNextSelectedItem SGDisplayItem CurrentItem = NULL  )  [virtual]
 

Scanning the selection within a Group (document/library). Use after finding the subtree for a given doc/lib with FindSubtree, to scan through items in the selection.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/1/95
Parameters:
CurrentItem - NULL to find the first selected item, else [INPUTS] An item indicating the 'position' to search from for the next selected item
Returns:
NULL (if no selection), or A pointer to the first selected child of this node which occurs after the 'CurrentItem'. If CurrentItem is NULL, then the first selected child node is returned.
See also:
SGDisplayNode::FindSubtree; SGDisplayGroup::GetSelectedItemCount()

Definition at line 4655 of file sgtree.cpp.

04656 {
04657     if (CurrentItem == NULL)
04658         CurrentItem = (SGDisplayItem *) GetChild();
04659     else
04660     {
04661         if (CurrentItem->GetParent() != this)   // Sanity check
04662         {
04663             ERROR3("Asking for next selected when previous was not in this group! Starting from first child");
04664             CurrentItem = (SGDisplayItem *) GetChild();
04665         }
04666         else
04667             CurrentItem = (SGDisplayItem *) CurrentItem->GetNext();
04668     }
04669 
04670     while (CurrentItem != NULL && !CurrentItem->IsSelected())
04671         CurrentItem = (SGDisplayItem *) CurrentItem->GetNext();
04672 
04673     return(CurrentItem);
04674 }

void SGDisplayGroup::ForceRedrawOfMyselfAndChildren void   )  [virtual]
 

Uses the cached FormatRect to force-redraw the appropriate part of the SuperGallery display window to cause myself to be redrawn. Also redraws the entire area that my children will occupy, thus redrawing this entire category.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/1/95
See also:
SuperGallery::RedrawArea

Reimplemented from SGDisplayNode.

Definition at line 4589 of file sgtree.cpp.

04590 {
04591     SuperGallery *ParentGallery = GetParentGallery();
04592     if (ParentGallery != NULL)
04593     {
04594         DocRect WholeRect(FormatRect);              // My own rectangle
04595 
04596         if (!Flags.Folded && GetChild() != NULL && !ChildArea.IsEmpty())
04597         {
04598             // Union with child bounds rect, if any
04599             WholeRect.Union(ChildArea);
04600         }
04601 
04602         ParentGallery->ForceRedrawOfArea(&WholeRect);
04603     }
04604 }

SGDisplayNode * SGDisplayGroup::GetChild void   )  const [virtual]
 

Finds the child of this DisplayTree Node. Returns NULL if you have reached the boundary of the tree.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/10/94 (Made virtual 13/5/95)
Returns:
A pointer to the first child of this SGDisplayNode object, or NULL
See also:
SuperGallery; SGDisplayNode::GetParent; SGDisplayNode::GetNext; SGDisplayNode::GetPrevious

Reimplemented from SGDisplayNode.

Definition at line 4485 of file sgtree.cpp.

04486 {
04487     return(Child);
04488 }

void SGDisplayGroup::GetChildArea DocRect Result  ) 
 

Retrieves the display list rectangle of this group's children. This is a bounding rectangle which entirely contains the children of this group.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/95
Parameters:
Result - Filled in with a rectangle (may be 'Empty') [OUTPUTS]
Notes: This rectangle may be Empty (if the group is folded, or if it has not yet been reformatted after being unfolded)

The rectangle does NOT include the group's ("titlebar") FormatRect - to include the group title and all children, you must union with FormatRect

Definition at line 5251 of file sgtree.cpp.

05252 {
05253     ERROR3IF(Result == NULL, "Illegal NULL param");
05254 
05255     *Result = ChildArea;
05256 }

Document * SGDisplayGroup::GetParentDocument void   )  [inline]
 

Returns the document which this node (and its subtree) references.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/94
Returns:
The parent document, or NULL
See also:
SGDisplayGroup::GetParentGallery; SGDisplayGroup::GetParentLibrary

Definition at line 1451 of file sgtree.h.

01452 {
01453     return(ParentDocument);
01454 }

SuperGallery * SGDisplayGroup::GetParentGallery void   )  const [virtual]
 

Returns the SuperGallery which 'owns' this node (and its subtree).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/94
Returns:
The parent SuperGallery, or NULL
See also:
SGDisplayGroup::GetParentLibrary; SGDisplayGroup::GetParentDocument; SGDisplayNode::GetParentGallery

Reimplemented from SGDisplayNode.

Definition at line 4624 of file sgtree.cpp.

04625 {
04626     return(ParentGallery);
04627 }

Library * SGDisplayGroup::GetParentLibrary void   )  [inline]
 

Returns the Library which this node (and its subtree) references.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/94
Returns:
The parent library, or NULL
See also:
SGDisplayGroup::GetParentGallery; SGDisplayGroup::GetParentDocument

Definition at line 1473 of file sgtree.h.

01474 {
01475     return(ParentLibrary);
01476 }

INT32 SGDisplayGroup::GetSelectedItemCount void   )  [virtual]
 

To determine how many child items of this group are selected.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/1/95
Returns:
The number of items in this group which are selected (may return 0)
Notes: This scans the selection (is not cached), so calling it multiple times should be avoided where possible

See also:
SGDisplayNode::FindSubtree; SGDisplayGroup::FindNextSelectedItem

Definition at line 4697 of file sgtree.cpp.

04698 {
04699     INT32 Count = 0;
04700     SGDisplayItem *Item = FindNextSelectedItem(NULL);
04701 
04702     while (Item != NULL)
04703     {
04704         if (Item->IsSelected())
04705             Count++;
04706 
04707         Item = FindNextSelectedItem(Item);
04708     }
04709 
04710     return(Count);
04711 }

BOOL SGDisplayGroup::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.

Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order to pass the event dow the tree.

See also:
SGDisplayNode::HandleEvent; SGDisplayNode::GiveEventToMyChildren

Reimplemented from SGDisplayNode.

Reimplemented in SGFrameGroup, SGLayerGroup, SGLibGroup, and SGFontsGroup.

Definition at line 4968 of file sgtree.cpp.

04970 {
04971     TRACEUSER( "Matt", _T("SGDisplayGroup::HandleEvent called\n"));
04972     // And handle the specific event
04973     switch (EventType)
04974     {
04975         case SGEVENT_FORMAT:
04976             {
04977                 SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
04978 
04979                 // If we've recently folded or unfolded (ChildArea is Empty) then change the
04980                 // format rectangle to ensure everything below this point is redrawn
04981                 if (ChildArea.IsEmpty())
04982                     FormatRect = DocRect(0,0,0,0);
04983 
04984                 if (!Flags.Invisible)
04985                 {
04986                     CalculateFormatRect(FormatInfo, MiscInfo, DefaultGroupWidth, DefaultGroupHeight);
04987                 }
04988                 else
04989                 {
04990                     CalculateFormatRect(FormatInfo, MiscInfo, DefaultGroupWidth, 0);
04991                 }
04992             }
04993             break;
04994 
04995         case SGEVENT_REDRAW:
04996             {
04997                 DocRect MyRect = FormatRect;    // Rely on cached format info being correct
04998 
04999                 SGRedrawInfo *RedrawInfo = GetRedrawInfo(EventType, EventInfo);
05000 
05001                 if (IMustRedraw(RedrawInfo) && !Flags.Invisible && Flags.CanSelect)
05002                 {
05003                     StartRendering(RedrawInfo, MiscInfo);
05004 
05005                     DocColour Col(192, 192, 192);   //128, 128, 128);
05006                     Col.SetSeparable(FALSE);        // Do not colour correct or separate this colour!
05007 
05008                     RedrawInfo->Renderer->SetLineWidth(0);
05009                     RedrawInfo->Renderer->SetLineColour(RedrawInfo->Transparent);
05010                     RedrawInfo->Renderer->SetFillColour(Col);
05011                     RedrawInfo->Renderer->DrawRect(&MyRect);
05012 
05013                     ReadGroupTitle();       // (Re)Cache the title text
05014     
05015                     // Plot the folder glyph (an 18x14 bitmap)
05016                     DocRect GlyphRect(MyRect);
05017                     GlyphRect.lo.x += DevicePixels(MiscInfo, 2);
05018                     GlyphRect.hi.x = GlyphRect.lo.x + DevicePixels(MiscInfo, 18);
05019 
05020                     // Center the bitmap's 14 pixels of height in our strip
05021                     INT32 Excess = GlyphRect.Height() - DevicePixels(MiscInfo, 14);
05022                     Excess = GridLock(MiscInfo, Excess / 2);
05023                     GlyphRect.lo.y += Excess;
05024                     GlyphRect.hi.y = GlyphRect.lo.y + DevicePixels(MiscInfo, 14);
05025                     MyRect.lo.x = GlyphRect.hi.x;
05026 
05027                     #ifdef _DEBUG
05028                         if(IsVirtualised())
05029                         {
05030                             // in debug builds we get a green rectangle to denote virtualised-ness...
05031                             DrawBitmap(RedrawInfo->Renderer, &GlyphRect,
05032                                 (Flags.Folded) ? _R(IDB_GALLERY_FOLD2) : _R(IDB_GALLERY_FOLD0));
05033                         } else {
05034                             DrawBitmap(RedrawInfo->Renderer, &GlyphRect,
05035                                         (Flags.Folded) ? _R(IDB_GALLERY_FOLD1) : _R(IDB_GALLERY_FOLD0));
05036                         }
05037                     #else
05038                         DrawBitmap(RedrawInfo->Renderer, &GlyphRect,
05039                                     (Flags.Folded) ? _R(IDB_GALLERY_FOLD1) : _R(IDB_GALLERY_FOLD0));
05040                     #endif
05041 
05042                     // Mode selection rectangle one pixel to the right so it looks a bit better
05043                     MyRect.lo.x += DevicePixels(MiscInfo, 1);
05044 
05045                     if (MyRect.lo.x < MyRect.hi.x)  // If still room left, draw title
05046                     {
05047                         // Space between text and glyph
05048                         MyRect.lo.x += DevicePixels(MiscInfo, 3);
05049 
05050                         if (Flags.Selected)
05051                         {
05052                             // Fill the entire text background with the 'selected' colour
05053                             RedrawInfo->Renderer->SetFillColour(RedrawInfo->SelBackground);
05054                             RedrawInfo->Renderer->DrawRect(&MyRect);
05055 
05056                             RedrawInfo->Renderer->SetFixedSystemTextColours(&RedrawInfo->SelForeground, &RedrawInfo->SelBackground);
05057                         }
05058                         else
05059                             RedrawInfo->Renderer->SetFixedSystemTextColours(&RedrawInfo->Foreground, &Col);
05060 
05061                         // Space between text and glyph
05062                         MyRect.lo.x += DevicePixels(MiscInfo, 3);
05063     
05064                         if (MyRect.lo.x < MyRect.hi.x)  // If still room left, draw text
05065                             RedrawInfo->Renderer->DrawFixedSystemText(&TitleText, MyRect);
05066                     }
05067 
05068                     StopRendering(RedrawInfo, MiscInfo);
05069                 }
05070 
05071                 // Check if the cliprect overlaps any of our children - if not, then we
05072                 // can return now, passing the event on quickly without bothering to give
05073                 // it to our children.
05074 
05075                 if (Flags.Folded || GetChild() == NULL ||
05076                     !ChildArea.IsIntersectedWith(RedrawInfo->Bounds))
05077                 {
05078                     return(FALSE);
05079                 }
05080             }
05081             break;
05082 
05083 
05084         case SGEVENT_MOUSECLICK:
05085             {
05086                 if (!Flags.Invisible)
05087                 {
05088                     SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
05089 
05090                     // If the click hit us, we will always claim it to save the event going
05091                     // on through the tree unnecessarily
05092                     if (FormatRect.ContainsCoord(Mouse->Position))
05093                     {
05094                         DocRect FolderRect(FormatRect);
05095                         FolderRect.hi.x = FolderRect.lo.x + DevicePixels(MiscInfo, 24);
05096 
05097                         // Single clicks on the folder icon will fold/unfold the category
05098                         if (FolderRect.ContainsCoord(Mouse->Position))
05099                         {
05100                             if (!Mouse->DoubleClick)    // We ignore double-clicks, though
05101                             {
05102                                 // Toggle the folded state of this group and force a redraw
05103                                 SetFoldedState((Flags.Folded) ? FALSE : TRUE);
05104                             }
05105                         }
05106                         else
05107                         {
05108                             if (Mouse->DoubleClick) // It was a double-click, so {un}fold instead
05109                             {
05110                                 // Toggle the folded state of this group and force a redraw
05111                                 SetFoldedState((Flags.Folded) ? FALSE : TRUE);
05112                             }
05113                             else
05114                             {
05115                                 // Not a click on the folder or a general double-click, so assume it's a
05116                                 // drag of the group
05117                                 // This starts the drag. We will be called back, either with:
05118                                 // a) SGDisplayNode::DragWasReallyAClick(), or
05119                                 // b) Some variant of MoveBefore, MoveAfter, or AddItem
05120                                 //    (possibly via SuperGallery::CopyItem) to rearrange this
05121                                 //    item in the tree
05122     
05123                                 if (Flags.CanSelect)
05124                                     DefaultPreDragHandler(Mouse, MiscInfo);
05125     
05126                                 SGListDragInfo *DragGroup;
05127                                 DragGroup = new SGListDragInfo(GetParentGallery(), this,
05128                                                                 Mouse, Mouse->MenuClick);
05129                                 if (DragGroup != NULL)
05130                                     DragManagerOp::StartDrag(DragGroup, GetListWindow());
05131                                 // The DragWasReallyAClick handler will take care of clicks
05132                             }
05133                         }
05134 
05135                         // Claim this event - nobody else can own this click
05136                         return(TRUE);
05137                     }
05138 
05139                     // Next, if the click cannot hit any of our children, pass the event on
05140                     // without passing it to any of the children, to save time
05141                     if (Flags.Folded || GetChild() == NULL ||
05142                         !ChildArea.ContainsCoord(Mouse->Position))
05143                     {
05144                         return(FALSE);
05145                     }
05146                 }
05147             }
05148             break;      
05149 
05150 
05151         case SGEVENT_CLAIMPOINT:
05152             {
05153                 if (!Flags.Invisible)
05154                 {
05155                     SGClaimPointInfo *PointInfo = GetClaimPointInfo(EventType, EventInfo);
05156 
05157                     // If the point hit us, we must claim the event so that the caller
05158                     // knows which tree item contains the point.
05159                     if (FormatRect.ContainsCoord(PointInfo->Position))
05160                     {
05161                         PointInfo->ClosestSoFar = 0;
05162                         PointInfo->Claimant = this;     // Let 'em know it was me!
05163                         return(TRUE);
05164                     }
05165 
05166                     // OK, we don't OWN the point, but are we closer to it than anyone else
05167                     // checked so far? If so, we update ClosestSoFar and Claimant, but we
05168                     // do not claim the event (so others can check if they are closer)
05169                 
05170                     // Find the distance to the 2 closest edges of the rectangle. Then
05171                     // the approx. distance to the rectangle is the larger of the two.
05172                     INT32 XDist = 0;
05173                     if (FormatRect.lo.x > PointInfo->Position.x)
05174                         XDist = FormatRect.lo.x - PointInfo->Position.x;
05175                     else if (FormatRect.hi.x < PointInfo->Position.x)
05176                         XDist = PointInfo->Position.x - FormatRect.lo.x;
05177     
05178                     INT32 YDist = 0;
05179                     if (FormatRect.lo.y > PointInfo->Position.y)
05180                         YDist = FormatRect.lo.y - PointInfo->Position.y;
05181                     else if (FormatRect.hi.y < PointInfo->Position.y)
05182                         YDist = PointInfo->Position.y - FormatRect.lo.y;
05183     
05184                     XDist = max(XDist, YDist);  // XDist is now approx the dist to the point
05185     
05186                     if (XDist < PointInfo->ClosestSoFar)
05187                     {
05188                         PointInfo->Claimant = this;
05189                         PointInfo->ClosestSoFar = XDist;
05190                         // drop through to pass the event on...
05191                     }
05192 
05193                     // Next, if the point cannot hit any of our children, pass the event on
05194                     // without passing it to any of the children, to save time
05195                     if (Flags.Folded || GetChild() == NULL ||
05196                         !ChildArea.ContainsCoord(PointInfo->Position))
05197                     {
05198                         return(FALSE);
05199                     }
05200                 }
05201             }
05202             break;
05203 
05204         default:
05205             return(SGDisplayNode::HandleEvent(EventType, EventInfo, MiscInfo));
05206     }
05207 
05208     // Pass the event on to my children, as appropriate (but not if it's a thumbmsg)
05209     BOOL Result = GiveEventToMyChildren(EventType, EventInfo, MiscInfo);
05210 
05211     if (EventType == SGEVENT_FORMAT)
05212     {
05213         SGFormatInfo *FormatInfo = GetFormatInfo(EventType, EventInfo);
05214 
05215         // After they have formatted themselves, calculate the area they fill, so we can
05216         // quickly determine if events (clicks/redraws) fall over any of our children.
05217         ChildArea = FormatRect;     // We are 'infinite' width, so copy our rect to get width
05218                                     // and the top of the rectangle.
05219 
05220         // And then move the bottom down to include my children, and not myself
05221         ChildArea.hi.y = ChildArea.lo.y;
05222         ChildArea.lo.y = FormatInfo->LinePos;
05223     }
05224 
05225     // And return...
05226     return(Result);
05227 }

BOOL SGDisplayGroup::IsVirtualised void   )  [inline]
 

Definition at line 1406 of file sgtree.h.

01406 {return Flags.Virtualised;};

void SGDisplayGroup::ReadGroupTitle void   )  [protected, virtual]
 

Reads the title text for this Group from its parent document/library This information is cached, but at present it is re-read on each redraw request to ensure it is kept up to date.

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

Reimplemented in SGNameGroup, SGDisplayLibColGroup, SGLibGroup, and SGFontsGroup.

Definition at line 4864 of file sgtree.cpp.

04865 {
04866     // Generate the text to be displayed in this group heading
04867     if (ParentDocument != NULL)
04868     {
04869         String_256 NewTitle;
04870         const String_256 DocTitle = ParentDocument->GetTitle();
04871         NewTitle.MakeMsg(_R(IDS_GALGROUPDOCUMENT), (const TCHAR *) DocTitle);
04872 
04873         // Truncate the name into our 64-char buffer
04874         NewTitle.Left(&TitleText, 63);
04875     }
04876 PORTNOTE("galleries", "disabled folder updated stuff")
04877 #ifndef EXCLUDE_FROM_XARALX
04878     else if (ParentLibrary != NULL)
04879     {
04880         ParentLibrary->GetLibraryTitle(&TitleText);
04881         //>> webster (Adrian 02/01/97)
04882         UINT32 nModified = ParentLibrary->GetModified();
04883         if (nModified == FOLDER_UPDATED)
04884         {
04885             String_256 strUpdated(_R(IDS_FOLDERUPDATED));
04886             TitleText += strUpdated;
04887         }
04888         if (nModified == FOLDER_NEW)
04889         {
04890             String_256 strNew(_R(IDS_FOLDERNEW));
04891             TitleText += _T(" ");
04892             TitleText += strNew;
04893         }
04894         //<< webster
04895     }
04896 #endif
04897 }

void SGDisplayGroup::SelectGroups BOOL  SelectThem,
BOOL  Exclusive,
Document ParentDoc,
Library ParentLib
[virtual]
 

To select/deselect sets of display groups in this Gallery display. All groups whose state changes will force redraw themselves.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/5/95
Parameters:
SelectThem - TRUE to select the given groups, FALSE to deselect them [INPUTS]
Exclusive - TRUE to apply this action to all groups *outside* the given range, FALSE to apply it to all groups *inside* the range.

Document - NULL, or the document which defines the range of groups to affect

Library - NULL, or the library which defines the range of groups to affect

If selecting, all non-group nodes in the tree will be deselected

Do not call this method - use the SuperGallery version

Notes: To select all groups in a range, and deselect all groups outside the range, you need to use 2 calls to this method.

To select/deselect all groups in the display, pass FALSE, NULL, NULL to the last 3 parameters. (If Doc/Lib are both NULL, 'Exclusive' has no effect)

See also:
SuperGallery::SelectGroups; SGDisplayGroup::SelectGroups

Reimplemented from SGDisplayNode.

Definition at line 4819 of file sgtree.cpp.

04821 {
04822     BOOL InRange = TRUE;
04823     
04824     // If anything other than entire-display-tree was requested, then check if it includes us
04825     if (ParentDoc != NULL || ParentLib != NULL)
04826     {
04827         // First, do we contain display stuff for the requested Doc/Lib?
04828         InRange = (ParentDocument == ParentDoc) || (ParentLibrary == ParentLib);
04829 
04830         // Next, was the range inclusive (everything in doc/lib) or
04831         // exclusive (everything outside doc/lib)?
04832         if (Exclusive)
04833             InRange = !InRange;
04834     }
04835 
04836     // Select myself if I am withint the specified range
04837     if (InRange && Flags.CanSelect /*&& !Flags.Invisible*/)
04838         SetSelected(SelectThem);
04839 
04840     // Now, pass the selection request on to my children, so the items will be
04841     // deselected if necessary
04842     SGDisplayNode *Ptr = GetChild();
04843     while (Ptr != NULL)
04844     {
04845         Ptr->SelectGroups(SelectThem, Exclusive, ParentDocument, ParentLibrary);
04846         Ptr = Ptr->GetNext();
04847     }
04848 }

void SGDisplayGroup::SelectItems BOOL  SelectThem,
BOOL  Exclusive = FALSE,
Document ParentDoc = NULL,
Library ParentLib = NULL
[virtual]
 

To select/deselect groups of display items in this Gallery display. Do not call this method - use the SuperGallery version.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/95
Parameters:
SelectThem - TRUE to select the given items, FALSE to deselect them [INPUTS]
Exclusive - TRUE to apply this action to all items *outside* the given range, FALSE to apply it to all items *inside* the range.

Document - NULL, or the document which defines the range of items to affect

Library - NULL, or the library which defines the range of items to affect

Notes: To select all items in a range, and deselect all items outside the range, you need to use 2 calls to this method.

To select/deselect all items in the display, pass FALSE, NULL, NULL to the last 3 parameters. (If Doc/Lib are both NULL, 'Exclusive' has no effect)

OVERRIDES the base SGDisplayNode method to handle the last 3 paramters properly. Firstly, groups won't select themselves; secondly, the call is only passed on to my children if they are in the requested range.

See also:
SuperGallery::SelectItems; SGDisplayNode::SelectItems

Reimplemented from SGDisplayNode.

Definition at line 4749 of file sgtree.cpp.

04751 {
04752     BOOL InRange = TRUE;
04753     
04754     // If we are selecting items, make sure we (a group) are deselected
04755     if (SelectThem && Flags.CanSelect)
04756         SetSelected(FALSE);
04757 
04758     // If anythign other than entire-display-tree was requested, then check if it includes
04759     // our children...
04760     if (ParentDoc != NULL || ParentLib != NULL)
04761     {
04762         // First, do we contain display stuff for the requested Doc/Lib?
04763         InRange = (ParentDocument == ParentDoc) || (ParentLibrary == ParentLib);
04764 
04765         // Next, was the range inclusive (everything in doc/lib) or
04766         // exclusive (everything outside doc/lib)?
04767         if (Exclusive)
04768             InRange = !InRange;
04769     }
04770 
04771     if (!InRange)       // My children are not included in the range specified - return
04772         return;
04773 
04774     // Now, pass the selection request on to my children
04775     SGDisplayNode *Ptr = GetChild();
04776     while (Ptr != NULL)
04777     {
04778         Ptr->SelectItems(SelectThem, Exclusive, ParentDocument, ParentLibrary);
04779         Ptr = Ptr->GetNext();
04780     }
04781 }

void SGDisplayGroup::SetChild SGDisplayNode NewChild  )  [protected, virtual]
 

Sets the child of this DisplayTree Node. Overrides to base class method to allow the child to be set.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/95
Parameters:
A pointer to the new first-child of this SGDisplayNode object [INPUTS]
See also:
SuperGallery; SGDisplayNode::GetParent; SGDisplayNode::GetNext; SGDisplayNode::GetPrevious

Reimplemented from SGDisplayNode.

Definition at line 4509 of file sgtree.cpp.

04510 {
04511     Child = NewChild;
04512 }

BOOL SGDisplayGroup::SetFoldedState BOOL  NewState,
BOOL  ForceRedraw = TRUE
[virtual]
 

Folds or unfolds a display group.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/4/95
Parameters:
NewState - TRUE to fold, FALSE to unfold [INPUTS]
ForceRedraw - TRUE to force a reformat-and-redraw of the group, or FALSE to mark the tree format invalid but not bother actually reformatting and redrawing just yet (usually only set to FALSE when constructing the DisplayTree before the gallery window is opened, for AutoFolding)

Returns:
TRUE if the new state is different from the old state (if anything has changed)
Notes: If changed, forces an immediate reformat and redraw of the Display list

Reimplemented from SGDisplayNode.

Definition at line 4538 of file sgtree.cpp.

04539 {
04540     if ((BOOL)Flags.Folded != NewState)
04541     {
04542         SuperGallery *ParentGal = GetParentGallery();
04543 
04544         // Devirtualise the group. If there were problems, keep it folded...
04545         if (!NewState && IsVirtualised())
04546         {
04547             // For library galleries we need to set the Quiet button status ready to un-supress errors
04548             ParentGal->SetQuietStatus(FALSE);
04549 
04550             // On older machines this can take a couple of seconds, so we need some feedback...
04551             Progress ProgMsg(_R(IDS_GALLERY_PREPARE_FOR_UNFOLD), -1, FALSE);
04552 
04553             if(!DeVirtualise()) 
04554                 return FALSE;
04555         }
04556 
04557         Flags.Folded = NewState;
04558         ChildArea.MakeEmpty();
04559 
04560         ParentGal->InvalidateCachedFormat();
04561 
04562         if (ForceRedraw)
04563             ParentGal->ReformatAndRedrawIfNecessary();
04564 
04565         return(TRUE);
04566     }
04567 
04568     return(FALSE);
04569 }

void SGDisplayGroup::SetVirtualisedState BOOL  NewValue  )  [inline]
 

Definition at line 1403 of file sgtree.h.

01403 {Flags.Virtualised = NewValue;};

BOOL SGDisplayGroup::Virtualise void   )  [virtual]
 

Virtualise a group out of memory, or rather, vape the items and entire tree associcated with the group, leaving a memory-minimal shell.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/95
Returns:
TRUE if it virtualised out OK (or already was)

Reimplemented in SGDisplayLibColGroup.

Definition at line 5364 of file sgtree.cpp.

05365 {
05366     // Group is already virtualised
05367     if(IsVirtualised())
05368         return TRUE;
05369 
05370 PORTNOTE("galleries", "Disabled virtualising switch")
05371 #ifndef EXCLUDE_FROM_XARALX
05372     // Virtualisation disabled...
05373     if(!SGLibGroup::LibraryVirtualisingEnabled)
05374         return FALSE;
05375 #endif
05376 
05377     DestroySubtree(FALSE);  // Delete all items in the group (but not this one obviously)
05378     SetVirtualisedState(TRUE);
05379 
05380 #ifdef _DEBUG
05381     ForceRedrawOfMyselfAndChildren();
05382 #endif
05383 
05384     return TRUE;
05385 }


Member Data Documentation

SGDisplayNode* SGDisplayGroup::Child [protected]
 

Definition at line 1422 of file sgtree.h.

DocRect SGDisplayGroup::ChildArea [protected]
 

Definition at line 1431 of file sgtree.h.

Document* SGDisplayGroup::ParentDocument [protected]
 

Definition at line 1426 of file sgtree.h.

SuperGallery* SGDisplayGroup::ParentGallery [protected]
 

Definition at line 1429 of file sgtree.h.

Library* SGDisplayGroup::ParentLibrary [protected]
 

Definition at line 1427 of file sgtree.h.

String_64 SGDisplayGroup::TitleText [protected]
 

Definition at line 1424 of file sgtree.h.


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