/// <summary>
        /// Render the section specified by this SectionSpecification.
        /// </summary>
        /// <param name="srcWindow">
        /// Window object to be used when calculating pixel values from BaseDim values.
        /// </param>
        /// <param name="baseRect">
        /// Rect object to be used when calculating pixel values from BaseDim values.
        /// </param>
        /// <param name="modcols"></param>
        /// <param name="clipper"></param>
        /// <param name="clipToDisplay"></param>
        public void Render(Window srcWindow, Rectf baseRect, ColourRect modcols = null, Rectf? clipper = null, bool clipToDisplay = false)
        {
            // see if we need to bother rendering
            if (!ShouldBeDrawn(srcWindow))
                return;

            try
            {
                // get the imagery section object with the name we're set up to use
                var sect = WidgetLookManager.GetSingleton().GetWidgetLook(d_owner).GetImagerySection(d_sectionName);

                // decide what colours are to be used
                var finalColours = new ColourRect();
                InitColourRectForOverride(srcWindow, ref finalColours);
                finalColours.ModulateAlpha(srcWindow.GetEffectiveAlpha());

                if (modcols != null)
                    finalColours *= modcols;

                // render the imagery section
                sect.Render(srcWindow, baseRect, finalColours, clipper, clipToDisplay);
            }
            catch (Exception)
            {
                // do nothing here, errors are non-faltal and are logged for debugging purposes.
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Return a Rectd describing the absolute pixel area represented by this
        /// ComponentArea.
        /// </summary>
        /// <param name="wnd">
        /// Window object to be used when calculating final pixel area.
        /// </param>
        /// <param name="container">
        /// Rect object to be used as a base or container when converting relative
        /// dimensions.
        /// </param>
        /// <returns>
        /// Rectf object describing the pixels area represented by this
        /// ComponentArea when using \a wnd and \a container as a reference for
        /// calculating the final pixel dimensions.
        /// </returns>
        public Rectf GetPixelRect(Window wnd, Rectf container)
        {
            var pixelRect = new Rectf();

            // use a property?
            if (IsAreaFetchedFromProperty())
            {
                pixelRect = CoordConverter.AsAbsolute(wnd.GetProperty <URect>(_namedSource), wnd.GetPixelSize());
            }
            else if (IsAreaFetchedFromNamedArea())
            {
                return(WidgetLookManager.GetSingleton()
                       .GetWidgetLook(_namedAreaSourceLook)
                       .GetNamedArea(_namedSource)
                       .GetArea()
                       .GetPixelRect(wnd, container));
            }
            else
            {
                // not via property or named area- calculate using Dimensions

                // sanity check, we mus be able to form a Rect from what we represent.
                global::System.Diagnostics.Debug.Assert(d_left.GetDimensionType() == DimensionType.LeftEdge ||
                                                        d_left.GetDimensionType() == DimensionType.XPosition);
                global::System.Diagnostics.Debug.Assert(d_top.GetDimensionType() == DimensionType.TopEdge ||
                                                        d_top.GetDimensionType() == DimensionType.YPosition);
                global::System.Diagnostics.Debug.Assert(d_right_or_width.GetDimensionType() == DimensionType.RightEdge ||
                                                        d_right_or_width.GetDimensionType() == DimensionType.Width);
                global::System.Diagnostics.Debug.Assert(d_bottom_or_height.GetDimensionType() == DimensionType.BottomEdge ||
                                                        d_bottom_or_height.GetDimensionType() == DimensionType.Height);


                pixelRect.Left = d_left.GetBaseDimension().GetValue(wnd, container) + container.Left;
                pixelRect.Top  = d_top.GetBaseDimension().GetValue(wnd, container) + container.Top;

                if (d_right_or_width.GetDimensionType() == DimensionType.Width)
                {
                    pixelRect.Width = d_right_or_width.GetBaseDimension().GetValue(wnd, container);
                }
                else
                {
                    pixelRect.Right = d_right_or_width.GetBaseDimension().GetValue(wnd, container) + container.Left;
                }

                if (d_bottom_or_height.GetDimensionType() == DimensionType.Height)
                {
                    pixelRect.Height = d_bottom_or_height.GetBaseDimension().GetValue(wnd, container);
                }
                else
                {
                    pixelRect.Bottom = d_bottom_or_height.GetBaseDimension().GetValue(wnd, container) + container.Top;
                }
            }

            return(pixelRect);
        }
Esempio n. 3
0
        private void AppendAnimationNames(ISet <string> set, bool inherits = true)
        {
            foreach (var animation in d_animations)
            {
                set.Add(animation);
            }

            if (!String.IsNullOrEmpty(d_inheritedLookName) && inherits)
            {
                WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).AppendAnimationNames(set);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Load all xml looknfeel files required by the scheme.
        /// </summary>
        public void LoadLookNFeels()
        {
            var wlfMgr = WidgetLookManager.GetSingleton();

            // load look'n'feels
            // (we can't actually check these, at the moment, so we just re-parse data;
            // it does no harm except maybe waste a bit of time)
            foreach (var element in d_looknfeels)
            {
                wlfMgr.ParseLookNFeelSpecificationFromFile(element.filename, element.resourceGroup);
            }
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Return the NamedArea with the specified name.
        /// </summary>
        /// <param name="name">
        /// String object holding the name of the NamedArea to be returned.
        /// </param>
        /// <returns>
        /// The requested NamedArea object.
        /// </returns>
        public NamedArea GetNamedArea(string name)
        {
            if (d_namedAreas.ContainsKey(name))
            {
                return(d_namedAreas[name]);
            }

            if (String.IsNullOrEmpty(d_inheritedLookName))
            {
                throw new UnknownObjectException("unknown named area: '" + name + "' in look '" + d_lookName + "'.");
            }

            return(WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).GetNamedArea(name));
        }
Esempio n. 8
0
        // TODO: ...
        //WidgetLookFeel(const WidgetLookFeel& other);
        //WidgetLookFeel& operator=(const WidgetLookFeel& other);

        // TODO: virtual ~WidgetLookFeel();

        /// <summary>
        /// Return a const reference to the StateImagery object for the specified
        /// state.
        /// </summary>
        /// <param name="state"></param>
        /// <returns>
        /// StateImagery object for the requested state.
        /// </returns>
        public StateImagery GetStateImagery(string state)
        {
            if (d_stateImagery.ContainsKey(state))
            {
                return(d_stateImagery[state]);
            }

            if (String.IsNullOrEmpty(d_inheritedLookName))
            {
                throw new UnknownObjectException("unknown state '" + state + "' in look '" + d_lookName + "'.");
            }

            return(WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).GetStateImagery(state));
        }
Esempio n. 9
0
        /// <summary>
        /// Return a const reference to the ImagerySection object with the
        /// specified name.
        /// </summary>
        /// <param name="section">
        /// ImagerySection object with the specified name.
        /// </param>
        /// <returns></returns>
        public ImagerySection GetImagerySection(string section)
        {
            if (d_imagerySections.ContainsKey(section))
            {
                return(d_imagerySections[section]);
            }


            if (String.IsNullOrEmpty(d_inheritedLookName))
            {
                throw new UnknownObjectException("unknown imagery section '" + section + "' in look '" + d_lookName +
                                                 "'.");
            }

            return(WidgetLookManager.GetSingleton().GetWidgetLook(d_inheritedLookName).GetImagerySection(section));
        }
Esempio n. 10
0
        /// <summary>
        /// Returns if a NamedArea with the given name is present in this look.
        /// </summary>
        /// <param name="name">
        /// The name of the NamedArea to look for.
        /// </param>
        /// <param name="includeInheritedLook">
        /// If set to true, this function will try to also include elements from the inherited WidgetLookFeel.
        /// </param>
        /// <returns>
        /// - true, if the element with the given name is present,
        /// - false, if no such element is present.
        /// </returns>
        public bool IsNamedAreaPresent(string name, bool includeInheritedLook = true)
        {
            if (d_namedAreas.ContainsKey(name))
            {
                return(true);
            }

            if (String.IsNullOrEmpty(d_inheritedLookName) || !includeInheritedLook)
            {
                return(false);
            }

            return(WidgetLookManager.GetSingleton()
                   .GetWidgetLook(d_inheritedLookName)
                   .IsNamedAreaPresent(name, true));
        }
Esempio n. 11
0
        /// <summary>
        /// Returns if a WidgetComponent with the given name is present in this look.
        /// </summary>
        /// <param name="name">
        /// The name of the WidgetComponent to look for.
        /// </param>
        /// <param name="includeInheritedLook">
        /// If set to true, this function will try to also include elements from the inherited WidgetLookFeel.
        /// </param>
        /// <returns>
        /// - true, if the element with the given name is present,
        /// - false, if no such element is present.
        /// </returns>
        public bool IsWidgetComponentPresent(string name, bool includeInheritedLook = true)
        {
            throw new NotImplementedException();
            //WidgetComponentMap::const_iterator widgetComponentIter = d_widgetComponentMap.find(name);
            //if (widgetComponentIter != d_widgetComponentMap.end())
            //    return true;

            //if (d_namedAreas.ContainsKey(name))
            //    return true;

            if (String.IsNullOrEmpty(d_inheritedLookName) || !includeInheritedLook)
            {
                return(false);
            }

            return(WidgetLookManager.GetSingleton()
                   .GetWidgetLook(d_inheritedLookName)
                   .IsWidgetComponentPresent(name, true));
        }
Esempio n. 12
0
        /// <summary>
        /// perform any processing required due to the given font having changed.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="font"></param>
        /// <returns></returns>
        public bool HandleFontRenderSizeChange(Window window, Font font)
        {
            var result = false;

            foreach (var i in d_imagerySections)
            {
                result |= i.Value.HandleFontRenderSizeChange(window, font);
            }

            foreach (var i in d_childWidgets)
            {
                result |= i.HandleFontRenderSizeChange(window, font);
            }

            if (!String.IsNullOrEmpty(d_inheritedLookName))
            {
                result |= WidgetLookManager.GetSingleton().
                          GetWidgetLook(d_inheritedLookName).
                          HandleFontRenderSizeChange(window, font);
            }

            return(result);
        }
Esempio n. 13
0
        /// <summary>
        /// perform any processing required due to the given font having changed.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="font"></param>
        /// <returns></returns>
        public bool HandleFontRenderSizeChange(Window window, Font font)
        {
            if (IsAreaFetchedFromProperty())
            {
                return(false);
            }

            if (IsAreaFetchedFromNamedArea())
            {
                return(WidgetLookManager.GetSingleton()
                       .GetWidgetLook(_namedAreaSourceLook)
                       .GetNamedArea(_namedSource)
                       .HandleFontRenderSizeChange(window, font));
            }

            var result = d_left.HandleFontRenderSizeChange(window, font);

            result |= d_top.HandleFontRenderSizeChange(window, font);
            result |= d_right_or_width.HandleFontRenderSizeChange(window, font);
            result |= d_bottom_or_height.HandleFontRenderSizeChange(window, font);

            return(result);
        }
Esempio n. 14
0
 /// <summary>
 /// Get the Look'N'Feel assigned to our window
 /// </summary>
 /// <returns></returns>
 public WidgetLookFeel GetLookNFeel()
 {
     return(WidgetLookManager.GetSingleton().GetWidgetLook(Window.GetLookNFeel()));
 }