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.

94 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. JUCE demo code - use at your own risk!
  4. ==============================================================================
  5. */
  6. #include "../JuceLibraryCode/JuceHeader.h"
  7. #include "StringDemoComponent.h"
  8. //==============================================================================
  9. class PluckedStringsDemoApplication : public JUCEApplication
  10. {
  11. public:
  12. //==============================================================================
  13. PluckedStringsDemoApplication() {}
  14. const String getApplicationName() override { return ProjectInfo::projectName; }
  15. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  16. bool moreThanOneInstanceAllowed() override { return true; }
  17. //==============================================================================
  18. void initialise (const String& /*commandLine*/) override
  19. {
  20. mainWindow = new MainWindow();
  21. }
  22. void shutdown() override
  23. {
  24. mainWindow = nullptr; // (deletes our window)
  25. }
  26. //==============================================================================
  27. void systemRequestedQuit() override
  28. {
  29. // This is called when the app is being asked to quit: you can ignore this
  30. // request and let the app carry on running, or call quit() to allow the app to close.
  31. quit();
  32. }
  33. void anotherInstanceStarted (const String& /*commandLine*/) override
  34. {
  35. // When another instance of the app is launched while this one is running,
  36. // this method is invoked, and the commandLine parameter tells you what
  37. // the other instance's command-line arguments were.
  38. }
  39. //==============================================================================
  40. class MainWindow : public DocumentWindow
  41. {
  42. public:
  43. MainWindow() : DocumentWindow (ProjectInfo::projectName,
  44. LookAndFeel::getDefaultLookAndFeel()
  45. .findColour (ResizableWindow::backgroundColourId),
  46. DocumentWindow::allButtons)
  47. {
  48. setUsingNativeTitleBar (true);
  49. setContentOwned (new StringDemoComponent(), true);
  50. setResizable (true, false);
  51. centreWithSize (getWidth(), getHeight());
  52. setVisible (true);
  53. }
  54. void closeButtonPressed() override
  55. {
  56. // This is called when the user tries to close this window. Here, we'll just
  57. // ask the app to quit when this happens, but you can change this to do
  58. // whatever you need.
  59. JUCEApplication::getInstance()->systemRequestedQuit();
  60. }
  61. /* Note: Be careful if you override any DocumentWindow methods - the base
  62. class uses a lot of them, so by overriding you might break its functionality.
  63. It's best to do all your work in your content component instead, but if
  64. you really have to override any DocumentWindow methods, make sure your
  65. subclass also calls the superclass's method.
  66. */
  67. private:
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  69. };
  70. private:
  71. ScopedPointer<MainWindow> mainWindow;
  72. };
  73. //==============================================================================
  74. // This macro generates the main() routine that launches the app.
  75. START_JUCE_APPLICATION (PluckedStringsDemoApplication)