Hit.cs: Remove FIXME by using binary search while searching properties.
[beagle.git] / search / Panes.cs
blob8b24e1be2fc3a6d66e38e193b8e67a5f12f51bd3
1 using Gtk;
2 using Gdk;
3 using System;
4 using System.Collections;
6 namespace Search {
8 public class Panes : Gtk.VPaned {
10 Gtk.ScrolledWindow mainSW, detailsSW;
11 WhiteBox main, details;
13 public Panes ()
15 Gtk.Viewport vp;
17 mainSW = new Gtk.ScrolledWindow ();
18 mainSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Always);
19 mainSW.ShadowType = Gtk.ShadowType.In;
20 mainSW.SizeAllocated += MainResized;
21 Pack1 (mainSW, true, false);
23 vp = new Gtk.Viewport (null, null);
24 vp.ShadowType = ShadowType.None;
25 mainSW.Add (vp);
26 vp.Show ();
28 main = new WhiteBox ();
29 vp.Add (main);
30 main.Show ();
32 detailsSW = new Gtk.ScrolledWindow ();
33 detailsSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
34 detailsSW.WidthRequest = 0;
35 detailsSW.NoShowAll = true;
36 detailsSW.ShadowType = Gtk.ShadowType.In;
37 Pack2 (detailsSW, false, false);
39 vp = new Gtk.Viewport (null, null);
40 vp.ShadowType = ShadowType.None;
41 detailsSW.Add (vp);
42 vp.Show ();
44 details = new WhiteBox ();
45 vp.Add (details);
46 details.Show ();
49 public Gtk.Widget MainContents {
50 get {
51 return main.Child;
53 set {
54 if (main.Child != null)
55 main.Remove (main.Child);
56 if (value != null) {
57 main.Add (value);
58 if (value is Container)
59 ((Container)value).FocusVadjustment = mainSW.Vadjustment;
64 public Gtk.Widget Details {
65 get {
66 return details.Child;
68 set {
69 if (details.Child != null)
70 details.Remove (details.Child);
71 if (value != null) {
72 details.Add (value);
73 detailsSW.Show ();
74 } else
75 detailsSW.Hide ();
79 private void MainResized (object obj, Gtk.SizeAllocatedArgs args)
81 // If the details pane pops up and covers the selected tile,
82 // fix it.
84 Gtk.Container mainChild = main.Child as Gtk.Container;
85 if (mainChild != null) {
86 Gtk.Widget focusChild = mainChild.FocusChild;
87 mainChild.FocusChild = null;
88 mainChild.FocusChild = focusChild;
92 public class WhiteBox : Gtk.EventBox
94 public WhiteBox () : base ()
96 AppPaintable = true;
99 protected override bool OnExposeEvent (Gdk.EventExpose evt)
101 if (!IsDrawable)
102 return false;
104 if (evt.Window == GdkWindow) {
105 GdkWindow.DrawRectangle (Style.BaseGC (State), true,
106 evt.Area.X, evt.Area.Y,
107 evt.Area.Width, evt.Area.Height);
110 if (Child != null)
111 PropagateExpose (Child, evt);
113 return false;