[Monodevelop-patches-list] r2764 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Gui/Completion
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Fri Aug 19 11:54:12 EDT 2005
Author: lluis
Date: 2005-08-19 11:54:12 -0400 (Fri, 19 Aug 2005)
New Revision: 2764
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/DeclarationViewWindow.cs
Log:
2005-08-19 Lluis Sanchez Gual <lluis at novell.com>
* Gui/Completion/CompletionListWindow.cs: Improved the declaration
window. Now it will wrap the member declaration if it doesn't fit in
the screen.
* Gui/Completion/DeclarationViewWindow.cs: Indent the member declaration
if it doesn't fit one line. Reduced the size of the the documentation
text.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-08-19 09:40:20 UTC (rev 2763)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-08-19 15:54:12 UTC (rev 2764)
@@ -1,3 +1,12 @@
+2005-08-19 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Gui/Completion/CompletionListWindow.cs: Improved the declaration
+ window. Now it will wrap the member declaration if it doesn't fit in
+ the screen.
+ * Gui/Completion/DeclarationViewWindow.cs: Indent the member declaration
+ if it doesn't fit one line. Reduced the size of the the documentation
+ text.
+
2005-08-19 Lluis Sanchez Gual <lluis at novell.com>
* Gui/Completion/CompletionListWindow.cs: Avoid crash is something
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs 2005-08-19 09:40:20 UTC (rev 2763)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs 2005-08-19 15:54:12 UTC (rev 2764)
@@ -12,6 +12,8 @@
ICompletionWidget completionWidget;
ICompletionData[] completionData;
DeclarationViewWindow declarationviewwindow = new DeclarationViewWindow ();
+ ICompletionData currentData;
+ const int declarationWindowMargin = 3;
static DataComparer dataComparer = new DataComparer ();
class DataComparer: IComparer
@@ -119,10 +121,16 @@
if ((ka & ListWindow.KeyAction.Process) != 0) {
if (e.Key == Gdk.Key.Left) {
- wnd.declarationviewwindow.OverloadLeft ();
+ if (wnd.declarationviewwindow.Multiple) {
+ wnd.declarationviewwindow.OverloadLeft ();
+ wnd.UpdateDeclarationView ();
+ }
return true;
} else if (e.Key == Gdk.Key.Right) {
- wnd.declarationviewwindow.OverloadRight ();
+ if (wnd.declarationviewwindow.Multiple) {
+ wnd.declarationviewwindow.OverloadRight ();
+ wnd.UpdateDeclarationView ();
+ }
return true;
}
}
@@ -143,9 +151,7 @@
void ListSizeChanged (object obj, SizeAllocatedArgs args)
{
- // FIXME: crashes on System.Runtime.
- // first line array out of bounds
- //UpdateDeclarationView ();
+ UpdateDeclarationView ();
}
protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
@@ -166,11 +172,9 @@
void UpdateDeclarationView ()
{
- ICompletionData data = completionData[List.Selection];
-
- declarationviewwindow.Hide ();
- declarationviewwindow.Clear ();
-
+ if (completionData == null || List.Selection >= completionData.Length)
+ return;
+
if (List.GdkWindow == null) return;
Gdk.Rectangle rect = List.GetRowArea (List.Selection);
int listpos_x = 0, listpos_y = 0;
@@ -186,23 +190,29 @@
} else if (vert < listpos_y) {
vert = listpos_y;
}
- int horiz = listpos_x + lvWidth + 2;
+ ICompletionData data = completionData[List.Selection];
ICompletionDataWithMarkup datawMarkup = data as ICompletionDataWithMarkup;
+ CodeCompletionData ccdata = (CodeCompletionData) data;
string descMarkup = datawMarkup != null ? datawMarkup.DescriptionPango : data.Description;
- declarationviewwindow.Realize ();
+ declarationviewwindow.Hide ();
+
+ if (data != currentData) {
+ declarationviewwindow.Clear ();
+ declarationviewwindow.Realize ();
+
+ declarationviewwindow.AddOverload (descMarkup);
- declarationviewwindow.AddOverload (descMarkup);
-
- CodeCompletionData ccdata = (CodeCompletionData) data;
-
- foreach (CodeCompletionData odata in ccdata.GetOverloads ()) {
- ICompletionDataWithMarkup odatawMarkup = odata as ICompletionDataWithMarkup;
- declarationviewwindow.AddOverload (odatawMarkup == null ? odata.Description : odatawMarkup.DescriptionPango);
+ foreach (CodeCompletionData odata in ccdata.GetOverloads ()) {
+ ICompletionDataWithMarkup odatawMarkup = odata as ICompletionDataWithMarkup;
+ declarationviewwindow.AddOverload (odatawMarkup == null ? odata.Description : odatawMarkup.DescriptionPango);
+ }
}
-
+
+ currentData = data;
+
if (declarationviewwindow.DescriptionMarkup.Length == 0)
return;
@@ -210,16 +220,25 @@
declarationviewwindow.Move (this.Screen.Width+1, vert);
+ declarationviewwindow.SetFixedWidth (-1);
declarationviewwindow.ReshowWithInitialSize ();
declarationviewwindow.ShowAll ();
declarationviewwindow.Multiple = (ccdata.Overloads != 0);
declarationviewwindow.GdkWindow.GetSize (out dvwWidth, out dvwHeight);
- if (this.Screen.Width <= horiz + dvwWidth) {
- horiz = listpos_x - dvwWidth - 10;
+ int horiz = listpos_x + lvWidth + declarationWindowMargin;
+ if (this.Screen.Width - horiz >= lvWidth) {
+ if (this.Screen.Width - horiz < dvwWidth)
+ declarationviewwindow.SetFixedWidth (this.Screen.Width - horiz);
+ } else {
+ if (listpos_x - dvwWidth - declarationWindowMargin < 0) {
+ declarationviewwindow.SetFixedWidth (listpos_x - declarationWindowMargin);
+ dvwWidth = declarationviewwindow.SizeRequest ().Width;
+ }
+ horiz = listpos_x - dvwWidth - declarationWindowMargin;
}
-
+
declarationviewwindow.Move (horiz, vert);
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/DeclarationViewWindow.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/DeclarationViewWindow.cs 2005-08-19 09:40:20 UTC (rev 2763)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/DeclarationViewWindow.cs 2005-08-19 15:54:12 UTC (rev 2764)
@@ -22,7 +22,8 @@
ArrayList overloads;
int current_overload;
- Label headlabel, bodylabel, helplabel;
+ HeaderWidget headlabel;
+ Label bodylabel, helplabel;
Arrow left, right;
VBox helpbox;
@@ -44,7 +45,7 @@
string[] parts = value.Split (newline, 2);
headlabel.Markup = parts[0].Trim (whitespace);
- bodylabel.Markup = (parts.Length == 2 ? parts[1].Trim (whitespace) : String.Empty);
+ bodylabel.Markup = "<span size=\"smaller\">" + (parts.Length == 2 ? parts[1].Trim (whitespace) : String.Empty) + "</span>";
headlabel.Visible = headlabel.Text != "";
bodylabel.Visible = bodylabel.Text != "";
@@ -109,6 +110,18 @@
DescriptionMarkup = String.Empty;
current_overload = 0;
}
+
+ public void SetFixedWidth (int w)
+ {
+ if (w != -1) {
+ int boxMargin = SizeRequest().Width - headlabel.SizeRequest().Width;
+ w -= boxMargin;
+ headlabel.Width = w > 0 ? w : 1;
+ } else {
+ headlabel.Width = -1;
+ }
+ bodylabel.WidthRequest = headlabel.SizeRequest().Width;
+ }
public DeclarationViewWindow () : base (WindowType.Popup)
{
@@ -116,17 +129,17 @@
this.AllowShrink = false;
this.AllowGrow = false;
- headlabel = new Label ("");
- headlabel.LineWrap = false;
- headlabel.Xalign = 0;
+ headlabel = new HeaderWidget ();
+// headlabel.LineWrap = true;
+// headlabel.Xalign = 0;
bodylabel = new Label ("");
bodylabel.LineWrap = true;
bodylabel.Xalign = 0;
VBox vb = new VBox (false, 0);
- vb.PackStart (headlabel, false, true, 0);
- vb.PackStart (bodylabel, false, true, 0);
+ vb.PackStart (headlabel, true, true, 0);
+ vb.PackStart (bodylabel, true, true, 3);
left = new Arrow (ArrowType.Left, ShadowType.None);
right = new Arrow (ArrowType.Right, ShadowType.None);
@@ -150,7 +163,7 @@
VBox vb2 = new VBox (false, 0);
vb2.Spacing = 4;
- vb2.PackStart (hb, false, true, 0);
+ vb2.PackStart (hb, true, true, 0);
vb2.PackStart (helpbox, false, true, 0);
Frame frame = new Frame ();
@@ -159,4 +172,62 @@
this.Add (frame);
}
}
+
+ class HeaderWidget: Gtk.DrawingArea
+ {
+ string text;
+ Pango.Layout layout;
+ int width;
+
+ public HeaderWidget ()
+ {
+ layout = new Pango.Layout (this.PangoContext);
+ layout.Indent = (int) (-20 * Pango.Scale.PangoScale);
+ layout.Wrap = Pango.WrapMode.WordChar;
+ }
+
+ public string Markup {
+ get { return text; }
+ set {
+ layout.SetMarkup (value);
+ text = value;
+ QueueResize ();
+ QueueDraw ();
+ }
+ }
+
+ public string Text {
+ get { return Markup; }
+ set { Markup = value; }
+ }
+
+ public int Width {
+ get { return width; }
+ set {
+ width = value;
+ if (width == -1)
+ layout.Width = int.MaxValue;
+ else
+ layout.Width = (int)(width * Pango.Scale.PangoScale);
+ QueueResize ();
+ }
+ }
+
+ protected override bool OnExposeEvent (Gdk.EventExpose args)
+ {
+ base.OnExposeEvent (args);
+
+ this.GdkWindow.DrawLayout (Style.TextGC (StateType.Normal), 0, 0, layout);
+ return true;
+ }
+
+ protected override void OnSizeRequested (ref Requisition req)
+ {
+ int w, h;
+ layout.GetPixelSize (out w, out h);
+
+ req.Width = w;
+ req.Height = h;
+ }
+ }
}
More information about the Monodevelop-patches-list
mailing list