**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / Gtk / SWFGtkConv.cs
blob80d6f518d7b0f6221f5bfb060dfaeb839b15f18c
3 namespace System.Windows.Forms{
5 using Pango;
6 using System.Drawing;
8 internal class SWFGtkConv{
10 private SWFGtkConv(){}
12 public static MouseEventArgs MouseUpDownArgs (Gdk.EventButton ev){
13 uint boton = ev.button;
14 MouseButtons btn;
15 switch (boton){
16 case 1: btn = MouseButtons.Left;
17 break;
18 case 2: btn = MouseButtons.Middle;
19 break;
20 case 3: btn = MouseButtons.Right;
21 break;
23 //FIXME : Does it work? I've a typical wheelmouse.
24 case 4: btn = MouseButtons.XButton1;
25 break;
26 case 5: btn = MouseButtons.XButton2;
27 break;
28 default:
29 btn = MouseButtons.None;
30 break;
32 int clicks = 0;
33 switch (ev.type){
34 case Gdk.EventType.ButtonRelease:
35 case Gdk.EventType.ButtonPress: clicks = 1;
36 break;
37 case Gdk.EventType.TwoButtonPress:
38 case Gdk.EventType.ThreeButtonPress: clicks = 2;
39 break;
40 default:
41 clicks = 1;
42 break;
44 MouseEventArgs ret = new MouseEventArgs
45 (btn, clicks, (int)ev.x, (int)ev.y, 0);
46 return ret;
49 // TODO: && is a literal &
50 public static string AccelString (string st){
51 //return st.Replace("_", "__").Replace ("&", "_");
52 String s = st.Replace ("_", "__");
53 String ret = "";
54 int i=0;
56 while (i < s.Length){
57 if (s[i] == '&'){
58 if ((i < (s.Length -1)) && (s[i+1] == '&')){
59 i+=2;
60 ret +="&";
62 else{
63 i++;
64 ret += "_";
67 else{
68 ret += s[i++];
72 return ret;
76 // Font not implemented.
77 [MonoTODO]
78 public static Pango.FontDescription Font (System.Drawing.Font f){
79 FontDescription ret = new FontDescription();
80 //ret.Weight = (f.Bold) ? Pango.Weight.Bold : Pango.Weight.Normal;
81 //ret.Family = f.FontFamily.Name;
82 //ret.Style = (f.Italic) ? Pango.Style.Italic : Pango.Style.Normal;
84 return ret;