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.

178 lines
8.0KB

  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 const char* getDisplayOrientation()
  38. {
  39. switch (Desktop::getInstance().getCurrentOrientation())
  40. {
  41. case Desktop::upright: return "Upright";
  42. case Desktop::upsideDown: return "Upside-down";
  43. case Desktop::rotatedClockwise: return "Rotated Clockwise";
  44. case Desktop::rotatedAntiClockwise: return "Rotated Anti-clockwise";
  45. default: jassertfalse; break;
  46. }
  47. return nullptr;
  48. }
  49. static String getDisplayInfo()
  50. {
  51. const Desktop::Displays& displays = Desktop::getInstance().getDisplays();
  52. String displayDesc;
  53. for (int i = 0; i < displays.displays.size(); ++i)
  54. {
  55. const Desktop::Displays::Display display = displays.displays.getReference(i);
  56. displayDesc
  57. << "Display " << (i + 1) << (display.isMain ? " (main)" : "") << ":" << newLine
  58. << " Total area: " << display.totalArea.toString() << newLine
  59. << " User area: " << display.userArea.toString() << newLine
  60. << " DPI: " << display.dpi << newLine
  61. << " Scale: " << display.scale << newLine
  62. << newLine;
  63. }
  64. displayDesc << "Orientation: " << getDisplayOrientation() << newLine;
  65. return displayDesc;
  66. }
  67. static String getAllSystemInfo()
  68. {
  69. String systemInfo;
  70. systemInfo
  71. << "Here are a few system statistics..." << newLine
  72. << newLine
  73. << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
  74. << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
  75. << newLine
  76. << "Operating system: " << SystemStats::getOperatingSystemName() << newLine
  77. << "Host name: " << SystemStats::getComputerName() << newLine
  78. << "Device type: " << SystemStats::getDeviceDescription() << newLine
  79. << "User logon name: " << SystemStats::getLogonName() << newLine
  80. << "Full user name: " << SystemStats::getFullUserName() << newLine
  81. << "User region: " << SystemStats::getUserRegion() << newLine
  82. << "User language: " << SystemStats::getUserLanguage() << newLine
  83. << "Display language: " << SystemStats::getDisplayLanguage() << newLine
  84. << newLine
  85. << "Number of CPUs: " << SystemStats::getNumCpus() << newLine
  86. << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine
  87. << "CPU vendor: " << SystemStats::getCpuVendor() << newLine
  88. << "CPU speed: " << SystemStats::getCpuSpeedInMegaherz() << " MHz" << newLine
  89. << "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine
  90. << "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine
  91. << "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine
  92. << "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine
  93. << "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine
  94. << newLine
  95. << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine
  96. << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine
  97. << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine
  98. << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine
  99. << newLine
  100. << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine
  101. << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine
  102. << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine
  103. << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine
  104. << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine
  105. << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine
  106. << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine
  107. << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine
  108. << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine
  109. << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine
  110. << newLine
  111. << "File System roots: " << getFileSystemRoots() << newLine
  112. << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory)
  113. .getBytesFreeOnVolume()) << newLine
  114. << newLine
  115. << getDisplayInfo() << newLine
  116. << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine;
  117. DBG (systemInfo);
  118. return systemInfo;
  119. }
  120. class SystemInfoDemo : public Component
  121. {
  122. public:
  123. SystemInfoDemo()
  124. {
  125. addAndMakeVisible (resultsBox);
  126. resultsBox.setReadOnly (true);
  127. resultsBox.setMultiLine (true);
  128. resultsBox.setColour (TextEditor::backgroundColourId, Colours::transparentBlack);
  129. resultsBox.setFont (Font (Font::getDefaultMonospacedFontName(), 12.0f, Font::plain));
  130. resultsBox.setText (getAllSystemInfo());
  131. }
  132. void paint (Graphics& g) override
  133. {
  134. g.fillAll (Colour::greyLevel (0.93f));
  135. }
  136. void resized() override
  137. {
  138. resultsBox.setBounds (getLocalBounds().reduced (8));
  139. }
  140. private:
  141. TextEditor resultsBox;
  142. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo);
  143. };
  144. // This static object will register this demo type in a global list of demos..
  145. static JuceDemoType<SystemInfoDemo> demo ("02 System Info");