LayerSGallery Class Reference

The Layer SuperGallery class. More...

#include <sglayer.h>

Inheritance diagram for LayerSGallery:

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

Public Member Functions

 LayerSGallery ()
 LayerSGallery default constructor.
 ~LayerSGallery ()
 LayerSGallery destructor.
virtual MsgResult Message (Msg *Message)
 A standard message handler, really.
virtual BOOL InitMenuCommands (void)
 Initialises any menu commands that this gallery needs.
virtual BOOL BuildCommandMenu (GalleryContextMenu *TheMenu, SGMenuID MenuID)
 To build a menu of commands to be popped up over the gallery.
virtual OpState GetCommandState (StringBase *CommandID, String_256 *ShadeReason)
 To determine the state of a given menu item. This method is an exact parallel to an Op's GetState method (in fact, it is called by an Op's GetState).
virtual void DoCommand (StringBase *CommandID)
 To apply a given command when it is chosen from the menu.
virtual void CreateNewSubtree (Document *ParentDoc, SGDisplayGroup *ExistingGroup=NULL)
 Internal call. This takes the Layer 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.
SpreadGetSelectedSpread (void)
 To find the current layer gallery spread.
virtual void DoChangeAllVisible (BOOL AllVisible)
 Called when the AllVisible button is clicked in the layers gallery. Effects the visibility of all layers, regardless of their visibility.
virtual void DoChangeMultilayer (BOOL Multilayer)
 Called when the Multilayer button is clicked in the layers gallery. Effects the locked state of all layers, regardless of their individual locked state.
virtual void DoChangeLayerState (Layer *pLayer, OpLayerGalReason Reason, BOOL NewState)
 Undoable way of changing the layer's state.

Static Public Member Functions

static void ForceRedrawLayer (Document *pDoc, Layer *pLayer)
 Does a ForceRedraw on the layer in the given doc.
static void MakeActiveLayer (Layer *pNewActiveLayer, BOOL TellAll=TRUE)
 Makes the layer active. Firstly it will inactivate any other active layers, forcing it to redraw if necessary Then it will set this layer to be active, again forcing a redraw if necessary.
static void EnsureActiveLayerIntegrity (Spread *pSpread, Layer **ppActiveLayer=NULL)
 This checks that there is one and only one active layer in the given spread. If there isn't an active layer, the first layer is made active. If there is more than on active layer, all but the first active layer are made inactive.
static void SetActive (Document *pDoc, Layer *pLayer, BOOL state)
 Calls pLayer->SetActive(state), redrawing and changing the layer's selection if necessary. DON'T CALL THIS FUNC!! USE MakeActiveLayer() INSTEAD!!!!
static void MakeTopLayerActive (Spread *pSpread)
 Makes the layer active. Firstly it will inactivate any other active layers, forcing it to redraw if necessary If the new layer is already active, nothing else happens Then it will set this layer to be active, again forcing a redraw if necessary.
static String_256 CreateUniqueLayerID (Spread *pSpread)
 Used to generate a LayerID which is unique for the spread. The name generated is normally of the form "Layer n", where n is the number of layers in the spread + 1. If "Layer n" already exists on the spread then "Layer m" is generated where m is the smallest integer greater than n such that the id is unique.
static void DoChangeVisible (Layer *pLayer, BOOL Visible)
 Called when the visible button is clicked in a layer gallery item. Changes the visibility of the displayed layer.
static void DoChangeLocked (Layer *pLayer, BOOL Locked)
 Called when the Locked button is clicked in a layer gallery item. Changes the lockedness of the displayed layer.
static BOOL DoMoveSelectionToActiveLayer ()

Protected Member Functions

virtual BOOL PreCreate (void)
 Layer SuperGallery PreCreate handler.
virtual BOOL PostCreate (void)
 The LayerSGallery PostCreate handler. This overrides the base class PostCreate function. It is called at the very end of the SuperGallery::Create method, after the window has been created and opened.
virtual BOOL ApplyAction (SGActionType Action)
 Applies certain conventional gallery actions (usually associated with gallery buttons, for new, edit, delete, etc).
virtual void DoShadeGallery (BOOL ShadeIt)
 Called by the base class whenever the shaded status of the gallery is changed, to allow derived galleries to shade/unshade any extra controls that they provide in the window. ONLY called if the gallery is actually open/visible.
virtual SGDisplayItemCopyDisplayItem (SGDisplayItem *SourceItem, SGDisplayGroup *DestGroup, SGDisplayItem *TargetPosition=NULL)
 "Copies" the existing node in the tree in an appropriate fashion.
virtual void NewSelectedSpread (Spread *pNewSelSpread=NULL)
 Central place for setting the layer gal's selected spread. Also takes a copy of the selected document.
virtual void EnsureSelSpreadSelectionIntegrity ()
 This makes sure that all the invisible and/or locked layers in the spread have no selection. It calls NodeRenderableInk::DeselectAllOnLayer() on each layer that should NOT have a selection, just in case. Currently only called after an undo or redo op, because it could be quite slow.
virtual void EnsureActiveLayerIntegrity ()
 This checks that there is one and only one active layer in the gallery's spread.
virtual BOOL CheckVarsAreValid ()
 A routine that checks to see if critical vars are OK. All it does at the mo is check that pSpread and pDoc are not NULL. In debug builds, an ENSURE will go off if something goes wrong.
virtual SGDisplayLayerGetSelectedLayerGalItem ()
 Gets the selected layer gallery item In debug builds, an ENSURE will go off if there is no selected gal item.
virtual BOOL HasLayerGotChildren (Layer *pLayer)
 Scans the layer for children that render something on the screen. It ignores attributes, hidden nodes, etc - nodes that don't render anything themselves.
virtual BOOL PrepareToDelete (void)
 Scans the current Gallery selection. Possibly asks the user for confirmation about the delete. Possibly adjusts the selection as appropriate. Then returns a value to indicate whether the remaining selection should be deleted.
virtual BOOL DoDeleteSelection (void)
 FORCIBLY deletes the current gallery selection. By the time this function is called, PrepareToDelete has made sure that it is safe to continue. This must simply invoke a forced delete upon the selection. Deletion of colours occurs by hiding (with undo).
virtual void DoCreateNewItem (void)
 This function is meant to be overridden in derived classes It creates a new item and adds it to the Gallery DisplayList The item may be created by cloning/deriving/basing-on the selected item, depending on the type of Gallery concerned.
virtual void DoChangeName ()
 Pops up the name changing dialog for the selected layer.
virtual void DoCopyLayer ()
 Pops up the name changing dialog for the selected layer, and if OK is clicked a copy of the layer is made with the new name.
virtual void DoLayerProperties ()
 Opens the layer properties dlg.
virtual void DoCreateGuideLayer ()
 Creates a guide layer.
virtual void DoChangeLayerStatus (Layer *pLayer, const LayerStatus &NewStatus)
 General undoable way of changing the selected layer's status.
virtual void DoMoveLayer (MoveLayerType Reason)
 Called when the Locked button is clicked in the layers gallery. Changes the lockedness of the selected layer, if there is one.
virtual INT32 GetGuideLayerState (DocView *pDocView)
 This returns the current state of the guide layer. It is used to determine whether we need to recreate and redraw the layer gallery when the selected view changes.
virtual BOOL IsSelectedItemGuideLayer ()
 General function for finding out if the selected item is a guide layer Notes: Need not be overridden - the default action is to do nothing extra to the normal shade/unshade operation.
BOOL IsLayerMode (Document *pDoc)
BOOL CloseLayerGallery ()
BOOL OpenFrameGallery ()
void SetNewDocBorn (BOOL Val)
BOOL GetNewDocBorn ()

Protected Attributes

SpreadpSpread
DocumentpDoc
SGDisplayGroupDisplayForeground
SGDisplayGroupDisplayBackground
BOOL m_NewDocBorn
INT32 OldGuideLayerState
INT32 NewGuideLayerState

Detailed Description

The Layer SuperGallery class.

Author:
Jason_Williams (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; SGDisplayLayer

Definition at line 267 of file sglayer.h.


Constructor & Destructor Documentation

LayerSGallery::LayerSGallery  ) 
 

LayerSGallery default constructor.

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

Definition at line 1290 of file sglayer.cpp.

01291 {
01292 #ifndef EXCLUDE_GALS
01293     DlgResID = _R(IDD_LAYERSGALLERY);
01294     pSpread = NULL;
01295     pDoc = NULL;
01296     DisplayForeground = NULL;   // Group of foreground layers
01297     DisplayBackground = NULL;   // Group of background layers
01298 
01299     OldGuideLayerState = -1;
01300     NewGuideLayerState = -1;
01301     m_NewDocBorn = FALSE;
01302 #endif
01303 } 

LayerSGallery::~LayerSGallery  ) 
 

LayerSGallery destructor.

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

Definition at line 1317 of file sglayer.cpp.

01318 {
01319 }


Member Function Documentation

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

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

Author:
Jason_Williams (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.

Reimplemented in FrameSGallery.

Definition at line 1527 of file sglayer.cpp.

01528 {
01529     // No display tree? Better forget about it then!
01530     if (DisplayTree == NULL)
01531         return(FALSE);
01532 
01533     // Determine useful info - this is usually needed for most actions, so always get it
01534     Document        *SelectedDoc = Document::GetSelected();
01535     SGDisplayGroup  *DocumentGroup = DisplayTree->FindSubtree(this, SelectedDoc, NULL);
01536     SGDisplayLayer  *FirstSelected = NULL;
01537     
01538     if (DocumentGroup != NULL)
01539         FirstSelected = (SGDisplayLayer *) DocumentGroup->FindNextSelectedItem(NULL);
01540 
01541     // Now, process the action  TO DO! - see Colour gallery for examples
01542     switch(Action)
01543     {
01544         case SGACTION_CREATE:
01545             DoCreateNewItem();
01546             break;
01547 
01548         case SGACTION_EDIT:
01549             DoChangeName();
01550             break;
01551 
01552         case SGACTION_DELETE:
01553             if (PrepareToDelete())
01554                 DoDeleteSelection();
01555             break;
01556 
01557 //      case SGACTION_APPLY:
01558 //      case SGACTION_REDEFINE:
01559 //      case SGACTION_DISPLAYMODECHANGED:
01560 //          These operations are not provided by the layer gallery
01561 //          break;
01562 
01563         default:
01564             return(SuperGallery::ApplyAction(Action));
01565     }
01566 
01567     return(TRUE);
01568 }

BOOL LayerSGallery::BuildCommandMenu GalleryContextMenu TheMenu,
SGMenuID  MenuID
[virtual]
 

To build a menu of commands to be popped up over the gallery.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/95
Parameters:
TheMenu - The menu to add commands to [INPUTS] MenuID - The type of menu (over-list or from-options-button) to create
Returns:
TRUE if it succeeded
Notes: The Layer gallery provides only a simple item-pop-up menu

Reimplemented from SuperGallery.

Reimplemented in FrameSGallery.

Definition at line 3279 of file sglayer.cpp.

03280 {
03281     BOOL ok = TRUE;
03282 
03283     if (MenuID == SGMENU_OVERITEM)
03284     {
03285         // Over-list menu
03286         SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
03287 
03288 #ifndef STANDALONE
03289 // no layer properties tab present on standalone version
03290         if (pLayerGalItem != NULL)
03291         {
03292 // Changed for Frame/Layer integration.
03293 //#ifdef WEBSTER
03294 //          GIFAnimationPropertyTabs * pTabHandler = GIFAnimationPropertyTabsDlg::GetGIFAnimationPropertiesTabs();
03295 //#else
03296             LayerPropertyTabs * pTabHandler = LayerPropertyTabsDlg::GetLayerPropertiesTabs();
03297 //#endif //webster
03298             if (pTabHandler)
03299             {
03300                 pTabHandler->SetCurrentLayer(pLayerGalItem->GetDisplayedLayer());
03301             }
03302         }
03303 #endif
03304         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_New);
03305         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Copy);
03306         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Delete,TRUE);
03307         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Create);
03308 #ifndef STANDALONE
03309         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
03310 #endif
03311     }
03312 
03313     return(ok);
03314 }

BOOL LayerSGallery::CheckVarsAreValid  )  [protected, virtual]
 

A routine that checks to see if critical vars are OK. All it does at the mo is check that pSpread and pDoc are not NULL. In debug builds, an ENSURE will go off if something goes wrong.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE - the vars are ok FALSE - one or more of the vars is invalid

Definition at line 2395 of file sglayer.cpp.

02396 {
02397     return ((pSpread != NULL) && (pDoc != NULL));
02398 }

BOOL LayerSGallery::CloseLayerGallery  )  [protected]
 

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/10/97
Parameters:
- [INPUTS]
Returns:
TRUE if sucessful, else FALSE.

Definition at line 3454 of file sglayer.cpp.

03455 {
03456     SuperGallery* pSuperGallery = SuperGallery::FindSuperGallery(_R(IDD_LAYERSGALLERY));
03457 
03458     // Ensure a valid ptr.
03459     if (pSuperGallery == NULL)
03460         return FALSE;
03461     
03462     if (pSuperGallery->GetRuntimeClass() == CC_RUNTIME_CLASS(LayerSGallery))
03463     {
03464 PORTNOTE("galleries", "Disabled frame gallery")
03465 #ifndef EXCLUDE_FROM_XARALX
03466         GIFAnimationPropertyTabs::SetFrameGalleryOpen(FALSE);
03467 #endif
03468         // Toggle the visible state of the gallery window
03469         pSuperGallery->SetVisibility( FALSE );
03470     }
03471     else
03472     {
03473         ERROR3("Got the frame gallery but it's not of the LayerSGallery class");
03474     }
03475 
03476     SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYLAYERGALLERY), FALSE);
03477 
03478     // Everything ok.
03479     return TRUE;
03480 }

SGDisplayItem * LayerSGallery::CopyDisplayItem SGDisplayItem SourceItem,
SGDisplayGroup DestGroup,
SGDisplayItem TargetPosition = NULL
[protected, virtual]
 

"Copies" the existing node in the tree in an appropriate fashion.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (from a Jason func)
Date:
21/3/95
Parameters:
SourceItem - The item to copy elsewhere in the tree (see below) [INPUTS]
DestGroup - The group into which the item should be inserted

TargetPosition - NULL (to add to the end of the sibling list), or points to the item BEFORE which the SourceItem will be copied.

Returns:
NULL (failed) or a pointer to the new (copied) display item
This method is normally called when a gallery-organising drag completes, and it is discovered that the dragged item(s) have been dragged to a different display group.

Notes: This method should be overridden by derived galleries to provide appropriate behaviour (some galleries (e.g colour) will copy the real-item that the given display-item references to the new group (document), while other galleries (layer) may just move the item after all).

Note the handy InsertCopiedItem and MoveBefore/After methods which are available to take all of the hard work out of copying/moving items!

See the body of this method in the source code for example pseudocode. For real code, see the Colour Gallery (sgcolour.cpp)

See also:
SuperGallery::InsertCopiedItem; SGDisplayItem::MoveBefore; SGDisplayItem::MoveAfter; SGColour::CopyDisplayItem

Reimplemented from SuperGallery.

Definition at line 3147 of file sglayer.cpp.

03149 {
03150     ERROR3IF(SourceItem == NULL || DestGroup == NULL, "Illegal NULL param");
03151     if (SourceItem == NULL || DestGroup == NULL)
03152         return(NULL);
03153 
03154     ERROR3IF(!IS_A(DestGroup,SGLayerGroup),"DestGroup is not a SGLayerGroup");
03155     ERROR3IF(!IS_A(SourceItem,SGDisplayLayer),"SourceItem is not a SGDisplayLayer");
03156     if (!IS_A(DestGroup,SGLayerGroup) || !IS_A(SourceItem,SGDisplayLayer))
03157         return(NULL);
03158 
03159     SGLayerGroup*   pDestLayerGroup  = (SGLayerGroup*)DestGroup;
03160     SGDisplayLayer* pSourceLayerItem = (SGDisplayLayer*)SourceItem;
03161 
03162     SGDisplayItem*  pDestItem   = TargetPosition;
03163     BOOL            Before      = TRUE;
03164 
03165     if (pDestItem == NULL)
03166     {
03167         pDestItem = (SGDisplayItem*) pDestLayerGroup->GetChild();
03168         Before = TRUE;
03169 
03170         if (pDestItem == NULL)
03171         {
03172             SGDisplayNode* pNode = SourceItem;
03173             while (pNode != NULL)
03174             {
03175                 pDestItem = (SGDisplayItem*) pNode;
03176                 if (pDestLayerGroup->IsForeground())
03177                     pNode = pNode->GetPrevious();
03178                 else
03179                     pNode = pNode->GetNext();
03180             }
03181 
03182             Before = pDestLayerGroup->IsForeground();
03183         }
03184         else
03185         {
03186             SGDisplayItem* pLastDestItem = NULL;
03187             while (pDestItem != NULL)
03188             {
03189                 pLastDestItem = pDestItem;
03190                 pDestItem = (SGDisplayItem*)(pDestItem->GetNext());
03191             }
03192 
03193             pDestItem = pLastDestItem;
03194             Before = FALSE;
03195         }
03196     }
03197 
03198     ERROR3IF(pDestItem == NULL,"pDestItem is still NULL");
03199     if (pDestItem == NULL)
03200         return(NULL);
03201 
03202     // Move the display item around
03203     SourceItem->RemoveFromTree();       // Delink from current displaytree position
03204     SuperGallery::InsertCopiedItem(SourceItem, DestGroup, TargetPosition);
03205 
03206     if (pDestItem != NULL)
03207     {
03208         ERROR3IF(!IS_A(pDestItem,SGDisplayLayer),"SourceItem is not a SGDisplayLayer");
03209         if (!IS_A(pDestItem,SGDisplayLayer))
03210             return(NULL);
03211 
03212         SGDisplayLayer* pDestLayerItem = (SGDisplayLayer*)pDestItem;
03213         pDestLayerItem->MoveLayer(pSourceLayerItem,Before,TRUE);
03214     }
03215 
03216     return(SourceItem);
03217 }

void LayerSGallery::CreateNewSubtree Document ParentDoc,
SGDisplayGroup ExistingGroup = NULL
[virtual]
 

Internal call. This takes the Layer 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:
Jason_Williams (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

Reimplemented in FrameSGallery.

Definition at line 1348 of file sglayer.cpp.

01349 {
01350     if (DisplayTree == NULL)
01351         return;
01352 
01353 TRACEUSER( "Neville", _T("LayerSGallery::CreateNewSubtree Just about to DestroySubtree\n"));
01354     // The layer gallery only ever shows one document, so destroy the entire tree
01355     // and start again from scratch (note that this doesn't destroy the root node)
01356     DisplayTree->DestroySubtree();
01357 
01358     // All groups will be destroyed by DestroySubtree(), so we'd better forget them
01359     DisplayForeground = NULL;
01360     DisplayBackground = NULL;
01361     
01362 TRACEUSER( "Neville", _T("LayerSGallery::CreateNewSubtree completed DestroySubtree\n"));
01363 
01364     if (ParentDoc == NULL)
01365         return;
01366 
01367     SGDisplayLayer  *DisplayLayer = NULL;
01368 
01369     EnsureActiveLayerIntegrity();
01370 
01371     // Create the foreground layer group
01372     DisplayForeground = new SGLayerGroup(this, ParentDoc,NULL,TRUE);    // Create new Group
01373     if (DisplayForeground == NULL)                                      // Total failure - abort
01374         return;
01375     DisplayTree->AddItem(DisplayForeground);                            // Add new group to tree
01376 
01377     // Create the background layer group
01378     DisplayBackground = new SGLayerGroup(this, ParentDoc,NULL,FALSE);   // Create new Group
01379     if (DisplayBackground == NULL)                                      // Total failure - abort
01380         return;
01381     DisplayTree->AddItem(DisplayBackground);                            // Add new group to tree
01382     
01383 
01384     Spread* pSelSpread = GetSelectedSpread();
01385     ERROR3IF(pSelSpread == NULL,"No selected spread in LayerSGallery");
01386     if (pSelSpread == NULL) return;
01387 
01388     Layer* pLayer       = pSelSpread->FindLastLayer();
01389     Layer* pActiveLayer = NULL;
01390     Layer* pGuideLayer  = NULL;
01391 
01392     while (pLayer != NULL)
01393     {
01394         // Keep a ptr to the guide layer, if there is one
01395         if (pLayer->IsGuide())
01396             pGuideLayer = pLayer;
01397 
01398         DisplayLayer = new SGDisplayLayer(pLayer);
01399 
01400         if (DisplayLayer != NULL)
01401         {
01402             if (pLayer->IsBackground())
01403                 DisplayBackground->AddItem(DisplayLayer);
01404             else
01405                 DisplayForeground->AddItem(DisplayLayer);
01406         }
01407 
01408         if (pLayer->IsActive())
01409         {
01410             ERROR3IF(pActiveLayer != NULL,
01411                         "Found more than one active layer in the selected spread");
01412             pActiveLayer = pLayer;
01413 
01414             DisplayLayer->SetSelected(TRUE);    // Make the active layer selected
01415         }
01416 
01417         pLayer = pLayer->FindPrevLayer();
01418     }
01419 
01420     // The new state of the Guide Layer is now the old state
01421     OldGuideLayerState = NewGuideLayerState;
01422 
01423     if (pGuideLayer == NULL)
01424         NewGuideLayerState = -1;                        // If there's no guide layer, set new state to be -1
01425     else
01426         NewGuideLayerState = pGuideLayer->IsVisible();  // New state is based on the guide layer's visibility
01427 
01428     if (IsVisible())
01429     {
01430         SetBoolGadgetSelected(_R(IDC_BTN_MULTILAYER),!(ParentDoc->IsMultilayer() == 0));
01431         SetBoolGadgetSelected(_R(IDC_BTN_ALLVISIBLE),!(ParentDoc->IsAllVisible() == 0));
01432     }
01433 
01434     TRACEUSER( "Neville", _T("LayerSGallery::CreateNewSubtree exit\n"));
01435 }

String_256 LayerSGallery::CreateUniqueLayerID Spread pSpread  )  [static]
 

Used to generate a LayerID which is unique for the spread. The name generated is normally of the form "Layer n", where n is the number of layers in the spread + 1. If "Layer n" already exists on the spread then "Layer m" is generated where m is the smallest integer greater than n such that the id is unique.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (based on a Simon routine)
Date:
4/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A LayerID which is unique for the layer galleries spread.

Errors: -

See also:
-

Definition at line 2327 of file sglayer.cpp.

02328 {
02329     if (pSpread == NULL) return String_256("");
02330 
02331     String_256 UniqueLayerID; 
02332     INT32 NumLayers = 0; 
02333 
02334     Layer* pLayer = pSpread->FindFirstLayer();
02335 
02336     // Calculate how many layers are on the current spread
02337     while (pLayer != NULL)
02338     {
02339         // Don't cound the guide layer - it's LayerID (aka Name) is "Guides"
02340         if(!pLayer->IsGuide())
02341         {
02342             NumLayers++;
02343         }
02344         pLayer = pLayer->FindNextLayer();
02345     }
02346 
02347     INT32 NewLayerNum = NumLayers+1; 
02348 
02349     BOOL Unique;  // Flag used to indicate if the id generated is unique or not 
02350     do 
02351     {
02352         // Construct a first attempt at a unique layer id 'Layer n' 
02353         // where n = the number of layers on the current spread + 1  
02354         UniqueLayerID.MakeMsg(_R(IDS_SGLAYER_LAYER_NUM), /*TEXT("Layer #1%ld"),*/NewLayerNum);
02355     
02356         // Check that UniqueLayerID is indeed unique 
02357         Unique = TRUE; // Until we know better 
02358         pLayer = pSpread->FindFirstLayer();
02359         while (pLayer != NULL)
02360         {   
02361             if (UniqueLayerID == pLayer->GetLayerID())
02362             {
02363                 Unique = FALSE; 
02364 
02365                 // UniqueLayerID is not unique so increment NewLayerNum and try again 
02366                 NewLayerNum++;      
02367                 break; 
02368             }
02369             pLayer = pLayer->FindNextLayer();
02370         }
02371         
02372     } while (!Unique); 
02373 
02374     return(UniqueLayerID); 
02375 }

void LayerSGallery::DoChangeAllVisible BOOL  AllVisible  )  [virtual]
 

Called when the AllVisible button is clicked in the layers gallery. Effects the visibility of all layers, regardless of their visibility.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/8/94
Parameters:
AllVisible - TRUE means all layers become visible [INPUTS] FALSE means only visible layers are visible
Returns:
-

Definition at line 2736 of file sglayer.cpp.

02737 {
02738     if (!CheckVarsAreValid()) return;
02739 
02740     // Get the state prior to the change
02741     BOOL PrevAllVisible = pDoc->IsAllVisible();
02742 
02743     // If no change, return
02744     if (PrevAllVisible == AllVisible) return;
02745 
02746     Layer* pLayer = pSpread->FindFirstLayer();
02747 
02748     while (pLayer != NULL)
02749     {
02750         // Do not include the page background layer in this process as this is very bad!
02751         if (!pLayer->IsPageBackground())
02752         {
02753             pDoc->SetAllVisible(PrevAllVisible);
02754             BOOL PrevVisible = pLayer->IsVisible();
02755 //          BOOL PrevLocked  = pLayer->IsLocked();
02756 
02757             pDoc->SetAllVisible(AllVisible);
02758             BOOL PostVisible = pLayer->IsVisible();
02759 //          BOOL PostLocked  = pLayer->IsLocked();
02760 
02761             if (PrevVisible != PostVisible)
02762             {
02763                 LayerSGallery::ForceRedrawLayer(pDoc,pLayer);
02764 
02765                 if (!PostVisible)
02766                     NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02767             }
02768         }
02769 
02770         pLayer = pLayer->FindNextLayer();
02771     }
02772 
02773     pDoc->SetAllVisible(AllVisible);
02774 
02775     // inform that visible layers have changed
02776     BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::LAYER_VISIBILITY_CHANGED));
02777 }

void LayerSGallery::DoChangeLayerState Layer pLayer,
OpLayerGalReason  Reason,
BOOL  NewState
[virtual]
 

Undoable way of changing the layer's state.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/3/95
Parameters:
pLayer = ptr to the layer to change [INPUTS] Reason = the flag which to change NewState = The new state of the flag to change
Returns:
-

Definition at line 2951 of file sglayer.cpp.

02952 {
02953     if (!CheckVarsAreValid()) return;
02954 
02955     OpLayerGalParam Param(Reason, pSpread);
02956 
02957     Param.pLayer    = pLayer;
02958     Param.NewState  = NewState;
02959     Param.pLayerSGal= this;
02960 
02961     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
02962     if (pOpDesc != NULL)
02963         pOpDesc->Invoke((OpParam*)&Param);
02964     else
02965     {
02966         ERROR3("Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
02967     }
02968 }

void LayerSGallery::DoChangeLayerStatus Layer pLayer,
const LayerStatus NewStatus
[protected, virtual]
 

General undoable way of changing the selected layer's status.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/8/94
Parameters:
pLayer = ptr to the layer to change [INPUTS] NewStatus = reference to the status that the selected layer should take on board.
Returns:
-

Definition at line 2919 of file sglayer.cpp.

02920 {
02921     if (!CheckVarsAreValid()) return;
02922 
02923     OpLayerGalParam Param(LAYER_CHANGE, pSpread);
02924 
02925     Param.pLayer = pLayer;
02926     Param.Status = NewStatus;
02927 
02928     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
02929     if (pOpDesc != NULL)
02930         pOpDesc->Invoke((OpParam*)&Param);
02931     else
02932     {
02933         ENSURE(FALSE,"Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
02934     }
02935 }

void LayerSGallery::DoChangeLocked Layer pLayer,
BOOL  Locked
[static]
 

Called when the Locked button is clicked in a layer gallery item. Changes the lockedness of the displayed layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (Jason, ripped from the LayerGallery, 1/2/95)
Date:
8/8/94
Parameters:
pLayer = the layer to change [INPUTS] Locked - TRUE means make the displayed layer locked FALSE means unlock
Returns:
-
Notes: Does not redraw the layer in the display list

Definition at line 2891 of file sglayer.cpp.

02892 {
02893     ERROR3IF(pLayer == NULL,"pLayer == NULL");
02894     if (pLayer == NULL) return;
02895 
02896     BOOL PrevLocked = pLayer->IsLocked();
02897     pLayer->SetLocked(Locked);
02898     BOOL PostLocked = pLayer->IsLocked();
02899 
02900     if (PrevLocked != PostLocked)
02901         NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02902 }

void LayerSGallery::DoChangeMultilayer BOOL  Multilayer  )  [virtual]
 

Called when the Multilayer button is clicked in the layers gallery. Effects the locked state of all layers, regardless of their individual locked state.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/8/94
Parameters:
Multilayer - TRUE means all layers become unlocked [INPUTS] FALSE means only locked layers are locked
Returns:
-

Definition at line 2796 of file sglayer.cpp.

02797 {
02798     if (!CheckVarsAreValid()) return;
02799 
02800     // Get the state prior to the change
02801     BOOL PrevMultilayer = pDoc->IsMultilayer();
02802 
02803     // If no change, return
02804     if (PrevMultilayer == Multilayer) return;
02805 
02806     Layer* pLayer = pSpread->FindFirstLayer();
02807     BOOL PrevLocked;
02808     BOOL PostLocked;
02809 
02810     while (pLayer != NULL)
02811     {
02812         // Do not include the page background layer in this process as this is very bad!
02813         if (!pLayer->IsPageBackground())
02814         {
02815             pDoc->SetMultilayer(PrevMultilayer);
02816             PrevLocked = pLayer->IsLocked();
02817             pDoc->SetMultilayer(Multilayer);
02818             PostLocked = pLayer->IsLocked();
02819 
02820             if ((PrevLocked != PostLocked) && PostLocked)
02821                 NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02822         }
02823 
02824         pLayer = pLayer->FindNextLayer();
02825     }
02826 
02827     pDoc->SetMultilayer(Multilayer);
02828 }

void LayerSGallery::DoChangeName  )  [protected, virtual]
 

Pops up the name changing dialog for the selected layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
Returns:
-

Definition at line 2610 of file sglayer.cpp.

02611 {
02612     SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02613 
02614     if (pLayerGalItem != NULL)
02615     {
02616         LayerDlgParam Param(LAYER_CHANGE_NAME,NULL,pLayerGalItem->GetDisplayedLayer());
02617         LayerNameDlg::StartUp(&Param);
02618     }
02619 }

void LayerSGallery::DoChangeVisible Layer pLayer,
BOOL  Visible
[static]
 

Called when the visible button is clicked in a layer gallery item. Changes the visibility of the displayed layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (Jason, ripped from the LayerGallery, 1/2/95)
Date:
8/8/94
Parameters:
pLayer = the layer to change [INPUTS] Visible - TRUE means make the displayed layer visible FALSE means make invisiblr
Returns:
-
Notes: Does not redraw the layer in the display list

Definition at line 2850 of file sglayer.cpp.

02851 {
02852     ERROR3IF(pLayer == NULL,"pLayer == NULL");
02853     if (pLayer == NULL) return;
02854 
02855     BOOL PrevVisible = pLayer->IsVisible();
02856     pLayer->SetVisible(Visible);
02857     BOOL PostVisible = pLayer->IsVisible();
02858 
02859     if (PrevVisible != PostVisible)
02860     {
02861         // Force a redraw if the layer's visibility has changed
02862         LayerSGallery::ForceRedrawLayer(pLayer->FindDocument(), pLayer);
02863 
02864         // inform that visible layers have changed
02865         BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::LAYER_VISIBILITY_CHANGED));
02866 
02867         // If layer has just become invisible, remove the selections on the layer 
02868         if (!PostVisible)
02869             NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02870     }
02871 }

void LayerSGallery::DoCommand StringBase CommandID  )  [virtual]
 

To apply a given command when it is chosen from the menu.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/95
Parameters:
CommandID - The String ID of the command [INPUTS]
Notes: Override this method to provide handling for your special commands. Call the base class if you don't recognise the command, so that it can handle standard commands.

The base class handles all of these (maybe more - see the base class help) Properties, Sort, Find; New, Edit, Delete, Redefine; (it calls ApplyAction as appropriate) NextGroup, PrevGroup, FoldGroup, UnfoldGroup;

Reimplemented from SuperGallery.

Reimplemented in FrameSGallery.

Definition at line 3424 of file sglayer.cpp.

03425 {
03426     if (*CommandID == SGCmd_Copy)
03427         DoCopyLayer();
03428     else if (*CommandID == SGCmd_New)
03429         DoCreateNewItem();
03430     else if (*CommandID == SGCmd_Delete)
03431     {
03432         if (PrepareToDelete())
03433             DoDeleteSelection();
03434     }
03435     else if (*CommandID == SGCmd_Properties)
03436         DoLayerProperties();
03437     else if (*CommandID == SGCmd_Create)
03438         DoCreateGuideLayer();
03439 
03440     // Don't call the base class 'cos we don't want any other commands
03441 }

void LayerSGallery::DoCopyLayer  )  [protected, virtual]
 

Pops up the name changing dialog for the selected layer, and if OK is clicked a copy of the layer is made with the new name.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
Returns:
-

Reimplemented in FrameSGallery.

Definition at line 2637 of file sglayer.cpp.

02638 {
02639     SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02640 
02641     if (pLayerGalItem != NULL)
02642     {
02643         LayerDlgParam Param(LAYER_COPY,NULL,pLayerGalItem->GetDisplayedLayer());
02644         LayerNameDlg::StartUp(&Param);
02645     }
02646 }

void LayerSGallery::DoCreateGuideLayer  )  [protected, virtual]
 

Creates a guide layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 2704 of file sglayer.cpp.

02705 {
02706 #ifndef WEBSTER
02707     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_GUIDELINE);
02708     ERROR3IF(pOpDesc == NULL,"FindOpDescriptor(OPTOKEN_GUIDELINE) failed");
02709 
02710     if (pOpDesc != NULL)
02711     {
02712         OpGuidelineParam GuidelineParam;
02713 
02714         GuidelineParam.Method = GUIDELINEOPMETHOD_CREATE_GUIDE_LAYER;
02715 
02716         pOpDesc->Invoke(&GuidelineParam);
02717     }
02718 #endif // WEBSTER
02719 }

void LayerSGallery::DoCreateNewItem void   )  [protected, virtual]
 

This function is meant to be overridden in derived classes It creates a new item and adds it to the Gallery DisplayList The item may be created by cloning/deriving/basing-on the selected item, depending on the type of Gallery concerned.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/8/94

Reimplemented in FrameSGallery.

Definition at line 2589 of file sglayer.cpp.

02590 {
02591     if (!CheckVarsAreValid())
02592         return;
02593     LayerDlgParam Param(LAYER_NEW,pSpread,NULL);
02594     LayerNameDlg::StartUp(&Param);
02595 
02596 }

BOOL LayerSGallery::DoDeleteSelection void   )  [protected, virtual]
 

FORCIBLY deletes the current gallery selection. By the time this function is called, PrepareToDelete has made sure that it is safe to continue. This must simply invoke a forced delete upon the selection. Deletion of colours occurs by hiding (with undo).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/8/94
Returns:
FALSE if it couldn't delete the selection. (This should, if at all possible leave the entire selection undeleted in this case)
See also:
LayerSGallery::PrepareToDelete; ColourManager::HideColours

Reimplemented in FrameSGallery.

Definition at line 2549 of file sglayer.cpp.

02550 {
02551     SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02552 
02553     if (pLayerGalItem != NULL)
02554     {
02555         OpLayerGalParam Param(LAYER_DELETE,pSpread);
02556         Param.pLayer = pLayerGalItem->GetDisplayedLayer();
02557 
02558         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
02559         if (pOpDesc != NULL)
02560             pOpDesc->Invoke((OpParam*)&Param);
02561         else
02562         {
02563             ERROR3("Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
02564         }
02565         return (TRUE);
02566     }
02567 
02568     return (pLayerGalItem != NULL);
02569 }

void LayerSGallery::DoLayerProperties  )  [protected, virtual]
 

Opens the layer properties dlg.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 2661 of file sglayer.cpp.

02662 {
02663 #ifndef STANDALONE
02664     // layer property tabs not present in viewer
02665     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERPROPERTYTABS);
02666 
02667     if (pOpDesc != NULL)
02668     {
02669         String_256 Str;
02670         OpState State = pOpDesc->GetOpsState(&Str);
02671         if (!State.Greyed)
02672             pOpDesc->Invoke();
02673         else
02674         {
02675 // Changed for Frame/Layer integration - RanbirR
02676 //#ifdef WEBSTER
02677 //          GIFAnimationPropertyTabs * pTabHandler = GIFAnimationPropertyTabsDlg::GetGIFAnimationPropertiesTabs();
02678 //#else
02679             LayerPropertyTabs * pTabHandler = LayerPropertyTabsDlg::GetLayerPropertiesTabs();   
02680 //#endif // webster -RanbirR
02681             if (pTabHandler)
02682             {
02683                 DialogTabOp* pDlg =  pTabHandler->GetTabbedDlg();
02684                 if (pDlg != NULL)
02685                     pDlg->Open();
02686             }
02687         }
02688     }
02689 #endif
02690 }

void LayerSGallery::DoMoveLayer MoveLayerType  Reason  )  [protected, virtual]
 

Called when the Locked button is clicked in the layers gallery. Changes the lockedness of the selected layer, if there is one.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
Reason = how the layer should be moved [INPUTS]
Returns:
-

Reimplemented in FrameSGallery.

Definition at line 2986 of file sglayer.cpp.

02987 {
02988     SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02989 
02990     if (pLayerGalItem != NULL)
02991     {
02992         OpLayerGalParam Param(LAYER_MOVE, pSpread);
02993 
02994         Param.pLayer = pLayerGalItem->GetDisplayedLayer();
02995 
02996         switch (Reason)
02997         {
02998             case (MOVELAYER_UPONE) :
02999                 Param.pContextNode  = Param.pLayer->FindNextLayer();
03000                 Param.AttDir        = NEXT;
03001                 break;
03002 
03003             case (MOVELAYER_DOWNONE) :
03004                 Param.pContextNode  = Param.pLayer->FindPrevLayer();
03005                 Param.AttDir        = PREV;
03006                 break;
03007 
03008             default:
03009                 ENSURE(FALSE,"Unrecognised MoveLayer reason");
03010                 break;
03011         }
03012 
03013         if (Param.pContextNode != NULL)
03014         {
03015             // Redraw after the op if both this layer and the one it's moving in front/behind
03016             // is also visible
03017             Param.MoveRedraw = ((Layer*)Param.pContextNode)->IsVisible() &&
03018                                     Param.pLayer->IsVisible();
03019 
03020             // The above won't work in an undo or redo, so always redraw
03021             Param.MoveRedraw = TRUE;
03022 
03023             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
03024             if (pOpDesc != NULL)
03025                 pOpDesc->Invoke((OpParam*)&Param);
03026             else
03027             {
03028                 ENSURE(FALSE,"Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
03029             }
03030         }
03031     }
03032 }

BOOL LayerSGallery::DoMoveSelectionToActiveLayer  )  [static]
 

Author:
Simon_Knight (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/5/00
Parameters:
- [INPUTS]
Returns:
TRUE if op exists

Definition at line 3562 of file sglayer.cpp.

03563 {
03564     // Find the OP. for the Layer gallery.
03565     OpDescriptor* OpDesc;
03566     OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_MOVE_SEL_TO_ACTIVE_LAYER);
03567 
03568     // Ensure we get a ptr to the OP.
03569     if(!OpDesc)
03570         return FALSE;
03571 
03572     // ok, now open the layergallery.
03573     OpDesc->Invoke();        
03574 
03575     // Lets go back.
03576     return TRUE;
03577 }

void LayerSGallery::DoShadeGallery BOOL  ShadeIt  )  [protected, virtual]
 

Called by the base class whenever the shaded status of the gallery is changed, to allow derived galleries to shade/unshade any extra controls that they provide in the window. ONLY called if the gallery is actually open/visible.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/94
Parameters:
ShadeIt - TRUE if the gallery is being shaded [INPUTS] FALSE if the gallery is being unshaded
Notes: Need not be overridden - the default action is to do nothing extra to the normal shade/unshade operation.
See also:
Gallery::ShadeGallery; Gallery::UnshadeGallery

Reimplemented from SuperGallery.

Reimplemented in FrameSGallery.

Definition at line 3083 of file sglayer.cpp.

03084 {
03085     BOOL fEnableMove = FALSE;
03086     OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_MOVE_SEL_TO_ACTIVE_LAYER);
03087     if (pDesc != 0)
03088     {
03089         String_256 str;
03090         OpState os = pDesc->GetOpsState(&str);
03091         fEnableMove = !os.Greyed;
03092     }
03093 
03094     EnableGadget(_R(IDC_LAYER_MOVE_TO_ACTIVE),  !ShadeIt && fEnableMove);
03095     EnableGadget(_R(IDC_GALLERY_UPONE),         !ShadeIt);
03096     EnableGadget(_R(IDC_GALLERY_DOWNONE),       !ShadeIt);
03097     EnableGadget(_R(IDC_GALLERY_PROPERTIES),    !ShadeIt);
03098     EnableGadget(_R(IDC_GALLERY_COPY),          !ShadeIt && !IsSelectedItemGuideLayer());
03099 
03100     EnableGadget(_R(IDC_BTN_MULTILAYER),        !ShadeIt);
03101     EnableGadget(_R(IDC_BTN_ALLVISIBLE),        !ShadeIt);
03102 
03103     //EnableGadget(_R(IDC_GALLERY_NAME),        !ShadeIt);
03104 }

void LayerSGallery::EnsureActiveLayerIntegrity  )  [protected, virtual]
 

This checks that there is one and only one active layer in the gallery's spread.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
LayerSGallery::EnsureActiveLayerIntegrity(Spread* pSpread)

Definition at line 2415 of file sglayer.cpp.

void LayerSGallery::EnsureActiveLayerIntegrity Spread pSpread,
Layer **  ppActiveLayer = NULL
[static]
 

This checks that there is one and only one active layer in the given spread. If there isn't an active layer, the first layer is made active. If there is more than on active layer, all but the first active layer are made inactive.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/3/95
Parameters:
pSpread = ptr to spread [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 2231 of file sglayer.cpp.

02232 {
02233     if (pSpread == NULL) return;
02234 
02235     // Get the first layer in the spread
02236     Layer* pFirstLayer = pSpread->FindFirstLayer(); 
02237 
02238     // Not found an active layer yet
02239     Layer* pActiveLayer = NULL;
02240 
02241     // Start the search from the first layer
02242     Layer* pLayer = pFirstLayer;
02243 
02244     INT32 ActiveLayers = 0;
02245 
02246     while (pLayer != NULL && pActiveLayer == NULL)
02247     {
02248         if (pLayer->IsActive())
02249         {
02250             ActiveLayers++;
02251             pActiveLayer = pLayer;  // Found the active layer, so make a note of it
02252         }
02253 
02254         pLayer = pLayer->FindNextLayer();
02255     }
02256 
02257     // If we haven't found any active layers, make the last (top) one active
02258     // WEBSTER - markn 23/1/97
02259     // In Webster, always pick the top layer to be the active layer
02260 //#ifndef WEBSTER
02261     if (pActiveLayer == NULL)
02262 //#endif // WEBSTER
02263         pActiveLayer = pSpread->FindLastLayer(); // In this instance ActiveLayers must be 0
02264 
02265     // If we have an active layer, ensure that it really is the one and only active layer
02266     // AMB20060416 - only make the call if did not have exactly one active layer before
02267     // to save an unnecessary layer change message when the layer gallery is brought up
02268     if ((pActiveLayer != NULL) /*&& (ActiveLayers != 1)*/)
02269         LayerSGallery::MakeActiveLayer(pActiveLayer);
02270 
02271     // If caller wants the ptr to the active layer
02272     if (ppActiveLayer != NULL)
02273         *ppActiveLayer = pActiveLayer;
02274 }

void LayerSGallery::EnsureSelSpreadSelectionIntegrity  )  [protected, virtual]
 

This makes sure that all the invisible and/or locked layers in the spread have no selection. It calls NodeRenderableInk::DeselectAllOnLayer() on each layer that should NOT have a selection, just in case. Currently only called after an undo or redo op, because it could be quite slow.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Reimplemented in FrameSGallery.

Definition at line 2050 of file sglayer.cpp.

02051 {
02052     if (pSpread == NULL) return;
02053 
02054     // Get the first layer in the spread
02055     Layer* pLayer = pSpread->FindFirstLayer();  
02056 
02057     while (pLayer != NULL)
02058     {
02059         // If the layer is not visible OR the layer is locked, make sure there is no selection
02060         if (!pLayer->IsVisible() || pLayer->IsLocked())
02061             NodeRenderableInk::DeselectAllOnLayer(pLayer);
02062 
02063         pLayer = pLayer->FindNextLayer();
02064     }
02065 }

void LayerSGallery::ForceRedrawLayer Document pDoc,
Layer pLayer
[static]
 

Does a ForceRedraw on the layer in the given doc.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/94
Parameters:
pDoc = ptr that contains this layer [INPUTS] pLayer = ptr to the layer you want to redraw
- [OUTPUTS]
Returns:
-

Definition at line 2083 of file sglayer.cpp.

02084 {
02085     Spread* pSpread = pLayer->FindParentSpread();
02086 
02087     if (pSpread != NULL)
02088     {
02089         DocRect rect = pLayer->GetUnionBlobBoundingRect();
02090         pDoc->ForceRedraw(pSpread, rect, FALSE, pLayer);            // Don't allow caches to retain backgrounds
02091 
02092         if (pLayer->IsGuide())
02093         {
02094             Node* pNode = pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGuideline));
02095             while (pNode != NULL)
02096             {
02097                 rect = ((NodeGuideline*)pNode)->GetRenderRect();
02098                 pDoc->ForceRedraw(pSpread, rect, FALSE, pLayer);    // Don't allow caches to retain backgrounds
02099                 pNode = pNode->FindNext(CC_RUNTIME_CLASS(NodeGuideline));
02100             }
02101         }
02102     }
02103 }

OpState LayerSGallery::GetCommandState StringBase CommandID,
String_256 ShadeReason
[virtual]
 

To determine the state of a given menu item. This method is an exact parallel to an Op's GetState method (in fact, it is called by an Op's GetState).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/9/95
Parameters:
CommandID - TheString ID of the command [INPUTS]
ShadeReason - If you return (OpState.Greyed == TRUE) then this should be filled [OUTPUTS] ion with the reason that the item is shaded/greyed.
Returns:
An OpState indicating the current menu item state.
Notes: Override this method to provide state info for your special commands Call the base class for unknown commands to allow it to handle them for you

The base class handles all of these (maybe more - see the base class help) Properties, Sort, Find; New, Edit, Delete, Redefine; NextGroup, PrevGroup, FoldGroup, UnfoldGroup;

Reimplemented from SuperGallery.

Reimplemented in FrameSGallery.

Definition at line 3344 of file sglayer.cpp.

03345 {
03346     OpState State;
03347 
03348     if (AmShaded)       // No commands available while the gallery is shaded
03349     {
03350         State.Greyed = TRUE;
03351         return(State);
03352     }
03353 
03354     if (*CommandID == SGCmd_Copy    || // --- Copy/Delete/Properties
03355         *CommandID == SGCmd_Delete  ||
03356         *CommandID == SGCmd_Properties) 
03357     {
03358         SGDisplayLayer* pItem = GetSelectedLayerGalItem();
03359 
03360         if (pItem == NULL)
03361         {
03362             State.Greyed = TRUE;
03363             ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLECOL));
03364         }
03365         else if (*CommandID == SGCmd_Copy)          // Can't copy Guide layers
03366             State.Greyed = IsSelectedItemGuideLayer();
03367 #ifndef STANDALONE
03368         else if (*CommandID == SGCmd_Properties)    // Shade when dlg is open
03369         {
03370             //State.Greyed = (LayerPropertyTabs::GetTabbedDlg() != NULL);
03371 //#ifdef WEBSTR
03372 //          GIFAnimationPropertyTabs * pTabHandler = GIFAnimationPropertyTabsDlg::GetGIFAnimationPropertiesTabs();
03373 //#else
03374             LayerPropertyTabs * pTabHandler = LayerPropertyTabsDlg::GetLayerPropertiesTabs();
03375 //#endif //webster RanbirR
03376             if (pTabHandler)
03377                 State.Greyed = (pTabHandler->GetTabbedDlg() != NULL);
03378             else
03379                 State.Greyed = TRUE;    
03380         }
03381 #endif
03382     }
03383     else if (*CommandID == SGCmd_Create)
03384     {
03385         Spread* pSpread = Document::GetSelectedSpread();
03386         Layer* pGuideLayer = NULL;
03387 
03388         if (pSpread != NULL)
03389             pGuideLayer = pSpread->FindFirstGuideLayer();
03390 
03391         State.Greyed = (pGuideLayer != NULL);
03392     }
03393 
03394 
03395     // Don't call the base class 'cos we don't want any other commands
03396 
03397     return(State);
03398 }

INT32 LayerSGallery::GetGuideLayerState DocView pDocView  )  [protected, virtual]
 

This returns the current state of the guide layer. It is used to determine whether we need to recreate and redraw the layer gallery when the selected view changes.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/95
Parameters:
pDocView = ptr to docview (This holds visibility info for guide layers) [INPUTS]
- [OUTPUTS]
Returns:
0 = Guide layer is invisible 1 = Guide layer is visible -1 = Guide layer doesn't exist

Definition at line 1990 of file sglayer.cpp.

01991 {
01992     Spread* pSelSpread = GetSelectedSpread();
01993 
01994     if (pSelSpread != NULL)
01995     {
01996         Layer* pLayer = pSelSpread->FindFirstGuideLayer();
01997         if (pLayer != NULL)
01998             return (pLayer->IsVisible(pDocView));
01999     }
02000 
02001     return -1;
02002 }

BOOL LayerSGallery::GetNewDocBorn  )  [inline, protected]
 

Reimplemented in FrameSGallery.

Definition at line 392 of file sglayer.h.

00392 { return m_NewDocBorn; }

SGDisplayLayer * LayerSGallery::GetSelectedLayerGalItem  )  [protected, virtual]
 

Gets the selected layer gallery item In debug builds, an ENSURE will go off if there is no selected gal item.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A ptr to the selected layer gallery item. NULL if there is no selectet item

Reimplemented in FrameSGallery.

Definition at line 2436 of file sglayer.cpp.

02437 {
02438     SGDisplayLayer* pDispLayer = NULL;
02439 
02440     if (CheckVarsAreValid())
02441     {
02442         ERROR3IF(DisplayForeground == NULL || DisplayBackground == NULL,"Fore and/or background group(s) are/is NULL");
02443         if (DisplayForeground == NULL || DisplayBackground == NULL)
02444             return NULL;
02445 
02446         // Look in the foreground group first
02447         pDispLayer = ((SGDisplayLayer *) DisplayForeground->FindNextSelectedItem(NULL));
02448 
02449         // If no joy, have a look in the background group
02450         if (pDispLayer == NULL)
02451             pDispLayer = ((SGDisplayLayer *) DisplayBackground->FindNextSelectedItem(NULL));
02452 
02453         ERROR3IF(pDispLayer == NULL,"Can't find the selected layer item in the layer gallery");
02454 
02455 //      SGDisplayGroup  *DocumentGroup = DisplayTree->FindSubtree(this, pDoc, NULL);
02456 //      if (DocumentGroup != NULL)
02457 //          return((SGDisplayLayer *) DocumentGroup->FindNextSelectedItem(NULL));
02458     }
02459 
02460     return(pDispLayer);
02461 }

Spread * LayerSGallery::GetSelectedSpread void   )  [inline]
 

To find the current layer gallery spread.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/1/95
Returns:
A pointer to the spread that the layer gallery regards as 'current'

Definition at line 414 of file sglayer.h.

00415 {
00416     return(pSpread);
00417 }

BOOL LayerSGallery::HasLayerGotChildren Layer pLayer  )  [protected, virtual]
 

Scans the layer for children that render something on the screen. It ignores attributes, hidden nodes, etc - nodes that don't render anything themselves.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/8/94
Parameters:
pLayer = the layer you want to check [INPUTS]
- [OUTPUTS]
Returns:
TRUE - The layer has children the user may be interested in - i.e. children that actually render something. FALSE - The layer has no rendering children
Code moved into Layer::HasLayerGotRenderableChildren 21/7/97

Definition at line 2483 of file sglayer.cpp.

02484 {
02485     ERROR2IF(pLayer == NULL,FALSE,"HasLayerGotChildren bad param!");
02486     return pLayer->HasLayerGotRenderableChildren();
02487 }

BOOL LayerSGallery::InitMenuCommands void   )  [virtual]
 

Initialises any menu commands that this gallery needs.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/9/95
Returns:
TRUE for success
Notes: Will only create the menu commands once - further calls in the future will return TRUE immediately wihtout doing anything.

Reimplemented from SuperGallery.

Reimplemented in FrameSGallery.

Definition at line 3237 of file sglayer.cpp.

03238 {
03239     static BOOL MenusInitialised = FALSE;
03240 
03241     BOOL ok = TRUE;
03242 
03243     if (!MenusInitialised)
03244     {
03245         // Initialise menu command Ops
03246         // "Special" entries for over-list menu
03247         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Copy,      _R(IDS_SGMENU_COPY));
03248         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Delete,    _R(IDS_SGMENU_DELETE));
03249         ok = ok && InitMenuCommand((StringBase *) &SGCmd_New,       _R(IDS_NEW_LAYER));
03250         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Create,    _R(IDS_CREATE_GUIDE_LAYER));
03251         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties,_R(IDS_SGMENU_PROPERTIES));
03252 
03253         MenusInitialised = TRUE;
03254     }
03255 
03256     return(ok);
03257 }

BOOL LayerSGallery::IsLayerMode Document pDoc  )  [protected]
 

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/10/97
Parameters:
Pointer to the document. [INPUTS]
Returns:
TRUE if the document is Frame based, else FALSE.

Definition at line 3522 of file sglayer.cpp.

03523 {
03524     ERROR3IF(pDoc == NULL,"pDoc == NULL");
03525 
03526     // flag to determine the document mode.
03527     BOOL LayerMode = TRUE;
03528 
03529     // Get a ptr to the selected spread
03530     Spread* pSpread = pDoc->GetSelectedSpread();
03531 
03532     // Ensure a valid spread ptr.
03533     if(pSpread)
03534     {
03535         // Are there any frame layers?
03536         Layer* pFrameLayer = pSpread->FindFirstFrameLayer();    
03537 
03538         //If a frame layer exists, then this is an animation doc.
03539         if (pFrameLayer)
03540             LayerMode = FALSE;
03541     }
03542 
03543     // return the document mode.
03544     return LayerMode;
03545 }

BOOL LayerSGallery::IsSelectedItemGuideLayer  )  [protected, virtual]
 

General function for finding out if the selected item is a guide layer Notes: Need not be overridden - the default action is to do nothing extra to the normal shade/unshade operation.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/95
Parameters:
- [INPUTS]
Returns:
TRUE if the selected layer is a guide layer or no selected layer, FALSE otherwise
See also:
Gallery::ShadeGallery; Gallery::UnshadeGallery

Definition at line 3050 of file sglayer.cpp.

03051 {
03052     SGDisplayLayer* pItem = GetSelectedLayerGalItem();
03053     Layer* pLayer = NULL;
03054 
03055     if (pItem != NULL)
03056         pLayer = pItem->GetDisplayedLayer();
03057 
03058     if (pLayer != NULL)
03059         return (pLayer->IsGuide());
03060 
03061     return TRUE;
03062 }

void LayerSGallery::MakeActiveLayer Layer pNewActiveLayer,
BOOL  TellAll = TRUE
[static]
 

Makes the layer active. Firstly it will inactivate any other active layers, forcing it to redraw if necessary Then it will set this layer to be active, again forcing a redraw if necessary.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/8/94
Parameters:
pNewActiveLayer = ptr to the layer you want to be active [INPUTS]
- [OUTPUTS]
Returns:
-
If the given new layer is already active, nothing happens

Note: pNewActiveLayer must be in the currect doc

Definition at line 2179 of file sglayer.cpp.

02180 {
02181     Spread* pSpread = pNewActiveLayer->FindParentSpread();
02182     ERROR3IF(pSpread == NULL,"Eh up, the layer has no parent spread");
02183     if (pSpread == NULL) return;
02184 
02185     Document *pDoc = pSpread->FindParentDocument();
02186     if (pDoc == NULL) return;
02187         
02188     {
02189         // Remove any other active layers, redrawing if necessary.
02190         Layer* pLayer = pSpread->FindFirstLayer();
02191         while (pLayer != NULL)
02192         {
02193             if (pLayer->IsActive() && pLayer != pNewActiveLayer)
02194                 LayerSGallery::SetActive(pDoc,pLayer,FALSE);
02195 
02196             pLayer = pLayer->FindNextLayer();
02197         }
02198     }
02199 
02200     // Make sure the new layer is active, redrawing if necessary
02201     if (!pNewActiveLayer->IsActive())
02202         LayerSGallery::SetActive(pDoc,pNewActiveLayer,TRUE);
02203 
02204 #if defined(EXCLUDE_FROM_RALPH)
02205     //ERROR3("LayerSGallery::MakeActiveLayer supressed broadcast - bad !");
02206 #else
02207     if (TellAll)
02208         BROADCAST_TO_ALL(LayerMsg(pNewActiveLayer,LayerMsg::ACTIVE_LAYER_CHANGED));
02209 #endif
02210 }

void LayerSGallery::MakeTopLayerActive Spread pSpread  )  [static]
 

Makes the layer active. Firstly it will inactivate any other active layers, forcing it to redraw if necessary If the new layer is already active, nothing else happens Then it will set this layer to be active, again forcing a redraw if necessary.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/1/95
Parameters:
pSpread = Spread which should have its top layer made active [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 2294 of file sglayer.cpp.

02295 {
02296     // Check for NULL spread
02297     if (pSpread == NULL)
02298         return;
02299 
02300     // The top layer is the last layer in the spread's child list
02301     // so find the last layer and make it active
02302     Layer* pLayer = pSpread->FindLastLayer();
02303     if (pLayer != NULL)
02304         MakeActiveLayer(pLayer);
02305 }

MsgResult LayerSGallery::Message Msg Message  )  [virtual]
 

A standard message handler, really.

Author:
Jason_Williams (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.

Reimplemented in FrameSGallery.

Definition at line 1597 of file sglayer.cpp.

01598 {
01599     if (IS_OUR_DIALOG_MSG(Message))
01600     {
01601         DialogMsg* Msg = (DialogMsg*)Message;
01602 
01603         switch (Msg->DlgMsg)
01604         {
01605             case DIM_CREATE:
01606                 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYLAYERGALLERY), TRUE);
01607                 break;
01608 
01609             case DIM_CANCEL:
01610                 SGInit::UpdateGalleryButton(_R(OPTOKEN_DISPLAYLAYERGALLERY), FALSE);
01611                 break;
01612 
01613             default:
01614                 break;
01615         }
01616     }
01617 
01618 
01619     // If we have no displaytree, then we have not been shown, or something terrible has
01620     // happened, so we don't bother handling any of these messages.
01621     if (DisplayTree == NULL)
01622         return(SuperGallery::Message(Message));
01623 
01624 
01625     if (IS_OUR_DIALOG_MSG(Message))
01626     {
01627         DialogMsg* Msg = (DialogMsg*)Message;
01628         INT32 state;
01629 
01630         switch (Msg->DlgMsg)
01631         {
01632             case DIM_LFT_BN_CLICKED:
01633             {
01634                 //TRACE( _T("Gadget %d clicked\n"),Msg->GadgetID);
01635                 if (FALSE) {}
01636                 else if (Msg->GadgetID ==  _R(IDC_BTN_MULTILAYER))
01637                 {
01638                     state = GetLongGadgetValue(_R(IDC_BTN_MULTILAYER),0,1);
01639                     DoChangeLayerState(NULL,LAYER_MULTILAYER,state);
01640                     //DoChangeMultilayer(state);
01641                     //ForceRedrawOfList();
01642                 }
01643                 else if (Msg->GadgetID == _R(IDC_BTN_ALLVISIBLE))
01644                 {
01645                     state = GetLongGadgetValue(_R(IDC_BTN_ALLVISIBLE),0,1);
01646                     DoChangeLayerState(NULL,LAYER_ALLVISIBLE,state);
01647                     //DoChangeAllVisible(state);
01648                     //ForceRedrawOfList();
01649                 }
01650                 else if (Msg->GadgetID == _R(IDC_GALLERY_UPONE))
01651                 {
01652                     DoMoveLayer(MOVELAYER_UPONE);
01653                 }
01654                 else if (Msg->GadgetID == _R(IDC_GALLERY_DOWNONE))
01655                 {
01656                     DoMoveLayer(MOVELAYER_DOWNONE);
01657                 }
01658                 else if (Msg->GadgetID ==  _R(IDC_GALLERY_NAME))
01659                 {
01660                     //DoChangeName();
01661                     //break;
01662                 }
01663                 else if (Msg->GadgetID == _R(IDC_GALLERY_PROPERTIES))
01664                 {
01665                     DoLayerProperties();
01666                 }
01667                 else if (Msg->GadgetID == _R(IDC_GALLERY_COPY))
01668                 {
01669                     DoCopyLayer();
01670                 }
01671                 else if (Msg->GadgetID == _R(IDC_LAYER_MOVE_TO_ACTIVE))
01672                 {
01673                     DoMoveSelectionToActiveLayer();
01674                 }                                           
01675 #ifndef WEBSTER
01676                 else if (Msg->GadgetID == _R(IDC_GALLERY_HELP))
01677                 {
01678                     HelpUserTopic(_R(IDS_HELPPATH_Gallery_Layer));
01679                 }
01680 #endif                  
01681             }
01682             default:
01683                 break;
01684         }
01685     }
01686     else if (MESSAGE_IS_A(Message, OpMsg))
01687     {
01688         switch (((OpMsg*)Message)->MsgType)
01689         {
01690             case OpMsg::AFTER_UNDO:
01691             case OpMsg::AFTER_REDO:
01692                 EnsureSelSpreadSelectionIntegrity();
01693                 break;
01694             default:
01695                 break;
01696         }
01697     }
01698     else if (MESSAGE_IS_A(Message, SpreadMsg))
01699     {
01700         SpreadMsg*  pSpreadMsg = (SpreadMsg*) Message;
01701 
01702         switch (pSpreadMsg->Reason)
01703         {
01704             case SpreadMsg::SELCHANGED:
01705                 NewSelectedSpread(pSpreadMsg->pNewSpread);  // gets selected doc too
01706                 if (pDoc != NULL && IsVisible())
01707                 {
01708 TRACEUSER( "Neville", _T("SpreadMsg::SELCHANGED CreateNewSubtree\n"));
01709                     CreateNewSubtree(pDoc);
01710                     ForceRedrawOfList();
01711                 }
01712                 break;
01713 
01714 
01715             case SpreadMsg::LAYERCHANGES:
01716                 if (IsVisible())
01717                 {
01718                     if (pSpreadMsg->pNewSpread == pSpread)
01719                     {
01720                         if (pSpread->FindFirstLayer() != NULL)
01721                         {
01722                             EnsureActiveLayerIntegrity();
01723                             if (pDoc != NULL && IsVisible())
01724                             {
01725 TRACEUSER( "Neville", _T("SpreadMsg::LAYERCHANGES CreateNewSubtree\n"));
01726                                 CreateNewSubtree(pDoc);
01727                                 ForceRedrawOfList();
01728                             }
01729                         }
01730                     }
01731                 }
01732                 else
01733                 {
01734                     if (pSpreadMsg->pNewSpread->FindFirstLayer() != NULL)
01735                     {
01736                         pSpread = pSpreadMsg->pNewSpread;
01737                         EnsureActiveLayerIntegrity();
01738                     }
01739                 }
01740                 break;
01741             default:
01742                 break;
01743         }
01744     }
01745     else if (MESSAGE_IS_A(Message, DocChangingMsg))
01746     {
01747         DocChangingMsg *Msg = (DocChangingMsg *) Message;
01748         switch (Msg->State)
01749         {
01750                 case DocChangingMsg::TITLECHANGED:
01751 // Showstopper removed, Jason, 28/3/96
01752 // When the doc title changes, we simply need to redraw to update the group titles.
01753 // Calling CreateNewSubtree will destroy the existing tree - this is really really bad
01754 // when the document title changed as a result of us (e.g.) locking a layer, because the
01755 // message broadcats hits us while we're still in the middle of traversing the tree,
01756 // we then delete the tree out from under ourselves, and are then in a highly dodgy state!
01757 //              CreateNewSubtree(Msg->pChangingDoc);
01758                 ForceRedrawOfList();
01759                 break;
01760         
01761             // This message is sent when a new or just opened document is stable.
01762             case DocChangingMsg::SELCHANGED:
01763             {
01764                 if (Msg->pNewDoc == NULL)
01765                 {
01766                     // No documents around any more, so we must wipe the display tree
01767                     // The base class will shade the gallery for us.
01768                     TRACEUSER( "Neville", _T("DocChangingMsg::SELCHANGED CreateNewSubtree\n"));
01769                     CreateNewSubtree(NULL);
01770                     ForceRedrawOfList();
01771                 }
01772                 else 
01773                 {
01774             #ifdef WEBSTER
01775                     // There is an active document, so ensure the gallery is unshaded
01776                     ShadeGallery(FALSE);
01777             #else
01778                     //Do not process the message if it has been sent due to the creation of a new document.
01779                     if ( !GetNewDocBorn() )
01780                     {
01781                         // flag variables.
01782                         BOOL LayerMode = FALSE; 
01783                     
01784                         // Get the changing document pointer.
01785                         Document* pDoc = Msg->pNewDoc;
01786 
01787                         if(pDoc)
01788                         {
01789                             // Determine the document mode.
01790                             LayerMode = IsLayerMode(pDoc);
01791 
01792                             // If we are no longer in Layer mode then
01793                             // close the Layer gallery and open the Frame gallery.
01794                             if( !LayerMode && IsVisible() )
01795                             {
01796                                 // Close the layer gallery.
01797                                 if( CloseLayerGallery() )
01798                                 {
01799                                     // Open the frame gallery.
01800                                     OpenFrameGallery();
01801                                 }
01802                             }
01803                         }
01804                     }
01805                     
01806                     // If the gallery is visible, then ensure the gallery is unshaded.
01807                     if(IsVisible())
01808                     {
01809                         // There is an active document, so ensure the gallery is unshaded
01810                         ShadeGallery(FALSE);
01811                     }
01812                     
01813                 #endif
01814                 }
01815                 break;
01816             }
01817         #ifndef WEBSTER
01818             case DocChangingMsg::BORN:
01819             {
01820                 // When a new document is created, a SELCHANGED
01821                 // message is broadcasted, for Camelot2 frame/layer integration
01822                 // we do not wish to process the message. 
01823                 // We therefore set this flag to notify us when a new document
01824                 // is born.
01825 
01826                 // Ensure we are no longer in Frame mode and the frame gallery is open.
01827                 if( IsVisible() )
01828                 {
01829                     // Set the flag to true.
01830                     // This is set to false in BORNANDSTABLE. 
01831                     SetNewDocBorn(TRUE);
01832                 }
01833                 break;
01834             }
01835 
01836             case DocChangingMsg::BORNANDSTABLE:
01837             {
01838                 // flag variables.
01839                 BOOL LayerMode = FALSE; 
01840 //              BOOL GalleryClosed = FALSE;
01841 
01842                 // Get the changing document pointer.
01843                 Document* pChangingDoc = Msg->pChangingDoc;
01844 
01845                 if(pChangingDoc)
01846                 {
01847                     // Determine the document mode.
01848                     LayerMode = IsLayerMode(pChangingDoc);
01849 
01850                     // If we are no longer in Layer mode then
01851                     // close the Layer gallery and open the Frame gallery.
01852                     if( !LayerMode && IsVisible() )
01853                     {
01854                         // Close the layer gallery.
01855                         if(CloseLayerGallery())
01856                         {
01857                             // Open the frame gallery.
01858                             OpenFrameGallery();
01859 
01860                             // Now we have processed this message, it is safe to process SELCHANGED messages.
01861                             SetNewDocBorn(FALSE);
01862                         }
01863                     }
01864                 }
01865                 break;
01866             }
01867 
01868             case DocChangingMsg::KILLED:
01869             case DocChangingMsg::ABOUTTODIE:
01870             {
01871                 // The doc. is about to die, therefore, set this falg to false.
01872                 SetNewDocBorn(FALSE);
01873             break;
01874             }
01875 
01876         #endif
01877         }
01878     }
01879 
01880 
01881     else if (MESSAGE_IS_A(Message, DocViewMsg))
01882     {
01883         DocViewMsg *Msg = (DocViewMsg *) Message;
01884         switch (Msg->State)
01885         {
01886             case DocViewMsg::SELABOUTTOCHANGE: 
01887                 OldGuideLayerState = GetGuideLayerState(Msg->pNewDocView);
01888                 break;
01889 
01890             case DocViewMsg::SELCHANGED: 
01891             {
01892                 if (IsVisible())
01893                 {
01894                     NewGuideLayerState = GetGuideLayerState(Msg->pNewDocView);
01895                     if (OldGuideLayerState != NewGuideLayerState)
01896                     {
01897                         TRACEUSER( "Neville", _T("DocViewMsg::SELCHANGED CreateNewSubtree\n"));
01898                         CreateNewSubtree(Msg->pNewDocView ? Msg->pNewDocView->GetDoc() : NULL);
01899                         ForceRedrawOfList();
01900                     }
01901                 }
01902             }
01903             break;
01904             default:
01905                 break;
01906         }
01907     }
01908     else if (MESSAGE_IS_A(Message, LayerMsg))
01909     {
01910         LayerMsg *pMsg = (LayerMsg *) Message;
01911 
01912         switch ( pMsg->Reason )
01913         {
01914             // The active layer has changed.
01915             case LayerMsg::ACTIVE_LAYER_CHANGED:
01916             {
01917                 EnableGadget(_R(IDC_GALLERY_COPY),pMsg->pNewLayer != NULL && !pMsg->pNewLayer->IsGuide()); 
01918             }
01919             break;
01920 
01921             // The visibility of a layer has changed, probably by an external source
01922             // so update the display
01923             case LayerMsg::LAYER_VISIBILITY_CHANGED:
01924             {
01925                 ForceRedrawOfList(); 
01926             }
01927             break;
01928 
01929             // The active layer has been changed externally to the gallery.
01930             case LayerMsg::UPDATE_ACTIVE_LAYER:
01931             {
01932                 // We must now check whether the selected layer has been changed externally
01933                 // to us. May happen if an animated GIF is being loaded onto layers
01934                 SGDisplayLayer *pDisplayItem = NULL;
01935                 if (DisplayForeground != NULL)
01936                     pDisplayItem = GetSelectedLayerGalItem();
01937                 if (pDisplayItem != NULL)
01938                 {
01939                     if (pDisplayItem->GetDisplayedLayer() != pMsg->pNewLayer)
01940                     {
01941                         Layer* pNewActiveLayer = pMsg->pNewLayer;
01942                         // Search for the new display item to match this new active layer 
01943                         SGDisplayLayer *pWantedDispLayer = NULL;
01944                         SGDisplayLayer *pDispLayer = ((SGDisplayLayer *) DisplayForeground->GetChild());
01945                         while (pDispLayer != NULL)                      
01946                         {
01947                             if (pDispLayer->GetDisplayedLayer() == pNewActiveLayer)
01948                                 pWantedDispLayer = pDispLayer;
01949                             pDispLayer = (SGDisplayLayer *) pDispLayer->GetNext();
01950                         }
01951                         
01952                         // If we found the required display item then go and select it
01953                         if (pWantedDispLayer)
01954                         {
01955                             // Now update the selection states...
01956                             SelectItems(FALSE); // Deselect everything else
01957                             // Something has changed so we must go and select this new item
01958                             pWantedDispLayer->SetSelected(TRUE);
01959                         }
01960                     }
01961                 }
01962             }
01963             break;
01964             default:
01965                 break;
01966         }
01967     }
01968 
01969     return(SuperGallery::Message(Message));
01970 }    

void LayerSGallery::NewSelectedSpread Spread pNewSelSpread = NULL  )  [protected, virtual]
 

Central place for setting the layer gal's selected spread. Also takes a copy of the selected document.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/8/94
Parameters:
pNewSelSpread = ptr to the spread the layer gal should take as the [INPUTS] selected one; NULL will read the global Selected spread value.
- [OUTPUTS]
Returns:
-

Definition at line 2021 of file sglayer.cpp.

02022 {
02023     if (pNewSelSpread == NULL)
02024         pSpread = Document::GetSelectedSpread();
02025     else
02026         pSpread = pNewSelSpread;
02027     
02028     pDoc = Document::GetSelected();
02029 }

BOOL LayerSGallery::OpenFrameGallery  )  [protected]
 

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/10/97
Parameters:
- [INPUTS]
Returns:
TRUE if the document is Frame based, else FALSE.

Definition at line 3493 of file sglayer.cpp.

03494 {
03495     // Find the OP. for the Layer gallery.
03496     OpDescriptor* OpDesc;
03497     OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DISPLAYFRAMEGALLERY);
03498 
03499     // Ensure we get a ptr to the OP.
03500     if(!OpDesc)
03501         return FALSE;
03502 
03503     // ok, now open the layergallery.
03504     OpDesc->Invoke();        
03505 
03506     // Lets go back.
03507     return TRUE;
03508 }

BOOL LayerSGallery::PostCreate void   )  [protected, virtual]
 

The LayerSGallery PostCreate handler. This overrides the base class PostCreate function. It is called at the very end of the SuperGallery::Create method, after the window has been created and opened.

Author:
Jason_Williams (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

Reimplemented from SuperGallery.

Reimplemented in FrameSGallery.

Definition at line 1492 of file sglayer.cpp.

01493 {
01494     Document *ParentDoc = Document::GetSelected();
01495     if (ParentDoc != NULL)
01496     {
01497         SetBoolGadgetSelected(_R(IDC_BTN_MULTILAYER),!(ParentDoc->IsMultilayer() == 0));
01498         SetBoolGadgetSelected(_R(IDC_BTN_ALLVISIBLE),!(ParentDoc->IsAllVisible() == 0));
01499     }
01500 
01501     EnableGadget(_R(IDC_GALLERY_COPY),ParentDoc != NULL && !IsSelectedItemGuideLayer());
01502 
01503     return(TRUE);
01504 }

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

Layer SuperGallery PreCreate handler.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
2/8/94
Returns:
TRUE if it is successful; FALSE to abort creation of the window
Notes: This method is called whenever the gallery window is about to be created.

Reimplemented from SuperGallery.

Definition at line 1454 of file sglayer.cpp.

01455 {
01456     NewSelectedSpread();        // Cache the selected spread info
01457 
01458     // If there isn't already one, create a DisplayTree
01459     if (DisplayTree == NULL)
01460     {
01461         DisplayTree = new SGDisplayRootScroll(this);    // New root node, with a scrollbar
01462         if (DisplayTree == NULL)
01463             return(FALSE);
01464     }
01465 
01466     // The layer sgallery is a splitter, in that it only ever shows information for the
01467     // selected document, so there is no point trying to call this method for loads of
01468     // documents as the other galleries do.
01469     CreateNewSubtree(Document::GetSelected());
01470 
01471     return(TRUE);
01472 }

BOOL LayerSGallery::PrepareToDelete void   )  [protected, virtual]
 

Scans the current Gallery selection. Possibly asks the user for confirmation about the delete. Possibly adjusts the selection as appropriate. Then returns a value to indicate whether the remaining selection should be deleted.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/8/94
See also:
LayerSGallery::DoDeleteSelection

Definition at line 2503 of file sglayer.cpp.

02504 {
02505     SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02506 
02507     if (pLayerGalItem != NULL)
02508     {
02509         if (HasLayerGotChildren(pLayerGalItem->GetDisplayedLayer()) != FALSE)
02510         {
02511             // If some are in use, determine if the user really wants to delete them
02512             INT32 ButtonPressed = AskQuestion(_R(IDS_LAYER_CONSTAINSOBJECTS),
02513                                             _R(IDS_LAYER_DELETE), _R(IDB_CANCEL), 0, 0,
02514                                             2, 2);
02515                                           
02516             if (ButtonPressed == 1)     // Force-delete all items, so go ahead and delete
02517                 return(TRUE);
02518 
02519             // Delete was cancelled (or Help pressed) - return FALSE
02520             return(FALSE);
02521         }
02522         else
02523             return(TRUE);
02524     }
02525     
02526     return (pLayerGalItem != NULL);
02527 }

void LayerSGallery::SetActive Document pDoc,
Layer pLayer,
BOOL  state
[static]
 

Calls pLayer->SetActive(state), redrawing and changing the layer's selection if necessary. DON'T CALL THIS FUNC!! USE MakeActiveLayer() INSTEAD!!!!

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/94
Parameters:
pDoc = ptr to doc containing layer [INPUTS] pLayer = ptr that contains this layer state = TRUE means make active, FALSE means make inactive
- [OUTPUTS]
Returns:
-

Reimplemented in FrameSGallery.

Definition at line 2124 of file sglayer.cpp.

02125 {
02126     // This flag is TRUE if the selection on the layer should be cleared
02127     BOOL ClearSelection = FALSE;
02128 
02129     // get state before active change
02130     BOOL PrevVisibleState = pLayer->IsVisible();
02131     BOOL PrevLockedState  = pLayer->IsLocked();
02132 
02133     // Change active state
02134     pLayer->SetActive(state);
02135 
02136     // get state after active change
02137     BOOL PostVisibleState = pLayer->IsVisible();
02138     BOOL PostLockedState  = pLayer->IsLocked();
02139 
02140     if (PrevVisibleState != PostVisibleState)
02141     {
02142         // If the visible state has changed, redraw the layer
02143         LayerSGallery::ForceRedrawLayer(pDoc,pLayer);
02144 
02145         // If it has just become invisible, clear the selection
02146         ClearSelection = (ClearSelection || !PostVisibleState);
02147     }
02148 
02149     // if it has just become locked, clear the selection
02150     if (PrevLockedState != PostLockedState)
02151         ClearSelection = (ClearSelection || PostLockedState);
02152 
02153     // Clear the selection if needed
02154     if (ClearSelection)
02155         NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02156 }

void LayerSGallery::SetNewDocBorn BOOL  Val  )  [inline, protected]
 

Reimplemented in FrameSGallery.

Definition at line 391 of file sglayer.h.

00391 { m_NewDocBorn = Val;  }


Member Data Documentation

SGDisplayGroup* LayerSGallery::DisplayBackground [protected]
 

Definition at line 325 of file sglayer.h.

SGDisplayGroup* LayerSGallery::DisplayForeground [protected]
 

Definition at line 324 of file sglayer.h.

BOOL LayerSGallery::m_NewDocBorn [protected]
 

Reimplemented in FrameSGallery.

Definition at line 326 of file sglayer.h.

INT32 LayerSGallery::NewGuideLayerState [protected]
 

Definition at line 366 of file sglayer.h.

INT32 LayerSGallery::OldGuideLayerState [protected]
 

Definition at line 365 of file sglayer.h.

Document* LayerSGallery::pDoc [protected]
 

Definition at line 323 of file sglayer.h.

Spread* LayerSGallery::pSpread [protected]
 

Definition at line 322 of file sglayer.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:48 2007 for Camelot by  doxygen 1.4.4