TEMPLATESGallery Class Reference

The TEMPLATE SuperGallery class. More...

#include <sgbase.h>

Inheritance diagram for TEMPLATESGallery:

SuperGallery DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 TEMPLATESGallery ()
 TEMPLATESGallery default constructor.
 ~TEMPLATESGallery ()
 TEMPLATESGallery destructor.
virtual MsgResult Message (Msg *Message)
 A standard message handler, really.

Protected Member Functions

virtual BOOL PreCreate (void)
 The TEMPLATESGallery PreCreate handler. This overrides the base class PreCreate function. It is called at the very beginning of the SuperGallery::Create method, before the window has been created.
virtual BOOL ApplyAction (SGActionType Action)
 Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).
void CreateNewSubtree (Document *ParentDoc, SGDisplayGroup *ExistingGroup=NULL)
 Internal call. This takes the DATATYPE list of the given document and creates a DisplayTree subtree from it. This subtree is then added to the DisplayTree. Note that this does not force a redraw of the list - after making this call, you should also call ForceRedrawOfList.

Detailed Description

The TEMPLATE SuperGallery class.

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
27/1/95 (Based on the Colour SGallery code)
Notes: SuperGalleries are specced in a number of docs including specs.doc ("super" gallery extensions) specs.doc (gallery basic ui) There is also howtouse.doc which describes creating a supergallery

See also:
SuperGallery; SGDisplayTEMPLATE

Definition at line 212 of file sgbase.h.


Constructor & Destructor Documentation

TEMPLATESGallery::TEMPLATESGallery  ) 
 

TEMPLATESGallery default constructor.

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)

Definition at line 490 of file sgbase.cpp.

00491 {
00492 } 

TEMPLATESGallery::~TEMPLATESGallery  ) 
 

TEMPLATESGallery destructor.

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)

Definition at line 506 of file sgbase.cpp.

00507 {
00508 }


Member Function Documentation

BOOL TEMPLATESGallery::ApplyAction SGActionType  Action  )  [protected, virtual]
 

Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
Action - Indicates what action to apply [INPUTS]
Returns:
TRUE to indicate successful handling of the action, or FALSE to indicate failure
See also:
SGActionType

Reimplemented from SuperGallery.

Definition at line 670 of file sgbase.cpp.

00671 {
00672     // No display tree? Better forget about it then!
00673     if (DisplayTree == NULL)
00674         return(FALSE);
00675 
00676     // Determine useful info - this is usually needed for most actions, so always get it
00677     Document        *SelectedDoc = Document::GetSelected();
00678     SGDisplayGroup  *DocumentGroup = DisplayTree->FindSubtree(this, SelectedDoc, NULL);
00679     SGDisplayDATATYPE   *FirstSelected = NULL;
00680     
00681     if (DocumentGroup != NULL)
00682         FirstSelected = (SGDisplayDATATYPE *) DocumentGroup->FindNextSelectedItem(NULL);
00683 
00684     // Now, process the action  TO DO! - see Colour gallery for examples
00685     switch(Action)
00686     {
00687         case SGACTION_CREATE:
00688 TRACE( _T("Unimplemented feature executed in TEMPLATE gallery"));
00689             break;
00690 
00691         case SGACTION_APPLY:
00692 TRACE( _T("Unimplemented feature executed in TEMPLATE gallery"));
00693             break;
00694 
00695         case SGACTION_REDEFINE:
00696 TRACE( _T("Unimplemented feature executed in TEMPLATE gallery"));
00697             break;
00698 
00699         case SGACTION_EDIT:
00700 TRACE( _T("Unimplemented feature executed in TEMPLATE gallery"));
00701             break;
00702 
00703         case SGACTION_DELETE:
00704 TRACE( _T("Unimplemented feature executed in TEMPLATE gallery"));
00705             break;
00706 
00707         case SGACTION_DISPLAYMODECHANGED:
00708 TRACE( _T("Unimplemented feature executed in TEMPLATE gallery"));
00709             break;
00710 
00711         default:
00712             return(FALSE);
00713     }
00714 
00715     return(TRUE);
00716 }

void TEMPLATESGallery::CreateNewSubtree Document ParentDoc,
SGDisplayGroup ExistingGroup = NULL
[protected]
 

Internal call. This takes the DATATYPE list of the given document and creates a DisplayTree subtree from it. This subtree is then added to the DisplayTree. Note that this does not force a redraw of the list - after making this call, you should also call ForceRedrawOfList.

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
ParentDoc - The document to create a display subtree for [INPUTS] ExistingGroup - NULL (creates a new group for this document), or a pointer to the existing group-node for this document (in which case it clears all displayitems from the group and rebuilds it in place - this stops the display group moving around the tree at random!)
Notes: Passing in a NULL parent document pointer results in an ERROR3 - the function returns without doing anything in retail builds

See also:
SuperGallery::ForceRedrawOfList

Definition at line 537 of file sgbase.cpp.

00538 {
00539     ERROR3IF(ParentDoc == NULL, "TEMPLATESGallery::CreateNewSubtree - NULL parameter passed in");
00540     if (ParentDoc == NULL)
00541         return;
00542 
00543     SGDisplayGroup  *DisplayDocument;
00544     SGDisplayDATATYPE *DisplayDATATYPE;
00545 
00546     if (ExistingGroup != NULL)
00547     {
00548         ERROR3IF(ExistingGroup->GetParentDocument() != ParentDoc, 
00549                  "This group is not for that document! What's going down, dude?");
00550         DisplayDocument = ExistingGroup;                            // Use existing group
00551         DisplayDocument->DestroySubtree(FALSE); // Wipe any existing DATATYPE display items
00552     }
00553     else
00554     {
00555         DisplayDocument = new SGDisplayGroup(this, ParentDoc,NULL); // Create new Group
00556 
00557         if (DisplayDocument == NULL)                                // Total failure - abort
00558             return;
00559 
00560         DisplayTree->AddItem(DisplayDocument);                      // Add new group to tree
00561     }
00562 
00563 
00564     // **** TO DO ****
00565     // Fill in some code here to generate SGDisplayDATATYPEs to be displayed.
00566     // e.g: (in PSEUDO code!! ;-)
00567     //
00568     // DATATYPE *Ptr = ParentDoc->GetDATATYPEList()->GetHead();
00569     // while (Ptr != NULL)
00570     // {
00571     //    DisplayDATATYPE = new SGDisplayDATATYPE(Ptr);
00572     //    if (DisplayDATATYPE != NULL)
00573     //       DisplayDocument->AddItem(DisplayDATATYPE);
00574     //
00575     //    Ptr = ParentDoc->GetDATATYPEList()->GetNext();
00576     // }
00577     //
00578     //
00579     // Default : create a few items to display
00580     // NOTE: The pointer faked up to pass in to the constructor will cause the thing
00581     // to blow up if you start actually trying to USE the data item! Replace this at
00582     // earliest convenience with proper tree construction code.
00583     for (INT32 Bob = 0; Bob < 7; Bob++)
00584     {
00585         DisplayDATATYPE = new SGDisplayDATATYPE( (DATATYPE *) 0xcdcdcdcd );
00586         if (DisplayDATATYPE != NULL)
00587             DisplayDocument->AddItem(DisplayDATATYPE);
00588     }
00589 }

MsgResult TEMPLATESGallery::Message Msg Message  )  [virtual]
 

A standard message handler, really.

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Parameters:
Message - The message to handle [INPUTS]
Notes: Any messages that this does not handle must be passed down to the SuperGallery base class message handler.

NOTE WELL that the SuperGallery base class handler does some funky things for us - see SuperGallery::Message - such as deleting our display subtree for any document which dies (which, uncannily, would explain why they go away like that when you close documents ;-), and shading the gallery when there are no documents present. [To override this behaviour in these cases, you should respond to the message, and return OK rather than calling the base class message handler]

See also:
SuperGallery::Message

Reimplemented from SuperGallery.

Definition at line 745 of file sgbase.cpp.

00746 {
00747     if (IS_OUR_DIALOG_MSG(Message))
00748     {
00749         DialogMsg* Msg = (DialogMsg*)Message;
00750 
00751         switch (Msg->DlgMsg)
00752         {
00753             case DIM_CREATE:
00754                 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYTEMPLATEGALLERY, TRUE);
00755                 break;
00756 
00757             case DIM_CANCEL:
00758                 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYTEMPLATEGALLERY, FALSE);
00759                 break;
00760         }
00761 
00762         return(SuperGallery::Message(Message));
00763     }
00764 
00765     // If we have no displaytree, then we have not been shown, or something terrible has
00766     // happened, so we don't bother handling any of these messages.
00767     if (DisplayTree == NULL)
00768         return(SuperGallery::Message(Message));
00769 
00770 
00771     // **** TO DO ****
00772     // Just another note: Most galleries ignore most messages when closed (!IsVisible())
00773     // This means that they must re-create themselves properly to get back up to date
00774     // when they are opened - this is done in the PostCreate handler. If you wish to 
00775     // respond to messages to keep up to date while closed, you should address the
00776     // default code in the PostCreate handler as well.
00777 
00778     if (IsVisible() && MESSAGE_IS_A(Message, DocChangingMsg))
00779     {
00780         DocChangingMsg *TheMsg = (DocChangingMsg *) Message;
00781 
00782         switch ( TheMsg->State )
00783         {
00784             case DocChangingMsg::DocState::BORN:            // New document - add to display tree
00785                 {
00786                     INT32 Extent = GetDisplayExtent();      // Remember previous list extent
00787 
00788                     CreateNewSubtree(TheMsg->pChangingDoc); // Add a subtree for this doc
00789                     ShadeGallery(FALSE);                    // Unshade the gallery
00790 
00791                     InvalidateCachedFormat();               // And redraw what is necessary
00792                     RedrawEverythingBelow(-Extent);
00793                 }
00794                 break;      // Pass this message on to the base class as well
00795         }
00796     }
00797 
00798     return(SuperGallery::Message(Message));
00799 }    

BOOL TEMPLATESGallery::PreCreate void   )  [protected, virtual]
 

The TEMPLATESGallery PreCreate handler. This overrides the base class PreCreate function. It is called at the very beginning of the SuperGallery::Create method, before the window has been created.

Author:
Unattributed (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/95 (base generated in sgbase.cpp)
Returns:
TRUE if the Gallery initialised successfully FALSE if it should not be opened due to a failure to initialise
Notes: As this is called before the window is open, it must not attempt to touch any of the button gadgets in the window, or force redraws, etc. Also, events cannot be passed to the tree, as the tree formatting relies on knowing the window size - however, the tree will be reformatted and redrawn automatically when the window is opened - this will happen shortly.

Reimplemented from SuperGallery.

Definition at line 615 of file sgbase.cpp.

00616 {
00617     // If there isn't already one, create a DisplayTree
00618     if (DisplayTree == NULL)
00619     {
00620         DisplayTree = new SGDisplayRootScroll(this);    // New root node, with a scrollbar
00621         if (DisplayTree == NULL)
00622             return(FALSE);
00623     }
00624 
00625 
00626     // **** TO DO ****
00627     // You may not need to adjust the following, but note that it re-creates the entire
00628     // display tree from scratch whenever the gallery window is opened - if this is
00629     // unsuitable for your needs, you'll have to change it (e.g. you could make it only
00630     // do it if the DisplayTree has not already been created, above)
00631 
00632     // And for each document already present, create a display subtree (possibly replacing
00633     // a previous displaytree for it if we had one earlier)
00634     Document *ParentDoc = (Document *) GetApplication()->Documents.GetTail();
00635     while (ParentDoc != NULL)
00636     {
00637         // Find the existing subtree, if any
00638         SGDisplayGroup *ParentGroup = DisplayTree->FindSubtree(this, ParentDoc, NULL);
00639 
00640         // Create a new subtree, replacing the old one if possible
00641         CreateNewSubtree(ParentDoc, ParentGroup);
00642 
00643         ParentDoc = (Document *) GetApplication()->Documents.GetPrev(ParentDoc);
00644     }
00645 
00646     return(TRUE);
00647 }


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