93
93
first_style_set = true;
96
protected override void OnSizeRequested (ref Gtk.Requisition requisition)
98
if (!IsRealized || layout == null) {
103
layout.GetPixelSize (out width, out height);
105
requisition.Width = width;
106
requisition.Height = height;
109
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
96
protected override void OnGetPreferredHeight (out int minimum_height, out int natural_height)
98
minimum_height = natural_height = 0;
99
if (!IsRealized || layout == null) {
104
layout.GetPixelSize (out width, out height);
105
minimum_height = natural_height = height;
108
protected override void OnGetPreferredWidth (out int minimum_width, out int natural_width)
110
minimum_width = natural_width = 0;
111
if (!IsRealized || layout == null) {
116
layout.GetPixelSize (out width, out height);
117
minimum_width = natural_width = width;
120
protected override bool OnDrawn (Cairo.Context cr)
111
122
int bar_width = (int)((double)Allocation.Width * buffering_progress);
112
123
bool render_bar = false;
125
var border = StyleContext.GetBorder (StateFlags);
114
126
if (bar_width > 0 && IsBuffering) {
115
bar_width -= 2 * Style.XThickness;
127
bar_width -= border.Left + border.Right;
116
128
render_bar = true;
118
Gtk.Style.PaintBox (Style, GdkWindow, StateType.Normal, ShadowType.In, evnt.Area, this, null,
119
Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
130
StyleContext.Save ();
131
StyleContext.AddClass ("trough");
132
StyleContext.RenderBackground (cr, 0, 0, Allocation.Width, Allocation.Height);
133
StyleContext.RenderFrame (cr, 0, 0, Allocation.Width, Allocation.Height);
134
StyleContext.Restore ();
121
136
if (bar_width > 0) {
122
Gtk.Style.PaintBox (Style, GdkWindow, StateType.Selected, ShadowType.EtchedOut,
123
evnt.Area, this, "bar",
124
Allocation.X + Style.XThickness, Allocation.Y + Style.YThickness,
125
bar_width, Allocation.Height - 2 * Style.YThickness);
137
StyleContext.Save ();
138
StyleContext.AddClass ("progressbar");
139
StyleContext.RenderActivity (cr,
140
border.Left, border.Top,
141
bar_width, Allocation.Height - (border.Top + border.Bottom));
142
StyleContext.Restore ();
129
146
int width, height;
130
147
layout.GetPixelSize (out width, out height);
132
int x = Allocation.X + ((Allocation.Width - width) / 2);
133
int y = Allocation.Y + ((Allocation.Height - height) / 2);
134
Gdk.Rectangle rect = evnt.Area;
149
int x = (Allocation.Width - width) / 2;
150
int y = (Allocation.Height - height) / 2;
151
Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, Allocation.Width, Allocation.Height);
136
153
if (render_bar) {
137
width = bar_width + Style.XThickness;
138
rect = new Gdk.Rectangle (evnt.Area.X, evnt.Area.Y, width, evnt.Area.Height);
139
Gtk.Style.PaintLayout (Style, GdkWindow, StateType.Selected, true, rect, this, null, x, y, layout);
154
// First render the text that is on the progressbar
155
int full_bar_width = bar_width + border.Left;
156
rect.Width = full_bar_width;
159
Gdk.CairoHelper.Rectangle (cr, rect);
161
StyleContext.Save ();
162
// The entry class is need so that the text get the "selected" color
163
StyleContext.AddClass ("entry");
164
StyleContext.AddClass ("progressbar");
165
StyleContext.RenderLayout (cr, x, y, layout);
166
StyleContext.Restore ();
169
// Adjust the rectangle so that the rest of the text is rendered as expected
141
170
rect.X += rect.Width;
142
rect.Width = evnt.Area.Width - rect.Width;
171
rect.Width = Allocation.Width - rect.Width;
145
Gtk.Style.PaintLayout (Style, GdkWindow, StateType.Normal, false, rect, this, null, x, y, layout);
175
Gdk.CairoHelper.Rectangle (cr, rect);
177
StyleContext.Save ();
178
StyleContext.AddClass ("trough");
179
StyleContext.RenderLayout (cr, x, y, layout);
180
StyleContext.Restore ();