~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Components/HeaderBox.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
                int bottomPadding;
41
41
                int leftPadding;
42
42
                int rightPadding;
43
 
                
 
43
                Gdk.Color? backgroundColor;
 
44
                bool showTopShadow;
 
45
                bool useChildBackgroundColor;
 
46
                int shadowSize = 3;
 
47
                double shadowStrengh = 0.1;
 
48
 
44
49
                public HeaderBox ()
45
50
                {
46
51
                }
65
70
                        this.leftPadding = leftPadding;
66
71
                        this.rightPadding = rightPadding;
67
72
                }
 
73
 
 
74
                public bool ShowTopShadow {
 
75
                        get { return showTopShadow; }
 
76
                        set {
 
77
                                showTopShadow = value;
 
78
                                QueueDraw ();
 
79
                        }
 
80
                }
 
81
 
 
82
                public int ShadowSize {
 
83
                        get {
 
84
                                return shadowSize;
 
85
                        }
 
86
                        set {
 
87
                                shadowSize = value;
 
88
                                QueueDraw ();
 
89
                        }
 
90
                }
 
91
 
 
92
                public double ShadowStrengh {
 
93
                        get {
 
94
                                return shadowStrengh;
 
95
                        }
 
96
                        set {
 
97
                                shadowStrengh = value;
 
98
                                QueueDraw ();
 
99
                        }
 
100
                }
68
101
                
69
102
                public bool GradientBackround { get; set; }
70
103
 
 
104
                public Gdk.Color? BorderColor { get; set; }
 
105
 
 
106
                public Gdk.Color? BackgroundColor {
 
107
                        get { return backgroundColor; }
 
108
                        set {
 
109
                                backgroundColor = value;
 
110
                                QueueDraw ();
 
111
                        }
 
112
                }
 
113
 
 
114
                public bool UseChildBackgroundColor {
 
115
                        get {
 
116
                                return useChildBackgroundColor;
 
117
                        }
 
118
                        set {
 
119
                                useChildBackgroundColor = value;
 
120
                                QueueDraw ();
 
121
                        }
 
122
                }
 
123
 
71
124
                protected override void OnAdded (Widget widget)
72
125
                {
73
126
                        base.OnAdded (widget);
126
179
                                        cr.Pattern = pat;
127
180
                                        cr.FillPreserve ();
128
181
                                }
 
182
                        } else if (BackgroundColor != null) {
 
183
                                using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
 
184
                                        cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
 
185
                                        cr.Color = BackgroundColor.Value.ToCairoColor ();
 
186
                                        cr.Fill ();
 
187
                                }
 
188
                        } else if (useChildBackgroundColor && Child != null) {
 
189
                                using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
 
190
                                        cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
 
191
                                        cr.Color = Child.Style.Base (StateType.Normal).ToCairoColor ();
 
192
                                        cr.Fill ();
 
193
                                }
129
194
                        }
130
195
                        
131
196
                        bool res = base.OnExposeEvent (evnt);
132
197
                        
133
 
                        Gdk.GC borderColor = Style.DarkGC (Gtk.StateType.Normal);
134
 
                        
 
198
                        var borderColor = new Gdk.GC (GdkWindow);
 
199
                        borderColor.RgbFgColor = BorderColor != null ? BorderColor.Value : Style.Dark (Gtk.StateType.Normal);
 
200
 
135
201
                        rect = Allocation;
136
202
                        for (int n=0; n<topMargin; n++)
137
203
                                GdkWindow.DrawLine (borderColor, rect.X, rect.Y + n, rect.Right - 1, rect.Y + n);
138
204
                        
139
205
                        for (int n=0; n<bottomMargin; n++)
140
 
                                GdkWindow.DrawLine (borderColor, rect.X, rect.Bottom - n - 1, rect.Right - 1, rect.Bottom - n - 1);
 
206
                                GdkWindow.DrawLine (borderColor, rect.X, rect.Bottom - n, rect.Right, rect.Bottom - n);
141
207
                        
142
208
                        for (int n=0; n<leftMargin; n++)
143
 
                                GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom - 1);
 
209
                                GdkWindow.DrawLine (borderColor, rect.X + n, rect.Y, rect.X + n, rect.Bottom);
144
210
                        
145
211
                        for (int n=0; n<rightMargin; n++)
146
 
                                GdkWindow.DrawLine (borderColor, rect.Right - n - 1, rect.Y, rect.Right - n - 1, rect.Bottom - 1);
147
 
                        
 
212
                                GdkWindow.DrawLine (borderColor, rect.Right - n, rect.Y, rect.Right - n, rect.Bottom);
 
213
 
 
214
                        if (showTopShadow) {
 
215
                                using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) {
 
216
                                        cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, shadowSize);
 
217
                                        Cairo.Gradient pat = new Cairo.LinearGradient (rect.X, rect.Y, rect.X, rect.Y + shadowSize);
 
218
                                        pat.AddColorStop (0, new Cairo.Color (0, 0, 0, shadowStrengh));
 
219
                                        pat.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
 
220
                                        cr.Pattern = pat;
 
221
                                        cr.Fill ();
 
222
                                }
 
223
                        }
 
224
 
 
225
                        borderColor.Dispose ();
148
226
                        return res;
149
227
                }
150
228
        }