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.

123 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()
  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. }
  55. ~JUCEHelloWorldApplication()
  56. {
  57. }
  58. //==============================================================================
  59. void initialise (const String& commandLine)
  60. {
  61. // For this demo, we'll just create the main window...
  62. helloWorldWindow = new HelloWorldWindow();
  63. /* ..and now return, which will fall into to the main event
  64. dispatch loop, and this will run until something calls
  65. JUCEAppliction::quit().
  66. In this case, JUCEAppliction::quit() will be called by the
  67. hello world window being clicked.
  68. */
  69. }
  70. void shutdown()
  71. {
  72. // This method is where you should clear-up your app's resources..
  73. // The helloWorldWindow variable is a ScopedPointer, so setting it to a null
  74. // pointer will delete the window.
  75. helloWorldWindow = 0;
  76. }
  77. //==============================================================================
  78. const String getApplicationName()
  79. {
  80. return "Hello World for JUCE";
  81. }
  82. const String getApplicationVersion()
  83. {
  84. // The ProjectInfo::versionString value is automatically updated by the Jucer, and
  85. // can be found in the JuceHeader.h file that it generates for our project.
  86. return ProjectInfo::versionString;
  87. }
  88. bool moreThanOneInstanceAllowed()
  89. {
  90. return true;
  91. }
  92. void anotherInstanceStarted (const String& commandLine)
  93. {
  94. }
  95. private:
  96. ScopedPointer<HelloWorldWindow> helloWorldWindow;
  97. };
  98. //==============================================================================
  99. // This macro creates the application's main() function..
  100. START_JUCE_APPLICATION (JUCEHelloWorldApplication)