FrameSGallery Class Reference

The Layer SuperGallery class. More...

#include <sgframe.h>

Inheritance diagram for FrameSGallery:

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

Public Member Functions

 FrameSGallery ()
 FrameSGallery default constructor.
 ~FrameSGallery ()
 FrameSGallery 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.

Static Public Member Functions

static void MakeActiveLayer (Layer *pNewActiveLayer, UndoableOperation *pUndoOp=NULL)
 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 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 String_256 CreateUniqueLayerID (Spread *pSpread, const String_256 *pBaseName=NULL)
 This function tries to hide the specified node. Copy of the undoable operation version as we are not undoable and don't have an op. Hide it as it may be mentioned in the undo history. Note: This would be safer than deleting the layer nodes but if we use this, which should be the same as the DoHideNode in undoable operation does, then it leaks the hidden nodes and layers that are being hidden. So there must be something sneaky going on.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 BOOL EnsureFrameLayerIntegrity (Spread *pSpread)
 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.This function should be called before any frame related actions are carried out It will ensure that all the visible layers are frame layers.
static BOOL DoHideNode (Node *pNodeToHide)
static void DoChangeSolid (Layer *pLayer, BOOL Solid)
 Called when the Solid button is clicked in a layer gallery item. Changes the Solidness of the displayed layer.
static void DoChangeOverlay (Layer *pLayer, BOOL Overlay)
 Called when the Overlay button is clicked in a layer gallery item. Changes the Overlayness of the displayed layer.
static void FixOtherLayers (Spread *pSpread)
 A layer flag such as overlay or solid has been changed and so we need to go and find the active layer and ensure that the other layers above and below this have the correct visibility and locked settings.
static void FixOtherLayersFromActive (Layer *pActiveLayer, UndoableOperation *pUndoOp=NULL)
 A layer flag such as overlay or solid has been changed and so we need take the passed in current active layer and then ensure that the other layers above and below this have the correct visibility and locked settings.

Protected Member Functions

virtual BOOL PostCreate (void)
 The FrameSGallery 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 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 SGDisplayLayerGetSelectedLayerGalItem ()
 Gets the selected layer gallery item In debug builds, an ENSURE will go off if there is no selected gal item.
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 BOOL DoDeleteSelection (void)
 FORCIBLY deletes the active layer/frame.
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 DoCopyLayer ()
 Copies the active layer creating a new one with a default frame name.
virtual BOOL DoSaveAnimation ()
 Saves out the current animation to file.
virtual BOOL DoPreviewAnimation ()
 Previews the current animation.
virtual BOOL DoFrameProperties ()
 Opens the frame properties dlg.
virtual BOOL DoRegenerateFrames ()
 While previewing an animation, if the spread properties are changed we neeed to regenerate the frame layers. This function invokes the correct Op.
virtual BOOL DoRegenerateSingleFrame ()
 While previewing an animation, if the frame layer properties are changed we neeed to regenerate the active frame. This function invokes the correct Op.
BOOL UpdateFrameRelatedButtons ()
 Ensures that they buttons on the gallery up to date in their greying/ungreying status.
BOOL IsFrameMode (Document *pDoc)
BOOL CloseFrameGallery ()
BOOL OpenLayerGallery ()
void SetNewDocBorn (BOOL Val)
BOOL GetNewDocBorn ()

Protected Attributes

BOOL m_NewDocBorn

Detailed Description

The Layer SuperGallery class.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery 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; SGDisplayFrame

Definition at line 224 of file sgframe.h.


Constructor & Destructor Documentation

FrameSGallery::FrameSGallery  ) 
 

FrameSGallery default constructor.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)

Definition at line 1006 of file sgframe.cpp.

01007 {
01008 #ifndef EXCLUDE_GALS
01009     pSpread = NULL;
01010     pDoc = NULL;
01011     DisplayForeground = NULL;   // Group of foreground layers
01012     DisplayBackground = NULL;   // Group of background layers
01013 
01014     OldGuideLayerState = -1;
01015     NewGuideLayerState = -1;
01016     m_NewDocBorn = FALSE;
01017 #endif
01018 } 

FrameSGallery::~FrameSGallery  ) 
 

FrameSGallery destructor.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)

Definition at line 1032 of file sgframe.cpp.

01033 {
01034 }


Member Function Documentation

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

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

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 1265 of file sgframe.cpp.

01266 {
01267     // No display tree? Better forget about it then!
01268     if (DisplayTree == NULL)
01269         return(FALSE);
01270 
01271     // Determine useful info - this is usually needed for most actions, so always get it
01272     Document        *SelectedDoc = Document::GetSelected();
01273     SGDisplayGroup  *DocumentGroup = DisplayTree->FindSubtree(this, SelectedDoc, NULL);
01274     SGDisplayFrame  *FirstSelected = NULL;
01275     
01276     if (DocumentGroup != NULL)
01277         FirstSelected = (SGDisplayFrame *) DocumentGroup->FindNextSelectedItem(NULL);
01278 
01279     // Now, process the action  TO DO! - see Colour gallery for examples
01280     switch(Action)
01281     {
01282         case SGACTION_CREATE:
01283             DoCreateNewItem();
01284             break;
01285 
01286         case SGACTION_EDIT:
01287             DoChangeName();
01288             break;
01289 
01290         case SGACTION_DELETE:
01291             //if (PrepareToDelete()) // No warning on Frame gallery
01292             DoDeleteSelection();
01293             break;
01294         
01295 //      case SGACTION_APPLY:
01296 //      case SGACTION_REDEFINE:
01297 //      case SGACTION_DISPLAYMODECHANGED:
01298 //          These operations are not provided by the layer gallery
01299 //          break;
01300 
01301         default:
01302             return(SuperGallery::ApplyAction(Action));
01303     }
01304 
01305     return(TRUE);
01306 }

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

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

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 2854 of file sgframe.cpp.

02855 {
02856     BOOL ok = TRUE;
02857 
02858     if (MenuID == SGMENU_OVERITEM)
02859     {
02860         // Over-list menu
02861         SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02862 
02863 #ifndef STANDALONE
02864 // no layer properties tab present on standalone version
02865         if (pLayerGalItem != NULL)
02866         {
02867             GIFAnimationPropertyTabs * pTabHandler = GIFAnimationPropertyTabsDlg::GetGIFAnimationPropertiesTabs();
02868             //LayerPropertyTabs * pTabHandler = LayerPropertyTabsDlg::GetLayerPropertiesTabs();
02869             if (pTabHandler)
02870             {
02871                 pTabHandler->SetCurrentLayer(pLayerGalItem->GetDisplayedLayer());
02872             }
02873         }
02874 #endif
02875         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_New);
02876         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Copy);
02877         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Delete,TRUE);
02878 #ifndef STANDALONE
02879 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Animation);
02880 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Save);
02881         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Preview);
02882         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Properties);
02883 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_FrameProps);
02884 //      ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Browser);
02885         ok = ok && AddCommand(TheMenu, (StringBase *) &SGCmd_Show);
02886 #endif
02887     }
02888 
02889     return(ok);
02890 }

BOOL FrameSGallery::CloseFrameGallery  )  [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 3273 of file sgframe.cpp.

03274 {
03275     String_32 Name(_R(IDS_FRAMEGAL_GALLNAME));
03276     DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(Name);
03277 
03278     // Ensure a valid ptr.
03279     if (pDialogBarOp == NULL)
03280         return FALSE;
03281     
03282     if (pDialogBarOp->GetRuntimeClass() == CC_RUNTIME_CLASS(FrameSGallery))
03283     {
03284         GIFAnimationPropertyTabs::SetFrameGalleryOpen(FALSE);
03285 
03286         // Toggle the visible state of the gallery window
03287         pDialogBarOp->SetVisibility( FALSE );
03288     }
03289     else
03290     {
03291         ERROR3("Got the frame gallery but it's not of the LayerSGallery class");
03292     }
03293 
03294     SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYFRAMEGALLERY, FALSE);
03295 
03296     GIFAnimationPropertyTabs::SetFrameGalleryOpen(FALSE);
03297 
03298     // Everything ok.
03299     return TRUE;
03300 }

void FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 from LayerSGallery.

Definition at line 1063 of file sgframe.cpp.

01064 {
01065     if (DisplayTree == NULL)
01066         return;
01067 
01068 TRACEUSER( "Neville", _T("FrameSGallery::CreateNewSubtree Just about to DestroySubtree\n"));
01069     // The layer gallery only ever shows one document, so destroy the entire tree
01070     // and start again from scratch (note that this doesn't destroy the root node)
01071     DisplayTree->DestroySubtree();
01072 
01073     // All groups will be destroyed by DestroySubtree(), so we'd better forget them
01074     DisplayForeground = NULL;
01075     
01076 TRACEUSER( "Neville", _T("FrameSGallery::CreateNewSubtree completed DestroySubtree\n"));
01077 
01078     if (ParentDoc == NULL)
01079         return;
01080 
01081     SGDisplayFrame  *DisplayLayer = NULL;
01082 
01083     EnsureActiveLayerIntegrity();
01084 
01085     // Create the foreground layer group
01086     DisplayForeground = new SGFrameGroup(this, ParentDoc,NULL,TRUE);    // Create new Group
01087     if (DisplayForeground == NULL)                                      // Total failure - abort
01088         return;
01089     DisplayTree->AddItem(DisplayForeground);                            // Add new group to tree
01090 
01091     Spread* pSelSpread = GetSelectedSpread();
01092     ERROR3IF(pSelSpread == NULL,"No selected spread in FrameSGallery");
01093     if (pSelSpread == NULL) return;
01094 
01095     Layer* pLayer                   = pSelSpread->FindLastLayer();
01096     Layer* pActiveLayer             = NULL;
01097     Layer* pGuideLayer              = NULL;
01098     BOOL SetActiveLayer             = FALSE;
01099 // Only Webster needs to show a dummy frame layer 
01100 #ifdef WEBSTER
01101     Layer* pSingleNonFrameLayer     = NULL;
01102     BOOL ShownSingleNonFrameLayer   = FALSE;
01103 #endif // WEBSTER
01104 
01105     while (pLayer != NULL)
01106     {
01107         // If we find a guide layer then note that for future use
01108         if (pLayer->IsGuide())
01109         {
01110             pGuideLayer = pLayer;
01111         }
01112         else if (
01113                  (pLayer->IsPseudoFrame() && pLayer->IsFrame())             // its a proper frame layer
01114 #ifdef WEBSTER
01115                  || (pLayer->IsPseudoFrame() && !ShownSingleNonFrameLayer)  // its a potential frame layer
01116 #endif // WEBSTER
01117                 )
01118         {
01119 #ifdef WEBSTER
01120             // If its not a frame layer then note that we have added our single
01121             // non-frame layer in.
01122             if (!pLayer->IsFrame())
01123             {
01124                 ShownSingleNonFrameLayer = TRUE;
01125                 pSingleNonFrameLayer = pLayer;
01126             }
01127 #endif // WEBSTER
01128 
01129             // Only add foreground layers and non-guide layers
01130             DisplayLayer = new SGDisplayFrame(pLayer);
01131 
01132             if (DisplayLayer != NULL)
01133             {
01134                 // Always add to the foreground layers
01135                 DisplayForeground->AddItem(DisplayLayer);
01136 
01137                 if (pLayer->IsActive())
01138                 {
01139                     ERROR3IF(pActiveLayer != NULL,"Found more than one active layer in the selected spread");
01140                     pActiveLayer = pLayer;
01141 
01142                     DisplayLayer->SetSelected(TRUE);    // Make the active layer selected
01143                     SetActiveLayer = TRUE;              // Note this fact
01144                 }
01145             }
01146         }
01147 
01148         pLayer = pLayer->FindPrevLayer();
01149     }
01150 
01151     // If we have not set a selected layer then this is very bad
01152     if (!SetActiveLayer)
01153     {
01154         TRACEUSER( "Neville", _T("Active layer is not a frame layer so force it!\n"));
01155         Layer * pNewActiveLayer = pSpread->FindLastFrameLayer();
01156 #ifdef WEBSTER
01157         if (pNewActiveLayer == NULL && pSingleNonFrameLayer != NULL)
01158             pNewActiveLayer = pSingleNonFrameLayer;
01159 #else
01160 //      ERROR3IF(pNewActiveLayer == NULL,"No current active frame layer");
01161 #endif // WEBSTER
01162 
01163         // If we have an active layer, ensure that it really is the one and only active layer
01164         if (pNewActiveLayer != NULL)
01165         {
01166             // Search for the new display item to match this new active layer 
01167             SGDisplayLayer *pWantedDispLayer = NULL;
01168             SGDisplayLayer *pDispLayer = ((SGDisplayLayer *) DisplayForeground->GetChild());
01169             while (pDispLayer != NULL)                      
01170             {
01171                 if (pDispLayer->GetDisplayedLayer() == pNewActiveLayer)
01172                     pWantedDispLayer = pDispLayer;
01173                 pDispLayer = ((SGDisplayLayer *)pDispLayer->GetNext());
01174             }
01175             
01176             // If we found the required display item then go and select it
01177             if (pWantedDispLayer)
01178             {
01179                 // Now update the selection states...
01180                 SelectItems(FALSE); // Deselect everything else
01181                 // Something has changed so we must go and select this new item
01182                 pWantedDispLayer->SetSelected(TRUE);
01183             }
01184 
01185             // As this can only happen when we have a frame layer which is not active
01186             // e.g. import a non-frame xar/web document into a non-frame document
01187             // we must use the layer form of MakeActiveLayer so that the visibility of
01188             // layers is not affected. 
01189             LayerSGallery::MakeActiveLayer(pNewActiveLayer);
01190             //FrameSGallery::MakeActiveLayer(pNewActiveLayer);
01191         }
01192     }
01193 
01194     // The new state of the Guide Layer is now the old state
01195     OldGuideLayerState = NewGuideLayerState;
01196 
01197     if (pGuideLayer == NULL)
01198         NewGuideLayerState = -1;                        // If there's no guide layer, set new state to be -1
01199     else
01200         NewGuideLayerState = pGuideLayer->IsVisible();  // New state is based on the guide layer's visibility
01201 
01202     if (IsVisible())
01203     {
01204         SetBoolGadgetSelected(_R(IDC_BTN_MULTILAYER),!(ParentDoc->IsMultilayer() == 0));
01205         SetBoolGadgetSelected(_R(IDC_BTN_ALLVISIBLE),!(ParentDoc->IsAllVisible() == 0));
01206     }
01207 
01208     TRACEUSER( "Neville", _T("FrameSGallery::CreateNewSubtree exit\n"));
01209 }

String_256 FrameSGallery::CreateUniqueLayerID Spread pSpread,
const String_256 pBaseName = NULL
[static]
 

This function tries to hide the specified node. Copy of the undoable operation version as we are not undoable and don't have an op. Hide it as it may be mentioned in the undo history. Note: This would be safer than deleting the layer nodes but if we use this, which should be the same as the DoHideNode in undoable operation does, then it leaks the hidden nodes and layers that are being hidden. So there must be something sneaky going on.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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Parameters:
pSpread - the spread to use when checking [INPUTS] pBaseName - the name to use as the basis of the layer name, defaults to just 'Frame'
Returns:
A LayerID which is unique for the layer galleries spread.

Errors: -

See also:
-

Definition at line 2425 of file sgframe.cpp.

02426 {
02427     if (pSpread == NULL) return String_256("");
02428 
02429     String_256 UniqueLayerID; 
02430     INT32 NumLayers = 0; 
02431 
02432     Layer* pLayer = pSpread->FindFirstLayer();
02433 
02434     // Calculate how many layers are on the current spread
02435     while (pLayer != NULL)
02436     {
02437         NumLayers++;
02438         pLayer = pLayer->FindNextLayer();
02439     }
02440 
02441     INT32 NewLayerNum = NumLayers;
02442     if (NewLayerNum == 0)
02443         NewLayerNum = 1; // Always start at one
02444 
02445     BOOL Unique;  // Flag used to indicate if the id generated is unique or not 
02446     String_256 LayerName(_R(IDS_DEFAULTFRAMENAME));
02447     // If the caller suggested a base name then use this instead.
02448     if (pBaseName != NULL)
02449         LayerName = *pBaseName;
02450 
02451     do 
02452     {
02453         // Construct a first attempt at a unique layer id 'Layer n' 
02454         // where n = the number of layers on the current spread + 1
02455         UniqueLayerID.MakeMsg(_R(IDS_FRAMENAMEUNIQUEFORM), (TCHAR *)LayerName, NewLayerNum);
02456         //UniqueLayerID.MakeMsg(_R(IDS_SGLAYER_LAYER_NUM), /*TEXT("Layer #1%ld"),*/NewLayerNum);
02457     
02458         // Check that UniqueLayerID is indeed unique 
02459         Unique = TRUE; // Until we know better 
02460         pLayer = pSpread->FindFirstLayer();
02461         while (pLayer != NULL)
02462         {   
02463             if (UniqueLayerID == pLayer->GetLayerID())
02464             {
02465                 Unique = FALSE; 
02466 
02467                 // UniqueLayerID is not unique so increment NewLayerNum and try again 
02468                 NewLayerNum++;      
02469                 break; 
02470             }
02471             pLayer = pLayer->FindNextLayer();
02472         }
02473         
02474     } while (!Unique); 
02475 
02476     return(UniqueLayerID); 
02477 }

void FrameSGallery::DoChangeOverlay Layer pLayer,
BOOL  Overlay
[static]
 

Called when the Overlay button is clicked in a layer gallery item. Changes the Overlayness of the displayed layer.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Parameters:
pLayer = the layer to change [INPUTS] Overlay - TRUE means make the displayed layer Overlayed FALSE means make the displayed layer non-Overlayed
Returns:
-
Notes: Does not redraw the layer in the display list

Definition at line 2667 of file sgframe.cpp.

02668 {
02669     ERROR3IF(pLayer == NULL,"pLayer == NULL");
02670     if (pLayer == NULL) return;
02671 
02672     BOOL PrevOverlay = pLayer->IsOverlay();
02673     pLayer->SetOverlay(Overlay);
02674     BOOL PostOverlay = pLayer->IsOverlay();
02675 
02676     //if (PrevOverlay != PostOverlay)
02677     //  NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02678 
02679     if (PrevOverlay != PostOverlay)
02680     {
02681         Spread* pSpread = pLayer->FindParentSpread();
02682         // Go and fix the status of other layers according to this new setting
02683         FixOtherLayers(pSpread);
02684 
02685         // Ensure that the buttons are in the correct state
02686         BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::LayerReason::ACTIVE_LAYER_CHANGED));
02687     }
02688 }

void FrameSGallery::DoChangeSolid Layer pLayer,
BOOL  Solid
[static]
 

Called when the Solid button is clicked in a layer gallery item. Changes the Solidness of the displayed layer.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Parameters:
pLayer = the layer to change [INPUTS] Solid - TRUE means make the displayed layer Solid FALSE means make Solid
Returns:
-
Notes: Does not redraw the layer in the display list

Definition at line 2607 of file sgframe.cpp.

02608 {
02609     ERROR3IF(pLayer == NULL,"pLayer == NULL");
02610     if (pLayer == NULL) return;
02611 
02612     BOOL PrevSolid = pLayer->IsSolid();
02613     pLayer->SetSolid(Solid);
02614     BOOL PostSolid = pLayer->IsSolid();
02615 
02616     /* if (PrevSolid != PostSolid)
02617     {
02618         // Force a redraw if the layer's visibility has changed
02619         FrameSGallery::ForceRedrawLayer(pLayer->FindDocument(), pLayer);
02620 
02621         // If layer has just become invisible, remove the selections on the layer 
02622         if (!PostSolid)
02623             NodeRenderableInk::DeselectAllOnLayer(pLayer); 
02624     } */
02625 
02626     if (PrevSolid != PostSolid)
02627     {
02628         // Mark all frames above this as edited until we reach the last frame
02629         // OR we hit a solid/background layer.
02630         // Previewing all the frames copes with dependent frames
02631         // Previwing single frames does not if you preview the solid frame.
02632         Layer * pFrame = pLayer->FindNextFrameLayer();
02633         while (pFrame != NULL && !pFrame->IsSolid())
02634         {
02635             // Mark that frame as edited
02636             pFrame->SetEdited(TRUE);
02637             pFrame = pFrame->FindNextFrameLayer();
02638         }
02639         
02640         Spread* pSpread = pLayer->FindParentSpread();
02641         // Go and fix the status of other layers according to this new setting
02642         FixOtherLayers(pSpread);
02643 
02644         // Ensure that the buttons are in the correct state
02645         BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::LayerReason::ACTIVE_LAYER_CHANGED));
02646     }
02647 }

void FrameSGallery::DoCommand StringBase CommandID  )  [virtual]
 

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

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 3021 of file sgframe.cpp.

03022 {
03023     if (*CommandID == SGCmd_Copy)
03024         DoCopyLayer();
03025     else if (*CommandID == SGCmd_New)
03026         DoCreateNewItem();
03027     else if (*CommandID == SGCmd_Delete)
03028     {
03029         //if (PrepareToDelete()) // No warning on Frame gallery
03030         DoDeleteSelection();
03031     }
03032 //  else if (*CommandID == SGCmd_Properties)
03033 //      DoFrameProperties();
03034     else if (*CommandID == SGCmd_Preview)
03035     {
03036         DoPreviewAnimation();
03037     }
03038     else if (*CommandID == SGCmd_FrameProps || *CommandID == SGCmd_Properties)
03039     {
03040         // Open the Animation properties dlg with the "Frame properties" page selected.
03041         DoFrameProperties();
03042     }
03043     else if (*CommandID == SGCmd_Show)
03044     {
03045         // Toggle the state of the show frame in animation flag
03046         SGDisplayLayer* pItem = GetSelectedLayerGalItem();
03047         Layer * pLayer = NULL;
03048         if (pItem)
03049             pLayer = pItem->GetDisplayedLayer();
03050         if (pLayer)
03051         {
03052             BOOL CurrentState = pLayer->IsHiddenFrame();
03053             pLayer->SetHiddenFrame(!CurrentState);
03054             if (pItem)
03055                 pItem->ForceRedrawOfMyself();
03056 
03057             // Ensure that the buttons are in the correct state
03058             BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::LayerReason::ACTIVE_LAYER_CHANGED));
03059         }
03060     }
03061 //  else if (*CommandID == SGCmd_Save)
03062 //      DoSaveAnimation();
03063     // Implement ****
03064     //  *CommandID == SGCmd_Animation
03065     //  *CommandID == SGCmd_Browser
03066 
03067     // Don't call the base class 'cos we don't want any other commands
03068 }

void FrameSGallery::DoCopyLayer  )  [protected, virtual]
 

Copies the active layer creating a new one with a default frame name.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Parameters:
- [INPUTS]
Returns:
-

Reimplemented from LayerSGallery.

Definition at line 2578 of file sgframe.cpp.

02579 {
02580     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_COPYFRAME); 
02581     if (pOpDesc != NULL)
02582         pOpDesc->Invoke();
02583     else
02584     {
02585         ERROR3("Couldn't find OPTOKEN_FRAME_COPYFRAME op descriptor");
02586     }
02587 }

void FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)

Reimplemented from LayerSGallery.

Definition at line 2555 of file sgframe.cpp.

02556 {
02557     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_NEWFRAME); 
02558     if (pOpDesc != NULL)
02559         pOpDesc->Invoke();
02560     else
02561     {
02562         ERROR3("Couldn't find OPTOKEN_FRAME_NEWFRAME op descriptor");
02563     }
02564 }

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

FORCIBLY deletes the active layer/frame.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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:
FrameSGallery::PrepareToDelete; ColourManager::HideColours

Reimplemented from LayerSGallery.

Definition at line 2528 of file sgframe.cpp.

02529 {
02530     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_DELETEFRAME); 
02531     if (pOpDesc != NULL)
02532         pOpDesc->Invoke();
02533     else
02534     {
02535         ERROR3("Couldn't find OPTOKEN_FRAME_DELETEFRAME op descriptor");
02536     }
02537 
02538     return TRUE;
02539 }

BOOL FrameSGallery::DoFrameProperties  )  [protected, virtual]
 

Opens the frame properties dlg.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/5/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 3205 of file sgframe.cpp.

03206 {
03207     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_GIFANIMPROPERTYTABS);
03208 
03209     if (pOpDesc != NULL)
03210     {
03211         // Select the "Frame properties tab".
03212         GIFAnimationPropertyTabsDlg::SetPageToOpen(GIFAnimationPropertyTabs::FramePropertiesTabNumber);
03213 
03214         String_256 Str;
03215         OpState State = pOpDesc->GetOpsState(&Str);
03216         if (!State.Greyed)
03217             pOpDesc->Invoke();
03218         else
03219         {
03220             GIFAnimationPropertyTabs * pTabHandler = GIFAnimationPropertyTabsDlg::GetGIFAnimationPropertiesTabs();
03221             if (pTabHandler)
03222             {
03223                 DialogTabOp* pDlg =  pTabHandler->GetTabbedDlg();
03224                 if (pDlg != NULL)
03225                     pDlg->Open();
03226             }
03227         }
03228     }
03229     return TRUE;
03230 }

static BOOL FrameSGallery::DoHideNode Node pNodeToHide  )  [static]
 

void FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Parameters:
Reason = how the layer should be moved [INPUTS]
Returns:
-
Note: Same as LayerSGallery version but uses FRAME_MOVE

Reimplemented from LayerSGallery.

Definition at line 2706 of file sgframe.cpp.

02707 {
02708     SGDisplayLayer* pLayerGalItem = GetSelectedLayerGalItem();
02709 
02710     if (pLayerGalItem != NULL)
02711     {
02712         OpLayerGalParam Param(FRAME_MOVE, pSpread);
02713 
02714         Param.pLayer = pLayerGalItem->GetDisplayedLayer();
02715 
02716         switch (Reason)
02717         {
02718             case (MOVELAYER_UPONE) :
02719                 Param.pContextNode  = Param.pLayer->FindNextLayer();
02720                 Param.AttDir        = NEXT;
02721                 break;
02722 
02723             case (MOVELAYER_DOWNONE) :
02724                 Param.pContextNode  = Param.pLayer->FindPrevLayer();
02725                 Param.AttDir        = PREV;
02726                 break;
02727 
02728             default:
02729                 ERROR3("Unrecognised MoveLayer reason");
02730                 break;
02731         }
02732 
02733         if (Param.pContextNode != NULL)
02734         {
02735             // Redraw after the op if both this layer and the one it's moving in front/behind
02736             // is also visible
02737             Param.MoveRedraw = ((Layer*)Param.pContextNode)->IsVisible() &&
02738                                     Param.pLayer->IsVisible();
02739 
02740             // The above won't work in an undo or redo, so always redraw
02741             Param.MoveRedraw = TRUE;
02742 
02743             OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_LAYERGALCHANGE); 
02744             if (pOpDesc != NULL)
02745                 pOpDesc->Invoke((OpParam*)&Param);
02746             else
02747             {
02748                 ERROR3("Couldn't find OPTOKEN_LAYERGALCHANGE op descriptor");
02749             }
02750         }
02751     }
02752 }

BOOL FrameSGallery::DoPreviewAnimation  )  [protected, virtual]
 

Previews the current animation.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 3108 of file sgframe.cpp.

03109 {
03110     // Check to see if the operation is available
03111     // No longer required as the button is hooked into the real op
03112     //String_256 ShadeReason;
03113     //OpState State;
03114     
03115     //State = OpGrabAllFrames::GetState(&ShadeReason, NULL);
03116     //if (State.Greyed)
03117     //  return FALSE;
03118 
03119     // Normally we want to invoke the grab frame, but we will sneak in that
03120     // if the shift key is pressed then we will grab all frames.
03121     OpDescriptor* pOpDesc = NULL;
03122     // Is the shift key pressed? 
03123     if (KeyPress::IsAdjustPressed())
03124         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABALLFRAMES); 
03125     else
03126         pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABFRAME); 
03127 
03128     if (pOpDesc != NULL)
03129         pOpDesc->Invoke();
03130     else
03131     {
03132         ERROR3("Couldn't find OPTOKEN_FRAME_GRABFRAME/_GRABALLFRAMES op descriptor");
03133     }
03134 
03135     return TRUE;
03136 }

BOOL FrameSGallery::DoRegenerateFrames  )  [protected, virtual]
 

While previewing an animation, if the spread properties are changed we neeed to regenerate the frame layers. This function invokes the correct Op.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/05/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 3179 of file sgframe.cpp.

03180 {
03181     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABALLFRAMES); 
03182     if (pOpDesc != NULL)
03183         pOpDesc->Invoke();
03184     else
03185     {
03186         ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
03187     }
03188 
03189     return TRUE;
03190 }

BOOL FrameSGallery::DoRegenerateSingleFrame  )  [protected, virtual]
 

While previewing an animation, if the frame layer properties are changed we neeed to regenerate the active frame. This function invokes the correct Op.

Author:
Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/05/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 3151 of file sgframe.cpp.

03152 {
03153     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_FRAME_GRABFRAME); 
03154     GIFAnimationExportParam Param;
03155     if (pOpDesc != NULL)
03156         pOpDesc->Invoke(&Param);
03157     else
03158     {
03159         ERROR3("Couldn't find OPTOKEN_FRAME_GRABALLFRAMES op descriptor");
03160     }
03161 
03162     return TRUE;
03163 }

BOOL FrameSGallery::DoSaveAnimation  )  [protected, virtual]
 

Saves out the current animation to file.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 3082 of file sgframe.cpp.

03083 {
03084     // Not required at present
03085 /*  OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_SAVEANIMATEDGIF); 
03086     if (pOpDesc != NULL)
03087         pOpDesc->Invoke();
03088     else
03089     {
03090         ERROR3("Couldn't find OPTOKEN_FRAME_COPYFRAME op descriptor");
03091     }
03092 */
03093     return TRUE;
03094 }

void FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 2773 of file sgframe.cpp.

02774 {
02775     EnableGadget(_R(IDC_GALLERY_UPONE),     !ShadeIt);
02776     EnableGadget(_R(IDC_GALLERY_DOWNONE),   !ShadeIt);
02777     EnableGadget(_R(IDC_GALLERY_PROPERTIES),!ShadeIt);
02778     EnableGadget(_R(IDC_GALLERY_COPY),      !ShadeIt && !IsSelectedItemGuideLayer());
02779     EnableGadget(_R(IDC_FRAME_DELETE),      !ShadeIt);
02780 
02781     EnableGadget(_R(IDC_BTN_MULTILAYER),    !ShadeIt);
02782     EnableGadget(_R(IDC_BTN_ALLVISIBLE),    !ShadeIt);
02783 
02784     //EnableGadget(_R(IDC_GALLERY_NAME),        !ShadeIt);
02785 
02786     EnableGadget(_R(IDC_GALLERY_COPY),      !ShadeIt && !IsSelectedItemGuideLayer());
02787 
02788     UpdateFrameRelatedButtons();
02789 }

BOOL FrameSGallery::EnsureFrameLayerIntegrity Spread pSpread  )  [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.This function should be called before any frame related actions are carried out It will ensure that all the visible layers are frame layers.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/5/97
Returns:
True if worked ok, False otherwise.

Errors: -

See also:
-

Definition at line 2199 of file sgframe.cpp.

02200 {
02201     ERROR2IF(pSpread == NULL,FALSE,"EnsureFrameLayerIntegrity null spread passed in");
02202 
02203     // For the present moment just ensure that the active layer is a frame layer
02204     //Layer * pActiveLayer = pSpread->FindActiveLayer();
02205     //if (pActiveLayer)
02206     //  pActiveLayer->SetFrame(TRUE);
02207 
02208 /* #if _DEBUG
02209     // Find out whether the operation thinks it is required or not
02210     String_256 ShadeReason;
02211     OpState State;
02212     State = OpCombineLayersToFrameLayer::GetState(&ShadeReason, NULL);
02213     if (!State.Greyed)
02214     {
02215         // Try and find the operation we want to use
02216         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_COMBINELAYERSTOFRAMELAYER); 
02217         if (pOpDesc != NULL)
02218         {
02219             // We found it, so invoke it with the spread we were given
02220             OpParam Param;
02221             Param.Param1 = (INT32)pSpread;
02222             pOpDesc->Invoke(&Param);
02223         }
02224         else
02225         {
02226             ERROR3("Couldn't find OPTOKEN_COMBINELAYERSTOFRAMELAYER op descriptor");
02227         }
02228     } */
02229 
02230 /* #if 0 //_DEBUG
02231 // WARNING only do this in Webster builds as otherwise may be corrupting layers that are in the
02232 // undo buffer which could lead to immense problems.
02233 // This leads to problems in the undo e.g. draw object, import doc with layers and undo back to start
02234 // can mean no layers in doc.
02235 // In Camelot do nothing
02236 #ifdef WEBSTER
02237     // Ensure that all other non-guide and non-background layers are frame layers
02238     UINT32 NonFrameLayersFound = 0;
02239     Layer* pCurrentLayer = pSpread->FindFirstLayer();
02240     Layer* pNonFrameLayer = NULL; 
02241     while (pCurrentLayer != NULL)
02242     {
02243         if (!pCurrentLayer->IsBackground() && !pCurrentLayer->IsGuide() &&
02244             !pCurrentLayer->IsPageBackground() && !pCurrentLayer->IsFrame())
02245         {
02246             // Note that we have found a non-frame layer.
02247             pNonFrameLayer = pCurrentLayer;
02248             NonFrameLayersFound++;
02249         }
02250 
02251         pCurrentLayer = pCurrentLayer->FindNextLayer();
02252     }
02253 
02254     if (NonFrameLayersFound > 0 && pNonFrameLayer != NULL)
02255     {
02256         TRACEUSER( "Neville", _T("++++++++++EnsureFrameLayerIntegrity found %d non-frame layers\n"),NonFrameLayersFound);
02257 
02258         // Right, we need to move all the nodes from the all non-frame layers and move them
02259         // to one of the non-frame layers and make this one a frame layer. The user should
02260         // therefore notice no difference in appearance of the document as they would have
02261         // been seeing one frame representing all the non-frame layers in the frame gallery.
02262 
02263         // First, mark the non-frame layer found in the above search as a frame layer as this
02264         // is the one that we are going to use as out destination. Then all other non-frame
02265         // searches will not find it. Also, mark it as edited.
02266         pNonFrameLayer->SetFrame(TRUE);
02267         pNonFrameLayer->SetEdited(TRUE);
02268 
02269         // Start a progress bar
02270         Progress CombiningProgress(_R(IDS_COMBINING_LAYERS));
02271         CombiningProgress.Update();
02272 
02273         BOOL UpdateSelection = FALSE;
02274         Layer* pLayer = pSpread->FindFirstLayer();
02275         while (pLayer != NULL)
02276         {
02277             if (!pLayer->IsBackground() && !pLayer->IsGuide() &&
02278                 !pLayer->IsPageBackground() && !pLayer->IsFrame())
02279             {
02280                 // Move all the top level nodes to the new layer
02281                 // We MUST include hidden nodes as these will be in undo records
02282                 Node * pNode = pLayer->FindFirstChild();
02283                 while (pNode)
02284                 {
02285                     // Note the node to move
02286                     Node* pNodeToMove = pNode;
02287                     // and the next node in the tree
02288                     pNode = pNode->FindNext();
02289                     // Now move hide the node (should hide it but we are not undoable)
02290                     UpdateSelection = pNodeToMove->IsSelected();
02291                     //if (!DoHideNode(pNodeToMove, FALSE, NULL, FALSE))
02292                     // Find the insertion point, which will be after the last child but
02293                     // BEFORE the insertion node, if present.
02294                     Node * pInsertPoint = pNonFrameLayer->FindLastChild(TRUE);
02295                     if (pInsertPoint)
02296                         pNodeToMove->MoveNode(pInsertPoint, NEXT);
02297                     else
02298                         pNodeToMove->MoveNode(pNonFrameLayer, LASTCHILD);
02299 
02300                     // Update the progress display to show we have done something
02301                     CombiningProgress.Update();
02302                 }
02303                 
02304                 // Finally, go and hide that layer
02305                 Layer * pLayerToHide = pLayer;
02306                 // First, invalidate the bounding rect
02307                 pLayerToHide->InvalidateBoundingRect();
02308                 // note the next layer
02309                 pLayer = pLayer->FindNextLayer();
02310                 // and hide the layer itself.
02311                 // Have to do this ourselves as we are not undoable
02312                 pLayerToHide->CascadeDelete();
02313                 delete pLayerToHide;
02314                 pLayerToHide = NULL;
02315             }
02316             else
02317                 pLayer = pLayer->FindNextLayer();
02318 
02319             // Update the progress display to show we have done something
02320             CombiningProgress.Update();
02321         }
02322 
02323         // Make sure that our new frame layer is up to date
02324         pNonFrameLayer->InvalidateBoundingRect();
02325 
02326         // If we have changed a selected node then update the selection
02327         if (UpdateSelection)
02328         {
02329             // Update the selection range 
02330             Camelot.UpdateSelection();
02331         }
02332 
02333         // We need to update the display as one or more layer items have changed status
02334         // So tell ourselves about the change. (We are static and so cannot do it directly!)
02335         BROADCAST_TO_ALL(SpreadMsg(pSpread, SpreadMsg::SpreadReason::LAYERCHANGES));
02336 
02337         // Update the progress display to show we have done something
02338         CombiningProgress.Update();
02339     }
02340 #endif // WEBSTER
02341 #endif // DEBUG
02342 */
02343 
02344 // In Webster ensure that all layers are actually frames
02345 // In Camelot do nothing
02346 #ifdef WEBSTER
02347     // Ensure that all other non-guide and non-background layers are frame layers
02348     UINT32 NonFrameLayersFound = 0;
02349     Layer* pCurrentLayer = pSpread->FindFirstLayer();
02350     while (pCurrentLayer != NULL)
02351     {
02352         if (pCurrentLayer->IsPseudoFrame() && !pCurrentLayer->IsFrame())
02353         {
02354             pCurrentLayer->SetFrame(TRUE);
02355             NonFrameLayersFound++;
02356         }
02357 
02358         pCurrentLayer = pCurrentLayer->FindNextLayer();
02359     }
02360 
02361     if (NonFrameLayersFound > 0)
02362     {
02363         TRACEUSER( "Neville", _T("++++++++++EnsureFrameLayerIntegrity found %d non-frame layers\n"),NonFrameLayersFound);
02364 
02365         // We need to update the display as one or more layer items have changed status
02366         // So tell ourselves about the change. (We are static and so cannot do it directly!)
02367         BROADCAST_TO_ALL(SpreadMsg(pSpread, SpreadMsg::SpreadReason::LAYERCHANGES));
02368     } 
02369 #endif // WEBSTER
02370 
02371     return TRUE;
02372 }

void FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)

Reimplemented from LayerSGallery.

Definition at line 1735 of file sgframe.cpp.

01736 {
01737     if (pSpread == NULL) return;
01738 
01739     // Get the first layer in the spread
01740     Layer* pLayer = pSpread->FindFirstLayer();  
01741 
01742     while (pLayer != NULL)
01743     {
01744         // If the layer is not visible OR the layer is locked, make sure there is no selection
01745         if (!pLayer->IsVisible() || pLayer->IsLocked())
01746             NodeRenderableInk::DeselectAllOnLayer(pLayer);
01747 
01748         pLayer = pLayer->FindNextLayer();
01749     }
01750 }

void FrameSGallery::FixOtherLayers Spread pSpread  )  [static]
 

A layer flag such as overlay or solid has been changed and so we need to go and find the active layer and ensure that the other layers above and below this have the correct visibility and locked settings.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/97
Parameters:
pSpread = ptr to spread [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 1915 of file sgframe.cpp.

01916 {
01917     // Check that the class variable storing the current/selected spread is ok
01918     if (pSpread == NULL) return;
01919 
01920     // Get the first layer in the spread
01921     Layer* pFirstLayer = pSpread->FindFirstLayer(); 
01922 
01923     // Not found an active layer yet
01924     Layer* pActiveLayer = NULL;
01925 
01926     // Start the search from the first layer
01927     Layer* pLayer = pFirstLayer;
01928     while (pLayer != NULL && pActiveLayer == NULL)
01929     {
01930         if (pLayer->IsActive())
01931             pActiveLayer = pLayer;  // Found the active layer, so make a note of it
01932 
01933         pLayer = pLayer->FindNextLayer();
01934     }
01935 
01936     if (pActiveLayer)
01937         FixOtherLayersFromActive(pActiveLayer);
01938 }

void FrameSGallery::FixOtherLayersFromActive Layer pActiveLayer,
UndoableOperation pUndoOp = NULL
[static]
 

A layer flag such as overlay or solid has been changed and so we need take the passed in current active layer and then ensure that the other layers above and below this have the correct visibility and locked settings.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/97
Parameters:
pActiveLayer = the current active layer [INPUTS] pUndoOp = if non null, the default, will do the change undoably

Definition at line 1955 of file sgframe.cpp.

01957 {
01958     // This might be the new active layer that we are setting and so
01959     // it might not have been made active yet!
01960     if (pActiveLayer == NULL) // || !pActiveLayer->IsActive())
01961     {
01962         ERROR3("FixOtherLayersFromActive has been given a bad active layer!");
01963         return;
01964     }
01965 
01966     // Only need a spread pointer in the undoable case
01967     Spread * pSpread = NULL;
01968     if (pUndoOp != NULL)
01969         pSpread = pActiveLayer->FindParentSpread();
01970 
01971     // Ensure that the new active layer is going to be visible and unlocked
01972     // Assume code is called from make active code which will force the redraw
01973     // and selection changes as required. So do it the simple way
01974     if (pUndoOp == NULL || pSpread == NULL)
01975     {
01976         LayerSGallery::DoChangeVisible(pActiveLayer,TRUE);
01977         LayerSGallery::DoChangeLocked(pActiveLayer,FALSE);
01978     }
01979     else
01980     {
01981         // Make visible and locked
01982         // Only change if required as otherwise we will get an unwanted undo step
01983 //      if (!pActiveLayer->IsVisible())
01984         {
01985             OpLayerGalParam Param(LAYER_VISIBLE, pSpread);
01986             Param.NewState = TRUE;
01987             Param.pLayer = pActiveLayer;
01988             LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
01989         }
01990 
01991         // Only change if required as otherwise we will get an unwanted undo step
01992 //      if (pActiveLayer->IsLocked())
01993         {
01994             OpLayerGalParam LockedParam(LAYER_LOCKED, pSpread);
01995             LockedParam.NewState = FALSE;
01996             LockedParam.pLayer = pActiveLayer;
01997             LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), LockedParam);
01998         }
01999     }
02000 
02001     // Go though the layers from the new active layer downwards and set
02002     // all previous layers non-visible and non-selected
02003     Layer* pLayer = pActiveLayer->FindPrevLayer();
02004     BOOL FoundSolid = pActiveLayer->IsSolid();
02005     BOOL OverlayPrevious = FALSE;
02006     // Solid flag overrides the overlay flag
02007     if (!FoundSolid)
02008         OverlayPrevious = pActiveLayer->IsOverlay();
02009     while (pLayer != NULL)
02010     {
02011         if (pLayer->IsPseudoFrame())
02012         {
02013             if (pLayer->IsSolid() && !FoundSolid)
02014             {
02015                 // Stop any later solid frames having any effect
02016                 FoundSolid = TRUE;
02017                 // Stop any overlay having an effect
02018                 OverlayPrevious = FALSE;
02019                 if (pUndoOp == NULL || pSpread == NULL)
02020                 {
02021                     LayerSGallery::DoChangeVisible(pLayer,TRUE);
02022                     LayerSGallery::DoChangeLocked(pLayer,TRUE);
02023                 }
02024                 else
02025                 {
02026                     // Only change if required as otherwise we will get an unwanted undo step
02027 //                  if (!pLayer->IsVisible())
02028                     {
02029                         OpLayerGalParam Param(LAYER_VISIBLE, pSpread);
02030                         Param.NewState = TRUE;
02031                         Param.pLayer = pLayer;
02032                         LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
02033                     }
02034                     // Only change if required as otherwise we will get an unwanted undo step
02035 //                  if (!pLayer->IsLocked())
02036                     {
02037                         OpLayerGalParam LockedParam(LAYER_LOCKED, pSpread);
02038                         LockedParam.NewState = TRUE;
02039                         LockedParam.pLayer = pLayer;
02040                         LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), LockedParam);
02041                     }
02042                 }
02043             }
02044             else
02045             {
02046                 BOOL NewVisibleState = TRUE;
02047                 if (OverlayPrevious)
02048                     NewVisibleState = TRUE;
02049                 else
02050                     NewVisibleState = FALSE;
02051 
02052                 if (pUndoOp == NULL || pSpread == NULL)
02053                 {
02054                     LayerSGallery::DoChangeVisible(pLayer,NewVisibleState);
02055                     LayerSGallery::DoChangeLocked(pLayer,TRUE);
02056                 }
02057                 else
02058                 {
02059                     // Only change if required as otherwise we will get an unwanted undo step
02060 //                  if (pLayer->IsVisible() != NewVisibleState)
02061                     {
02062                         OpLayerGalParam Param(LAYER_VISIBLE, pSpread);
02063                         Param.NewState = NewVisibleState;
02064                         Param.pLayer = pLayer;
02065                         LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
02066                     }
02067                     // Only change if required as otherwise we will get an unwanted undo step
02068 //                  if (!pLayer->IsLocked())
02069                     {
02070                         OpLayerGalParam LockedParam(LAYER_LOCKED, pSpread);
02071                         LockedParam.NewState = TRUE;
02072                         LockedParam.pLayer = pLayer;
02073                         LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), LockedParam);
02074                     }
02075                 }
02076 
02077                 // If we are currently overlaying and this frame
02078                 // is overlay as well then keep overlay on, otherwise
02079                 // turn it off.
02080                 if (OverlayPrevious && pLayer->IsOverlay())
02081                     OverlayPrevious = TRUE;
02082                 else 
02083                     OverlayPrevious = FALSE;
02084             }
02085 
02086             // Overlay should only affect the previous frame
02087             //if (!pLayer->IsSolid() && pLayer->IsOverlay())
02088             //  OverlayPrevious = TRUE;
02089             //else 
02090             //  OverlayPrevious = FALSE;
02091         }
02092 
02093         pLayer = pLayer->FindPrevLayer();
02094     }
02095 
02096     // Go though the layers from the new active layer upwards and set
02097     // all layers above to be non-visible and non-selected
02098     pLayer = pActiveLayer->FindNextLayer();
02099     while (pLayer != NULL)
02100     {
02101         if (pLayer->IsPseudoFrame())
02102         {
02103             if (pUndoOp == NULL || pSpread == NULL)
02104             {
02105                 LayerSGallery::DoChangeVisible(pLayer,FALSE);
02106                 LayerSGallery::DoChangeLocked(pLayer,TRUE);
02107             }
02108             else
02109             {
02110                 // Only change if required as otherwise we will get an unwanted undo step
02111 //              if (pLayer->IsVisible())
02112                 {
02113                     OpLayerGalParam Param(LAYER_VISIBLE, pSpread);
02114                     Param.NewState = FALSE;
02115                     Param.pLayer = pLayer;
02116                     LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
02117                 }
02118                 // Only change if required as otherwise we will get an unwanted undo step
02119 //              if (!pLayer->IsLocked())
02120                 {
02121                     OpLayerGalParam LockedParam(LAYER_LOCKED, pSpread);
02122                     LockedParam.NewState = TRUE;
02123                     LockedParam.pLayer = pLayer;
02124                     LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), LockedParam);
02125                 }
02126             }
02127         }
02128 
02129         pLayer = pLayer->FindNextLayer();
02130     }
02131 }

OpState FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 2920 of file sgframe.cpp.

02921 {
02922     OpState State;
02923 
02924     if (AmShaded)       // No commands available while the gallery is shaded
02925     {
02926         State.Greyed = TRUE;
02927         return(State);
02928     }
02929 
02930     if (*CommandID == SGCmd_Copy    || // --- Copy/Delete/Properties
02931     //  *CommandID == SGCmd_Delete  ||
02932         *CommandID == SGCmd_Show
02933 //      *CommandID == SGCmd_Properties ||
02934 //      *CommandID == SGCmd_Animation ||
02935 //      *CommandID == SGCmd_Browser ||
02936 //      *CommandID == SGCmd_FrameProps  
02937         )
02938     {
02939         SGDisplayLayer* pItem = GetSelectedLayerGalItem();
02940 
02941         if (pItem == NULL)
02942         {
02943             State.Greyed = TRUE;
02944             ShadeReason->MakeMsg(_R(IDS_SGSHADE_SINGLECOL));
02945         }
02946         else if (*CommandID == SGCmd_Copy)          // Can't copy Guide layers
02947             State.Greyed = IsSelectedItemGuideLayer();
02948         else if (*CommandID == SGCmd_Show)          // Can't hide Guide layers
02949         {
02950             State.Greyed = IsSelectedItemGuideLayer();
02951             Layer * pLayer = pItem->GetDisplayedLayer();
02952             if (pLayer)
02953                 State.Ticked = !pLayer->IsHiddenFrame();
02954             else
02955                 State.Greyed = TRUE;
02956         }
02957 /* #ifndef STANDALONE
02958         else if (*CommandID == SGCmd_Properties)    // Shade when dlg is open
02959         {
02960             //State.Greyed = (LayerPropertyTabs::GetTabbedDlg() != NULL);
02961             LayerPropertyTabs * pTabHandler = LayerPropertyTabsDlg::GetLayerPropertiesTabs();
02962             if (pTabHandler)
02963                 State.Greyed = (pTabHandler->GetTabbedDlg() != NULL);
02964             else
02965                 State.Greyed = TRUE;    
02966         }
02967 #endif */
02968     }
02969 /* #if _DEBUG
02970     else if (*CommandID == SGCmd_Save)
02971     {
02972         // Just call the GetState function for the op directly
02973         return OpSaveAnimatedGIF::GetState(ShadeReason, NULL);
02974     }
02975 #endif */
02976     else if (*CommandID == SGCmd_Preview)
02977     {
02978         // Just call the GetState function for the op directly
02979         return OpGrabAllFrames::GetState(ShadeReason, NULL);
02980     }
02981     else if (*CommandID == SGCmd_FrameProps || *CommandID == SGCmd_Properties)
02982     {
02983         // Call the GetState function for the frame properties op.
02984         return OpFrameProperties::GetState(ShadeReason, NULL);      
02985     }
02986     else if (*CommandID == SGCmd_Delete)
02987     {
02988         // Call the GetState function for the frame delete op.
02989         return OpDeleteFrame::GetState(ShadeReason, NULL);  
02990     }
02991 
02992     // Don't call the base class 'cos we don't want any other commands
02993 
02994     return(State);
02995 }

BOOL FrameSGallery::GetNewDocBorn  )  [inline, protected]
 

Reimplemented from LayerSGallery.

Definition at line 313 of file sgframe.h.

00313 { return m_NewDocBorn; }

SGDisplayLayer * FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Returns:
A ptr to the selected layer gallery item. NULL if there is no selectet item

Reimplemented from LayerSGallery.

Definition at line 2494 of file sgframe.cpp.

02495 {
02496     SGDisplayFrame* pDispLayer = NULL;
02497 
02498     if (CheckVarsAreValid())
02499     {
02500         ERROR3IF(DisplayForeground == NULL,"Foreground group is NULL");
02501         if (DisplayForeground == NULL)
02502             return NULL;
02503 
02504         // Look in the foreground group first
02505         pDispLayer = ((SGDisplayFrame *) DisplayForeground->FindNextSelectedItem(NULL));
02506 
02507         ERROR3IF(pDispLayer == NULL,"Can't find the selected layer item in the layer gallery");
02508     }
02509 
02510     return(pDispLayer);
02511 }

BOOL FrameSGallery::InitMenuCommands void   )  [virtual]
 

Initialises any menu commands that this gallery needs.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 2808 of file sgframe.cpp.

02809 {
02810     static BOOL MenusInitialised = FALSE;
02811 
02812     BOOL ok = TRUE;
02813 
02814     if (!MenusInitialised)
02815     {
02816         // Initialise menu command Ops
02817         // "Special" entries for over-list menu
02818         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Copy,      _R(IDS_COPYFRAME));
02819         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Delete,    _R(IDS_DELETEFRAME));
02820         ok = ok && InitMenuCommand((StringBase *) &SGCmd_New,       _R(IDS_NEWFRAME));          // _R(IDS_SGMENU_NEW)
02821 //      ok = ok && InitMenuCommand((StringBase *) &SGCmd_Animation, _R(IDS_SGMENU_ANIMATION));
02822 //      ok = ok && InitMenuCommand((StringBase *) &SGCmd_Save,      _R(IDS_SGMENU_SAVE));
02823         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Preview,   _R(IDS_GRABFRAME));         // _R(IDS_SGMENU_PREVIEW));
02824 //      ok = ok && InitMenuCommand((StringBase *) &SGCmd_Browser,   _R(IDS_SGMENU_BROWSER));
02825         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Properties,_R(IDS_FRAMEPROPERTIES));   //_R(IDS_SGMENU_FRAMEPROPS));
02826 //      ok = ok && InitMenuCommand((StringBase *) &SGCmd_FrameProps,_R(IDS_SGMENU_FRAMEPROPS));
02827         ok = ok && InitMenuCommand((StringBase *) &SGCmd_Show,      _R(IDS_SGMENU_SHOWFRAME));
02828         MenusInitialised = TRUE;
02829     }
02830 
02831     return(ok);
02832 }

BOOL FrameSGallery::IsFrameMode 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 3342 of file sgframe.cpp.

03343 {
03344     ERROR3IF(pDoc == NULL,"pDoc == NULL");
03345 
03346     // flag to determine the document mode.
03347     BOOL FrameMode = FALSE;
03348 
03349     // Get a ptr to the selected spread
03350     Spread* pSpread = pDoc->GetSelectedSpread();
03351 
03352     // Ensure a valid spread ptr.
03353     if(pSpread)
03354     {
03355         // Are there any frame layers?
03356         Layer* pFrameLayer = pSpread->FindFirstFrameLayer();    
03357 
03358         //If a frame layer exists, then this is an animation doc.
03359         if (pFrameLayer)
03360             FrameMode = TRUE;
03361     }
03362 
03363     // return the document mode.
03364     return FrameMode;
03365 }

void FrameSGallery::MakeActiveLayer Layer pNewActiveLayer,
UndoableOperation pUndoOp = NULL
[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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Parameters:
pNewActiveLayer = ptr to the layer you want to be active [INPUTS] pUndoOp = if non null, the default, will do the change undoably
- [OUTPUTS]
Returns:
-
If the given new layer is already active, nothing happens

Note: pNewActiveLayer must be in the currect doc

Definition at line 1828 of file sgframe.cpp.

01829 {
01830     Spread* pSpread = pNewActiveLayer->FindParentSpread();
01831     ERROR3IF(pSpread == NULL,"Eh up, the layer has no parent spread");
01832     if (pSpread == NULL) return;
01833 
01834     Document *pDoc = pSpread->FindParentDocument();
01835     if (pDoc == NULL) return;
01836     
01837     {
01838         // Remove any other active layers, redrawing if necessary.
01839         Layer* pLayer = pSpread->FindFirstLayer();
01840         while (pLayer != NULL)
01841         {
01842             if (pLayer->IsActive() && pLayer != pNewActiveLayer)
01843             {
01844                 if (pUndoOp == NULL)
01845                     FrameSGallery::SetActive(pDoc,pLayer,FALSE);
01846                 else
01847                 {
01848                     // Make layer active undoably
01849                     OpLayerGalParam Param(LAYER_ACTIVE, pSpread);
01850                     Param.NewState = FALSE;
01851                     Param.pLayer = pLayer;
01852                     LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
01853                 }
01854             }
01855 
01856             pLayer = pLayer->FindNextLayer();
01857         }
01858     }
01859 
01860     // Go though the layers from the new active layer downwards and set
01861     // all previous layers non-visible and non-selected
01862     FixOtherLayersFromActive(pNewActiveLayer, pUndoOp);
01863 
01864     // Make sure the new layer is active, redrawing if necessary
01865 /*  if (!pNewActiveLayer->IsActive())
01866     {
01867         if (pUndoOp == NULL)
01868             FrameSGallery::SetActive(pDoc,pNewActiveLayer,TRUE);
01869         else
01870         {
01871             // Make layer active undoably
01872             OpLayerGalParam Param(LAYER_ACTIVE, pSpread);
01873             Param.NewState = TRUE;
01874             Param.pLayer = pNewActiveLayer;
01875             LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
01876         }
01877     } */
01878     if (pUndoOp == NULL)
01879     {
01880         if (!pNewActiveLayer->IsActive())
01881             FrameSGallery::SetActive(pDoc,pNewActiveLayer,TRUE);
01882     }
01883     else
01884     {
01885         // Make layer active undoably
01886         OpLayerGalParam Param(LAYER_ACTIVE, pSpread);
01887         Param.NewState = TRUE;
01888         Param.pLayer = pNewActiveLayer;
01889         LayerStateAction::Init(pUndoOp, pUndoOp->GetUndoActions(), Param);
01890     }
01891 
01892 #if defined(EXCLUDE_FROM_RALPH)
01893     //ERROR3("FrameSGallery::MakeActiveLayer supressed broadcast - bad !");
01894 #else
01895     BROADCAST_TO_ALL(LayerMsg(pNewActiveLayer,LayerMsg::LayerReason::ACTIVE_LAYER_CHANGED));
01896 #endif
01897 }

MsgResult FrameSGallery::Message Msg Message  )  [virtual]
 

A standard message handler, really.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 LayerSGallery.

Definition at line 1335 of file sgframe.cpp.

01336 {
01337     if (IS_OUR_DIALOG_MSG(Message))
01338     {
01339         DialogMsg* Msg = (DialogMsg*)Message;
01340 
01341         switch (Msg->DlgMsg)
01342         {
01343             case DIM_CREATE:
01344                 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYFRAMEGALLERY, TRUE);
01345                 break;
01346 
01347                 case DIM_CANCEL:
01348                 SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYFRAMEGALLERY, FALSE);
01349                 break;
01350         }
01351     }
01352 
01353     // If we have no displaytree, then we have not been shown, or something terrible has
01354     // happened, so we don't bother handling any of these messages.
01355     if (DisplayTree == NULL)
01356         return(SuperGallery::Message(Message));
01357 
01358 
01359     if (IS_OUR_DIALOG_MSG(Message))
01360     {
01361         DialogMsg* Msg = (DialogMsg*)Message;
01362         INT32 state;
01363 
01364         switch (Msg->DlgMsg)
01365         {
01366             case DIM_LFT_BN_CLICKED:
01367                 //TRACE( _T("Gadget %d clicked\n"),Msg->GadgetID);
01368                 switch(Msg->GadgetID)
01369                 {
01370                     case _R(IDC_BTN_MULTILAYER):
01371                         state = GetLongGadgetValue(_R(IDC_BTN_MULTILAYER),0,1);
01372                         DoChangeLayerState(NULL,FRAME_MULTILAYER,state);
01373                         break;
01374 
01375                     case _R(IDC_BTN_ALLVISIBLE):
01376                         state = GetLongGadgetValue(_R(IDC_BTN_ALLVISIBLE),0,1);
01377                         DoChangeLayerState(NULL,FRAME_ALLVISIBLE,state);
01378                         break;
01379 
01380                     case _R(IDC_GALLERY_UPONE):
01381                         DoMoveLayer(MOVELAYER_UPONE);
01382                         break;
01383 
01384                     case _R(IDC_GALLERY_DOWNONE):
01385                         DoMoveLayer(MOVELAYER_DOWNONE);
01386                         break;
01387 
01388                     case _R(IDC_GALLERY_NEW_NODLG):
01389                         DoCreateNewItem();
01390                         break;
01391 
01392                     case _R(IDC_GALLERY_COPY_NODLG):
01393                         DoCopyLayer();
01394                         break;
01395 
01396                     case _R(IDC_GALLERY_HELP):      // Show help page
01397                         HelpUserTopic(_R(IDS_HELPPATH_Gallery_Frame));
01398                         break;
01399 
01400 
01401 /*                  case _R(IDC_GALLERY_PROPERTIES):
01402                         // Handled by optoken
01403                         DoFrameProperties();
01404                         break; */
01405 
01406 /*                  case _R(IDC_BMPGAL_SAVE):
01407                         // Handled by optoken
01408                         DoSaveAnimation();
01409                         break; */
01410 
01411 /*                  case _R(IDC_BMPGAL_PREVIEW):
01412                         // Handled by optoken
01413                         DoPreviewAnimation();
01414                         break; */
01415 
01416 /*                  case _R(IDC_FRAME_ANIMATION):
01417                         // Handled by optoken
01418                         // Implement ****
01419                         break; */
01420                 }
01421                 break;
01422         }
01423     }
01424     else if (MESSAGE_IS_A(Message, OpMsg))
01425     {
01426         switch (((OpMsg*)Message)->MsgType)
01427         {
01428             case OpMsg::AFTER_UNDO:
01429             case OpMsg::AFTER_REDO:
01430                 EnsureSelSpreadSelectionIntegrity();
01431                 break;
01432         }
01433     }
01434     else if (MESSAGE_IS_A(Message, SpreadMsg))
01435     {
01436         SpreadMsg*  pSpreadMsg = (SpreadMsg*) Message;
01437 
01438         switch (pSpreadMsg->Reason)
01439         {
01440             case SpreadMsg::SELCHANGED:
01441                 NewSelectedSpread(pSpreadMsg->pNewSpread);  // gets selected doc too
01442                 if (pDoc != NULL && IsVisible())
01443                 {
01444                     TRACEUSER( "Neville", _T("frame SpreadMsg::SELCHANGED CreateNewSubtree\n"));
01445                     CreateNewSubtree(pDoc);
01446                     ForceRedrawOfList();
01447                 }
01448                 break;
01449 
01450 
01451             case SpreadMsg::LAYERCHANGES:
01452                 if (IsVisible())
01453                 {
01454                     if (pSpreadMsg->pNewSpread == pSpread)
01455                     {
01456                         if (pSpread->FindFirstLayer() != NULL)
01457                         {
01458                             EnsureActiveLayerIntegrity();
01459                             if (pDoc != NULL && IsVisible())
01460                             {
01461                                 TRACEUSER( "Neville", _T("frame SpreadMsg::LAYERCHANGES CreateNewSubtree\n"));
01462                                 CreateNewSubtree(pDoc);
01463                                 ForceRedrawOfList();
01464                             }
01465                         }
01466                     }
01467                 }
01468                 else
01469                 {
01470                     if (pSpreadMsg->pNewSpread->FindFirstLayer() != NULL)
01471                     {
01472                         pSpread = pSpreadMsg->pNewSpread;
01473                         EnsureActiveLayerIntegrity();
01474                     }
01475                 }
01476                 break;
01477         }
01478     }
01479     else if (MESSAGE_IS_A(Message, DocChangingMsg))
01480     {
01481         DocChangingMsg *Msg = (DocChangingMsg *) Message;
01482         switch (Msg->State)
01483         {
01484             case DocChangingMsg::DocState::TITLECHANGED:
01485             {
01486             // Showstopper removed, Jason, 28/3/96
01487             // When the doc title changes, we simply need to redraw to update the group titles.
01488             // Calling CreateNewSubtree will destroy the existing tree - this is really really bad
01489             // when the document title changed as a result of us (e.g.) locking a layer, because the
01490             // message broadcats hits us while we're still in the middle of traversing the tree,
01491             // we then delete the tree out from under ourselves, and are then in a highly dodgy state!
01492             // CreateNewSubtree(Msg->pChangingDoc);
01493                 ForceRedrawOfList();
01494                 break;
01495             }
01496 
01497             // This message is sent when a new or just opened document is stable.
01498             case DocChangingMsg::DocState::SELCHANGED:
01499             {
01500                 if (Msg->pNewDoc == NULL)
01501                 {
01502                     // No documents around any more, so we must wipe the display tree
01503                     // The base class will shade the gallery for us.
01504                     TRACEUSER( "Neville", _T("frame DocChangingMsg CreateNewSubtree\n"));
01505                     CreateNewSubtree(NULL);
01506                     ForceRedrawOfList();
01507                 }
01508                 else
01509                 {
01510             #ifdef WEBSTER
01511                     // There is an active document, so ensure the gallery is unshaded
01512                     ShadeGallery(FALSE);
01513             #else
01514                     //Do not process the message if it has been sent due to the creation of a new document.
01515                     if (!GetNewDocBorn())
01516                     {
01517                         // The document has changed, do we detect any non-frame layers? 
01518                         BOOL FrameMode = FALSE; 
01519                         
01520                         // Get a ptr to the document.
01521                         Document* pDoc = Msg->pNewDoc;
01522                                 
01523                         // Ensure a valid ptr.
01524                         if(pDoc)
01525                         {
01526                             // Determine the document mode.
01527                             FrameMode = IsFrameMode(pDoc);
01528 
01529                             // If we are no longer in Frame mode and the frame gallery is open,
01530                             // then close the frame gallery and open the layer gallery.
01531                             if( !FrameMode && IsVisible() )
01532                             {
01533                                 // Close the frame gallery.
01534                                 if(CloseFrameGallery())
01535                                 {
01536                                     // Open the the layer gallery.
01537                                     OpenLayerGallery();
01538                                 }
01539                             }
01540                         }
01541                     }
01542 
01543                     // If the gallery is visible, then ensure the gallery is unshaded.
01544                     if(IsVisible())     
01545                     {
01546                         // There is an active document, so ensure the gallery is unshaded
01547                         ShadeGallery(FALSE);
01548                     }
01549                     
01550             #endif
01551                 }
01552                 break;
01553             }
01554         #ifndef WEBSTER
01555             case DocChangingMsg::DocState::BORN:
01556             {
01557                 // When a new document is created, a SELCHANGED
01558                 // message is broadcasted, for Camelot2 frame/layer integration
01559                 // we do not wish to process the message. 
01560                 // We therefore set this flag to notify us when a new document
01561                 // is born.
01562 
01563                 // Ensure the frame gallery is open.
01564                 if( IsVisible() )
01565                 {       
01566                     // Set the flag to true.
01567                     // This is set to false in BORNANDSTABLE. 
01568                     SetNewDocBorn(TRUE);
01569                 }
01570                 break;
01571             }
01572 
01573             case DocChangingMsg::DocState::BORNANDSTABLE:
01574             {
01575                 // The document has changed, do we detect any non-frame layers? 
01576                 BOOL FrameMode = FALSE; 
01577                 BOOL GalleryClosed = FALSE;
01578 
01579                 // Get a ptr to the document.
01580                 Document* pChangingDoc = Msg->pChangingDoc;
01581                             
01582                 // Ensure a valid ptr.
01583                 if(pChangingDoc)
01584                 {
01585                     // Determine the document mode.
01586                     FrameMode = IsFrameMode(pChangingDoc);
01587 
01588                     // If we are no longer in Frame mode then
01589                     // close the frame gallery and open the layer gallery.
01590                     if( !FrameMode && IsVisible() )
01591                     {
01592                         // Close the frame gallery.
01593                         if(CloseFrameGallery())
01594                         {
01595                             // Open the Layer gallery.
01596                             OpenLayerGallery();
01597 
01598                             // Now we have processed this message, it is safe to process SELCHANGED messages.
01599                             SetNewDocBorn(FALSE);
01600                         }
01601                     }
01602                 }
01603                 break;
01604             }
01605 
01606             case DocChangingMsg::DocState::KILLED:
01607             case DocChangingMsg::DocState::ABOUTTODIE:
01608             {
01609                 // The doc. is about to die, therefore, set this falg to false.
01610                 SetNewDocBorn(FALSE);
01611             break;
01612             }
01613         #endif
01614         }
01615     }
01616     else if (MESSAGE_IS_A(Message, DocViewMsg))
01617     {
01618         DocViewMsg *Msg = (DocViewMsg *) Message;
01619         switch (Msg->State)
01620         {
01621         case DocViewMsg::DocViewState::SELABOUTTOCHANGE:
01622                 OldGuideLayerState = GetGuideLayerState(Msg->pNewDocView);
01623                 break;
01624 
01625             case DocViewMsg::DocViewState::SELCHANGED: 
01626             {
01627                 if (IsVisible())
01628                 {
01629                     NewGuideLayerState = GetGuideLayerState(Msg->pNewDocView);
01630                     if (OldGuideLayerState != NewGuideLayerState)
01631                     {
01632                         TRACEUSER( "Neville", _T("frame DocViewMsg::DocViewState::SELCHANGED CreateNewSubtree\n"));
01633                         CreateNewSubtree(Msg->pNewDocView->GetDoc());
01634                         ForceRedrawOfList();
01635                     }
01636                 }
01637             }
01638             break;
01639         }
01640     }
01641     else if (MESSAGE_IS_A(Message, LayerMsg))
01642     {
01643         LayerMsg *pMsg = (LayerMsg *) Message;
01644 
01645         switch ( pMsg->Reason )
01646         {
01647             // The active layer has changed.
01648             case LayerMsg::LayerReason::ACTIVE_LAYER_CHANGED:
01649             {
01650                 EnableGadget(_R(IDC_GALLERY_COPY),pMsg->pNewLayer != NULL && !pMsg->pNewLayer->IsGuide()); 
01651             
01652                 UpdateFrameRelatedButtons();
01653             }
01654             break;
01655             
01656             // The active layer has been changed externally to the gallery.
01657             case LayerMsg::LayerReason::UPDATE_ACTIVE_LAYER:
01658             {
01659                 // We must now check whether the selected layer has been changed externally
01660                 // to us. May happen if an animated GIF is being loaded onto layers
01661                 SGDisplayLayer *pDisplayItem = NULL;
01662                 if (DisplayForeground != NULL && IsVisible())
01663                     pDisplayItem = GetSelectedLayerGalItem();
01664                 if (pDisplayItem != NULL)
01665                 {
01666                     if (pMsg->pNewLayer != NULL && pDisplayItem->GetDisplayedLayer() != pMsg->pNewLayer)
01667                     {
01668                         Layer* pNewActiveLayer = pMsg->pNewLayer;
01669                         // Search for the new display item to match this new active layer 
01670                         SGDisplayLayer *pWantedDispLayer = NULL;
01671                         SGDisplayLayer *pDispLayer = ((SGDisplayLayer *) DisplayForeground->GetChild());
01672                         while (pDispLayer != NULL)                      
01673                         {
01674                             if (pDispLayer->GetDisplayedLayer() == pNewActiveLayer)
01675                                 pWantedDispLayer = pDispLayer;
01676                             pDispLayer = ((SGDisplayLayer *)pDispLayer->GetNext());
01677                         }
01678                         
01679                         // If we found the required display item then go and select it
01680                         if (pWantedDispLayer)
01681                         {
01682                             // Now update the selection states...
01683                             SelectItems(FALSE); // Deselect everything else
01684                             // Something has changed so we must go and select this new item
01685                             pWantedDispLayer->SetSelected(TRUE);
01686                         }
01687                     }
01688                 }
01689             }
01690             break;
01691             
01692             // The specified layer has been changed externally to the gallery.
01693             // So redraw the name.
01694             case LayerMsg::LayerReason::REDRAW_LAYER:
01695             {
01696                 TRACEUSER( "Neville", _T("frame LayerMsg::LayerReason::REDRAW_LAYER\n"));
01697                 Layer * pWantedLayer = pMsg->pNewLayer;
01698                 if (pWantedLayer != NULL && DisplayForeground != NULL && IsVisible())
01699                 {
01700                     // Search for the new display item to match this new active layer 
01701                     SGDisplayLayer *pWantedDispLayer = NULL;
01702                     SGDisplayLayer *pDispLayer = ((SGDisplayLayer *) DisplayForeground->GetChild());
01703                     while (pDispLayer != NULL)                      
01704                     {
01705                         if (pDispLayer->GetDisplayedLayer() == pWantedLayer)
01706                             pWantedDispLayer = pDispLayer;
01707                         pDispLayer = ((SGDisplayLayer *)pDispLayer->GetNext());
01708                     }
01709 
01710                     // If we found it then force a redraw
01711                     if (pWantedDispLayer)
01712                         pWantedDispLayer->ForceRedrawOfMyself();
01713                 }
01714             }
01715             break;
01716         }
01717     }
01718 
01719     return(SuperGallery::Message(Message));
01720 }    

BOOL FrameSGallery::OpenLayerGallery  )  [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 3313 of file sgframe.cpp.

03314 {
03315     // Find the OP. for the Layer gallery.
03316     OpDescriptor* OpDesc;
03317     OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_DISPLAYLAYERGALLERY);
03318 
03319     // Ensure we get a ptr to the OP.
03320     if(!OpDesc)
03321         return FALSE;
03322 
03323     // ok, now open the layergallery.
03324     OpDesc->Invoke();        
03325 
03326     // Lets go back.
03327     return TRUE;
03328 }

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

The FrameSGallery 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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Jason's Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
Returns:
TRUE if the Gallery initialised successfully FALSE if it should not be opened due to a failure to initialise

Reimplemented from LayerSGallery.

Definition at line 1228 of file sgframe.cpp.

01229 {
01230     Document *ParentDoc = Document::GetSelected();
01231     if (ParentDoc != NULL)
01232     {
01233         SetBoolGadgetSelected(_R(IDC_BTN_MULTILAYER),!(ParentDoc->IsMultilayer() == 0));
01234         SetBoolGadgetSelected(_R(IDC_BTN_ALLVISIBLE),!(ParentDoc->IsAllVisible() == 0));
01235     }
01236 
01237     EnableGadget(_R(IDC_GALLERY_COPY),ParentDoc != NULL && !IsSelectedItemGuideLayer());
01238 
01239     UpdateFrameRelatedButtons();
01240 
01241     return(TRUE);
01242 }

void FrameSGallery::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> (Based on Mark N's function in the Layer gallery code)
Date:
16/4/97 (Based on Jason's Layer gallery code)
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 from LayerSGallery.

Definition at line 1772 of file sgframe.cpp.

01773 {
01774     // This flag is TRUE if the selection on the layer should be cleared
01775     BOOL ClearSelection = FALSE;
01776 
01777     // get state before active change
01778     BOOL PrevVisibleState = pLayer->IsVisible();
01779     BOOL PrevLockedState  = pLayer->IsLocked();
01780 
01781     // Change active state
01782     pLayer->SetActive(state);
01783 
01784     // get state after active change
01785     BOOL PostVisibleState = pLayer->IsVisible();
01786     BOOL PostLockedState  = pLayer->IsLocked();
01787 
01788     if (PrevVisibleState != PostVisibleState)
01789     {
01790         // If the visible state has changed, redraw the layer
01791         FrameSGallery::ForceRedrawLayer(pDoc,pLayer);
01792 
01793         // If it has just become invisible, clear the selection
01794         ClearSelection = (ClearSelection || !PostVisibleState);
01795     }
01796 
01797     // if it has just become locked, clear the selection
01798     if (PrevLockedState != PostLockedState)
01799         ClearSelection = (ClearSelection || PostLockedState);
01800 
01801     // Clear the selection if needed
01802     if (ClearSelection)
01803         NodeRenderableInk::DeselectAllOnLayer(pLayer); 
01804 }

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

Reimplemented from LayerSGallery.

Definition at line 312 of file sgframe.h.

00312 { m_NewDocBorn = Val;  }

BOOL FrameSGallery::UpdateFrameRelatedButtons  )  [protected]
 

Ensures that they buttons on the gallery up to date in their greying/ungreying status.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/5/97
Parameters:
- [INPUTS]
Returns:
True if worked ok, False otherwise

Definition at line 3245 of file sgframe.cpp.

03246 {
03247     // This is no longer required for the present as we have hooked the buttons
03248     // into the real ops that we have.
03249 
03250 //  String_256 ShadeReason;
03251 //  OpState State;
03252     
03253 //  State = OpGrabAllFrames::GetState(&ShadeReason, NULL);
03254 //  EnableGadget(_R(IDC_BMPGAL_PREVIEW), !State.Greyed);
03255 
03256 //  State = OpFrameProperties::GetState(&ShadeReason, NULL);
03257 //  EnableGadget(_R(IDC_GALLERY_PROPERTIES), !State.Greyed);
03258 
03259     return TRUE;
03260 }


Member Data Documentation

BOOL FrameSGallery::m_NewDocBorn [protected]
 

Reimplemented from LayerSGallery.

Definition at line 325 of file sgframe.h.


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