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.0KB

  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 (T("JUCE Hello World!"),
  21. Colours::lightgrey,
  22. DocumentWindow::allButtons,
  23. true)
  24. {
  25. // Create an instance of our main content component, and add it
  26. // to our window.
  27. MainComponent* const contentComponent = new MainComponent();
  28. setContentComponent (contentComponent, true, true);
  29. centreWithSize (getWidth(), getHeight());
  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()
  38. {
  39. // When the user presses the close button, we'll tell the app to quit. This
  40. // window will be deleted by our HelloWorldApplication::shutdown() method
  41. //
  42. JUCEApplication::quit();
  43. }
  44. };
  45. //==============================================================================
  46. /** This is the application object that is started up when Juce starts. It handles
  47. the initialisation and shutdown of the whole application.
  48. */
  49. class JUCEHelloWorldApplication : public JUCEApplication
  50. {
  51. public:
  52. //==============================================================================
  53. JUCEHelloWorldApplication()
  54. : helloWorldWindow (0)
  55. {
  56. }
  57. ~JUCEHelloWorldApplication()
  58. {
  59. }
  60. //==============================================================================
  61. void initialise (const String& commandLine)
  62. {
  63. // For this demo, we'll just create the main window...
  64. helloWorldWindow = new HelloWorldWindow();
  65. /* ..and now return, which will fall into to the main event
  66. dispatch loop, and this will run until something calls
  67. JUCEAppliction::quit().
  68. In this case, JUCEAppliction::quit() will be called by the
  69. hello world window being clicked.
  70. */
  71. }
  72. void shutdown()
  73. {
  74. // This method is where you should clear-up your app's resources..
  75. // The helloWorldWindow variable is a ScopedPointer, so setting it to a null
  76. // pointer will delete the window.
  77. helloWorldWindow = 0;
  78. }
  79. //==============================================================================
  80. const String getApplicationName()
  81. {
  82. return "Hello World for JUCE";
  83. }
  84. const String getApplicationVersion()
  85. {
  86. // The ProjectInfo::versionString value is automatically updated by the Jucer, and
  87. // can be found in the JuceHeader.h file that it generates for our project.
  88. return ProjectInfo::versionString;
  89. }
  90. bool moreThanOneInstanceAllowed()
  91. {
  92. return true;
  93. }
  94. void anotherInstanceStarted (const String& commandLine)
  95. {
  96. }
  97. private:
  98. ScopedPointer<HelloWorldWindow> helloWorldWindow;
  99. };
  100. //==============================================================================
  101. // This macro creates the application's main() function..
  102. START_JUCE_APPLICATION (JUCEHelloWorldApplication)