コード例 #1
0
ファイル: Scheme.cs プロジェクト: xdinos/SDL2Experiments
        /// <summary>
        /// Register all factory aliases required by the scheme.
        /// </summary>
        public void LoadFactoryAliases()
        {
            var wfmgr = WindowFactoryManager.GetSingleton();

            // check aliases
            foreach (var alias in d_aliasMappings)
            {
                // get iterator
                var iter = wfmgr.getAliasIterator();


                //// look for this alias
                //while (!iter.isAtEnd() && (iter.getCurrentKey() != (*alias).aliasName))
                //    ++iter;

                //// if the alias exists
                //if (!iter.isAtEnd())
                //{
                //    // if the current target type matches
                //    if (iter.getCurrentValue().getActiveTarget() == alias.targetName)
                //    {
                //        // assume this mapping is ours and skip to next alias
                //        continue;
                //    }
                //}

                // create a new alias entry
                wfmgr.AddWindowTypeAlias(alias.aliasName, alias.targetName);
            }
        }
コード例 #2
0
ファイル: Scheme.cs プロジェクト: xdinos/SDL2Experiments
        /// <summary>
        /// Create all falagard mappings required by the scheme.
        /// </summary>
        public void LoadFalagardMappings()
        {
            var wfmgr = WindowFactoryManager.GetSingleton();

            // check falagard window mappings.
            foreach (var falagard in d_falagardMappings)
            {
                // get iterator
                var iter = wfmgr.getFalagardMappingIterator();

                // look for this mapping
                var kvp = iter.SingleOrDefault(x => x.Key == falagard.windowName);
                if (!kvp.Equals(default(KeyValuePair <string, WindowFactoryManager.FalagardWindowMapping>)))
                {
                    // check if the current target and looks and window renderer match
                    if ((kvp.Value.d_baseType == falagard.targetName) &&
                        (kvp.Value.d_rendererType == falagard.rendererName) &&
                        (kvp.Value.d_lookName == falagard.lookName))
                    {
                        // assume this mapping is ours and skip to next
                        continue;
                    }
                }
                //// look for this mapping
                //while (!iter.isAtEnd() && (iter.getCurrentKey() != falagard.windowName))
                //    ++iter;

                //// if the mapping exists
                //if (!iter.isAtEnd())
                //{
                //    // check if the current target and looks and window renderer match
                //    if ((iter.getCurrentValue().d_baseType == falagard.targetName) &&
                //        (iter.getCurrentValue().d_rendererType == falagard.rendererName) &&
                //        (iter.getCurrentValue().d_lookName == falagard.lookName))
                //    {
                //        // assume this mapping is ours and skip to next
                //        continue;
                //    }
                //}

                // create a new mapping entry
                wfmgr.AddFalagardWindowMapping(falagard.windowName,
                                               falagard.targetName,
                                               falagard.lookName,
                                               falagard.rendererName,
                                               falagard.effectName);
            }
        }
コード例 #3
0
ファイル: System.cs プロジェクト: xdinos/SDL2Experiments
        /// <summary>
        /// adds factories for all the basic window types
        ///
        /// You do not need to call this manually! Standard Window factories will be
        /// added automatically. One occasion when you will need this is if you
        /// remove all window factories from WindowFactoryManager and want to add the
        /// standard ones back
        /// </summary>
        public void AddStandardWindowFactories()
        {
            WindowFactoryManager.AddWindowType <DefaultWindow>();
            WindowFactoryManager.AddWindowType <DragContainer>();
            WindowFactoryManager.AddWindowType <ScrolledContainer>();
            WindowFactoryManager.AddWindowType <ClippedContainer>(); // TODO: to be removed
            WindowFactoryManager.AddWindowType <PushButton>();
            WindowFactoryManager.AddWindowType <RadioButton>();
            WindowFactoryManager.AddWindowType <Combobox>();
            WindowFactoryManager.AddWindowType <ComboDropList>();
            //WindowFactoryManager.AddWindowType<ComboboxV2>(); // TODO: to be removed
            //WindowFactoryManager.AddWindowType<ComboDropListV2>(); // TODO: to be removed
            WindowFactoryManager.AddWindowType <Editbox>();
            WindowFactoryManager.AddWindowType <FrameWindow>();
            WindowFactoryManager.AddWindowType <ItemEntry>();
            WindowFactoryManager.AddWindowType <Listbox>(); // TODO: to be removed
            WindowFactoryManager.AddWindowType <ListHeader>();
            WindowFactoryManager.AddWindowType <ListHeaderSegment>();
            WindowFactoryManager.AddWindowType <ListWidget>();
            WindowFactoryManager.AddWindowType <Menubar>();
            WindowFactoryManager.AddWindowType <PopupMenu>();
            WindowFactoryManager.AddWindowType <MenuItem>();
            WindowFactoryManager.AddWindowType <MultiColumnList>();
            WindowFactoryManager.AddWindowType <MultiLineEditbox>();
            WindowFactoryManager.AddWindowType <ProgressBar>();
            WindowFactoryManager.AddWindowType <ScrollablePane>();
            WindowFactoryManager.AddWindowType <Scrollbar>();
            WindowFactoryManager.AddWindowType <Slider>();
            WindowFactoryManager.AddWindowType <Spinner>();
            WindowFactoryManager.AddWindowType <TabButton>();
            WindowFactoryManager.AddWindowType <TabControl>();
            WindowFactoryManager.AddWindowType <Thumb>();
            WindowFactoryManager.AddWindowType <Titlebar>();
            WindowFactoryManager.AddWindowType <ToggleButton>();
            WindowFactoryManager.AddWindowType <Tooltip>();
            WindowFactoryManager.AddWindowType <ItemListbox>();
            // TODO: WindowFactoryManager.AddWindowType<GroupBox>();
            WindowFactoryManager.AddWindowType <Tree>(); // TODO: to be removed
            // TODO: WindowFactoryManager.AddWindowType<TreeWidget>();
            WindowFactoryManager.AddWindowType <HorizontalLayoutContainer>();
            WindowFactoryManager.AddWindowType <VerticalLayoutContainer>();
            WindowFactoryManager.AddWindowType <GridLayoutContainer>();

            WindowFactoryManager.AddWindowType <ListView>();
            WindowFactoryManager.AddWindowType <TreeView>();
        }
コード例 #4
0
        /// <summary>
        /// Permanently destroys any windows placed in the dead pool.
        /// </summary>
        /// <remarks>
        /// It is probably not a good idea to call this from a Window based event handler
        /// if the specific window has been or is being destroyed.
        /// </remarks>
        public void CleanDeadPool()
        {
            var wfm = WindowFactoryManager.GetSingleton();

            foreach (var curr in Enumerable.Reverse(d_deathrow))
            {
#if DEBUG
                // in debug mode, log what gets cleaned from the dead pool (insane level)
                Logger.LogInsane("Window '" + curr.GetName() + "' about to be finally destroyed from dead pool.");
#endif
                wfm.GetFactory(curr.GetWidgetType())
                .DestroyWindow(curr);
            }

            // all done here, so clear all pointers from dead pool
            d_deathrow.Clear();
        }
コード例 #5
0
        /*!
         * \brief
         *  Destructor for WindowManager objects
         *
         *  This will properly destry all remaining Window objects.  Note that WindowFactory objects will not
         *  be destroyed (since they are owned by whoever created them).
         */
        // TODO: ~WindowManager(void);


        /*************************************************************************
        *   Window Related Methods
        *************************************************************************/
        /*!
         * \brief
         *
         *
         * \param type
         * \param name
         *
         *
         * \return
         * \exception  InvalidRequestException WindowManager is locked and no Windows may be created.
         * \exception	UnknownObjectException
         * \exception	GenericException
         */
        /// <summary>
        /// Creates a new Window object of the specified type, and gives it the specified unique name.
        /// </summary>
        /// <param name="type">
        /// String that describes the type of Window to be created.
        /// A valid WindowFactory for the specified type must be registered.
        /// </param>
        /// <param name="name">
        /// String that holds the name that is to be given to the new window.
        /// If \a name is empty, a name will be generated for the window.
        /// </param>
        /// <returns>
        /// Pointer to the newly created Window object.
        /// </returns>
        /// <exception cref="InvalidRequestException">
        /// WindowManager is locked and no Windows may be created.
        /// </exception>
        /// <exception cref="UnknownObjectException">
        /// No WindowFactory is registered for \a type Window objects.
        /// </exception>
        /// <exception cref="Exception">
        /// Some other error occurred (Exception message has details).
        /// </exception>
        public Window CreateWindow(string type, string name = "")
        {
            // only allow creation of Window objects if we are in unlocked state
            if (IsLocked())
            {
                throw new InvalidRequestException("WindowManager is in the locked state.");
            }

            var finalName = String.IsNullOrEmpty(name) ? GenerateUniqueWindowName() : name;

            var wfMgr   = WindowFactoryManager.GetSingleton();
            var factory = wfMgr.GetFactory(type);

            var newWindow = factory.CreateWindow(finalName);

            System.GetSingleton().Logger
            .LogEvent(
                "Window '" + finalName + "' of type '" + type + "' has been created. " +
                newWindow.GetHashCode().ToString("X8"), LoggingLevel.Informative);

            // see if we need to assign a look to this window
            if (wfMgr.IsFalagardMappedType(type))
            {
                var fwm = wfMgr.GetFalagardMappingForType(type);
                // this was a mapped type, so assign a look to the window so it can finalise
                // its initialisation
                newWindow.d_falagardType = type;
                newWindow.SetWindowRenderer(fwm.d_rendererType);
                newWindow.SetLookNFeel(fwm.d_lookName);

                InitialiseRenderEffect(newWindow, fwm.d_effectName);
            }

            d_windowRegistry.Add(newWindow);

            // fire event to notify interested parites about the new window.
            var args    = new WindowEventArgs(newWindow);
            var handler = WindowCreated;

            if (handler != null)
            {
                handler(this, args);
            }

            return(newWindow);
        }
コード例 #6
0
ファイル: System.cs プロジェクト: xdinos/SDL2Experiments
        /// <summary>
        /// Destructor for System objects.
        /// </summary>
        // TODO: ~System();

        #region Implementation of IDisposable

        public void Dispose()
        {
            Logger.LogEvent("---- Begining CEGUI System destruction ----");

            //// execute shut-down script
            //if (!d_termScriptName.empty())
            //{
            //    CEGUI_TRY
            //    {
            //        executeScriptFile(d_termScriptName);
            //    }
            //    CEGUI_CATCH (...) {}  // catch all exceptions and continue system shutdown

            //}

            CleanupImageCodec();

            // cleanup XML stuff
            CleanupXmlParser();

            //
            // perform cleanup in correct sequence
            //
            // ensure no windows get created during destruction.  NB: I'm allowing the
            // potential exception to escape here so as to make it obvious that client
            // code should really be adjusted to not create windows during cleanup.
            WindowManager.GetSingleton().Lock();
            // destroy windows so it's safe to destroy factories
            WindowManager.GetSingleton().DestroyAllWindows();
            WindowManager.GetSingleton().CleanDeadPool();

            // remove factories so it's safe to unload GUI modules
            WindowFactoryManager.GetSingleton().RemoveAllFactories();

            //// Cleanup script module bindings
            //if (d_scriptModule)
            //    d_scriptModule->destroyBindings();

            // cleanup singletons
            DestroySingletons();

            // delete all the GUIContexts
            foreach (var i in d_guiContexts)
            {
                i.Dispose();
            }

            // TODO: cleanup resource provider if we own it
            //if (d_ourResourceProvider)
            //    CEGUI_DELETE_AO d_resourceProvider;

            Logger.LogEvent("CEGUI::System singleton destroyed. " + this.GetHashCode().ToString("X8"));

            Logger.LogEvent("---- CEGUI System destruction completed ----");

            //#if CEGUI_HAS_DEFAULT_LOGGER
            // delete the Logger object only if we created it.
            if (d_ourLogger)
            {
                Logger.Instance.Dispose();
            }
            //#endif

            //CEGUI_DELETE_AO d_clipboard;
            d_clipboard = null;
        }