Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PadTreeView.cs « MonoDevelop.Ide.Gui.Components « MonoDevelop.Ide « core « src « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fed5414ad495ba43b2e934fb35fd303b05585452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 
// PadTreeView.cs
//  
// Author:
//       Michael Hutchinson <mhutchinson@novell.com>
// 
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using Gtk;
using Mono.TextEditor;

namespace MonoDevelop.Ide.Gui.Components
{
	public class PadTreeView : MonoDevelop.Components.ContextMenuTreeView
	{
		PadFontChanger changer;
		CellRendererText textRenderer = new CellRendererText ();
		
		public PadTreeView ()
		{
			Init ();
		}
		
		public PadTreeView (TreeModel model) : base (model)
		{
			Init ();
		}
		
		void Init ()
		{
			changer = new PadFontChanger (this,
				delegate (Pango.FontDescription desc) { textRenderer.FontDesc = desc; },
				ColumnsAutosize);
			MonoDevelop.Components.GtkUtil.EnableAutoTooltips (this);
		}
		
		public CellRendererText TextRenderer {
			get { return textRenderer; }
		}
		
		protected override void OnDestroyed ()
		{
			if (changer != null) {
				changer.Dispose ();
				changer = null;
			}
			base.OnDestroyed ();
		}
		
		// Workaround for Bug 1698 - Error list scroll position doesn't reset when list changes, hides items
		// If the store of a pad treeview is modified while the pad is unrealized (autohidden), the treeview
		// doesn't update its internal vertical offset. This can lead to items becoming offset outside the 
		// visible area and therefore becoming unreachable. The only way to force the treeview to recalculate
		// this offset is by setting the Vadjustment.Value, but it ignores values the same as the current value.
		// Therefore we simply set it to something slightly different then back again.
		
		bool forceInternalOffsetUpdate;
		
		protected override void OnUnrealized ()
		{
			base.OnUnrealized ();
			forceInternalOffsetUpdate = true;
		}
		
		protected override void OnSizeAllocated (Gdk.Rectangle allocation)
		{
			base.OnSizeAllocated (allocation);
			if (forceInternalOffsetUpdate && IsRealized) {
				forceInternalOffsetUpdate = false;
				var v = Vadjustment.Value;
				int delta = v > 2? 0 : 1;
				Vadjustment.Value = v + delta;
				Vadjustment.Value = v;
			}
		}
	}
}