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.

205 lines
8.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #include "../JuceDemoHeader.h"
  18. static String getMacAddressList()
  19. {
  20. Array<MACAddress> macAddresses;
  21. MACAddress::findAllAddresses (macAddresses);
  22. String addressList;
  23. for (int i = 0; i < macAddresses.size(); ++i)
  24. addressList << " " << macAddresses[i].toString() << newLine;
  25. return addressList;
  26. }
  27. static String getFileSystemRoots()
  28. {
  29. Array<File> roots;
  30. File::findFileSystemRoots (roots);
  31. StringArray rootList;
  32. for (int i = 0; i < roots.size(); ++i)
  33. rootList.add (roots[i].getFullPathName());
  34. return rootList.joinIntoString (", ");
  35. }
  36. static String getIPAddressList()
  37. {
  38. Array<IPAddress> addresses;
  39. IPAddress::findAllAddresses (addresses);
  40. String addressList;
  41. for (int i = 0; i < addresses.size(); ++i)
  42. addressList << " " << addresses[i].toString() << newLine;
  43. return addressList;
  44. }
  45. static const char* getDisplayOrientation()
  46. {
  47. switch (Desktop::getInstance().getCurrentOrientation())
  48. {
  49. case Desktop::upright: return "Upright";
  50. case Desktop::upsideDown: return "Upside-down";
  51. case Desktop::rotatedClockwise: return "Rotated Clockwise";
  52. case Desktop::rotatedAntiClockwise: return "Rotated Anti-clockwise";
  53. default: jassertfalse; break;
  54. }
  55. return nullptr;
  56. }
  57. static String getDisplayInfo()
  58. {
  59. const Desktop::Displays& displays = Desktop::getInstance().getDisplays();
  60. String displayDesc;
  61. for (int i = 0; i < displays.displays.size(); ++i)
  62. {
  63. const Desktop::Displays::Display display = displays.displays.getReference(i);
  64. displayDesc
  65. << "Display " << (i + 1) << (display.isMain ? " (main)" : "") << ":" << newLine
  66. << " Total area: " << display.totalArea.toString() << newLine
  67. << " User area: " << display.userArea.toString() << newLine
  68. << " DPI: " << display.dpi << newLine
  69. << " Scale: " << display.scale << newLine
  70. << newLine;
  71. }
  72. displayDesc << "Orientation: " << getDisplayOrientation() << newLine;
  73. return displayDesc;
  74. }
  75. static String getAllSystemInfo()
  76. {
  77. String systemInfo;
  78. systemInfo
  79. << "Here are a few system statistics..." << newLine
  80. << newLine
  81. << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
  82. << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
  83. << "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine
  84. << newLine
  85. << "Operating system: " << SystemStats::getOperatingSystemName() << newLine
  86. << "Host name: " << SystemStats::getComputerName() << newLine
  87. << "Device type: " << SystemStats::getDeviceDescription() << newLine
  88. << "User logon name: " << SystemStats::getLogonName() << newLine
  89. << "Full user name: " << SystemStats::getFullUserName() << newLine
  90. << "User region: " << SystemStats::getUserRegion() << newLine
  91. << "User language: " << SystemStats::getUserLanguage() << newLine
  92. << "Display language: " << SystemStats::getDisplayLanguage() << newLine
  93. << newLine;
  94. systemInfo
  95. << "Number of CPUs: " << SystemStats::getNumCpus() << newLine
  96. << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
  97. << "CPU vendor: " << SystemStats::getCpuVendor() << newLine
  98. << "CPU speed: " << SystemStats::getCpuSpeedInMegaherz() << " MHz" << newLine
  99. << "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
  100. << "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
  101. << "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
  102. << "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
  103. << "CPU has SSSE3: " << (SystemStats::hasSSSE3() ? "yes" : "no") << newLine
  104. << "CPU has SSE4.1: " << (SystemStats::hasSSE41() ? "yes" : "no") << newLine
  105. << "CPU has SSE4.2: " << (SystemStats::hasSSE42() ? "yes" : "no") << newLine
  106. << "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
  107. << "CPU has AVX: " << (SystemStats::hasAVX() ? "yes" : "no") << newLine
  108. << "CPU has AVX2: " << (SystemStats::hasAVX2() ? "yes" : "no") << newLine
  109. << newLine;
  110. systemInfo
  111. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  112. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  113. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  114. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  115. << newLine;
  116. systemInfo
  117. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  118. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  119. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  120. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  121. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  122. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  123. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  124. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  125. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  126. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  127. << newLine;
  128. systemInfo
  129. << "File System roots: " << getFileSystemRoots() << newLine
  130. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  131. .getBytesFreeOnVolume()) << newLine
  132. << newLine
  133. << getDisplayInfo() << newLine
  134. << "Network IP addresses: " << newLine << getIPAddressList() << newLine
  135. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  136. DBG (systemInfo);
  137. return systemInfo;
  138. }
  139. class SystemInfoDemo : public Component
  140. {
  141. public:
  142. SystemInfoDemo()
  143. {
  144. addAndMakeVisible (resultsBox);
  145. resultsBox.setReadOnly (true);
  146. resultsBox.setMultiLine (true);
  147. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  148. resultsBox.setFont (Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
  149. resultsBox.setText (getAllSystemInfo());
  150. }
  151. void paint (Graphics& g) override
  152. {
  153. g.fillAll (Colour::greyLevel (0.93f));
  154. }
  155. void resized() override
  156. {
  157. resultsBox.setBounds (getLocalBounds().reduced (8));
  158. }
  159. private:
  160. TextEditor resultsBox;
  161. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo)
  162. };
  163. // This static object will register this demo type in a global list of demos..
  164. static JuceDemoType<SystemInfoDemo> demo ("02 System Info");