コード例 #1
0
ファイル: HtmlDocument.cs プロジェクト: hifi/UltimaXNA
        unsafe private void DoRenderBlock(BlockElement root, uint *ptr, int width, int height)
        {
            foreach (AElement element in root.Children)
            {
                int x = element.Layout_X;
                int y = element.Layout_Y - Ascender; // ascender is always negative.
                if (element is CharacterElement)
                {
                    IFont      font      = element.Style.Font;
                    ICharacter character = font.GetCharacter((element as CharacterElement).Character);
                    // HREF links should be colored white, because we will hue them at runtime.
                    uint color = element.Style.IsHREF ? 0xFFFFFFFF : Utility.UintFromColor(element.Style.Color);
                    character.WriteToBuffer(ptr, x, y, width, height, font.Baseline,
                                            element.Style.IsBold, element.Style.IsItalic, element.Style.IsUnderlined, element.Style.MustDrawnOutline, color, 0xFF000008);
                    // offset y by ascender for links...
                    if (character.YOffset < 0)
                    {
                        y      += character.YOffset;
                        height -= character.YOffset;
                    }
                }
                else if (element is ImageElement)
                {
                    ImageElement image = (element as ImageElement);
                    image.AssociatedImage.Area = new Rectangle(x, y, image.Width, image.Height);
                    if (element.Style.IsHREF)
                    {
                        Links.AddLink(element.Style, new Rectangle(x, y, element.Width, element.Height));
                        image.AssociatedImage.LinkIndex = Links.Count;
                    }
                }
                else if (element is BlockElement)
                {
                    DoRenderBlock(element as BlockElement, ptr, width, height);
                }

                // set href link regions
                if (element.Style.IsHREF)
                {
                    Links.AddLink(element.Style, new Rectangle(x, y, element.Width, element.Height));
                }
            }
        }