74
81
hScrollBar = new HScrollbar (hAdjustment);
75
82
hScrollBar.Parent = this;
76
83
hScrollBar.Show ();
87
protected override void OnDestroyed ()
91
if (vAdjustment != null) {
92
vAdjustment.Changed -= HandleAdjustmentChanged;
93
vAdjustment.Destroy ();
96
if (hAdjustment != null) {
97
hAdjustment.Changed -= HandleAdjustmentChanged;
98
hAdjustment.Destroy ();
101
foreach (var c in children) {
79
107
void HandleAdjustmentChanged (object sender, EventArgs e)
95
123
protected override void ForAll (bool include_internals, Gtk.Callback callback)
97
base.ForAll (include_internals, callback);
99
if (include_internals) {
100
callback (vScrollBar);
101
callback (hScrollBar);
102
children.ForEach (child => callback (child.Child));
125
if (!include_internals)
129
callback (vScrollBar);
130
callback (hScrollBar);
131
children.ForEach (child => callback (child.Child));
106
134
public void AddChild (Gtk.Widget child, ChildPosition position)
120
148
protected override void OnRemoved (Widget widget)
123
150
foreach (var info in children.ToArray ()) {
124
151
if (info.Child == widget) {
152
info.Child.Unparent ();
125
153
children.Remove (info);
157
base.OnRemoved (widget);
131
protected override void OnDestroyed ()
133
base.OnDestroyed (); // child gets destroyed here
134
vScrollBar.Destroy ();
135
hScrollBar.Destroy ();
136
vAdjustment.Destroy ();
137
hAdjustment.Destroy ();
140
160
protected override void OnSizeAllocated (Rectangle allocation)
142
162
base.OnSizeAllocated (allocation);
144
int vwidth = vScrollBar.Visible ? vScrollBar.Requisition.Width : 1;
145
int hheight = hScrollBar.Visible ? hScrollBar.Requisition.Height : 1;
146
Rectangle childRectangle = new Rectangle (allocation.X + 1, allocation.Y + 1, allocation.Width - vwidth, allocation.Height - hheight);
164
int vwidth = vScrollBar.Visible ? vScrollBar.Requisition.Width : 0;
165
int hheight = hScrollBar.Visible ? hScrollBar.Requisition.Height : 0;
166
Rectangle childRectangle = new Rectangle (allocation.X + 1, allocation.Y + 1, allocation.Width - vwidth - 1, allocation.Height - hheight - 1);
147
167
if (Child != null)
148
168
Child.SizeAllocate (childRectangle);
155
175
vChildTopHeight += child.Child.Requisition.Height;
157
177
int v = hScrollBar.Visible ? hScrollBar.Requisition.Height : 0;
158
vScrollBar.SizeAllocate (new Rectangle (right, childRectangle.Y + vChildTopHeight, vwidth, Allocation.Height - v - vChildTopHeight));
178
vScrollBar.SizeAllocate (new Rectangle (right, childRectangle.Y + vChildTopHeight, vwidth, Allocation.Height - v - vChildTopHeight - 1));
159
179
vScrollBar.Value = System.Math.Max (System.Math.Min (vAdjustment.Upper - vAdjustment.PageSize, vScrollBar.Value), vAdjustment.Lower);
201
221
protected override bool OnExposeEvent (EventExpose evnt)
203
Gdk.GC gc = Style.DarkGC (State);
204
evnt.Window.DrawLine (gc, Allocation.X, Allocation.Top, Allocation.X, Allocation.Bottom);
205
if (vScrollBar.Visible && hScrollBar.Visible) {
206
evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Y + Allocation.Height / 2);
208
evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom);
210
evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y);
211
if (vScrollBar.Visible && hScrollBar.Visible) {
212
evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Left + Allocation.Width / 2 , Allocation.Bottom);
214
evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom);
217
/* if (vScrollBar.Visible && hScrollBar.Visible) {
218
int vwidth = vScrollBar.Requisition.Width;
219
int hheight = hScrollBar.Requisition.Height;
221
evnt.Window.DrawRectangle (Style.BackgroundGC (State), true,
222
Allocation.Right - vwidth,
223
Allocation.Bottom - hheight,
223
using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) {
226
cr.SharpLineX (Allocation.X, Allocation.Y, Allocation.X, Allocation.Bottom);
228
/*if (vScrollBar.Visible && hScrollBar.Visible) {
229
cr.SharpLineX (Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Y + Allocation.Height / 2);
231
cr.SharpLineX (Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom);
234
cr.SharpLineY (Allocation.Left, Allocation.Y, Allocation.Right, Allocation.Y);
235
/* if (vScrollBar.Visible && hScrollBar.Visible) {
236
cr.SharpLineY (Allocation.Left, Allocation.Bottom, Allocation.Left + Allocation.Width / 2 , Allocation.Bottom);
238
cr.SharpLineY (Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom);
240
cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor (Style.Dark (State));
226
243
return base.OnExposeEvent (evnt);