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.

238 lines
10KB

  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, vs2017, 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. Array<MACAddress> macAddresses;
  39. MACAddress::findAllAddresses (macAddresses);
  40. String addressList;
  41. for (auto& addr : macAddresses)
  42. addressList << addr.toString() << newLine;
  43. return addressList;
  44. }
  45. static String getFileSystemRoots()
  46. {
  47. Array<File> roots;
  48. File::findFileSystemRoots (roots);
  49. StringArray rootList;
  50. for (auto& r : roots)
  51. rootList.add (r.getFullPathName());
  52. return rootList.joinIntoString (", ");
  53. }
  54. static String getIPAddressList()
  55. {
  56. Array<IPAddress> addresses;
  57. IPAddress::findAllAddresses (addresses);
  58. String addressList;
  59. for (auto& addr : addresses)
  60. addressList << " " << addr.toString() << newLine;
  61. return addressList;
  62. }
  63. static const char* getDisplayOrientation()
  64. {
  65. switch (Desktop::getInstance().getCurrentOrientation())
  66. {
  67. case Desktop::upright: return "Upright";
  68. case Desktop::upsideDown: return "Upside-down";
  69. case Desktop::rotatedClockwise: return "Rotated Clockwise";
  70. case Desktop::rotatedAntiClockwise: return "Rotated Anti-clockwise";
  71. default: jassertfalse; break;
  72. }
  73. return nullptr;
  74. }
  75. static String getDisplayInfo()
  76. {
  77. auto& displays = Desktop::getInstance().getDisplays();
  78. String displayDesc;
  79. for (int i = 0; i < displays.displays.size(); ++i)
  80. {
  81. auto display = displays.displays.getReference (i);
  82. displayDesc << "Display " << (i + 1) << (display.isMain ? " (main)" : "") << ":" << newLine
  83. << " Total area: " << display.totalArea.toString() << newLine
  84. << " User area: " << display.userArea .toString() << newLine
  85. << " DPI: " << display.dpi << newLine
  86. << " Scale: " << display.scale << newLine
  87. << newLine;
  88. }
  89. displayDesc << "Orientation: " << getDisplayOrientation() << newLine;
  90. return displayDesc;
  91. }
  92. static String getAllSystemInfo()
  93. {
  94. String systemInfo;
  95. systemInfo
  96. << "Here are a few system statistics..." << newLine
  97. << newLine
  98. << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
  99. << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
  100. << "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine
  101. << newLine
  102. << "Operating system: " << SystemStats::getOperatingSystemName() << newLine
  103. << "Host name: " << SystemStats::getComputerName() << newLine
  104. << "Device type: " << SystemStats::getDeviceDescription() << newLine
  105. << "Manufacturer: " << SystemStats::getDeviceManufacturer() << newLine
  106. << "User logon name: " << SystemStats::getLogonName() << newLine
  107. << "Full user name: " << SystemStats::getFullUserName() << newLine
  108. << "User region: " << SystemStats::getUserRegion() << newLine
  109. << "User language: " << SystemStats::getUserLanguage() << newLine
  110. << "Display language: " << SystemStats::getDisplayLanguage() << newLine
  111. << newLine;
  112. systemInfo
  113. << "Number of logical CPUs: " << SystemStats::getNumCpus() << newLine
  114. << "Number of physical CPUs: " << SystemStats::getNumPhysicalCpus() << newLine
  115. << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
  116. << "CPU vendor: " << SystemStats::getCpuVendor() << newLine
  117. << "CPU model: " << SystemStats::getCpuModel() << newLine
  118. << "CPU speed: " << SystemStats::getCpuSpeedInMegahertz() << " MHz" << newLine
  119. << "CPU has MMX: " << (SystemStats::hasMMX() ? "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 Neon: " << (SystemStats::hasNeon() ? "yes" : "no") << newLine
  130. << newLine;
  131. systemInfo
  132. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  133. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  134. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  135. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  136. << newLine;
  137. systemInfo
  138. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  139. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  140. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  141. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  142. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  143. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  144. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  145. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  146. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  147. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  148. << newLine;
  149. systemInfo
  150. << "File System roots: " << getFileSystemRoots() << newLine
  151. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  152. .getBytesFreeOnVolume()) << newLine
  153. << newLine
  154. << getDisplayInfo() << newLine
  155. << "Network IP addresses: " << newLine << getIPAddressList() << newLine
  156. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  157. DBG (systemInfo);
  158. return systemInfo;
  159. }
  160. class SystemInfoDemo : public Component
  161. {
  162. public:
  163. SystemInfoDemo()
  164. {
  165. addAndMakeVisible (resultsBox);
  166. resultsBox.setReadOnly (true);
  167. resultsBox.setMultiLine (true);
  168. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  169. resultsBox.setFont ({ Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
  170. resultsBox.setText (getAllSystemInfo());
  171. setSize (500, 500);
  172. }
  173. void paint (Graphics& g) override
  174. {
  175. g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
  176. Colour::greyLevel (0.93f)));
  177. }
  178. void resized() override
  179. {
  180. resultsBox.setBounds (getLocalBounds().reduced (8));
  181. }
  182. private:
  183. TextEditor resultsBox;
  184. void lookAndFeelChanged() override
  185. {
  186. resultsBox.applyFontToAllText (resultsBox.getFont());
  187. }
  188. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo)
  189. };