Context.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef ROCKETCORELUACONTEXT_H
  28. #define ROCKETCORELUACONTEXT_H
  29. /*
  30. This defines a Context type in the Lua global namespace
  31. //methods
  32. noreturn Context:AddEventListener(string event, function | string listener, [Element element, bool capture]) --see note at the bottom
  33. noreturn Context:AddMouseCursor(Document cursor_document)
  34. Document Context:CreateDocument([string tag]) --tag defaults to "body"
  35. Document Context:LoadDocument(string path)
  36. Document Context:LoadMouseCursor(string path)
  37. bool Context:Render()
  38. noreturn Context:ShowMouseCursor(bool show)
  39. noreturn Context:UnloadAllDocuments()
  40. noreturn Context:UnloadAllMouseCursors()
  41. noreturn Context:UnloadDocument(Document doc)
  42. noreturn Context:UnloadMouseCursor(string name)
  43. bool Context:Update()
  44. //getters
  45. Vector2i Context.dimensions
  46. {} where key=string id,value=Document Context.documents
  47. Element Context.focus_element
  48. Element Context.hover_element
  49. string Context.name
  50. Element Context.root_element
  51. //setters
  52. Context.dimensions = Vector2i
  53. --note 1
  54. --[[
  55. Context:AddEventListener has 2 'unusuals'. The first is that the 2nd argument can be either a string or a function;
  56. see footnote 1 in Element.h for more info
  57. The second is the optional parameters. If you pass in an element (anything not nil), then it will actually call
  58. element->AddEventListener and will call context->AddEventListener otherwise. capture will default to false
  59. ]]
  60. */
  61. #include <Rocket/Core/Lua/LuaType.h>
  62. #include <Rocket/Core/Lua/lua.hpp>
  63. #include <Rocket/Core/Context.h>
  64. namespace Rocket {
  65. namespace Core {
  66. namespace Lua {
  67. template<> void ExtraInit<Context>(lua_State* L, int metatable_index);
  68. //methods
  69. int ContextAddEventListener(lua_State* L, Context* obj);
  70. int ContextAddMouseCursor(lua_State* L, Context* obj);
  71. int ContextCreateDocument(lua_State* L, Context* obj);
  72. int ContextLoadDocument(lua_State* L, Context* obj);
  73. int ContextLoadMouseCursor(lua_State* L, Context* obj);
  74. int ContextRender(lua_State* L, Context* obj);
  75. int ContextShowMouseCursor(lua_State* L, Context* obj);
  76. int ContextUnloadAllDocuments(lua_State* L, Context* obj);
  77. int ContextUnloadAllMouseCursors(lua_State* L, Context* obj);
  78. int ContextUnloadDocument(lua_State* L, Context* obj);
  79. int ContextUnloadMouseCursor(lua_State* L, Context* obj);
  80. int ContextUpdate(lua_State* L, Context* obj);
  81. //getters
  82. int ContextGetAttrdimensions(lua_State* L);
  83. int ContextGetAttrdocuments(lua_State* L);
  84. int ContextGetAttrfocus_element(lua_State* L);
  85. int ContextGetAttrhover_element(lua_State* L);
  86. int ContextGetAttrname(lua_State* L);
  87. int ContextGetAttrroot_element(lua_State* L);
  88. //setters
  89. int ContextSetAttrdimensions(lua_State* L);
  90. RegType<Context> ContextMethods[];
  91. luaL_reg ContextGetters[];
  92. luaL_reg ContextSetters[];
  93. LUATYPEDECLARE(Context)
  94. }
  95. }
  96. }
  97. #endif