示例#1
0
        public HeaderFooterNode(bool isHeader
                                , double pageWidth
                                , FontInfo font
                                , PrintLineType lineType
                                , PrintFieldType leftField
                                , PrintFieldType centerField
                                , PrintFieldType rightField
                                , SongData song)
        {
            _isHeader  = isHeader;
            _song      = song;
            _pageWidth = pageWidth;

            _fields[0] = GetTextNode(leftField, font);
            _fields[1] = GetTextNode(centerField, font);
            _fields[2] = GetTextNode(rightField, font);

            if (lineType != PrintLineType.None)
            {
                _lineNode = new LineNode(_pageWidth, 0, 0, lineType);
            }
        }
示例#2
0
        public override TextExtents GetExtents(Cairo.Context cr)
        {
            if (!_extentsDetermined)
            {
                _extentsDetermined = true;

                _chordExtents = _chordLine.GetHorizontalExtents(cr);
                _extents      = _children.GetHorizontalExtents(cr);

                // Check to see if we need to add a word connecting line.
                if (_children.Count > 0 && _extents.Width < _chordExtents.Width)
                {
                    TextNode textNode = (TextNode)_children[0];
                    if (textNode != null && _breaksWord)
                    {
                        _children.Add(new SpacerNode(textNode.Font, 1));
                        double len = _chordExtents.Width - _extents.Width - 2;
                        if (len > 0)
                        {
                            LineNode lineNode = new LineNode(len, _extents.Height, _extents.YAdvance, PrintLineType.Single);

                            _children.Add(lineNode);

                            _extents = _children.GetHorizontalExtents(cr);
                        }
                    }
                }

                _totalExtents          = new TextExtents();
                _totalExtents.Width    = Math.Max(_chordExtents.Width, _extents.Width);
                _totalExtents.Height   = _chordExtents.Height + _chordExtents.YAdvance + _extents.Height;
                _totalExtents.YAdvance = _extents.YAdvance;
            }

            return(_totalExtents);
        }