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.

117 lines
3.9KB

  1. /*
  2. ==============================================================================
  3. Demonstration "Hello World" application in JUCE
  4. Copyright 2008 by Julian Storer.
  5. ==============================================================================
  6. */
  7. #include "../JuceLibraryCode/JuceHeader.h"
  8. #include "MainComponent.h"
  9. //==============================================================================
  10. /**
  11. This is the top-level window that we'll pop up. Inside it, we'll create and
  12. show a component from the MainComponent.cpp file (you can open this file using
  13. the Jucer to edit it).
  14. */
  15. class HelloWorldWindow : public DocumentWindow
  16. {
  17. public:
  18. //==============================================================================
  19. HelloWorldWindow()
  20. : DocumentWindow ("JUCE Hello World!",
  21. Colours::lightgrey,
  22. DocumentWindow::allButtons,
  23. true)
  24. {
  25. // Create an instance of our main content component, and add it to our window..
  26. setContentOwned (new MainComponent(), true);
  27. // Centre the window on the screen
  28. centreWithSize (getWidth(), getHeight());
  29. // And show it!
  30. setVisible (true);
  31. }
  32. ~HelloWorldWindow()
  33. {
  34. // (the content component will be deleted automatically, so no need to do it here)
  35. }
  36. //==============================================================================
  37. void closeButtonPressed() override
  38. {
  39. // When the user presses the close button, we'll tell the app to quit. This
  40. // HelloWorldWindow object will be deleted by the JUCEHelloWorldApplication class.
  41. JUCEApplication::quit();
  42. }
  43. };
  44. //==============================================================================
  45. /** This is the application object that is started up when Juce starts. It handles
  46. the initialisation and shutdown of the whole application.
  47. */
  48. class JUCEHelloWorldApplication : public JUCEApplication
  49. {
  50. public:
  51. //==============================================================================
  52. JUCEHelloWorldApplication() {}
  53. //==============================================================================
  54. void initialise (const String& commandLine) override
  55. {
  56. // For this demo, we'll just create the main window...
  57. helloWorldWindow = new HelloWorldWindow();
  58. /* ..and now return, which will fall into to the main event
  59. dispatch loop, and this will run until something calls
  60. JUCEAppliction::quit().
  61. In this case, JUCEAppliction::quit() will be called by the
  62. hello world window being clicked.
  63. */
  64. }
  65. void shutdown() override
  66. {
  67. // This method is where you should clear-up your app's resources..
  68. // The helloWorldWindow variable is a ScopedPointer, so setting it to a null
  69. // pointer will delete the window.
  70. helloWorldWindow = nullptr;
  71. }
  72. //==============================================================================
  73. const String getApplicationName() override
  74. {
  75. return "Hello World for JUCE";
  76. }
  77. const String getApplicationVersion() override
  78. {
  79. // The ProjectInfo::versionString value is automatically updated by the Jucer, and
  80. // can be found in the JuceHeader.h file that it generates for our project.
  81. return ProjectInfo::versionString;
  82. }
  83. bool moreThanOneInstanceAllowed() override
  84. {
  85. return true;
  86. }
  87. void anotherInstanceStarted (const String& commandLine) override
  88. {
  89. }
  90. private:
  91. ScopedPointer<HelloWorldWindow> helloWorldWindow;
  92. };
  93. //==============================================================================
  94. // This macro creates the application's main() function..
  95. START_JUCE_APPLICATION (JUCEHelloWorldApplication)