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.

138 lines
4.4KB

  1. /*
  2. ==============================================================================
  3. Demonstration "Hello World" application in JUCE
  4. Copyright 2008 by Julian Storer.
  5. ==============================================================================
  6. */
  7. #include "includes.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. /* Important! NEVER embed objects directly inside your JUCEApplication class! Use
  52. ONLY pointers to objects, which you should create during the initialise() method
  53. (NOT in the constructor!) and delete in the shutdown() method (NOT in the
  54. destructor!)
  55. This is because the application object gets created before Juce has been properly
  56. initialised, so any embedded objects would also get constructed too soon.
  57. */
  58. HelloWorldWindow* helloWorldWindow;
  59. public:
  60. //==============================================================================
  61. JUCEHelloWorldApplication()
  62. : helloWorldWindow (0)
  63. {
  64. // NEVER do anything in here that could involve any Juce function being called
  65. // - leave all your startup tasks until the initialise() method.
  66. }
  67. ~JUCEHelloWorldApplication()
  68. {
  69. // Your shutdown() method should already have done all the things necessary to
  70. // clean up this app object, so you should never need to put anything in
  71. // the destructor.
  72. // Making any Juce calls in here could be very dangerous...
  73. }
  74. //==============================================================================
  75. void initialise (const String& commandLine)
  76. {
  77. // just create the main window...
  78. helloWorldWindow = new HelloWorldWindow();
  79. /* ..and now return, which will fall into to the main event
  80. dispatch loop, and this will run until something calls
  81. JUCEAppliction::quit().
  82. In this case, JUCEAppliction::quit() will be called by the
  83. hello world window being clicked.
  84. */
  85. }
  86. void shutdown()
  87. {
  88. // clear up..
  89. if (helloWorldWindow != 0)
  90. delete helloWorldWindow;
  91. }
  92. //==============================================================================
  93. const String getApplicationName()
  94. {
  95. return T("Hello World for JUCE");
  96. }
  97. const String getApplicationVersion()
  98. {
  99. return T("1.0");
  100. }
  101. bool moreThanOneInstanceAllowed()
  102. {
  103. return true;
  104. }
  105. void anotherInstanceStarted (const String& commandLine)
  106. {
  107. }
  108. };
  109. //==============================================================================
  110. // This macro creates the application's main() function..
  111. START_JUCE_APPLICATION (JUCEHelloWorldApplication)