#include <layermgr.h>
Inheritance diagram for LayerManager:
Public Member Functions | |
LayerManager () | |
LayerManager Constructor, initially the LayerManager has no CurrentSpread. | |
~LayerManager () | |
LayerManager destructor. | |
String_256 | CreateUniqueLayerID () |
Used to generate a LayerID which is unique for the current spread. The name generated is normally of the form "Layer n", where n is the number of layers in the LyrDetList + 1. If "Layer n" already exists on the current spread then "Layer m" is generated where m is the smallest integer greater than n such that the id is unique. | |
BOOL | CommitLayerChanges () |
If the layer details have changed then performs a LayerChangeOp which modifies the Camelot tree to reflect the changes made to the LyrDetList. | |
BOOL | NewCurrentSpread (Spread *NewCurrentSpread) |
Sets a new current spread. | |
Spread * | GetCurrentSpread () |
For finding the current spread. | |
BOOL | CancelLayerChanges () |
This private function gets called from NewCurrentSpread. It informs all subsystems (that need to know) that the Current Spread has changed. The LyrDetList contains the new current spread's details before this function is called. Causes the changes made to the LyrDetList to be discarded, and new values read. | |
BOOL | RefreshLayerDetails () |
Reads in new layer details and updates the interface. | |
void | UpdateInterface () |
Updates the interface after layers have changed. | |
Public Attributes | |
List | LyrDetList |
Private Member Functions | |
void | DeleteLayerDetList () |
Deletes the contents of the LyrDetList. | |
BOOL | ReadSpreadLayerDetails () |
Read the current spread's layer details into the LyrDetList. If memory runs out then InformError is called and FALSE is returned. | |
void | BroadcastNewCurrentSpread () |
BOOL | LayerDetailsChanged () |
This function compares the current spread's layers against the Layer details list. If the layers have changed in any way, then the function returns TRUE. Otherwise the function returns FALSE. | |
Private Attributes | |
Spread * | CurrentSpread |
Definition at line 177 of file layermgr.h.
|
LayerManager Constructor, initially the LayerManager has no CurrentSpread.
Definition at line 170 of file layermgr.cpp. 00171 { 00172 CurrentSpread = NULL; // There is no current spread 00173 }
|
|
LayerManager destructor.
Definition at line 190 of file layermgr.cpp. 00191 { 00192 DeleteLayerDetList(); // Delete the layer details list 00193 }
|
|
|
|
This private function gets called from NewCurrentSpread. It informs all subsystems (that need to know) that the Current Spread has changed. The LyrDetList contains the new current spread's details before this function is called. Causes the changes made to the LyrDetList to be discarded, and new values read.
Definition at line 443 of file layermgr.cpp. 00444 { 00445 DeleteLayerDetList(); // Delete details including any changes whioch may have been made 00446 if (ReadSpreadLayerDetails()) // Read new values 00447 { 00448 return TRUE; 00449 } 00450 else 00451 { 00452 return FALSE; 00453 } 00454 }
|
|
If the layer details have changed then performs a LayerChangeOp which modifies the Camelot tree to reflect the changes made to the LyrDetList.
Definition at line 290 of file layermgr.cpp. 00291 { 00292 if (LayerDetailsChanged()) // The layer details have changed so we need to perform 00293 // a LayerChangeOp to commit the changes. 00294 { 00295 // Invoke the layer change operation 00296 // Obtain a pointer to the op descriptor for the Layer change operation 00297 OpDescriptor* OpDesc = 00298 OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpLayerChange)); 00299 // Invoke the operation. 00300 OpDesc->Invoke(); 00301 } 00302 if (RefreshLayerDetails()) // We need to refresh the layer details even if the layers were 00303 // not changed because a new layer could have been deleted 00304 { 00305 return TRUE; 00306 } 00307 else return FALSE; // Failed to refresh layer details (InformError has been called) 00308 }
|
|
Used to generate a LayerID which is unique for the current spread. The name generated is normally of the form "Layer n", where n is the number of layers in the LyrDetList + 1. If "Layer n" already exists on the current spread then "Layer m" is generated where m is the smallest integer greater than n such that the id is unique.
Definition at line 214 of file layermgr.cpp. 00215 { 00216 // We can't generate a unique id if there is no current spread 00217 ENSURE(CurrentSpread != NULL, "There is no current spread"); 00218 00219 String_256 UniqueLayerID; 00220 INT32 NumLayers = 0; 00221 00222 ListItem* Lyr = LyrDetList.GetHead(); 00223 00224 // Calculate how many layers are on the current spread, we must ignore layers 00225 // which have been deleted. 00226 while (Lyr != NULL) 00227 { 00228 if (!((LyrDetails*)Lyr)->Deleted) // Don't count deleted layers 00229 { 00230 NumLayers++; 00231 } 00232 Lyr = LyrDetList.GetNext(Lyr); 00233 } 00234 00235 ENSURE(NumLayers != 0, "The current spread has no layers"); 00236 00237 00238 INT32 NewLayerNum = NumLayers+1; 00239 00240 BOOL Unique; // Flag used to indicate if the id generated is unique or not 00241 do 00242 { 00243 // Construct a first attempt at a unique layer id 'Layer n' 00244 // where n = the number of layers on the current spread + 1 00245 00246 UniqueLayerID.MakeMsg(_R(IDS_LAYERMGR_LAYERNAME),NewLayerNum); 00247 00248 // Check that UniqueLayerID is indeed unique 00249 Unique = TRUE; // Until we know better 00250 Lyr = LyrDetList.GetHead(); 00251 while (Lyr != NULL) 00252 { 00253 if (!((LyrDetails*)Lyr)->Deleted) // Ignore deleted layers 00254 { 00255 if (UniqueLayerID == ((LyrDetails*)Lyr)->Status.StringLayerID) 00256 { 00257 Unique = FALSE; 00258 00259 // UniqueLayerID is not unique so increment NewLayerNum and try again 00260 NewLayerNum++; 00261 break; 00262 } 00263 } 00264 Lyr = LyrDetList.GetNext(Lyr); // Get the next layer 00265 } 00266 00267 } while (!Unique); 00268 return(UniqueLayerID); 00269 }
|
|
Deletes the contents of the LyrDetList.
Definition at line 500 of file layermgr.cpp. 00501 { 00502 // Delete all current spread details 00503 ListItem* Current = LyrDetList.GetHead(); 00504 while (Current != NULL) 00505 { 00506 delete (LyrDetList.RemoveItem(Current)); 00507 Current = LyrDetList.GetHead(); 00508 } 00509 }
|
|
For finding the current spread.
Definition at line 367 of file layermgr.cpp. 00368 { 00369 return CurrentSpread; 00370 }
|
|
This function compares the current spread's layers against the Layer details list. If the layers have changed in any way, then the function returns TRUE. Otherwise the function returns FALSE.
Definition at line 580 of file layermgr.cpp. 00581 { 00582 LyrDetails* CurrentLyrDet = (LyrDetails*)LyrDetList.GetHead(); 00583 Layer* CurrentLyr = CurrentSpread->FindFirstLayer(); // Get the first layer node 00584 00585 ENSURE(CurrentLyrDet != NULL, "There are no layer details on the layer details list"); 00586 ENSURE(CurrentLyr != NULL, "The LayerManager's current spread has no layers"); 00587 00588 while (CurrentLyrDet != NULL) 00589 { 00590 // We ignore deleted new layers because they don't change anything 00591 if (!(CurrentLyrDet->New && CurrentLyrDet->Deleted)) 00592 { 00593 if (CurrentLyr != CurrentLyrDet->m_pLayer) // z-order change 00594 { 00595 return TRUE; 00596 } 00597 else if ((CurrentLyrDet->New) || (CurrentLyrDet->Deleted)) 00598 { 00599 return TRUE; // New layer created or existing layer deleted 00600 } 00601 else if (!(CurrentLyrDet->Status == CurrentLyr->GetLayerStatus())) 00602 { 00603 // The layer's status has changed 00604 return TRUE; 00605 } 00606 CurrentLyrDet = (LyrDetails*)(LyrDetList.GetNext(CurrentLyrDet)); 00607 CurrentLyr = (CurrentLyr->FindNextLayer()); 00608 } 00609 else 00610 CurrentLyrDet = (LyrDetails*)(LyrDetList.GetNext(CurrentLyrDet)); 00611 } 00612 // Sanity check 00613 ENSURE (CurrentLyr == NULL, "CurrentLyr ptr should be NULL"); 00614 return FALSE; // Nothing has changed 00615 }
|
|
Sets a new current spread.
Definition at line 326 of file layermgr.cpp. 00327 { 00328 ENSURE(NewCurrentSpread != NULL, "The new current spread is NULL"); 00329 BOOL ok = TRUE; 00330 00331 if (CurrentSpread != NULL) // There is already a current spread 00332 { 00333 00334 // The LayerDetList should never be empty 00335 ENSURE(!LyrDetList.IsEmpty(), "Empty Layer details list"); 00336 00337 DeleteLayerDetList(); 00338 00339 } 00340 00341 // The LayerDetList should be empty 00342 ENSURE(LyrDetList.IsEmpty(), "Empty Layer details list"); 00343 00344 CurrentSpread = NewCurrentSpread; 00345 00346 // Read the current spread's layer details into the LyrDetList 00347 ok = ReadSpreadLayerDetails(); 00348 00349 return (ok); 00350 }
|
|
Read the current spread's layer details into the LyrDetList. If memory runs out then InformError is called and FALSE is returned.
Definition at line 530 of file layermgr.cpp. 00531 { 00532 ENSURE(CurrentSpread != NULL, "Trying to read the details of a NULL current spread"); 00533 ENSURE(LyrDetList.IsEmpty(), "Layer details list not empty"); 00534 00535 LyrDetails* LayerDet; 00536 00537 Layer* Current = CurrentSpread->FindFirstLayer(); 00538 while (Current != NULL) 00539 { 00540 // Found a layer so record the details 00541 LayerDet = new LyrDetails(); 00542 if (LayerDet == NULL) 00543 { 00544 // Inform an error - The error will already be set by new 00545 InformError(); 00546 return FALSE; 00547 } 00548 LayerDet->Status = (Current)->GetLayerStatus(); // record the layer status 00549 LayerDet->m_pLayer = Current; 00550 LayerDet->New = FALSE; 00551 LayerDet->Deleted = FALSE; 00552 00553 LyrDetList.AddTail(LayerDet); // Add the layers details to the tail of the layer 00554 // detail list, so preserving the correct z-order. 00555 Current = Current->FindNextLayer(); 00556 } 00557 ENSURE(!LyrDetList.IsEmpty(), "No layers found on the current spread"); 00558 return TRUE; 00559 }
|
|
Reads in new layer details and updates the interface.
Definition at line 471 of file layermgr.cpp. 00472 { 00473 // Make sure that no changes have been made 00474 DeleteLayerDetList(); // Delete details including any changes whioch may have been made 00475 if (ReadSpreadLayerDetails()) // Read new values 00476 { 00477 UpdateInterface(); 00478 return TRUE; 00479 } 00480 else return FALSE; // InformError has been called 00481 }
|
|
Updates the interface after layers have changed.
Definition at line 387 of file layermgr.cpp.
|
|
Definition at line 209 of file layermgr.h. |
|
Definition at line 206 of file layermgr.h. |