cvsimport
[beagle.git] / search / Panes.cs
blobc43a1f460b9fab138f5393b831029eda93aceee4
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.ResizeMode = Gtk.ResizeMode.Parent;
25 vp.ShadowType = ShadowType.None;
26 mainSW.Add (vp);
27 vp.Show ();
29 main = new WhiteBox ();
30 vp.Add (main);
31 main.Show ();
33 detailsSW = new Gtk.ScrolledWindow ();
34 detailsSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
35 detailsSW.WidthRequest = 0;
36 detailsSW.NoShowAll = true;
37 detailsSW.ShadowType = Gtk.ShadowType.In;
38 Pack2 (detailsSW, false, false);
40 vp = new Gtk.Viewport (null, null);
41 vp.ShadowType = ShadowType.None;
42 detailsSW.Add (vp);
43 vp.Show ();
45 details = new WhiteBox ();
46 vp.Add (details);
47 details.Show ();
50 public Gtk.Widget MainContents {
51 get {
52 return main.Child;
54 set {
55 if (main.Child != null)
56 main.Remove (main.Child);
57 if (value != null) {
58 main.Add (value);
59 if (value is Container)
60 ((Container)value).FocusVadjustment = mainSW.Vadjustment;
65 public Gtk.Widget Details {
66 get {
67 return details.Child;
69 set {
70 if (details.Child != null)
71 details.Remove (details.Child);
72 if (value != null)
73 details.Add (value);
77 public void ToggleDetails (bool visible)
79 if (visible)
80 detailsSW.Show ();
81 else
82 detailsSW.Hide ();
85 private void MainResized (object obj, Gtk.SizeAllocatedArgs args)
87 // If the details pane pops up and covers the selected tile,
88 // fix it.
90 Gtk.Container mainChild = main.Child as Gtk.Container;
91 if (mainChild != null) {
92 Gtk.Widget focusChild = mainChild.FocusChild;
93 mainChild.FocusChild = null;
94 mainChild.FocusChild = focusChild;
98 public class WhiteBox : Gtk.EventBox
100 public WhiteBox () : base ()
102 AppPaintable = true;
105 protected override bool OnExposeEvent (Gdk.EventExpose evt)
107 if (!IsDrawable)
108 return false;
110 if (evt.Window == GdkWindow) {
111 GdkWindow.DrawRectangle (Style.BaseGC (State), true,
112 evt.Area.X, evt.Area.Y,
113 evt.Area.Width, evt.Area.Height);
116 if (Child != null)
117 PropagateExpose (Child, evt);
119 return false;