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.

123 lines
4.7KB

  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. @see ScopedJuceInitialiser_NonGUI
  47. */
  48. class ScopedJuceInitialiser_GUI
  49. {
  50. public:
  51. /** The constructor simply calls initialiseJuce_GUI(). */
  52. ScopedJuceInitialiser_GUI() { initialiseJuce_GUI(); }
  53. /** The destructor simply calls shutdownJuce_GUI(). */
  54. ~ScopedJuceInitialiser_GUI() { shutdownJuce_GUI(); }
  55. };
  56. //==============================================================================
  57. /*
  58. To start a JUCE app, use this macro: START_JUCE_APPLICATION (AppSubClass) where
  59. AppSubClass is the name of a class derived from JUCEApplication.
  60. See the JUCEApplication class documentation (juce_Application.h) for more details.
  61. */
  62. #if JUCE_ANDROID
  63. #define START_JUCE_APPLICATION(AppClass) \
  64. juce::JUCEApplication* juce_CreateApplication() { return new AppClass(); }
  65. #elif JUCE_WINDOWS && defined (WINAPI)
  66. #define START_JUCE_APPLICATION(AppClass) \
  67. static juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); } \
  68. int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \
  69. { \
  70. juce::JUCEApplication::createInstance = &juce_CreateApplication; \
  71. return juce::JUCEApplication::main(); \
  72. }
  73. #elif JUCE_WINDOWS
  74. #define START_JUCE_APPLICATION(AppClass) \
  75. static juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); } \
  76. int __stdcall WinMain (void*, void*, const char*, int) \
  77. { \
  78. juce::JUCEApplication::createInstance = &juce_CreateApplication; \
  79. return juce::JUCEApplication::main(); \
  80. }
  81. #else
  82. #define START_JUCE_APPLICATION(AppClass) \
  83. static juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); } \
  84. int main (int argc, char* argv[]) \
  85. { \
  86. juce::JUCEApplication::createInstance = &juce_CreateApplication; \
  87. return juce::JUCEApplication::main (argc, (const char**) argv); \
  88. }
  89. #endif
  90. #endif // __JUCE_INITIALISATION_JUCEHEADER__