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.

127 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 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 __JUCER_APPLICATION_H_6595C2A8__
  19. #define __JUCER_APPLICATION_H_6595C2A8__
  20. #include "jucer_Headers.h"
  21. #include "ui/jucer_MainWindow.h"
  22. ApplicationCommandManager* commandManager = 0;
  23. //==============================================================================
  24. class JucerApplication : public JUCEApplication
  25. {
  26. public:
  27. //==============================================================================
  28. JucerApplication() {}
  29. ~JucerApplication() {}
  30. //==============================================================================
  31. void initialise (const String& commandLine)
  32. {
  33. /* Running a command-line of the form "Jucer --resave foobar.jucer" will try to load that
  34. jucer file and re-export all of its projects.
  35. */
  36. if (commandLine.startsWithIgnoreCase ("-resave ") || commandLine.startsWithIgnoreCase ("--resave "))
  37. {
  38. Project::resaveJucerFile (File::getCurrentWorkingDirectory()
  39. .getChildFile (commandLine.fromFirstOccurrenceOf (" ", false, false).unquoted()));
  40. quit();
  41. return;
  42. }
  43. commandManager = new ApplicationCommandManager();
  44. commandManager->registerAllCommandsForTarget (this);
  45. theMainWindow = new MainWindow();
  46. doExtraInitialisation();
  47. ImageCache::setCacheTimeout (30 * 1000);
  48. if (commandLine.trim().isNotEmpty() && ! commandLine.trim().startsWithChar ('-'))
  49. anotherInstanceStarted (commandLine);
  50. theMainWindow->reloadLastProject();
  51. theMainWindow->getLookAndFeel().setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
  52. }
  53. void shutdown()
  54. {
  55. theMainWindow = 0;
  56. OpenDocumentManager::deleteInstance();
  57. deleteAndZero (commandManager);
  58. }
  59. //==============================================================================
  60. void systemRequestedQuit()
  61. {
  62. if (theMainWindow == 0 || theMainWindow->closeCurrentProject())
  63. {
  64. theMainWindow = 0;
  65. StoredSettings::deleteInstance();
  66. quit();
  67. }
  68. }
  69. //==============================================================================
  70. const String getApplicationName()
  71. {
  72. return "The Jucer V" + getApplicationVersion();
  73. }
  74. const String getApplicationVersion()
  75. {
  76. return ProjectInfo::versionString;
  77. }
  78. bool moreThanOneInstanceAllowed()
  79. {
  80. #ifndef JUCE_LINUX
  81. return false;
  82. #else
  83. return true; //xxx should be false but doesn't work on linux..
  84. #endif
  85. }
  86. void anotherInstanceStarted (const String& commandLine)
  87. {
  88. if (theMainWindow != 0)
  89. theMainWindow->openFile (commandLine.unquoted());
  90. }
  91. virtual void doExtraInitialisation() {}
  92. private:
  93. ScopedPointer <MainWindow> theMainWindow;
  94. };
  95. #endif // __JUCER_APPLICATION_H_6595C2A8__