103
128
filter_button.Pixbuf = value;
107
132
private void BuildWidget ()
134
alignment = new Alignment (0.5f, 0.5f, 1f, 0f);
135
alignment.SetPadding (1, 1, 3, 3);
136
VisibleWindow = false;
109
138
box = new HBox ();
110
139
entry = new FramelessEntry (this);
111
filter_button = new HoverImageButton (IconSize.Menu, new string[] { Stock.Find });
112
clear_button = new HoverImageButton (IconSize.Menu, new string[] { Stock.Clear });
140
filter_button = new HoverImageButton (IconSize.Menu, "md-searchbox-search");
141
clear_button = new HoverImageButton (IconSize.Menu, "md-searchbox-clear");
143
entryAlignment = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f);
144
alignment.SetPadding (0, 0, 3, 3);
145
entryAlignment.Add (entry);
114
146
box.PackStart (filter_button, false, false, 0);
115
box.PackStart (entry, true, true, 0);
147
box.PackStart (entryAlignment, true, true, 0);
116
148
box.PackStart (clear_button, false, false, 0);
151
alignment.ShowAll ();
120
153
entry.StyleSet += OnInnerEntryStyleSet;
121
154
entry.StateChanged += OnInnerEntryStateChanged;
122
155
entry.FocusInEvent += OnInnerEntryFocusEvent;
123
156
entry.FocusOutEvent += OnInnerEntryFocusEvent;
124
157
entry.Changed += OnInnerEntryChanged;
126
filter_button.Image.Xpad = 2;
127
clear_button.Image.Xpad = 2;
158
entry.Activated += delegate {
162
filter_button.Image.Xpad = 0;
163
clear_button.Image.Xpad = 0;
128
164
filter_button.CanFocus = false;
129
165
clear_button.CanFocus = false;
131
167
filter_button.ButtonReleaseEvent += OnButtonReleaseEvent;
132
168
clear_button.ButtonReleaseEvent += OnButtonReleaseEvent;
133
169
clear_button.Clicked += OnClearButtonClicked;
135
filter_button.Visible = false;
136
clear_button.Visible = false;
174
protected override void OnSizeRequested (ref Requisition requisition)
176
if (HeightRequest != -1 && box.HeightRequest != HeightRequest)
177
box.HeightRequest = HeightRequest;
178
if (box.HeightRequest != -1 && HeightRequest == -1)
179
box.HeightRequest = -1;
180
base.OnSizeRequested (ref requisition);
140
183
Gtk.EventBox statusLabelEventBox;
245
297
clear_button.ModifyBg (entry.State, color);
246
298
if (statusLabelEventBox != null)
247
299
statusLabelEventBox.ModifyBg (entry.State, color);
248
box.BorderWidth = (uint)entry.Style.XThickness;
302
var h = entry.SizeRequest ().Height + entry.Style.Ythickness * 2;
303
var req = entry.SizeRequest ().Height;
304
req = Math.Max (req, filter_button.SizeRequest ().Height);
305
req = Math.Max (req, clear_button.SizeRequest ().Height);
308
box.BorderWidth = (uint)(diff / 2);
251
311
private void OnInnerEntryStyleSet (object o, StyleSetArgs args)
317
379
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
319
Style.PaintFlatBox (entry.Style, GdkWindow, State, ShadowType.None,
320
evnt.Area, this, "entry_bg", 0, 0, Allocation.Width, Allocation.Height);
381
var alloc = new Gdk.Rectangle (alignment.Allocation.X, box.Allocation.Y, alignment.Allocation.Width, box.Allocation.Height);
383
if (hasFrame && (!roundedShape || (roundedShape && !customRoundedShapeDrawing))) {
384
Style.PaintShadow (entry.Style, GdkWindow, StateType.Normal, ShadowType.In,
385
evnt.Area, entry, "entry", alloc.X, alloc.Y, alloc.Width, alloc.Height);
386
/* using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
388
ctx.Rectangle (alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1);
389
ctx.Color = new Cairo.Color (1,0,0);
393
else if (!roundedShape) {
394
using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
395
CairoExtensions.RoundedRectangle (ctx, alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1, 4);
396
ctx.Color = entry.Style.Base (Gtk.StateType.Normal).ToCairoColor ();
401
using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
402
RoundBorder (ctx, alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1);
403
ctx.Color = entry.Style.Base (Gtk.StateType.Normal).ToCairoColor ();
321
408
PropagateExpose (Child, evnt);
322
Style.PaintShadow (entry.Style, GdkWindow, StateType.Normal, ShadowType.In,
323
evnt.Area, entry, "entry", 0, 0, Allocation.Width, Allocation.Height);
410
if (hasFrame && roundedShape && customRoundedShapeDrawing) {
411
using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) {
412
RoundBorder (ctx, alloc.X + 0.5, alloc.Y + 0.5, alloc.Width - 1, alloc.Height - 1);
413
ctx.Color = Styles.WidgetBorderColor;
421
static void RoundBorder (Cairo.Context ctx, double x, double y, double w, double h)
424
ctx.Arc (x + r, y + r, r, Math.PI / 2, Math.PI + Math.PI / 2);
425
ctx.LineTo (x + w - r, y);
427
ctx.Arc (x + w - r, y + r, r, Math.PI + Math.PI / 2, Math.PI + Math.PI + Math.PI / 2);
429
ctx.LineTo (x + r, y + h);
327
434
protected override void OnShown ()