juce_Application.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. JUCEApplication::JUCEApplication() {}
  18. JUCEApplication::~JUCEApplication() {}
  19. //==============================================================================
  20. JUCEApplication* JUCE_CALLTYPE JUCEApplication::getInstance() noexcept
  21. {
  22. return dynamic_cast <JUCEApplication*> (JUCEApplicationBase::getInstance());
  23. }
  24. bool JUCEApplication::moreThanOneInstanceAllowed() { return true; }
  25. void JUCEApplication::anotherInstanceStarted (const String&) {}
  26. void JUCEApplication::suspended() {}
  27. void JUCEApplication::resumed() {}
  28. void JUCEApplication::systemRequestedQuit() { quit(); }
  29. void JUCEApplication::unhandledException (const std::exception*, const String&, int)
  30. {
  31. jassertfalse;
  32. }
  33. //==============================================================================
  34. ApplicationCommandTarget* JUCEApplication::getNextCommandTarget()
  35. {
  36. return nullptr;
  37. }
  38. void JUCEApplication::getAllCommands (Array<CommandID>& commands)
  39. {
  40. commands.add (StandardApplicationCommandIDs::quit);
  41. }
  42. void JUCEApplication::getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result)
  43. {
  44. if (commandID == StandardApplicationCommandIDs::quit)
  45. {
  46. result.setInfo (TRANS("Quit"),
  47. TRANS("Quits the application"),
  48. "Application", 0);
  49. result.defaultKeypresses.add (KeyPress ('q', ModifierKeys::commandModifier, 0));
  50. }
  51. }
  52. bool JUCEApplication::perform (const InvocationInfo& info)
  53. {
  54. if (info.commandID == StandardApplicationCommandIDs::quit)
  55. {
  56. systemRequestedQuit();
  57. return true;
  58. }
  59. return false;
  60. }
  61. //==============================================================================
  62. #if JUCE_MAC
  63. extern void juce_initialiseMacMainMenu();
  64. #endif
  65. bool JUCEApplication::initialiseApp()
  66. {
  67. if (JUCEApplicationBase::initialiseApp())
  68. {
  69. #if JUCE_MAC
  70. juce_initialiseMacMainMenu(); // (needs to get the app's name)
  71. #endif
  72. return true;
  73. }
  74. return false;
  75. }