Controls.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include "precompiled.h"
  28. #include <Rocket/Controls/Lua/Controls.h>
  29. #include <Rocket/Core/Lua/LuaType.h>
  30. #include <Rocket/Core/Lua/lua.hpp>
  31. #include <Rocket/Core/Lua/Interpreter.h>
  32. #include <Rocket/Core/Log.h>
  33. #include "SelectOptionsProxy.h"
  34. #include "DataFormatter.h"
  35. #include "DataSource.h"
  36. #include "ElementForm.h"
  37. #include "ElementFormControl.h"
  38. #include "ElementFormControlSelect.h"
  39. #include "ElementFormControlDataSelect.h"
  40. #include "ElementFormControlInput.h"
  41. #include "ElementFormControlTextArea.h"
  42. #include "ElementDataGrid.h"
  43. #include "ElementDataGridRow.h"
  44. #include "ElementTabSet.h"
  45. using Rocket::Core::Lua::LuaType;
  46. namespace Rocket {
  47. namespace Controls {
  48. namespace Lua {
  49. //This will define all of the types from RocketControls for Lua. There is not a
  50. //corresponding function for types of RocketCore, because they are defined automatically
  51. //when the Interpreter starts.
  52. void RegisterTypes(lua_State* L)
  53. {
  54. if(Rocket::Core::Lua::Interpreter::GetLuaState() == NULL)
  55. {
  56. Rocket::Core::Log::Message(Rocket::Core::Log::LT_ERROR,
  57. "In Rocket::Controls::Lua::RegisterTypes: Tried to register the \'Controls\' types for Lua without first initializing the Interpreter.");
  58. return;
  59. }
  60. LuaType<ElementForm>::Register(L);
  61. LuaType<ElementFormControl>::Register(L);
  62. //Inherits from ElementFormControl
  63. LuaType<ElementFormControlSelect>::Register(L);
  64. LuaType<ElementFormControlDataSelect>::Register(L);
  65. LuaType<ElementFormControlInput>::Register(L);
  66. LuaType<ElementFormControlTextArea>::Register(L);
  67. LuaType<DataFormatter>::Register(L);
  68. LuaType<DataSource>::Register(L);
  69. LuaType<ElementDataGrid>::Register(L);
  70. LuaType<ElementDataGridRow>::Register(L);
  71. LuaType<ElementTabSet>::Register(L);
  72. //proxy tables
  73. LuaType<SelectOptionsProxy>::Register(L);
  74. }
  75. }
  76. }
  77. }