Exemplo n.º 1
0
 protected Style(Style s)
 {
     this.desc    = new FontDesc(s.desc);
     this.Margin  = new Box(s.Margin);
     this.Padding = new Box(s.Padding);
     this.Empty   = s.Empty;
     this.Pre     = s.Pre;
 }
Exemplo n.º 2
0
        public Stylesheet()
        {
            DefaultFont = new FontDesc("Times New Roman", 12, false, false, false);
            TagFont     = new FontDesc("Verdana", 9, false, false, false);

            DefaultPadding = new Box(0, 0, 0, 15);

            BindStyles(new NameTable());
        }
Exemplo n.º 3
0
        public void Cascade(FontDesc baseStyle)
        {
            if (this.Family == null || this.Family.Length == 0)
            {
                this.Family = baseStyle.Family;
            }
            if (this.Size == 0)
            {
                this.Size = baseStyle.Size;
            }

            this.bold.Cascade(baseStyle.bold);
            this.italic.Cascade(baseStyle.italic);
            this.underline.Cascade(baseStyle.underline);
        }
Exemplo n.º 4
0
        public void Bind(IGraphics gr, Stylesheet s)
        {
            stylesheet = s;
            FontDesc fd = desc;

            if (fd.Family == null)
            {
                fd = s.DefaultFont;
            }

            object fontHandle = gr.GetFontHandle(fd);

            gr.PushFont(fontHandle);
            fontAscent = gr.GetFontAscent();
            fontHeight = gr.GetFontHeight();
            gr.PopFont();
        }
Exemplo n.º 5
0
        public override bool Equals(object obj)
        {
            FontDesc other = obj as FontDesc;

            if (other == null)
            {
                return(false);
            }

            if (!(Size == other.Size && Bold.Equals(other.Bold) && Italic.Equals(other.Italic) &&
                  Underline.Equals(other.Underline)))
            {
                return(false);
            }

            return(Family == null ? other.Family == null : Family.Equals(other.Family));
        }
Exemplo n.º 6
0
 private Font CreateFont(FontDesc fd)
 {
     Font f=new Font(fd.Family, fd.Size, fd.Style);
     fontHandles[fd]=f;
     return f;
 }
Exemplo n.º 7
0
        public object GetFontHandle(FontDesc fd)
        {
            object ret=fontHandles[fd];
            if ( ret == null )
                ret=CreateFont(fd);

            return ret;
        }
Exemplo n.º 8
0
        public Stylesheet()
        {
            DefaultFont=new FontDesc("Times New Roman", 12, false, false, false);
            TagFont=new FontDesc("Verdana", 9, false, false, false);

            DefaultPadding=new Box(0, 0, 0, 15);

            BindStyles(new NameTable());
        }
Exemplo n.º 9
0
 protected Style(Style s)
 {
     this.desc=new FontDesc(s.desc);
     this.Margin=new Box(s.Margin);
     this.Padding=new Box(s.Padding);
     this.Empty=s.Empty;
     this.Pre=s.Pre;
 }
Exemplo n.º 10
0
        public void Cascade(FontDesc baseStyle)
        {
            if ( this.Family == null || this.Family.Length == 0 )
                this.Family=baseStyle.Family;
            if ( this.Size == 0 )
                this.Size=baseStyle.Size;

            this.bold.Cascade(baseStyle.bold);
            this.italic.Cascade(baseStyle.italic);
            this.underline.Cascade(baseStyle.underline);
        }
Exemplo n.º 11
0
 public FontDesc(FontDesc o)
     : this(o.Family, o.Size, o.bold, o.italic, o.underline)
 {
 }
Exemplo n.º 12
0
 public void Cascade(Style baseStyle)
 {
     Padding.Cascade(baseStyle.Padding);
     Margin.Cascade(baseStyle.Margin);
     FontDesc.Cascade(baseStyle.FontDesc);
 }
Exemplo n.º 13
0
 public FontDesc(FontDesc o) : this(o.Family, o.Size, o.bold, o.italic, o.underline)
 {
 }
Exemplo n.º 14
0
            public object GetFontHandle(FontDesc fd)
            {
                Win32Util.LOGFONT lf=new Win32Util.LOGFONT();
                lf.lfFaceName=fd.Family;
                lf.lfHeight=fd.Size;
                lf.lfItalic=(byte) (fd.Style & FontStyle.Italic);
                if ( (fd.Style & FontStyle.Bold) == FontStyle.Bold )
                    lf.lfWeight=700;
                lf.lfItalic=(byte) (fd.Style & FontStyle.Underline);

                return Win32Util.CreateFont(lf);
            }
Exemplo n.º 15
0
            private static void Recurse(int depth, IGraphics gr, Rectangle rc)
            {
                object o;
                FontDesc fd;
                fd=new FontDesc("Arial", 10, false, false, false);
                o=gr.GetFontHandle(fd);
                gr.PushFont(o);
                gr.MeasureText("my name is alfie");
                gr.DrawText(rc, 20, "hello", Color.Black, Color.White, -1, -1);

                fd=new FontDesc("Times New Roman", 10, false, false, false);
                o=gr.GetFontHandle(fd);
                gr.PushFont(o);
                gr.MeasureText("my name is alfie");

                fd=new FontDesc("Arial", 10, false, false, false);
                o=gr.GetFontHandle(fd);
                gr.PushFont(o);
                gr.MeasureText("my name is alfie");

                if ( depth < 100 )
                    Recurse(depth+1, gr, rc);

                gr.PopFont();
                gr.PopFont();
            }