7
7
namespace ClutterFlow.Alphabet
10
public class AlphabetEventArgs : EventArgs
12
protected AlphabetChars letter = AlphabetChars.unknown;
13
public AlphabetChars Letter {
14
get { return letter; }
17
public AlphabetEventArgs (AlphabetChars letter) : base ()
24
public class AlphabetBar : Clutter.Group
28
public event EventHandler<AlphabetEventArgs> LetterClicked;
29
protected void InvokeLetterClicked (AlphabetChars letter)
31
if (LetterClicked!=null) LetterClicked (this, new AlphabetEventArgs (letter));
36
protected CairoTexture background;
38
protected Dictionary<AlphabetChars, AlphabetButton> buttons = new Dictionary<AlphabetChars, AlphabetButton>(Enum.GetValues(typeof(AlphabetChars)).Length);
39
public AlphabetButton this [AlphabetChars index] {
40
get { return buttons[index]; }
43
protected double Margin {
44
get { return Width * 0.075; }
49
#region Initialisation
50
public AlphabetBar (uint width, uint height)
52
this.SetSize (width, height);
60
protected virtual void InitBackground ()
62
background = new CairoTexture ((uint) Width,(uint) Height);
69
protected virtual void SetupBackground ()
72
Cairo.Context context = background.Create();
75
double hlwidth = lwidth*0.5;
77
double margin = Margin;
80
context.MoveTo (-hlwidth, -hlwidth);
81
context.CurveTo (margin*0.33, -hlwidth,
82
margin*0.5, Height*0.4,
83
margin*0.5, Height*0.5);
84
context.CurveTo (margin*0.5, Height*0.6,
85
margin*0.66, Height-hlwidth,
86
margin-hlwidth, Height-hlwidth);
90
context.LineTo (Width-margin-hlwidth, Height-hlwidth);
93
context.CurveTo (Width-margin*0.66, Height - hlwidth,
94
Width-margin*0.5, Height*0.6,
95
Width-margin*0.5, Height*0.5);
96
context.CurveTo (Width-margin*0.5, Height*0.4,
97
Width-margin*0.33, -hlwidth,
98
Width-hlwidth, -hlwidth);
101
context.LineTo (-hlwidth, -hlwidth);
102
context.ClosePath ();
104
context.LineWidth = lwidth;
105
context.SetSourceRGBA (1.0, 1.0, 1.0, 1.0);
106
context.StrokePreserve ();
107
context.SetSourceRGBA (1.0, 1.0, 1.0, 0.10);
110
((IDisposable) context.Target).Dispose();
111
((IDisposable) context).Dispose();
114
protected virtual void InitButtons ()
116
Array values = Enum.GetValues(typeof(AlphabetChars));
118
int x_step = (int) ((Width * 0.950) / values.Length);
119
uint b_width = (uint) x_step;
120
uint b_height = (uint) (Height - 2);
122
int x = (int) (Margin*0.5f + x_step);
123
int y = (int) (Height * 0.5)+2;
125
foreach (AlphabetChars key in values) {
126
buttons[key] = new AlphabetButton (b_width, b_height, key);
127
buttons[key].ButtonReleaseEvent += HandleButtonReleaseEvent;
129
buttons[key].SetAnchorPoint ((float) buttons[key].Width*0.5f, (float) buttons[key].Height*0.5f);
130
buttons[key].SetPosition (x, y);
136
#region Event Handling
137
protected void HandleButtonReleaseEvent (object o, ButtonReleaseEventArgs args)
139
if (o is AlphabetButton) {
140
InvokeLetterClicked ((o as AlphabetButton).Letter);
10
public class AlphabetEventArgs : EventArgs
12
protected AlphabetChars letter = AlphabetChars.unknown;
13
public AlphabetChars Letter {
14
get { return letter; }
17
public AlphabetEventArgs (AlphabetChars letter) : base ()
24
public class AlphabetBar : Clutter.Group
28
public event EventHandler<AlphabetEventArgs> LetterClicked;
29
protected void InvokeLetterClicked (AlphabetChars letter)
31
if (LetterClicked!=null) LetterClicked (this, new AlphabetEventArgs (letter));
36
protected CairoTexture background;
38
protected Dictionary<AlphabetChars, AlphabetButton> buttons = new Dictionary<AlphabetChars, AlphabetButton>(Enum.GetValues(typeof(AlphabetChars)).Length);
39
public AlphabetButton this [AlphabetChars index] {
40
get { return buttons[index]; }
43
protected double Margin {
44
get { return Width * 0.075; }
49
#region Initialisation
50
public AlphabetBar (uint width, uint height)
52
this.SetSize (width, height);
60
protected virtual void InitBackground ()
62
background = new CairoTexture ((uint) Width,(uint) Height);
69
protected virtual void SetupBackground ()
72
Cairo.Context context = background.Create ();
75
double hlwidth = lwidth*0.5;
77
double margin = Margin;
80
context.MoveTo (-hlwidth, -hlwidth);
81
context.CurveTo (margin*0.33, -hlwidth,
82
margin*0.5, Height*0.4,
83
margin*0.5, Height*0.5);
84
context.CurveTo (margin*0.5, Height*0.6,
85
margin*0.66, Height-hlwidth,
86
margin-hlwidth, Height-hlwidth);
90
context.LineTo (Width-margin-hlwidth, Height-hlwidth);
93
context.CurveTo (Width-margin*0.66, Height - hlwidth,
94
Width-margin*0.5, Height*0.6,
95
Width-margin*0.5, Height*0.5);
96
context.CurveTo (Width-margin*0.5, Height*0.4,
97
Width-margin*0.33, -hlwidth,
98
Width-hlwidth, -hlwidth);
101
context.LineTo (-hlwidth, -hlwidth);
102
context.ClosePath ();
104
context.LineWidth = lwidth;
105
context.SetSourceRGBA (1.0, 1.0, 1.0, 1.0);
106
context.StrokePreserve ();
107
context.SetSourceRGBA (1.0, 1.0, 1.0, 0.10);
110
((IDisposable) context.Target).Dispose();
111
((IDisposable) context).Dispose();
114
protected virtual void InitButtons ()
116
Array values = Enum.GetValues(typeof(AlphabetChars));
118
int x_step = (int) ((Width * 0.950) / values.Length);
119
uint b_width = (uint) x_step;
120
uint b_height = (uint) (Height - 2);
122
int x = (int) (Margin*0.5f + x_step);
123
int y = (int) (Height * 0.5)+2;
125
foreach (AlphabetChars key in values) {
126
buttons[key] = new AlphabetButton (b_width, b_height, key);
127
buttons[key].ButtonReleaseEvent += HandleButtonReleaseEvent;
129
buttons[key].SetAnchorPoint ((float) buttons[key].Width*0.5f, (float) buttons[key].Height*0.5f);
130
buttons[key].SetPosition (x, y);
136
#region Event Handling
137
protected void HandleButtonReleaseEvent (object o, ButtonReleaseEventArgs args)
139
if (o is AlphabetButton) {
140
InvokeLetterClicked ((o as AlphabetButton).Letter);