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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
using Gtk;
using Gdk;
using System;
using System.Collections;
namespace Search {
public class Panes : Gtk.VPaned {
Gtk.ScrolledWindow mainSW, detailsSW;
WhiteBox main, details;
public Panes ()
{
Gtk.Viewport vp;
mainSW = new Gtk.ScrolledWindow ();
mainSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Always);
mainSW.ShadowType = Gtk.ShadowType.In;
mainSW.SizeAllocated += MainResized;
Pack1 (mainSW, true, false);
vp = new Gtk.Viewport (null, null);
vp.ResizeMode = Gtk.ResizeMode.Parent;
vp.ShadowType = ShadowType.None;
mainSW.Add (vp);
vp.Show ();
main = new WhiteBox ();
vp.Add (main);
main.Show ();
detailsSW = new Gtk.ScrolledWindow ();
detailsSW.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
detailsSW.WidthRequest = 0;
detailsSW.NoShowAll = true;
detailsSW.ShadowType = Gtk.ShadowType.In;
Pack2 (detailsSW, false, false);
vp = new Gtk.Viewport (null, null);
vp.ShadowType = ShadowType.None;
detailsSW.Add (vp);
vp.Show ();
details = new WhiteBox ();
vp.Add (details);
details.Show ();
}
public Gtk.Widget MainContents {
get {
return main.Child;
}
set {
if (main.Child != null)
main.Remove (main.Child);
if (value != null) {
main.Add (value);
if (value is Container)
((Container)value).FocusVadjustment = mainSW.Vadjustment;
}
}
}
public Gtk.Widget Details {
get {
return details.Child;
}
set {
if (details.Child != null)
details.Remove (details.Child);
if (value != null)
details.Add (value);
}
}
public void ToggleDetails (bool visible)
{
if (visible)
detailsSW.Show ();
else
detailsSW.Hide ();
}
private void MainResized (object obj, Gtk.SizeAllocatedArgs args)
{
// If the details pane pops up and covers the selected tile,
// fix it.
Gtk.Container mainChild = main.Child as Gtk.Container;
if (mainChild != null) {
Gtk.Widget focusChild = mainChild.FocusChild;
mainChild.FocusChild = null;
mainChild.FocusChild = focusChild;
}
}
public class WhiteBox : Gtk.EventBox
{
public WhiteBox () : base ()
{
AppPaintable = true;
}
protected override bool OnExposeEvent (Gdk.EventExpose evt)
{
if (!IsDrawable)
return false;
if (evt.Window == GdkWindow) {
GdkWindow.DrawRectangle (Style.BaseGC (State), true,
evt.Area.X, evt.Area.Y,
evt.Area.Width, evt.Area.Height);
}
if (Child != null)
PropagateExpose (Child, evt);
return false;
}
}
}
}
|