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.

243 lines
11KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE examples.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. The code included in this file is provided under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  7. To use, copy, modify, and/or distribute this software for any purpose with or
  8. without fee is hereby granted provided that the above copyright notice and
  9. this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
  11. WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
  12. PURPOSE, ARE DISCLAIMED.
  13. ==============================================================================
  14. */
  15. /*******************************************************************************
  16. The block below describes the properties of this PIP. A PIP is a short snippet
  17. of code that can be read by the Projucer and used to generate a JUCE project.
  18. BEGIN_JUCE_PIP_METADATA
  19. name: SystemInfoDemo
  20. version: 1.0.0
  21. vendor: JUCE
  22. website: http://juce.com
  23. description: Displays system information.
  24. dependencies: juce_core, juce_data_structures, juce_events, juce_graphics,
  25. juce_gui_basics
  26. exporters: xcode_mac, vs2019, linux_make, androidstudio, xcode_iphone
  27. moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
  28. type: Component
  29. mainClass: SystemInfoDemo
  30. useLocalCopy: 1
  31. END_JUCE_PIP_METADATA
  32. *******************************************************************************/
  33. #pragma once
  34. #include "../Assets/DemoUtilities.h"
  35. //==============================================================================
  36. static String getMacAddressList()
  37. {
  38. String addressList;
  39. for (auto& addr : MACAddress::getAllAddresses())
  40. addressList << addr.toString() << newLine;
  41. return addressList;
  42. }
  43. static String getFileSystemRoots()
  44. {
  45. Array<File> roots;
  46. File::findFileSystemRoots (roots);
  47. StringArray rootList;
  48. for (auto& r : roots)
  49. rootList.add (r.getFullPathName());
  50. return rootList.joinIntoString (", ");
  51. }
  52. static String getIPAddressList()
  53. {
  54. String addressList;
  55. for (auto& addr : IPAddress::getAllAddresses())
  56. addressList << " " << addr.toString() << newLine;
  57. return addressList;
  58. }
  59. static const char* getDisplayOrientation()
  60. {
  61. switch (Desktop::getInstance().getCurrentOrientation())
  62. {
  63. case Desktop::upright: return "Upright";
  64. case Desktop::upsideDown: return "Upside-down";
  65. case Desktop::rotatedClockwise: return "Rotated Clockwise";
  66. case Desktop::rotatedAntiClockwise: return "Rotated Anti-clockwise";
  67. default: jassertfalse; break;
  68. }
  69. return nullptr;
  70. }
  71. static String getDisplayInfo()
  72. {
  73. auto& displays = Desktop::getInstance().getDisplays();
  74. String displayDesc;
  75. for (int i = 0; i < displays.displays.size(); ++i)
  76. {
  77. auto display = displays.displays.getReference (i);
  78. displayDesc << "Display " << (i + 1) << (display.isMain ? " (main)" : "") << ":" << newLine
  79. << " Total area: " << display.totalArea.toString() << newLine
  80. << " User area: " << display.userArea .toString() << newLine
  81. << " DPI: " << display.dpi << newLine
  82. << " Scale: " << display.scale << newLine
  83. << newLine;
  84. }
  85. displayDesc << "Orientation: " << getDisplayOrientation() << newLine;
  86. return displayDesc;
  87. }
  88. static String getAllSystemInfo()
  89. {
  90. String systemInfo;
  91. systemInfo
  92. << "Here are a few system statistics..." << newLine
  93. << newLine
  94. << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
  95. << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
  96. << "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine
  97. << newLine
  98. << "Operating system: " << SystemStats::getOperatingSystemName() << newLine
  99. << "Host name: " << SystemStats::getComputerName() << newLine
  100. << "Device type: " << SystemStats::getDeviceDescription() << newLine
  101. << "Manufacturer: " << SystemStats::getDeviceManufacturer() << newLine
  102. << "User logon name: " << SystemStats::getLogonName() << newLine
  103. << "Full user name: " << SystemStats::getFullUserName() << newLine
  104. << "User region: " << SystemStats::getUserRegion() << newLine
  105. << "User language: " << SystemStats::getUserLanguage() << newLine
  106. << "Display language: " << SystemStats::getDisplayLanguage() << newLine
  107. << newLine;
  108. systemInfo
  109. << "Number of logical CPUs: " << SystemStats::getNumCpus() << newLine
  110. << "Number of physical CPUs: " << SystemStats::getNumPhysicalCpus() << newLine
  111. << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
  112. << "CPU vendor: " << SystemStats::getCpuVendor() << newLine
  113. << "CPU model: " << SystemStats::getCpuModel() << newLine
  114. << "CPU speed: " << SystemStats::getCpuSpeedInMegahertz() << " MHz" << newLine
  115. << "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
  116. << "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
  117. << "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
  118. << "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
  119. << "CPU has SSSE3: " << (SystemStats::hasSSSE3() ? "yes" : "no") << newLine
  120. << "CPU has SSE4.1: " << (SystemStats::hasSSE41() ? "yes" : "no") << newLine
  121. << "CPU has SSE4.2: " << (SystemStats::hasSSE42() ? "yes" : "no") << newLine
  122. << "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
  123. << "CPU has AVX: " << (SystemStats::hasAVX() ? "yes" : "no") << newLine
  124. << "CPU has AVX2: " << (SystemStats::hasAVX2() ? "yes" : "no") << newLine
  125. << "CPU has AVX512F: " << (SystemStats::hasAVX512F() ? "yes" : "no") << newLine
  126. << "CPU has AVX512BW: " << (SystemStats::hasAVX512BW() ? "yes" : "no") << newLine
  127. << "CPU has AVX512CD: " << (SystemStats::hasAVX512CD() ? "yes" : "no") << newLine
  128. << "CPU has AVX512DQ: " << (SystemStats::hasAVX512DQ() ? "yes" : "no") << newLine
  129. << "CPU has AVX512ER: " << (SystemStats::hasAVX512ER() ? "yes" : "no") << newLine
  130. << "CPU has AVX512IFMA: " << (SystemStats::hasAVX512IFMA() ? "yes" : "no") << newLine
  131. << "CPU has AVX512PF: " << (SystemStats::hasAVX512PF() ? "yes" : "no") << newLine
  132. << "CPU has AVX512VBMI: " << (SystemStats::hasAVX512VBMI() ? "yes" : "no") << newLine
  133. << "CPU has AVX512VL: " << (SystemStats::hasAVX512VL() ? "yes" : "no") << newLine
  134. << "CPU has AVX512VPOPCNTDQ: " << (SystemStats::hasAVX512VPOPCNTDQ() ? "yes" : "no") << newLine
  135. << "CPU has Neon: " << (SystemStats::hasNeon() ? "yes" : "no") << newLine
  136. << newLine;
  137. systemInfo
  138. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  139. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  140. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  141. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  142. << newLine;
  143. systemInfo
  144. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  145. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  146. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  147. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  148. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  149. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  150. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  151. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  152. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  153. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  154. << newLine;
  155. systemInfo
  156. << "File System roots: " << getFileSystemRoots() << newLine
  157. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  158. .getBytesFreeOnVolume()) << newLine
  159. << newLine
  160. << getDisplayInfo() << newLine
  161. << "Network IP addresses: " << newLine << getIPAddressList() << newLine
  162. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  163. DBG (systemInfo);
  164. return systemInfo;
  165. }
  166. class SystemInfoDemo : public Component
  167. {
  168. public:
  169. SystemInfoDemo()
  170. {
  171. addAndMakeVisible (resultsBox);
  172. resultsBox.setReadOnly (true);
  173. resultsBox.setMultiLine (true);
  174. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  175. resultsBox.setFont ({ Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
  176. resultsBox.setText (getAllSystemInfo());
  177. setSize (500, 500);
  178. }
  179. void paint (Graphics& g) override
  180. {
  181. g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
  182. Colour::greyLevel (0.93f)));
  183. }
  184. void resized() override
  185. {
  186. resultsBox.setBounds (getLocalBounds().reduced (8));
  187. }
  188. private:
  189. TextEditor resultsBox;
  190. void lookAndFeelChanged() override
  191. {
  192. resultsBox.applyFontToAllText (resultsBox.getFont());
  193. }
  194. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo)
  195. };