Browse Source

Display TreeGrid in debug mode (currently without content).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@641 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
04b763d047
  1. 8
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/DeclarationViewWindow.cs
  2. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 19
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicList.cs
  4. 23
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicTreeRow.cs
  5. 103
      src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs
  6. 45
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

8
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/DeclarationViewWindow.cs

@ -72,14 +72,14 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -72,14 +72,14 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
protected override void OnPaint(PaintEventArgs pe)
{
TipPainterTools.DrawHelpTipFromCombinedDescription(this, pe.Graphics, Font, null, description);
if (description != null && description.Length > 0) {
TipPainterTools.DrawHelpTipFromCombinedDescription(this, pe.Graphics, Font, null, description);
}
}
protected override void OnPaintBackground(PaintEventArgs pe)
{
if (description != null && description.Length > 0) {
pe.Graphics.FillRectangle(SystemBrushes.Info, pe.ClipRectangle);
}
pe.Graphics.FillRectangle(SystemBrushes.Info, pe.ClipRectangle);
}
}
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -718,6 +718,7 @@ @@ -718,6 +718,7 @@
<Compile Include="Src\Gui\TreeGrid\DynamicTreeRow.cs" />
<Compile Include="Src\Gui\TreeGrid\ScrollButton.cs" />
<Compile Include="Src\Gui\TreeGrid\VerticalScrollContainer.cs" />
<Compile Include="Src\Services\Debugger\DebuggerGridControl.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

19
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicList.cs

@ -203,6 +203,25 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -203,6 +203,25 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
}
public int GetRequiredWidth(Graphics graphics)
{
int width = 0;
for (int i = 0; i < columns.Count; i++) {
if (columns[i].AutoSize) {
int minimumWidth = DynamicListColumn.DefaultWidth;
foreach (DynamicListRow row in Rows) {
DynamicListItem item = row[i];
item.MeasureMinimumWidth(graphics, ref minimumWidth);
}
width += minimumWidth;
} else {
width += columns[i].Width;
}
width += 1;
}
return width;
}
protected override void OnPaint(PaintEventArgs e)
{
//Debug.WriteLine("OnPaint");

23
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicTreeRow.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -38,7 +38,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, r);
}
class ChildForm : Form
public class ChildForm : Form
{
bool isActive = true;
@ -71,15 +71,12 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -71,15 +71,12 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
}
ChildForm frm;
static bool isOpeningChild;
protected virtual void OnPlusClick(object sender, DynamicListEventArgs e)
{
if (frm != null) {
frm.Close();
}
frm = new ChildForm();
OnExpanding(e);
ChildForm frm = new ChildForm();
frm.Closed += delegate {
frm = null;
OnCollapsed(EventArgs.Empty);
@ -92,7 +89,6 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -92,7 +89,6 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
frm.ShowInTaskbar = false;
frm.Text = childWindowCaption;
frm.Owner = e.List.FindForm();
OnExpanding(e);
VerticalScrollContainer scrollContainer = new VerticalScrollContainer();
scrollContainer.Dock = DockStyle.Fill;
@ -113,12 +109,14 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -113,12 +109,14 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y;
screenHeight -= frm.Size.Height - frm.ClientSize.Height;
int formHeight = Math.Min(childList.TotalRowHeight + 4, screenHeight);
if (formHeight < 100) {
formHeight += 100;
frm.Top -= 100;
int requiredHeight = childList.TotalRowHeight + 4;
int formHeight = Math.Min(requiredHeight, screenHeight);
if (formHeight < requiredHeight) {
int missingHeight = Math.Min(100, requiredHeight - formHeight);
formHeight += missingHeight;
frm.Top -= missingHeight;
}
frm.ClientSize = new Size(e.List.Width, formHeight);
frm.ClientSize = new Size(e.List.Width + 4, formHeight);
isOpeningChild = true;
frm.Show();
isOpeningChild = false;
@ -159,7 +157,6 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -159,7 +157,6 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
if (value == null)
throw new ArgumentNullException();
childWindowCaption = value;
if (frm != null) frm.Text = value;
}
}

103
src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs

@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 27.10.2005
* Time: 14:18
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui.TreeGrid;
namespace ICSharpCode.Core
{
public class DebuggerGridControl : DynamicList
{
// Columns:
// 0 = plus sign
// 1 = icon
// 2 = text
// 3 = value
DynamicTreeRow row = new DynamicTreeRow();
public DebuggerGridControl(string text, string value)
{
BeginUpdate();
Columns.Add(new DynamicListColumn());
Columns.Add(new DynamicListColumn());
Columns.Add(new DynamicListColumn());
Columns.Add(new DynamicListColumn());
Columns[0].BackgroundBrush = SystemBrushes.ControlLightLight;
// default is allowgrow = true and autosize = false
Columns[0].AllowGrow = false;
Columns[1].AllowGrow = false;
Columns[1].Width = 18;
Columns[2].AutoSize = true;
Columns[3].AutoSize = true;
Rows.Add(row);
row.ChildWindowCaption = text;
row[2].Text = text;
row[3].Text = value;
foreach (DynamicListColumn col in Columns) {
row.ChildColumns.Add(col.Clone());
}
row.Expanding += RowExpanding;
row.Expanded += delegate { isExpanded = true; };
row.Collapsed += delegate { isExpanded = false; };
CreateControl();
using (Graphics g = CreateGraphics()) {
this.Width = GetRequiredWidth(g);
}
this.Height = row.Height;
EndUpdate();
}
Form frm;
public void ShowForm(ICSharpCode.TextEditor.TextArea textArea, Point logicTextPos)
{
frm = new DynamicTreeRow.ChildForm();
frm.FormBorderStyle = FormBorderStyle.None;
frm.Owner = textArea.FindForm();
int ypos = (textArea.Document.GetVisibleLine(logicTextPos.Y) + 1) * textArea.TextView.FontHeight - textArea.VirtualTop.Y;
Point p = new Point(0, ypos);
p = textArea.PointToScreen(p);
p.X = Control.MousePosition.X;
frm.StartPosition = FormStartPosition.Manual;
frm.ShowInTaskbar = false;
frm.Location = p;
frm.Size = new Size(Width, row.Height);
Dock = DockStyle.Fill;
frm.Controls.Add(this);
ICSharpCode.TextEditor.Gui.CompletionWindow.AbstractCompletionWindow.ShowWindowWithoutFocus(frm);
textArea.Click += OnTextAreaClick;
textArea.KeyDown += OnTextAreaClick;
frm.Height = row.Height;
}
void OnTextAreaClick(object sender, EventArgs e)
{
((ICSharpCode.TextEditor.TextArea)sender).KeyDown -= OnTextAreaClick;
((ICSharpCode.TextEditor.TextArea)sender).Click -= OnTextAreaClick;
frm.Close();
}
bool isExpanded;
public bool AllowClose {
get {
return !isExpanded;
}
}
void RowExpanding(object sender, EventArgs e)
{
row.ChildRows.Clear();
row.ChildRows.Add(row);
}
}
}

45
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -278,6 +278,7 @@ namespace ICSharpCode.Core @@ -278,6 +278,7 @@ namespace ICSharpCode.Core
#region Tool tips
static string oldExpression, oldToolTip;
static DebuggerGridControl oldToolTipControl;
static int oldLine;
public class SetIPArgs: EventArgs
@ -297,6 +298,7 @@ namespace ICSharpCode.Core @@ -297,6 +298,7 @@ namespace ICSharpCode.Core
try {
TextArea textArea = (TextArea)sender;
if (textArea.ToolTipVisible) return;
if (oldToolTipControl != null && !oldToolTipControl.AllowClose) return;
if (!CodeCompletionOptions.TooltipsEnabled) return;
if (CodeCompletionOptions.TooltipsOnlyWhenDebugging) {
@ -311,7 +313,7 @@ namespace ICSharpCode.Core @@ -311,7 +313,7 @@ namespace ICSharpCode.Core
mousepos.Y - viewRect.Top);
if (logicPos.Y >= 0 && logicPos.Y < textArea.Document.TotalNumberOfLines) {
// This is for testing olny - it must be reworked properly
if (Control.ModifierKeys == Keys.Control && currentDebugger != null && currentDebugger.IsDebugging) {
if (Control.ModifierKeys == (Keys.Control | Keys.Shift) && currentDebugger != null && currentDebugger.IsDebugging) {
SetIPArgs a = new SetIPArgs();
a.filename = textArea.MotherTextEditorControl.FileName;
a.line = logicPos.Y;
@ -343,14 +345,29 @@ namespace ICSharpCode.Core @@ -343,14 +345,29 @@ namespace ICSharpCode.Core
} else {
// Look if it is variable
ResolveResult result = ParserService.Resolve(expressionResult, logicPos.Y + 1, logicPos.X + 1, textArea.MotherTextEditorControl.FileName, textContent);
string value = GetText(result, expression);
if (value != null) {
bool debuggerCanShowValue;
string toolTipText = GetText(result, expression, out debuggerCanShowValue);
DebuggerGridControl toolTipControl = null;
if (toolTipText != null) {
if (Control.ModifierKeys == Keys.Control) {
value = "expr: " + expressionResult.ToString() + "\n" + value;
toolTipText = "expr: " + expressionResult.ToString() + "\n" + toolTipText;
} else if (debuggerCanShowValue) {
toolTipControl = new DebuggerGridControl("hello", "world");
toolTipText = null;
}
textArea.SetToolTip(value);
}
oldToolTip = value;
if (toolTipText != null) {
textArea.SetToolTip(toolTipText);
}
if (oldToolTipControl != null) {
Form frm = oldToolTipControl.FindForm();
if (frm != null) frm.Close();
}
if (toolTipControl != null) {
toolTipControl.ShowForm(textArea, logicPos);
}
oldToolTip = toolTipText;
oldToolTipControl = toolTipControl;
}
}
oldLine = logicPos.Y;
@ -362,18 +379,19 @@ namespace ICSharpCode.Core @@ -362,18 +379,19 @@ namespace ICSharpCode.Core
}
}
static string GetText(ResolveResult result, string expression)
static string GetText(ResolveResult result, string expression, out bool debuggerCanShowValue)
{
debuggerCanShowValue = false;
if (result == null) {
// when pressing control, show the expression even when it could not be resolved
return (Control.ModifierKeys == Keys.Control) ? "" : null;
}
if (result is MixedResolveResult)
return GetText(((MixedResolveResult)result).PrimaryResult, expression);
return GetText(((MixedResolveResult)result).PrimaryResult, expression, out debuggerCanShowValue);
IAmbience ambience = AmbienceService.CurrentAmbience;
ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowAccessibility;
if (result is MemberResolveResult) {
return GetMemberText(ambience, ((MemberResolveResult)result).ResolvedMember, expression);
return GetMemberText(ambience, ((MemberResolveResult)result).ResolvedMember, expression, out debuggerCanShowValue);
} else if (result is LocalResolveResult) {
LocalResolveResult rr = (LocalResolveResult)result;
ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedNames
@ -388,6 +406,7 @@ namespace ICSharpCode.Core @@ -388,6 +406,7 @@ namespace ICSharpCode.Core
if (currentDebugger != null) {
string currentValue = currentDebugger.GetValueAsString(rr.Field.Name);
if (currentValue != null) {
debuggerCanShowValue = true;
b.Append(" = ");
b.Append(currentValue);
}
@ -398,14 +417,14 @@ namespace ICSharpCode.Core @@ -398,14 +417,14 @@ namespace ICSharpCode.Core
} else if (result is TypeResolveResult) {
IClass c = ((TypeResolveResult)result).ResolvedClass;
if (c != null)
return GetMemberText(ambience, c, expression);
return GetMemberText(ambience, c, expression, out debuggerCanShowValue);
else
return ambience.Convert(result.ResolvedType);
} else if (result is MethodResolveResult) {
MethodResolveResult mrr = result as MethodResolveResult;
IMethod m = mrr.GetMethodIfSingleOverload();
if (m != null)
return GetMemberText(ambience, m, expression);
return GetMemberText(ambience, m, expression, out debuggerCanShowValue);
else
return "Overload of " + ambience.Convert(mrr.ContainingType) + "." + mrr.Name;
} else {
@ -420,9 +439,10 @@ namespace ICSharpCode.Core @@ -420,9 +439,10 @@ namespace ICSharpCode.Core
}
}
static string GetMemberText(IAmbience ambience, IDecoration member, string expression)
static string GetMemberText(IAmbience ambience, IDecoration member, string expression, out bool debuggerCanShowValue)
{
bool tryDisplayValue = false;
debuggerCanShowValue = false;
StringBuilder text = new StringBuilder();
if (member is IField) {
text.Append(ambience.Convert(member as IField));
@ -443,6 +463,7 @@ namespace ICSharpCode.Core @@ -443,6 +463,7 @@ namespace ICSharpCode.Core
if (tryDisplayValue && currentDebugger != null) {
string currentValue = currentDebugger.GetValueAsString(expression);
if (currentValue != null) {
debuggerCanShowValue = true;
text.Append(" = ");
text.Append(currentValue);
}

Loading…
Cancel
Save