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.

134 lines
4.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #include "../JuceLibraryCode/JuceHeader.h"
  20. #include "MainComponent.h"
  21. //==============================================================================
  22. /**
  23. This is the top-level window that we'll pop up. Inside it, we'll create and
  24. show a component from the MainComponent.cpp file (you can open this file using
  25. the Jucer to edit it).
  26. */
  27. class HelloWorldWindow : public DocumentWindow
  28. {
  29. public:
  30. //==============================================================================
  31. HelloWorldWindow()
  32. : DocumentWindow ("JUCE Hello World!",
  33. LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId),
  34. DocumentWindow::allButtons,
  35. true)
  36. {
  37. // Create an instance of our main content component, and add it to our window..
  38. setContentOwned (new MainComponent(), true);
  39. // Centre the window on the screen
  40. centreWithSize (getWidth(), getHeight());
  41. // And show it!
  42. setVisible (true);
  43. }
  44. ~HelloWorldWindow()
  45. {
  46. // (the content component will be deleted automatically, so no need to do it here)
  47. }
  48. //==============================================================================
  49. void closeButtonPressed() override
  50. {
  51. // When the user presses the close button, we'll tell the app to quit. This
  52. // HelloWorldWindow object will be deleted by the JUCEHelloWorldApplication class.
  53. JUCEApplication::quit();
  54. }
  55. };
  56. //==============================================================================
  57. /** This is the application object that is started up when Juce starts. It handles
  58. the initialisation and shutdown of the whole application.
  59. */
  60. class JUCEHelloWorldApplication : public JUCEApplication
  61. {
  62. public:
  63. //==============================================================================
  64. JUCEHelloWorldApplication() {}
  65. //==============================================================================
  66. void initialise (const String& commandLine) override
  67. {
  68. // For this demo, we'll just create the main window...
  69. helloWorldWindow = new HelloWorldWindow();
  70. /* ..and now return, which will fall into to the main event
  71. dispatch loop, and this will run until something calls
  72. JUCEAppliction::quit().
  73. In this case, JUCEAppliction::quit() will be called by the
  74. hello world window being clicked.
  75. */
  76. }
  77. void shutdown() override
  78. {
  79. // This method is where you should clear-up your app's resources..
  80. // The helloWorldWindow variable is a ScopedPointer, so setting it to a null
  81. // pointer will delete the window.
  82. helloWorldWindow = nullptr;
  83. }
  84. //==============================================================================
  85. const String getApplicationName() override
  86. {
  87. return "Hello World for JUCE";
  88. }
  89. const String getApplicationVersion() override
  90. {
  91. // The ProjectInfo::versionString value is automatically updated by the Jucer, and
  92. // can be found in the JuceHeader.h file that it generates for our project.
  93. return ProjectInfo::versionString;
  94. }
  95. bool moreThanOneInstanceAllowed() override
  96. {
  97. return true;
  98. }
  99. void anotherInstanceStarted (const String& commandLine) override
  100. {
  101. }
  102. private:
  103. ScopedPointer<HelloWorldWindow> helloWorldWindow;
  104. };
  105. //==============================================================================
  106. // This macro creates the application's main() function..
  107. START_JUCE_APPLICATION (JUCEHelloWorldApplication)