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.

177 lines
7.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-7 by Raw Material Software ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the
  7. GNU General Public License, as published by the Free Software Foundation;
  8. either version 2 of the License, or (at your option) any later version.
  9. JUCE is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with JUCE; if not, visit www.gnu.org/licenses or write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. ------------------------------------------------------------------------------
  18. If you'd like to release a closed-source product which uses JUCE, commercial
  19. licenses are also available: visit www.rawmaterialsoftware.com/juce for
  20. more information.
  21. ==============================================================================
  22. */
  23. #include "jucedemo_headers.h"
  24. #include "MainDemoWindow.h"
  25. //==============================================================================
  26. class JUCEDemoApplication : public JUCEApplication
  27. {
  28. /* Important! NEVER embed objects directly inside your JUCEApplication class! Use
  29. ONLY pointers to objects, which you should create during the initialise() method
  30. (NOT in the constructor!) and delete in the shutdown() method (NOT in the
  31. destructor!)
  32. This is because the application object gets created before Juce has been properly
  33. initialised, so any embedded objects would also get constructed too soon.
  34. */
  35. MainDemoWindow* theMainWindow;
  36. public:
  37. //==============================================================================
  38. JUCEDemoApplication()
  39. : theMainWindow (0)
  40. {
  41. // NEVER do anything in here that could involve any Juce function being called
  42. // - leave all your startup tasks until the initialise() method.
  43. }
  44. ~JUCEDemoApplication()
  45. {
  46. // Your shutdown() method should already have done all the things necessary to
  47. // clean up this app object, so you should never need to put anything in
  48. // the destructor.
  49. // Making any Juce calls in here could be very dangerous...
  50. }
  51. //==============================================================================
  52. void initialise (const String& commandLine)
  53. {
  54. // just create the main window...
  55. theMainWindow = new MainDemoWindow();
  56. theMainWindow->centreWithSize (700, 600);
  57. theMainWindow->setVisible (true);
  58. // this little function just demonstrates a few system info calls
  59. Logger::outputDebugString (collectSomeSystemInfo());
  60. /* on return from this method, the app will go into its the main event
  61. dispatch loop, and this will run until something calls
  62. JUCEAppliction::quit().
  63. In this case, JUCEAppliction::quit() will be called by the
  64. demo window when the user clicks on its close button.
  65. */
  66. }
  67. void shutdown()
  68. {
  69. delete theMainWindow;
  70. theMainWindow = 0;
  71. }
  72. //==============================================================================
  73. const String getApplicationName()
  74. {
  75. return T("JUCE Demo");
  76. }
  77. const String getApplicationVersion()
  78. {
  79. return T("1.0");
  80. }
  81. bool moreThanOneInstanceAllowed()
  82. {
  83. return false;
  84. }
  85. void anotherInstanceStarted (const String& commandLine)
  86. {
  87. // This will get called if the user launches another copy of the app, but
  88. // there's nothing that the demo app needs to do here.
  89. }
  90. private:
  91. //==============================================================================
  92. // this little function just demonstrates a few system info calls
  93. static const String collectSomeSystemInfo()
  94. {
  95. String systemInfo;
  96. systemInfo
  97. << T("Time and date: ") << Time::getCurrentTime().toString (true, true)
  98. << T("\nOperating system: ") << SystemStats::getOperatingSystemName()
  99. << T("\nCPU vendor: ") << SystemStats::getCpuVendor()
  100. << T("\nCPU speed: ") << SystemStats::getCpuSpeedInMegaherz() << T("MHz\n")
  101. << T("\nNumber of CPUs: ") << SystemStats::getNumCpus()
  102. << T("\nCPU has MMX: ") << (SystemStats::hasMMX() ? T("yes") : T("no"))
  103. << T("\nCPU has SSE: ") << (SystemStats::hasSSE() ? T("yes") : T("no"))
  104. << T("\nCPU has SSE2: ") << (SystemStats::hasSSE2() ? T("yes") : T("no"))
  105. << T("\nCPU has 3DNOW: ") << (SystemStats::has3DNow() ? T("yes") : T("no"))
  106. << T("\nMemory size: ") << SystemStats::getMemorySizeInMegabytes() << T("MB\n");
  107. int64 macAddresses[8];
  108. const int numAddresses = SystemStats::getMACAddresses (macAddresses, 8, false);
  109. for (int i = 0; i < numAddresses; ++i)
  110. {
  111. systemInfo
  112. << T("Found network card MAC address: ")
  113. << String::formatted (T("%02x-%02x-%02x-%02x-%02x-%02x\n"),
  114. 0xff & (int) (macAddresses [i] >> 40),
  115. 0xff & (int) (macAddresses [i] >> 32),
  116. 0xff & (int) (macAddresses [i] >> 24),
  117. 0xff & (int) (macAddresses [i] >> 16),
  118. 0xff & (int) (macAddresses [i] >> 8),
  119. 0xff & (int) macAddresses [i]);
  120. }
  121. systemInfo
  122. << T("Current executable file: ")
  123. << File::getSpecialLocation (File::currentExecutableFile).getFullPathName()
  124. << T("\nCurrent application file: ")
  125. << File::getSpecialLocation (File::currentApplicationFile).getFullPathName()
  126. << T("\nUser home directory: ")
  127. << File::getSpecialLocation (File::userHomeDirectory).getFullPathName()
  128. << T("\nUser documents directory: ")
  129. << File::getSpecialLocation (File::userDocumentsDirectory).getFullPathName()
  130. << T("\nUser application data directory: ")
  131. << File::getSpecialLocation (File::userApplicationDataDirectory).getFullPathName()
  132. << T("\nCommon application data directory: ")
  133. << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName()
  134. << T("\nTemp directory: ")
  135. << File::getSpecialLocation (File::tempDirectory).getFullPathName()
  136. << T("\n\n");
  137. return systemInfo;
  138. }
  139. };
  140. //==============================================================================
  141. /*
  142. This macro creates the application's main() function..
  143. */
  144. START_JUCE_APPLICATION (JUCEDemoApplication)