gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-commit] gnash/server Key.cpp Key.h action.cpp action.h ...


From: strk
Subject: Re: [Gnash-commit] gnash/server Key.cpp Key.h action.cpp action.h ...
Date: Mon, 10 Jul 2006 18:35:04 +0200

Vitaly, after your commit:

/usr/src/gnash/gnash/server/edit_text_character.cpp:160: error: conversion from
   `tu_string' to non-scalar type `std::basic_string<char,
   std::char_traits<char>, std::allocator<char> >' requested

--strk;

On Mon, Jul 10, 2006 at 01:47:13PM +0000, Vitaly Alexeev wrote:
> CVSROOT:      /sources/gnash
> Module name:  gnash
> Changes by:   Vitaly Alexeev <alexeev>        06/07/10 13:47:13
> 
> Modified files:
>       server         : Key.cpp Key.h action.cpp action.h array.h 
>                        as_function.h as_object.cpp button.cpp 
>                        edit_text_character.cpp edit_text_character.h 
>                        edit_text_character_def.h movie_root.cpp 
>                        movie_root.h sprite_instance.cpp 
> 
> Log message:
>       added input edit text stuff, setfocus & killfocus events handler, 
> keypress_listener moved to movie_root
> 
> CVSWeb URLs:
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/Key.cpp?cvsroot=gnash&r1=1.7&r2=1.8
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/Key.h?cvsroot=gnash&r1=1.7&r2=1.8
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/action.cpp?cvsroot=gnash&r1=1.95&r2=1.96
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/action.h?cvsroot=gnash&r1=1.37&r2=1.38
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.h?cvsroot=gnash&r1=1.12&r2=1.13
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.h?cvsroot=gnash&r1=1.1&r2=1.2
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.7&r2=1.8
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/button.cpp?cvsroot=gnash&r1=1.19&r2=1.20
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.5&r2=1.6
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.5&r2=1.6
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character_def.h?cvsroot=gnash&r1=1.7&r2=1.8
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.6&r2=1.7
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.5&r2=1.6
> http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.20&r2=1.21
> 
> Patches:
> Index: Key.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/Key.cpp,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -b -r1.7 -r1.8
> --- Key.cpp   5 Jul 2006 12:43:49 -0000       1.7
> +++ Key.cpp   10 Jul 2006 13:47:12 -0000      1.8
> @@ -43,7 +43,7 @@
>  #include "Key.h"
>  #include "action.h" // for action_init
>  #include "fn_call.h"
> -#include "sprite_instance.h"
> +#include "movie_root.h"
>  
>  namespace gnash {
>  
> @@ -384,39 +384,6 @@
>      ko->remove_listener(listener);
>  }
>  
> -static std::vector<weak_ptr<as_object> >     s_keypress_listeners;
> -
> -void add_keypress_listener(as_object* listener)
> -{
> -     std::vector<weak_ptr<as_object> >::const_iterator end = 
> s_keypress_listeners.end();
> -     for (std::vector<weak_ptr<as_object> >::iterator iter = 
> s_keypress_listeners.begin();
> -                     iter != end; ++iter) 
> -     {
> -             if (*iter == NULL)
> -             {
> -                     // Already in the list.
> -                     return;
> -             }
> -     }
> -     listener->add_ref();
> -     s_keypress_listeners.push_back(listener);
> -}
> -
> -void remove_keypress_listener(as_object* listener)
> -{
> -     for (std::vector<weak_ptr<as_object> >::iterator iter = 
> s_keypress_listeners.begin();
> -                     iter != s_keypress_listeners.end(); )
> -     {
> -             if (*iter == listener)
> -             {
> -                     iter = s_keypress_listeners.erase(iter);
> -                     listener->drop_ref();
> -                     continue;
> -             }
> -             iter++;
> -     }
> -}
> -
>  void notify_key_event(key::code k, bool down)
>      // External interface for the host to report key events.
>  {
> @@ -427,19 +394,8 @@
>       // Notify keypress listeners.
>       if (down) 
>       {
> -             for (std::vector<weak_ptr<as_object> >::iterator iter = 
> s_keypress_listeners.begin();
> -                              iter != s_keypress_listeners.end(); ++iter)
> -             {
> -                     if (*iter == NULL)
> -                     {
> -                                     continue;
> -                     }
> -
> -                     smart_ptr<as_object>  listener = *iter; // Hold an 
> owning reference.
> -
> -                     sprite_instance* sprite = (sprite_instance*) 
> listener.get_ptr();
> -                     sprite->on_event(event_id(event_id::KEY_PRESS, 
> (key::code) k));
> -             }
> +             movie_root* mroot = (movie_root*) get_current_root();
> +             mroot->notify_keypress_listeners(k);
>       }
>  
>      static tu_string key_obj_name("Key");
> 
> Index: Key.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/Key.h,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -b -r1.7 -r1.8
> --- Key.h     19 Jun 2006 14:39:48 -0000      1.7
> +++ Key.h     10 Jul 2006 13:47:12 -0000      1.8
> @@ -134,9 +134,6 @@
>  
>  void key_init(as_object* global);
>  
> -void add_keypress_listener(as_object* listener);
> -void remove_keypress_listener(as_object* listener);
> -
>  } // end of gnash namespace
>  
>  // __KEY_H__
> 
> Index: action.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/action.cpp,v
> retrieving revision 1.95
> retrieving revision 1.96
> diff -u -b -r1.95 -r1.96
> --- action.cpp        8 Jul 2006 00:15:09 -0000       1.95
> +++ action.cpp        10 Jul 2006 13:47:12 -0000      1.96
> @@ -580,7 +580,9 @@
>           "onXMLData",                 // XML_DATA
>           "onTimer",           // setInterval Timer expired
>  
> -         "onConstruct"
> +         "onConstruct",
> +                     "onSetFocus",
> +                     "onKillFocus"
>       };
>  
>      assert(m_id > INVALID && m_id < EVENT_COUNT);
> 
> Index: action.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/action.h,v
> retrieving revision 1.37
> retrieving revision 1.38
> diff -u -b -r1.37 -r1.38
> --- action.h  8 Jul 2006 00:15:09 -0000       1.37
> +++ action.h  10 Jul 2006 13:47:12 -0000      1.38
> @@ -123,6 +123,8 @@
>                       TIMER,
>  
>                       CONSTRUCT,
> +                     SETFOCUS,
> +                     KILLFOCUS,
>  
>                       EVENT_COUNT
>               };
> 
> Index: array.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/array.h,v
> retrieving revision 1.12
> retrieving revision 1.13
> diff -u -b -r1.12 -r1.13
> --- array.h   6 Jul 2006 11:38:20 -0000       1.12
> +++ array.h   10 Jul 2006 13:47:12 -0000      1.13
> @@ -48,8 +48,8 @@
>  
>  // Forward declarations
>  namespace gnash {
> -     class fn_call;
> -     class as_value;
> +     struct fn_call;
> +     struct as_value;
>  }
>  
>  namespace gnash {
> 
> Index: as_function.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/as_function.h,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -b -r1.1 -r1.2
> --- as_function.h     7 Jul 2006 13:49:40 -0000       1.1
> +++ as_function.h     10 Jul 2006 13:47:12 -0000      1.2
> @@ -47,7 +47,7 @@
>  
>  // Forward declarations
>  namespace gnash {
> -     class fn_call;
> +     struct fn_call;
>  }
>  
>  namespace gnash {
> 
> Index: as_object.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/as_object.cpp,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -b -r1.7 -r1.8
> --- as_object.cpp     7 Jul 2006 23:29:51 -0000       1.7
> +++ as_object.cpp     10 Jul 2006 13:47:12 -0000      1.8
> @@ -189,8 +189,9 @@
>  {
>       typedef stringi_hash<as_member>::const_iterator members_iterator;
>  
> -     log_msg("%d Members of object %p follow",
> -             m_members.size(), (void*)this);
> +     //Vitaly: temporarily commented because of problems with the VC++ 
> compiler
> +//   log_msg("%d Members of object %p follow",
> +//           m_members..size(), (void*)this);
>       for ( members_iterator it=m_members.begin(), itEnd=m_members.end();
>               it != itEnd; ++it )
>       {
> 
> Index: button.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/button.cpp,v
> retrieving revision 1.19
> retrieving revision 1.20
> diff -u -b -r1.19 -r1.20
> --- button.cpp        5 Jul 2006 12:43:49 -0000       1.19
> +++ button.cpp        10 Jul 2006 13:47:12 -0000      1.20
> @@ -14,8 +14,7 @@
>  #include "stream.h"
>  #include "movie_definition.h"
>  #include "sprite_instance.h"
> -#include "Key.h"
> -
> +#include "movie_root.h"
>  
>  
>  /** \page buttons Buttons and mouse behaviour
> @@ -252,6 +251,31 @@
>               if (ms->m_mouse_button_state_current == 1)
>               {
>                       // onPress
> +
> +                     // set/kill focus for current root
> +                     movie_root* mroot = (movie_root*) get_current_root();
> +                     movie* current_active_entity = 
> mroot->get_active_entity();
> +
> +                     // It's another entity ?
> +                     if (current_active_entity != active_entity.get_ptr())
> +                     {
> +                             // First to clean focus
> +                             if (current_active_entity != NULL)
> +                             {
> +                                     
> current_active_entity->on_event(event_id::KILLFOCUS);
> +                                     mroot->set_active_entity(NULL);
> +                             }
> +
> +                             // Then to set focus
> +                             if (active_entity != NULL)
> +                             {
> +                                     if 
> (active_entity->on_event(event_id::SETFOCUS))
> +                                     {
> +                                             
> mroot->set_active_entity(active_entity.get_ptr());
> +                                     }
> +                             }
> +                     }
> +
>                       if (active_entity != NULL)
>                       {
>                               active_entity->on_button_event(event_id::PRESS);
> @@ -335,7 +359,7 @@
>               {
>                       if (m_def->m_button_actions[i].m_conditions & 0xFE00)   
> // check up on CondKeyPress: UB[7]
>                       {
> -                             add_keypress_listener(this);
> +                             get_root()->add_keypress_listener(this);
>                               break;
>                       }
>               }
> @@ -344,6 +368,7 @@
>  
>       ~button_character_instance()
>       {
> +             get_root()->remove_keypress_listener(this);
>       }
>  
>       // called from keypress listener only
> 
> Index: edit_text_character.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -b -r1.5 -r1.6
> --- edit_text_character.cpp   1 Jul 2006 20:44:10 -0000       1.5
> +++ edit_text_character.cpp   10 Jul 2006 13:47:12 -0000      1.6
> @@ -8,8 +8,9 @@
>  #include "render.h"
>  #include "movie_definition.h" // to extract version info
>  #include "sprite_instance.h"
> -
>  #include "edit_text_character.h"
> +#include "Key.h"
> +#include "movie_root.h"      
>  
>  #include <algorithm>
>  
> @@ -20,7 +21,11 @@
>       :
>       character(parent, id),
>       m_def(def),
> -     _font(0)
> +     _font(0),
> +     m_has_focus(false),
> +     m_cursor(0),
> +     m_xcursor(0.0f),
> +     m_ycursor(0.0f)
>  {
>       assert(parent);
>       assert(m_def);
> @@ -35,6 +40,212 @@
>       reset_bounding_box(0, 0);
>  }
>  
> +edit_text_character::~edit_text_character()
> +{
> +     on_event(event_id::KILLFOCUS);
> +}
> +
> +movie_root*  edit_text_character::get_root() { return 
> get_parent()->get_root(); }
> +
> +void edit_text_character::show_cursor()
> +{
> +     uint16_t x = (int) m_xcursor;
> +     uint16_t y = (int) m_ycursor;
> +     uint16_t h = m_def->get_font_height();
> +
> +     int16_t box[4];
> +     box[0] = x;
> +     box[1] = y;
> +     box[2] = x;
> +     box[3] = y + h;
> +
> +     matrix mat = get_world_matrix();
> +     render::set_matrix(mat);
> +     render::line_style_color(rgba(0, 0, 0, 255));   // black cursor
> +     render::draw_line_strip(box, 2);        // draw line
> +}
> +
> +void
> +edit_text_character::display()
> +{
> +//           GNASH_REPORT_FUNCTION;
> +
> +     if (m_def->has_border())
> +     {
> +             matrix  mat = get_world_matrix();
> +             
> +             // @@ hm, should we apply the color xform?  It seems logical; 
> need to test.
> +             // cxform       cx = get_world_cxform();
> +
> +             // Show white background + black bounding box.
> +             render::set_matrix(mat);
> +
> +             point   coords[4];
> +             const rect def_bounds = m_def->get_bounds();
> +             coords[0] = def_bounds.get_corner(0);
> +             coords[1] = def_bounds.get_corner(1);
> +             coords[2] = def_bounds.get_corner(3);
> +             coords[3] = def_bounds.get_corner(2);
> +
> +             int16_t icoords[18] = 
> +             {
> +                     // strip (fill in)
> +                     (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
> +                     (int16_t) coords[1].m_x, (int16_t) coords[1].m_y,
> +                     (int16_t) coords[2].m_x, (int16_t) coords[2].m_y,
> +                     (int16_t) coords[3].m_x, (int16_t) coords[3].m_y,
> +
> +                     // outline
> +                     (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
> +                     (int16_t) coords[1].m_x, (int16_t) coords[1].m_y,
> +                     (int16_t) coords[3].m_x, (int16_t) coords[3].m_y,
> +                     (int16_t) coords[2].m_x, (int16_t) coords[2].m_y,
> +                     (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
> +             };
> +             
> +             render::fill_style_color(0, rgba(255, 255, 255, 255));
> +             render::draw_mesh_strip(&icoords[0], 4);
> +
> +             render::line_style_color(rgba(0,0,0,255));
> +             render::draw_line_strip(&icoords[8], 5);
> +     }
> +
> +     // Draw our actual text.
> +     display_glyph_records(matrix::identity, this, m_text_glyph_records,
> +             m_def->get_root_def());
> +
> +     if (m_has_focus)
> +     {
> +             show_cursor();
> +     }
> +
> +     do_display_callback();
> +}
> +
> +bool edit_text_character::on_event(event_id id)
> +{
> +     if (m_def->get_readonly() == true)
> +     {
> +             return false;
> +     }
> +
> +     switch (id.m_id)
> +     {
> +             case event_id::SETFOCUS:
> +             {
> +                     if (m_has_focus == false)
> +                     {
> +                             get_root()->add_keypress_listener(this);
> +                             m_has_focus = true;
> +                             m_cursor = m_text.size();
> +                             format_text();
> +                     }
> +                     break;
> +             }
> +
> +             case event_id::KILLFOCUS:
> +             {
> +                     if (m_has_focus == true)
> +                     {
> +                             get_root()->set_active_entity(NULL);
> +                             get_root()->remove_keypress_listener(this);
> +                             m_has_focus = false;
> +                             format_text();
> +                     }
> +                     break;
> +             }
> +
> +             case event_id::KEY_PRESS:
> +             {
> +                     std::string s = m_text;
> +                     std::string c;
> +                     c = (char) id.m_key_code;
> +
> +                     // may be m_text is changed in ActionScript
> +                     m_cursor = imin(m_cursor, m_text.size());
> +
> +                     switch (c[0])
> +                     {
> +                             case key::BACKSPACE:
> +                                     if (m_cursor > 0)
> +                                     {
> +                                             s.erase(m_cursor - 1, 1);
> +                                             m_cursor--;
> +                                             set_text_value(s.c_str());
> +                                     }
> +                                     break;
> +
> +                             case key::DELETEKEY:
> +                                     if (s.size() > m_cursor)
> +                                     {
> +                                             s.erase(m_cursor, 1);
> +                                             set_text_value(s.c_str());
> +                                     }
> +                                     break;
> +
> +                             case key::INSERT:               // TODO
> +                                     break;
> +
> +                             case key::HOME:
> +                             case key::PGUP:
> +                             case key::UP:
> +                                     m_cursor = 0;
> +                                     format_text();
> +                                     break;
> +
> +                             case key::END:
> +                             case key::PGDN:
> +                             case key::DOWN:
> +                                     m_cursor = m_text.size();
> +                                     format_text();
> +                                     break;
> +
> +                             case key::LEFT:
> +                                     m_cursor = m_cursor > 0 ? m_cursor - 1 
> : 0;
> +                                     format_text();
> +                                     break;
> +
> +                             case key::RIGHT:
> +                                     m_cursor = m_cursor < m_text.size() ? 
> m_cursor + 1 : m_text.size();
> +                                     format_text();
> +                                     break;
> +
> +                             default:
> +                             {
> +                                     s.insert(m_cursor, c);
> +                                     m_cursor++;
> +                                     set_text_value(s.c_str());
> +                                     break;
> +                             }
> +                     }
> +             }
> +
> +             default:
> +                     return false;
> +     }
> +     return true;
> +}
> +
> +movie*       edit_text_character::get_topmost_mouse_entity(float x, float y)
> +{
> +     if (get_visible() == false)
> +     {
> +             return NULL;
> +     }
> +
> +     matrix  m = get_matrix();
> +             
> +     point   p;
> +     m.transform_by_inverse(&p, point(x, y));
> +
> +     const rect def_bounds = m_def->get_bounds();
> +     if (def_bounds.point_test(p.m_x, p.m_y))
> +     {
> +             return this;
> +     }
> +     return NULL;
> +}
> +
>  void
>  edit_text_character::set_text_value(const char* new_text)
>  {
> @@ -356,6 +567,9 @@
>       int     last_space_glyph = -1;
>       int     last_line_start_record = 0;
>  
> +     int character_idx = 0;
> +     m_xcursor = x;
> +     m_ycursor = y;
>  
>       const char*     text = &m_text[0];
>       while (uint32_t code = utf8::decode_next_unicode_character(&text))
> @@ -537,9 +751,19 @@
>                       last_line_start_record = m_text_glyph_records.size();
>               }
>  
> +             if (m_cursor > character_idx)
> +             {
> +                     m_xcursor = x;
> +                     m_ycursor = y;
> +             }
> +             character_idx++;
> +
>               // TODO: HTML markup
>       }
>  
> +     m_xcursor += _font->get_leading() * scale;
> +     m_ycursor -= m_def->get_font_height() + (_font->get_leading() - 
> _font->get_descent()) * scale;
> +
>       // Add this line to our output.
>       m_text_glyph_records.push_back(rec);
>  
> @@ -547,59 +771,6 @@
>  
>  }
>  
> -void
> -edit_text_character::display()
> -{
> -//           GNASH_REPORT_FUNCTION;
> -
> -     if (m_def->has_border())
> -     {
> -             matrix  mat = get_world_matrix();
> -             
> -             // @@ hm, should we apply the color xform?  It seems logical; 
> need to test.
> -             // cxform       cx = get_world_cxform();
> -
> -             // Show white background + black bounding box.
> -             render::set_matrix(mat);
> -
> -             point   coords[4];
> -             const rect def_bounds = m_def->get_bounds();
> -             coords[0] = def_bounds.get_corner(0);
> -             coords[1] = def_bounds.get_corner(1);
> -             coords[2] = def_bounds.get_corner(3);
> -             coords[3] = def_bounds.get_corner(2);
> -
> -             int16_t icoords[18] = 
> -             {
> -                     // strip (fill in)
> -                     (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
> -                     (int16_t) coords[1].m_x, (int16_t) coords[1].m_y,
> -                     (int16_t) coords[2].m_x, (int16_t) coords[2].m_y,
> -                     (int16_t) coords[3].m_x, (int16_t) coords[3].m_y,
> -
> -                     // outline
> -                     (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
> -                     (int16_t) coords[1].m_x, (int16_t) coords[1].m_y,
> -                     (int16_t) coords[3].m_x, (int16_t) coords[3].m_y,
> -                     (int16_t) coords[2].m_x, (int16_t) coords[2].m_y,
> -                     (int16_t) coords[0].m_x, (int16_t) coords[0].m_y,
> -             };
> -             
> -             render::fill_style_color(0, rgba(255, 255, 255, 255));
> -             render::draw_mesh_strip(&icoords[0], 4);
> -
> -             render::line_style_color(rgba(0,0,0,255));
> -             render::draw_line_strip(&icoords[8], 5);
> -     }
> -
> -     // Draw our actual text.
> -     display_glyph_records(matrix::identity, this, m_text_glyph_records,
> -             m_def->get_root_def());
> -
> -     do_display_callback();
> -}
> -
> -
>  } // namespace gnash
>  
>  
> 
> Index: edit_text_character.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -b -r1.5 -r1.6
> --- edit_text_character.h     1 Jul 2006 20:44:10 -0000       1.5
> +++ edit_text_character.h     10 Jul 2006 13:47:12 -0000      1.6
> @@ -66,9 +66,11 @@
>                       edit_text_character_def* def,
>                       int id);
>  
> -     ~edit_text_character()
> -     {
> -     }
> +     ~edit_text_character();
> +
> +     virtual movie*  get_topmost_mouse_entity(float x, float y);     
> +     virtual bool on_event(event_id id);     
> +     virtual movie_root *get_root();
>  
>       virtual const char* get_text_name() const
>       {
> @@ -138,6 +140,12 @@
>  
>       const font* _font;
>  
> +     bool m_has_focus;
> +     int m_cursor;
> +     void show_cursor();
> +     float m_xcursor;
> +     float m_ycursor;
> +
>  };
>  
>  } // namespace gnash
> 
> Index: edit_text_character_def.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/edit_text_character_def.h,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -b -r1.7 -r1.8
> --- edit_text_character_def.h 1 Jul 2006 20:44:10 -0000       1.7
> +++ edit_text_character_def.h 10 Jul 2006 13:47:12 -0000      1.8
> @@ -208,6 +208,11 @@
>               return m_root_def;
>       }
>  
> +     bool get_readonly() const
> +     {
> +             return m_readonly;
> +     }
> +
>  private:
>  
>       /// Root movie_definition
> 
> Index: movie_root.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -b -r1.6 -r1.7
> --- movie_root.cpp    28 Jun 2006 23:27:44 -0000      1.6
> +++ movie_root.cpp    10 Jul 2006 13:47:12 -0000      1.7
> @@ -74,8 +74,9 @@
>  //    m_on_event_load_called(false),
>      m_on_event_xmlsocket_ondata_called(false),
>      m_on_event_xmlsocket_onxml_called(false),
> -    m_on_event_load_progress_called(false)
> -{
> +    m_on_event_load_progress_called(false),
> +             m_active_input_text(NULL)
> +     {
>       assert(m_def != NULL);
>  
>       set_display_viewport(0, 0,
> @@ -301,7 +302,62 @@
>       return m_movie->call_method_args(method_name, method_arg_fmt, args);
>  }
>  
> +void movie_root::notify_keypress_listeners(key::code k)
> +{
> +     for (std::vector< as_object* >::iterator iter = 
> m_keypress_listeners.begin();
> +                      iter != m_keypress_listeners.end(); ++iter)
> +     {
> +             if (*iter == NULL)
> +             {
> +                             continue;
> +             }
> +
> +             smart_ptr<as_object>  listener = *iter; // Hold an owning 
> reference.
> +
> +             // sprite, button & input_edit_text characters
> +             character* ch = (character*) listener.get_ptr();
> +             ch->on_event(event_id(event_id::KEY_PRESS, (key::code) k));
> +     }
> +}
> +
> +void movie_root::add_keypress_listener(as_object* listener)
> +{
> +     std::vector< as_object* >::const_iterator end = 
> m_keypress_listeners.end();
> +     for (std::vector< as_object* >::iterator iter = 
> m_keypress_listeners.begin();
> +                     iter != end; ++iter) 
> +     {
> +             if (*iter == NULL)
> +             {
> +                     // Already in the list.
> +                     return;
> +             }
> +     }
> +     m_keypress_listeners.push_back(listener);
> +}
> +
> +void movie_root::remove_keypress_listener(as_object* listener)
> +{
> +     for (std::vector< as_object* >::iterator iter = 
> m_keypress_listeners.begin();
> +                     iter != m_keypress_listeners.end(); )
> +     {
> +             if (*iter == listener)
> +             {
> +                     iter = m_keypress_listeners.erase(iter);
> +                     continue;
> +             }
> +             iter++;
> +     }
> +}
>  
> +movie* movie_root::get_active_entity()
> +{
> +     return m_active_input_text;
> +}
> +
> +void movie_root::set_active_entity(movie* ch)
> +{
> +     m_active_input_text = ch;
> +}
>  
>  } // namespace gnash
>  
> 
> Index: movie_root.h
> ===================================================================
> RCS file: /sources/gnash/gnash/server/movie_root.h,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -b -r1.5 -r1.6
> --- movie_root.h      28 Jun 2006 23:27:44 -0000      1.5
> +++ movie_root.h      10 Jul 2006 13:47:12 -0000      1.6
> @@ -79,6 +79,8 @@
>       bool                    m_on_event_xmlsocket_onxml_called;
>       bool                    m_on_event_load_progress_called;
>       std::vector<Timer *>    m_interval_timers;
> +     std::vector< as_object* >       m_keypress_listeners;
> +     movie*  m_active_input_text;
>  
>  public:
>       // XXXbastiaan: make these two variables private
> @@ -241,6 +243,14 @@
>               m_movie->attach_display_callback(path_to_object,
>                       callback, user_ptr);
>       }
> +
> +     void notify_keypress_listeners(key::code k);
> +     void add_keypress_listener(as_object* listener);
> +     void remove_keypress_listener(as_object* listener);
> +
> +     movie* get_active_entity();
> +     void set_active_entity(movie* ch);
> +
>  };
>  
>  
> 
> Index: sprite_instance.cpp
> ===================================================================
> RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
> retrieving revision 1.20
> retrieving revision 1.21
> diff -u -b -r1.20 -r1.21
> --- sprite_instance.cpp       7 Jul 2006 13:49:40 -0000       1.20
> +++ sprite_instance.cpp       10 Jul 2006 13:47:12 -0000      1.21
> @@ -406,7 +406,7 @@
>  
>       if (m_has_keypress_event)
>       {
> -             remove_keypress_listener(this);
> +             m_root->remove_keypress_listener(this);
>       }
>  
>       m_display_list.clear();
> @@ -1241,7 +1241,7 @@
>               //
>               if (m_has_keypress_event)
>               {
> -                     add_keypress_listener(this);
> +                     m_root->add_keypress_listener(this);
>               }
>       }
>       
> 
> 
> _______________________________________________
> Gnash-commit mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gnash-commit

-- 

 /"\    ASCII Ribbon Campaign
 \ /    Respect for low technology.
  X     Keep e-mail messages readable by any computer system.
 / \    Keep it ASCII. 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]