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.

233 lines
9.9KB

  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. 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 Neon: " << (SystemStats::hasNeon() ? "yes" : "no") << newLine
  126. << newLine;
  127. systemInfo
  128. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  129. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  130. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  131. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  132. << newLine;
  133. systemInfo
  134. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  135. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  136. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  137. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  138. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  139. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  140. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  141. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  142. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  143. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  144. << newLine;
  145. systemInfo
  146. << "File System roots: " << getFileSystemRoots() << newLine
  147. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  148. .getBytesFreeOnVolume()) << newLine
  149. << newLine
  150. << getDisplayInfo() << newLine
  151. << "Network IP addresses: " << newLine << getIPAddressList() << newLine
  152. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  153. DBG (systemInfo);
  154. return systemInfo;
  155. }
  156. class SystemInfoDemo : public Component
  157. {
  158. public:
  159. SystemInfoDemo()
  160. {
  161. addAndMakeVisible (resultsBox);
  162. resultsBox.setReadOnly (true);
  163. resultsBox.setMultiLine (true);
  164. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  165. resultsBox.setFont ({ Font::getDefaultMonospacedFontName(), 12.0f, Font::plain });
  166. resultsBox.setText (getAllSystemInfo());
  167. setSize (500, 500);
  168. }
  169. void paint (Graphics& g) override
  170. {
  171. g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
  172. Colour::greyLevel (0.93f)));
  173. }
  174. void resized() override
  175. {
  176. resultsBox.setBounds (getLocalBounds().reduced (8));
  177. }
  178. private:
  179. TextEditor resultsBox;
  180. void lookAndFeelChanged() override
  181. {
  182. resultsBox.applyFontToAllText (resultsBox.getFont());
  183. }
  184. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo)
  185. };