PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/test/Test.hx

http://github.com/blackdog66/bdog-gtk
Haxe | 57 lines | 45 code | 12 blank | 0 comment | 0 complexity | 6f5c904b491848c27441af218397ba15 MD5 | raw file
 1
 2package test;
 3
 4import gtk.Model;
 5import gtk.Gtk;
 6import ui.Ui;
 7using ui.ButtonTools;
 8using ui.EventTools;
 9
10class Test {
11
12  public static function
13  main() {
14
15    Ui.init(50001);
16    var
17      g = Ui.fromFile("fs.glade"),
18      win = Ui.button(g,"window1"),
19      btn1 = Ui.button(g,"button1"),
20      btn2 = Ui.button(g,"button2"),
21      btn3 = Ui.button(g,"button3");
22    
23    btn1.label("this sets!");
24
25    btn2.event(clicked,function(w:Widget,e:Event) {
26        trace("ok this works ");
27      });
28    btn2.event(enter,function(w:Widget,e:Event) {
29        trace("entering btn2");
30      });
31    btn3.event(clicked,function(w:Widget,e:Event) {
32        btn2.removeEvent(enter);
33      });
34    
35    ui.EventTools.poll(win);
36  }
37
38
39  public static
40  function simple() {
41    
42    var win = Gtk.windowNew(0);
43    Gtk.windowSetTitle(win,"Nice");
44    Gtk.windowSetDefaultSize(win,500,500);
45    Gtk.windowSetPosition(win,1);
46    var tbl = Gtk.tableNew(30,30,true);
47    Gtk.containerAdd(win,tbl);
48    var btn1 = Gtk.buttonNewWithLabel("Exit");
49    Gtk.tableAttachDefaults(tbl,btn1,17,28,20,25);
50    var btn2 = Gtk.buttonNewWithLabel("Print Text");
51    Gtk.tableAttachDefaults(tbl,btn2,2,13,20,25);
52    var entry = Gtk.entryNew();
53    Gtk.tableAttachDefaults(tbl,entry,2,28,5,15);
54    Gtk.widgetShowAll(win);
55    
56  }
57}