Esempio n. 1
0
        //=========================================================================================
        /// <summary> 
        /// Removes the given widget from the gui.
        /// </summary>
        /// 
        /// <param name="obj"> Widget to remove</param>
        //=========================================================================================
        public void Remove( GuiWidget obj )
        {
            // Do nothing if objet is null:

            if ( obj == null ) return;

            // Do nothing if the object has no ID or is not in the gui:

            if ( obj.Id == 0 || obj.ParentContainer != this || obj.ParentGui != this.m_gui ) return;

            // See if object exists in gui:

            if ( m_objects.ContainsKey( obj.Id ) )
            {
                // If the gui data is locked then just add to the list of pending gui data changes:

                if ( m_lock_count != 0 )
                {
                    // Add this change to the list:

                    m_pending_changes.AddLast
                    (
                        new PendingGuiChange
                        (
                            obj                                     ,
                            PendingGuiChangeType.REMOVE_OBJECT    ,
                            obj.Name
                        )
                    );

                    // Abort: do not actually add the object into the list - we will do this later on Unlock()

                    return;
                }

                // Cleanup after the object:

                obj.OnDelete();

                // Unregister object name and type:

                UnregisterName(obj,obj.Name); UnregisterType(obj);

                // Remove widget from the master dictionary:

                m_objects.Remove( obj.Id );

                // Add this id to the list of free ids

                m_free_ids.AddLast(obj.Id);

                // Clear all the object's scene related variables

                obj.Id              = 0;
                obj.ParentGui       = null;
                obj.ParentContainer = null;
            }
        }