The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_INITIALISATION_JUCEHEADER__
  19. #define __JUCE_INITIALISATION_JUCEHEADER__
  20. //==============================================================================
  21. /** Initialises Juce's GUI classes.
  22. If you're embedding Juce into an application that uses its own event-loop rather
  23. than using the START_JUCE_APPLICATION macro, call this function before making any
  24. Juce calls, to make sure things are initialised correctly.
  25. Note that if you're creating a Juce DLL for Windows, you may also need to call the
  26. Process::setCurrentModuleInstanceHandle() method.
  27. @see shutdownJuce_GUI()
  28. */
  29. JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI();
  30. /** Clears up any static data being used by Juce's GUI classes.
  31. If you're embedding Juce into an application that uses its own event-loop rather
  32. than using the START_JUCE_APPLICATION macro, call this function in your shutdown
  33. code to clean up any juce objects that might be lying around.
  34. @see initialiseJuce_GUI()
  35. */
  36. JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI();
  37. //==============================================================================
  38. /** A utility object that helps you initialise and shutdown Juce correctly
  39. using an RAII pattern.
  40. When an instance of this class is created, it calls initialiseJuce_GUI(),
  41. and when it's deleted, it calls shutdownJuce_GUI(), which lets you easily
  42. make sure that these functions are matched correctly.
  43. This class is particularly handy to use at the beginning of a console app's
  44. main() function, because it'll take care of shutting down whenever you return
  45. from the main() call.
  46. */
  47. class ScopedJuceInitialiser_GUI
  48. {
  49. public:
  50. /** The constructor simply calls initialiseJuce_GUI(). */
  51. ScopedJuceInitialiser_GUI() { initialiseJuce_GUI(); }
  52. /** The destructor simply calls shutdownJuce_GUI(). */
  53. ~ScopedJuceInitialiser_GUI() { shutdownJuce_GUI(); }
  54. };
  55. //==============================================================================
  56. /*
  57. To start a JUCE app, use this macro: START_JUCE_APPLICATION (AppSubClass) where
  58. AppSubClass is the name of a class derived from JUCEApplication.
  59. See the JUCEApplication class documentation (juce_Application.h) for more details.
  60. */
  61. #if JUCE_ANDROID
  62. #define START_JUCE_APPLICATION(AppClass) \
  63. juce::JUCEApplication* juce_CreateApplication() { return new AppClass(); }
  64. #else
  65. #if JUCE_WINDOWS
  66. #if defined (WINAPI) || defined (_WINDOWS_)
  67. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (HINSTANCE, HINSTANCE, const LPSTR, int)
  68. #elif defined (_UNICODE)
  69. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (void*, void*, const wchar_t*, int)
  70. #else
  71. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (void*, void*, const char*, int)
  72. #endif
  73. #define JUCE_MAIN_FUNCTION_ARGS
  74. #else
  75. #define JUCE_MAIN_FUNCTION int main (int argc, char* argv[])
  76. #define JUCE_MAIN_FUNCTION_ARGS argc, (const char**) argv
  77. #endif
  78. #define START_JUCE_APPLICATION(AppClass) \
  79. static juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); } \
  80. extern "C" JUCE_MAIN_FUNCTION \
  81. { \
  82. juce::JUCEApplication::createInstance = &juce_CreateApplication; \
  83. return juce::JUCEApplication::main (JUCE_MAIN_FUNCTION_ARGS); \
  84. }
  85. #endif
  86. #endif // __JUCE_INITIALISATION_JUCEHEADER__