2 // HitRendererControl.cs
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 using System
.Collections
;
30 public class HitRendererControl
: Gtk
.HBox
{
36 Gtk
.Label displayedLabel
;
38 Gtk
.Button prevButton
;
39 Gtk
.Button nextButton
;
41 public HitRendererControl (string _name
, string icon
, HitRenderer r
)
47 renderer
.RefreshEvent
+= new HitRenderer
.RefreshHandler (OnRefresh
);
50 Gtk
.Widget iconW
= DataBarn
.GetImageWidget (icon
);
52 this.PackStart (iconW
, false, false, 3);
57 nameLabel
= new Gtk
.Label ("");
58 this.PackStart (nameLabel
, false, false, 3);
62 nextButton
= new Gtk
.Button ("Next");
63 nextButton
.Clicked
+= new EventHandler (OnNextClicked
);
64 this.PackEnd (nextButton
, false, false, 3);
66 displayedLabel
= new Gtk
.Label ("");
67 this.PackEnd (displayedLabel
, false, false, 3);
68 displayedLabel
.Show ();
70 prevButton
= new Gtk
.Button ("Prev");
71 prevButton
.Clicked
+= new EventHandler (OnPrevClicked
);
72 this.PackEnd (prevButton
, false, false, 3);
78 private void OnRefresh (HitRenderer signaller
)
82 str
= "<b>" + name
+ "</b>";
83 if (renderer
.TotalCount
> 0) {
84 str
+= " -- " + renderer
.TotalCount
+ " match";
85 if (renderer
.TotalCount
> 1)
88 nameLabel
.Markup
= str
;
92 if (renderer
.DisplayedCount
> 1) {
93 str
= String
.Format ("{0} - {1} displayed",
94 renderer
.FirstDisplayed
+ 1,
95 renderer
.LastDisplayed
+ 1);
96 if (renderer
.LastDisplayed
+ 1 < renderer
.TotalCount
) {
101 displayedLabel
.Text
= str
;
103 prevButton
.Sensitive
= (renderer
.FirstDisplayed
> 0);
104 nextButton
.Sensitive
= (renderer
.LastDisplayed
+ 1 < renderer
.TotalCount
105 && renderer
.TotalCount
> 0);
108 private void OnPrevClicked (object o
, EventArgs args
)
110 renderer
.DisplayPrev ();
113 private void OnNextClicked (object o
, EventArgs args
)
115 renderer
.DisplayNext ();