Ejemplo n.º 1
0
        public HtmlLink AddLink(StyleState style, Rectangle area)
        {
            HtmlLink matched = null;
            foreach (HtmlLink link in m_Links)
            {
                if (link.Style.HREF == style.HREF && link.Area.Right == area.Left)
                {
                    bool overlap = link.Area.Top < area.Bottom && area.Top < link.Area.Bottom;
                    if (overlap)
                    {
                        matched = link;
                        matched.Area.Width = matched.Area.Width + area.Width;
                        if (matched.Area.Y > area.Y)
                            matched.Area.Y = area.Y;
                        if (matched.Area.Bottom < area.Bottom)
                            matched.Area.Height += (area.Bottom - matched.Area.Bottom);
                        break;
                    }
                }
            }

            if (matched == null)
            {
                m_Links.Add(new HtmlLink(m_Links.Count, style));
                matched = m_Links[m_Links.Count - 1];
                matched.Area = area;
            }
            return matched;
        }
Ejemplo n.º 2
0
 public HtmlLink(int i, StyleState style)
 {
     Area = new Rectangle();
     Index = i;
     HREF = style.HREF;
     Style = style;
 }
Ejemplo n.º 3
0
 public InternalLineBreakElement(StyleState style) : base(style, '\n')
 {
 }
Ejemplo n.º 4
0
 public StyleStateIndex(StyleState styleState)
 {
     this.styleState = styleState;
     this.elements   = new LightList <UIElement>();
 }
Ejemplo n.º 5
0
 public PairType()
 {
     _key = StyleState.Normal;
 }
Ejemplo n.º 6
0
 public bool IsInState(StyleState state)
 {
     return((currentState & state) != 0);
 }
Ejemplo n.º 7
0
 public PairType()
 {
     _key = StyleState.Normal;
 }
Ejemplo n.º 8
0
 public ImageElement(StyleState style, ImageTypes imageType = ImageTypes.UI)
     : base(style)
 {
     ImageType = imageType;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Resolves all the styles in the specified <see cref="Feature"/>.
 /// </summary>
 /// <param name="feature">
 /// The <c>Feature</c> to search for styles.
 /// </param>
 /// <param name="file">
 /// The <see cref="KmlFile"/> the feature belongs to.
 /// </param>
 /// <param name="state">
 /// The <see cref="StyleState"/> of the styles to look for.
 /// </param>
 /// <returns>
 /// A new <see cref="Style"/> that has been resolved.
 /// </returns>
 /// <exception cref="ArgumentNullException">feature/file is null.</exception>
 public static Style CreateResolvedStyle(Feature feature, KmlFile file, StyleState state)
 {
     return CreateResolvedStyle(feature, file, state, null);
 }
Ejemplo n.º 10
0
        private Image GetFilterImageEx(StyleState state, bool inFilter)
        {
            int n = (int)state;

            if (inFilter == true)
                n += ImageCacheSize;

            Image cacheImage = _FilterCacheImages[n];

            if (cacheImage == null)
            {
                Image image = new Bitmap(8, 8);

                using (Graphics g = Graphics.FromImage(image))
                {
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    using (GraphicsPath path = new GraphicsPath())
                    {
                        Point[] pts =
                        {
                            new Point(0, 0),
                            new Point(7, 0),
                            new Point(7, 1),
                            new Point(4, 4),
                            new Point(4, 7),
                            new Point(3, 6),
                            new Point(3, 4),
                            new Point(0, 1),
                            new Point(0, 0),
                        };

                        path.AddLines(pts);

                        Rectangle r = new Rectangle(1, 1, 6, 3);

                        ColumnHeaderRowVisualStyle style = GetEffectiveRowHeaderStyleEx(state);

                        Color color = style.FilterBorderColor;

                        if (color.IsEmpty)
                            color = Color.DimGray;

                        if (inFilter == false)
                            style = GetEffectiveRowHeaderStyleEx(state & ~StyleState.MouseOver);

                        Background back = (style.FilterBackground != null && style.FilterBackground.IsEmpty == false)
                            ? style.FilterBackground : new Background(Color.White);

                        using (Brush br = back.GetBrush(r))
                            g.FillPath(br, path);

                        using (Pen pen = new Pen(color))
                            g.DrawPath(pen, path);
                    }
                }

                _FilterCacheImages[n] = image;

                cacheImage = image;
            }

            return (cacheImage);
        }
Ejemplo n.º 11
0
 //style number is used to prioritize shared styles, higher numbers are less important
 public StyleEntry(UIStyleGroup sourceGroup, UIStyleRunCommand styleRunCommand, StyleType type, StyleState state, int styleNumber, int attributeCount)
 {
     this.sourceGroup     = sourceGroup;
     this.styleRunCommand = styleRunCommand;
     this.type            = type;
     this.state           = state;
     this.priority        = (int)BitUtil.SetBytes(styleNumber, attributeCount, (int)type, (int)state);
 }
Ejemplo n.º 12
0
            GetEffectiveRowHeaderStyleEx(StyleState rowState)
        {
            ValidateRowHeaderStyle();

            switch (rowState)
            {
                case StyleState.MouseOver:
                    return (GetRowHeaderStyle(StyleType.MouseOver));

                case StyleState.Selected:
                    return (GetRowHeaderStyle(StyleType.Selected));

                case StyleState.Selected | StyleState.MouseOver:
                    return (GetRowHeaderStyle(StyleType.SelectedMouseOver));

                case StyleState.ReadOnly:
                    return (GetRowHeaderStyle(StyleType.ReadOnly));

                case StyleState.ReadOnly | StyleState.MouseOver:
                    return (GetRowHeaderStyle(StyleType.ReadOnlyMouseOver));

                case StyleState.ReadOnly | StyleState.Selected:
                    return (GetRowHeaderStyle(StyleType.ReadOnlySelected));

                case StyleState.ReadOnly | StyleState.MouseOver | StyleState.Selected:
                    return (GetRowHeaderStyle(StyleType.ReadOnlySelectedMouseOver));

                default:
                    return (GetRowHeaderStyle(StyleType.Default));
            }
        }
Ejemplo n.º 13
0
        internal Image GetFilterImage(
            GridColumn column, StyleState state, bool inFilter)
        {
            if (_FilterImage != null)
                return (_FilterImage);

            if (_FilterImageIndex >= 0)
            {
                ImageList imageList = GridPanel.ImageList;

                if (imageList != null && _FilterImageIndex < imageList.Images.Count)
                    return (imageList.Images[_FilterImageIndex]);
            }

            return (GetFilterImageEx(state, inFilter));
        }
Ejemplo n.º 14
0
            GetEffectiveStyle(GridColumn column, StyleState cellState)
        {
            StyleType type;

            switch (cellState)
            {
                case StyleState.MouseOver:
                    type = StyleType.MouseOver;
                    break;

                case StyleState.Selected:
                    type = StyleType.Selected;
                    break;

                case StyleState.Selected | StyleState.MouseOver:
                    type = StyleType.SelectedMouseOver;
                    break;

                case StyleState.ReadOnly:
                    type = StyleType.ReadOnly;
                    break;

                case StyleState.ReadOnly | StyleState.MouseOver:
                    type = StyleType.ReadOnlyMouseOver;
                    break;

                case StyleState.ReadOnly | StyleState.Selected:
                    type = StyleType.ReadOnlySelected;
                    break;

                case StyleState.ReadOnly | StyleState.MouseOver | StyleState.Selected:
                    type = StyleType.ReadOnlySelectedMouseOver;
                    break;

                default:
                    type = StyleType.Default;
                    break;
           }

            return (column.GetHeaderStyle(type));
        }
Ejemplo n.º 15
0
            GetEffectiveStyle(GridColumn column, StyleState cellState)
        {
            ValidateStyle(column);

            switch (cellState)
            {
                case StyleState.MouseOver:
                    return (GetStyle(column, StyleType.MouseOver));

                case StyleState.Selected:
                    return (GetStyle(column, StyleType.Selected));

                case StyleState.Selected | StyleState.MouseOver:
                    return (GetStyle(column, StyleType.SelectedMouseOver));

                case StyleState.ReadOnly:
                    return (GetStyle(column, StyleType.ReadOnly));

                case StyleState.ReadOnly | StyleState.MouseOver:
                    return (GetStyle(column, StyleType.ReadOnlyMouseOver));

                case StyleState.ReadOnly | StyleState.Selected:
                    return (GetStyle(column, StyleType.ReadOnlySelected));

                case StyleState.ReadOnly | StyleState.MouseOver | StyleState.Selected:
                    return (GetStyle(column, StyleType.ReadOnlySelectedMouseOver));

                default:
                    return (GetStyle(column, StyleType.Default));
            }
        }
Ejemplo n.º 16
0
        internal GroupHeaderVisualStyle GetEffectiveStyle(StyleState state)
        {
            ValidateStyle();

            switch (state)
            {
                case StyleState.MouseOver:
                    return (GetStyle(StyleType.MouseOver));

                case StyleState.Selected:
                    return (GetStyle(StyleType.Selected));

                case StyleState.Selected | StyleState.MouseOver:
                    return (GetStyle(StyleType.SelectedMouseOver));

                case StyleState.ReadOnly:
                    return (GetStyle(StyleType.ReadOnly));

                case StyleState.ReadOnly | StyleState.MouseOver:
                    return (GetStyle(StyleType.ReadOnlyMouseOver));

                case StyleState.ReadOnly | StyleState.Selected:
                    return (GetStyle(StyleType.ReadOnlySelected));

                case StyleState.ReadOnly | StyleState.MouseOver | StyleState.Selected:
                    return (GetStyle(StyleType.ReadOnlySelectedMouseOver));

                default:
                    return (GetStyle(StyleType.Default));
            }
        }
Ejemplo n.º 17
0
        // ======================================================================
        // Old code
        // ======================================================================

        private void DoLayoutOld(AElement root, int maxwidth, out int width, out int height, out int ascender)
        {
            // default values for out variables.
            width    = 0;
            height   = 0;
            ascender = 0;

            // local variables
            int  descenderHeight = 0;
            int  lineHeight      = 0;
            int  styleWidth      = 0;        // italic + outlined characters need more room for the slant/outline.
            int  widestLine      = maxwidth; // we automatically set the content to fill the specified width.
            int  wordWidth       = 0;
            bool firstLine       = true;

            List <AElement> word     = new List <AElement>();
            List <AElement> elements = null;

            for (int i = 0; i < elements.Count; i++)
            {
                wordWidth  += elements[i].Width;
                styleWidth -= elements[i].Width;
                if (styleWidth < 0)
                {
                    styleWidth = 0;
                }

                if (lineHeight < elements[i].Height)
                {
                    lineHeight = elements[i].Height;
                }

                if (elements[i].IsThisAtomALineBreak)
                {
                    if (width + styleWidth > widestLine)
                    {
                        widestLine = width + styleWidth;
                    }
                    height         += lineHeight;
                    descenderHeight = 0;
                    lineHeight      = 0;
                    width           = 0;
                    firstLine       = false;
                }
                else
                {
                    word.Add(elements[i]);

                    // we may need to add additional width for special style characters.
                    if (elements[i] is CharacterElement)
                    {
                        CharacterElement atom = (CharacterElement)elements[i];
                        IFont            font = atom.Style.Font;
                        ICharacter       ch   = font.GetCharacter(atom.Character);

                        // italic characters need a little extra width if they are at the end of the line.
                        if (atom.Style.IsItalic)
                        {
                            styleWidth = font.Height / 2;
                        }
                        if (atom.Style.MustDrawnOutline)
                        {
                            styleWidth += 2;
                        }
                        if (ch.YOffset + ch.Height - lineHeight > descenderHeight)
                        {
                            descenderHeight = ch.YOffset + ch.Height - lineHeight;
                        }
                        if (ch.YOffset < 0 && firstLine && ascender > ch.YOffset)
                        {
                            ascender = ch.YOffset;
                        }
                    }

                    if (i == elements.Count - 1 || elements[i + 1].CanBreakAtThisAtom)
                    {
                        // Now make sure this line can fit the word.
                        if (width + wordWidth + styleWidth <= maxwidth)
                        {
                            // it can fit!
                            width    += wordWidth + styleWidth;
                            wordWidth = 0;
                            word.Clear();
                            // if this word is followed by a space, does it fit? If not, drop it entirely and insert \n after the word.
                            if (!(i == elements.Count - 1) && elements[i + 1].IsThisAtomABreakingSpace)
                            {
                                int charwidth = elements[i + 1].Width;
                                if (width + charwidth <= maxwidth)
                                {
                                    // we can fit an extra space here.
                                    width += charwidth;
                                    i++;
                                }
                                else
                                {
                                    // can't fit an extra space on the end of the line. replace the space with a \n.
                                    ((CharacterElement)elements[i + 1]).Character = '\n';
                                }
                            }
                        }
                        else
                        {
                            // this word cannot fit in the current line.
                            if ((width > 0) && (i - word.Count >= 0))
                            {
                                // if this is the last word in a line. Replace the last space character with a line break
                                // and back up to the beginning of this word.
                                if (elements[i - word.Count].IsThisAtomABreakingSpace)
                                {
                                    ((CharacterElement)elements[i - word.Count]).Character = '\n';
                                    i = i - word.Count - 1;
                                }
                                else
                                {
                                    StyleState inheritedStyle = elements[i - word.Count].Style;
                                    elements.Insert(i - word.Count, new CharacterElement(inheritedStyle, '\n'));
                                    i = i - word.Count;
                                }
                                word.Clear();
                                wordWidth = 0;
                            }
                            else
                            {
                                // this is the only word on the line and we will need to split it.
                                // first back up until we've reached the reduced the size of the word
                                // so that it fits on one line, and split it there.
                                int iWordWidth = wordWidth;
                                for (int j = word.Count - 1; j >= 1; j--)
                                {
                                    int iDashWidth = word[j].Style.Font.GetCharacter('-').Width;
                                    if (iWordWidth + iDashWidth <= maxwidth)
                                    {
                                        StyleState inheritedStyle = elements[i - (word.Count - j) + 1].Style;
                                        elements.Insert(i - (word.Count - j) + 1, new CharacterElement(inheritedStyle, '\n'));
                                        elements.Insert(i - (word.Count - j) + 1, new CharacterElement(inheritedStyle, '-'));
                                        break;
                                    }
                                    iWordWidth -= word[j].Width;
                                }
                                i -= word.Count + 2;
                                word.Clear();
                                width     = 0;
                                wordWidth = 0;
                                if (i < 0)
                                {
                                    // the texture size is too small to hold this small number of characters. This is a problem.
                                    i = -1;
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            width  += styleWidth;
            height += lineHeight + descenderHeight;
            if (widestLine > width)
            {
                width = widestLine;
            }
        }
Ejemplo n.º 18
0
 public PropertyModifyData(string modifiedElementStyleName, StyleState modifiedStyleState, SerializableTexture2D addedTexture)
     : this(modifiedElementStyleName, modifiedStyleState, default, default, default, addedTexture)
 {
 }
Ejemplo n.º 19
0
 internal UIStyleSetStateProxy(UIStyleSet styleSet, StyleState state)
 {
     this.m_StyleSet = styleSet;
     this.state      = state;
 }
Ejemplo n.º 20
0
 public BlockElement(string tag, StyleState style)
     : base(style)
 {
     Tag = tag;
 }
Ejemplo n.º 21
0
 public CharacterAtom(StyleState style, char c)
     : base(style)
 {
     Character = c;
 }
 public InternalHyphenBreakElement(StyleState style)
     : base(style, '-')
 {
 }
Ejemplo n.º 23
0
        private void CreateStyleEntry(LightList <StylePropertyId> toUpdate, UIStyleGroup group, UIStyleRunCommand styleRunCommand, StyleType styleType, StyleState styleState, int ruleCount)
        {
            if (styleRunCommand.style == null)
            {
                return;
            }

            containedStates |= styleState;

            if ((currentState & styleState) != 0)
            {
                AddMissingProperties(toUpdate, styleRunCommand.style);
                RunCommands(styleRunCommand.runCommands);
            }

            availableStyles.Add(new StyleEntry(group, styleRunCommand, styleType, styleState, availableStyles.Count, ruleCount));
        }
Ejemplo n.º 24
0
        private RowVisualStyle GetRowStateStyle(GridContainer item, StyleState rowState)
        {
            ValidateRowStyle();

            switch (rowState)
            {
                case StyleState.MouseOver:
                    return (GetRowStyle(item, StyleType.MouseOver));

                case StyleState.Selected:
                    return (GetRowStyle(item, StyleType.Selected));

                case StyleState.Selected | StyleState.MouseOver:
                    return (GetRowStyle(item, StyleType.SelectedMouseOver));

                case StyleState.ReadOnly:
                    return (GetRowStyle(item, StyleType.ReadOnly));

                case StyleState.ReadOnly | StyleState.MouseOver:
                    return (GetRowStyle(item, StyleType.ReadOnlyMouseOver));

                case StyleState.ReadOnly | StyleState.Selected:
                    return (GetRowStyle(item, StyleType.ReadOnlySelected));

                case StyleState.ReadOnly | StyleState.MouseOver | StyleState.Selected:
                    return (GetRowStyle(item, StyleType.ReadOnlySelectedMouseOver));

                default:
                    return (GetRowStyle(item, StyleType.Default));
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Creates a new atom.
 /// </summary>
 /// <param name="openTags">This atom will copy the styles from this parameter.</param>
 public AElement(StyleState style)
 {
     Style = new StyleState(style);
 }
Ejemplo n.º 26
0
 public CharacterElement(StyleState style, char c)
     : base(style)
 {
     Character = c;
 }
Ejemplo n.º 27
0
 internal RowVisualStyle GetEffectiveRowStyle(
     GridContainer item, StyleState rowState)
 {
     return (GetRowStateStyle(item, rowState));
 }
Ejemplo n.º 28
0
 public ImageAtom(StyleState style)
     : base(style)
 {
 }