Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/ceguilua-0.6.1/ceguilua/CEGUILuaFunctor.h @ 2256

Last change on this file since 2256 was 1810, checked in by rgrieder, 16 years ago

merged ceguilua branch back to trunk

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/***********************************************************************
2    filename: CEGUILuaFunctor.h
3    created:  Thu Jan 26 2006
4    author:   Tomas Lindquist Olsen <tomas@famolsen.dk>
5
6    purpose:  Defines interface for LuaFunctor class
7*************************************************************************/
8/***************************************************************************
9 *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10 *
11 *   Permission is hereby granted, free of charge, to any person obtaining
12 *   a copy of this software and associated documentation files (the
13 *   "Software"), to deal in the Software without restriction, including
14 *   without limitation the rights to use, copy, modify, merge, publish,
15 *   distribute, sublicense, and/or sell copies of the Software, and to
16 *   permit persons to whom the Software is furnished to do so, subject to
17 *   the following conditions:
18 *
19 *   The above copyright notice and this permission notice shall be
20 *   included in all copies or substantial portions of the Software.
21 *
22 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 *   OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30#ifndef _CEGUILuaFunctor_h_
31#define _CEGUILuaFunctor_h_
32
33#include "CEGUIEventSet.h"
34#include "CEGUIScriptWindowHelper.h"
35
36struct lua_State;
37
38// Start of CEGUI namespace section
39namespace CEGUI
40{
41
42// forward declaration
43class LuaScriptModule;
44
45/*!
46\brief
47    Functor class used for subscribing Lua functions to CEGUI events
48*/
49class LuaFunctor
50{
51public:
52    LuaFunctor(lua_State* state, int func, int selfIndex);
53    LuaFunctor(lua_State* state, const String& func, int selfIndex);
54    LuaFunctor(const LuaFunctor& cp);
55    ~LuaFunctor();
56
57    bool operator()(const EventArgs& args) const;
58
59    /*!
60    \brief
61        function used to subscribe any Lua function as event handler.
62        References using the Lua registry.
63        To be called from Lua only.
64    */
65    static Event::Connection SubscribeEvent(EventSet* self, const String& eventName, int funcIndex, int selfIndex, lua_State* L);
66
67    /*!
68    \brief
69        Pushes the Lua function named \param name on top of the Lua stack.
70        The name may contain '.' (dots) character for (nested) table values.
71    */
72    static void pushNamedFunction(lua_State* L, const String& name);
73
74private:
75    lua_State* L;
76    mutable int index;
77    int self;
78    mutable bool needs_lookup;
79    mutable String function_name;
80
81    friend class LuaScriptModule;
82};
83
84} // namespace CEGUI
85
86#endif // end of guard _CEGUILuaFunctor_h_
Note: See TracBrowser for help on using the repository browser.