diff --git a/extras/Jucer (experimental)/Source/Project/jucer_GroupInformationComponent.cpp b/extras/Jucer (experimental)/Source/Project/jucer_GroupInformationComponent.cpp index f487044e76..520c66f7a4 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_GroupInformationComponent.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_GroupInformationComponent.cpp @@ -94,9 +94,9 @@ public: void paint (Graphics& g) { int x = getHeight() + 6; - g.drawImageWithin (item.getIcon(), 2, 2, x - 4, getHeight() - 4, - RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, - false); + + item.getIcon()->drawWithin (g, Rectangle (2, 2, x - 4, getHeight() - 4), + RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); g.setColour (Colours::black); g.setFont (getHeight() * 0.6f); diff --git a/extras/Jucer (experimental)/Source/Project/jucer_Project.cpp b/extras/Jucer (experimental)/Source/Project/jucer_Project.cpp index b39f69e8e0..0242cc6c66 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_Project.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_Project.cpp @@ -745,12 +745,16 @@ bool Project::Item::addFile (const File& file, int insertIndex) return true; } -const Image Project::Item::getIcon() const +const Drawable* Project::Item::getIcon() const { if (isFile()) return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); else if (isMainGroup()) - return ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize); + { + static DrawableImage im; + im.setImage (ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize)); + return &im; + } else return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } diff --git a/extras/Jucer (experimental)/Source/Project/jucer_Project.h b/extras/Jucer (experimental)/Source/Project/jucer_Project.h index c63f4cf062..4286b8fb34 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_Project.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_Project.h @@ -203,7 +203,7 @@ public: Item getParent() const; - const Image getIcon() const; + const Drawable* getIcon() const; private: //============================================================================== diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp b/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp index 43477eaca2..e578b5cdf6 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.cpp @@ -433,19 +433,8 @@ void ProjectTreeViewBase::showMultiSelectionPopupMenu() switch (m.show()) { - case 6: deleteAllSelectedItems(); break; - default: break; - } -} - -void ProjectTreeViewBase::itemClicked (const MouseEvent& e) -{ - if (e.mods.isPopupMenu()) - { - if (getOwnerView()->getNumSelectedItems() > 1) - showMultiSelectionPopupMenu(); - else - showPopupMenu(); + case 6: deleteAllSelectedItems(); break; + default: break; } } diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.h index f29d717aef..c3d7fecb84 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectTreeViewBase.h @@ -64,8 +64,6 @@ public: virtual void addFiles (const StringArray& files, int insertIndex); virtual void moveSelectedItemsTo (OwnedArray & selectedNodes, int insertIndex); - - virtual void showPopupMenu() = 0; virtual void showMultiSelectionPopupMenu(); virtual ProjectTreeViewBase* findTreeViewItem (const Project::Item& itemToFind); @@ -82,7 +80,6 @@ public: void itemOpennessChanged (bool isNowOpen); void refreshSubItems(); bool canBeSelected() const { return true; } - void itemClicked (const MouseEvent& e); void itemDoubleClicked (const MouseEvent& e); void itemSelectionChanged (bool isNowSelected); const String getTooltip(); @@ -104,7 +101,7 @@ protected: //============================================================================== virtual void addSubItems(); virtual ProjectTreeViewBase* createSubItem (const Project::Item& node) = 0; - const Image getIcon() const { return item.getIcon(); } + const Drawable* getIcon() const { return item.getIcon(); } //============================================================================== void triggerAsyncRename (const Project::Item& itemToRename); diff --git a/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.cpp b/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.cpp index fccb3bfd3e..f5dd7b1f54 100644 --- a/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.cpp +++ b/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.cpp @@ -54,13 +54,13 @@ void JucerTreeViewBase::paintItem (Graphics& g, int width, int height) const int x = getTextX(); - g.setColour (isMissing() ? Colours::red : Colours::black); + g.setColour (Colours::black); - g.drawImageWithin (getIcon(), 0, 2, height + 6, height - 4, - RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, - false); + getIcon()->drawWithin (g, Rectangle (0.0f, 2.0f, height + 6.0f, height - 4.0f), + RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); g.setFont (getFont()); + g.setColour (isMissing() ? Colours::red : Colours::black); g.drawFittedText (getDisplayName(), x, 0, width - x, height, Justification::centredLeft, 1, 0.8f); } @@ -132,3 +132,22 @@ void JucerTreeViewBase::showRenameBox() if (ed.runModalLoop() != 0) setName (ed.getText()); } + +void JucerTreeViewBase::itemClicked (const MouseEvent& e) +{ + if (e.mods.isPopupMenu()) + { + if (getOwnerView()->getNumSelectedItems() > 1) + showMultiSelectionPopupMenu(); + else + showPopupMenu(); + } +} + +void JucerTreeViewBase::showPopupMenu() +{ +} + +void JucerTreeViewBase::showMultiSelectionPopupMenu() +{ +} diff --git a/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.h b/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.h index b9e891293f..fdd06701e2 100644 --- a/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.h +++ b/extras/Jucer (experimental)/Source/Utility/jucer_JucerTreeViewBase.h @@ -46,15 +46,19 @@ public: void paintItem (Graphics& g, int width, int height); void paintOpenCloseButton (Graphics& g, int width, int height, bool isMouseOver); Component* createItemComponent(); + void itemClicked (const MouseEvent& e); //============================================================================== virtual const String getRenamingName() const = 0; virtual const String getDisplayName() const = 0; virtual void setName (const String& newName) = 0; virtual bool isMissing() = 0; - virtual const Image getIcon() const = 0; + virtual const Drawable* getIcon() const = 0; virtual void createLeftEdgeComponents (Array& components) = 0; + virtual void showPopupMenu(); + virtual void showMultiSelectionPopupMenu(); + virtual void showRenameBox(); // Text editor listener for renaming.. diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index f680272ac6..67119f5edb 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -2303,11 +2303,12 @@ JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI() // turn RTTI off.. try { - TextButton tb (String::empty); - Component* c = &tb; + MemoryOutputStream mo; + OutputStream* o = &mo; // Got an exception here? Then TURN ON RTTI in your compiler settings!! - c = dynamic_cast (c); + o = dynamic_cast (o); + jassert (o != 0); } catch (...) { @@ -4536,11 +4537,11 @@ const var& NamedValueSet::operator[] (const Identifier& name) const const var NamedValueSet::getWithDefault (const Identifier& name, const var& defaultReturnValue) const { - const var* v = getItem (name); + const var* v = getVarPointer (name); return v != 0 ? *v : defaultReturnValue; } -var* NamedValueSet::getItem (const Identifier& name) const +var* NamedValueSet::getVarPointer (const Identifier& name) const { for (int i = values.size(); --i >= 0;) { @@ -4575,7 +4576,7 @@ bool NamedValueSet::set (const Identifier& name, const var& newValue) bool NamedValueSet::contains (const Identifier& name) const { - return getItem (name) != 0; + return getVarPointer (name) != 0; } bool NamedValueSet::remove (const Identifier& name) @@ -4626,7 +4627,7 @@ DynamicObject::~DynamicObject() bool DynamicObject::hasProperty (const Identifier& propertyName) const { - var* const v = properties.getItem (propertyName); + var* const v = properties.getVarPointer (propertyName); return v != 0 && ! v->isMethod(); } @@ -8619,20 +8620,20 @@ namespace SocketHelpers { typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); static juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0; -} - -static void initWin32Sockets() -{ - static CriticalSection lock; - const ScopedLock sl (lock); - if (SocketHelpers::juce_CloseWin32SocketLib == 0) + void initWin32Sockets() { - WSADATA wsaData; - const WORD wVersionRequested = MAKEWORD (1, 1); - WSAStartup (wVersionRequested, &wsaData); + static CriticalSection lock; + const ScopedLock sl (lock); + + if (SocketHelpers::juce_CloseWin32SocketLib == 0) + { + WSADATA wsaData; + const WORD wVersionRequested = MAKEWORD (1, 1); + WSAStartup (wVersionRequested, &wsaData); - SocketHelpers::juce_CloseWin32SocketLib = &WSACleanup; + SocketHelpers::juce_CloseWin32SocketLib = &WSACleanup; + } } } @@ -8865,7 +8866,7 @@ StreamingSocket::StreamingSocket() isListener (false) { #if JUCE_WINDOWS - initWin32Sockets(); + SocketHelpers::initWin32Sockets(); #endif } @@ -8879,7 +8880,7 @@ StreamingSocket::StreamingSocket (const String& hostName_, isListener (false) { #if JUCE_WINDOWS - initWin32Sockets(); + SocketHelpers::initWin32Sockets(); #endif SocketHelpers::resetSocketOptions (handle_, false, false); @@ -9056,7 +9057,7 @@ DatagramSocket::DatagramSocket (const int localPortNumber, const bool allowBroad serverAddress (0) { #if JUCE_WINDOWS - initWin32Sockets(); + SocketHelpers::initWin32Sockets(); #endif handle = (int) socket (AF_INET, SOCK_DGRAM, 0); @@ -9073,7 +9074,7 @@ DatagramSocket::DatagramSocket (const String& hostName_, const int portNumber_, serverAddress (0) { #if JUCE_WINDOWS - initWin32Sockets(); + SocketHelpers::initWin32Sockets(); #endif SocketHelpers::resetSocketOptions (handle_, true, allowBroadcast); @@ -9254,27 +9255,41 @@ URL::~URL() { } -static const String getMangledParameters (const StringPairArray& parameters) +namespace URLHelpers { - String p; - - for (int i = 0; i < parameters.size(); ++i) + const String getMangledParameters (const StringPairArray& parameters) { - if (i > 0) - p << '&'; + String p; - p << URL::addEscapeChars (parameters.getAllKeys() [i], true) - << '=' - << URL::addEscapeChars (parameters.getAllValues() [i], true); + for (int i = 0; i < parameters.size(); ++i) + { + if (i > 0) + p << '&'; + + p << URL::addEscapeChars (parameters.getAllKeys() [i], true) + << '=' + << URL::addEscapeChars (parameters.getAllValues() [i], true); + } + + return p; } - return p; + int findStartOfDomain (const String& url) + { + int i = 0; + + while (CharacterFunctions::isLetterOrDigit (url[i]) + || CharacterFunctions::indexOfChar (L"+-.", url[i], false) >= 0) + ++i; + + return url[i] == ':' ? i + 1 : 0; + } } const String URL::toString (const bool includeGetParameters) const { if (includeGetParameters && parameters.size() > 0) - return url + "?" + getMangledParameters (parameters); + return url + "?" + URLHelpers::getMangledParameters (parameters); else return url; } @@ -9285,20 +9300,9 @@ bool URL::isWellFormed() const return url.isNotEmpty(); } -static int findStartOfDomain (const String& url) -{ - int i = 0; - - while (CharacterFunctions::isLetterOrDigit (url[i]) - || CharacterFunctions::indexOfChar (L"+-.", url[i], false) >= 0) - ++i; - - return url[i] == ':' ? i + 1 : 0; -} - const String URL::getDomain() const { - int start = findStartOfDomain (url); + int start = URLHelpers::findStartOfDomain (url); while (url[start] == '/') ++start; @@ -9313,7 +9317,7 @@ const String URL::getDomain() const const String URL::getSubPath() const { - int start = findStartOfDomain (url); + int start = URLHelpers::findStartOfDomain (url); while (url[start] == '/') ++start; @@ -9325,12 +9329,12 @@ const String URL::getSubPath() const const String URL::getScheme() const { - return url.substring (0, findStartOfDomain (url) - 1); + return url.substring (0, URLHelpers::findStartOfDomain (url) - 1); } const URL URL::withNewSubPath (const String& newPath) const { - int start = findStartOfDomain (url); + int start = URLHelpers::findStartOfDomain (url); while (url[start] == '/') ++start; @@ -9557,7 +9561,7 @@ private: } else { - data << getMangledParameters (url.getParameters()) + data << URLHelpers::getMangledParameters (url.getParameters()) << url.getPostData(); data.flush(); @@ -9737,21 +9741,44 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_BufferedInputStream.cpp ***/ BEGIN_JUCE_NAMESPACE -BufferedInputStream::BufferedInputStream (InputStream* const source_, - const int bufferSize_, +namespace +{ + int calcBufferStreamBufferSize (int requestedSize, InputStream* const source) throw() + { + // You need to supply a real stream when creating a BufferedInputStream + jassert (source != 0); + + requestedSize = jmax (256, requestedSize); + + const int64 sourceSize = source->getTotalLength(); + if (sourceSize >= 0 && sourceSize < requestedSize) + requestedSize = jmax (32, (int) sourceSize); + + return requestedSize; + } +} + +BufferedInputStream::BufferedInputStream (InputStream* const sourceStream, const int bufferSize_, const bool deleteSourceWhenDestroyed) - : source (source_), - sourceToDelete (deleteSourceWhenDestroyed ? source_ : 0), - bufferSize (jmax (256, bufferSize_)), - position (source_->getPosition()), + : source (sourceStream), + sourceToDelete (deleteSourceWhenDestroyed ? sourceStream : 0), + bufferSize (calcBufferStreamBufferSize (bufferSize_, sourceStream)), + position (sourceStream->getPosition()), lastReadPos (0), + bufferStart (position), bufferOverlap (128) { - const int sourceSize = (int) source_->getTotalLength(); - if (sourceSize >= 0) - bufferSize = jmin (jmax (32, sourceSize), bufferSize); + buffer.malloc (bufferSize); +} - bufferStart = position; +BufferedInputStream::BufferedInputStream (InputStream& sourceStream, const int bufferSize_) + : source (&sourceStream), + bufferSize (calcBufferStreamBufferSize (bufferSize_, &sourceStream)), + position (sourceStream.getPosition()), + lastReadPos (0), + bufferStart (position), + bufferOverlap (128) +{ buffer.malloc (bufferSize); } @@ -10637,7 +10664,7 @@ void ZipFile::init() if (in != 0) { int numEntries = 0; - int pos = findEndOfZipEntryTable (in, numEntries); + int pos = findEndOfZipEntryTable (*in, numEntries); if (pos >= 0 && pos < in->getTotalLength()) { @@ -10693,9 +10720,9 @@ void ZipFile::init() } } -int ZipFile::findEndOfZipEntryTable (InputStream* input, int& numEntries) +int ZipFile::findEndOfZipEntryTable (InputStream& input, int& numEntries) { - BufferedInputStream in (input, 8192, false); + BufferedInputStream in (input, 8192); in.setPosition (in.getTotalLength()); int64 pos = in.getPosition(); @@ -11237,150 +11264,153 @@ int64 CharacterFunctions::getInt64Value (const juce_wchar* s) throw() #endif } -static double juce_mulexp10 (const double value, int exponent) throw() +namespace { - if (exponent == 0) - return value; + double juce_mulexp10 (const double value, int exponent) throw() + { + if (exponent == 0) + return value; - if (value == 0) - return 0; + if (value == 0) + return 0; - const bool negative = (exponent < 0); - if (negative) - exponent = -exponent; + const bool negative = (exponent < 0); + if (negative) + exponent = -exponent; - double result = 1.0, power = 10.0; - for (int bit = 1; exponent != 0; bit <<= 1) - { - if ((exponent & bit) != 0) + double result = 1.0, power = 10.0; + for (int bit = 1; exponent != 0; bit <<= 1) { - exponent ^= bit; - result *= power; - if (exponent == 0) - break; + if ((exponent & bit) != 0) + { + exponent ^= bit; + result *= power; + if (exponent == 0) + break; + } + power *= power; } - power *= power; - } - - return negative ? (value / result) : (value * result); -} -template -double juce_atof (const CharType* const original) throw() -{ - double result[3] = { 0, 0, 0 }, accumulator[2] = { 0, 0 }; - int exponentAdjustment[2] = { 0, 0 }, exponentAccumulator[2] = { -1, -1 }; - int exponent = 0, decPointIndex = 0, digit = 0; - int lastDigit = 0, numSignificantDigits = 0; - bool isNegative = false, digitsFound = false; - const int maxSignificantDigits = 15 + 2; - - const CharType* s = original; - while (CharacterFunctions::isWhitespace (*s)) - ++s; + return negative ? (value / result) : (value * result); + } - switch (*s) + template + double juce_atof (const CharType* const original) throw() { - case '-': isNegative = true; // fall-through.. - case '+': ++s; - } + double result[3] = { 0, 0, 0 }, accumulator[2] = { 0, 0 }; + int exponentAdjustment[2] = { 0, 0 }, exponentAccumulator[2] = { -1, -1 }; + int exponent = 0, decPointIndex = 0, digit = 0; + int lastDigit = 0, numSignificantDigits = 0; + bool isNegative = false, digitsFound = false; + const int maxSignificantDigits = 15 + 2; - if (*s == 'n' || *s == 'N' || *s == 'i' || *s == 'I') - return atof (String (original).toUTF8()); // Let the c library deal with NAN and INF + const CharType* s = original; + while (CharacterFunctions::isWhitespace (*s)) + ++s; - for (;;) - { - if (CharacterFunctions::isDigit (*s)) + switch (*s) { - lastDigit = digit; - digit = *s++ - '0'; - digitsFound = true; - - if (decPointIndex != 0) - exponentAdjustment[1]++; + case '-': isNegative = true; // fall-through.. + case '+': ++s; + } - if (numSignificantDigits == 0 && digit == 0) - continue; + if (*s == 'n' || *s == 'N' || *s == 'i' || *s == 'I') + return atof (String (original).toUTF8()); // Let the c library deal with NAN and INF - if (++numSignificantDigits > maxSignificantDigits) + for (;;) + { + if (CharacterFunctions::isDigit (*s)) { - if (digit > 5) - ++accumulator [decPointIndex]; - else if (digit == 5 && (lastDigit & 1) != 0) - ++accumulator [decPointIndex]; + lastDigit = digit; + digit = *s++ - '0'; + digitsFound = true; - if (decPointIndex > 0) - exponentAdjustment[1]--; - else - exponentAdjustment[0]++; + if (decPointIndex != 0) + exponentAdjustment[1]++; + + if (numSignificantDigits == 0 && digit == 0) + continue; - while (CharacterFunctions::isDigit (*s)) + if (++numSignificantDigits > maxSignificantDigits) { - ++s; - if (decPointIndex == 0) + if (digit > 5) + ++accumulator [decPointIndex]; + else if (digit == 5 && (lastDigit & 1) != 0) + ++accumulator [decPointIndex]; + + if (decPointIndex > 0) + exponentAdjustment[1]--; + else exponentAdjustment[0]++; + + while (CharacterFunctions::isDigit (*s)) + { + ++s; + if (decPointIndex == 0) + exponentAdjustment[0]++; + } + } + else + { + const double maxAccumulatorValue = (double) ((std::numeric_limits::max() - 9) / 10); + if (accumulator [decPointIndex] > maxAccumulatorValue) + { + result [decPointIndex] = juce_mulexp10 (result [decPointIndex], exponentAccumulator [decPointIndex]) + + accumulator [decPointIndex]; + accumulator [decPointIndex] = 0; + exponentAccumulator [decPointIndex] = 0; + } + + accumulator [decPointIndex] = accumulator[decPointIndex] * 10 + digit; + exponentAccumulator [decPointIndex]++; } } - else + else if (decPointIndex == 0 && *s == '.') { - const double maxAccumulatorValue = (double) ((std::numeric_limits::max() - 9) / 10); - if (accumulator [decPointIndex] > maxAccumulatorValue) + ++s; + decPointIndex = 1; + + if (numSignificantDigits > maxSignificantDigits) { - result [decPointIndex] = juce_mulexp10 (result [decPointIndex], exponentAccumulator [decPointIndex]) - + accumulator [decPointIndex]; - accumulator [decPointIndex] = 0; - exponentAccumulator [decPointIndex] = 0; + while (CharacterFunctions::isDigit (*s)) + ++s; + break; } - - accumulator [decPointIndex] = accumulator[decPointIndex] * 10 + digit; - exponentAccumulator [decPointIndex]++; } - } - else if (decPointIndex == 0 && *s == '.') - { - ++s; - decPointIndex = 1; - - if (numSignificantDigits > maxSignificantDigits) + else { - while (CharacterFunctions::isDigit (*s)) - ++s; break; } } - else - { - break; - } - } - - result[0] = juce_mulexp10 (result[0], exponentAccumulator[0]) + accumulator[0]; - if (decPointIndex != 0) - result[1] = juce_mulexp10 (result[1], exponentAccumulator[1]) + accumulator[1]; + result[0] = juce_mulexp10 (result[0], exponentAccumulator[0]) + accumulator[0]; - if ((*s == 'e' || *s == 'E') && digitsFound) - { - bool negativeExponent = false; + if (decPointIndex != 0) + result[1] = juce_mulexp10 (result[1], exponentAccumulator[1]) + accumulator[1]; - switch (*++s) + if ((*s == 'e' || *s == 'E') && digitsFound) { - case '-': negativeExponent = true; // fall-through.. - case '+': ++s; - } + bool negativeExponent = false; + + switch (*++s) + { + case '-': negativeExponent = true; // fall-through.. + case '+': ++s; + } - while (CharacterFunctions::isDigit (*s)) - exponent = (exponent * 10) + (*s++ - '0'); + while (CharacterFunctions::isDigit (*s)) + exponent = (exponent * 10) + (*s++ - '0'); - if (negativeExponent) - exponent = -exponent; - } + if (negativeExponent) + exponent = -exponent; + } - double r = juce_mulexp10 (result[0], exponent + exponentAdjustment[0]); - if (decPointIndex != 0) - r += juce_mulexp10 (result[1], exponent - exponentAdjustment[1]); + double r = juce_mulexp10 (result[0], exponent + exponentAdjustment[0]); + if (decPointIndex != 0) + r += juce_mulexp10 (result[1], exponent - exponentAdjustment[1]); - return isNegative ? -r : r; + return isNegative ? -r : r; + } } double CharacterFunctions::getDoubleValue (const char* const s) throw() @@ -11583,31 +11613,37 @@ const String LocalisedStrings::translate (const String& text) const return translations.getValue (text, text); } -static int findCloseQuote (const String& text, int startPos) +namespace { - juce_wchar lastChar = 0; + CriticalSection currentMappingsLock; + LocalisedStrings* currentMappings = 0; - for (;;) + int findCloseQuote (const String& text, int startPos) { - const juce_wchar c = text [startPos]; + juce_wchar lastChar = 0; - if (c == 0 || (c == '"' && lastChar != '\\')) - break; + for (;;) + { + const juce_wchar c = text [startPos]; - lastChar = c; - ++startPos; - } + if (c == 0 || (c == '"' && lastChar != '\\')) + break; - return startPos; -} + lastChar = c; + ++startPos; + } -static const String unescapeString (const String& s) -{ - return s.replace ("\\\"", "\"") - .replace ("\\\'", "\'") - .replace ("\\t", "\t") - .replace ("\\r", "\r") - .replace ("\\n", "\n"); + return startPos; + } + + const String unescapeString (const String& s) + { + return s.replace ("\\\"", "\"") + .replace ("\\\'", "\'") + .replace ("\\t", "\t") + .replace ("\\r", "\r") + .replace ("\\n", "\n"); + } } void LocalisedStrings::loadFromText (const String& fileContents) @@ -11654,9 +11690,6 @@ void LocalisedStrings::setIgnoresCase (const bool shouldIgnoreCase) translations.setIgnoresCase (shouldIgnoreCase); } -static CriticalSection currentMappingsLock; -static LocalisedStrings* currentMappings = 0; - void LocalisedStrings::setCurrentMappings (LocalisedStrings* newTranslations) { const ScopedLock sl (currentMappingsLock); @@ -12675,46 +12708,49 @@ bool String::containsWholeWordIgnoreCase (const String& wordToLookFor) const thr return indexOfWholeWordIgnoreCase (wordToLookFor) >= 0; } -static int indexOfMatch (const juce_wchar* const wildcard, - const juce_wchar* const test, - const bool ignoreCase) throw() +namespace WildCardHelpers { - int start = 0; - - while (test [start] != 0) + int indexOfMatch (const juce_wchar* const wildcard, + const juce_wchar* const test, + const bool ignoreCase) throw() { - int i = 0; + int start = 0; - for (;;) + while (test [start] != 0) { - const juce_wchar wc = wildcard [i]; - const juce_wchar c = test [i + start]; + int i = 0; - if (wc == c - || (ignoreCase && CharacterFunctions::toLowerCase (wc) == CharacterFunctions::toLowerCase (c)) - || (wc == '?' && c != 0)) + for (;;) { - if (wc == 0) - return start; + const juce_wchar wc = wildcard [i]; + const juce_wchar c = test [i + start]; - ++i; - } - else - { - if (wc == '*' && (wildcard [i + 1] == 0 - || indexOfMatch (wildcard + i + 1, test + start + i, ignoreCase) >= 0)) + if (wc == c + || (ignoreCase && CharacterFunctions::toLowerCase (wc) == CharacterFunctions::toLowerCase (c)) + || (wc == '?' && c != 0)) { - return start; + if (wc == 0) + return start; + + ++i; } + else + { + if (wc == '*' && (wildcard [i + 1] == 0 + || indexOfMatch (wildcard + i + 1, test + start + i, ignoreCase) >= 0)) + { + return start; + } - break; + break; + } } + + ++start; } - ++start; + return -1; } - - return -1; } bool String::matchesWildcard (const String& wildcard, const bool ignoreCase) const throw() @@ -12738,7 +12774,7 @@ bool String::matchesWildcard (const String& wildcard, const bool ignoreCase) con else { return wc == '*' && (wildcard [i + 1] == 0 - || indexOfMatch (wildcard.text + i + 1, text + i, ignoreCase) >= 0); + || WildCardHelpers::indexOfMatch (wildcard.text + i + 1, text + i, ignoreCase) >= 0); } } } @@ -14693,46 +14729,49 @@ BEGIN_JUCE_NAMESPACE StringPool::StringPool() throw() {} StringPool::~StringPool() {} -template -static const juce_wchar* getPooledStringFromArray (Array& strings, StringType newString) +namespace StringPoolHelpers { - int start = 0; - int end = strings.size(); - - for (;;) + template + const juce_wchar* getPooledStringFromArray (Array& strings, StringType newString) { - if (start >= end) - { - jassert (start <= end); - strings.insert (start, newString); - return strings.getReference (start); - } - else - { - const String& startString = strings.getReference (start); - - if (startString == newString) - return startString; + int start = 0; + int end = strings.size(); - const int halfway = (start + end) >> 1; - - if (halfway == start) + for (;;) + { + if (start >= end) { - if (startString.compare (newString) < 0) - ++start; - + jassert (start <= end); strings.insert (start, newString); return strings.getReference (start); } + else + { + const String& startString = strings.getReference (start); - const int comp = strings.getReference (halfway).compare (newString); + if (startString == newString) + return startString; - if (comp == 0) - return strings.getReference (halfway); - else if (comp < 0) - start = halfway; - else - end = halfway; + const int halfway = (start + end) >> 1; + + if (halfway == start) + { + if (startString.compare (newString) < 0) + ++start; + + strings.insert (start, newString); + return strings.getReference (start); + } + + const int comp = strings.getReference (halfway).compare (newString); + + if (comp == 0) + return strings.getReference (halfway); + else if (comp < 0) + start = halfway; + else + end = halfway; + } } } } @@ -14742,7 +14781,7 @@ const juce_wchar* StringPool::getPooledString (const String& s) if (s.isEmpty()) return String::empty; - return getPooledStringFromArray (strings, s); + return StringPoolHelpers::getPooledStringFromArray (strings, s); } const juce_wchar* StringPool::getPooledString (const char* const s) @@ -14750,7 +14789,7 @@ const juce_wchar* StringPool::getPooledString (const char* const s) if (s == 0 || *s == 0) return String::empty; - return getPooledStringFromArray (strings, s); + return StringPoolHelpers::getPooledStringFromArray (strings, s); } const juce_wchar* StringPool::getPooledString (const juce_wchar* const s) @@ -14758,7 +14797,7 @@ const juce_wchar* StringPool::getPooledString (const juce_wchar* const s) if (s == 0 || *s == 0) return String::empty; - return getPooledStringFromArray (strings, s); + return StringPoolHelpers::getPooledStringFromArray (strings, s); } int StringPool::size() const throw() @@ -18156,7 +18195,7 @@ void ValueTree::SharedObject::setProperty (const Identifier& name, const var& ne } else { - var* const existingValue = properties.getItem (name); + var* const existingValue = properties.getVarPointer (name); if (existingValue != 0) { @@ -23550,37 +23589,40 @@ AudioFormatWriter* WavAudioFormat::createWriterFor (OutputStream* out, return 0; } -static bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const StringPairArray& metadata) +namespace { - TemporaryFile tempFile (file); - - WavAudioFormat wav; - ScopedPointer reader (wav.createReaderFor (file.createInputStream(), true)); - - if (reader != 0) + bool juce_slowCopyOfWavFileWithNewMetadata (const File& file, const StringPairArray& metadata) { - ScopedPointer outStream (tempFile.getFile().createOutputStream()); + TemporaryFile tempFile (file); - if (outStream != 0) + WavAudioFormat wav; + ScopedPointer reader (wav.createReaderFor (file.createInputStream(), true)); + + if (reader != 0) { - ScopedPointer writer (wav.createWriterFor (outStream, reader->sampleRate, - reader->numChannels, reader->bitsPerSample, - metadata, 0)); + ScopedPointer outStream (tempFile.getFile().createOutputStream()); - if (writer != 0) + if (outStream != 0) { - outStream.release(); + ScopedPointer writer (wav.createWriterFor (outStream, reader->sampleRate, + reader->numChannels, reader->bitsPerSample, + metadata, 0)); - bool ok = writer->writeFromAudioReader (*reader, 0, -1); - writer = 0; - reader = 0; + if (writer != 0) + { + outStream.release(); + + bool ok = writer->writeFromAudioReader (*reader, 0, -1); + writer = 0; + reader = 0; - return ok && tempFile.overwriteTargetFileWithTemporary(); + return ok && tempFile.overwriteTargetFileWithTemporary(); + } } } - } - return false; + return false; + } } bool WavAudioFormat::replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata) @@ -27882,38 +27924,41 @@ void MidiBuffer::addEvent (const MidiMessage& m, const int sampleNumber) addEvent (m.getRawData(), m.getRawDataSize(), sampleNumber); } -static int findActualEventLength (const uint8* const data, const int maxBytes) throw() +namespace MidiBufferHelpers { - unsigned int byte = (unsigned int) *data; - int size = 0; - - if (byte == 0xf0 || byte == 0xf7) + int findActualEventLength (const uint8* const data, const int maxBytes) throw() { - const uint8* d = data + 1; + unsigned int byte = (unsigned int) *data; + int size = 0; - while (d < data + maxBytes) - if (*d++ == 0xf7) - break; + if (byte == 0xf0 || byte == 0xf7) + { + const uint8* d = data + 1; - size = (int) (d - data); - } - else if (byte == 0xff) - { - int n; - const int bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n); - size = jmin (maxBytes, n + 2 + bytesLeft); - } - else if (byte >= 0x80) - { - size = jmin (maxBytes, MidiMessage::getMessageLengthFromFirstByte ((uint8) byte)); - } + while (d < data + maxBytes) + if (*d++ == 0xf7) + break; - return size; + size = (int) (d - data); + } + else if (byte == 0xff) + { + int n; + const int bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n); + size = jmin (maxBytes, n + 2 + bytesLeft); + } + else if (byte >= 0x80) + { + size = jmin (maxBytes, MidiMessage::getMessageLengthFromFirstByte ((uint8) byte)); + } + + return size; + } } void MidiBuffer::addEvent (const void* const newData, const int maxBytes, const int sampleNumber) { - const int numBytes = findActualEventLength (static_cast (newData), maxBytes); + const int numBytes = MidiBufferHelpers::findActualEventLength (static_cast (newData), maxBytes); if (numBytes > 0) { @@ -30364,17 +30409,20 @@ void KnownPluginList::removeType (const int index) sendChangeMessage (this); } -static const Time getPluginFileModTime (const String& fileOrIdentifier) +namespace { - if (fileOrIdentifier.startsWithChar ('/') || fileOrIdentifier[1] == ':') - return File (fileOrIdentifier).getLastModificationTime(); + const Time getPluginFileModTime (const String& fileOrIdentifier) + { + if (fileOrIdentifier.startsWithChar ('/') || fileOrIdentifier[1] == ':') + return File (fileOrIdentifier).getLastModificationTime(); - return Time (0); -} + return Time (0); + } -static bool timesAreDifferent (const Time& t1, const Time& t2) throw() -{ - return t1 != t2 || t1 == Time (0); + bool timesAreDifferent (const Time& t1, const Time& t2) throw() + { + return t1 != t2 || t1 == Time (0); + } } bool KnownPluginList::isListingUpToDate (const String& fileOrIdentifier) const @@ -33002,40 +33050,43 @@ struct fxProgramSet char chunk[8]; // variable }; -static long vst_swap (const long x) throw() +namespace { - #ifdef JUCE_LITTLE_ENDIAN - return (long) ByteOrder::swap ((uint32) x); - #else - return x; - #endif -} + long vst_swap (const long x) throw() + { + #ifdef JUCE_LITTLE_ENDIAN + return (long) ByteOrder::swap ((uint32) x); + #else + return x; + #endif + } -static float vst_swapFloat (const float x) throw() -{ - #ifdef JUCE_LITTLE_ENDIAN - union { uint32 asInt; float asFloat; } n; - n.asFloat = x; - n.asInt = ByteOrder::swap (n.asInt); - return n.asFloat; - #else - return x; - #endif -} + float vst_swapFloat (const float x) throw() + { + #ifdef JUCE_LITTLE_ENDIAN + union { uint32 asInt; float asFloat; } n; + n.asFloat = x; + n.asInt = ByteOrder::swap (n.asInt); + return n.asFloat; + #else + return x; + #endif + } -static double getVSTHostTimeNanoseconds() -{ - #if JUCE_WINDOWS - return timeGetTime() * 1000000.0; - #elif JUCE_LINUX - timeval micro; - gettimeofday (µ, 0); - return micro.tv_usec * 1000.0; - #elif JUCE_MAC - UnsignedWide micro; - Microseconds (µ); - return micro.lo * 1000.0; - #endif + double getVSTHostTimeNanoseconds() + { + #if JUCE_WINDOWS + return timeGetTime() * 1000000.0; + #elif JUCE_LINUX + timeval micro; + gettimeofday (µ, 0); + return micro.tv_usec * 1000.0; + #elif JUCE_MAC + UnsignedWide micro; + Microseconds (µ); + return micro.lo * 1000.0; + #endif + } } typedef AEffect* (*MainCall) (audioMasterCallback); @@ -33079,94 +33130,97 @@ typedef void (*EventProcPtr) (XEvent* ev); static bool xErrorTriggered; -static int temporaryErrorHandler (Display*, XErrorEvent*) -{ - xErrorTriggered = true; - return 0; -} - -static int getPropertyFromXWindow (Window handle, Atom atom) +namespace { - XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler); - xErrorTriggered = false; + int temporaryErrorHandler (Display*, XErrorEvent*) + { + xErrorTriggered = true; + return 0; + } - int userSize; - unsigned long bytes, userCount; - unsigned char* data; - Atom userType; + int getPropertyFromXWindow (Window handle, Atom atom) + { + XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler); + xErrorTriggered = false; - XGetWindowProperty (display, handle, atom, 0, 1, false, AnyPropertyType, - &userType, &userSize, &userCount, &bytes, &data); + int userSize; + unsigned long bytes, userCount; + unsigned char* data; + Atom userType; - XSetErrorHandler (oldErrorHandler); + XGetWindowProperty (display, handle, atom, 0, 1, false, AnyPropertyType, + &userType, &userSize, &userCount, &bytes, &data); - return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast (data) - : 0; -} + XSetErrorHandler (oldErrorHandler); -static Window getChildWindow (Window windowToCheck) -{ - Window rootWindow, parentWindow; - Window* childWindows; - unsigned int numChildren; + return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast (data) + : 0; + } - XQueryTree (display, - windowToCheck, - &rootWindow, - &parentWindow, - &childWindows, - &numChildren); + Window getChildWindow (Window windowToCheck) + { + Window rootWindow, parentWindow; + Window* childWindows; + unsigned int numChildren; - if (numChildren > 0) - return childWindows [0]; + XQueryTree (display, + windowToCheck, + &rootWindow, + &parentWindow, + &childWindows, + &numChildren); - return 0; -} + if (numChildren > 0) + return childWindows [0]; -static void translateJuceToXButtonModifiers (const MouseEvent& e, XEvent& ev) throw() -{ - if (e.mods.isLeftButtonDown()) - { - ev.xbutton.button = Button1; - ev.xbutton.state |= Button1Mask; + return 0; } - else if (e.mods.isRightButtonDown()) + + void translateJuceToXButtonModifiers (const MouseEvent& e, XEvent& ev) throw() { - ev.xbutton.button = Button3; - ev.xbutton.state |= Button3Mask; + if (e.mods.isLeftButtonDown()) + { + ev.xbutton.button = Button1; + ev.xbutton.state |= Button1Mask; + } + else if (e.mods.isRightButtonDown()) + { + ev.xbutton.button = Button3; + ev.xbutton.state |= Button3Mask; + } + else if (e.mods.isMiddleButtonDown()) + { + ev.xbutton.button = Button2; + ev.xbutton.state |= Button2Mask; + } } - else if (e.mods.isMiddleButtonDown()) + + void translateJuceToXMotionModifiers (const MouseEvent& e, XEvent& ev) throw() { - ev.xbutton.button = Button2; - ev.xbutton.state |= Button2Mask; + if (e.mods.isLeftButtonDown()) ev.xmotion.state |= Button1Mask; + else if (e.mods.isRightButtonDown()) ev.xmotion.state |= Button3Mask; + else if (e.mods.isMiddleButtonDown()) ev.xmotion.state |= Button2Mask; } -} - -static void translateJuceToXMotionModifiers (const MouseEvent& e, XEvent& ev) throw() -{ - if (e.mods.isLeftButtonDown()) ev.xmotion.state |= Button1Mask; - else if (e.mods.isRightButtonDown()) ev.xmotion.state |= Button3Mask; - else if (e.mods.isMiddleButtonDown()) ev.xmotion.state |= Button2Mask; -} - -static void translateJuceToXCrossingModifiers (const MouseEvent& e, XEvent& ev) throw() -{ - if (e.mods.isLeftButtonDown()) ev.xcrossing.state |= Button1Mask; - else if (e.mods.isRightButtonDown()) ev.xcrossing.state |= Button3Mask; - else if (e.mods.isMiddleButtonDown()) ev.xcrossing.state |= Button2Mask; -} -static void translateJuceToXMouseWheelModifiers (const MouseEvent& e, const float increment, XEvent& ev) throw() -{ - if (increment < 0) + void translateJuceToXCrossingModifiers (const MouseEvent& e, XEvent& ev) throw() { - ev.xbutton.button = Button5; - ev.xbutton.state |= Button5Mask; + if (e.mods.isLeftButtonDown()) ev.xcrossing.state |= Button1Mask; + else if (e.mods.isRightButtonDown()) ev.xcrossing.state |= Button3Mask; + else if (e.mods.isMiddleButtonDown()) ev.xcrossing.state |= Button2Mask; } - else if (increment > 0) + + void translateJuceToXMouseWheelModifiers (const MouseEvent& e, const float increment, XEvent& ev) throw() { - ev.xbutton.button = Button4; - ev.xbutton.state |= Button4Mask; + if (increment < 0) + { + ev.xbutton.button = Button5; + ev.xbutton.state |= Button5Mask; + } + else if (increment > 0) + { + ev.xbutton.button = Button4; + ev.xbutton.state |= Button4Mask; + } } } @@ -34972,65 +35026,67 @@ int VSTPluginInstance::dispatch (const int opcode, const int index, const int va return result; } -// handles non plugin-specific callbacks.. - -static const int defaultVSTSampleRateValue = 16384; -static const int defaultVSTBlockSizeValue = 512; - -static VstIntPtr handleGeneralCallback (VstInt32 opcode, VstInt32 index, VstInt32 value, void *ptr, float opt) +namespace { - (void) index; - (void) value; - (void) opt; + static const int defaultVSTSampleRateValue = 16384; + static const int defaultVSTBlockSizeValue = 512; - switch (opcode) + // handles non plugin-specific callbacks.. + VstIntPtr handleGeneralCallback (VstInt32 opcode, VstInt32 index, VstInt32 value, void *ptr, float opt) { - case audioMasterCanDo: + (void) index; + (void) value; + (void) opt; + + switch (opcode) { - static const char* canDos[] = { "supplyIdle", - "sendVstEvents", - "sendVstMidiEvent", - "sendVstTimeInfo", - "receiveVstEvents", - "receiveVstMidiEvent", - "supportShell", - "shellCategory" }; + case audioMasterCanDo: + { + static const char* canDos[] = { "supplyIdle", + "sendVstEvents", + "sendVstMidiEvent", + "sendVstTimeInfo", + "receiveVstEvents", + "receiveVstMidiEvent", + "supportShell", + "shellCategory" }; - for (int i = 0; i < numElementsInArray (canDos); ++i) - if (strcmp (canDos[i], (const char*) ptr) == 0) - return 1; + for (int i = 0; i < numElementsInArray (canDos); ++i) + if (strcmp (canDos[i], (const char*) ptr) == 0) + return 1; - return 0; - } + return 0; + } - case audioMasterVersion: return 0x2400; - case audioMasterCurrentId: return shellUIDToCreate; - case audioMasterGetNumAutomatableParameters: return 0; - case audioMasterGetAutomationState: return 1; - case audioMasterGetVendorVersion: return 0x0101; + case audioMasterVersion: return 0x2400; + case audioMasterCurrentId: return shellUIDToCreate; + case audioMasterGetNumAutomatableParameters: return 0; + case audioMasterGetAutomationState: return 1; + case audioMasterGetVendorVersion: return 0x0101; - case audioMasterGetVendorString: - case audioMasterGetProductString: - { - String hostName ("Juce VST Host"); + case audioMasterGetVendorString: + case audioMasterGetProductString: + { + String hostName ("Juce VST Host"); - if (JUCEApplication::getInstance() != 0) - hostName = JUCEApplication::getInstance()->getApplicationName(); + if (JUCEApplication::getInstance() != 0) + hostName = JUCEApplication::getInstance()->getApplicationName(); - hostName.copyToCString ((char*) ptr, jmin (kVstMaxVendorStrLen, kVstMaxProductStrLen) - 1); - break; - } + hostName.copyToCString ((char*) ptr, jmin (kVstMaxVendorStrLen, kVstMaxProductStrLen) - 1); + break; + } - case audioMasterGetSampleRate: return (VstIntPtr) defaultVSTSampleRateValue; - case audioMasterGetBlockSize: return (VstIntPtr) defaultVSTBlockSizeValue; - case audioMasterSetOutputSampleRate: return 0; + case audioMasterGetSampleRate: return (VstIntPtr) defaultVSTSampleRateValue; + case audioMasterGetBlockSize: return (VstIntPtr) defaultVSTBlockSizeValue; + case audioMasterSetOutputSampleRate: return 0; - default: - DBG ("*** Unhandled VST Callback: " + String ((int) opcode)); - break; - } + default: + DBG ("*** Unhandled VST Callback: " + String ((int) opcode)); + break; + } - return 0; + return 0; + } } // handles callbacks for a specific plugin @@ -41340,17 +41396,20 @@ void Component::sendLookAndFeelChange() } } -static const Identifier getColourPropertyId (const int colourId) +namespace ComponentHelpers { - String s; - s.preallocateStorage (18); - s << "jcclr_" << String::toHexString (colourId); - return s; + const Identifier getColourPropertyId (const int colourId) + { + String s; + s.preallocateStorage (18); + s << "jcclr_" << String::toHexString (colourId); + return s; + } } const Colour Component::findColour (const int colourId, const bool inheritFromParent) const { - var* v = properties.getItem (getColourPropertyId (colourId)); + var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)); if (v != 0) return Colour ((int) *v); @@ -41363,18 +41422,18 @@ const Colour Component::findColour (const int colourId, const bool inheritFromPa bool Component::isColourSpecified (const int colourId) const { - return properties.contains (getColourPropertyId (colourId)); + return properties.contains (ComponentHelpers::getColourPropertyId (colourId)); } void Component::removeColour (const int colourId) { - if (properties.remove (getColourPropertyId (colourId))) + if (properties.remove (ComponentHelpers::getColourPropertyId (colourId))) colourChanged(); } void Component::setColour (const int colourId, const Colour& colour) { - if (properties.set (getColourPropertyId (colourId), (int) colour.getARGB())) + if (properties.set (ComponentHelpers::getColourPropertyId (colourId), (int) colour.getARGB())) colourChanged(); } @@ -45388,10 +45447,13 @@ bool CodeDocument::hasChangedSinceSavePoint() const throw() return currentActionIndex != indexOfSavedState; } -static int getCodeCharacterCategory (const juce_wchar character) throw() +namespace CodeDocumentHelpers { - return (CharacterFunctions::isLetterOrDigit (character) || character == '_') - ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); + int getCharacterType (const juce_wchar character) throw() + { + return (CharacterFunctions::isLetterOrDigit (character) || character == '_') + ? 2 : (CharacterFunctions::isWhitespace (character) ? 0 : 1); + } } const CodeDocument::Position CodeDocument::findWordBreakAfter (const Position& position) const throw() @@ -45411,9 +45473,9 @@ const CodeDocument::Position CodeDocument::findWordBreakAfter (const Position& p if (i == 0) { - const int type = getCodeCharacterCategory (p.getCharacter()); + const int type = CodeDocumentHelpers::getCharacterType (p.getCharacter()); - while (i < maxDistance && type == getCodeCharacterCategory (p.getCharacter())) + while (i < maxDistance && type == CodeDocumentHelpers::getCharacterType (p.getCharacter())) { ++i; p.moveBy (1); @@ -45460,9 +45522,9 @@ const CodeDocument::Position CodeDocument::findWordBreakBefore (const Position& if (i < maxDistance && ! stoppedAtLineStart) { - const int type = getCodeCharacterCategory (p.movedBy (-1).getCharacter()); + const int type = CodeDocumentHelpers::getCharacterType (p.movedBy (-1).getCharacter()); - while (i < maxDistance && type == getCodeCharacterCategory (p.movedBy (-1).getCharacter())) + while (i < maxDistance && type == CodeDocumentHelpers::getCharacterType (p.movedBy (-1).getCharacter())) { p.moveBy (-1); ++i; @@ -46467,22 +46529,25 @@ void CodeEditorComponent::goToStartOfDocument (const bool selecting) moveCaretTo (CodeDocument::Position (&document, 0, 0), selecting); } -static int findFirstNonWhitespaceChar (const String& line) throw() +namespace CodeEditorHelpers { - const int len = line.length(); + int findFirstNonWhitespaceChar (const String& line) throw() + { + const int len = line.length(); - for (int i = 0; i < len; ++i) - if (! CharacterFunctions::isWhitespace (line [i])) - return i; + for (int i = 0; i < len; ++i) + if (! CharacterFunctions::isWhitespace (line [i])) + return i; - return 0; + return 0; + } } void CodeEditorComponent::goToStartOfLine (const bool selecting) { newTransaction(); - int index = findFirstNonWhitespaceChar (caretPos.getLineText()); + int index = CodeEditorHelpers::findFirstNonWhitespaceChar (caretPos.getLineText()); if (index >= caretPos.getIndexInLine() && caretPos.getIndexInLine() > 0) index = 0; @@ -50720,11 +50785,14 @@ void Slider::modifierKeysChanged (const ModifierKeys& modifiers) } } -static double smallestAngleBetween (double a1, double a2) +namespace SliderHelpers { - return jmin (std::abs (a1 - a2), - std::abs (a1 + double_Pi * 2.0 - a2), - std::abs (a2 + double_Pi * 2.0 - a1)); + double smallestAngleBetween (double a1, double a2) throw() + { + return jmin (std::abs (a1 - a2), + std::abs (a1 + double_Pi * 2.0 - a2), + std::abs (a2 + double_Pi * 2.0 - a1)); + } } void Slider::mouseDrag (const MouseEvent& e) @@ -50766,7 +50834,8 @@ void Slider::mouseDrag (const MouseEvent& e) if (angle > rotaryEnd) { - if (smallestAngleBetween (angle, rotaryStart) <= smallestAngleBetween (angle, rotaryEnd)) + if (SliderHelpers::smallestAngleBetween (angle, rotaryStart) + <= SliderHelpers::smallestAngleBetween (angle, rotaryEnd)) angle = rotaryStart; else angle = rotaryEnd; @@ -58316,6 +58385,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_, FileBrowserComponent::~FileBrowserComponent() { + fileListComponent = 0; fileList = 0; thread.stopThread (10000); } @@ -60197,39 +60267,42 @@ namespace KeyboardFocusHelpers } } -static Component* getIncrementedComponent (Component* const current, const int delta) +namespace KeyboardFocusHelpers { - Component* focusContainer = current->getParentComponent(); - - if (focusContainer != 0) + Component* getIncrementedComponent (Component* const current, const int delta) { - while (focusContainer->getParentComponent() != 0 && ! focusContainer->isFocusContainer()) - focusContainer = focusContainer->getParentComponent(); + Component* focusContainer = current->getParentComponent(); if (focusContainer != 0) { - Array comps; - KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps); + while (focusContainer->getParentComponent() != 0 && ! focusContainer->isFocusContainer()) + focusContainer = focusContainer->getParentComponent(); - if (comps.size() > 0) + if (focusContainer != 0) { - const int index = comps.indexOf (current); - return comps [(index + comps.size() + delta) % comps.size()]; + Array comps; + KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps); + + if (comps.size() > 0) + { + const int index = comps.indexOf (current); + return comps [(index + comps.size() + delta) % comps.size()]; + } } } - } - return 0; + return 0; + } } Component* KeyboardFocusTraverser::getNextComponent (Component* current) { - return getIncrementedComponent (current, 1); + return KeyboardFocusHelpers::getIncrementedComponent (current, 1); } Component* KeyboardFocusTraverser::getPreviousComponent (Component* current) { - return getIncrementedComponent (current, -1); + return KeyboardFocusHelpers::getIncrementedComponent (current, -1); } Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentComponent) @@ -62292,9 +62365,12 @@ MultiDocumentPanel::~MultiDocumentPanel() closeAllDocuments (false); } -static bool shouldDeleteComp (Component* const c) +namespace MultiDocHelpers { - return c->getProperties() ["mdiDocumentDelete_"]; + bool shouldDeleteComp (Component* const c) + { + return c->getProperties() ["mdiDocumentDelete_"]; + } } bool MultiDocumentPanel::closeAllDocuments (const bool checkItsOkToCloseFirst) @@ -62414,7 +62490,7 @@ bool MultiDocumentPanel::closeDocument (Component* component, component->removeComponentListener (this); - const bool shouldDelete = shouldDeleteComp (component); + const bool shouldDelete = MultiDocHelpers::shouldDeleteComp (component); component->getProperties().remove ("mdiDocumentDelete_"); component->getProperties().remove ("mdiDocumentBkg_"); @@ -62600,7 +62676,7 @@ void MultiDocumentPanel::setLayoutMode (const LayoutMode newLayoutMode) addDocument (c, Colour ((int) c->getProperties().getWithDefault ("mdiDocumentBkg_", (int) Colours::white.getARGB())), - shouldDeleteComp (c)); + MultiDocHelpers::shouldDeleteComp (c)); } } } @@ -65094,20 +65170,87 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_LookAndFeel.cpp ***/ BEGIN_JUCE_NAMESPACE -static const Colour createBaseColour (const Colour& buttonColour, - const bool hasKeyboardFocus, - const bool isMouseOverButton, - const bool isButtonDown) throw() +namespace LookAndFeelHelpers { - const float sat = hasKeyboardFocus ? 1.3f : 0.9f; - const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); + void createRoundedPath (Path& p, + const float x, const float y, + const float w, const float h, + const float cs, + const bool curveTopLeft, const bool curveTopRight, + const bool curveBottomLeft, const bool curveBottomRight) throw() + { + const float cs2 = 2.0f * cs; - if (isButtonDown) - return baseColour.contrasting (0.2f); - else if (isMouseOverButton) - return baseColour.contrasting (0.1f); + if (curveTopLeft) + { + p.startNewSubPath (x, y + cs); + p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f); + } + else + { + p.startNewSubPath (x, y); + } + + if (curveTopRight) + { + p.lineTo (x + w - cs, y); + p.addArc (x + w - cs2, y, cs2, cs2, 0.0f, float_Pi * 0.5f); + } + else + { + p.lineTo (x + w, y); + } + + if (curveBottomRight) + { + p.lineTo (x + w, y + h - cs); + p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi); + } + else + { + p.lineTo (x + w, y + h); + } + + if (curveBottomLeft) + { + p.lineTo (x + cs, y + h); + p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f); + } + else + { + p.lineTo (x, y + h); + } + + p.closeSubPath(); + } + + const Colour createBaseColour (const Colour& buttonColour, + const bool hasKeyboardFocus, + const bool isMouseOverButton, + const bool isButtonDown) throw() + { + const float sat = hasKeyboardFocus ? 1.3f : 0.9f; + const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); + + if (isButtonDown) + return baseColour.contrasting (0.2f); + else if (isMouseOverButton) + return baseColour.contrasting (0.1f); + + return baseColour; + } + + const TextLayout layoutTooltipText (const String& text) throw() + { + const float tooltipFontSize = 12.0f; + const int maxToolTipWidth = 400; + + const Font f (tooltipFontSize, Font::bold); + TextLayout tl (text, f); + tl.layout (maxToolTipWidth, Justification::left, true); - return baseColour; + return tl; + } } LookAndFeel::LookAndFeel() @@ -65378,9 +65521,9 @@ void LookAndFeel::drawButtonBackground (Graphics& g, const float indentT = button.isConnectedOnTop() ? 0.1f : halfThickness; const float indentB = button.isConnectedOnBottom() ? 0.1f : halfThickness; - const Colour baseColour (createBaseColour (backgroundColour, - button.hasKeyboardFocus (true), - isMouseOverButton, isButtonDown) + const Colour baseColour (LookAndFeelHelpers::createBaseColour (backgroundColour, + button.hasKeyboardFocus (true), + isMouseOverButton, isButtonDown) .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); drawGlassLozenge (g, @@ -65435,11 +65578,9 @@ void LookAndFeel::drawTickBox (Graphics& g, const float boxSize = w * 0.7f; drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize, - createBaseColour (component.findColour (TextButton::buttonColourId) - .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), - true, - isMouseOverButton, - isButtonDown), + LookAndFeelHelpers::createBaseColour (component.findColour (TextButton::buttonColourId) + .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), + true, isMouseOverButton, isButtonDown), isEnabled ? ((isButtonDown || isMouseOverButton) ? 1.1f : 0.5f) : 0.3f); if (ticked) @@ -66152,7 +66293,7 @@ int LookAndFeel::getMenuWindowFlags() void LookAndFeel::drawMenuBarBackground (Graphics& g, int width, int height, bool, MenuBarComponent& menuBar) { - const Colour baseColour (createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false)); + const Colour baseColour (LookAndFeelHelpers::createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false)); if (menuBar.isEnabled()) { @@ -66263,10 +66404,10 @@ void LookAndFeel::drawComboBox (Graphics& g, int width, int height, const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f; - const Colour baseColour (createBaseColour (box.findColour (ComboBox::buttonColourId), - box.hasKeyboardFocus (true), - false, isButtonDown) - .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f)); + const Colour baseColour (LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), + box.hasKeyboardFocus (true), + false, isButtonDown) + .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f)); drawGlassLozenge (g, buttonX + outlineThickness, buttonY + outlineThickness, @@ -66399,10 +66540,10 @@ void LookAndFeel::drawLinearSliderThumb (Graphics& g, { const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2); - Colour knobColour (createBaseColour (slider.findColour (Slider::thumbColourId), - slider.hasKeyboardFocus (false) && slider.isEnabled(), - slider.isMouseOverOrDragging() && slider.isEnabled(), - slider.isMouseButtonDown() && slider.isEnabled())); + Colour knobColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), + slider.hasKeyboardFocus (false) && slider.isEnabled(), + slider.isMouseOverOrDragging() && slider.isEnabled(), + slider.isMouseButtonDown() && slider.isEnabled())); const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; @@ -66485,11 +66626,10 @@ void LookAndFeel::drawLinearSlider (Graphics& g, { const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); - Colour baseColour (createBaseColour (slider.findColour (Slider::thumbColourId) - .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), - false, - isMouseOver, - isMouseOver || slider.isMouseButtonDown())); + Colour baseColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId) + .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), + false, isMouseOver, + isMouseOver || slider.isMouseButtonDown())); drawShinyButtonShape (g, (float) x, (float) y, sliderPos - (float) x, (float) height, 0.0f, @@ -66631,21 +66771,9 @@ ImageEffectFilter* LookAndFeel::getSliderEffect() return 0; } -static const TextLayout layoutTooltipText (const String& text) throw() -{ - const float tooltipFontSize = 12.0f; - const int maxToolTipWidth = 400; - - const Font f (tooltipFontSize, Font::bold); - TextLayout tl (text, f); - tl.layout (maxToolTipWidth, Justification::left, true); - - return tl; -} - void LookAndFeel::getTooltipSize (const String& tipText, int& width, int& height) { - const TextLayout tl (layoutTooltipText (tipText)); + const TextLayout tl (LookAndFeelHelpers::layoutTooltipText (tipText)); width = tl.getWidth() + 14; height = tl.getHeight() + 6; @@ -66662,7 +66790,7 @@ void LookAndFeel::drawTooltip (Graphics& g, const String& text, int width, int h g.drawRect (0, 0, width, height, 1); #endif - const TextLayout tl (layoutTooltipText (text)); + const TextLayout tl (LookAndFeelHelpers::layoutTooltipText (text)); g.setColour (findColour (TooltipWindow::textColourId)); tl.drawWithin (g, 0, 0, width, height, Justification::centred); @@ -67569,25 +67697,27 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, if (isItemSelected) g.fillAll (findColour (DirectoryContentsDisplayComponent::highlightColourId)); - g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId)); - g.setFont (height * 0.7f); - - Image im; - if (icon != 0) - im = *icon; - - if (im.isNull()) - im = isDirectory ? getDefaultFolderImage() - : getDefaultDocumentFileImage(); - const int x = 32; + g.setColour (Colours::black); - if (im.isValid()) + if (icon != 0 && icon->isValid()) { - g.drawImageWithin (im, 2, 2, x - 4, height - 4, + g.drawImageWithin (*icon, 2, 2, x - 4, height - 4, RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false); } + else + { + const Drawable* d = isDirectory ? getDefaultFolderImage() + : getDefaultDocumentFileImage(); + + if (d != 0) + d->drawWithin (g, Rectangle (2.0f, 2.0f, x - 4.0f, height - 4.0f), + RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); + } + + g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId)); + g.setFont (height * 0.7f); if (width > 450 && ! isDirectory) { @@ -67673,82 +67803,75 @@ void LookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp, filenameBox->setBounds (x + 50, y, w - 50, controlsHeight); } -const Image LookAndFeel::getDefaultFolderImage() -{ - static const unsigned char foldericon_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,28,8,6,0,0,0,0,194,189,34,0,0,0,4,103,65,77,65,0,0,175,200,55,5, - 138,233,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,201,101,60,0,0,9,46,73,68,65,84,120,218,98,252,255,255,63,3,50,240,41,95,192, - 197,205,198,32,202,204,202,33,241,254,235,47,133,47,191,24,180,213,164,133,152,69,24,222,44,234,42,77,188,245,31,170,129,145,145,145,1,29,128,164,226,91,86,113,252,248,207,200,171,37,39,204,239,170,43, - 254,206,218,88,231,61,62,61,0,1,196,2,149,96,116,200,158,102,194,202,201,227,197,193,206,166,194,204,193,33,195,202,204,38,42,197,197,42,196,193,202,33,240,241,231,15,134,151,95,127,9,2,149,22,0,241,47, - 152,230,128,134,245,204,63,191,188,103,83,144,16,16,228,229,102,151,76,239,217,32,199,204,198,169,205,254,159,65,245,203,79,6,169,131,151,30,47,1,42,91,10,196,127,208,236,101,76,235,90,43,101,160,40,242, - 19,32,128,64,78,98,52,12,41,149,145,215,52,89,162,38,35,107,39,196,203,203,192,206,194,206,192,197,198,202,192,203,197,198,192,205,193,206,240,252,227,103,134,139,55,175,191,127,243,242,78,219,187,207, - 63,215,255,98,23,48,228,227,96,83,98,102,102,85,225,224,228,80,20,224,230,86,226,225,228,150,103,101,97,101,230,227,228,96,224,0,234,191,243,252,5,195,222,19,199,38,191,127,112,161,83,66,199,86,141,131, - 149,69,146,133,153,69,137,149,133,89,157,141,131,77,83,140,143,243,219,255,31,159,123,0,2,136,69,90,207,129,157,71,68,42,66,71,73,209,210,81,91,27,24,142,140,12,127,255,253,103,0,185,236,31,3,144,6,50, - 148,68,216,25,216,24,117,4,239,11,243,214,49,50,51,84,178,48,114,240,112,177,114,177,240,115,113,49,241,112,112,48,176,179,178,51,176,48,49,3,85,255,99,248,253,247,15,195,247,159,191,25,30,191,126,253, - 71,74,76,200,66,75,197,119,138,168,144,160,150,168,0,183,160,152,32,15,175,188,184,32,199,175,191,127,25,214,31,184,120,247,236,209,253,159,0,2,136,133,95,70,93,74,88,80,196,83,69,66,130,149,9,104,219, - 151,31,191,193,150,194,146,6,136,102,102,98,100,16,227,231,103,16,23,210,230,101,101,102,100,248,255,143,137,225,223,63,6,6,22,102,38,134,239,191,126,49,220,123,241,134,225,227,247,175,64,7,252,101,96, - 97,249,207,192,193,198,200,160,171,34,192,108,165,235,104,42,204,207,101,42,194,199,197,192,199,201,198,192,197,193,202,192,198,202,194,176,247,194,3,134,155,183,110,61,188,127,124,221,19,128,0,92,146, - 49,14,64,64,16,69,63,153,85,16,52,18,74,71,112,6,87,119,0,165,160,86,138,32,172,216,29,49,182,84,253,169,94,94,230,127,17,87,133,34,146,174,3,88,126,240,219,164,147,113,31,145,244,152,112,179,211,130, - 34,31,203,113,162,233,6,36,49,163,174,74,124,140,60,141,144,165,161,220,228,25,3,24,105,255,17,168,101,1,139,245,188,93,104,251,73,239,235,50,90,189,111,175,0,98,249,254,254,249,175,239,223,190,126,6, - 5,27,19,47,90,170,102,0,249,158,129,129,141,133,25,228,20,6,38,38,72,74,7,185,243,243,247,239,12,23,31,60,98,228,231,253,207,144,227,107,206,32,202,199,193,240,249,251,127,134,95,191,255,49,124,249,250, - 159,225,237,239,95,12,63,127,1,35,229,31,194,71,32,71,63,123,251,245,223,197,27,183,159,189,187,178,103,61,80,232,59,64,0,177,48,252,5,134,225,255,191,223,126,254,250,13,182,132,1,41,167,176,3,53,128, - 188,254,226,253,103,96,212,252,96,120,247,249,203,255,79,223,191,254,255,250,235,199,191,239,63,191,255,87,145,17,100,73,116,181,100,252,249,243,63,195,149,123,223,193,14,132,101,55,96,52,3,125,255,15, - 204,254,15,132,160,232,253,13,20,124,248,226,227,223,23,207,30,221,120,119,255,226,109,160,210,31,0,1,196,242,231,219,135,175,140,255,126,190,7,197,37,35,19,34,216,65,248,211,143,111,255,79,223,121,240, - 255,211,183,79,76,220,156,172,12,236,204,140,140,252,124,28,140,250,226,82,140,106,82,34,140,124,156,156,12,175,222,253,1,90,4,137,162,63,127,33,161,6,178,242,215,239,255,224,160,255,15,198,12,64,7,48, - 128,211,200,253,151,111,254,254,248,240,236,44,80,217,71,80,246,4,8,32,160,31,255,255,100,102,248,243,238,199,159,63,16,221,16,19,128,248,31,195,181,199,207,254,255,253,247,133,49,212,78,27,104,8,11,40, - 94,25,184,216,89,129,108,38,70,144,242,183,31,17,105,230,63,148,248,15,97,49,252,248,249,15,20,85,72,105,9,148,187,254,49,220,127,254,242,207,243,75,135,14,128,130,31,84,64,1,4,16,203,247,143,175,127, - 48,253,254,246,234,7,48,206,96,137,13,4,64,65,248,234,195,7,6,7,3,57,70,33,46,97,134,111,63,254,50,252,5,250,244,51,216,103,255,192,185,0,150,91,80,44,135,242,127,253,129,164,23,24,96,102,250,207,112, - 255,213,219,255,247,31,63,188,251,246,201,173,199,176,2,13,32,128,88,62,188,121,241,243,211,231,207,31,126,2,147,236,63,168,6,144,193,223,190,255,254,207,198,198,192,40,35,44,206,240,252,205,79,6,132, - 223,24,224,150,32,251,28,25,128,211,29,19,170,24,51,48,88,111,61,127,206,248,254,245,179,139,192,18,247,219,239,239,95,192,249,9,32,128,88,126,124,249,248,231,203,183,111,159,128,33,240,15,24,68,160,180, - 2,204,223,140,12,111,63,127,102,16,228,229,4,6,53,35,195,31,176,119,25,112,3,70,84,55,0,203,50,112,33,134,108,249,103,160,7,159,189,126,253,235,235,227,203,7,255,255,251,247,13,86,63,0,4,16,168,46,248, - 199,250,231,243,235,159,191,126,254,248,245,251,47,23,11,51,51,48,184,152,24,94,127,250,248,95,68,136,151,241,243,55,96,208,51,160,218,255,31,139,27,144,197,254,98,201,202,79,223,124,96,120,245,232,250, - 185,119,143,174,95,250,243,243,219,119,152,60,64,0,129,2,234,223,183,215,15,95,48,254,255,253,3,146,109,192,229,5,195,135,47,159,25,248,184,121,24,126,0,227,29,88,240,49,252,101,36,14,255,1,90,249,7,156, - 222,17,24,24,164,12,207,223,189,99,248,250,252,230,97,96,229,245,2,104,231,111,152,3,0,2,8,228,128,191,15,239,220,120,255,255,223,159,47,160,116,0,42,44,222,124,250,244,239,207,255,63,12,236,108,236,64, - 67,65,81,0,52,244,63,113,248,47,52,10,96,14,98,2,230,191,119,223,127,48,60,121,254,248,235,151,55,207,46,1,163,252,35,114,128,1,4,16,40,10,254,191,121,249,252,199,175,159,63,191,254,2,230,45,118,22,22, - 134,219,207,94,252,231,224,100,103,250,247,15,148,32,64,85,12,34,14,254,227,72,6,255,225,9,240,63,138,26,46,96,214,189,249,244,37,195,139,167,143,30,124,253,246,253,9,40,245,255,71,202,30,0,1,196,2,226, - 0,243,232,159,239,63,127,124,253,11,202,94,64,169,23,31,62,50,138,137,242,49,50,0,211,195,223,255,80,7,252,199,159,6,224,137,145,9,146,231,153,160,165,218,23,96,29,240,244,237,59,134,111,175,31,95,250, - 252,230,241,83,244,182,1,64,0,177,192,28,14,76,132,31,128,169,19,88,220,126,253,207,206,198,196,32,38,36,0,244,61,11,176,148,251,139,145,3,208,29,0,178,16,82,228,66,42,174,223,192,26,8,152,162,25,222, - 125,248,200,240,242,253,39,134,151,79,238,126,254,242,242,238,177,15,47,30,190,5,215,242,72,0,32,128,224,14,96,254,255,231,61,168,92,123,241,254,253,127,1,62,78,6,78,110,78,134,223,64,195,254,50,98,183, - 24,36,12,202,179,224,202,9,88,228,253,132,90,250,246,211,71,134,55,175,94,254,122,255,250,249,247,15,175,159,126,249,251,237,195,135,95,175,110,31,122,117,251,244,49,160,150,111,255,209,218,128,0,1,152, - 44,183,21,0,65,32,136,110,247,254,255,243,122,9,187,64,105,174,74,22,138,25,173,80,208,194,188,238,156,151,217,217,15,32,182,197,37,83,201,4,31,243,178,169,232,242,214,224,223,252,103,175,35,85,1,41,129, - 228,148,142,8,214,30,32,149,6,161,204,109,182,53,236,184,156,78,142,147,195,153,89,35,198,3,87,166,249,220,227,198,59,218,48,252,223,185,111,30,1,132,228,128,127,31,222,124,248,248,27,24,152,28,60,220, - 220,12,44,172,172,224,224,103,5,102,98,144,133,160,236,244,229,231,47,134,239,223,127,49,188,121,251,158,225,241,179,103,12,31,223,189,254,251,227,221,139,55,191,62,188,120,246,235,205,189,59,207,238, - 94,58,241,228,254,109,144,101,159,128,248,51,40,9,32,97,80,217,255,15,221,1,0,1,4,143,130,207,159,191,126,252,246,234,213,111,94,126,94,118,73,94,9,198,127,64,223,126,252,246,147,225,243,215,239,12,223, - 128,229,198,251,15,239,24,62,189,126,249,227,203,171,135,47,63,189,122,252,228,235,155,199,247,95,63,188,118,227,197,227,123,247,127,255,250,249,30,104,198,7,32,126,11,181,252,7,212,183,160,4,247,7,155, - 197,48,0,16,64,112,7,60,121,241,238,189,16,207,15,134,63,63,216,25,95,125,248,198,112,227,241,27,134,15,239,223,50,124,126,245,228,253,143,55,143,158,191,123,116,237,226,171,135,55,175,126,253,252,225, - 229,183,47,159,95,254,253,245,227,253,175,159,223,223,193,124,7,181,20,84,105,252,70,143,103,124,0,32,128,224,14,224,102,253,251,81,144,253,223,235,167,207,30,254,124,127,231,252,155,143,175,159,188,250, - 246,254,249,125,96,60,62,248,250,233,253,147,119,207,238,221,6,150,214,175,129,106,191,130,18,19,146,133,120,125,72,8,0,4,16,34,27,190,121,112,251,3,211,159,69,143,110,223,229,120,255,232,230,221,215, - 79,239,62,4,102,203,207,72,241,9,11,218,63,72,89,137,20,207,98,100,93,16,0,8,32,70,144,1,64,14,168,209,199,7,196,194,160,166,27,212,135,95,96,65,10,173,95,254,34,219,6,51,128,88,7,96,235,21,129,0,64,0, - 193,28,192,8,174,53,33,152,1,155,133,184,12,196,165,4,151,133,232,0,32,192,0,151,97,210,163,246,134,208,52,0,0,0,0,73,69,78,68,174,66,96,130,0,0}; - - return ImageCache::getFromMemory (foldericon_png, sizeof (foldericon_png)); -} - -const Image LookAndFeel::getDefaultDocumentFileImage() -{ - static const unsigned char fileicon_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,32,8,6,0,0,0,115,122,122,244,0,0,0,4,103,65,77,65,0,0,175,200,55,5, - 138,233,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,201,101,60,0,0,4,99,73,68,65,84,120,218,98,252,255,255,63,3,12,48,50,50,50,1, - 169,127,200,98,148,2,160,153,204,64,243,254,226,146,7,8,32,22,52,203,255,107,233,233,91,76,93,176,184,232,239,239,95,127,24,40,112,8,19,51,203,255,179,23,175,108,1,90,190,28,104,54,43,80,232,207,127,44, - 62,3,8,32,6,144,24,84,156,25,132,189,252,3,146,255,83,9,220,127,254,242,134,162,138,170,10,208,92,144,3,152,97,118,33,99,128,0,98,66,114,11,200,1,92,255,254,252,225,32,215,215,32,127,64,240,127,80,60, - 50,40,72,136,169,47,95,179,118,130,136,148,140,0,40,80,128,33,193,136,174,7,32,128,144,29,192,8,117,41,59,209,22,66,241,191,255,16,12,244,19,195,63,48,134,240,255,0,9,115,125,93,239,252,130,130,108,168, - 249,44,232,102,0,4,16,19,22,62,51,33,11,255,195,44,4,211,255,25,96,16,33,6,117,24,56,226,25,24,202,139,10,75,226,51,115,66,160,105,13,197,17,0,1,196,68,172,79,255,33,91,206,192,192,128,176,22,17,10,200, - 234,32,161,240,31,24,10,255,24,152,153,153,184,39,244,247,117,107,234,234,105,131,66,1,154,224,193,0,32,128,240,58,0,22,180,255,144,18,13,40,136,33,113,140,36,255,15,17,26,48,12,81,15,145,255,254,251, - 31,131,0,59,171,84,81,73,105,33,208,216,191,200,161,12,16,64,44,248,131,251,63,10,31,198,253,143,38,6,83,7,11,33,228,232,2,123,4,202,226,228,96,151,132,166,49,144,35,126,131,196,0,2,136,5,103,60,51,252, - 71,49,12,213,130,255,168,226,232,150,254,255,15,143,6,80,202,3,133,16,200,198,63,127,193,229,17,39,16,127,135,217,7,16,64,88,67,0,28,143,255,25,225,46,135,249,18,155,133,240,178,4,205,145,8,62,52,186, - 32,234,152,160,118,194,179,35,64,0,177,96,11,123,144,236,95,104,92,162,228,113,36,11,81,125,140,112,56,186,131,96,226,176,172,137,148,229,193,0,32,128,88,112,167,248,255,112,223,48,34,165,110,6,124,190, - 253,143,61,106,192,9,19,73,28,25,0,4,16,206,40,248,251,15,45,104,209,130,21,51,222,145,18,238,127,180,68,8,244,250,95,164,16,66,6,0,1,196,130,45,253,195,12,250,135,53,206,255,195,131,18,213,98,236,81, - 243,31,154,11,144,115,8,50,0,8,32,156,81,0,203,227,12,80,223,98,230,4,68,72,96,38,78,84,11,65,9,250,47,146,3,145,1,64,0,97,117,192,95,112,34,68,138,130,255,176,224,251,143,226,51,6,6,68,29,192,136,20, - 77,200,69,54,35,3,36,49,255,69,77,132,112,0,16,64,44,56,139,94,36,7,96,102,59,164,108,249,31,181,82,98,64,203,174,255,144,234,142,127,88,146,33,64,0,97,205,134,240,120,67,75,76,136,224,198,140,22,6,44, - 142,66,201,41,255,177,231,2,128,0,194,25,5,255,254,161,134,192,127,6,28,229,0,129,242,1,150,56,33,81,138,209,28,96,0,8,32,172,81,0,78,3,104,190,68,182,224,31,146,197,224,56,6,146,140,176,202,135,17,169, - 96,130,40,64,56,0,139,93,0,1,132,61,10,64,248,31,106,156,162,199,55,204,65,255,144,178,38,74,84,252,71,51,239,63,246,68,8,16,64,44,216,74,1,88,217,13,203,191,32,1,80,58,7,133,224,127,6,68,114,6,241,65, - 81,197,8,101,255,71,114,33,92,237,127,228,52,128,233,2,128,0,98,193,149,3,64,117,193,255,127,255,81,75,191,127,168,5,18,136,255,31,45,161,49,32,151,134,72,252,127,12,216,203,98,128,0,98,193,210,144,135, - 248,30,201,242,127,208,252,140,145,27,160,113,206,136,148,197,192,121,159,17,53,184,225,149,17,22,23,0,4,16,11,182,150,237,63,168,207,96,142,248,143,163,72,6,203,253,67,13,61,6,104,14,66,46,17,254,65, - 19,40,182,16,0,8,32,22,108,109,235,255,176,234,24,35,79,255,199,222,30,64,81,135,90,35,194,211,4,142,92,0,16,64,88,29,0,107,7,254,251,247,31,53,78,241,54,207,80,29,135,209,96,249,143,189,46,0,8,32,116, - 7,252,101,102,103,103,228,103,99,96,248,193,198,137,53,248,49,125,204,128,225,227,255,88,18,54,47,176,25,202,205,195,205,6,109,11,194,149,0,4,16,35,204,85,208,254,27,159,128,176,176,142,166,182,142,21, - 48,4,248,129,41,143,13,217,16,70,52,95,147,0,254,0,187,69,95,223,188,122,125,235,206,141,107,7,129,252,247,64,123,193,237,66,128,0,66,118,0,168,189,198,3,196,252,32,135,64,105,54,228,230,19,185,29,100, - 168,175,191,0,241,7,32,254,4,196,159,129,246,254,2,73,2,4,16,11,90,72,125,135,210,63,161,138,153,169,212,75,255,15,117,196,15,40,134,119,215,1,2,12,0,187,0,132,247,216,161,197,124,0,0,0,0,73,69,78,68, - 174,66,96,130,0,0}; - - return ImageCache::getFromMemory (fileicon_png, sizeof (fileicon_png)); +// Pulls a drawable out of compressed valuetree data.. +Drawable* LookAndFeel::loadDrawableFromData (const void* data, size_t numBytes) +{ + MemoryInputStream m (data, numBytes, false); + GZIPDecompressorInputStream gz (m); + ValueTree drawable (ValueTree::readFromStream (gz)); + return Drawable::createFromValueTree (drawable.getChild (0), 0); +} + +const Drawable* LookAndFeel::getDefaultFolderImage() +{ + if (folderImage == 0) + { + static const unsigned char drawableData[] = + { 120,218,197,86,77,111,27,55,16,229,182,161,237,6,61,39,233,77,63,192,38,56,195,225,215,209,105,210,2,141,13,20,201,193,109,111,178,181,178,183,145,181,130,180,110,145,127,159,199,93,73,137,87,53,218,91,109,192,160,151,179,156,55,111,222,188,229,155,247, + 231,87,231,175,47,222,170,234,155,229,244,190,86,213,115,253,102,61,253,123,122,189,168,85,51,83,213,119,250,238,221,47,231,151,175,223,169,170,250,121,221,62,172,84,245,172,60,63,209,243,118,49,171,215,170,107,87,23,245,188,83,213,145,182,167,19,91, + 254,127,223,220,222,117,37,68,82,40,143,174,219,174,107,239,135,168,147,18,37,108,85,245,237,46,207,70,33,249,175,211,238,78,85,186,28,253,76,175,73,109,186,117,251,177,190,106,102,229,241,247,58,24,103,203,15,101,245,103,219,44,187,15,221,39,0,172,142, + 245,125,211,1,196,205,116,181,125,114,164,175,31,186,78,45,219,229,31,245,186,189,106,150,179,102,121,139,100,154,240,231,167,102,177,64,72,247,105,213,23,122,187,158,206,154,122,217,169,85,57,18,1,47,53,101,107,18,135,204,167,147,192,201,216,20,114, + 244,195,62,171,234,7,125,198,100,136,216,145,149,211,9,57,103,40,249,72,219,8,167,170,87,250,140,162,199,123,226,3,34,82,202,134,131,13,172,74,170,233,162,0,177,234,166,93,180,15,235,141,170,206,180,157,204,231,150,156,159,207,39,195,50,214,88,18,150, + 245,205,124,250,104,169,212,135,158,19,144,53,20,112,172,55,237,2,132,13,199,149,130,230,115,145,112,147,147,82,61,157,32,238,178,253,11,145,213,138,10,52,138,38,103,111,99,164,211,137,139,198,35,177,35,167,212,143,15,215,205,13,160,109,163,172,225,152, + 16,232,17,149,140,103,144,158,146,90,113,217,12,6,197,167,236,3,54,5,181,101,73,54,138,90,245,165,227,120,18,252,150,77,15,242,188,228,204,81,169,139,102,249,5,68,192,145,14,244,112,1,145,29,94,137,96,235,49,136,151,58,246,32,88,192,161,88,176,76,226, + 36,247,24,176,7,232,62,16,83,42,155,201,160,30,222,65,72,98,82,76,33,198,254,197,96,124,10,150,243,8,130,48,228,36,94,124,6,4,43,38,0,142,205,99,30,4,221,13,33,230,220,71,177,65,49,142,243,150,7,1,51,20,2,5,96,96,84,225,56,217,188,3,33,46,24,228,112, + 69,69,12,68,228,108,242,99,16,165,118,208,28,51,200,98,87,42,74,62,209,24,4,206,48,22,153,125,132,220,196,56,15,234,99,216,130,0,141,38,74,162,130,48,35,163,141,94,196,245,32,94,104,7,154,132,209,40,108,162,165,232,153,165,17,4,138,201,176,135,58,49, + 165,130,122,108,114,54,28,240,64,17,89,188,79,177,116,149,10,4,246,91,30,94,104,112,96,226,144,131,144,142,98,78,177,7,128,81,242,224,140,36,249,80,208,145,196,12,202,15,16,60,161,200,69,187,169,213,86,198,123,87,224,255,199,21,94,105,134,72,40,177,245, + 14,182,32,232,54,196,231,100,111,11,189,168,201,39,177,84,102,38,139,177,168,74,210,87,174,64,20,138,160,67,111,10,4,98,196,97,60,158,118,133,25,111,173,224,171,37,97,185,119,133,221,242,63,184,194,140,71,174,240,252,145,43,72,32,147,146,147,4,104,104, + 117,134,10,18,12,107,212,40,72,148,57,6,71,69,135,222,248,16,160,168,3,169,144,55,201,69,41,147,137,134,99,50,97,8,178,85,43,217,140,201,151,192,152,10,242,190,24,11,59,183,29,25,42,115,236,98,14,229,252,32,80,66,0,162,17,136,72,6,67,5,45,242,224,10, + 193,102,71,50,6,17,129,212,18,115,105,150,80,169,45,123,222,141,76,178,70,32,55,24,90,217,132,71,73,200,57,238,204,3,136,49,144,185,55,183,190,20,137,52,246,47,113,232,158,69,35,49,145,208,129,193,56,178,77,135,230,145,113,22,140,69,74,20,146,2,120,218, + 155,135,48,32,10,89,30,156,165,204,254,222,193,160,12,19,49,6,210,59,11,70,62,4,31,15,64,196,2,157,98,33,58,1,104,32,152,50,31,128,64,148,183,197,108,209,89,107,240,41,75,36,123,16,208,108,180,44,236,250,182,227,27,20,137,118,76,60,165,137,221,92,94, + 78,215,31,235,245,230,183,242,229,30,214,251,251,195,145,94,148,15,253,170,221,52,93,211,46,7,109,171,81,208,177,94,247,119,132,47,81,186,92,22,246,7,255,254,15,7,107,141,171,197,191,156,123,162,135,187,198,227,131,113,219,80,159,1,4,239,223,231,0,0 }; + + folderImage = loadDrawableFromData (drawableData, sizeof (drawableData)); + } + + return folderImage; +} + +const Drawable* LookAndFeel::getDefaultDocumentFileImage() +{ + if (documentImage == 0) + { + static const unsigned char drawableData[] = + { 120,218,213,88,77,115,219,54,16,37,147,208,246,228,214,75,155,246,164,123,29,12,176,216,197,199,49,105,218,94,156,153,78,114,72,219,155,108,75,137,26,89,212,200,116,59,233,175,239,3,105,201,164,68,50,158,166,233,76,196,11,69,60,173,128,197,123,139,183, + 124,241,234,217,155,103,207,207,126,204,242,7,171,233,213,44,203,31,23,47,54,211,191,166,231,203,89,182,184,204,242,147,226,195,165,219,252,125,150,229,249,207,155,242,102,157,229,143,210,227,199,197,101,121,113,115,53,91,85,89,85,174,207,102,243,42, + 203,143,10,125,58,209,233,251,171,197,219,119,85,250,173,97,151,30,157,151,85,85,94,53,168,147,132,50,226,179,252,225,246,143,174,179,44,63,254,101,90,189,203,242,34,5,127,84,172,77,118,93,109,202,247,179,55,139,203,244,248,97,161,179,63,202,197,170, + 122,93,125,192,196,242,227,226,106,81,205,54,217,197,116,125,251,228,168,56,191,169,170,108,85,174,126,159,109,202,55,139,213,229,98,245,182,249,97,254,240,167,197,114,137,5,86,31,214,245,111,175,203,37,254,230,162,92,150,55,155,180,148,249,237,39,203, + 94,215,127,58,10,213,245,39,203,234,249,102,249,87,47,203,63,129,204,49,227,252,73,225,149,145,104,131,245,254,116,34,202,82,164,16,153,179,236,108,177,234,7,49,41,237,130,144,167,17,144,15,42,104,239,93,12,35,32,99,68,9,187,24,125,7,244,77,23,36,164, + 40,56,226,61,12,107,229,130,215,100,105,24,227,89,17,246,211,105,55,140,49,218,43,207,100,245,72,28,195,70,17,230,201,118,8,243,164,139,233,95,88,23,52,152,162,54,104,48,217,237,105,15,111,91,107,253,131,160,118,34,239,69,128,54,232,135,101,121,61,203, + 110,169,181,147,2,253,159,82,48,180,229,247,167,74,193,41,141,188,35,93,241,116,18,148,113,214,120,207,113,47,19,109,16,51,182,153,193,5,59,2,10,90,69,114,218,135,48,2,50,198,43,171,189,152,81,144,88,108,85,136,78,246,64,54,42,163,35,69,30,3,121,82,38, + 98,81,98,70,64,70,139,34,111,163,167,49,144,13,202,138,179,58,220,23,52,180,186,54,104,48,79,109,208,96,198,219,19,31,220,187,118,10,6,65,237,100,222,139,5,109,80,191,30,236,151,162,135,147,142,30,68,105,182,58,6,22,84,43,229,124,148,116,97,145,55,231, + 139,11,76,228,16,37,14,48,205,145,77,134,34,176,55,152,182,200,57,99,93,204,144,145,253,65,97,229,132,72,104,63,62,71,21,140,54,186,41,226,59,84,19,63,130,15,222,235,224,185,59,104,27,226,68,101,153,241,227,177,248,29,20,136,26,8,252,178,183,241,219, + 131,137,160,209,107,109,92,79,124,16,211,184,104,93,77,130,110,124,2,65,172,67,201,60,157,88,163,2,91,99,92,216,198,55,78,69,75,190,150,119,84,98,200,71,150,109,124,36,204,227,52,8,33,229,223,68,167,173,167,131,248,137,212,226,141,19,233,160,154,248, + 144,142,195,140,137,185,59,104,15,247,119,40,126,23,69,81,200,242,110,254,123,20,49,94,112,110,245,199,111,241,167,87,36,252,101,138,132,149,22,22,38,65,134,29,182,139,24,230,192,31,144,184,133,130,72,44,131,210,142,111,147,216,30,76,123,30,113,206,242, + 150,196,157,65,129,130,76,180,194,61,34,225,160,5,228,233,160,118,34,137,26,202,115,212,29,108,72,134,243,223,90,114,226,199,226,119,80,6,245,152,197,122,217,146,184,53,24,140,210,30,21,59,80,79,124,182,202,71,207,218,112,159,72,80,53,140,109,68,2,191, + 227,217,210,78,36,94,137,88,231,82,157,8,176,61,0,122,191,19,137,3,255,13,39,183,228,20,193,151,144,119,166,79,36,40,253,156,138,72,11,181,19,137,14,46,176,217,27,180,135,251,219,31,255,235,61,148,165,96,72,122,118,23,229,81,52,135,24,250,163,183,216, + 211,43,17,217,151,136,253,116,137,28,53,188,127,92,188,221,76,47,23,169,59,90,167,144,141,239,197,86,104,141,189,60,157,80,84,142,140,4,31,154,241,122,105,132,41,107,13,201,39,86,120,24,82,114,206,198,6,96,27,227,172,36,232,168,201,36,219,24,113,62,163, + 154,101,233,143,166,203,102,26,141,206,174,179,252,89,161,39,243,249,197,121,186,38,233,246,146,211,53,1,123,56,194,231,122,143,103,179,217,60,204,167,19,147,110,41,93,173,219,123,72,89,248,35,173,16,220,50,179,111,60,181,24,88,103,156,235,7,78,248,14, + 4,119,78,162,93,60,112,35,109,16,124,126,12,17,71,67,24,1,165,142,1,181,215,248,56,6,66,235,193,137,167,61,22,30,5,3,27,101,71,64,169,25,112,216,2,63,22,169,110,43,18,200,140,129,208,160,88,44,220,208,125,65,67,171,107,131,6,243,212,6,13,102,188,61,241, + 225,189,107,165,96,16,212,78,230,189,88,208,6,245,235,214,237,235,150,62,167,110,155,106,170,53,133,192,117,193,20,84,78,74,174,98,39,92,156,8,112,21,46,80,106,12,209,207,225,228,16,113,59,225,126,87,60,133,25,209,34,36,2,99,242,52,197,48,30,75,244,247, + 212,238,246,182,173,221,185,78,215,127,167,221,162,163,221,250,152,217,146,196,222,145,100,223,235,105,108,28,250,149,212,74,224,86,2,213,118,110,119,204,224,144,208,38,214,131,200,14,214,223,120,189,230,53,1,193,70,133,154,131,56,223,16,229,48,188,14, + 201,205,213,121,71,233,68,89,15,124,103,37,53,26,11,118,176,127,169,88,166,158,219,178,117,173,83,108,75,95,55,68,186,193,53,246,146,206,127,6,63,53,78,58,228,204,155,224,113,74,91,232,221,195,240,105,215,34,29,138,64,128,183,8,130,233,71,173,56,54,101, + 99,75,186,111,65,58,28,229,145,82,19,152,12,99,180,81,130,131,75,234,229,220,247,53,231,154,79,205,185,185,155,199,249,172,38,85,253,204,76,68,95,92,204,207,255,221,75,178,227,14,187,224,224,97,202,172,173,219,12,167,130,133,9,54,135,245,92,176,29,134, + 165,110,139,141,18,16,223,29,188,183,65,207,144,106,144,151,143,128,224,176,168,110,140,32,62,56,110,219,195,54,235,20,68,209,216,34,232,21,6,41,234,157,39,211,201,107,160,230,66,225,56,153,9,101,21,37,237,150,204,14,115,208,22,221,54,216,230,33,116, + 14,65,14,44,19,8,236,73,71,246,182,110,125,224,75,132,195,214,247,163,36,51,252,84,76,124,37,212,100,88,62,183,179,76,67,217,218,242,244,229,116,243,126,182,185,254,21,105,126,208,220,239,94,229,30,21,203,244,202,117,93,94,47,170,69,185,106,246,60,219, + 3,29,23,155,250,109,237,29,170,72,175,109,119,129,127,235,9,92,20,85,185,254,72,220,147,162,121,235,219,13,44,144,225,63,241,244,165,51,0,0 }; + + documentImage = loadDrawableFromData (drawableData, sizeof (drawableData)); + } + + return documentImage; } void LookAndFeel::playAlertSound() @@ -67823,58 +67946,6 @@ void LookAndFeel::drawKeymapChangeButton (Graphics& g, int width, int height, Bu } } -static void createRoundedPath (Path& p, - const float x, const float y, - const float w, const float h, - const float cs, - const bool curveTopLeft, const bool curveTopRight, - const bool curveBottomLeft, const bool curveBottomRight) throw() -{ - const float cs2 = 2.0f * cs; - - if (curveTopLeft) - { - p.startNewSubPath (x, y + cs); - p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f); - } - else - { - p.startNewSubPath (x, y); - } - - if (curveTopRight) - { - p.lineTo (x + w - cs, y); - p.addArc (x + w - cs2, y, cs2, cs2, 0.0f, float_Pi * 0.5f); - } - else - { - p.lineTo (x + w, y); - } - - if (curveBottomRight) - { - p.lineTo (x + w, y + h - cs); - p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi); - } - else - { - p.lineTo (x + w, y + h); - } - - if (curveBottomLeft) - { - p.lineTo (x + cs, y + h); - p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f); - } - else - { - p.lineTo (x, y + h); - } - - p.closeSubPath(); -} - void LookAndFeel::drawShinyButtonShape (Graphics& g, float x, float y, float w, float h, float maxCornerSize, @@ -67891,11 +67962,11 @@ void LookAndFeel::drawShinyButtonShape (Graphics& g, const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f); Path outline; - createRoundedPath (outline, x, y, w, h, cs, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); + LookAndFeelHelpers::createRoundedPath (outline, x, y, w, h, cs, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); ColourGradient cg (baseColour, 0.0f, y, baseColour.overlaidWith (Colour (0x070000ff)), 0.0f, y + h, @@ -68020,11 +68091,11 @@ void LookAndFeel::drawGlassLozenge (Graphics& g, const int intEdge = (int) edgeBlurRadius; Path outline; - createRoundedPath (outline, x, y, width, height, cs, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); + LookAndFeelHelpers::createRoundedPath (outline, x, y, width, height, cs, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); { ColourGradient cg (colour.darker (0.2f), 0, y, @@ -68070,15 +68141,15 @@ void LookAndFeel::drawGlassLozenge (Graphics& g, const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; Path highlight; - createRoundedPath (highlight, - x + leftIndent, - y + cs * 0.1f, - width - (leftIndent + rightIndent), - height * 0.4f, cs * 0.4f, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); + LookAndFeelHelpers::createRoundedPath (highlight, + x + leftIndent, + y + cs * 0.1f, + width - (leftIndent + rightIndent), + height * 0.4f, cs * 0.4f, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); g.setGradientFill (ColourGradient (colour.brighter (10.0f), 0, y + height * 0.06f, Colours::transparentWhite, 0, y + height * 0.4f, false)); @@ -78129,21 +78200,24 @@ const Rectangle& ComponentPeer::getNonFullScreenBounds() const throw() return lastNonFullscreenBounds; } -static FileDragAndDropTarget* findDragAndDropTarget (Component* c, - const StringArray& files, - FileDragAndDropTarget* const lastOne) +namespace ComponentPeerHelpers { - while (c != 0) + FileDragAndDropTarget* findDragAndDropTarget (Component* c, + const StringArray& files, + FileDragAndDropTarget* const lastOne) { - FileDragAndDropTarget* const t = dynamic_cast (c); + while (c != 0) + { + FileDragAndDropTarget* const t = dynamic_cast (c); - if (t != 0 && (t == lastOne || t->isInterestedInFileDrag (files))) - return t; + if (t != 0 && (t == lastOne || t->isInterestedInFileDrag (files))) + return t; - c = c->getParentComponent(); - } + c = c->getParentComponent(); + } - return 0; + return 0; + } } void ComponentPeer::handleFileDragMove (const StringArray& files, const Point& position) @@ -78160,7 +78234,7 @@ void ComponentPeer::handleFileDragMove (const StringArray& files, const Point -static bool areCoordsSensibleNumbers (Type x, Type y, Type w, Type h) +namespace { - const int maxVal = 0x3fffffff; + template + bool areCoordsSensibleNumbers (Type x, Type y, Type w, Type h) + { + const int maxVal = 0x3fffffff; - return (int) x >= -maxVal && (int) x <= maxVal - && (int) y >= -maxVal && (int) y <= maxVal - && (int) w >= -maxVal && (int) w <= maxVal - && (int) h >= -maxVal && (int) h <= maxVal; + return (int) x >= -maxVal && (int) x <= maxVal + && (int) y >= -maxVal && (int) y <= maxVal + && (int) w >= -maxVal && (int) w <= maxVal + && (int) h >= -maxVal && (int) h <= maxVal; + } } LowLevelGraphicsContext::LowLevelGraphicsContext() @@ -83919,11 +83996,14 @@ private: GradientEdgeTableRenderer& operator= (const GradientEdgeTableRenderer&); }; -static forcedinline int safeModulo (int n, const int divisor) throw() +namespace { - jassert (divisor > 0); - n %= divisor; - return (n < 0) ? (n + divisor) : n; + forcedinline int safeModulo (int n, const int divisor) throw() + { + jassert (divisor > 0); + n %= divisor; + return (n < 0) ? (n + divisor) : n; + } } template @@ -86366,13 +86446,16 @@ const FillType DrawableShape::FillAndStrokeState::readFillType (const ValueTree& return FillType(); } -static const Point calcThirdGradientPoint (const FillType& fillType) +namespace DrawableShapeHelpers { - const ColourGradient& g = *fillType.gradient; - const Point point3Source (g.point1.getX() + g.point2.getY() - g.point1.getY(), - g.point1.getY() + g.point1.getX() - g.point2.getX()); + const Point calcThirdGradientPoint (const FillType& fillType) + { + const ColourGradient& g = *fillType.gradient; + const Point point3Source (g.point1.getX() + g.point2.getY() - g.point1.getY(), + g.point1.getY() + g.point1.getX() - g.point2.getX()); - return point3Source.transformedBy (fillType.transform); + return point3Source.transformedBy (fillType.transform); + } } void DrawableShape::FillAndStrokeState::writeFillType (ValueTree& v, const FillType& fillType, @@ -86389,7 +86472,7 @@ void DrawableShape::FillAndStrokeState::writeFillType (ValueTree& v, const FillT v.setProperty (type, "gradient", undoManager); v.setProperty (gradientPoint1, gp1 != 0 ? gp1->toString() : fillType.gradient->point1.toString(), undoManager); v.setProperty (gradientPoint2, gp2 != 0 ? gp2->toString() : fillType.gradient->point2.toString(), undoManager); - v.setProperty (gradientPoint3, gp3 != 0 ? gp3->toString() : calcThirdGradientPoint (fillType).toString(), undoManager); + v.setProperty (gradientPoint3, gp3 != 0 ? gp3->toString() : DrawableShapeHelpers::calcThirdGradientPoint (fillType).toString(), undoManager); v.setProperty (radial, fillType.gradient->isRadial, undoManager); @@ -87610,28 +87693,32 @@ void DrawablePath::ValueTreeWrapper::Element::convertToPathBreak (UndoManager* u } } -static const Point findCubicSubdivisionPoint (float proportion, const Point points[4]) +namespace DrawablePathHelpers { - const Point mid1 (points[0] + (points[1] - points[0]) * proportion), - mid2 (points[1] + (points[2] - points[1]) * proportion), - mid3 (points[2] + (points[3] - points[2]) * proportion); + const Point findCubicSubdivisionPoint (float proportion, const Point points[4]) + { + const Point mid1 (points[0] + (points[1] - points[0]) * proportion), + mid2 (points[1] + (points[2] - points[1]) * proportion), + mid3 (points[2] + (points[3] - points[2]) * proportion); - const Point newCp1 (mid1 + (mid2 - mid1) * proportion), - newCp2 (mid2 + (mid3 - mid2) * proportion); + const Point newCp1 (mid1 + (mid2 - mid1) * proportion), + newCp2 (mid2 + (mid3 - mid2) * proportion); - return newCp1 + (newCp2 - newCp1) * proportion; -} + return newCp1 + (newCp2 - newCp1) * proportion; + } -static const Point findQuadraticSubdivisionPoint (float proportion, const Point points[3]) -{ - const Point mid1 (points[0] + (points[1] - points[0]) * proportion), - mid2 (points[1] + (points[2] - points[1]) * proportion); + const Point findQuadraticSubdivisionPoint (float proportion, const Point points[3]) + { + const Point mid1 (points[0] + (points[1] - points[0]) * proportion), + mid2 (points[1] + (points[2] - points[1]) * proportion); - return mid1 + (mid2 - mid1) * proportion; + return mid1 + (mid2 - mid1) * proportion; + } } float DrawablePath::ValueTreeWrapper::Element::findProportionAlongLine (const Point& targetPoint, Expression::EvaluationContext* nameFinder) const { + using namespace DrawablePathHelpers; const Identifier i (state.getType()); float bestProp = 0; @@ -88944,8 +89031,12 @@ private: if (gradient.isRadial) { - gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth), - dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight)); + if (userSpace) + gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth), + dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight)); + else + gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("cx", "50%"), 1.0f), + dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("cy", "50%"), 1.0f)); const float radius = getCoordLength (fillXml->getStringAttribute ("r", "50%"), gradientWidth); gradient.point2 = gradient.point1 + Point (radius, 0.0f); @@ -88954,11 +89045,22 @@ private: } else { - gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth), - dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight)); + if (userSpace) + { + gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth), + dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight)); + + gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth), + dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight)); + } + else + { + gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x1", "0%"), 1.0f), + dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y1", "0%"), 1.0f)); - gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth), - dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight)); + gradient.point2.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x2", "100%"), 1.0f), + dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y2", "0%"), 1.0f)); + } if (gradient.point1 == gradient.point2) return Colour (gradient.getColour (gradient.getNumColours() - 1)); @@ -91254,8 +91356,8 @@ CustomTypeface::CustomTypeface (InputStream& serialisedTypefaceStream) { clear(); - GZIPDecompressorInputStream gzin (&serialisedTypefaceStream, false); - BufferedInputStream in (&gzin, 32768, false); + GZIPDecompressorInputStream gzin (serialisedTypefaceStream); + BufferedInputStream in (gzin, 32768); name = in.readString(); isBold = in.readBool(); @@ -98441,7 +98543,7 @@ BEGIN_JUCE_NAMESPACE // internal helper object that holds the zlib structures so they don't have to be // included publicly. -class GZIPCompressorHelper +class GZIPCompressorOutputStream::GZIPCompressorHelper { public: GZIPCompressorHelper (const int compressionLevel, const bool nowrap) @@ -98514,6 +98616,8 @@ public: return 0; } + enum { gzipCompBufferSize = 32768 }; + private: zlibNamespace::z_stream stream; const uint8* data; @@ -98524,15 +98628,13 @@ public: bool finished, shouldFinish; }; -const int gzipCompBufferSize = 32768; - GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const destStream_, int compressionLevel, const bool deleteDestStream, const bool noWrap) : destStream (destStream_), streamToDelete (deleteDestStream ? destStream_ : 0), - buffer (gzipCompBufferSize) + buffer ((size_t) GZIPCompressorHelper::gzipCompBufferSize) { if (compressionLevel < 1 || compressionLevel > 9) compressionLevel = -1; @@ -98576,7 +98678,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) bool GZIPCompressorOutputStream::doNextBlock() { - const int len = helper->doNextBlock (buffer, gzipCompBufferSize); + const int len = helper->doNextBlock (buffer, (int) GZIPCompressorHelper::gzipCompBufferSize); if (len > 0) return destStream->write (buffer, len); @@ -105834,7 +105936,7 @@ BEGIN_JUCE_NAMESPACE // internal helper object that holds the zlib structures so they don't have to be // included publicly. -class GZIPDecompressHelper +class GZIPDecompressorInputStream::GZIPDecompressHelper { public: GZIPDecompressHelper (const bool noWrap) @@ -105906,6 +106008,8 @@ public: bool finished, needsDictionary, error, streamIsValid; + enum { gzipDecompBufferSize = 32768 }; + private: zlibNamespace::z_stream stream; uint8* data; @@ -105915,8 +106019,6 @@ private: GZIPDecompressHelper& operator= (const GZIPDecompressHelper&); }; -const int gzipDecompBufferSize = 32768; - GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sourceStream_, const bool deleteSourceWhenDestroyed, const bool noWrap_, @@ -105929,11 +106031,24 @@ GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const sou activeBufferSize (0), originalSourcePos (sourceStream_->getPosition()), currentPos (0), - buffer (gzipDecompBufferSize), + buffer ((size_t) GZIPDecompressHelper::gzipDecompBufferSize), helper (new GZIPDecompressHelper (noWrap_)) { } +GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream& sourceStream_) + : sourceStream (&sourceStream_), + uncompressedStreamLength (-1), + noWrap (false), + isEof (false), + activeBufferSize (0), + originalSourcePos (sourceStream_.getPosition()), + currentPos (0), + buffer ((size_t) GZIPDecompressHelper::gzipDecompBufferSize), + helper (new GZIPDecompressHelper (false)) +{ +} + GZIPDecompressorInputStream::~GZIPDecompressorInputStream() { } @@ -105969,7 +106084,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) if (helper->needsInput()) { - activeBufferSize = sourceStream->read (buffer, gzipDecompBufferSize); + activeBufferSize = sourceStream->read (buffer, (int) GZIPDecompressHelper::gzipDecompBufferSize); if (activeBufferSize > 0) { @@ -238629,6 +238744,55 @@ void InterProcessLock::exit() #define INVALID_FILE_ATTRIBUTES ((DWORD) -1) #endif +namespace WindowsFileHelpers +{ + int64 fileTimeToTime (const FILETIME* const ft) + { + static_jassert (sizeof (ULARGE_INTEGER) == sizeof (FILETIME)); // tell me if this fails! + + return (reinterpret_cast (ft)->QuadPart - literal64bit (116444736000000000)) / 10000; + } + + void timeToFileTime (const int64 time, FILETIME* const ft) + { + reinterpret_cast (ft)->QuadPart = time * 10000 + literal64bit (116444736000000000); + } + + const String getDriveFromPath (const String& path) + { + if (path.isNotEmpty() && path[1] == ':') + return path.substring (0, 2) + '\\'; + + return path; + } + + int64 getDiskSpaceInfo (const String& path, const bool total) + { + ULARGE_INTEGER spc, tot, totFree; + + if (GetDiskFreeSpaceEx (getDriveFromPath (path), &spc, &tot, &totFree)) + return total ? (int64) tot.QuadPart + : (int64) spc.QuadPart; + + return 0; + } + + unsigned int getWindowsDriveType (const String& path) + { + return GetDriveType (getDriveFromPath (path)); + } + + const File getSpecialFolderPath (int type) + { + WCHAR path [MAX_PATH + 256]; + + if (SHGetSpecialFolderPath (0, path, type, FALSE)) + return File (String (path)); + + return File::nonexistent; + } +} + const juce_wchar File::separator = '\\'; const String File::separatorString ("\\"); @@ -238817,20 +238981,9 @@ int64 File::getSize() const return 0; } -static int64 fileTimeToTime (const FILETIME* const ft) -{ - static_jassert (sizeof (ULARGE_INTEGER) == sizeof (FILETIME)); // tell me if this fails! - - return (reinterpret_cast (ft)->QuadPart - literal64bit (116444736000000000)) / 10000; -} - -static void timeToFileTime (const int64 time, FILETIME* const ft) -{ - reinterpret_cast (ft)->QuadPart = time * 10000 + literal64bit (116444736000000000); -} - void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int64& creationTime) const { + using namespace WindowsFileHelpers; WIN32_FILE_ATTRIBUTE_DATA attributes; if (GetFileAttributesEx (fullPath, GetFileExInfoStandard, &attributes)) @@ -238847,6 +239000,8 @@ void File::getFileTimesInternal (int64& modificationTime, int64& accessTime, int bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 creationTime) const { + using namespace WindowsFileHelpers; + bool ok = false; HANDLE h = CreateFile (fullPath, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); @@ -238893,18 +239048,10 @@ void File::findFileSystemRoots (Array& destArray) destArray.add (roots [i]); } -static const String getDriveFromPath (const String& path) -{ - if (path.isNotEmpty() && path[1] == ':') - return path.substring (0, 2) + '\\'; - - return path; -} - const String File::getVolumeLabel() const { TCHAR dest[64]; - if (! GetVolumeInformation (getDriveFromPath (getFullPathName()), dest, + if (! GetVolumeInformation (WindowsFileHelpers::getDriveFromPath (getFullPathName()), dest, numElementsInArray (dest), 0, 0, 0, 0, 0)) dest[0] = 0; @@ -238916,42 +239063,26 @@ int File::getVolumeSerialNumber() const TCHAR dest[64]; DWORD serialNum; - if (! GetVolumeInformation (getDriveFromPath (getFullPathName()), dest, + if (! GetVolumeInformation (WindowsFileHelpers::getDriveFromPath (getFullPathName()), dest, numElementsInArray (dest), &serialNum, 0, 0, 0, 0)) return 0; return (int) serialNum; } -static int64 getDiskSpaceInfo (const String& path, const bool total) -{ - ULARGE_INTEGER spc, tot, totFree; - - if (GetDiskFreeSpaceEx (getDriveFromPath (path), &spc, &tot, &totFree)) - return total ? (int64) tot.QuadPart - : (int64) spc.QuadPart; - - return 0; -} - int64 File::getBytesFreeOnVolume() const { - return getDiskSpaceInfo (getFullPathName(), false); + return WindowsFileHelpers::getDiskSpaceInfo (getFullPathName(), false); } int64 File::getVolumeTotalSize() const { - return getDiskSpaceInfo (getFullPathName(), true); -} - -static unsigned int getWindowsDriveType (const String& path) -{ - return GetDriveType (getDriveFromPath (path)); + return WindowsFileHelpers::getDiskSpaceInfo (getFullPathName(), true); } bool File::isOnCDRomDrive() const { - return getWindowsDriveType (getFullPathName()) == DRIVE_CDROM; + return WindowsFileHelpers::getWindowsDriveType (getFullPathName()) == DRIVE_CDROM; } bool File::isOnHardDisk() const @@ -238959,7 +239090,7 @@ bool File::isOnHardDisk() const if (fullPath.isEmpty()) return false; - const unsigned int n = getWindowsDriveType (getFullPathName()); + const unsigned int n = WindowsFileHelpers::getWindowsDriveType (getFullPathName()); if (fullPath.toLowerCase()[0] <= 'b' && fullPath[1] == ':') return n != DRIVE_REMOVABLE; @@ -238972,7 +239103,7 @@ bool File::isOnRemovableDrive() const if (fullPath.isEmpty()) return false; - const unsigned int n = getWindowsDriveType (getFullPathName()); + const unsigned int n = WindowsFileHelpers::getWindowsDriveType (getFullPathName()); return n == DRIVE_CDROM || n == DRIVE_REMOTE @@ -238980,16 +239111,6 @@ bool File::isOnRemovableDrive() const || n == DRIVE_RAMDISK; } -static const File juce_getSpecialFolderPath (int type) -{ - WCHAR path [MAX_PATH + 256]; - - if (SHGetSpecialFolderPath (0, path, type, FALSE)) - return File (String (path)); - - return File::nonexistent; -} - const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) { int csidlType = 0; @@ -239038,7 +239159,7 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ return File::nonexistent; } - return juce_getSpecialFolderPath (csidlType); + return WindowsFileHelpers::getSpecialFolderPath (csidlType); } const File File::getCurrentWorkingDirectory() @@ -239130,6 +239251,7 @@ public: bool* const isDir, bool* const isHidden, int64* const fileSize, Time* const modTime, Time* const creationTime, bool* const isReadOnly) { + using namespace WindowsFileHelpers; WIN32_FIND_DATA findData; if (handle == INVALID_HANDLE_VALUE) @@ -239907,44 +240029,45 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd // compiled on its own). #if JUCE_INCLUDED_FILE -static HKEY findKeyForPath (String name, - const bool createForWriting, - String& valueName) +namespace { - HKEY rootKey = 0; + HKEY findKeyForPath (String name, const bool createForWriting, String& valueName) + { + HKEY rootKey = 0; - if (name.startsWithIgnoreCase ("HKEY_CURRENT_USER\\")) - rootKey = HKEY_CURRENT_USER; - else if (name.startsWithIgnoreCase ("HKEY_LOCAL_MACHINE\\")) - rootKey = HKEY_LOCAL_MACHINE; - else if (name.startsWithIgnoreCase ("HKEY_CLASSES_ROOT\\")) - rootKey = HKEY_CLASSES_ROOT; + if (name.startsWithIgnoreCase ("HKEY_CURRENT_USER\\")) + rootKey = HKEY_CURRENT_USER; + else if (name.startsWithIgnoreCase ("HKEY_LOCAL_MACHINE\\")) + rootKey = HKEY_LOCAL_MACHINE; + else if (name.startsWithIgnoreCase ("HKEY_CLASSES_ROOT\\")) + rootKey = HKEY_CLASSES_ROOT; - if (rootKey != 0) - { - name = name.substring (name.indexOfChar ('\\') + 1); + if (rootKey != 0) + { + name = name.substring (name.indexOfChar ('\\') + 1); - const int lastSlash = name.lastIndexOfChar ('\\'); - valueName = name.substring (lastSlash + 1); - name = name.substring (0, lastSlash); + const int lastSlash = name.lastIndexOfChar ('\\'); + valueName = name.substring (lastSlash + 1); + name = name.substring (0, lastSlash); - HKEY key; - DWORD result; + HKEY key; + DWORD result; - if (createForWriting) - { - if (RegCreateKeyEx (rootKey, name, 0, 0, REG_OPTION_NON_VOLATILE, - (KEY_WRITE | KEY_QUERY_VALUE), 0, &key, &result) == ERROR_SUCCESS) - return key; - } - else - { - if (RegOpenKeyEx (rootKey, name, 0, KEY_READ, &key) == ERROR_SUCCESS) - return key; + if (createForWriting) + { + if (RegCreateKeyEx (rootKey, name, 0, 0, REG_OPTION_NON_VOLATILE, + (KEY_WRITE | KEY_QUERY_VALUE), 0, &key, &result) == ERROR_SUCCESS) + return key; + } + else + { + if (RegOpenKeyEx (rootKey, name, 0, KEY_READ, &key) == ERROR_SUCCESS) + return key; + } } - } - return 0; + return 0; + } } const String PlatformUtilities::getRegistryValue (const String& regValuePath, @@ -241645,7 +241768,6 @@ static HPALETTE palette = 0; static bool createPaletteIfNeeded = true; static bool shouldDeactivateTitleBar = true; -static HICON createHICONFromImage (const Image& image, const BOOL isIcon, int hotspotX, int hotspotY); #define WM_TRAYNOTIFY WM_USER + 100 using ::abs; @@ -241927,6 +242049,101 @@ private: WindowsBitmapImage& operator= (const WindowsBitmapImage&); }; +namespace IconConverters +{ + const Image createImageFromHBITMAP (HBITMAP bitmap) + { + Image im; + + if (bitmap != 0) + { + BITMAP bm; + + if (GetObject (bitmap, sizeof (BITMAP), &bm) + && bm.bmWidth > 0 && bm.bmHeight > 0) + { + HDC tempDC = GetDC (0); + HDC dc = CreateCompatibleDC (tempDC); + ReleaseDC (0, tempDC); + + SelectObject (dc, bitmap); + + im = Image (Image::ARGB, bm.bmWidth, bm.bmHeight, true); + Image::BitmapData imageData (im, true); + + for (int y = bm.bmHeight; --y >= 0;) + { + for (int x = bm.bmWidth; --x >= 0;) + { + COLORREF col = GetPixel (dc, x, y); + + imageData.setPixelColour (x, y, Colour ((uint8) GetRValue (col), + (uint8) GetGValue (col), + (uint8) GetBValue (col))); + } + } + + DeleteDC (dc); + } + } + + return im; + } + + const Image createImageFromHICON (HICON icon) + { + ICONINFO info; + + if (GetIconInfo (icon, &info)) + { + Image mask (createImageFromHBITMAP (info.hbmMask)); + Image image (createImageFromHBITMAP (info.hbmColor)); + + if (mask.isValid() && image.isValid()) + { + for (int y = image.getHeight(); --y >= 0;) + { + for (int x = image.getWidth(); --x >= 0;) + { + const float brightness = mask.getPixelAt (x, y).getBrightness(); + + if (brightness > 0.0f) + image.multiplyAlphaAt (x, y, 1.0f - brightness); + } + } + + return image; + } + } + + return Image::null; + } + + HICON createHICONFromImage (const Image& image, const BOOL isIcon, int hotspotX, int hotspotY) + { + WindowsBitmapImage* nativeBitmap = new WindowsBitmapImage (Image::ARGB, image.getWidth(), image.getHeight(), true); + Image bitmap (nativeBitmap); + + { + Graphics g (bitmap); + g.drawImageAt (image, 0, 0); + } + + HBITMAP mask = CreateBitmap (image.getWidth(), image.getHeight(), 1, 1, 0); + + ICONINFO info; + info.fIcon = isIcon; + info.xHotspot = hotspotX; + info.yHotspot = hotspotY; + info.hbmMask = mask; + info.hbmColor = nativeBitmap->hBitmap; + + HICON hi = CreateIconIndirect (&info); + DeleteObject (mask); + return hi; + } +} + long improbableWindowNumber = 0xf965aa01; // also referenced by messaging.cpp bool KeyPress::isKeyCurrentlyDown (const int keyCode) @@ -241955,14 +242172,6 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode) return (GetKeyState (k) & 0x8000) != 0; } -static void* callFunctionIfNotLocked (MessageCallbackFunction* callback, void* userData) -{ - if (MessageManager::getInstance()->currentThreadHasLockedMessageManager()) - return callback (userData); - else - return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData); -} - class Win32ComponentPeer : public ComponentPeer { public: @@ -242368,7 +242577,7 @@ public: { if (image.isValid()) { - HICON hicon = createHICONFromImage (image, TRUE, 0, 0); + HICON hicon = IconConverters::createHICONFromImage (image, TRUE, 0, 0); if (taskBarIcon == 0) { @@ -242704,7 +242913,7 @@ private: void setIcon (const Image& newIcon) { - HICON hicon = createHICONFromImage (newIcon, TRUE, 0, 0); + HICON hicon = IconConverters::createHICONFromImage (newIcon, TRUE, 0, 0); if (hicon != 0) { @@ -243333,6 +243542,14 @@ public: } private: + static void* callFunctionIfNotLocked (MessageCallbackFunction* callback, void* userData) + { + if (MessageManager::getInstance()->currentThreadHasLockedMessageManager()) + return callback (userData); + else + return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData); + } + static const Point getPointFromLParam (LPARAM lParam) throw() { return Point (GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam)); @@ -244020,98 +244237,6 @@ void juce_updateMultiMonitorInfo (Array >& monitorCoords, const } } -static const Image createImageFromHBITMAP (HBITMAP bitmap) -{ - Image im; - - if (bitmap != 0) - { - BITMAP bm; - - if (GetObject (bitmap, sizeof (BITMAP), &bm) - && bm.bmWidth > 0 && bm.bmHeight > 0) - { - HDC tempDC = GetDC (0); - HDC dc = CreateCompatibleDC (tempDC); - ReleaseDC (0, tempDC); - - SelectObject (dc, bitmap); - - im = Image (Image::ARGB, bm.bmWidth, bm.bmHeight, true); - Image::BitmapData imageData (im, true); - - for (int y = bm.bmHeight; --y >= 0;) - { - for (int x = bm.bmWidth; --x >= 0;) - { - COLORREF col = GetPixel (dc, x, y); - - imageData.setPixelColour (x, y, Colour ((uint8) GetRValue (col), - (uint8) GetGValue (col), - (uint8) GetBValue (col))); - } - } - - DeleteDC (dc); - } - } - - return im; -} - -static const Image createImageFromHICON (HICON icon) -{ - ICONINFO info; - - if (GetIconInfo (icon, &info)) - { - Image mask (createImageFromHBITMAP (info.hbmMask)); - Image image (createImageFromHBITMAP (info.hbmColor)); - - if (mask.isValid() && image.isValid()) - { - for (int y = image.getHeight(); --y >= 0;) - { - for (int x = image.getWidth(); --x >= 0;) - { - const float brightness = mask.getPixelAt (x, y).getBrightness(); - - if (brightness > 0.0f) - image.multiplyAlphaAt (x, y, 1.0f - brightness); - } - } - - return image; - } - } - - return Image::null; -} - -static HICON createHICONFromImage (const Image& image, const BOOL isIcon, int hotspotX, int hotspotY) -{ - WindowsBitmapImage* nativeBitmap = new WindowsBitmapImage (Image::ARGB, image.getWidth(), image.getHeight(), true); - Image bitmap (nativeBitmap); - - { - Graphics g (bitmap); - g.drawImageAt (image, 0, 0); - } - - HBITMAP mask = CreateBitmap (image.getWidth(), image.getHeight(), 1, 1, 0); - - ICONINFO info; - info.fIcon = isIcon; - info.xHotspot = hotspotX; - info.yHotspot = hotspotY; - info.hbmMask = mask; - info.hbmColor = nativeBitmap->hBitmap; - - HICON hi = CreateIconIndirect (&info); - DeleteObject (mask); - return hi; -} - const Image juce_createIconForFile (const File& file) { Image image; @@ -244125,7 +244250,7 @@ const Image juce_createIconForFile (const File& file) if (icon != 0) { - image = createImageFromHICON (icon); + image = IconConverters::createImageFromHICON (icon); DestroyIcon (icon); } @@ -244147,7 +244272,7 @@ void* MouseCursor::createMouseCursorFromImage (const Image& image, int hotspotX, hotspotY = (hotspotY * maxH) / image.getHeight(); } - return createHICONFromImage (im, FALSE, hotspotX, hotspotY); + return IconConverters::createHICONFromImage (im, FALSE, hotspotX, hotspotY); } void MouseCursor::deleteMouseCursor (void* const cursorHandle, const bool isStandard) @@ -247134,7 +247259,7 @@ static HINSTANCE winAspiLib = 0; static bool usingScsi = false; static bool initialised = false; -static bool InitialiseCDRipper() +bool InitialiseCDRipper() { if (! initialised) { @@ -247170,7 +247295,7 @@ static bool InitialiseCDRipper() return true; } -static void DeinitialiseCDRipper() +void DeinitialiseCDRipper() { if (winAspiLib != 0) { @@ -247183,7 +247308,7 @@ static void DeinitialiseCDRipper() initialised = false; } -static HANDLE CreateSCSIDeviceHandle (char driveLetter) +HANDLE CreateSCSIDeviceHandle (char driveLetter) { TCHAR devicePath[] = { '\\', '\\', '.', '\\', driveLetter, ':', 0, 0 }; @@ -247207,10 +247332,8 @@ static HANDLE CreateSCSIDeviceHandle (char driveLetter) return h; } -static DWORD performScsiPassThroughCommand (const LPSRB_ExecSCSICmd srb, - const char driveLetter, - HANDLE& deviceHandle, - const bool retryOnFailure = true) +DWORD performScsiPassThroughCommand (const LPSRB_ExecSCSICmd srb, const char driveLetter, + HANDLE& deviceHandle, const bool retryOnFailure = true) { SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER s; zerostruct (s); @@ -247824,7 +247947,7 @@ bool CDDeviceHandle::testController (const int type, return passed; } -static void GetAspiDeviceInfo (CDDeviceInfo* dev, BYTE ha, BYTE tgt, BYTE lun) +void GetAspiDeviceInfo (CDDeviceInfo* dev, BYTE ha, BYTE tgt, BYTE lun) { HANDLE event = CreateEvent (0, TRUE, FALSE, 0); @@ -247864,8 +247987,7 @@ static void GetAspiDeviceInfo (CDDeviceInfo* dev, BYTE ha, BYTE tgt, BYTE lun) } } -static int FindCDDevices (CDDeviceInfo* const list, - int maxItems) +int FindCDDevices (CDDeviceInfo* const list, int maxItems) { int count = 0; @@ -248047,7 +248169,7 @@ struct CDDeviceWrapper bool jitter; }; -static int getAddressOf (const TOCTRACK* const t) +int getAddressOf (const TOCTRACK* const t) { return (((DWORD)t->addr[0]) << 24) + (((DWORD)t->addr[1]) << 16) + (((DWORD)t->addr[2]) << 8) + ((DWORD)t->addr[3]); @@ -248056,7 +248178,7 @@ static int getAddressOf (const TOCTRACK* const t) static const int samplesPerFrame = 44100 / 75; static const int bytesPerFrame = samplesPerFrame * 4; -static CDDeviceHandle* openHandle (const CDDeviceInfo* const device) +CDDeviceHandle* openHandle (const CDDeviceInfo* const device) { SRB_GDEVBlock s; zerostruct (s); @@ -248470,61 +248592,64 @@ void AudioCDReader::ejectDisk() #if JUCE_USE_CDBURNER -static IDiscRecorder* enumCDBurners (StringArray* list, int indexToOpen, IDiscMaster** master) +namespace CDBurnerHelpers { - CoInitialize (0); + IDiscRecorder* enumCDBurners (StringArray* list, int indexToOpen, IDiscMaster** master) + { + CoInitialize (0); - IDiscMaster* dm; - IDiscRecorder* result = 0; + IDiscMaster* dm; + IDiscRecorder* result = 0; - if (SUCCEEDED (CoCreateInstance (CLSID_MSDiscMasterObj, 0, - CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, - IID_IDiscMaster, - (void**) &dm))) - { - if (SUCCEEDED (dm->Open())) + if (SUCCEEDED (CoCreateInstance (CLSID_MSDiscMasterObj, 0, + CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, + IID_IDiscMaster, + (void**) &dm))) { - IEnumDiscRecorders* drEnum = 0; - - if (SUCCEEDED (dm->EnumDiscRecorders (&drEnum))) + if (SUCCEEDED (dm->Open())) { - IDiscRecorder* dr = 0; - DWORD dummy; - int index = 0; + IEnumDiscRecorders* drEnum = 0; - while (drEnum->Next (1, &dr, &dummy) == S_OK) + if (SUCCEEDED (dm->EnumDiscRecorders (&drEnum))) { - if (indexToOpen == index) - { - result = dr; - break; - } - else if (list != 0) + IDiscRecorder* dr = 0; + DWORD dummy; + int index = 0; + + while (drEnum->Next (1, &dr, &dummy) == S_OK) { - BSTR path; + if (indexToOpen == index) + { + result = dr; + break; + } + else if (list != 0) + { + BSTR path; - if (SUCCEEDED (dr->GetPath (&path))) - list->add ((const WCHAR*) path); + if (SUCCEEDED (dr->GetPath (&path))) + list->add ((const WCHAR*) path); + } + + ++index; + dr->Release(); } - ++index; - dr->Release(); + drEnum->Release(); } - drEnum->Release(); + if (master == 0) + dm->Close(); } - if (master == 0) - dm->Close(); + if (master != 0) + *master = dm; + else + dm->Release(); } - if (master != 0) - *master = dm; - else - dm->Release(); + return result; } - - return result; } class AudioCDBurner::Pimpl : public ComBaseClassHelper , @@ -248672,7 +248797,7 @@ public: AudioCDBurner::AudioCDBurner (const int deviceIndex) { IDiscMaster* discMaster = 0; - IDiscRecorder* discRecorder = enumCDBurners (0, deviceIndex, &discMaster); + IDiscRecorder* discRecorder = CDBurnerHelpers::enumCDBurners (0, deviceIndex, &discMaster); if (discRecorder != 0) pimpl = new Pimpl (*this, discMaster, discRecorder); @@ -248687,7 +248812,7 @@ AudioCDBurner::~AudioCDBurner() const StringArray AudioCDBurner::findAvailableDevices() { StringArray devs; - enumCDBurners (&devs, -1, 0); + CDBurnerHelpers::enumCDBurners (&devs, -1, 0); return devs; } @@ -249385,6 +249510,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message) // #define ASIO_DEBUGGING 1 +#undef log #if ASIO_DEBUGGING #define log(a) { Logger::writeToLog (a); DBG (a) } #else @@ -249398,24 +249524,29 @@ void MidiOutput::sendMessageNow (const MidiMessage& message) */ #define JUCE_ASIOCALLBACK __cdecl -#if ASIO_DEBUGGING -static void logError (const String& context, long error) +namespace ASIODebugging { - String err ("unknown error"); + #if ASIO_DEBUGGING + static void log (const String& context, long error) + { + String err ("unknown error"); - if (error == ASE_NotPresent) err = "Not Present"; - else if (error == ASE_HWMalfunction) err = "Hardware Malfunction"; - else if (error == ASE_InvalidParameter) err = "Invalid Parameter"; - else if (error == ASE_InvalidMode) err = "Invalid Mode"; - else if (error == ASE_SPNotAdvancing) err = "Sample position not advancing"; - else if (error == ASE_NoClock) err = "No Clock"; - else if (error == ASE_NoMemory) err = "Out of memory"; + if (error == ASE_NotPresent) err = "Not Present"; + else if (error == ASE_HWMalfunction) err = "Hardware Malfunction"; + else if (error == ASE_InvalidParameter) err = "Invalid Parameter"; + else if (error == ASE_InvalidMode) err = "Invalid Mode"; + else if (error == ASE_SPNotAdvancing) err = "Sample position not advancing"; + else if (error == ASE_NoClock) err = "No Clock"; + else if (error == ASE_NoMemory) err = "Out of memory"; - log ("!!error: " + context + " - " + err); + log ("!!error: " + context + " - " + err); + } + + #define logError(a, b) ASIODebugging::log ((a), (b)) + #else + #define logError(a, b) {} + #endif } -#else - #define logError(a, b) {} -#endif class ASIOAudioIODevice; static ASIOAudioIODevice* volatile currentASIODev[3] = { 0, 0, 0 }; @@ -251210,6 +251341,7 @@ AudioIODevice* juce_createASIOAudioIODeviceForGUID (const String& name, return new ASIOAudioIODevice (name, *(CLSID*) guid, freeSlot, optionalDllForDirectLoading); } +#undef logError #undef log #endif @@ -251328,86 +251460,90 @@ DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) BEGIN_JUCE_NAMESPACE -static const String getDSErrorMessage (HRESULT hr) +namespace { - const char* result = 0; + const String getDSErrorMessage (HRESULT hr) + { + const char* result = 0; - switch (hr) - { - case MAKE_HRESULT(1, 0x878, 10): result = "Device already allocated"; break; - case MAKE_HRESULT(1, 0x878, 30): result = "Control unavailable"; break; - case E_INVALIDARG: result = "Invalid parameter"; break; - case MAKE_HRESULT(1, 0x878, 50): result = "Invalid call"; break; - case E_FAIL: result = "Generic error"; break; - case MAKE_HRESULT(1, 0x878, 70): result = "Priority level error"; break; - case E_OUTOFMEMORY: result = "Out of memory"; break; - case MAKE_HRESULT(1, 0x878, 100): result = "Bad format"; break; - case E_NOTIMPL: result = "Unsupported function"; break; - case MAKE_HRESULT(1, 0x878, 120): result = "No driver"; break; - case MAKE_HRESULT(1, 0x878, 130): result = "Already initialised"; break; - case CLASS_E_NOAGGREGATION: result = "No aggregation"; break; - case MAKE_HRESULT(1, 0x878, 150): result = "Buffer lost"; break; - case MAKE_HRESULT(1, 0x878, 160): result = "Another app has priority"; break; - case MAKE_HRESULT(1, 0x878, 170): result = "Uninitialised"; break; - case E_NOINTERFACE: result = "No interface"; break; - case S_OK: result = "No error"; break; - default: return "Unknown error: " + String ((int) hr); - } + switch (hr) + { + case MAKE_HRESULT(1, 0x878, 10): result = "Device already allocated"; break; + case MAKE_HRESULT(1, 0x878, 30): result = "Control unavailable"; break; + case E_INVALIDARG: result = "Invalid parameter"; break; + case MAKE_HRESULT(1, 0x878, 50): result = "Invalid call"; break; + case E_FAIL: result = "Generic error"; break; + case MAKE_HRESULT(1, 0x878, 70): result = "Priority level error"; break; + case E_OUTOFMEMORY: result = "Out of memory"; break; + case MAKE_HRESULT(1, 0x878, 100): result = "Bad format"; break; + case E_NOTIMPL: result = "Unsupported function"; break; + case MAKE_HRESULT(1, 0x878, 120): result = "No driver"; break; + case MAKE_HRESULT(1, 0x878, 130): result = "Already initialised"; break; + case CLASS_E_NOAGGREGATION: result = "No aggregation"; break; + case MAKE_HRESULT(1, 0x878, 150): result = "Buffer lost"; break; + case MAKE_HRESULT(1, 0x878, 160): result = "Another app has priority"; break; + case MAKE_HRESULT(1, 0x878, 170): result = "Uninitialised"; break; + case E_NOINTERFACE: result = "No interface"; break; + case S_OK: result = "No error"; break; + default: return "Unknown error: " + String ((int) hr); + } - return result; -} + return result; + } -#define DS_DEBUGGING 1 + #define DS_DEBUGGING 1 -#ifdef DS_DEBUGGING - #define CATCH JUCE_CATCH_EXCEPTION - #undef log - #define log(a) Logger::writeToLog(a); - #undef logError - #define logError(a) logDSError(a, __LINE__); + #ifdef DS_DEBUGGING + #define CATCH JUCE_CATCH_EXCEPTION + #undef log + #define log(a) Logger::writeToLog(a); + #undef logError + #define logError(a) logDSError(a, __LINE__); - static void logDSError (HRESULT hr, int lineNum) - { - if (hr != S_OK) + static void logDSError (HRESULT hr, int lineNum) { - String error ("DS error at line "); - error << lineNum << " - " << getDSErrorMessage (hr); - log (error); + if (hr != S_OK) + { + String error ("DS error at line "); + error << lineNum << " - " << getDSErrorMessage (hr); + log (error); + } } - } -#else - #define CATCH JUCE_CATCH_ALL - #define log(a) - #define logError(a) -#endif + #else + #define CATCH JUCE_CATCH_ALL + #define log(a) + #define logError(a) + #endif -#define DSOUND_FUNCTION(functionName, params) \ - typedef HRESULT (WINAPI *type##functionName) params; \ - static type##functionName ds##functionName = 0; + #define DSOUND_FUNCTION(functionName, params) \ + typedef HRESULT (WINAPI *type##functionName) params; \ + static type##functionName ds##functionName = 0; -#define DSOUND_FUNCTION_LOAD(functionName) \ - ds##functionName = (type##functionName) GetProcAddress (h, #functionName); \ - jassert (ds##functionName != 0); + #define DSOUND_FUNCTION_LOAD(functionName) \ + ds##functionName = (type##functionName) GetProcAddress (h, #functionName); \ + jassert (ds##functionName != 0); -typedef BOOL (CALLBACK *LPDSENUMCALLBACKW) (LPGUID, LPCWSTR, LPCWSTR, LPVOID); -typedef BOOL (CALLBACK *LPDSENUMCALLBACKA) (LPGUID, LPCSTR, LPCSTR, LPVOID); + typedef BOOL (CALLBACK *LPDSENUMCALLBACKW) (LPGUID, LPCWSTR, LPCWSTR, LPVOID); + typedef BOOL (CALLBACK *LPDSENUMCALLBACKA) (LPGUID, LPCSTR, LPCSTR, LPVOID); -DSOUND_FUNCTION (DirectSoundCreate, (const GUID*, IDirectSound**, LPUNKNOWN)) -DSOUND_FUNCTION (DirectSoundCaptureCreate, (const GUID*, IDirectSoundCapture**, LPUNKNOWN)) -DSOUND_FUNCTION (DirectSoundEnumerateW, (LPDSENUMCALLBACKW, LPVOID)) -DSOUND_FUNCTION (DirectSoundCaptureEnumerateW, (LPDSENUMCALLBACKW, LPVOID)) + DSOUND_FUNCTION (DirectSoundCreate, (const GUID*, IDirectSound**, LPUNKNOWN)) + DSOUND_FUNCTION (DirectSoundCaptureCreate, (const GUID*, IDirectSoundCapture**, LPUNKNOWN)) + DSOUND_FUNCTION (DirectSoundEnumerateW, (LPDSENUMCALLBACKW, LPVOID)) + DSOUND_FUNCTION (DirectSoundCaptureEnumerateW, (LPDSENUMCALLBACKW, LPVOID)) -static void initialiseDSoundFunctions() -{ - if (dsDirectSoundCreate == 0) + void initialiseDSoundFunctions() { - HMODULE h = LoadLibraryA ("dsound.dll"); + if (dsDirectSoundCreate == 0) + { + HMODULE h = LoadLibraryA ("dsound.dll"); - DSOUND_FUNCTION_LOAD (DirectSoundCreate) - DSOUND_FUNCTION_LOAD (DirectSoundCaptureCreate) - DSOUND_FUNCTION_LOAD (DirectSoundEnumerateW) - DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateW) + DSOUND_FUNCTION_LOAD (DirectSoundCreate) + DSOUND_FUNCTION_LOAD (DirectSoundCaptureCreate) + DSOUND_FUNCTION_LOAD (DirectSoundEnumerateW) + DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateW) + } } + } class DSoundInternalOutChannel @@ -252772,7 +252908,7 @@ AudioIODeviceType* juce_createAudioIODeviceType_DirectSound() namespace WasapiClasses { -static void logFailure (HRESULT hr) +void logFailure (HRESULT hr) { (void) hr; @@ -252821,13 +252957,13 @@ static void logFailure (HRESULT hr) #undef check -static bool check (HRESULT hr) +bool check (HRESULT hr) { logFailure (hr); return SUCCEEDED (hr); } -static const String getDeviceID (IMMDevice* const device) +const String getDeviceID (IMMDevice* const device) { String s; WCHAR* deviceId = 0; @@ -252841,7 +252977,7 @@ static const String getDeviceID (IMMDevice* const device) return s; } -static EDataFlow getDataFlow (const ComSmartPtr& device) +EDataFlow getDataFlow (const ComSmartPtr& device) { EDataFlow flow = eRender; ComSmartPtr endPoint; @@ -252851,12 +252987,12 @@ static EDataFlow getDataFlow (const ComSmartPtr& device) return flow; } -static int refTimeToSamples (const REFERENCE_TIME& t, const double sampleRate) throw() +int refTimeToSamples (const REFERENCE_TIME& t, const double sampleRate) throw() { return roundDoubleToInt (sampleRate * ((double) t) * 0.0000001); } -static void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* const src) throw() +void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* const src) throw() { memcpy (&dest, src, src->wFormatTag == WAVE_FORMAT_EXTENSIBLE ? sizeof (WAVEFORMATEXTENSIBLE) : sizeof (WAVEFORMATEX)); @@ -253126,7 +253262,7 @@ public: const int samplesToDo = jmin (bufferSize, (int) reservoirSize); for (int i = 0; i < numDestBuffers; ++i) - converter->convertSamples (destBuffers[i], offset, reservoir.getData(), channelMaps.getUnchecked(i), samplesToDo); + converter->convertSamples (destBuffers[i] + offset, 0, reservoir.getData(), channelMaps.getUnchecked(i), samplesToDo); bufferSize -= samplesToDo; offset += samplesToDo; @@ -253156,7 +253292,7 @@ public: const int samplesToDo = jmin (bufferSize, (int) numSamplesAvailable); for (int i = 0; i < numDestBuffers; ++i) - converter->convertSamples (destBuffers[i], offset, inputData, channelMaps.getUnchecked(i), samplesToDo); + converter->convertSamples (destBuffers[i] + offset, 0, inputData, channelMaps.getUnchecked(i), samplesToDo); bufferSize -= samplesToDo; offset += samplesToDo; @@ -253252,7 +253388,7 @@ public: if (check (renderClient->GetBuffer (samplesToDo, &outputData))) { for (int i = 0; i < numSrcBuffers; ++i) - converter->convertSamples (outputData, channelMaps.getUnchecked(i), srcBuffers[i], offset, samplesToDo); + converter->convertSamples (outputData, channelMaps.getUnchecked(i), srcBuffers[i] + offset, 0, samplesToDo); renderClient->ReleaseBuffer (samplesToDo, 0); @@ -254543,65 +254679,68 @@ void CameraDevice::removeListener (Listener* listenerToRemove) d->removeListener (listenerToRemove); } -static ComSmartPtr enumerateCameras (StringArray* const names, - const int deviceIndexToOpen, - String& name) +namespace { - int index = 0; - ComSmartPtr result; - - ComSmartPtr pDevEnum; - HRESULT hr = pDevEnum.CoCreateInstance (CLSID_SystemDeviceEnum); - - if (SUCCEEDED (hr)) + ComSmartPtr enumerateCameras (StringArray* const names, + const int deviceIndexToOpen, + String& name) { - ComSmartPtr enumerator; - hr = pDevEnum->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, enumerator.resetAndGetPointerAddress(), 0); + int index = 0; + ComSmartPtr result; + + ComSmartPtr pDevEnum; + HRESULT hr = pDevEnum.CoCreateInstance (CLSID_SystemDeviceEnum); - if (SUCCEEDED (hr) && enumerator != 0) + if (SUCCEEDED (hr)) { - ComSmartPtr moniker; - ULONG fetched; + ComSmartPtr enumerator; + hr = pDevEnum->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, enumerator.resetAndGetPointerAddress(), 0); - while (enumerator->Next (1, moniker.resetAndGetPointerAddress(), &fetched) == S_OK) + if (SUCCEEDED (hr) && enumerator != 0) { - ComSmartPtr captureFilter; - hr = moniker->BindToObject (0, 0, IID_IBaseFilter, (void**) captureFilter.resetAndGetPointerAddress()); + ComSmartPtr moniker; + ULONG fetched; - if (SUCCEEDED (hr)) + while (enumerator->Next (1, moniker.resetAndGetPointerAddress(), &fetched) == S_OK) { - ComSmartPtr propertyBag; - hr = moniker->BindToStorage (0, 0, IID_IPropertyBag, (void**) propertyBag.resetAndGetPointerAddress()); + ComSmartPtr captureFilter; + hr = moniker->BindToObject (0, 0, IID_IBaseFilter, (void**) captureFilter.resetAndGetPointerAddress()); if (SUCCEEDED (hr)) { - VARIANT var; - var.vt = VT_BSTR; - - hr = propertyBag->Read (_T("FriendlyName"), &var, 0); - propertyBag = 0; + ComSmartPtr propertyBag; + hr = moniker->BindToStorage (0, 0, IID_IPropertyBag, (void**) propertyBag.resetAndGetPointerAddress()); if (SUCCEEDED (hr)) { - if (names != 0) - names->add (var.bstrVal); + VARIANT var; + var.vt = VT_BSTR; + + hr = propertyBag->Read (_T("FriendlyName"), &var, 0); + propertyBag = 0; - if (index == deviceIndexToOpen) + if (SUCCEEDED (hr)) { - name = var.bstrVal; - result = captureFilter; - break; - } + if (names != 0) + names->add (var.bstrVal); - ++index; + if (index == deviceIndexToOpen) + { + name = var.bstrVal; + result = captureFilter; + break; + } + + ++index; + } } } } } } - } - return result; + return result; + } } const StringArray CameraDevice::getAvailableDevices() @@ -254918,20 +255057,37 @@ bool File::setAsCurrentWorkingDirectory() const return chdir (getFullPathName().toUTF8()) == 0; } -#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T - typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) -#else - typedef struct stat juce_statStruct; -#endif - -static bool juce_stat (const String& fileName, juce_statStruct& info) +namespace { - return fileName.isNotEmpty() - #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T - && (stat64 (fileName.toUTF8(), &info) == 0); - #else - && (stat (fileName.toUTF8(), &info) == 0); - #endif + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T + typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) + #else + typedef struct stat juce_statStruct; + #endif + + bool juce_stat (const String& fileName, juce_statStruct& info) + { + return fileName.isNotEmpty() + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T + && (stat64 (fileName.toUTF8(), &info) == 0); + #else + && (stat (fileName.toUTF8(), &info) == 0); + #endif + } + + // if this file doesn't exist, find a parent of it that does.. + bool juce_doStatFS (File f, struct statfs& result) + { + for (int i = 5; --i >= 0;) + { + if (f.exists()) + break; + + f = f.getParentDirectory(); + } + + return statfs (f.getFullPathName().toUTF8(), &result) == 0; + } } bool File::isDirectory() const @@ -255138,20 +255294,6 @@ const File juce_getExecutableFile() return File::getCurrentWorkingDirectory().getChildFile (String::fromUTF8 (exeInfo.dli_fname)); } -// if this file doesn't exist, find a parent of it that does.. -static bool juce_doStatFS (File f, struct statfs& result) -{ - for (int i = 5; --i >= 0;) - { - if (f.exists()) - break; - - f = f.getParentDirectory(); - } - - return statfs (f.getFullPathName().toUTF8(), &result) == 0; -} - int64 File::getBytesFreeOnVolume() const { struct statfs buf; @@ -255444,10 +255586,13 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) // compiled on its own). #if JUCE_INCLUDED_FILE -static const short U_ISOFS_SUPER_MAGIC = 0x9660; // linux/iso_fs.h -static const short U_MSDOS_SUPER_MAGIC = 0x4d44; // linux/msdos_fs.h -static const short U_NFS_SUPER_MAGIC = 0x6969; // linux/nfs_fs.h -static const short U_SMB_SUPER_MAGIC = 0x517B; // linux/smb_fs.h +enum +{ + U_ISOFS_SUPER_MAGIC = 0x9660, // linux/iso_fs.h + U_MSDOS_SUPER_MAGIC = 0x4d44, // linux/msdos_fs.h + U_NFS_SUPER_MAGIC = 0x6969, // linux/nfs_fs.h + U_SMB_SUPER_MAGIC = 0x517B // linux/smb_fs.h +}; bool File::copyInternal (const File& dest) const { @@ -255481,7 +255626,7 @@ bool File::isOnCDRomDrive() const struct statfs buf; return statfs (getFullPathName().toUTF8(), &buf) == 0 - && buf.f_type == U_ISOFS_SUPER_MAGIC; + && buf.f_type == (short) U_ISOFS_SUPER_MAGIC; } bool File::isOnHardDisk() const @@ -255521,18 +255666,21 @@ bool File::isHidden() const return getFileName().startsWithChar ('.'); } -static const File juce_readlink (const String& file, const File& defaultFile) +namespace { - const int size = 8192; - HeapBlock buffer; - buffer.malloc (size + 4); + const File juce_readlink (const String& file, const File& defaultFile) + { + const int size = 8192; + HeapBlock buffer; + buffer.malloc (size + 4); - const size_t numBytes = readlink (file.toUTF8(), buffer, size); + const size_t numBytes = readlink (file.toUTF8(), buffer, size); - if (numBytes > 0 && numBytes <= size) - return File (file).getSiblingFile (String::fromUTF8 (buffer, (int) numBytes)); + if (numBytes > 0 && numBytes <= size) + return File (file).getSiblingFile (String::fromUTF8 (buffer, (int) numBytes)); - return defaultFile; + return defaultFile; + } } const File File::getLinkedTarget() const @@ -256435,26 +256583,50 @@ bool SystemStats::isOperatingSystem64Bit() #endif } -static const String juce_getCpuInfo (const char* const key) +namespace LinuxStatsHelpers { - StringArray lines; - lines.addLines (File ("/proc/cpuinfo").loadFileAsString()); + const String getCpuInfo (const char* const key) + { + StringArray lines; + lines.addLines (File ("/proc/cpuinfo").loadFileAsString()); - for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order) - if (lines[i].startsWithIgnoreCase (key)) - return lines[i].fromFirstOccurrenceOf (":", false, false).trim(); + for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order) + if (lines[i].startsWithIgnoreCase (key)) + return lines[i].fromFirstOccurrenceOf (":", false, false).trim(); - return String::empty; + return String::empty; + } + + bool getTimeSinceStartup (timeval* const t) throw() + { + if (gettimeofday (t, 0) != 0) + return false; + + static unsigned int calibrate = 0; + static bool calibrated = false; + + if (! calibrated) + { + calibrated = true; + + struct sysinfo sysi; + if (sysinfo (&sysi) == 0) + calibrate = t->tv_sec - sysi.uptime; // Safe to assume system was not brought up earlier than 1970! + } + + t->tv_sec -= calibrate; + return true; + } } const String SystemStats::getCpuVendor() { - return juce_getCpuInfo ("vendor_id"); + return LinuxStatsHelpers::getCpuInfo ("vendor_id"); } int SystemStats::getCpuSpeedInMegaherz() { - return roundToInt (juce_getCpuInfo ("cpu MHz").getFloatValue()); + return roundToInt (LinuxStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue()); } int SystemStats::getMemorySizeInMegabytes() @@ -256493,44 +256665,23 @@ const String SystemStats::getFullUserName() void SystemStats::initialiseStats() { - const String flags (juce_getCpuInfo ("flags")); + const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); cpuFlags.hasMMX = flags.contains ("mmx"); cpuFlags.hasSSE = flags.contains ("sse"); cpuFlags.hasSSE2 = flags.contains ("sse2"); cpuFlags.has3DNow = flags.contains ("3dnow"); - cpuFlags.numCpus = juce_getCpuInfo ("processor").getIntValue() + 1; + cpuFlags.numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; } void PlatformUtilities::fpuReset() { } -static bool juce_getTimeSinceStartup (timeval* const t) throw() -{ - if (gettimeofday (t, 0) != 0) - return false; - - static unsigned int calibrate = 0; - static bool calibrated = false; - - if (! calibrated) - { - calibrated = true; - - struct sysinfo sysi; - if (sysinfo (&sysi) == 0) - calibrate = t->tv_sec - sysi.uptime; // Safe to assume system was not brought up earlier than 1970! - } - - t->tv_sec -= calibrate; - return true; -} - uint32 juce_millisecondsSinceStartup() throw() { timeval t; - if (juce_getTimeSinceStartup (&t)) + if (LinuxStatsHelpers::getTimeSinceStartup (&t)) return (uint32) (t.tv_sec * 1000 + (t.tv_usec / 1000)); return 0; @@ -256539,7 +256690,7 @@ uint32 juce_millisecondsSinceStartup() throw() int64 Time::getHighResolutionTicks() throw() { timeval t; - if (juce_getTimeSinceStartup (&t)) + if (LinuxStatsHelpers::getTimeSinceStartup (&t)) return ((int64) t.tv_sec * (int64) 1000000) + (int64) t.tv_usec; return 0; @@ -257799,54 +257950,57 @@ const StringArray Font::findAllTypefaceNames() return s; } -static const String pickBestFont (const StringArray& names, - const char* const choicesString) +namespace { - StringArray choices; - choices.addTokens (String (choicesString), ",", String::empty); - choices.trim(); - choices.removeEmptyStrings(); + const String pickBestFont (const StringArray& names, + const char* const choicesString) + { + StringArray choices; + choices.addTokens (String (choicesString), ",", String::empty); + choices.trim(); + choices.removeEmptyStrings(); - int i, j; - for (j = 0; j < choices.size(); ++j) - if (names.contains (choices[j], true)) - return choices[j]; + int i, j; + for (j = 0; j < choices.size(); ++j) + if (names.contains (choices[j], true)) + return choices[j]; - for (j = 0; j < choices.size(); ++j) - for (i = 0; i < names.size(); i++) - if (names[i].startsWithIgnoreCase (choices[j])) - return names[i]; + for (j = 0; j < choices.size(); ++j) + for (i = 0; i < names.size(); i++) + if (names[i].startsWithIgnoreCase (choices[j])) + return names[i]; - for (j = 0; j < choices.size(); ++j) - for (i = 0; i < names.size(); i++) - if (names[i].containsIgnoreCase (choices[j])) - return names[i]; + for (j = 0; j < choices.size(); ++j) + for (i = 0; i < names.size(); i++) + if (names[i].containsIgnoreCase (choices[j])) + return names[i]; - return names[0]; -} + return names[0]; + } -static const String linux_getDefaultSansSerifFontName() -{ - StringArray allFonts; - FreeTypeInterface::getInstance()->getSansSerifNames (allFonts); + const String linux_getDefaultSansSerifFontName() + { + StringArray allFonts; + FreeTypeInterface::getInstance()->getSansSerifNames (allFonts); - return pickBestFont (allFonts, "Verdana, Bitstream Vera Sans, Luxi Sans, Sans"); -} + return pickBestFont (allFonts, "Verdana, Bitstream Vera Sans, Luxi Sans, Sans"); + } -static const String linux_getDefaultSerifFontName() -{ - StringArray allFonts; - FreeTypeInterface::getInstance()->getSerifNames (allFonts); + const String linux_getDefaultSerifFontName() + { + StringArray allFonts; + FreeTypeInterface::getInstance()->getSerifNames (allFonts); - return pickBestFont (allFonts, "Bitstream Vera Serif, Times, Nimbus Roman, Serif"); -} + return pickBestFont (allFonts, "Bitstream Vera Serif, Times, Nimbus Roman, Serif"); + } -static const String linux_getDefaultMonospacedFontName() -{ - StringArray allFonts; - FreeTypeInterface::getInstance()->getMonospacedNames (allFonts); + const String linux_getDefaultMonospacedFontName() + { + StringArray allFonts; + FreeTypeInterface::getInstance()->getMonospacedNames (allFonts); - return pickBestFont (allFonts, "Bitstream Vera Sans Mono, Courier, Sans Mono, Mono"); + return pickBestFont (allFonts, "Bitstream Vera Sans Mono, Courier, Sans Mono, Mono"); + } } void Font::getPlatformDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed) @@ -261297,85 +261451,88 @@ const int KeyPress::rewindKey = (0xffeeff03) | Keys::extendedKeyModifier; // compiled on its own). #if JUCE_INCLUDED_FILE && JUCE_ALSA -static void getDeviceSampleRates (snd_pcm_t* handle, Array & rates) +namespace { - const int ratesToTry[] = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 0 }; + void getDeviceSampleRates (snd_pcm_t* handle, Array & rates) + { + const int ratesToTry[] = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 0 }; - snd_pcm_hw_params_t* hwParams; - snd_pcm_hw_params_alloca (&hwParams); + snd_pcm_hw_params_t* hwParams; + snd_pcm_hw_params_alloca (&hwParams); - for (int i = 0; ratesToTry[i] != 0; ++i) - { - if (snd_pcm_hw_params_any (handle, hwParams) >= 0 - && snd_pcm_hw_params_test_rate (handle, hwParams, ratesToTry[i], 0) == 0) + for (int i = 0; ratesToTry[i] != 0; ++i) { - rates.addIfNotAlreadyThere (ratesToTry[i]); + if (snd_pcm_hw_params_any (handle, hwParams) >= 0 + && snd_pcm_hw_params_test_rate (handle, hwParams, ratesToTry[i], 0) == 0) + { + rates.addIfNotAlreadyThere (ratesToTry[i]); + } } } -} -static void getDeviceNumChannels (snd_pcm_t* handle, unsigned int* minChans, unsigned int* maxChans) -{ - snd_pcm_hw_params_t *params; - snd_pcm_hw_params_alloca (¶ms); - - if (snd_pcm_hw_params_any (handle, params) >= 0) + void getDeviceNumChannels (snd_pcm_t* handle, unsigned int* minChans, unsigned int* maxChans) { - snd_pcm_hw_params_get_channels_min (params, minChans); - snd_pcm_hw_params_get_channels_max (params, maxChans); - } -} - -static void getDeviceProperties (const String& deviceID, - unsigned int& minChansOut, - unsigned int& maxChansOut, - unsigned int& minChansIn, - unsigned int& maxChansIn, - Array & rates) -{ - if (deviceID.isEmpty()) - return; + snd_pcm_hw_params_t *params; + snd_pcm_hw_params_alloca (¶ms); - snd_ctl_t* handle; + if (snd_pcm_hw_params_any (handle, params) >= 0) + { + snd_pcm_hw_params_get_channels_min (params, minChans); + snd_pcm_hw_params_get_channels_max (params, maxChans); + } + } - if (snd_ctl_open (&handle, deviceID.upToLastOccurrenceOf (",", false, false).toUTF8(), SND_CTL_NONBLOCK) >= 0) + void getDeviceProperties (const String& deviceID, + unsigned int& minChansOut, + unsigned int& maxChansOut, + unsigned int& minChansIn, + unsigned int& maxChansIn, + Array & rates) { - snd_pcm_info_t* info; - snd_pcm_info_alloca (&info); + if (deviceID.isEmpty()) + return; - snd_pcm_info_set_stream (info, SND_PCM_STREAM_PLAYBACK); - snd_pcm_info_set_device (info, deviceID.fromLastOccurrenceOf (",", false, false).getIntValue()); - snd_pcm_info_set_subdevice (info, 0); + snd_ctl_t* handle; - if (snd_ctl_pcm_info (handle, info) >= 0) + if (snd_ctl_open (&handle, deviceID.upToLastOccurrenceOf (",", false, false).toUTF8(), SND_CTL_NONBLOCK) >= 0) { - snd_pcm_t* pcmHandle; - if (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_PLAYBACK, SND_PCM_ASYNC | SND_PCM_NONBLOCK) >= 0) + snd_pcm_info_t* info; + snd_pcm_info_alloca (&info); + + snd_pcm_info_set_stream (info, SND_PCM_STREAM_PLAYBACK); + snd_pcm_info_set_device (info, deviceID.fromLastOccurrenceOf (",", false, false).getIntValue()); + snd_pcm_info_set_subdevice (info, 0); + + if (snd_ctl_pcm_info (handle, info) >= 0) { - getDeviceNumChannels (pcmHandle, &minChansOut, &maxChansOut); - getDeviceSampleRates (pcmHandle, rates); + snd_pcm_t* pcmHandle; + if (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_PLAYBACK, SND_PCM_ASYNC | SND_PCM_NONBLOCK) >= 0) + { + getDeviceNumChannels (pcmHandle, &minChansOut, &maxChansOut); + getDeviceSampleRates (pcmHandle, rates); - snd_pcm_close (pcmHandle); + snd_pcm_close (pcmHandle); + } } - } - snd_pcm_info_set_stream (info, SND_PCM_STREAM_CAPTURE); + snd_pcm_info_set_stream (info, SND_PCM_STREAM_CAPTURE); - if (snd_ctl_pcm_info (handle, info) >= 0) - { - snd_pcm_t* pcmHandle; - if (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_CAPTURE, SND_PCM_ASYNC | SND_PCM_NONBLOCK) >= 0) + if (snd_ctl_pcm_info (handle, info) >= 0) { - getDeviceNumChannels (pcmHandle, &minChansIn, &maxChansIn); + snd_pcm_t* pcmHandle; + if (snd_pcm_open (&pcmHandle, deviceID.toUTF8(), SND_PCM_STREAM_CAPTURE, SND_PCM_ASYNC | SND_PCM_NONBLOCK) >= 0) + { + getDeviceNumChannels (pcmHandle, &minChansIn, &maxChansIn); - if (rates.size() == 0) - getDeviceSampleRates (pcmHandle, rates); + if (rates.size() == 0) + getDeviceSampleRates (pcmHandle, rates); - snd_pcm_close (pcmHandle); + snd_pcm_close (pcmHandle); + } } - } - snd_ctl_close (handle); + snd_ctl_close (handle); + } } } @@ -262332,19 +262489,22 @@ JUCE_DECL_JACK_FUNCTION (int, jack_port_connected_to, (const jack_port_t* port, #endif #if JACK_LOGGING_ENABLED -static void jack_Log (const String& s) +namespace { - std::cerr << s << std::endl; -} + void jack_Log (const String& s) + { + std::cerr << s << std::endl; + } -static void dumpJackErrorMessage (const jack_status_t status) -{ - if (status & JackServerFailed || status & JackServerError) jack_Log ("Unable to connect to JACK server"); - if (status & JackVersionError) jack_Log ("Client's protocol version does not match"); - if (status & JackInvalidOption) jack_Log ("The operation contained an invalid or unsupported option"); - if (status & JackNameNotUnique) jack_Log ("The desired client name was not unique"); - if (status & JackNoSuchClient) jack_Log ("Requested client does not exist"); - if (status & JackInitFailure) jack_Log ("Unable to initialize client"); + void dumpJackErrorMessage (const jack_status_t status) + { + if (status & JackServerFailed || status & JackServerError) jack_Log ("Unable to connect to JACK server"); + if (status & JackVersionError) jack_Log ("Client's protocol version does not match"); + if (status & JackInvalidOption) jack_Log ("The operation contained an invalid or unsupported option"); + if (status & JackNameNotUnique) jack_Log ("The desired client name was not unique"); + if (status & JackNoSuchClient) jack_Log ("Requested client does not exist"); + if (status & JackInitFailure) jack_Log ("Unable to initialize client"); + } } #else #define dumpJackErrorMessage(a) {} @@ -262852,123 +263012,125 @@ AudioIODeviceType* juce_createAudioIODeviceType_JACK() { return 0; } #if JUCE_INCLUDED_FILE #if JUCE_ALSA -static snd_seq_t* iterateMidiDevices (const bool forInput, - StringArray& deviceNamesFound, - const int deviceIndexToOpen) +namespace { - snd_seq_t* returnedHandle = 0; - snd_seq_t* seqHandle; - - if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT - : SND_SEQ_OPEN_OUTPUT, 0) == 0) + snd_seq_t* iterateMidiDevices (const bool forInput, + StringArray& deviceNamesFound, + const int deviceIndexToOpen) { - snd_seq_system_info_t* systemInfo; - snd_seq_client_info_t* clientInfo; + snd_seq_t* returnedHandle = 0; + snd_seq_t* seqHandle; - if (snd_seq_system_info_malloc (&systemInfo) == 0) + if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT + : SND_SEQ_OPEN_OUTPUT, 0) == 0) { - if (snd_seq_system_info (seqHandle, systemInfo) == 0 - && snd_seq_client_info_malloc (&clientInfo) == 0) - { - int numClients = snd_seq_system_info_get_cur_clients (systemInfo); + snd_seq_system_info_t* systemInfo; + snd_seq_client_info_t* clientInfo; - while (--numClients >= 0 && returnedHandle == 0) + if (snd_seq_system_info_malloc (&systemInfo) == 0) + { + if (snd_seq_system_info (seqHandle, systemInfo) == 0 + && snd_seq_client_info_malloc (&clientInfo) == 0) { - if (snd_seq_query_next_client (seqHandle, clientInfo) == 0) + int numClients = snd_seq_system_info_get_cur_clients (systemInfo); + + while (--numClients >= 0 && returnedHandle == 0) { - snd_seq_port_info_t* portInfo; - if (snd_seq_port_info_malloc (&portInfo) == 0) + if (snd_seq_query_next_client (seqHandle, clientInfo) == 0) { - int numPorts = snd_seq_client_info_get_num_ports (clientInfo); - const int client = snd_seq_client_info_get_client (clientInfo); + snd_seq_port_info_t* portInfo; + if (snd_seq_port_info_malloc (&portInfo) == 0) + { + int numPorts = snd_seq_client_info_get_num_ports (clientInfo); + const int client = snd_seq_client_info_get_client (clientInfo); - snd_seq_port_info_set_client (portInfo, client); - snd_seq_port_info_set_port (portInfo, -1); + snd_seq_port_info_set_client (portInfo, client); + snd_seq_port_info_set_port (portInfo, -1); - while (--numPorts >= 0) - { - if (snd_seq_query_next_port (seqHandle, portInfo) == 0 - && (snd_seq_port_info_get_capability (portInfo) - & (forInput ? SND_SEQ_PORT_CAP_READ - : SND_SEQ_PORT_CAP_WRITE)) != 0) + while (--numPorts >= 0) { - deviceNamesFound.add (snd_seq_client_info_get_name (clientInfo)); - - if (deviceNamesFound.size() == deviceIndexToOpen + 1) + if (snd_seq_query_next_port (seqHandle, portInfo) == 0 + && (snd_seq_port_info_get_capability (portInfo) + & (forInput ? SND_SEQ_PORT_CAP_READ + : SND_SEQ_PORT_CAP_WRITE)) != 0) { - const int sourcePort = snd_seq_port_info_get_port (portInfo); - const int sourceClient = snd_seq_client_info_get_client (clientInfo); + deviceNamesFound.add (snd_seq_client_info_get_name (clientInfo)); - if (sourcePort != -1) + if (deviceNamesFound.size() == deviceIndexToOpen + 1) { - snd_seq_set_client_name (seqHandle, - forInput ? "Juce Midi Input" - : "Juce Midi Output"); - - const int portId - = snd_seq_create_simple_port (seqHandle, - forInput ? "Juce Midi In Port" - : "Juce Midi Out Port", - forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) - : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), - SND_SEQ_PORT_TYPE_MIDI_GENERIC); - - snd_seq_connect_from (seqHandle, portId, sourceClient, sourcePort); - - returnedHandle = seqHandle; + const int sourcePort = snd_seq_port_info_get_port (portInfo); + const int sourceClient = snd_seq_client_info_get_client (clientInfo); + + if (sourcePort != -1) + { + snd_seq_set_client_name (seqHandle, + forInput ? "Juce Midi Input" + : "Juce Midi Output"); + + const int portId + = snd_seq_create_simple_port (seqHandle, + forInput ? "Juce Midi In Port" + : "Juce Midi Out Port", + forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) + : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), + SND_SEQ_PORT_TYPE_MIDI_GENERIC); + + snd_seq_connect_from (seqHandle, portId, sourceClient, sourcePort); + + returnedHandle = seqHandle; + } } } } - } - snd_seq_port_info_free (portInfo); + snd_seq_port_info_free (portInfo); + } } } + + snd_seq_client_info_free (clientInfo); } - snd_seq_client_info_free (clientInfo); + snd_seq_system_info_free (systemInfo); } - snd_seq_system_info_free (systemInfo); + if (returnedHandle == 0) + snd_seq_close (seqHandle); } - if (returnedHandle == 0) - snd_seq_close (seqHandle); - } - - deviceNamesFound.appendNumbersToDuplicates (true, true); + deviceNamesFound.appendNumbersToDuplicates (true, true); - return returnedHandle; -} - -static snd_seq_t* createMidiDevice (const bool forInput, - const String& deviceNameToOpen) -{ - snd_seq_t* seqHandle = 0; + return returnedHandle; + } - if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT - : SND_SEQ_OPEN_OUTPUT, 0) == 0) + snd_seq_t* createMidiDevice (const bool forInput, const String& deviceNameToOpen) { - snd_seq_set_client_name (seqHandle, - (deviceNameToOpen + (forInput ? " Input" : " Output")).toCString()); - - const int portId - = snd_seq_create_simple_port (seqHandle, - forInput ? "in" - : "out", - forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) - : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), - forInput ? SND_SEQ_PORT_TYPE_APPLICATION - : SND_SEQ_PORT_TYPE_MIDI_GENERIC); + snd_seq_t* seqHandle = 0; - if (portId < 0) + if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT + : SND_SEQ_OPEN_OUTPUT, 0) == 0) { - snd_seq_close (seqHandle); - seqHandle = 0; + snd_seq_set_client_name (seqHandle, + (deviceNameToOpen + (forInput ? " Input" : " Output")).toCString()); + + const int portId + = snd_seq_create_simple_port (seqHandle, + forInput ? "in" + : "out", + forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) + : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), + forInput ? SND_SEQ_PORT_TYPE_APPLICATION + : SND_SEQ_PORT_TYPE_MIDI_GENERIC); + + if (portId < 0) + { + snd_seq_close (seqHandle); + seqHandle = 0; + } } - } - return seqHandle; + return seqHandle; + } } class MidiOutputDevice @@ -263534,22 +263696,25 @@ BEGIN_JUCE_NAMESPACE #undef Point -template -static const Rectangle convertToRectInt (const RectType& r) +namespace { - return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); -} + template + const Rectangle convertToRectInt (const RectType& r) + { + return Rectangle ((int) r.origin.x, (int) r.origin.y, (int) r.size.width, (int) r.size.height); + } -template -static const Rectangle convertToRectFloat (const RectType& r) -{ - return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); -} + template + const Rectangle convertToRectFloat (const RectType& r) + { + return Rectangle (r.origin.x, r.origin.y, r.size.width, r.size.height); + } -template -static CGRect convertToCGRect (const RectType& r) -{ - return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight()); + template + CGRect convertToCGRect (const RectType& r) + { + return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight()); + } } #define JUCE_INCLUDED_FILE 1 @@ -263586,24 +263751,27 @@ static CGRect convertToCGRect (const RectType& r) // compiled on its own). #if JUCE_INCLUDED_FILE -static const String nsStringToJuce (NSString* s) +namespace { - return String::fromUTF8 ([s UTF8String]); -} + const String nsStringToJuce (NSString* s) + { + return String::fromUTF8 ([s UTF8String]); + } -static NSString* juceStringToNS (const String& s) -{ - return [NSString stringWithUTF8String: s.toUTF8()]; -} + NSString* juceStringToNS (const String& s) + { + return [NSString stringWithUTF8String: s.toUTF8()]; + } -static const String convertUTF16ToString (const UniChar* utf16) -{ - String s; + const String convertUTF16ToString (const UniChar* utf16) + { + String s; - while (*utf16 != 0) - s += (juce_wchar) *utf16++; + while (*utf16 != 0) + s += (juce_wchar) *utf16++; - return s; + return s; + } } const String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) @@ -264789,20 +264957,37 @@ bool File::setAsCurrentWorkingDirectory() const return chdir (getFullPathName().toUTF8()) == 0; } -#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T - typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) -#else - typedef struct stat juce_statStruct; -#endif - -static bool juce_stat (const String& fileName, juce_statStruct& info) +namespace { - return fileName.isNotEmpty() - #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T - && (stat64 (fileName.toUTF8(), &info) == 0); - #else - && (stat (fileName.toUTF8(), &info) == 0); - #endif + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T + typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) + #else + typedef struct stat juce_statStruct; + #endif + + bool juce_stat (const String& fileName, juce_statStruct& info) + { + return fileName.isNotEmpty() + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T + && (stat64 (fileName.toUTF8(), &info) == 0); + #else + && (stat (fileName.toUTF8(), &info) == 0); + #endif + } + + // if this file doesn't exist, find a parent of it that does.. + bool juce_doStatFS (File f, struct statfs& result) + { + for (int i = 5; --i >= 0;) + { + if (f.exists()) + break; + + f = f.getParentDirectory(); + } + + return statfs (f.getFullPathName().toUTF8(), &result) == 0; + } } bool File::isDirectory() const @@ -265009,20 +265194,6 @@ const File juce_getExecutableFile() return File::getCurrentWorkingDirectory().getChildFile (String::fromUTF8 (exeInfo.dli_fname)); } -// if this file doesn't exist, find a parent of it that does.. -static bool juce_doStatFS (File f, struct statfs& result) -{ - for (int i = 5; --i >= 0;) - { - if (f.exists()) - break; - - f = f.getParentDirectory(); - } - - return statfs (f.getFullPathName().toUTF8(), &result) == 0; -} - int64 File::getBytesFreeOnVolume() const { struct statfs buf; @@ -265342,20 +265513,55 @@ void File::findFileSystemRoots (Array& destArray) destArray.add (File ("/")); } -static bool isFileOnDriveType (const File& f, const char* const* types) +namespace { - struct statfs buf; + bool isFileOnDriveType (const File& f, const char* const* types) + { + struct statfs buf; + + if (juce_doStatFS (f, buf)) + { + const String type (buf.f_fstypename); + + while (*types != 0) + if (type.equalsIgnoreCase (*types++)) + return true; + } + + return false; + } - if (juce_doStatFS (f, buf)) + bool juce_isHiddenFile (const String& path) { - const String type (buf.f_fstypename); + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + const ScopedAutoReleasePool pool; + NSNumber* hidden = nil; + NSError* err = nil; - while (*types != 0) - if (type.equalsIgnoreCase (*types++)) - return true; + return [[NSURL fileURLWithPath: juceStringToNS (path)] + getResourceValue: &hidden forKey: NSURLIsHiddenKey error: &err] + && [hidden boolValue]; + #else + #if JUCE_IOS + return File (path).getFileName().startsWithChar ('.'); + #else + FSRef ref; + LSItemInfoRecord info; + + return FSPathMakeRefWithOptions ((const UInt8*) path.toUTF8(), kFSPathMakeRefDoNotFollowLeafSymlink, &ref, 0) == noErr + && LSCopyItemInfoForRef (&ref, kLSRequestBasicFlagsOnly, &info) == noErr + && (info.flags & kLSItemInfoIsInvisible) != 0; + #endif + #endif } - return false; +#if JUCE_IOS + const String getIOSSystemLocation (NSSearchPathDirectory type) + { + return nsStringToJuce ([NSSearchPathForDirectoriesInDomains (type, NSUserDomainMask, YES) + objectAtIndex: 0]); + } +#endif } bool File::isOnCDRomDrive() const @@ -265392,43 +265598,11 @@ bool File::isOnRemovableDrive() const #endif } -static bool juce_isHiddenFile (const String& path) -{ -#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 - const ScopedAutoReleasePool pool; - NSNumber* hidden = nil; - NSError* err = nil; - - return [[NSURL fileURLWithPath: juceStringToNS (path)] - getResourceValue: &hidden forKey: NSURLIsHiddenKey error: &err] - && [hidden boolValue]; -#else - #if JUCE_IOS - return File (path).getFileName().startsWithChar ('.'); - #else - FSRef ref; - LSItemInfoRecord info; - - return FSPathMakeRefWithOptions ((const UInt8*) path.toUTF8(), kFSPathMakeRefDoNotFollowLeafSymlink, &ref, 0) == noErr - && LSCopyItemInfoForRef (&ref, kLSRequestBasicFlagsOnly, &info) == noErr - && (info.flags & kLSItemInfoIsInvisible) != 0; - #endif -#endif -} - bool File::isHidden() const { return juce_isHiddenFile (getFullPathName()); } -#if JUCE_IOS -static const String getIOSSystemLocation (NSSearchPathDirectory type) -{ - return nsStringToJuce ([NSSearchPathForDirectoriesInDomains (type, NSUserDomainMask, YES) - objectAtIndex: 0]); -} -#endif - const char* juce_Argv0 = 0; // referenced from juce_Application.cpp const File File::getSpecialLocation (const SpecialLocationType type) @@ -268079,18 +268253,21 @@ bool UIViewComponentPeer::isFullScreen() const return fullScreen; } -static Desktop::DisplayOrientation convertToJuceOrientation (UIInterfaceOrientation interfaceOrientation) +namespace { - switch (interfaceOrientation) + Desktop::DisplayOrientation convertToJuceOrientation (UIInterfaceOrientation interfaceOrientation) { - case UIInterfaceOrientationPortrait: return Desktop::upright; - case UIInterfaceOrientationPortraitUpsideDown: return Desktop::upsideDown; - case UIInterfaceOrientationLandscapeLeft: return Desktop::rotatedClockwise; - case UIInterfaceOrientationLandscapeRight: return Desktop::rotatedAntiClockwise; - default: jassertfalse; // unknown orientation! - } + switch (interfaceOrientation) + { + case UIInterfaceOrientationPortrait: return Desktop::upright; + case UIInterfaceOrientationPortraitUpsideDown: return Desktop::upsideDown; + case UIInterfaceOrientationLandscapeLeft: return Desktop::rotatedClockwise; + case UIInterfaceOrientationLandscapeRight: return Desktop::rotatedAntiClockwise; + default: jassertfalse; // unknown orientation! + } - return Desktop::upright; + return Desktop::upright; + } } BOOL UIViewComponentPeer::shouldRotate (UIInterfaceOrientation interfaceOrientation) @@ -268595,36 +268772,40 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) return ! quitMessagePosted; } -static CFRunLoopRef runLoop = 0; -static CFRunLoopSourceRef runLoopSource = 0; -static OwnedArray * pendingMessages = 0; -static JuceCustomMessageHandler* juceCustomMessageHandler = 0; - -static void runLoopSourceCallback (void*) +namespace iOSMessageLoopHelpers { - if (pendingMessages != 0) - { - int numDispatched = 0; + static CFRunLoopRef runLoop = 0; + static CFRunLoopSourceRef runLoopSource = 0; + static OwnedArray * pendingMessages = 0; + static JuceCustomMessageHandler* juceCustomMessageHandler = 0; - do + void runLoopSourceCallback (void*) + { + if (pendingMessages != 0) { - Message* const nextMessage = pendingMessages->removeAndReturn (0); + int numDispatched = 0; - if (nextMessage == 0) - return; + do + { + Message* const nextMessage = pendingMessages->removeAndReturn (0); - const ScopedAutoReleasePool pool; - MessageManager::getInstance()->deliverMessage (nextMessage); + if (nextMessage == 0) + return; - } while (++numDispatched <= 4); + const ScopedAutoReleasePool pool; + MessageManager::getInstance()->deliverMessage (nextMessage); - CFRunLoopSourceSignal (runLoopSource); - CFRunLoopWakeUp (runLoop); + } while (++numDispatched <= 4); + + CFRunLoopSourceSignal (runLoopSource); + CFRunLoopWakeUp (runLoop); + } } } void MessageManager::doPlatformSpecificInitialisation() { + using namespace iOSMessageLoopHelpers; pendingMessages = new OwnedArray (); runLoop = CFRunLoopGetCurrent(); @@ -268640,6 +268821,7 @@ void MessageManager::doPlatformSpecificInitialisation() void MessageManager::doPlatformSpecificShutdown() { + using namespace iOSMessageLoopHelpers; CFRunLoopSourceInvalidate (runLoopSource); CFRelease (runLoopSource); runLoopSource = 0; @@ -268655,6 +268837,8 @@ void MessageManager::doPlatformSpecificShutdown() bool juce_postMessageToSystemQueue (Message* message) { + using namespace iOSMessageLoopHelpers; + if (pendingMessages != 0) { pendingMessages->add (message); @@ -268671,6 +268855,8 @@ void MessageManager::broadcastMessage (const String& value) void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, void* data) { + using namespace iOSMessageLoopHelpers; + if (isThisTheMessageThread()) { return (*callback) (data); @@ -269394,7 +269580,7 @@ namespace MouseCursorHelpers static void* fromWebKitFile (const char* filename, float hx, float hy) { FileInputStream fileStream (String ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources/") + filename); - BufferedInputStream buf (&fileStream, 4096, false); + BufferedInputStream buf (fileStream, 4096); PNGImageFormat pngFormat; Image im (pngFormat.decodeImage (buf)); @@ -273978,7 +274164,7 @@ namespace MouseCursorHelpers static void* fromWebKitFile (const char* filename, float hx, float hy) { FileInputStream fileStream (String ("/System/Library/Frameworks/WebKit.framework/Frameworks/WebCore.framework/Resources/") + filename); - BufferedInputStream buf (&fileStream, 4096, false); + BufferedInputStream buf (fileStream, 4096); PNGImageFormat pngFormat; Image im (pngFormat.decodeImage (buf)); @@ -274224,50 +274410,59 @@ AppleRemoteDevice::~AppleRemoteDevice() stop(); } -static io_object_t getAppleRemoteDevice() +namespace { - CFMutableDictionaryRef dict = IOServiceMatching ("AppleIRController"); - - io_iterator_t iter = 0; - io_object_t iod = 0; - - if (IOServiceGetMatchingServices (kIOMasterPortDefault, dict, &iter) == kIOReturnSuccess - && iter != 0) + io_object_t getAppleRemoteDevice() { - iod = IOIteratorNext (iter); - } + CFMutableDictionaryRef dict = IOServiceMatching ("AppleIRController"); - IOObjectRelease (iter); - return iod; -} + io_iterator_t iter = 0; + io_object_t iod = 0; -static bool createAppleRemoteInterface (io_object_t iod, void** device) -{ - jassert (*device == 0); - io_name_t classname; + if (IOServiceGetMatchingServices (kIOMasterPortDefault, dict, &iter) == kIOReturnSuccess + && iter != 0) + { + iod = IOIteratorNext (iter); + } + + IOObjectRelease (iter); + return iod; + } - if (IOObjectGetClass (iod, classname) == kIOReturnSuccess) + bool createAppleRemoteInterface (io_object_t iod, void** device) { - IOCFPlugInInterface** cfPlugInInterface = 0; - SInt32 score = 0; + jassert (*device == 0); + io_name_t classname; - if (IOCreatePlugInInterfaceForService (iod, - kIOHIDDeviceUserClientTypeID, - kIOCFPlugInInterfaceID, - &cfPlugInInterface, - &score) == kIOReturnSuccess) + if (IOObjectGetClass (iod, classname) == kIOReturnSuccess) { - HRESULT hr = (*cfPlugInInterface)->QueryInterface (cfPlugInInterface, - CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), - device); + IOCFPlugInInterface** cfPlugInInterface = 0; + SInt32 score = 0; - (void) hr; + if (IOCreatePlugInInterfaceForService (iod, + kIOHIDDeviceUserClientTypeID, + kIOCFPlugInInterfaceID, + &cfPlugInInterface, + &score) == kIOReturnSuccess) + { + HRESULT hr = (*cfPlugInInterface)->QueryInterface (cfPlugInInterface, + CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), + device); - (*cfPlugInInterface)->Release (cfPlugInInterface); + (void) hr; + + (*cfPlugInInterface)->Release (cfPlugInInterface); + } } + + return *device != 0; } - return *device != 0; + void appleRemoteQueueCallback (void* const target, const IOReturn result, void*, void*) + { + if (result == kIOReturnSuccess) + ((AppleRemoteDevice*) target)->handleCallbackInternal(); + } } bool AppleRemoteDevice::start (const bool inExclusiveMode) @@ -274316,12 +274511,6 @@ bool AppleRemoteDevice::isActive() const return queue != 0; } -static void appleRemoteQueueCallback (void* const target, const IOReturn result, void*, void*) -{ - if (result == kIOReturnSuccess) - ((AppleRemoteDevice*) target)->handleCallbackInternal(); -} - bool AppleRemoteDevice::open (const bool openInExclusiveMode) { Array cookies; @@ -275363,88 +275552,90 @@ END_JUCE_NAMESPACE @end BEGIN_JUCE_NAMESPACE -static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, - const PopupMenu* extraItems) +namespace MainMenuHelpers { - if (extraItems != 0 && JuceMainMenuHandler::instance != 0 && extraItems->getNumItems() > 0) + NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, const PopupMenu* extraItems) { - PopupMenu::MenuItemIterator iter (*extraItems); - - while (iter.next()) - JuceMainMenuHandler::instance->addMenuItem (iter, menu, 0, -1); + if (extraItems != 0 && JuceMainMenuHandler::instance != 0 && extraItems->getNumItems() > 0) + { + PopupMenu::MenuItemIterator iter (*extraItems); - [menu addItem: [NSMenuItem separatorItem]]; - } + while (iter.next()) + JuceMainMenuHandler::instance->addMenuItem (iter, menu, 0, -1); - NSMenuItem* item; + [menu addItem: [NSMenuItem separatorItem]]; + } - // Services... - item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Services", nil) - action: nil keyEquivalent: @""]; - [menu addItem: item]; - [item release]; - NSMenu* servicesMenu = [[NSMenu alloc] initWithTitle: @"Services"]; - [menu setSubmenu: servicesMenu forItem: item]; - [NSApp setServicesMenu: servicesMenu]; - [servicesMenu release]; - [menu addItem: [NSMenuItem separatorItem]]; + NSMenuItem* item; - // Hide + Show stuff... - item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Hide " + appName) - action: @selector (hide:) keyEquivalent: @"h"]; - [item setTarget: NSApp]; - [menu addItem: item]; - [item release]; + // Services... + item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Services", nil) + action: nil keyEquivalent: @""]; + [menu addItem: item]; + [item release]; + NSMenu* servicesMenu = [[NSMenu alloc] initWithTitle: @"Services"]; + [menu setSubmenu: servicesMenu forItem: item]; + [NSApp setServicesMenu: servicesMenu]; + [servicesMenu release]; + [menu addItem: [NSMenuItem separatorItem]]; - item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) - action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; - [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; - [item setTarget: NSApp]; - [menu addItem: item]; - [item release]; + // Hide + Show stuff... + item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Hide " + appName) + action: @selector (hide:) keyEquivalent: @"h"]; + [item setTarget: NSApp]; + [menu addItem: item]; + [item release]; - item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) - action: @selector (unhideAllApplications:) keyEquivalent: @""]; - [item setTarget: NSApp]; - [menu addItem: item]; - [item release]; + item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) + action: @selector (hideOtherApplications:) keyEquivalent: @"h"]; + [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; + [item setTarget: NSApp]; + [menu addItem: item]; + [item release]; - [menu addItem: [NSMenuItem separatorItem]]; + item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) + action: @selector (unhideAllApplications:) keyEquivalent: @""]; + [item setTarget: NSApp]; + [menu addItem: item]; + [item release]; - // Quit item.... - item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Quit " + appName) - action: @selector (terminate:) keyEquivalent: @"q"]; + [menu addItem: [NSMenuItem separatorItem]]; - [item setTarget: NSApp]; - [menu addItem: item]; - [item release]; + // Quit item.... + item = [[NSMenuItem alloc] initWithTitle: juceStringToNS ("Quit " + appName) + action: @selector (terminate:) keyEquivalent: @"q"]; - return menu; -} + [item setTarget: NSApp]; + [menu addItem: item]; + [item release]; -// Since our app has no NIB, this initialises a standard app menu... -static void rebuildMainMenu (const PopupMenu* extraItems) -{ - // this can't be used in a plugin! - jassert (JUCEApplication::isStandaloneApp()); + return menu; + } - if (JUCEApplication::getInstance() != 0) + // Since our app has no NIB, this initialises a standard app menu... + void rebuildMainMenu (const PopupMenu* extraItems) { - const ScopedAutoReleasePool pool; + // this can't be used in a plugin! + jassert (JUCEApplication::isStandaloneApp()); - NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: @"MainMenu"]; - NSMenuItem* item = [mainMenu addItemWithTitle: @"Apple" action: nil keyEquivalent: @""]; + if (JUCEApplication::getInstance() != 0) + { + const ScopedAutoReleasePool pool; + + NSMenu* mainMenu = [[NSMenu alloc] initWithTitle: @"MainMenu"]; + NSMenuItem* item = [mainMenu addItemWithTitle: @"Apple" action: nil keyEquivalent: @""]; - NSMenu* appMenu = [[NSMenu alloc] initWithTitle: @"Apple"]; + NSMenu* appMenu = [[NSMenu alloc] initWithTitle: @"Apple"]; - [NSApp performSelector: @selector (setAppleMenu:) withObject: appMenu]; - [mainMenu setSubmenu: appMenu forItem: item]; + [NSApp performSelector: @selector (setAppleMenu:) withObject: appMenu]; + [mainMenu setSubmenu: appMenu forItem: item]; - [NSApp setMainMenu: mainMenu]; - createStandardAppMenu (appMenu, JUCEApplication::getInstance()->getApplicationName(), extraItems); + [NSApp setMainMenu: mainMenu]; + MainMenuHelpers::createStandardAppMenu (appMenu, JUCEApplication::getInstance()->getApplicationName(), extraItems); - [appMenu release]; - [mainMenu release]; + [appMenu release]; + [mainMenu release]; + } } } @@ -275472,7 +275663,7 @@ void MenuBarModel::setMacMainMenu (MenuBarModel* newMenuBarModel, } } - rebuildMainMenu (extraAppleMenuItems); + MainMenuHelpers::rebuildMainMenu (extraAppleMenuItems); if (newMenuBarModel != 0) newMenuBarModel->menuItemsChanged(); @@ -275487,7 +275678,7 @@ MenuBarModel* MenuBarModel::getMacMainMenu() void juce_initialiseMacMainMenu() { if (JuceMainMenuHandler::instance == 0) - rebuildMainMenu (0); + MainMenuHelpers::rebuildMainMenu (0); } #endif @@ -276405,20 +276596,23 @@ AudioCDBurner* AudioCDBurner::openDevice (const int deviceIndex) return b.release(); } -static NSArray* findDiskBurnerDevices() +namespace { - NSMutableArray* results = [NSMutableArray array]; - NSArray* devs = [DRDevice devices]; - - for (int i = 0; i < [devs count]; ++i) + NSArray* findDiskBurnerDevices() { - NSDictionary* dic = [[devs objectAtIndex: i] info]; - NSString* name = [dic valueForKey: DRDeviceProductNameKey]; - if (name != nil) - [results addObject: name]; - } + NSMutableArray* results = [NSMutableArray array]; + NSArray* devs = [DRDevice devices]; - return results; + for (int i = 0; i < [devs count]; ++i) + { + NSDictionary* dic = [[devs objectAtIndex: i] info]; + NSString* name = [dic valueForKey: DRDeviceProductNameKey]; + if (name != nil) + [results addObject: name]; + } + + return results; + } } const StringArray AudioCDBurner::findAvailableDevices() @@ -277082,88 +277276,91 @@ void MessageManager::stopDispatchLoop() [NSEvent startPeriodicEventsAfterDelay: 0 withPeriod: 0.1]; } -static bool isEventBlockedByModalComps (NSEvent* e) +namespace { - if (Component::getNumCurrentlyModalComponents() == 0) - return false; - - NSWindow* const w = [e window]; - if (w == 0 || [w worksWhenModal]) - return false; + bool isEventBlockedByModalComps (NSEvent* e) + { + if (Component::getNumCurrentlyModalComponents() == 0) + return false; - bool isKey = false, isInputAttempt = false; + NSWindow* const w = [e window]; + if (w == 0 || [w worksWhenModal]) + return false; - switch ([e type]) - { - case NSKeyDown: - case NSKeyUp: - isKey = isInputAttempt = true; - break; + bool isKey = false, isInputAttempt = false; - case NSLeftMouseDown: - case NSRightMouseDown: - case NSOtherMouseDown: - isInputAttempt = true; - break; + switch ([e type]) + { + case NSKeyDown: + case NSKeyUp: + isKey = isInputAttempt = true; + break; - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSLeftMouseUp: - case NSRightMouseUp: - case NSOtherMouseUp: - case NSOtherMouseDragged: - if (Desktop::getInstance().getDraggingMouseSource(0) != 0) - return false; - break; + case NSLeftMouseDown: + case NSRightMouseDown: + case NSOtherMouseDown: + isInputAttempt = true; + break; - case NSMouseMoved: - case NSMouseEntered: - case NSMouseExited: - case NSCursorUpdate: - case NSScrollWheel: - case NSTabletPoint: - case NSTabletProximity: - break; + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSLeftMouseUp: + case NSRightMouseUp: + case NSOtherMouseUp: + case NSOtherMouseDragged: + if (Desktop::getInstance().getDraggingMouseSource(0) != 0) + return false; + break; - default: - return false; - } + case NSMouseMoved: + case NSMouseEntered: + case NSMouseExited: + case NSCursorUpdate: + case NSScrollWheel: + case NSTabletPoint: + case NSTabletProximity: + break; - for (int i = ComponentPeer::getNumPeers(); --i >= 0;) - { - ComponentPeer* const peer = ComponentPeer::getPeer (i); - NSView* const compView = (NSView*) peer->getNativeHandle(); + default: + return false; + } - if ([compView window] == w) + for (int i = ComponentPeer::getNumPeers(); --i >= 0;) { - if (isKey) - { - if (compView == [w firstResponder]) - return false; - } - else + ComponentPeer* const peer = ComponentPeer::getPeer (i); + NSView* const compView = (NSView*) peer->getNativeHandle(); + + if ([compView window] == w) { - NSViewComponentPeer* nsViewPeer = dynamic_cast (peer); + if (isKey) + { + if (compView == [w firstResponder]) + return false; + } + else + { + NSViewComponentPeer* nsViewPeer = dynamic_cast (peer); - if ((nsViewPeer == 0 || ! nsViewPeer->isSharedWindow) - ? NSPointInRect ([e locationInWindow], NSMakeRect (0, 0, [w frame].size.width, [w frame].size.height)) - : NSPointInRect ([compView convertPoint: [e locationInWindow] fromView: nil], [compView bounds])) - return false; + if ((nsViewPeer == 0 || ! nsViewPeer->isSharedWindow) + ? NSPointInRect ([e locationInWindow], NSMakeRect (0, 0, [w frame].size.width, [w frame].size.height)) + : NSPointInRect ([compView convertPoint: [e locationInWindow] fromView: nil], [compView bounds])) + return false; + } } } - } - if (isInputAttempt) - { - if (! [NSApp isActive]) - [NSApp activateIgnoringOtherApps: YES]; + if (isInputAttempt) + { + if (! [NSApp isActive]) + [NSApp activateIgnoringOtherApps: YES]; - Component* const modal = Component::getCurrentlyModalComponent (0); - if (modal != 0) - modal->inputAttemptWhenModal(); - } + Component* const modal = Component::getCurrentlyModalComponent (0); + if (modal != 0) + modal->inputAttemptWhenModal(); + } - return true; + return true; + } } bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 9ab280ecb2..2cceaeb46a 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 82 +#define JUCE_BUILDNUMBER 83 /** Current Juce version number. @@ -6220,13 +6220,9 @@ public: */ const var getWithDefault (const Identifier& name, const var& defaultReturnValue) const; - /** Returns a pointer to the object holding a named value, or - null if there is no value with this name. */ - var* getItem (const Identifier& name) const; - /** Changes or adds a named value. - @returns true if a value was changed or added; false if the - value was already set the the value passed-in. + @returns true if a value was changed or added; false if the + value was already set the the value passed-in. */ bool set (const Identifier& name, const var& newValue); @@ -6254,6 +6250,14 @@ public: /** Removes all values. */ void clear(); + /** Returns a pointer to the var that holds a named value, or null if there is + no value with this name. + + Do not use this method unless you really need access to the internal var object + for some reason - for normal reading and writing always prefer operator[]() and set(). + */ + var* getVarPointer (const Identifier& name) const; + juce_UseDebuggingNewOperator private: @@ -16403,7 +16407,7 @@ private: #endif void init(); - int findEndOfZipEntryTable (InputStream* in, int& numEntries); + int findEndOfZipEntryTable (InputStream& input, int& numEntries); static int compareElements (const ZipEntryInfo* first, const ZipEntryInfo* second); ZipFile (const ZipFile&); @@ -16976,6 +16980,14 @@ public: int bufferSize, bool deleteSourceWhenDestroyed); + /** Creates a BufferedInputStream from an input source. + + @param sourceStream the source stream to read from - the source stream must not + be deleted until this object has been destroyed. + @param bufferSize the size of reservoir to use to buffer the source + */ + BufferedInputStream (InputStream& sourceStream, int bufferSize); + /** Destructor. This may also delete the source stream, if that option was chosen when the @@ -17051,8 +17063,6 @@ private: #ifndef __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__ #define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__ -class GZIPCompressorHelper; - /** A stream which uses zlib to compress the data written into it. @@ -17094,6 +17104,8 @@ private: OutputStream* const destStream; ScopedPointer streamToDelete; HeapBlock buffer; + class GZIPCompressorHelper; + friend class ScopedPointer ; ScopedPointer helper; bool doNextBlock(); @@ -17112,8 +17124,6 @@ private: #ifndef __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__ #define __JUCE_GZIPDECOMPRESSORINPUTSTREAM_JUCEHEADER__ -class GZIPDecompressHelper; - /** This stream will decompress a source-stream using zlib. @@ -17143,6 +17153,13 @@ public: bool noWrap = false, int64 uncompressedStreamLength = -1); + /** Creates a decompressor stream. + + @param sourceStream the stream to read from - the source stream must not be + deleted until this object has been destroyed + */ + GZIPDecompressorInputStream (InputStream& sourceStream); + /** Destructor. */ ~GZIPDecompressorInputStream(); @@ -17163,6 +17180,9 @@ private: int activeBufferSize; int64 originalSourcePos, currentPos; HeapBlock buffer; + + class GZIPDecompressHelper; + friend class ScopedPointer ; ScopedPointer helper; GZIPDecompressorInputStream (const GZIPDecompressorInputStream&); @@ -54871,6 +54891,7 @@ class DirectoryContentsDisplayComponent; class FilePreviewComponent; class ImageButton; class CallOutBox; +class Drawable; /** LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses @@ -55091,9 +55112,10 @@ public: virtual void fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor); virtual void drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor); - // these return an image from the ImageCache, so use ImageCache::release() to free it - virtual const Image getDefaultFolderImage(); - virtual const Image getDefaultDocumentFileImage(); + // These return a pointer to an internally cached drawable - make sure you don't keep + // a copy of this pointer anywhere, as it may become invalid in the future. + virtual const Drawable* getDefaultFolderImage(); + virtual const Drawable* getDefaultDocumentFileImage(); virtual void createFileChooserHeaderText (const String& title, const String& instructions, @@ -55423,6 +55445,8 @@ private: // default typeface names String defaultSans, defaultSerif, defaultFixed; + ScopedPointer folderImage, documentImage; + void drawShinyButtonShape (Graphics& g, float x, float y, float w, float h, float maxCornerSize, const Colour& baseColour, @@ -55435,6 +55459,8 @@ private: // This has been deprecated - see the new parameter list.. virtual int drawFileBrowserRow (Graphics&, int, int, const String&, Image*, const String&, const String&, bool, bool, int) { return 0; } + static Drawable* loadDrawableFromData (const void* data, size_t numBytes); + LookAndFeel (const LookAndFeel&); LookAndFeel& operator= (const LookAndFeel&); }; diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index fb0eabd4fe..7c6a08c09a 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 82 +#define JUCE_BUILDNUMBER 83 /** Current Juce version number. diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index 6115c83c28..3fbe7948d5 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -69,25 +69,93 @@ BEGIN_JUCE_NAMESPACE #include "../special/juce_MidiKeyboardComponent.h" #include "../special/juce_ColourSelector.h" #include "../../../core/juce_PlatformUtilities.h" - +#include "../../../text/juce_XmlDocument.h" +#include "../../../io/streams/juce_GZIPDecompressorInputStream.h" +#include "../../../io/streams/juce_MemoryInputStream.h" //============================================================================== -static const Colour createBaseColour (const Colour& buttonColour, - const bool hasKeyboardFocus, - const bool isMouseOverButton, - const bool isButtonDown) throw() +namespace LookAndFeelHelpers { - const float sat = hasKeyboardFocus ? 1.3f : 0.9f; - const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); + void createRoundedPath (Path& p, + const float x, const float y, + const float w, const float h, + const float cs, + const bool curveTopLeft, const bool curveTopRight, + const bool curveBottomLeft, const bool curveBottomRight) throw() + { + const float cs2 = 2.0f * cs; - if (isButtonDown) - return baseColour.contrasting (0.2f); - else if (isMouseOverButton) - return baseColour.contrasting (0.1f); + if (curveTopLeft) + { + p.startNewSubPath (x, y + cs); + p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f); + } + else + { + p.startNewSubPath (x, y); + } - return baseColour; -} + if (curveTopRight) + { + p.lineTo (x + w - cs, y); + p.addArc (x + w - cs2, y, cs2, cs2, 0.0f, float_Pi * 0.5f); + } + else + { + p.lineTo (x + w, y); + } + + if (curveBottomRight) + { + p.lineTo (x + w, y + h - cs); + p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi); + } + else + { + p.lineTo (x + w, y + h); + } + + if (curveBottomLeft) + { + p.lineTo (x + cs, y + h); + p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f); + } + else + { + p.lineTo (x, y + h); + } + p.closeSubPath(); + } + + const Colour createBaseColour (const Colour& buttonColour, + const bool hasKeyboardFocus, + const bool isMouseOverButton, + const bool isButtonDown) throw() + { + const float sat = hasKeyboardFocus ? 1.3f : 0.9f; + const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); + + if (isButtonDown) + return baseColour.contrasting (0.2f); + else if (isMouseOverButton) + return baseColour.contrasting (0.1f); + + return baseColour; + } + + const TextLayout layoutTooltipText (const String& text) throw() + { + const float tooltipFontSize = 12.0f; + const int maxToolTipWidth = 400; + + const Font f (tooltipFontSize, Font::bold); + TextLayout tl (text, f); + tl.layout (maxToolTipWidth, Justification::left, true); + + return tl; + } +} //============================================================================== LookAndFeel::LookAndFeel() @@ -364,9 +432,9 @@ void LookAndFeel::drawButtonBackground (Graphics& g, const float indentT = button.isConnectedOnTop() ? 0.1f : halfThickness; const float indentB = button.isConnectedOnBottom() ? 0.1f : halfThickness; - const Colour baseColour (createBaseColour (backgroundColour, - button.hasKeyboardFocus (true), - isMouseOverButton, isButtonDown) + const Colour baseColour (LookAndFeelHelpers::createBaseColour (backgroundColour, + button.hasKeyboardFocus (true), + isMouseOverButton, isButtonDown) .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); drawGlassLozenge (g, @@ -421,11 +489,9 @@ void LookAndFeel::drawTickBox (Graphics& g, const float boxSize = w * 0.7f; drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize, - createBaseColour (component.findColour (TextButton::buttonColourId) - .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), - true, - isMouseOverButton, - isButtonDown), + LookAndFeelHelpers::createBaseColour (component.findColour (TextButton::buttonColourId) + .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), + true, isMouseOverButton, isButtonDown), isEnabled ? ((isButtonDown || isMouseOverButton) ? 1.1f : 0.5f) : 0.3f); if (ticked) @@ -1146,7 +1212,7 @@ int LookAndFeel::getMenuWindowFlags() void LookAndFeel::drawMenuBarBackground (Graphics& g, int width, int height, bool, MenuBarComponent& menuBar) { - const Colour baseColour (createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false)); + const Colour baseColour (LookAndFeelHelpers::createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false)); if (menuBar.isEnabled()) { @@ -1259,10 +1325,10 @@ void LookAndFeel::drawComboBox (Graphics& g, int width, int height, const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f; - const Colour baseColour (createBaseColour (box.findColour (ComboBox::buttonColourId), - box.hasKeyboardFocus (true), - false, isButtonDown) - .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f)); + const Colour baseColour (LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), + box.hasKeyboardFocus (true), + false, isButtonDown) + .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f)); drawGlassLozenge (g, buttonX + outlineThickness, buttonY + outlineThickness, @@ -1397,10 +1463,10 @@ void LookAndFeel::drawLinearSliderThumb (Graphics& g, { const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2); - Colour knobColour (createBaseColour (slider.findColour (Slider::thumbColourId), - slider.hasKeyboardFocus (false) && slider.isEnabled(), - slider.isMouseOverOrDragging() && slider.isEnabled(), - slider.isMouseButtonDown() && slider.isEnabled())); + Colour knobColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), + slider.hasKeyboardFocus (false) && slider.isEnabled(), + slider.isMouseOverOrDragging() && slider.isEnabled(), + slider.isMouseButtonDown() && slider.isEnabled())); const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; @@ -1483,11 +1549,10 @@ void LookAndFeel::drawLinearSlider (Graphics& g, { const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); - Colour baseColour (createBaseColour (slider.findColour (Slider::thumbColourId) - .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), - false, - isMouseOver, - isMouseOver || slider.isMouseButtonDown())); + Colour baseColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId) + .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), + false, isMouseOver, + isMouseOver || slider.isMouseButtonDown())); drawShinyButtonShape (g, (float) x, (float) y, sliderPos - (float) x, (float) height, 0.0f, @@ -1630,21 +1695,9 @@ ImageEffectFilter* LookAndFeel::getSliderEffect() } //============================================================================== -static const TextLayout layoutTooltipText (const String& text) throw() -{ - const float tooltipFontSize = 12.0f; - const int maxToolTipWidth = 400; - - const Font f (tooltipFontSize, Font::bold); - TextLayout tl (text, f); - tl.layout (maxToolTipWidth, Justification::left, true); - - return tl; -} - void LookAndFeel::getTooltipSize (const String& tipText, int& width, int& height) { - const TextLayout tl (layoutTooltipText (tipText)); + const TextLayout tl (LookAndFeelHelpers::layoutTooltipText (tipText)); width = tl.getWidth() + 14; height = tl.getHeight() + 6; @@ -1661,7 +1714,7 @@ void LookAndFeel::drawTooltip (Graphics& g, const String& text, int width, int h g.drawRect (0, 0, width, height, 1); #endif - const TextLayout tl (layoutTooltipText (text)); + const TextLayout tl (LookAndFeelHelpers::layoutTooltipText (text)); g.setColour (findColour (TooltipWindow::textColourId)); tl.drawWithin (g, 0, 0, width, height, Justification::centred); @@ -2589,25 +2642,27 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height, if (isItemSelected) g.fillAll (findColour (DirectoryContentsDisplayComponent::highlightColourId)); - g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId)); - g.setFont (height * 0.7f); - - Image im; - if (icon != 0) - im = *icon; - - if (im.isNull()) - im = isDirectory ? getDefaultFolderImage() - : getDefaultDocumentFileImage(); - const int x = 32; + g.setColour (Colours::black); - if (im.isValid()) + if (icon != 0 && icon->isValid()) { - g.drawImageWithin (im, 2, 2, x - 4, height - 4, + g.drawImageWithin (*icon, 2, 2, x - 4, height - 4, RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false); } + else + { + const Drawable* d = isDirectory ? getDefaultFolderImage() + : getDefaultDocumentFileImage(); + + if (d != 0) + d->drawWithin (g, Rectangle (2.0f, 2.0f, x - 4.0f, height - 4.0f), + RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); + } + + g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId)); + g.setFont (height * 0.7f); if (width > 450 && ! isDirectory) { @@ -2693,82 +2748,75 @@ void LookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp, filenameBox->setBounds (x + 50, y, w - 50, controlsHeight); } -const Image LookAndFeel::getDefaultFolderImage() -{ - static const unsigned char foldericon_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,28,8,6,0,0,0,0,194,189,34,0,0,0,4,103,65,77,65,0,0,175,200,55,5, - 138,233,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,201,101,60,0,0,9,46,73,68,65,84,120,218,98,252,255,255,63,3,50,240,41,95,192, - 197,205,198,32,202,204,202,33,241,254,235,47,133,47,191,24,180,213,164,133,152,69,24,222,44,234,42,77,188,245,31,170,129,145,145,145,1,29,128,164,226,91,86,113,252,248,207,200,171,37,39,204,239,170,43, - 254,206,218,88,231,61,62,61,0,1,196,2,149,96,116,200,158,102,194,202,201,227,197,193,206,166,194,204,193,33,195,202,204,38,42,197,197,42,196,193,202,33,240,241,231,15,134,151,95,127,9,2,149,22,0,241,47, - 152,230,128,134,245,204,63,191,188,103,83,144,16,16,228,229,102,151,76,239,217,32,199,204,198,169,205,254,159,65,245,203,79,6,169,131,151,30,47,1,42,91,10,196,127,208,236,101,76,235,90,43,101,160,40,242, - 19,32,128,64,78,98,52,12,41,149,145,215,52,89,162,38,35,107,39,196,203,203,192,206,194,206,192,197,198,202,192,203,197,198,192,205,193,206,240,252,227,103,134,139,55,175,191,127,243,242,78,219,187,207, - 63,215,255,98,23,48,228,227,96,83,98,102,102,85,225,224,228,80,20,224,230,86,226,225,228,150,103,101,97,101,230,227,228,96,224,0,234,191,243,252,5,195,222,19,199,38,191,127,112,161,83,66,199,86,141,131, - 149,69,146,133,153,69,137,149,133,89,157,141,131,77,83,140,143,243,219,255,31,159,123,0,2,136,69,90,207,129,157,71,68,42,66,71,73,209,210,81,91,27,24,142,140,12,127,255,253,103,0,185,236,31,3,144,6,50, - 148,68,216,25,216,24,117,4,239,11,243,214,49,50,51,84,178,48,114,240,112,177,114,177,240,115,113,49,241,112,112,48,176,179,178,51,176,48,49,3,85,255,99,248,253,247,15,195,247,159,191,25,30,191,126,253, - 71,74,76,200,66,75,197,119,138,168,144,160,150,168,0,183,160,152,32,15,175,188,184,32,199,175,191,127,25,214,31,184,120,247,236,209,253,159,0,2,136,133,95,70,93,74,88,80,196,83,69,66,130,149,9,104,219, - 151,31,191,193,150,194,146,6,136,102,102,98,100,16,227,231,103,16,23,210,230,101,101,102,100,248,255,143,137,225,223,63,6,6,22,102,38,134,239,191,126,49,220,123,241,134,225,227,247,175,64,7,252,101,96, - 97,249,207,192,193,198,200,160,171,34,192,108,165,235,104,42,204,207,101,42,194,199,197,192,199,201,198,192,197,193,202,192,198,202,194,176,247,194,3,134,155,183,110,61,188,127,124,221,19,128,0,92,146, - 49,14,64,64,16,69,63,153,85,16,52,18,74,71,112,6,87,119,0,165,160,86,138,32,172,216,29,49,182,84,253,169,94,94,230,127,17,87,133,34,146,174,3,88,126,240,219,164,147,113,31,145,244,152,112,179,211,130, - 34,31,203,113,162,233,6,36,49,163,174,74,124,140,60,141,144,165,161,220,228,25,3,24,105,255,17,168,101,1,139,245,188,93,104,251,73,239,235,50,90,189,111,175,0,98,249,254,254,249,175,239,223,190,126,6, - 5,27,19,47,90,170,102,0,249,158,129,129,141,133,25,228,20,6,38,38,72,74,7,185,243,243,247,239,12,23,31,60,98,228,231,253,207,144,227,107,206,32,202,199,193,240,249,251,127,134,95,191,255,49,124,249,250, - 159,225,237,239,95,12,63,127,1,35,229,31,194,71,32,71,63,123,251,245,223,197,27,183,159,189,187,178,103,61,80,232,59,64,0,177,48,252,5,134,225,255,191,223,126,254,250,13,182,132,1,41,167,176,3,53,128, - 188,254,226,253,103,96,212,252,96,120,247,249,203,255,79,223,191,254,255,250,235,199,191,239,63,191,255,87,145,17,100,73,116,181,100,252,249,243,63,195,149,123,223,193,14,132,101,55,96,52,3,125,255,15, - 204,254,15,132,160,232,253,13,20,124,248,226,227,223,23,207,30,221,120,119,255,226,109,160,210,31,0,1,196,242,231,219,135,175,140,255,126,190,7,197,37,35,19,34,216,65,248,211,143,111,255,79,223,121,240, - 255,211,183,79,76,220,156,172,12,236,204,140,140,252,124,28,140,250,226,82,140,106,82,34,140,124,156,156,12,175,222,253,1,90,4,137,162,63,127,33,161,6,178,242,215,239,255,224,160,255,15,198,12,64,7,48, - 128,211,200,253,151,111,254,254,248,240,236,44,80,217,71,80,246,4,8,32,160,31,255,255,100,102,248,243,238,199,159,63,16,221,16,19,128,248,31,195,181,199,207,254,255,253,247,133,49,212,78,27,104,8,11,40, - 94,25,184,216,89,129,108,38,70,144,242,183,31,17,105,230,63,148,248,15,97,49,252,248,249,15,20,85,72,105,9,148,187,254,49,220,127,254,242,207,243,75,135,14,128,130,31,84,64,1,4,16,203,247,143,175,127, - 48,253,254,246,234,7,48,206,96,137,13,4,64,65,248,234,195,7,6,7,3,57,70,33,46,97,134,111,63,254,50,252,5,250,244,51,216,103,255,192,185,0,150,91,80,44,135,242,127,253,129,164,23,24,96,102,250,207,112, - 255,213,219,255,247,31,63,188,251,246,201,173,199,176,2,13,32,128,88,62,188,121,241,243,211,231,207,31,126,2,147,236,63,168,6,144,193,223,190,255,254,207,198,198,192,40,35,44,206,240,252,205,79,6,132, - 223,24,224,150,32,251,28,25,128,211,29,19,170,24,51,48,88,111,61,127,206,248,254,245,179,139,192,18,247,219,239,239,95,192,249,9,32,128,88,126,124,249,248,231,203,183,111,159,128,33,240,15,24,68,160,180, - 2,204,223,140,12,111,63,127,102,16,228,229,4,6,53,35,195,31,176,119,25,112,3,70,84,55,0,203,50,112,33,134,108,249,103,160,7,159,189,126,253,235,235,227,203,7,255,255,251,247,13,86,63,0,4,16,168,46,248, - 199,250,231,243,235,159,191,126,254,248,245,251,47,23,11,51,51,48,184,152,24,94,127,250,248,95,68,136,151,241,243,55,96,208,51,160,218,255,31,139,27,144,197,254,98,201,202,79,223,124,96,120,245,232,250, - 185,119,143,174,95,250,243,243,219,119,152,60,64,0,129,2,234,223,183,215,15,95,48,254,255,253,3,146,109,192,229,5,195,135,47,159,25,248,184,121,24,126,0,227,29,88,240,49,252,101,36,14,255,1,90,249,7,156, - 222,17,24,24,164,12,207,223,189,99,248,250,252,230,97,96,229,245,2,104,231,111,152,3,0,2,8,228,128,191,15,239,220,120,255,255,223,159,47,160,116,0,42,44,222,124,250,244,239,207,255,63,12,236,108,236,64, - 67,65,81,0,52,244,63,113,248,47,52,10,96,14,98,2,230,191,119,223,127,48,60,121,254,248,235,151,55,207,46,1,163,252,35,114,128,1,4,16,40,10,254,191,121,249,252,199,175,159,63,191,254,2,230,45,118,22,22, - 134,219,207,94,252,231,224,100,103,250,247,15,148,32,64,85,12,34,14,254,227,72,6,255,225,9,240,63,138,26,46,96,214,189,249,244,37,195,139,167,143,30,124,253,246,253,9,40,245,255,71,202,30,0,1,196,2,226, - 0,243,232,159,239,63,127,124,253,11,202,94,64,169,23,31,62,50,138,137,242,49,50,0,211,195,223,255,80,7,252,199,159,6,224,137,145,9,146,231,153,160,165,218,23,96,29,240,244,237,59,134,111,175,31,95,250, - 252,230,241,83,244,182,1,64,0,177,192,28,14,76,132,31,128,169,19,88,220,126,253,207,206,198,196,32,38,36,0,244,61,11,176,148,251,139,145,3,208,29,0,178,16,82,228,66,42,174,223,192,26,8,152,162,25,222, - 125,248,200,240,242,253,39,134,151,79,238,126,254,242,242,238,177,15,47,30,190,5,215,242,72,0,32,128,224,14,96,254,255,231,61,168,92,123,241,254,253,127,1,62,78,6,78,110,78,134,223,64,195,254,50,98,183, - 24,36,12,202,179,224,202,9,88,228,253,132,90,250,246,211,71,134,55,175,94,254,122,255,250,249,247,15,175,159,126,249,251,237,195,135,95,175,110,31,122,117,251,244,49,160,150,111,255,209,218,128,0,1,152, - 44,183,21,0,65,32,136,110,247,254,255,243,122,9,187,64,105,174,74,22,138,25,173,80,208,194,188,238,156,151,217,217,15,32,182,197,37,83,201,4,31,243,178,169,232,242,214,224,223,252,103,175,35,85,1,41,129, - 228,148,142,8,214,30,32,149,6,161,204,109,182,53,236,184,156,78,142,147,195,153,89,35,198,3,87,166,249,220,227,198,59,218,48,252,223,185,111,30,1,132,228,128,127,31,222,124,248,248,27,24,152,28,60,220, - 220,12,44,172,172,224,224,103,5,102,98,144,133,160,236,244,229,231,47,134,239,223,127,49,188,121,251,158,225,241,179,103,12,31,223,189,254,251,227,221,139,55,191,62,188,120,246,235,205,189,59,207,238, - 94,58,241,228,254,109,144,101,159,128,248,51,40,9,32,97,80,217,255,15,221,1,0,1,4,143,130,207,159,191,126,252,246,234,213,111,94,126,94,118,73,94,9,198,127,64,223,126,252,246,147,225,243,215,239,12,223, - 128,229,198,251,15,239,24,62,189,126,249,227,203,171,135,47,63,189,122,252,228,235,155,199,247,95,63,188,118,227,197,227,123,247,127,255,250,249,30,104,198,7,32,126,11,181,252,7,212,183,160,4,247,7,155, - 197,48,0,16,64,112,7,60,121,241,238,189,16,207,15,134,63,63,216,25,95,125,248,198,112,227,241,27,134,15,239,223,50,124,126,245,228,253,143,55,143,158,191,123,116,237,226,171,135,55,175,126,253,252,225, - 229,183,47,159,95,254,253,245,227,253,175,159,223,223,193,124,7,181,20,84,105,252,70,143,103,124,0,32,128,224,14,224,102,253,251,81,144,253,223,235,167,207,30,254,124,127,231,252,155,143,175,159,188,250, - 246,254,249,125,96,60,62,248,250,233,253,147,119,207,238,221,6,150,214,175,129,106,191,130,18,19,146,133,120,125,72,8,0,4,16,34,27,190,121,112,251,3,211,159,69,143,110,223,229,120,255,232,230,221,215, - 79,239,62,4,102,203,207,72,241,9,11,218,63,72,89,137,20,207,98,100,93,16,0,8,32,70,144,1,64,14,168,209,199,7,196,194,160,166,27,212,135,95,96,65,10,173,95,254,34,219,6,51,128,88,7,96,235,21,129,0,64,0, - 193,28,192,8,174,53,33,152,1,155,133,184,12,196,165,4,151,133,232,0,32,192,0,151,97,210,163,246,134,208,52,0,0,0,0,73,69,78,68,174,66,96,130,0,0}; - - return ImageCache::getFromMemory (foldericon_png, sizeof (foldericon_png)); -} - -const Image LookAndFeel::getDefaultDocumentFileImage() -{ - static const unsigned char fileicon_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,32,8,6,0,0,0,115,122,122,244,0,0,0,4,103,65,77,65,0,0,175,200,55,5, - 138,233,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,201,101,60,0,0,4,99,73,68,65,84,120,218,98,252,255,255,63,3,12,48,50,50,50,1, - 169,127,200,98,148,2,160,153,204,64,243,254,226,146,7,8,32,22,52,203,255,107,233,233,91,76,93,176,184,232,239,239,95,127,24,40,112,8,19,51,203,255,179,23,175,108,1,90,190,28,104,54,43,80,232,207,127,44, - 62,3,8,32,6,144,24,84,156,25,132,189,252,3,146,255,83,9,220,127,254,242,134,162,138,170,10,208,92,144,3,152,97,118,33,99,128,0,98,66,114,11,200,1,92,255,254,252,225,32,215,215,32,127,64,240,127,80,60, - 50,40,72,136,169,47,95,179,118,130,136,148,140,0,40,80,128,33,193,136,174,7,32,128,144,29,192,8,117,41,59,209,22,66,241,191,255,16,12,244,19,195,63,48,134,240,255,0,9,115,125,93,239,252,130,130,108,168, - 249,44,232,102,0,4,16,19,22,62,51,33,11,255,195,44,4,211,255,25,96,16,33,6,117,24,56,226,25,24,202,139,10,75,226,51,115,66,160,105,13,197,17,0,1,196,68,172,79,255,33,91,206,192,192,128,176,22,17,10,200, - 234,32,161,240,31,24,10,255,24,152,153,153,184,39,244,247,117,107,234,234,105,131,66,1,154,224,193,0,32,128,240,58,0,22,180,255,144,18,13,40,136,33,113,140,36,255,15,17,26,48,12,81,15,145,255,254,251, - 31,131,0,59,171,84,81,73,105,33,208,216,191,200,161,12,16,64,44,248,131,251,63,10,31,198,253,143,38,6,83,7,11,33,228,232,2,123,4,202,226,228,96,151,132,166,49,144,35,126,131,196,0,2,136,5,103,60,51,252, - 71,49,12,213,130,255,168,226,232,150,254,255,15,143,6,80,202,3,133,16,200,198,63,127,193,229,17,39,16,127,135,217,7,16,64,88,67,0,28,143,255,25,225,46,135,249,18,155,133,240,178,4,205,145,8,62,52,186, - 32,234,152,160,118,194,179,35,64,0,177,96,11,123,144,236,95,104,92,162,228,113,36,11,81,125,140,112,56,186,131,96,226,176,172,137,148,229,193,0,32,128,88,112,167,248,255,112,223,48,34,165,110,6,124,190, - 253,143,61,106,192,9,19,73,28,25,0,4,16,206,40,248,251,15,45,104,209,130,21,51,222,145,18,238,127,180,68,8,244,250,95,164,16,66,6,0,1,196,130,45,253,195,12,250,135,53,206,255,195,131,18,213,98,236,81, - 243,31,154,11,144,115,8,50,0,8,32,156,81,0,203,227,12,80,223,98,230,4,68,72,96,38,78,84,11,65,9,250,47,146,3,145,1,64,0,97,117,192,95,112,34,68,138,130,255,176,224,251,143,226,51,6,6,68,29,192,136,20, - 77,200,69,54,35,3,36,49,255,69,77,132,112,0,16,64,44,56,139,94,36,7,96,102,59,164,108,249,31,181,82,98,64,203,174,255,144,234,142,127,88,146,33,64,0,97,205,134,240,120,67,75,76,136,224,198,140,22,6,44, - 142,66,201,41,255,177,231,2,128,0,194,25,5,255,254,161,134,192,127,6,28,229,0,129,242,1,150,56,33,81,138,209,28,96,0,8,32,172,81,0,78,3,104,190,68,182,224,31,146,197,224,56,6,146,140,176,202,135,17,169, - 96,130,40,64,56,0,139,93,0,1,132,61,10,64,248,31,106,156,162,199,55,204,65,255,144,178,38,74,84,252,71,51,239,63,246,68,8,16,64,44,216,74,1,88,217,13,203,191,32,1,80,58,7,133,224,127,6,68,114,6,241,65, - 81,197,8,101,255,71,114,33,92,237,127,228,52,128,233,2,128,0,98,193,149,3,64,117,193,255,127,255,81,75,191,127,168,5,18,136,255,31,45,161,49,32,151,134,72,252,127,12,216,203,98,128,0,98,193,210,144,135, - 248,30,201,242,127,208,252,140,145,27,160,113,206,136,148,197,192,121,159,17,53,184,225,149,17,22,23,0,4,16,11,182,150,237,63,168,207,96,142,248,143,163,72,6,203,253,67,13,61,6,104,14,66,46,17,254,65, - 19,40,182,16,0,8,32,22,108,109,235,255,176,234,24,35,79,255,199,222,30,64,81,135,90,35,194,211,4,142,92,0,16,64,88,29,0,107,7,254,251,247,31,53,78,241,54,207,80,29,135,209,96,249,143,189,46,0,8,32,116, - 7,252,101,102,103,103,228,103,99,96,248,193,198,137,53,248,49,125,204,128,225,227,255,88,18,54,47,176,25,202,205,195,205,6,109,11,194,149,0,4,16,35,204,85,208,254,27,159,128,176,176,142,166,182,142,21, - 48,4,248,129,41,143,13,217,16,70,52,95,147,0,254,0,187,69,95,223,188,122,125,235,206,141,107,7,129,252,247,64,123,193,237,66,128,0,66,118,0,168,189,198,3,196,252,32,135,64,105,54,228,230,19,185,29,100, - 168,175,191,0,241,7,32,254,4,196,159,129,246,254,2,73,2,4,16,11,90,72,125,135,210,63,161,138,153,169,212,75,255,15,117,196,15,40,134,119,215,1,2,12,0,187,0,132,247,216,161,197,124,0,0,0,0,73,69,78,68, - 174,66,96,130,0,0}; - - return ImageCache::getFromMemory (fileicon_png, sizeof (fileicon_png)); +// Pulls a drawable out of compressed valuetree data.. +Drawable* LookAndFeel::loadDrawableFromData (const void* data, size_t numBytes) +{ + MemoryInputStream m (data, numBytes, false); + GZIPDecompressorInputStream gz (m); + ValueTree drawable (ValueTree::readFromStream (gz)); + return Drawable::createFromValueTree (drawable.getChild (0), 0); +} + +const Drawable* LookAndFeel::getDefaultFolderImage() +{ + if (folderImage == 0) + { + static const unsigned char drawableData[] = + { 120,218,197,86,77,111,27,55,16,229,182,161,237,6,61,39,233,77,63,192,38,56,195,225,215,209,105,210,2,141,13,20,201,193,109,111,178,181,178,183,145,181,130,180,110,145,127,159,199,93,73,137,87,53,218,91,109,192,160,151,179,156,55,111,222,188,229,155,247, + 231,87,231,175,47,222,170,234,155,229,244,190,86,213,115,253,102,61,253,123,122,189,168,85,51,83,213,119,250,238,221,47,231,151,175,223,169,170,250,121,221,62,172,84,245,172,60,63,209,243,118,49,171,215,170,107,87,23,245,188,83,213,145,182,167,19,91, + 254,127,223,220,222,117,37,68,82,40,143,174,219,174,107,239,135,168,147,18,37,108,85,245,237,46,207,70,33,249,175,211,238,78,85,186,28,253,76,175,73,109,186,117,251,177,190,106,102,229,241,247,58,24,103,203,15,101,245,103,219,44,187,15,221,39,0,172,142, + 245,125,211,1,196,205,116,181,125,114,164,175,31,186,78,45,219,229,31,245,186,189,106,150,179,102,121,139,100,154,240,231,167,102,177,64,72,247,105,213,23,122,187,158,206,154,122,217,169,85,57,18,1,47,53,101,107,18,135,204,167,147,192,201,216,20,114, + 244,195,62,171,234,7,125,198,100,136,216,145,149,211,9,57,103,40,249,72,219,8,167,170,87,250,140,162,199,123,226,3,34,82,202,134,131,13,172,74,170,233,162,0,177,234,166,93,180,15,235,141,170,206,180,157,204,231,150,156,159,207,39,195,50,214,88,18,150, + 245,205,124,250,104,169,212,135,158,19,144,53,20,112,172,55,237,2,132,13,199,149,130,230,115,145,112,147,147,82,61,157,32,238,178,253,11,145,213,138,10,52,138,38,103,111,99,164,211,137,139,198,35,177,35,167,212,143,15,215,205,13,160,109,163,172,225,152, + 16,232,17,149,140,103,144,158,146,90,113,217,12,6,197,167,236,3,54,5,181,101,73,54,138,90,245,165,227,120,18,252,150,77,15,242,188,228,204,81,169,139,102,249,5,68,192,145,14,244,112,1,145,29,94,137,96,235,49,136,151,58,246,32,88,192,161,88,176,76,226, + 36,247,24,176,7,232,62,16,83,42,155,201,160,30,222,65,72,98,82,76,33,198,254,197,96,124,10,150,243,8,130,48,228,36,94,124,6,4,43,38,0,142,205,99,30,4,221,13,33,230,220,71,177,65,49,142,243,150,7,1,51,20,2,5,96,96,84,225,56,217,188,3,33,46,24,228,112, + 69,69,12,68,228,108,242,99,16,165,118,208,28,51,200,98,87,42,74,62,209,24,4,206,48,22,153,125,132,220,196,56,15,234,99,216,130,0,141,38,74,162,130,48,35,163,141,94,196,245,32,94,104,7,154,132,209,40,108,162,165,232,153,165,17,4,138,201,176,135,58,49, + 165,130,122,108,114,54,28,240,64,17,89,188,79,177,116,149,10,4,246,91,30,94,104,112,96,226,144,131,144,142,98,78,177,7,128,81,242,224,140,36,249,80,208,145,196,12,202,15,16,60,161,200,69,187,169,213,86,198,123,87,224,255,199,21,94,105,134,72,40,177,245, + 14,182,32,232,54,196,231,100,111,11,189,168,201,39,177,84,102,38,139,177,168,74,210,87,174,64,20,138,160,67,111,10,4,98,196,97,60,158,118,133,25,111,173,224,171,37,97,185,119,133,221,242,63,184,194,140,71,174,240,252,145,43,72,32,147,146,147,4,104,104, + 117,134,10,18,12,107,212,40,72,148,57,6,71,69,135,222,248,16,160,168,3,169,144,55,201,69,41,147,137,134,99,50,97,8,178,85,43,217,140,201,151,192,152,10,242,190,24,11,59,183,29,25,42,115,236,98,14,229,252,32,80,66,0,162,17,136,72,6,67,5,45,242,224,10, + 193,102,71,50,6,17,129,212,18,115,105,150,80,169,45,123,222,141,76,178,70,32,55,24,90,217,132,71,73,200,57,238,204,3,136,49,144,185,55,183,190,20,137,52,246,47,113,232,158,69,35,49,145,208,129,193,56,178,77,135,230,145,113,22,140,69,74,20,146,2,120,218, + 155,135,48,32,10,89,30,156,165,204,254,222,193,160,12,19,49,6,210,59,11,70,62,4,31,15,64,196,2,157,98,33,58,1,104,32,152,50,31,128,64,148,183,197,108,209,89,107,240,41,75,36,123,16,208,108,180,44,236,250,182,227,27,20,137,118,76,60,165,137,221,92,94, + 78,215,31,235,245,230,183,242,229,30,214,251,251,195,145,94,148,15,253,170,221,52,93,211,46,7,109,171,81,208,177,94,247,119,132,47,81,186,92,22,246,7,255,254,15,7,107,141,171,197,191,156,123,162,135,187,198,227,131,113,219,80,159,1,4,239,223,231,0,0 }; + + folderImage = loadDrawableFromData (drawableData, sizeof (drawableData)); + } + + return folderImage; +} + +const Drawable* LookAndFeel::getDefaultDocumentFileImage() +{ + if (documentImage == 0) + { + static const unsigned char drawableData[] = + { 120,218,213,88,77,115,219,54,16,37,147,208,246,228,214,75,155,246,164,123,29,12,176,216,197,199,49,105,218,94,156,153,78,114,72,219,155,108,75,137,26,89,212,200,116,59,233,175,239,3,105,201,164,68,50,158,166,233,76,196,11,69,60,173,128,197,123,139,183, + 124,241,234,217,155,103,207,207,126,204,242,7,171,233,213,44,203,31,23,47,54,211,191,166,231,203,89,182,184,204,242,147,226,195,165,219,252,125,150,229,249,207,155,242,102,157,229,143,210,227,199,197,101,121,113,115,53,91,85,89,85,174,207,102,243,42, + 203,143,10,125,58,209,233,251,171,197,219,119,85,250,173,97,151,30,157,151,85,85,94,53,168,147,132,50,226,179,252,225,246,143,174,179,44,63,254,101,90,189,203,242,34,5,127,84,172,77,118,93,109,202,247,179,55,139,203,244,248,97,161,179,63,202,197,170, + 122,93,125,192,196,242,227,226,106,81,205,54,217,197,116,125,251,228,168,56,191,169,170,108,85,174,126,159,109,202,55,139,213,229,98,245,182,249,97,254,240,167,197,114,137,5,86,31,214,245,111,175,203,37,254,230,162,92,150,55,155,180,148,249,237,39,203, + 94,215,127,58,10,213,245,39,203,234,249,102,249,87,47,203,63,129,204,49,227,252,73,225,149,145,104,131,245,254,116,34,202,82,164,16,153,179,236,108,177,234,7,49,41,237,130,144,167,17,144,15,42,104,239,93,12,35,32,99,68,9,187,24,125,7,244,77,23,36,164, + 40,56,226,61,12,107,229,130,215,100,105,24,227,89,17,246,211,105,55,140,49,218,43,207,100,245,72,28,195,70,17,230,201,118,8,243,164,139,233,95,88,23,52,152,162,54,104,48,217,237,105,15,111,91,107,253,131,160,118,34,239,69,128,54,232,135,101,121,61,203, + 110,169,181,147,2,253,159,82,48,180,229,247,167,74,193,41,141,188,35,93,241,116,18,148,113,214,120,207,113,47,19,109,16,51,182,153,193,5,59,2,10,90,69,114,218,135,48,2,50,198,43,171,189,152,81,144,88,108,85,136,78,246,64,54,42,163,35,69,30,3,121,82,38, + 98,81,98,70,64,70,139,34,111,163,167,49,144,13,202,138,179,58,220,23,52,180,186,54,104,48,79,109,208,96,198,219,19,31,220,187,118,10,6,65,237,100,222,139,5,109,80,191,30,236,151,162,135,147,142,30,68,105,182,58,6,22,84,43,229,124,148,116,97,145,55,231, + 139,11,76,228,16,37,14,48,205,145,77,134,34,176,55,152,182,200,57,99,93,204,144,145,253,65,97,229,132,72,104,63,62,71,21,140,54,186,41,226,59,84,19,63,130,15,222,235,224,185,59,104,27,226,68,101,153,241,227,177,248,29,20,136,26,8,252,178,183,241,219, + 131,137,160,209,107,109,92,79,124,16,211,184,104,93,77,130,110,124,2,65,172,67,201,60,157,88,163,2,91,99,92,216,198,55,78,69,75,190,150,119,84,98,200,71,150,109,124,36,204,227,52,8,33,229,223,68,167,173,167,131,248,137,212,226,141,19,233,160,154,248, + 144,142,195,140,137,185,59,104,15,247,119,40,126,23,69,81,200,242,110,254,123,20,49,94,112,110,245,199,111,241,167,87,36,252,101,138,132,149,22,22,38,65,134,29,182,139,24,230,192,31,144,184,133,130,72,44,131,210,142,111,147,216,30,76,123,30,113,206,242, + 150,196,157,65,129,130,76,180,194,61,34,225,160,5,228,233,160,118,34,137,26,202,115,212,29,108,72,134,243,223,90,114,226,199,226,119,80,6,245,152,197,122,217,146,184,53,24,140,210,30,21,59,80,79,124,182,202,71,207,218,112,159,72,80,53,140,109,68,2,191, + 227,217,210,78,36,94,137,88,231,82,157,8,176,61,0,122,191,19,137,3,255,13,39,183,228,20,193,151,144,119,166,79,36,40,253,156,138,72,11,181,19,137,14,46,176,217,27,180,135,251,219,31,255,235,61,148,165,96,72,122,118,23,229,81,52,135,24,250,163,183,216, + 211,43,17,217,151,136,253,116,137,28,53,188,127,92,188,221,76,47,23,169,59,90,167,144,141,239,197,86,104,141,189,60,157,80,84,142,140,4,31,154,241,122,105,132,41,107,13,201,39,86,120,24,82,114,206,198,6,96,27,227,172,36,232,168,201,36,219,24,113,62,163, + 154,101,233,143,166,203,102,26,141,206,174,179,252,89,161,39,243,249,197,121,186,38,233,246,146,211,53,1,123,56,194,231,122,143,103,179,217,60,204,167,19,147,110,41,93,173,219,123,72,89,248,35,173,16,220,50,179,111,60,181,24,88,103,156,235,7,78,248,14, + 4,119,78,162,93,60,112,35,109,16,124,126,12,17,71,67,24,1,165,142,1,181,215,248,56,6,66,235,193,137,167,61,22,30,5,3,27,101,71,64,169,25,112,216,2,63,22,169,110,43,18,200,140,129,208,160,88,44,220,208,125,65,67,171,107,131,6,243,212,6,13,102,188,61,241, + 225,189,107,165,96,16,212,78,230,189,88,208,6,245,235,214,237,235,150,62,167,110,155,106,170,53,133,192,117,193,20,84,78,74,174,98,39,92,156,8,112,21,46,80,106,12,209,207,225,228,16,113,59,225,126,87,60,133,25,209,34,36,2,99,242,52,197,48,30,75,244,247, + 212,238,246,182,173,221,185,78,215,127,167,221,162,163,221,250,152,217,146,196,222,145,100,223,235,105,108,28,250,149,212,74,224,86,2,213,118,110,119,204,224,144,208,38,214,131,200,14,214,223,120,189,230,53,1,193,70,133,154,131,56,223,16,229,48,188,14, + 201,205,213,121,71,233,68,89,15,124,103,37,53,26,11,118,176,127,169,88,166,158,219,178,117,173,83,108,75,95,55,68,186,193,53,246,146,206,127,6,63,53,78,58,228,204,155,224,113,74,91,232,221,195,240,105,215,34,29,138,64,128,183,8,130,233,71,173,56,54,101, + 99,75,186,111,65,58,28,229,145,82,19,152,12,99,180,81,130,131,75,234,229,220,247,53,231,154,79,205,185,185,155,199,249,172,38,85,253,204,76,68,95,92,204,207,255,221,75,178,227,14,187,224,224,97,202,172,173,219,12,167,130,133,9,54,135,245,92,176,29,134, + 165,110,139,141,18,16,223,29,188,183,65,207,144,106,144,151,143,128,224,176,168,110,140,32,62,56,110,219,195,54,235,20,68,209,216,34,232,21,6,41,234,157,39,211,201,107,160,230,66,225,56,153,9,101,21,37,237,150,204,14,115,208,22,221,54,216,230,33,116, + 14,65,14,44,19,8,236,73,71,246,182,110,125,224,75,132,195,214,247,163,36,51,252,84,76,124,37,212,100,88,62,183,179,76,67,217,218,242,244,229,116,243,126,182,185,254,21,105,126,208,220,239,94,229,30,21,203,244,202,117,93,94,47,170,69,185,106,246,60,219, + 3,29,23,155,250,109,237,29,170,72,175,109,119,129,127,235,9,92,20,85,185,254,72,220,147,162,121,235,219,13,44,144,225,63,241,244,165,51,0,0 }; + + documentImage = loadDrawableFromData (drawableData, sizeof (drawableData)); + } + + return documentImage; } @@ -2847,59 +2895,6 @@ void LookAndFeel::drawKeymapChangeButton (Graphics& g, int width, int height, Bu } } -//============================================================================== -static void createRoundedPath (Path& p, - const float x, const float y, - const float w, const float h, - const float cs, - const bool curveTopLeft, const bool curveTopRight, - const bool curveBottomLeft, const bool curveBottomRight) throw() -{ - const float cs2 = 2.0f * cs; - - if (curveTopLeft) - { - p.startNewSubPath (x, y + cs); - p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f); - } - else - { - p.startNewSubPath (x, y); - } - - if (curveTopRight) - { - p.lineTo (x + w - cs, y); - p.addArc (x + w - cs2, y, cs2, cs2, 0.0f, float_Pi * 0.5f); - } - else - { - p.lineTo (x + w, y); - } - - if (curveBottomRight) - { - p.lineTo (x + w, y + h - cs); - p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi); - } - else - { - p.lineTo (x + w, y + h); - } - - if (curveBottomLeft) - { - p.lineTo (x + cs, y + h); - p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f); - } - else - { - p.lineTo (x, y + h); - } - - p.closeSubPath(); -} - //============================================================================== void LookAndFeel::drawShinyButtonShape (Graphics& g, float x, float y, float w, float h, @@ -2917,11 +2912,11 @@ void LookAndFeel::drawShinyButtonShape (Graphics& g, const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f); Path outline; - createRoundedPath (outline, x, y, w, h, cs, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); + LookAndFeelHelpers::createRoundedPath (outline, x, y, w, h, cs, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); ColourGradient cg (baseColour, 0.0f, y, baseColour.overlaidWith (Colour (0x070000ff)), 0.0f, y + h, @@ -3049,11 +3044,11 @@ void LookAndFeel::drawGlassLozenge (Graphics& g, const int intEdge = (int) edgeBlurRadius; Path outline; - createRoundedPath (outline, x, y, width, height, cs, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); + LookAndFeelHelpers::createRoundedPath (outline, x, y, width, height, cs, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); { ColourGradient cg (colour.darker (0.2f), 0, y, @@ -3099,15 +3094,15 @@ void LookAndFeel::drawGlassLozenge (Graphics& g, const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; Path highlight; - createRoundedPath (highlight, - x + leftIndent, - y + cs * 0.1f, - width - (leftIndent + rightIndent), - height * 0.4f, cs * 0.4f, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); + LookAndFeelHelpers::createRoundedPath (highlight, + x + leftIndent, + y + cs * 0.1f, + width - (leftIndent + rightIndent), + height * 0.4f, cs * 0.4f, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); g.setGradientFill (ColourGradient (colour.brighter (10.0f), 0, y + height * 0.06f, Colours::transparentWhite, 0, y + height * 0.4f, false)); diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.h b/src/gui/components/lookandfeel/juce_LookAndFeel.h index 764d42e3cb..8f66a0037a 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.h @@ -58,7 +58,7 @@ class DirectoryContentsDisplayComponent; class FilePreviewComponent; class ImageButton; class CallOutBox; - +class Drawable; //============================================================================== /** @@ -294,9 +294,10 @@ public: virtual void drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor); //============================================================================== - // these return an image from the ImageCache, so use ImageCache::release() to free it - virtual const Image getDefaultFolderImage(); - virtual const Image getDefaultDocumentFileImage(); + // These return a pointer to an internally cached drawable - make sure you don't keep + // a copy of this pointer anywhere, as it may become invalid in the future. + virtual const Drawable* getDefaultFolderImage(); + virtual const Drawable* getDefaultDocumentFileImage(); virtual void createFileChooserHeaderText (const String& title, const String& instructions, @@ -650,6 +651,9 @@ private: // default typeface names String defaultSans, defaultSerif, defaultFixed; + ScopedPointer folderImage, documentImage; + + void drawShinyButtonShape (Graphics& g, float x, float y, float w, float h, float maxCornerSize, const Colour& baseColour, @@ -662,6 +666,8 @@ private: // This has been deprecated - see the new parameter list.. virtual int drawFileBrowserRow (Graphics&, int, int, const String&, Image*, const String&, const String&, bool, bool, int) { return 0; } + static Drawable* loadDrawableFromData (const void* data, size_t numBytes); + LookAndFeel (const LookAndFeel&); LookAndFeel& operator= (const LookAndFeel&); }; diff --git a/src/gui/graphics/drawables/juce_SVGParser.cpp b/src/gui/graphics/drawables/juce_SVGParser.cpp index 0b6339bf36..c5c2aee63a 100644 --- a/src/gui/graphics/drawables/juce_SVGParser.cpp +++ b/src/gui/graphics/drawables/juce_SVGParser.cpp @@ -742,8 +742,12 @@ private: if (gradient.isRadial) { - gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth), - dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight)); + if (userSpace) + gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("cx", "50%"), gradientWidth), + dy + getCoordLength (fillXml->getStringAttribute ("cy", "50%"), gradientHeight)); + else + gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("cx", "50%"), 1.0f), + dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("cy", "50%"), 1.0f)); const float radius = getCoordLength (fillXml->getStringAttribute ("r", "50%"), gradientWidth); gradient.point2 = gradient.point1 + Point (radius, 0.0f); @@ -752,11 +756,22 @@ private: } else { - gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth), - dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight)); + if (userSpace) + { + gradient.point1.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x1", "0%"), gradientWidth), + dy + getCoordLength (fillXml->getStringAttribute ("y1", "0%"), gradientHeight)); - gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth), - dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight)); + gradient.point2.setXY (dx + getCoordLength (fillXml->getStringAttribute ("x2", "100%"), gradientWidth), + dy + getCoordLength (fillXml->getStringAttribute ("y2", "0%"), gradientHeight)); + } + else + { + gradient.point1.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x1", "0%"), 1.0f), + dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y1", "0%"), 1.0f)); + + gradient.point2.setXY (dx + gradientWidth * getCoordLength (fillXml->getStringAttribute ("x2", "100%"), 1.0f), + dy + gradientHeight * getCoordLength (fillXml->getStringAttribute ("y2", "0%"), 1.0f)); + } if (gradient.point1 == gradient.point2) return Colour (gradient.getColour (gradient.getNumColours() - 1));