root/branches/iteration3/xinf/ony/Root.hx

Revision 754, 1.2 kB (checked in by dan, 2 years ago)

ony: Root.children; Crop();
Document.load/.instantiate.

Line 
1 package xinf.ony;
2
3 import Xinf;
4 import xinf.event.EventKind;
5 import xinf.event.Event;
6
7 class Root {
8     private static var mRoot:Document;
9        
10     public static var children(get_children,null) :Iterator<Element>;
11         static function get_children() :Iterator<Element> {
12                 return cast mRoot.children;
13         }
14
15         private static function getRoot() :Document {
16                 if( mRoot==null ) {
17                         var r = new xinf.ony.erno.Root();
18                         mRoot = new Document();
19                         r.attach( mRoot );
20                 }
21                 return mRoot;
22         }
23        
24     public static function attach( o:Element, ?after:Element ) :Void {
25                 getRoot().attach( o, after );
26         }
27        
28     public static function detach( o:Element ) :Void {
29                 getRoot().detach( o );
30         }
31
32     public static function addEventListener<T>( type :EventKind<T>, h :T->Void ) :T->Void {
33         return xinf.erno.Runtime.runtime.addEventListener(type,h);
34     }
35    
36     public static function removeEventListener<T>( type :EventKind<T>, h :T->Void ) :Bool {
37         return xinf.erno.Runtime.runtime.removeEventListener(type,h);
38     }
39        
40     public static function postEvent<T>( e : Event<T>, ?pos:haxe.PosInfos ) :Void {
41             return xinf.erno.Runtime.runtime.postEvent(e,pos);
42     }
43
44     public static function main() {
45         xinf.erno.Runtime.runtime.run();
46     }
47
48 }
Note: See TracBrowser for help on using the browser.