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.

210 lines
9.0KB

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