1 // Andreas Kirsch Gecko item (to test it)
3 CLASS(Gecko) EXTENDS(Item)
4 METHOD(Gecko, configureBrowser, void( entity, string ) )
5 METHOD(Gecko, draw, void(entity))
6 METHOD(Gecko, keyDown, float(entity, float, float, float))
7 METHOD(Gecko, keyUp, float(entity, float, float, float))
8 METHOD(Gecko, mouseMove, float(entity, vector))
9 METHOD(Gecko, mouseDrag, float(entity, vector))
10 METHOD(Gecko, resizeNotify, void(entity, vector, vector, vector, vector))
11 ATTRIB(Gecko, texturePath, string, string_null )
12 ATTRIB(Gecko, textureExtent, vector, '0 0 0')
17 // define static members
18 float _gecko_instanceNumber;
20 void Gecko_configureBrowser( entity me, string URI ) {
23 //create a new gecko object if needed
24 if( !me.texturePath ) {
25 me.texturePath = strzone( strcat( "_dynamic/gecko/menu/", ftos( _gecko_instanceNumber ) ) );
26 _gecko_instanceNumber+=1;
27 // TODO: add error checks
28 gecko_create( me.texturePath );
30 gecko_navigate( me.texturePath, URI );
33 void Gecko_draw(entity me)
37 if( me.texturePath ) {
38 /* The gecko browser is actually only drawn to a part of the
39 texture. Correct scaling so that part fills up the whole
41 drawSize_x = 1.0 / me.textureExtent_x;
42 drawSize_y = 1.0 / me.textureExtent_y;
43 draw_Picture( '0 0 0', strcat( "/", me.texturePath ),
44 drawSize, '1 1 1', 1.0 );
46 local vector fontsize;
47 fontsize_x = fontsize_y = 1.0 / 30.0;
49 draw_Text( '0 0 0', _("Browser not initialized!"), fontsize, '1 1 1', 1.0, 0 );
53 float Gecko_keyDown(entity me, float scan, float ascii, float shift)
55 if( scan == K_ESCAPE ) {
59 return gecko_keyevent( me.texturePath, ascii, GECKO_BUTTON_DOWN );
61 return gecko_keyevent( me.texturePath, scan, GECKO_BUTTON_DOWN );
64 float Gecko_keyUp(entity me, float scan, float ascii, float shift)
67 return gecko_keyevent( me.texturePath, ascii, GECKO_BUTTON_UP );
69 return gecko_keyevent( me.texturePath, scan, GECKO_BUTTON_UP );
72 float Gecko_mouseMove(entity me, vector pos)
74 gecko_mousemove( me.texturePath, pos_x, pos_y );
78 float Gecko_mouseDrag(entity me, vector pos)
80 gecko_mousemove( me.texturePath, pos_x, pos_y );
84 void Gecko_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
86 SUPER(Gecko).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
87 gecko_resize( me.texturePath, absSize_x, absSize_y );
88 me.textureExtent = gecko_get_texture_extent( me.texturePath );
91 string toStringGecko(entity me)
93 return me.texturePath;