~ubuntu-branches/ubuntu/quantal/monodevelop/quantal

« back to all changes in this revision

Viewing changes to src/core/Mono.Texteditor/Mono.TextEditor.Theatrics/SmartScrolledWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2011-06-29 06:56:25 UTC
  • mfrom: (1.8.1 upstream) (1.3.11 experimental)
  • Revision ID: james.westby@ubuntu.com-20110629065625-7xx19c4vb95j65pl
Tags: 2.5.92+dfsg-1ubuntu1
* Merge from Debian experimental:
 - Dropped patches & changes to debian/control for Moonlight
   + debian/patches/remove_support_for_moonlight.patch,
   + debian/patches/dont_add_moonlight_to_core_addins.patch,
 - Remaining patches:
   + debian/patches/no_appmenu:

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
                        }
56
56
                }
57
57
                
 
58
                
 
59
                protected override void OnMapped ()
 
60
                {
 
61
                        base.OnMapped ();
 
62
                        QueueDraw ();
 
63
                }
 
64
                
58
65
                protected SmartScrolledWindow (IntPtr ptr) : base (ptr)
59
66
                {
60
67
                }
74
81
                        hScrollBar = new HScrollbar (hAdjustment);
75
82
                        hScrollBar.Parent = this;
76
83
                        hScrollBar.Show ();
 
84
                        
 
85
                }
 
86
                
 
87
                protected override void OnDestroyed ()
 
88
                {
 
89
                        if (Child != null)
 
90
                                Child.Destroy ();
 
91
                        if (vAdjustment != null) {
 
92
                                vAdjustment.Changed -= HandleAdjustmentChanged;
 
93
                                vAdjustment.Destroy ();
 
94
                                vAdjustment = null;
 
95
                        }
 
96
                        if (hAdjustment != null) {
 
97
                                hAdjustment.Changed -= HandleAdjustmentChanged;
 
98
                                hAdjustment.Destroy ();
 
99
                                hAdjustment = null;
 
100
                        }
 
101
                        foreach (var c in children) {
 
102
                                c.Child.Destroy ();
 
103
                        }
 
104
                        base.OnDestroyed ();
77
105
                }
78
106
                
79
107
                void HandleAdjustmentChanged (object sender, EventArgs e)
94
122
                
95
123
                protected override void ForAll (bool include_internals, Gtk.Callback callback)
96
124
                {
97
 
                        base.ForAll (include_internals, callback);
98
 
                        
99
 
                        if (include_internals) {
100
 
                                callback (vScrollBar);
101
 
                                callback (hScrollBar);
102
 
                                children.ForEach (child => callback (child.Child));
103
 
                        }
 
125
                        if (!include_internals) 
 
126
                                return;
 
127
                        if (Child != null)
 
128
                                callback (Child);
 
129
                        callback (vScrollBar);
 
130
                        callback (hScrollBar);
 
131
                        children.ForEach (child => callback (child.Child));
104
132
                }
105
133
                
106
134
                public void AddChild (Gtk.Widget child, ChildPosition position)
119
147
                
120
148
                protected override void OnRemoved (Widget widget)
121
149
                {
122
 
                        widget.Unparent ();
123
150
                        foreach (var info in children.ToArray ()) {
124
151
                                if (info.Child == widget) {
 
152
                                        info.Child.Unparent ();
125
153
                                        children.Remove (info);
126
 
                                        break;
 
154
                                        return;
127
155
                                }
128
156
                        }
 
157
                        base.OnRemoved (widget);
129
158
                }
130
159
                
131
 
                protected override void OnDestroyed ()
132
 
                {
133
 
                        base.OnDestroyed (); // child gets destroyed here
134
 
                        vScrollBar.Destroy ();
135
 
                        hScrollBar.Destroy ();
136
 
                        vAdjustment.Destroy ();
137
 
                        hAdjustment.Destroy (); 
138
 
                }
139
 
                 
140
160
                protected override void OnSizeAllocated (Rectangle allocation)
141
161
                {
142
162
                        base.OnSizeAllocated (allocation);
143
163
                        
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);
149
169
                        
155
175
                                        vChildTopHeight += child.Child.Requisition.Height;
156
176
                                }
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);
160
180
                        }
161
181
                        
200
220
                
201
221
                protected override bool OnExposeEvent (EventExpose evnt)
202
222
                {
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);
207
 
                        } else {
208
 
                                evnt.Window.DrawLine (gc, Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom);
209
 
                        }
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);
213
 
                        } else {
214
 
                                evnt.Window.DrawLine (gc, Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom);
215
 
                        }
216
 
                        
217
 
/*                      if (vScrollBar.Visible && hScrollBar.Visible) {
218
 
                                int vwidth = vScrollBar.Requisition.Width;
219
 
                                int hheight = hScrollBar.Requisition.Height; 
220
 
 
221
 
                                evnt.Window.DrawRectangle (Style.BackgroundGC (State), true, 
222
 
                                                           Allocation.Right - vwidth, 
223
 
                                                           Allocation.Bottom - hheight, 
224
 
                                                           vwidth, hheight);
225
 
                        }*/
 
223
                        using (Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window)) {
 
224
                                cr.LineWidth = 1;
 
225
                                
 
226
                                cr.SharpLineX (Allocation.X, Allocation.Y, Allocation.X, Allocation.Bottom);
 
227
                                
 
228
                                /*if (vScrollBar.Visible && hScrollBar.Visible) {
 
229
                                        cr.SharpLineX (Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Y + Allocation.Height / 2);
 
230
                                } else {*/
 
231
                                        cr.SharpLineX (Allocation.Right, Allocation.Top, Allocation.Right, Allocation.Bottom);
 
232
//                              }
 
233
                                
 
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);
 
237
                                } else {*/
 
238
                                        cr.SharpLineY (Allocation.Left, Allocation.Bottom, Allocation.Right, Allocation.Bottom);
 
239
//                              }
 
240
                                cr.Color = Mono.TextEditor.Highlighting.Style.ToCairoColor (Style.Dark (State));
 
241
                                cr.Stroke ();
 
242
                        }
226
243
                        return base.OnExposeEvent (evnt);
227
244
                }
228
245