/// <summary> /// Initialise the given window using PropertyInitialsers and component /// widgets specified for this WidgetLookFeel. /// </summary> /// <param name="widget"> /// Window based object to be initialised. /// </param> public void InitialiseWidget(Window widget) { // add new property definitions var pdc = new NamedDefinitionCollator <string, IPropertyDefinition>(); AppendPropertyDefinitions(pdc); foreach (var pdi in pdc) { // add the property to the window widget.AddProperty((Property)pdi); } // add required child widgets var wcc = new NamedDefinitionCollator <string, WidgetComponent>(); AppendChildWidgetComponents(wcc); foreach (var wci in wcc) { wci.Create(widget); } // add new property link definitions var pldc = new NamedDefinitionCollator <string, IPropertyDefinition>(); AppendPropertyLinkDefinitions(pldc); foreach (var pldi in pldc) { // add the property to the window widget.AddProperty((Property)pldi); } // apply properties to the parent window var pic = new NamedDefinitionCollator <string, PropertyInitialiser>(); AppendPropertyInitialisers(pic); foreach (var pi in pic) { pi.Apply(widget); } // setup linked events var eldc = new NamedDefinitionCollator <string, EventLinkDefinition>(); AppendEventLinkDefinitions(eldc); foreach (var eldi in eldc) { eldi.InitialiseWidget(widget); } // create animation instances var ans = new HashSet <string>(); AppendAnimationNames(ans); foreach (var ani in ans) { var instance = AnimationManager.GetSingleton().InstantiateAnimation(ani); d_animationInstances.Add(widget, instance); instance.SetTargetWindow(widget); } }
///// <summary> ///// return whether a NamedArea object with the specified name exists for ///// this WidgetLookFeel. ///// </summary> ///// <param name="name"> ///// String holding the name of the NamedArea to check for. ///// </param> ///// <returns> ///// - true if a named area with the requested name is defined for this ///// WidgetLookFeel. ///// - false if no such named area is defined for this WidgetLookFeel. ///// </returns> //public bool IsNamedAreaDefined(string name) //{ // if (d_namedAreas.ContainsKey(name)) // return true; // if (String.IsNullOrEmpty(d_inheritedLookName)) // return false; // return WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).IsNamedAreaDefined(name); //} /// <summary> /// Layout the child widgets defined for this WidgetLookFeel which are /// attached to the given window. /// </summary> /// <param name="owner"> /// Window object that has the child widgets that require laying out. /// </param> public void LayoutChildWidgets(Window owner) { var wcc = new NamedDefinitionCollator <string, WidgetComponent>(); AppendChildWidgetComponents(wcc); foreach (var wci in wcc) { wci.Layout(owner); } }
/// <summary> /// Clean up the given window from all properties and component widgets /// created by this WidgetLookFeel /// </summary> /// <param name="widget"> /// Window based object to be cleaned up. /// </param> public void CleanUpWidget(Window widget) { if (widget.GetLookNFeel() != GetName()) { throw new InvalidRequestException("The window '" + widget.GetNamePath() + "' does not have this WidgetLook assigned"); } // remove added child widgets var wcc = new NamedDefinitionCollator <string, WidgetComponent>(); AppendChildWidgetComponents(wcc); foreach (var wci in wcc) { wci.Cleanup(widget); } // delete added named Events var eldc = new NamedDefinitionCollator <string, EventLinkDefinition>(); AppendEventLinkDefinitions(eldc); foreach (var eldi in eldc) { eldi.CleanUpWidget(widget); } // remove added property definitions var pdc = new NamedDefinitionCollator <string, IPropertyDefinition>(); AppendPropertyDefinitions(pdc); foreach (var pdi in pdc) { // remove the property from the window widget.RemoveProperty(pdi.GetPropertyName()); } // remove added property link definitions var pldc = new NamedDefinitionCollator <string, IPropertyDefinition>(); AppendPropertyLinkDefinitions(pldc); foreach (var pldi in pldc) { // remove the property from the window widget.RemoveProperty(pldi.GetPropertyName()); } // TODO: clean up animation instances assoicated wit the window. //AnimationInstanceMap::iterator anim; //while ((anim = d_animationInstances.find(&widget)) != d_animationInstances.end()) //{ // AnimationManager::getSingleton().destroyAnimationInstance(anim->second); // d_animationInstances.erase(anim); //} }
private void AppendEventLinkDefinitions(NamedDefinitionCollator <string, EventLinkDefinition> col, bool inherits = true) { if (!String.IsNullOrEmpty(d_inheritedLookName) && inherits) { WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).AppendEventLinkDefinitions(col); } foreach (var i in d_eventLinkDefinitions) { col.Set(i.GetName(), i); } }
private void AppendPropertyInitialisers(NamedDefinitionCollator <string, PropertyInitialiser> col, bool inherits = true) { if (!String.IsNullOrEmpty(d_inheritedLookName) && inherits) { WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).AppendPropertyInitialisers(col); } foreach (var i in d_properties) { col.Set(i.GetTargetPropertyName(), i); } }
/// <summary> /// Takes the name for a widget component and returns a pointer to /// it if it exists or 0 if it does'nt. /// </summary> /// <param name="name"> /// The name of the Child component to look for. /// </param> /// <returns></returns> public WidgetComponent FindWidgetComponent(string name) { var wcc = new NamedDefinitionCollator <string, WidgetComponent>(); AppendChildWidgetComponents(wcc); return(wcc.SingleOrDefault(x => x.GetWidgetName() == name)); //WidgetComponentCollator::const_iterator wci = wcc.find(name); //if (wci == wcc.end()) // return 0; //return *wci; }
/// <summary> /// Takes the name of a property and returns a pointer to the last /// PropertyInitialiser for this property or 0 if the is no /// PropertyInitialiser for this property in the WidgetLookFeel /// </summary> /// <param name="propertyName"> /// The name of the property to look for. /// </param> /// <returns></returns> public PropertyInitialiser FindPropertyInitialiser(string propertyName) { var pic = new NamedDefinitionCollator <string, PropertyInitialiser>(); AppendPropertyInitialisers(pic); return(pic.SingleOrDefault(x => x.GetTargetPropertyName() == propertyName)); //PropertyInitialiserCollator::const_iterator i = pic.find(propertyName); //if (i == pic.end()) // return 0; //return *i; }