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.

247 lines
12KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE examples.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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, vs2022, 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. case Desktop::allOrientations: return "All";
  68. default: jassertfalse; break;
  69. }
  70. return nullptr;
  71. }
  72. static String getDisplayInfo()
  73. {
  74. auto& displays = Desktop::getInstance().getDisplays();
  75. String displayDesc;
  76. for (int i = 0; i < displays.displays.size(); ++i)
  77. {
  78. auto display = displays.displays.getReference (i);
  79. displayDesc << "Display " << (i + 1) << (display.isMain ? " (main)" : "") << ":" << newLine
  80. << " Total area: " << display.totalArea.toString() << newLine
  81. << " User area: " << display.userArea .toString() << newLine
  82. << " DPI: " << display.dpi << newLine
  83. << " Scale: " << display.scale << newLine
  84. << newLine;
  85. }
  86. displayDesc << "Orientation: " << getDisplayOrientation() << newLine;
  87. return displayDesc;
  88. }
  89. static String getAllSystemInfo()
  90. {
  91. String systemInfo;
  92. systemInfo
  93. << "Here are a few system statistics..." << newLine
  94. << newLine
  95. << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
  96. << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
  97. << "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine
  98. << newLine
  99. << "Operating system: " << SystemStats::getOperatingSystemName() << newLine
  100. << "Host name: " << SystemStats::getComputerName() << newLine
  101. << "Device type: " << SystemStats::getDeviceDescription() << newLine
  102. << "Manufacturer: " << SystemStats::getDeviceManufacturer() << newLine
  103. << "Device ID: " << SystemStats::getUniqueDeviceID() << newLine
  104. << "User logon name: " << SystemStats::getLogonName() << newLine
  105. << "Full user name: " << SystemStats::getFullUserName() << newLine
  106. << "User region: " << SystemStats::getUserRegion() << newLine
  107. << "User language: " << SystemStats::getUserLanguage() << newLine
  108. << "Display language: " << SystemStats::getDisplayLanguage() << newLine
  109. << newLine;
  110. systemInfo
  111. << "Number of logical CPUs: " << SystemStats::getNumCpus() << newLine
  112. << "Number of physical CPUs: " << SystemStats::getNumPhysicalCpus() << newLine
  113. << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
  114. << "CPU vendor: " << SystemStats::getCpuVendor() << newLine
  115. << "CPU model: " << SystemStats::getCpuModel() << newLine
  116. << "CPU speed: " << SystemStats::getCpuSpeedInMegahertz() << " MHz" << newLine
  117. << "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
  118. << "CPU has FMA3: " << (SystemStats::hasFMA3() ? "yes" : "no") << newLine
  119. << "CPU has FMA4: " << (SystemStats::hasFMA4() ? "yes" : "no") << newLine
  120. << "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
  121. << "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
  122. << "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
  123. << "CPU has SSSE3: " << (SystemStats::hasSSSE3() ? "yes" : "no") << newLine
  124. << "CPU has SSE4.1: " << (SystemStats::hasSSE41() ? "yes" : "no") << newLine
  125. << "CPU has SSE4.2: " << (SystemStats::hasSSE42() ? "yes" : "no") << newLine
  126. << "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
  127. << "CPU has AVX: " << (SystemStats::hasAVX() ? "yes" : "no") << newLine
  128. << "CPU has AVX2: " << (SystemStats::hasAVX2() ? "yes" : "no") << newLine
  129. << "CPU has AVX512F: " << (SystemStats::hasAVX512F() ? "yes" : "no") << newLine
  130. << "CPU has AVX512BW: " << (SystemStats::hasAVX512BW() ? "yes" : "no") << newLine
  131. << "CPU has AVX512CD: " << (SystemStats::hasAVX512CD() ? "yes" : "no") << newLine
  132. << "CPU has AVX512DQ: " << (SystemStats::hasAVX512DQ() ? "yes" : "no") << newLine
  133. << "CPU has AVX512ER: " << (SystemStats::hasAVX512ER() ? "yes" : "no") << newLine
  134. << "CPU has AVX512IFMA: " << (SystemStats::hasAVX512IFMA() ? "yes" : "no") << newLine
  135. << "CPU has AVX512PF: " << (SystemStats::hasAVX512PF() ? "yes" : "no") << newLine
  136. << "CPU has AVX512VBMI: " << (SystemStats::hasAVX512VBMI() ? "yes" : "no") << newLine
  137. << "CPU has AVX512VL: " << (SystemStats::hasAVX512VL() ? "yes" : "no") << newLine
  138. << "CPU has AVX512VPOPCNTDQ: " << (SystemStats::hasAVX512VPOPCNTDQ() ? "yes" : "no") << newLine
  139. << "CPU has Neon: " << (SystemStats::hasNeon() ? "yes" : "no") << newLine
  140. << newLine;
  141. systemInfo
  142. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  143. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  144. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  145. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  146. << newLine;
  147. systemInfo
  148. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  149. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  150. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  151. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  152. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  153. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  154. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  155. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  156. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  157. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  158. << newLine;
  159. systemInfo
  160. << "File System roots: " << getFileSystemRoots() << newLine
  161. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  162. .getBytesFreeOnVolume()) << newLine
  163. << newLine
  164. << getDisplayInfo() << newLine
  165. << "Network IP addresses: " << newLine << getIPAddressList() << newLine
  166. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  167. DBG (systemInfo);
  168. return systemInfo;
  169. }
  170. class SystemInfoDemo : public Component
  171. {
  172. public:
  173. SystemInfoDemo()
  174. {
  175. addAndMakeVisible (resultsBox);
  176. resultsBox.setReadOnly (true);
  177. resultsBox.setMultiLine (true);
  178. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  179. resultsBox.setFont ({ Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
  180. resultsBox.setText (getAllSystemInfo());
  181. setSize (500, 500);
  182. }
  183. void paint (Graphics& g) override
  184. {
  185. g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
  186. Colour::greyLevel (0.93f)));
  187. }
  188. void resized() override
  189. {
  190. resultsBox.setBounds (getLocalBounds().reduced (8));
  191. }
  192. private:
  193. TextEditor resultsBox;
  194. void lookAndFeelChanged() override
  195. {
  196. resultsBox.applyFontToAllText (resultsBox.getFont());
  197. }
  198. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo)
  199. };