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.

114 lines
4.3KB

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