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.

193 lines
8.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-12 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "../JuceDemoHeader.h"
  19. static String getMacAddressList()
  20. {
  21. Array<MACAddress> macAddresses;
  22. MACAddress::findAllAddresses (macAddresses);
  23. String addressList;
  24. for (int i = 0; i < macAddresses.size(); ++i)
  25. addressList << " " << macAddresses[i].toString() << newLine;
  26. return addressList;
  27. }
  28. static String getFileSystemRoots()
  29. {
  30. Array<File> roots;
  31. File::findFileSystemRoots (roots);
  32. StringArray rootList;
  33. for (int i = 0; i < roots.size(); ++i)
  34. rootList.add (roots[i].getFullPathName());
  35. return rootList.joinIntoString (", ");
  36. }
  37. static String getIPAddressList()
  38. {
  39. Array<IPAddress> addresses;
  40. IPAddress::findAllAddresses (addresses);
  41. String addressList;
  42. for (int i = 0; i < addresses.size(); ++i)
  43. addressList << " " << addresses[i].toString() << newLine;
  44. return addressList;
  45. }
  46. static const char* getDisplayOrientation()
  47. {
  48. switch (Desktop::getInstance().getCurrentOrientation())
  49. {
  50. case Desktop::upright: return "Upright";
  51. case Desktop::upsideDown: return "Upside-down";
  52. case Desktop::rotatedClockwise: return "Rotated Clockwise";
  53. case Desktop::rotatedAntiClockwise: return "Rotated Anti-clockwise";
  54. default: jassertfalse; break;
  55. }
  56. return nullptr;
  57. }
  58. static String getDisplayInfo()
  59. {
  60. const Desktop::Displays& displays = Desktop::getInstance().getDisplays();
  61. String displayDesc;
  62. for (int i = 0; i < displays.displays.size(); ++i)
  63. {
  64. const Desktop::Displays::Display display = displays.displays.getReference(i);
  65. displayDesc
  66. << "Display " << (i + 1) << (display.isMain ? " (main)" : "") << ":" << newLine
  67. << " Total area: " << display.totalArea.toString() << newLine
  68. << " User area: " << display.userArea.toString() << newLine
  69. << " DPI: " << display.dpi << newLine
  70. << " Scale: " << display.scale << newLine
  71. << newLine;
  72. }
  73. displayDesc << "Orientation: " << getDisplayOrientation() << newLine;
  74. return displayDesc;
  75. }
  76. static String getAllSystemInfo()
  77. {
  78. String systemInfo;
  79. systemInfo
  80. << "Here are a few system statistics..." << newLine
  81. << newLine
  82. << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
  83. << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
  84. << "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine
  85. << newLine
  86. << "Operating system: " << SystemStats::getOperatingSystemName() << newLine
  87. << "Host name: " << SystemStats::getComputerName() << newLine
  88. << "Device type: " << SystemStats::getDeviceDescription() << newLine
  89. << "User logon name: " << SystemStats::getLogonName() << newLine
  90. << "Full user name: " << SystemStats::getFullUserName() << newLine
  91. << "User region: " << SystemStats::getUserRegion() << newLine
  92. << "User language: " << SystemStats::getUserLanguage() << newLine
  93. << "Display language: " << SystemStats::getDisplayLanguage() << newLine
  94. << newLine
  95. << "Number of CPUs: " << SystemStats::getNumCpus() << newLine
  96. << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
  97. << "CPU vendor: " << SystemStats::getCpuVendor() << newLine
  98. << "CPU speed: " << SystemStats::getCpuSpeedInMegaherz() << " MHz" << newLine
  99. << "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
  100. << "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
  101. << "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
  102. << "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
  103. << "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
  104. << newLine
  105. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  106. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  107. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  108. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  109. << newLine
  110. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  111. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  112. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  113. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  114. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  115. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  116. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  117. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  118. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  119. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  120. << newLine
  121. << "File System roots: " << getFileSystemRoots() << newLine
  122. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  123. .getBytesFreeOnVolume()) << newLine
  124. << newLine
  125. << getDisplayInfo() << newLine
  126. << "Network IP addresses: " << newLine << getIPAddressList() << newLine
  127. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  128. DBG (systemInfo);
  129. return systemInfo;
  130. }
  131. class SystemInfoDemo : public Component
  132. {
  133. public:
  134. SystemInfoDemo()
  135. {
  136. addAndMakeVisible (resultsBox);
  137. resultsBox.setReadOnly (true);
  138. resultsBox.setMultiLine (true);
  139. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  140. resultsBox.setFont (Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
  141. resultsBox.setText (getAllSystemInfo());
  142. }
  143. void paint (Graphics& g) override
  144. {
  145. g.fillAll (Colour::greyLevel (0.93f));
  146. }
  147. void resized() override
  148. {
  149. resultsBox.setBounds (getLocalBounds().reduced (8));
  150. }
  151. private:
  152. TextEditor resultsBox;
  153. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo);
  154. };
  155. // This static object will register this demo type in a global list of demos..
  156. static JuceDemoType<SystemInfoDemo> demo ("02 System Info");