Example #1
0
 public TextSegment(int Start, int End, FontInfo FontInfo)
 {
     this.Start    = Start;
     this.End      = End;
     this.FontInfo = FontInfo;
 }
Example #2
0
        public QTextBox(Font Font, StringComparer Comparer)
        {
            InitializeComponent(); // NOP

            this.SuspendLayout();

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "QTextBox";

            this.DoubleBuffered = true;
            this.BackColor      = Color.White;

            FontInfo.SetFont(Font);

            ki = new KeywordInfo(comparer = Comparer);
            SubLine.SetKeywordInfo(ki);
            Line.SetKeywordInfo(ki);

            currentView = new View(new Document(4), this);
            curDoc      = currentView.Document;

            EventManager.ViewChanged += () =>
            {
                vsb.SetValue(currentView.FirstVisibleLine);
                this.Invalidate();
            };

            EventManager.DocumentChanged += () => { if (DocumentChanged != null)
                                                    {
                                                        DocumentChanged.Invoke(this, EventArgs.Empty);
                                                    }
            };
            EventManager.CaretLocationChanged += () => { if (CaretLocationChanged != null)
                                                         {
                                                             CaretLocationChanged.Invoke(currentView.CaretDocLoc);
                                                         }
            };
            EventManager.SelectionChanged += () => { if (SelectionChanged != null)
                                                     {
                                                         SelectionChanged.Invoke(this, EventArgs.Empty);
                                                     }
            };
            EventManager.NumLinesChanged    += updateMaxLinesChanged;
            EventManager.LongestLineChanged += updateForLongestLine;

            vsb = new QVScrollBar(SCROLL_BAR_WIDTH);
            this.Controls.Add(vsb);

            vsb.ValChanged += (e) =>
            {
                switch (e.Delta)
                {
                case -1:
                    if (!currentView.ScrollView(-1))
                    {
                        e.Accept = false;
                    }
                    break;

                case 1:
                    if (!currentView.ScrollView(1))
                    {
                        e.Accept = false;
                    }
                    break;

                default:
                    currentView.FirstVisibleLine = vsb.Value;
                    break;
                }
            };

            hsb = new QHScrollBar(SCROLL_BAR_WIDTH);
            this.Controls.Add(hsb);

            hsb.ValueChanged += (s, e) =>
            {
                currentView.FirstVisibleColumn = hsb.Value;
                this.Invalidate();
            };

            hsb.Visible = false;

            this.ResumeLayout(false);

            ViewEnvironment.NumColumnsPerLineChanged += setMetrics;
            FontInfo.FontMetricsChanged         += setMetrics;
            EventManager.DocumentChangedChanged += () => { if (this.DocumentChangedChanged != null)
                                                           {
                                                               DocumentChangedChanged.Invoke(this, EventArgs.Empty);
                                                           }
            };

            this.Size = new System.Drawing.Size(492, 313);
        }
Example #3
0
 public bool Matches(FontInfo other)
 {
     return(other.Color == this.Color && other.fontStyle == this.fontStyle);
 }