protected override void WndProc(ref Message m) { base.WndProc(ref m); if ((m.Msg == (WM_REFLECT | WM_NOTIFY)) || m.Msg == WM_NOTIFY) { STRUCT_NMHDR hdr = (STRUCT_NMHDR)(Marshal.PtrToStructure(m.LParam, typeof(STRUCT_NMHDR))); if (hdr.code == EN_OBJECTPOSITIONS) { m.Result = (IntPtr)(-1); } if (hdr.code == EN_REQUESTRESIZE) { STRUCT_REQRESIZE rrs = (STRUCT_REQRESIZE)(Marshal.PtrToStructure(m.LParam, typeof(STRUCT_REQRESIZE))); Control from = Control.FromHandle(rrs.nmhdr.hwndFrom); if (from == null) { return; } if (!(from is RichTextBox2)) { return; } RichTextBox2 rtb2 = (RichTextBox2)from; rtb2.native_rect = new Size(rrs.rc.right - rrs.rc.left, rrs.rc.bottom - rrs.rc.top); } } }
public void RenderRTF(RichTextBox2 rtf, int x, int y, int w, int h) { /* * obviously doesn't handle * RTFs with nontrivial formatting: more than one style. The correct solution * is to parse out the RTF into... into what? * And finally, we just output the local "true" name of each font, when we should * really be translating it into the names officially supported. */ Font font = rtf.GetCurrentFont(); int ch = font.Height; string[] lines = rtf.Lines; int lmax = 0; foreach (string line in lines) { if (line.Length > lmax) { lmax = line.Length; } } int linenum = 1; o.WriteLine(string.Format("<text text-anchor=\"middle\" x=\"{0}\" y=\"{1}\">", x + MAGICAL_TEXT_NOODLER + offset.X + w / 2, y - MAGICAL_TEXT_NOODLER + offset.Y)); foreach (string line in lines) { String l = string.Format("<tspan x=\"{0}\" dy=\"1em\" style=\"{1}\">{2}</tspan>", x + MAGICAL_TEXT_NOODLER + offset.X + w / 2, FontToString(font, rtf.GetCurrentColor()), System.Security.SecurityElement.Escape(line)); o.WriteLine(l); linenum++; } o.WriteLine("</text>"); }
public void RenderRTF(RichTextBox2 rtf, int x, int y, int w, int h) { /* obviously doesn't handle * RTFs with nontrivial formatting: more than one style. The correct solution * is to parse out the RTF into... into what? * And finally, we just output the local "true" name of each font, when we should * really be translating it into the names officially supported. */ Font font = rtf.GetCurrentFont(); int ch = font.Height; string[] lines = rtf.Lines; int lmax = 0; foreach (string line in lines) { if (line.Length > lmax) lmax = line.Length; } int linenum = 1; o.WriteLine(string.Format("<text text-anchor=\"middle\" x=\"{0}\" y=\"{1}\">", x + MAGICAL_TEXT_NOODLER + offset.X + w / 2, y - MAGICAL_TEXT_NOODLER + offset.Y)); foreach (string line in lines) { String l = string.Format("<tspan x=\"{0}\" dy=\"1em\" style=\"{1}\">{2}</tspan>", x + MAGICAL_TEXT_NOODLER + offset.X + w / 2, FontToString(font, rtf.GetCurrentColor()), System.Security.SecurityElement.Escape(line)); o.WriteLine(l); linenum++; } o.WriteLine("</text>"); }
public void RenderRTF(RichTextBox2 rtf, int x, int y, int w, int h) { // The RTFToGraphics routine, based on EM_FORMATRANGE, // ignores the CLR-only transformation, so we have to factor it in manually here rtf.RTFToGraphics(g, x + m_transform.Width, y + m_transform.Height, w, h); }
private Size EstimateSpace(RichTextBox2 c) { /*So. The original plan was just to use GetPreferredSize, * which, initially, seemed to correctly output the size * of the content of an RTF control. Little did I know. * In fact it only works correctly with the default font * size. So it was necessary to spent a few days figuring * shit out and eventually I wound up with the tepid * ugliness in RichTextBox2, which culminates in this * function: GetCleverSize. return c.GetPreferredSize(Size.Empty); * */ return c.GetCleverSize(); }
private void InitializeComponent() { this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.labelEditGroupBox = new System.Windows.Forms.GroupBox(); this.labelEditRichEditBox = new Tree.RichTextBox2(); this.lexEditGroupBox = new System.Windows.Forms.GroupBox(); this.triangleCheckBox = new System.Windows.Forms.CheckBox(); this.lexEditRichEditBox = new Tree.RichTextBox2(); this.nodeOperationsGroupBox = new System.Windows.Forms.GroupBox(); this.nodeToolStrip = new System.Windows.Forms.ToolStrip(); this.createChildButton = new System.Windows.Forms.ToolStripButton(); this.createParentButton = new System.Windows.Forms.ToolStripButton(); this.deleteButton = new System.Windows.Forms.ToolStripButton(); this.traceGroupBox = new System.Windows.Forms.GroupBox(); this.tracePane = new Tree.TracePane(); this.tableLayoutPanel.SuspendLayout(); this.labelEditGroupBox.SuspendLayout(); this.lexEditGroupBox.SuspendLayout(); this.nodeOperationsGroupBox.SuspendLayout(); this.nodeToolStrip.SuspendLayout(); this.traceGroupBox.SuspendLayout(); this.SuspendLayout(); // // tableLayoutPanel // this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel.Controls.Add(this.labelEditGroupBox, 0, 0); this.tableLayoutPanel.Controls.Add(this.lexEditGroupBox, 0, 1); this.tableLayoutPanel.Controls.Add(this.nodeOperationsGroupBox, 0, 2); this.tableLayoutPanel.Controls.Add(this.traceGroupBox, 0, 3); this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel.Name = "tableLayoutPanel"; this.tableLayoutPanel.RowCount = 4; this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel.Size = new System.Drawing.Size(183, 551); this.tableLayoutPanel.TabIndex = 0; this.tableLayoutPanel.Layout += new System.Windows.Forms.LayoutEventHandler(this.tableLayoutPanel1_Layout); // // labelEditGroupBox // this.labelEditGroupBox.Controls.Add(this.labelEditRichEditBox); this.labelEditGroupBox.Location = new System.Drawing.Point(3, 3); this.labelEditGroupBox.Name = "labelEditGroupBox"; this.labelEditGroupBox.Size = new System.Drawing.Size(175, 65); this.labelEditGroupBox.TabIndex = 1; this.labelEditGroupBox.TabStop = false; this.labelEditGroupBox.Text = "Label"; // // labelEditRichEditBox // this.labelEditRichEditBox.Bold = Tree.Ternary.No; this.labelEditRichEditBox.DetectUrls = false; this.labelEditRichEditBox.Dock = System.Windows.Forms.DockStyle.Fill; this.labelEditRichEditBox.Italic = Tree.Ternary.No; this.labelEditRichEditBox.Location = new System.Drawing.Point(3, 18); this.labelEditRichEditBox.MaxLength = 1024; this.labelEditRichEditBox.Name = "labelEditRichEditBox"; this.labelEditRichEditBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; this.labelEditRichEditBox.Size = new System.Drawing.Size(169, 44); this.labelEditRichEditBox.Subscript = Tree.Ternary.No; this.labelEditRichEditBox.Superscript = Tree.Ternary.No; this.labelEditRichEditBox.TabIndex = 0; this.labelEditRichEditBox.Text = ""; this.labelEditRichEditBox.Underline = Tree.Ternary.No; this.labelEditRichEditBox.WordWrap = false; this.labelEditRichEditBox.SelectionChanged += new System.EventHandler(this.labelEditRichEditBox_SelectionChanged); this.labelEditRichEditBox.TextChanged += new System.EventHandler(this.labelEditRichEditBox_TextChanged); // // lexEditGroupBox // this.lexEditGroupBox.Controls.Add(this.triangleCheckBox); this.lexEditGroupBox.Controls.Add(this.lexEditRichEditBox); this.lexEditGroupBox.Location = new System.Drawing.Point(3, 74); this.lexEditGroupBox.Name = "lexEditGroupBox"; this.lexEditGroupBox.Size = new System.Drawing.Size(175, 64); this.lexEditGroupBox.TabIndex = 2; this.lexEditGroupBox.TabStop = false; this.lexEditGroupBox.Text = "Lexical item"; // // triangleCheckBox // this.triangleCheckBox.Appearance = System.Windows.Forms.Appearance.Button; this.triangleCheckBox.Dock = System.Windows.Forms.DockStyle.Right; this.triangleCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System; this.triangleCheckBox.Location = new System.Drawing.Point(145, 18); this.triangleCheckBox.Name = "triangleCheckBox"; this.triangleCheckBox.Size = new System.Drawing.Size(27, 43); this.triangleCheckBox.TabIndex = 1; this.triangleCheckBox.Text = "/\\"; this.triangleCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.triangleCheckBox.UseVisualStyleBackColor = true; this.triangleCheckBox.CheckedChanged += new System.EventHandler(this.triangleCheckBox_CheckedChanged); // // lexEditRichEditBox // this.lexEditRichEditBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lexEditRichEditBox.Bold = Tree.Ternary.No; this.lexEditRichEditBox.DetectUrls = false; this.lexEditRichEditBox.ForeColor = System.Drawing.SystemColors.WindowText; this.lexEditRichEditBox.Italic = Tree.Ternary.No; this.lexEditRichEditBox.Location = new System.Drawing.Point(3, 18); this.lexEditRichEditBox.MaxLength = 1024; this.lexEditRichEditBox.Name = "lexEditRichEditBox"; this.lexEditRichEditBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; this.lexEditRichEditBox.Size = new System.Drawing.Size(136, 40); this.lexEditRichEditBox.Subscript = Tree.Ternary.No; this.lexEditRichEditBox.Superscript = Tree.Ternary.No; this.lexEditRichEditBox.TabIndex = 0; this.lexEditRichEditBox.Text = ""; this.lexEditRichEditBox.Underline = Tree.Ternary.No; this.lexEditRichEditBox.WordWrap = false; this.lexEditRichEditBox.SelectionChanged += new System.EventHandler(this.lexEditRichEditBox_SelectionChanged); this.lexEditRichEditBox.TextChanged += new System.EventHandler(this.lexEditRichEditBox_TextChanged); // // nodeOperationsGroupBox // this.nodeOperationsGroupBox.Controls.Add(this.nodeToolStrip); this.nodeOperationsGroupBox.Location = new System.Drawing.Point(3, 144); this.nodeOperationsGroupBox.Name = "nodeOperationsGroupBox"; this.nodeOperationsGroupBox.Size = new System.Drawing.Size(175, 53); this.nodeOperationsGroupBox.TabIndex = 4; this.nodeOperationsGroupBox.TabStop = false; this.nodeOperationsGroupBox.Text = "Node"; // // nodeToolStrip // this.nodeToolStrip.CanOverflow = false; this.nodeToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.nodeToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.createChildButton, this.createParentButton, this.deleteButton }); this.nodeToolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; this.nodeToolStrip.Location = new System.Drawing.Point(3, 16); this.nodeToolStrip.Name = "nodeToolStrip"; this.nodeToolStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; this.nodeToolStrip.Size = new System.Drawing.Size(169, 31); this.nodeToolStrip.Stretch = true; this.nodeToolStrip.TabIndex = 3; // // createChildButton // this.createChildButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.createChildButton.Image = global::Tree.Properties.Resources.nodeInsertChild; this.createChildButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.createChildButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.createChildButton.Name = "createChildButton"; this.createChildButton.Size = new System.Drawing.Size(28, 28); this.createChildButton.ToolTipText = "Insert child"; this.createChildButton.Click += new System.EventHandler(this.createChildButton_Click); // // createParentButton // this.createParentButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.createParentButton.Image = global::Tree.Properties.Resources.nodeInsertParent; this.createParentButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.createParentButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.createParentButton.Name = "createParentButton"; this.createParentButton.Size = new System.Drawing.Size(28, 28); this.createParentButton.ToolTipText = "Insert parent"; this.createParentButton.Click += new System.EventHandler(this.createParentButton_Click); // // deleteButton // this.deleteButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.deleteButton.Image = global::Tree.Properties.Resources.nodeDelete; this.deleteButton.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.deleteButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.deleteButton.Name = "deleteButton"; this.deleteButton.Size = new System.Drawing.Size(28, 28); this.deleteButton.ToolTipText = "Delete node"; this.deleteButton.Click += new System.EventHandler(this.deleteButton_Click); // // traceGroupBox // this.traceGroupBox.Controls.Add(this.tracePane); this.traceGroupBox.Location = new System.Drawing.Point(3, 203); this.traceGroupBox.Name = "traceGroupBox"; this.traceGroupBox.Size = new System.Drawing.Size(175, 100); this.traceGroupBox.TabIndex = 5; this.traceGroupBox.TabStop = false; this.traceGroupBox.Text = "Traces"; // // tracePane // this.tracePane.Dock = System.Windows.Forms.DockStyle.Fill; this.tracePane.Location = new System.Drawing.Point(3, 18); this.tracePane.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.tracePane.Name = "tracePane"; this.tracePane.Size = new System.Drawing.Size(169, 79); this.tracePane.TabIndex = 0; this.tracePane.OnTraceModified += new System.EventHandler(this.tracePane_OnTraceModified); // // NodeEditor // this.Controls.Add(this.tableLayoutPanel); this.Name = "NodeEditor"; this.Size = new System.Drawing.Size(183, 551); this.tableLayoutPanel.ResumeLayout(false); this.labelEditGroupBox.ResumeLayout(false); this.lexEditGroupBox.ResumeLayout(false); this.nodeOperationsGroupBox.ResumeLayout(false); this.nodeOperationsGroupBox.PerformLayout(); this.nodeToolStrip.ResumeLayout(false); this.nodeToolStrip.PerformLayout(); this.traceGroupBox.ResumeLayout(false); this.ResumeLayout(false); }