SystemInterface.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 ROCKETCORESYSTEMINTERFACE_H
  28. #define ROCKETCORESYSTEMINTERFACE_H
  29. #include "Log.h"
  30. #include "ReferenceCountable.h"
  31. #include "String.h"
  32. #include "Header.h"
  33. namespace Rocket {
  34. namespace Core {
  35. /**
  36. libRocket's System Interface.
  37. This class provides interfaces for Time, Translation and Logging.
  38. Time is the only required implementation.
  39. The default implemention of Translation doesn't translate anything
  40. The default implementation of logging logs Windows Debug Console,
  41. or Standard Error, depending on what platform you're using.
  42. @author Lloyd Weehuizen
  43. */
  44. class ROCKETCORE_API SystemInterface : public ReferenceCountable
  45. {
  46. public:
  47. SystemInterface();
  48. virtual ~SystemInterface();
  49. /// Get the number of seconds elapsed since the start of the application.
  50. /// @return Elapsed time, in seconds.
  51. virtual float GetElapsedTime() = 0;
  52. /// Translate the input string into the translated string.
  53. /// @param[out] translated Translated string ready for display.
  54. /// @param[in] input String as received from XML.
  55. /// @return Number of translations that occured.
  56. virtual int TranslateString(String& translated, const String& input);
  57. /// Joins the path of an RML or RCSS file with the path of a resource specified within the file.
  58. /// @param[out] translated_path The joined path.
  59. /// @param[in] document_path The path of the source document (including the file name).
  60. /// @param[in] path The path of the resource specified in the document.
  61. virtual void JoinPath(String& translated_path, const String& document_path, const String& path);
  62. /// Log the specified message.
  63. /// @param[in] type Type of log message, ERROR, WARNING, etc.
  64. /// @param[in] message Message to log.
  65. /// @return True to continue execution, false to break into the debugger.
  66. virtual bool LogMessage(Log::Type type, const String& message);
  67. /// Activate keyboard (for touchscreen devices)
  68. virtual void ActivateKeyboard();
  69. /// Deactivate keyboard (for touchscreen devices)
  70. virtual void DeactivateKeyboard();
  71. /// Called when this system interface is no longer required.
  72. virtual void Release();
  73. protected:
  74. virtual void OnReferenceDeactivate();
  75. };
  76. }
  77. }
  78. #endif