From 41c9c9e3bec8768b2997e6594c7b17a4967dd850 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 24 Jan 2011 13:09:38 +0000 Subject: [PATCH] Added channel count to AudioTransportSource. Disabled some win32 compiler warnings. Made utf8 parsing cope with illegal characters. Made variants send a change when their type changes. --- juce_amalgamated.cpp | 133 +++++++++--------- juce_amalgamated.h | 16 ++- .../juce_AudioTransportSource.cpp | 5 +- .../audio_sources/juce_AudioTransportSource.h | 4 +- src/containers/juce_Value.cpp | 6 +- src/containers/juce_Variant.cpp | 5 + src/containers/juce_Variant.h | 5 + src/core/juce_StandardHeader.h | 3 + src/gui/components/controls/juce_ComboBox.cpp | 6 + src/gui/components/controls/juce_ComboBox.h | 3 + .../windows/juce_win32_AutoLinkLibraries.h | 1 + .../juce_win32_Direct2DGraphicsContext.cpp | 56 ++++---- src/native/windows/juce_win32_Files.cpp | 8 +- .../windows/juce_win32_NativeIncludes.h | 5 +- src/text/juce_String.cpp | 41 ++---- 15 files changed, 161 insertions(+), 136 deletions(-) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index edfcd7a83f..2b11a63ffd 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -497,10 +497,6 @@ #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4100 4201 4514 4312 4995) - - #ifdef __INTEL_COMPILER - #pragma warning (disable: 1125) - #endif #endif #define _WIN32_WINNT 0x0500 @@ -529,6 +525,7 @@ #include #include #include +#include #if ! JUCE_MINGW #include @@ -4413,6 +4410,11 @@ bool var::equals (const var& other) const throw() return type->equals (value, other.value, *other.type); } +bool var::equalsWithSameType (const var& other) const throw() +{ + return type == other.type && equals (other); +} + bool operator== (const var& v1, const var& v2) throw() { return v1.equals (v2); } bool operator!= (const var& v1, const var& v2) throw() { return ! v1.equals (v2); } bool operator== (const var& v1, const String& v2) throw() { return v1.toString() == v2; } @@ -13770,21 +13772,20 @@ int64 String::getHexValue64() const throw() const String String::createStringFromData (const void* const data_, const int size) { - const char* const data = static_cast (data_); + const uint8* const data = static_cast (data_); if (size <= 0 || data == 0) { return empty; } - else if (size < 2) + else if (size == 1) { - return charToString (data[0]); + return charToString ((char) data[0]); } - else if ((data[0] == (char)-2 && data[1] == (char)-1) - || (data[0] == (char)-1 && data[1] == (char)-2)) + else if ((data[0] == (uint8) 0xfe && data[1] == (uint8) 0xff) // UTF-16 BOM + || (data[0] == (uint8) 0xff && data[1] == (uint8) 0xfe)) { - // assume it's 16-bit unicode - const bool bigEndian = (data[0] == (char)-2); + const bool bigEndian = (data[0] == (uint8) 0xfe); const int numChars = size / 2 - 1; String result; @@ -13809,7 +13810,10 @@ const String String::createStringFromData (const void* const data_, const int si } else { - return String::fromUTF8 (data, size); + if (size >= 3 && data[0] == (uint8) 0xef && data[1] == (uint8) 0xbb && data[2] == (uint8) 0xbf) // UTF-8 BOM + return String::fromUTF8 ((const char*) data + 3, size - 3); + + return String::fromUTF8 ((const char*) data, size); } } @@ -13857,17 +13861,7 @@ int String::copyToUTF8 (char* const buffer, const int maxBufferSizeBytes) const ++numExtraBytes; if (c >= 0x10000) - { ++numExtraBytes; - - if (c >= 0x200000) - { - ++numExtraBytes; - - if (c >= 0x4000000) - ++numExtraBytes; - } - } } if (buffer != 0) @@ -13929,15 +13923,7 @@ int String::getNumBytesAsUTF8() const throw() { ++num; if (c >= 0x10000) - { ++num; - if (c >= 0x200000) - { - ++num; - if (c >= 0x4000000) - ++num; - } - } } } else if (c == 0) @@ -13991,7 +13977,10 @@ const String String::fromUTF8 (const char* const buffer, int bufferSizeBytes) const char nextByte = buffer[i]; if ((nextByte & 0xc0) != 0x80) + { + n = c; // reset to original value if the input is invalid. break; + } n <<= 6; n |= (nextByte & 0x3f); @@ -14331,7 +14320,7 @@ public: zerostruct (wideBuffer); for (int i = 0; i < numElementsInArray (wideBuffer) - 1; ++i) - wideBuffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (std::numeric_limits::max() - 1)); + wideBuffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0x10ffff - 1)); String wide (wideBuffer); expect (wide == (const juce_wchar*) wideBuffer); @@ -18817,10 +18806,6 @@ public: { } - ~SimpleValueSource() - { - } - const var getValue() const { return value; @@ -18828,7 +18813,7 @@ public: void setValue (const var& newValue) { - if (newValue != value) + if (! newValue.equalsWithSameType (value)) { value = newValue; sendChangeMessage (false); @@ -24289,7 +24274,8 @@ AudioTransportSource::~AudioTransportSource() void AudioTransportSource::setSource (PositionableAudioSource* const newSource, int readAheadBufferSize_, - double sourceSampleRateToCorrectFor) + double sourceSampleRateToCorrectFor, + int maxNumChannels) { if (source == newSource) { @@ -24323,7 +24309,7 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource, if (sourceSampleRateToCorrectFor != 0) newMasterSource = newResamplerSource - = new ResamplingAudioSource (newPositionableSource, false); + = new ResamplingAudioSource (newPositionableSource, false, maxNumChannels); else newMasterSource = newPositionableSource; @@ -47834,6 +47820,12 @@ void ComboBox::setItemEnabled (const int itemId, const bool shouldBeEnabled) item->isEnabled = shouldBeEnabled; } +bool ComboBox::isItemEnabled (int itemId) const throw() +{ + const ItemInfo* const item = getItemForId (itemId); + return item != 0 && item->isEnabled; +} + void ComboBox::changeItemText (const int itemId, const String& newText) { ItemInfo* const item = getItemForId (itemId); @@ -238605,8 +238597,12 @@ namespace WindowsFileHelpers const String getDriveFromPath (const String& path) { - if (path.isNotEmpty() && path[1] == ':') - return path.substring (0, 2) + '\\'; + const int length = path.length(); + HeapBlock stringCopy (length + 1); + path.copyToUnicode (stringCopy, length); + + if (PathStripToRoot (stringCopy)) + return String (stringCopy); return path; } @@ -240725,11 +240721,13 @@ class SharedD2DFactory : public DeletedAtShutdown public: SharedD2DFactory() { - D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, &d2dFactory); - DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) &directWriteFactory); + jassertfalse; //xxx Direct2D support isn't ready for use yet! + + D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, d2dFactory.resetAndGetPointerAddress()); + DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) directWriteFactory.resetAndGetPointerAddress()); if (directWriteFactory != 0) - directWriteFactory->GetSystemFontCollection (&systemFonts); + directWriteFactory->GetSystemFontCollection (systemFonts.resetAndGetPointerAddress()); } ~SharedD2DFactory() @@ -240761,10 +240759,10 @@ public: D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(); D2D1_HWND_RENDER_TARGET_PROPERTIES propsHwnd = D2D1::HwndRenderTargetProperties (hwnd, size); - HRESULT hr = SharedD2DFactory::getInstance()->d2dFactory->CreateHwndRenderTarget (props, propsHwnd, &renderingTarget); + HRESULT hr = SharedD2DFactory::getInstance()->d2dFactory->CreateHwndRenderTarget (props, propsHwnd, renderingTarget.resetAndGetPointerAddress()); // xxx check for error - hr = renderingTarget->CreateSolidColorBrush (D2D1::ColorF::ColorF (0.0f, 0.0f, 0.0f, 1.0f), &colourBrush); + hr = renderingTarget->CreateSolidColorBrush (D2D1::ColorF::ColorF (0.0f, 0.0f, 0.0f, 1.0f), colourBrush.resetAndGetPointerAddress()); } ~Direct2DLowLevelGraphicsContext() @@ -240921,7 +240919,7 @@ public: const int x = currentState->origin.getX(); const int y = currentState->origin.getY(); - renderingTarget->SetTransform (transfromToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); + renderingTarget->SetTransform (transformToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); D2D1_SIZE_U size; size.width = image.getWidth(); @@ -240936,7 +240934,7 @@ public: { ComSmartPtr tempBitmap; - renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, &tempBitmap); + renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, tempBitmap.resetAndGetPointerAddress()); if (tempBitmap != 0) renderingTarget->DrawBitmap (tempBitmap); } @@ -241004,7 +241002,7 @@ public: float kerning = currentState->font.getExtraKerningFactor(); // xxx why does removing this line mess up the kerning?? float hScale = currentState->font.getHorizontalScale(); - renderingTarget->SetTransform (D2D1::Matrix3x2F::Scale (hScale, 1) * transfromToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); + renderingTarget->SetTransform (D2D1::Matrix3x2F::Scale (hScale, 1) * transformToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); float dpiX = 0, dpiY = 0; SharedD2DFactory::getInstance()->d2dFactory->GetDesktopDpi (&dpiX, &dpiY); @@ -241103,7 +241101,7 @@ public: clearPathClip(); if (complexClipLayer == 0) - owner.renderingTarget->CreateLayer (&complexClipLayer); + owner.renderingTarget->CreateLayer (complexClipLayer.resetAndGetPointerAddress()); complexClipGeometry = geometry; shouldClipComplex = true; @@ -241126,7 +241124,7 @@ public: clearRectListClip(); if (rectListLayer == 0) - owner.renderingTarget->CreateLayer (&rectListLayer); + owner.renderingTarget->CreateLayer (rectListLayer.resetAndGetPointerAddress()); rectListGeometry = geometry; shouldClipRectList = true; @@ -241150,11 +241148,11 @@ public: clearImageClip(); if (bitmapMaskLayer == 0) - owner.renderingTarget->CreateLayer (&bitmapMaskLayer); + owner.renderingTarget->CreateLayer (bitmapMaskLayer.resetAndGetPointerAddress()); D2D1_BRUSH_PROPERTIES brushProps; brushProps.opacity = 1; - brushProps.transform = transfromToMatrix (transform); + brushProps.transform = transformToMatrix (transform); D2D1_BITMAP_BRUSH_PROPERTIES bmProps = D2D1::BitmapBrushProperties (D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP); @@ -241169,8 +241167,8 @@ public: bp.pixelFormat = owner.renderingTarget->GetPixelFormat(); bp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; - HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, &maskBitmap); - hr = owner.renderingTarget->CreateBitmapBrush (maskBitmap, bmProps, brushProps, &bitmapMaskBrush); + HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, maskBitmap.resetAndGetPointerAddress()); + hr = owner.renderingTarget->CreateBitmapBrush (maskBitmap, bmProps, brushProps, bitmapMaskBrush.resetAndGetPointerAddress()); imageMaskLayerParams = D2D1::LayerParameters(); imageMaskLayerParams.opacityBrush = bitmapMaskBrush; @@ -241284,14 +241282,14 @@ public: fontIndex = 0; ComSmartPtr fontFam; - fonts->GetFontFamily (fontIndex, &fontFam); + fonts->GetFontFamily (fontIndex, fontFam.resetAndGetPointerAddress()); ComSmartPtr font; DWRITE_FONT_WEIGHT weight = this->font.isBold() ? DWRITE_FONT_WEIGHT_BOLD : DWRITE_FONT_WEIGHT_NORMAL; DWRITE_FONT_STYLE style = this->font.isItalic() ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; - fontFam->GetFirstMatchingFont (weight, DWRITE_FONT_STRETCH_NORMAL, style, &font); + fontFam->GetFirstMatchingFont (weight, DWRITE_FONT_STRETCH_NORMAL, style, font.resetAndGetPointerAddress()); - font->CreateFontFace (&localFontFace); + font->CreateFontFace (localFontFace.resetAndGetPointerAddress()); currentFontFace = localFontFace; } } @@ -241331,7 +241329,7 @@ public: { D2D1_BRUSH_PROPERTIES brushProps; brushProps.opacity = fillType.getOpacity(); - brushProps.transform = transfromToMatrix (fillType.transform); + brushProps.transform = transformToMatrix (fillType.transform); D2D1_BITMAP_BRUSH_PROPERTIES bmProps = D2D1::BitmapBrushProperties (D2D1_EXTEND_MODE_WRAP,D2D1_EXTEND_MODE_WRAP); @@ -241348,8 +241346,8 @@ public: bp.pixelFormat = owner.renderingTarget->GetPixelFormat(); bp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; - HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, &bitmap); - hr = owner.renderingTarget->CreateBitmapBrush (bitmap, bmProps, brushProps, &bitmapBrush); + HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, bitmap.resetAndGetPointerAddress()); + hr = owner.renderingTarget->CreateBitmapBrush (bitmap, bmProps, brushProps, bitmapBrush.resetAndGetPointerAddress()); currentBrush = bitmapBrush; } @@ -241359,7 +241357,7 @@ public: D2D1_BRUSH_PROPERTIES brushProps; brushProps.opacity = fillType.getOpacity(); - brushProps.transform = transfromToMatrix (fillType.transform); + brushProps.transform = transformToMatrix (fillType.transform); const int numColors = fillType.gradient->getNumColours(); @@ -241371,7 +241369,7 @@ public: stops[i].position = fillType.gradient->getColourPosition(i); } - owner.renderingTarget->CreateGradientStopCollection (stops.getData(), numColors, &gradientStops); + owner.renderingTarget->CreateGradientStopCollection (stops.getData(), numColors, gradientStops.resetAndGetPointerAddress()); if (fillType.gradient->isRadial) { @@ -241386,7 +241384,7 @@ public: D2D1::Point2F (0, 0), r, r); - owner.renderingTarget->CreateRadialGradientBrush (props, brushProps, gradientStops, &radialGradient); + owner.renderingTarget->CreateRadialGradientBrush (props, brushProps, gradientStops, radialGradient.resetAndGetPointerAddress()); currentBrush = radialGradient; } else @@ -241400,7 +241398,7 @@ public: D2D1::LinearGradientBrushProperties (D2D1::Point2F (p1.getX() + x, p1.getY() + y), D2D1::Point2F (p2.getX() + x, p2.getY() + y)); - owner.renderingTarget->CreateLinearGradientBrush (props, brushProps, gradientStops, &linearGradient); + owner.renderingTarget->CreateLinearGradientBrush (props, brushProps, gradientStops, linearGradient.resetAndGetPointerAddress()); currentBrush = linearGradient; } @@ -241494,7 +241492,7 @@ private: SharedD2DFactory::getInstance()->d2dFactory->CreatePathGeometry (&p); ComSmartPtr sink; - HRESULT hr = p->Open (&sink); // xxx handle error + HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); // xxx handle error sink->SetFillMode (D2D1_FILL_MODE_WINDING); for (int i = clipRegion.getNumRectangles(); --i >= 0;) @@ -241572,7 +241570,7 @@ private: SharedD2DFactory::getInstance()->d2dFactory->CreatePathGeometry (&p); ComSmartPtr sink; - HRESULT hr = p->Open (&sink); + HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); sink->SetFillMode (D2D1_FILL_MODE_WINDING); // xxx need to check Path::isUsingNonZeroWinding() pathToGeometrySink (path, sink, transform, point.getX(), point.getY()); @@ -241581,7 +241579,7 @@ private: return p; } - static const D2D1::Matrix3x2F transfromToMatrix (const AffineTransform& transform) + static const D2D1::Matrix3x2F transformToMatrix (const AffineTransform& transform) { D2D1::Matrix3x2F matrix; matrix._11 = transform.mat00; @@ -253743,6 +253741,7 @@ CameraDevice* CameraDevice::openDevice (int index, #pragma comment(lib, "advapi32.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "version.lib") +#pragma comment(lib, "shlwapi.lib") #ifdef _NATIVE_WCHAR_T_DEFINED #ifdef _DEBUG diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 6ac659d052..6294973680 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -845,6 +845,9 @@ namespace JuceDummyNamespace {} #define JUCE_API __declspec (dllimport) #pragma warning (disable: 4251) #endif + #ifdef __INTEL_COMPILER + #pragma warning (disable: 1125) // (virtual override warning) + #endif #elif defined (__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) #ifdef JUCE_DLL_BUILD #define JUCE_API __attribute__ ((visibility("default"))) @@ -6164,6 +6167,11 @@ public: /** Returns true if this var has the same value as the one supplied. */ bool equals (const var& other) const throw(); + /** Returns true if this var has the same value and type as the one supplied. + This differs from equals() because e.g. "0" and 0 will be considered different. + */ + bool equalsWithSameType (const var& other) const throw(); + private: class VariantType; friend class VariantType; @@ -34867,10 +34875,12 @@ public: rate of the source, and playback will be sample-rate adjusted to maintain playback at the correct pitch. If this is 0, no sample-rate adjustment will be performed + @param maxNumChannels the maximum number of channels that may need to be played */ void setSource (PositionableAudioSource* newSource, int readAheadBufferSize = 0, - double sourceSampleRateToCorrectFor = 0.0); + double sourceSampleRateToCorrectFor = 0.0, + int maxNumChannels = 2); /** Changes the current playback position in the source stream. @@ -39586,6 +39596,9 @@ public: */ void setItemEnabled (int itemId, bool shouldBeEnabled); + /** Returns true if the given item is enabled. */ + bool isItemEnabled (int itemId) const throw(); + /** Changes the text for an existing item. */ void changeItemText (int itemId, const String& newText); @@ -64022,6 +64035,7 @@ END_JUCE_NAMESPACE #pragma comment(lib, "advapi32.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "version.lib") +#pragma comment(lib, "shlwapi.lib") #ifdef _NATIVE_WCHAR_T_DEFINED #ifdef _DEBUG diff --git a/src/audio/audio_sources/juce_AudioTransportSource.cpp b/src/audio/audio_sources/juce_AudioTransportSource.cpp index 09fd30de9c..b21e148cc1 100644 --- a/src/audio/audio_sources/juce_AudioTransportSource.cpp +++ b/src/audio/audio_sources/juce_AudioTransportSource.cpp @@ -61,7 +61,8 @@ AudioTransportSource::~AudioTransportSource() void AudioTransportSource::setSource (PositionableAudioSource* const newSource, int readAheadBufferSize_, - double sourceSampleRateToCorrectFor) + double sourceSampleRateToCorrectFor, + int maxNumChannels) { if (source == newSource) { @@ -95,7 +96,7 @@ void AudioTransportSource::setSource (PositionableAudioSource* const newSource, if (sourceSampleRateToCorrectFor != 0) newMasterSource = newResamplerSource - = new ResamplingAudioSource (newPositionableSource, false); + = new ResamplingAudioSource (newPositionableSource, false, maxNumChannels); else newMasterSource = newPositionableSource; diff --git a/src/audio/audio_sources/juce_AudioTransportSource.h b/src/audio/audio_sources/juce_AudioTransportSource.h index 3d209e32e1..b19da4d84f 100644 --- a/src/audio/audio_sources/juce_AudioTransportSource.h +++ b/src/audio/audio_sources/juce_AudioTransportSource.h @@ -75,10 +75,12 @@ public: rate of the source, and playback will be sample-rate adjusted to maintain playback at the correct pitch. If this is 0, no sample-rate adjustment will be performed + @param maxNumChannels the maximum number of channels that may need to be played */ void setSource (PositionableAudioSource* newSource, int readAheadBufferSize = 0, - double sourceSampleRateToCorrectFor = 0.0); + double sourceSampleRateToCorrectFor = 0.0, + int maxNumChannels = 2); //============================================================================== /** Changes the current playback position in the source stream. diff --git a/src/containers/juce_Value.cpp b/src/containers/juce_Value.cpp index e42eeb29af..d46cf33ad5 100644 --- a/src/containers/juce_Value.cpp +++ b/src/containers/juce_Value.cpp @@ -74,10 +74,6 @@ public: { } - ~SimpleValueSource() - { - } - const var getValue() const { return value; @@ -85,7 +81,7 @@ public: void setValue (const var& newValue) { - if (newValue != value) + if (! newValue.equalsWithSameType (value)) { value = newValue; sendChangeMessage (false); diff --git a/src/containers/juce_Variant.cpp b/src/containers/juce_Variant.cpp index 593f57a1ff..e6aa735e19 100644 --- a/src/containers/juce_Variant.cpp +++ b/src/containers/juce_Variant.cpp @@ -343,6 +343,11 @@ bool var::equals (const var& other) const throw() return type->equals (value, other.value, *other.type); } +bool var::equalsWithSameType (const var& other) const throw() +{ + return type == other.type && equals (other); +} + bool operator== (const var& v1, const var& v2) throw() { return v1.equals (v2); } bool operator!= (const var& v1, const var& v2) throw() { return ! v1.equals (v2); } bool operator== (const var& v1, const String& v2) throw() { return v1.toString() == v2; } diff --git a/src/containers/juce_Variant.h b/src/containers/juce_Variant.h index 76ba85f585..e8dec7b924 100644 --- a/src/containers/juce_Variant.h +++ b/src/containers/juce_Variant.h @@ -140,6 +140,11 @@ public: /** Returns true if this var has the same value as the one supplied. */ bool equals (const var& other) const throw(); + /** Returns true if this var has the same value and type as the one supplied. + This differs from equals() because e.g. "0" and 0 will be considered different. + */ + bool equalsWithSameType (const var& other) const throw(); + private: class VariantType; friend class VariantType; diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 31141d289c..8649956f63 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -140,6 +140,9 @@ #define JUCE_API __declspec (dllimport) #pragma warning (disable: 4251) #endif + #ifdef __INTEL_COMPILER + #pragma warning (disable: 1125) // (virtual override warning) + #endif #elif defined (__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) #ifdef JUCE_DLL_BUILD #define JUCE_API __attribute__ ((visibility("default"))) diff --git a/src/gui/components/controls/juce_ComboBox.cpp b/src/gui/components/controls/juce_ComboBox.cpp index 2f1635a55a..0fd855cefe 100644 --- a/src/gui/components/controls/juce_ComboBox.cpp +++ b/src/gui/components/controls/juce_ComboBox.cpp @@ -159,6 +159,12 @@ void ComboBox::setItemEnabled (const int itemId, const bool shouldBeEnabled) item->isEnabled = shouldBeEnabled; } +bool ComboBox::isItemEnabled (int itemId) const throw() +{ + const ItemInfo* const item = getItemForId (itemId); + return item != 0 && item->isEnabled; +} + void ComboBox::changeItemText (const int itemId, const String& newText) { ItemInfo* const item = getItemForId (itemId); diff --git a/src/gui/components/controls/juce_ComboBox.h b/src/gui/components/controls/juce_ComboBox.h index df89593428..2ba9bad8a1 100644 --- a/src/gui/components/controls/juce_ComboBox.h +++ b/src/gui/components/controls/juce_ComboBox.h @@ -133,6 +133,9 @@ public: */ void setItemEnabled (int itemId, bool shouldBeEnabled); + /** Returns true if the given item is enabled. */ + bool isItemEnabled (int itemId) const throw(); + /** Changes the text for an existing item. */ void changeItemText (int itemId, const String& newText); diff --git a/src/native/windows/juce_win32_AutoLinkLibraries.h b/src/native/windows/juce_win32_AutoLinkLibraries.h index a15b0c7a88..a50db4feb6 100644 --- a/src/native/windows/juce_win32_AutoLinkLibraries.h +++ b/src/native/windows/juce_win32_AutoLinkLibraries.h @@ -13,6 +13,7 @@ #pragma comment(lib, "advapi32.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "version.lib") +#pragma comment(lib, "shlwapi.lib") #ifdef _NATIVE_WCHAR_T_DEFINED #ifdef _DEBUG diff --git a/src/native/windows/juce_win32_Direct2DGraphicsContext.cpp b/src/native/windows/juce_win32_Direct2DGraphicsContext.cpp index bb2efc5221..175d32c0f2 100644 --- a/src/native/windows/juce_win32_Direct2DGraphicsContext.cpp +++ b/src/native/windows/juce_win32_Direct2DGraphicsContext.cpp @@ -34,11 +34,13 @@ class SharedD2DFactory : public DeletedAtShutdown public: SharedD2DFactory() { - D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, &d2dFactory); - DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) &directWriteFactory); + jassertfalse; //xxx Direct2D support isn't ready for use yet! + + D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, d2dFactory.resetAndGetPointerAddress()); + DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) directWriteFactory.resetAndGetPointerAddress()); if (directWriteFactory != 0) - directWriteFactory->GetSystemFontCollection (&systemFonts); + directWriteFactory->GetSystemFontCollection (systemFonts.resetAndGetPointerAddress()); } ~SharedD2DFactory() @@ -72,10 +74,10 @@ public: D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(); D2D1_HWND_RENDER_TARGET_PROPERTIES propsHwnd = D2D1::HwndRenderTargetProperties (hwnd, size); - HRESULT hr = SharedD2DFactory::getInstance()->d2dFactory->CreateHwndRenderTarget (props, propsHwnd, &renderingTarget); + HRESULT hr = SharedD2DFactory::getInstance()->d2dFactory->CreateHwndRenderTarget (props, propsHwnd, renderingTarget.resetAndGetPointerAddress()); // xxx check for error - hr = renderingTarget->CreateSolidColorBrush (D2D1::ColorF::ColorF (0.0f, 0.0f, 0.0f, 1.0f), &colourBrush); + hr = renderingTarget->CreateSolidColorBrush (D2D1::ColorF::ColorF (0.0f, 0.0f, 0.0f, 1.0f), colourBrush.resetAndGetPointerAddress()); } ~Direct2DLowLevelGraphicsContext() @@ -232,7 +234,7 @@ public: const int x = currentState->origin.getX(); const int y = currentState->origin.getY(); - renderingTarget->SetTransform (transfromToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); + renderingTarget->SetTransform (transformToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); D2D1_SIZE_U size; size.width = image.getWidth(); @@ -247,7 +249,7 @@ public: { ComSmartPtr tempBitmap; - renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, &tempBitmap); + renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, tempBitmap.resetAndGetPointerAddress()); if (tempBitmap != 0) renderingTarget->DrawBitmap (tempBitmap); } @@ -315,7 +317,7 @@ public: float kerning = currentState->font.getExtraKerningFactor(); // xxx why does removing this line mess up the kerning?? float hScale = currentState->font.getHorizontalScale(); - renderingTarget->SetTransform (D2D1::Matrix3x2F::Scale (hScale, 1) * transfromToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); + renderingTarget->SetTransform (D2D1::Matrix3x2F::Scale (hScale, 1) * transformToMatrix (transform) * D2D1::Matrix3x2F::Translation (x, y)); float dpiX = 0, dpiY = 0; SharedD2DFactory::getInstance()->d2dFactory->GetDesktopDpi (&dpiX, &dpiY); @@ -415,7 +417,7 @@ public: clearPathClip(); if (complexClipLayer == 0) - owner.renderingTarget->CreateLayer (&complexClipLayer); + owner.renderingTarget->CreateLayer (complexClipLayer.resetAndGetPointerAddress()); complexClipGeometry = geometry; shouldClipComplex = true; @@ -438,7 +440,7 @@ public: clearRectListClip(); if (rectListLayer == 0) - owner.renderingTarget->CreateLayer (&rectListLayer); + owner.renderingTarget->CreateLayer (rectListLayer.resetAndGetPointerAddress()); rectListGeometry = geometry; shouldClipRectList = true; @@ -462,11 +464,11 @@ public: clearImageClip(); if (bitmapMaskLayer == 0) - owner.renderingTarget->CreateLayer (&bitmapMaskLayer); + owner.renderingTarget->CreateLayer (bitmapMaskLayer.resetAndGetPointerAddress()); D2D1_BRUSH_PROPERTIES brushProps; brushProps.opacity = 1; - brushProps.transform = transfromToMatrix (transform); + brushProps.transform = transformToMatrix (transform); D2D1_BITMAP_BRUSH_PROPERTIES bmProps = D2D1::BitmapBrushProperties (D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP); @@ -481,8 +483,8 @@ public: bp.pixelFormat = owner.renderingTarget->GetPixelFormat(); bp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; - HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, &maskBitmap); - hr = owner.renderingTarget->CreateBitmapBrush (maskBitmap, bmProps, brushProps, &bitmapMaskBrush); + HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, maskBitmap.resetAndGetPointerAddress()); + hr = owner.renderingTarget->CreateBitmapBrush (maskBitmap, bmProps, brushProps, bitmapMaskBrush.resetAndGetPointerAddress()); imageMaskLayerParams = D2D1::LayerParameters(); imageMaskLayerParams.opacityBrush = bitmapMaskBrush; @@ -596,14 +598,14 @@ public: fontIndex = 0; ComSmartPtr fontFam; - fonts->GetFontFamily (fontIndex, &fontFam); + fonts->GetFontFamily (fontIndex, fontFam.resetAndGetPointerAddress()); ComSmartPtr font; DWRITE_FONT_WEIGHT weight = this->font.isBold() ? DWRITE_FONT_WEIGHT_BOLD : DWRITE_FONT_WEIGHT_NORMAL; DWRITE_FONT_STYLE style = this->font.isItalic() ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; - fontFam->GetFirstMatchingFont (weight, DWRITE_FONT_STRETCH_NORMAL, style, &font); + fontFam->GetFirstMatchingFont (weight, DWRITE_FONT_STRETCH_NORMAL, style, font.resetAndGetPointerAddress()); - font->CreateFontFace (&localFontFace); + font->CreateFontFace (localFontFace.resetAndGetPointerAddress()); currentFontFace = localFontFace; } } @@ -643,7 +645,7 @@ public: { D2D1_BRUSH_PROPERTIES brushProps; brushProps.opacity = fillType.getOpacity(); - brushProps.transform = transfromToMatrix (fillType.transform); + brushProps.transform = transformToMatrix (fillType.transform); D2D1_BITMAP_BRUSH_PROPERTIES bmProps = D2D1::BitmapBrushProperties (D2D1_EXTEND_MODE_WRAP,D2D1_EXTEND_MODE_WRAP); @@ -660,8 +662,8 @@ public: bp.pixelFormat = owner.renderingTarget->GetPixelFormat(); bp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; - HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, &bitmap); - hr = owner.renderingTarget->CreateBitmapBrush (bitmap, bmProps, brushProps, &bitmapBrush); + HRESULT hr = owner.renderingTarget->CreateBitmap (size, bd.data, bd.lineStride, bp, bitmap.resetAndGetPointerAddress()); + hr = owner.renderingTarget->CreateBitmapBrush (bitmap, bmProps, brushProps, bitmapBrush.resetAndGetPointerAddress()); currentBrush = bitmapBrush; } @@ -671,7 +673,7 @@ public: D2D1_BRUSH_PROPERTIES brushProps; brushProps.opacity = fillType.getOpacity(); - brushProps.transform = transfromToMatrix (fillType.transform); + brushProps.transform = transformToMatrix (fillType.transform); const int numColors = fillType.gradient->getNumColours(); @@ -683,7 +685,7 @@ public: stops[i].position = fillType.gradient->getColourPosition(i); } - owner.renderingTarget->CreateGradientStopCollection (stops.getData(), numColors, &gradientStops); + owner.renderingTarget->CreateGradientStopCollection (stops.getData(), numColors, gradientStops.resetAndGetPointerAddress()); if (fillType.gradient->isRadial) { @@ -698,7 +700,7 @@ public: D2D1::Point2F (0, 0), r, r); - owner.renderingTarget->CreateRadialGradientBrush (props, brushProps, gradientStops, &radialGradient); + owner.renderingTarget->CreateRadialGradientBrush (props, brushProps, gradientStops, radialGradient.resetAndGetPointerAddress()); currentBrush = radialGradient; } else @@ -712,7 +714,7 @@ public: D2D1::LinearGradientBrushProperties (D2D1::Point2F (p1.getX() + x, p1.getY() + y), D2D1::Point2F (p2.getX() + x, p2.getY() + y)); - owner.renderingTarget->CreateLinearGradientBrush (props, brushProps, gradientStops, &linearGradient); + owner.renderingTarget->CreateLinearGradientBrush (props, brushProps, gradientStops, linearGradient.resetAndGetPointerAddress()); currentBrush = linearGradient; } @@ -809,7 +811,7 @@ private: SharedD2DFactory::getInstance()->d2dFactory->CreatePathGeometry (&p); ComSmartPtr sink; - HRESULT hr = p->Open (&sink); // xxx handle error + HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); // xxx handle error sink->SetFillMode (D2D1_FILL_MODE_WINDING); for (int i = clipRegion.getNumRectangles(); --i >= 0;) @@ -887,7 +889,7 @@ private: SharedD2DFactory::getInstance()->d2dFactory->CreatePathGeometry (&p); ComSmartPtr sink; - HRESULT hr = p->Open (&sink); + HRESULT hr = p->Open (sink.resetAndGetPointerAddress()); sink->SetFillMode (D2D1_FILL_MODE_WINDING); // xxx need to check Path::isUsingNonZeroWinding() pathToGeometrySink (path, sink, transform, point.getX(), point.getY()); @@ -896,7 +898,7 @@ private: return p; } - static const D2D1::Matrix3x2F transfromToMatrix (const AffineTransform& transform) + static const D2D1::Matrix3x2F transformToMatrix (const AffineTransform& transform) { D2D1::Matrix3x2F matrix; matrix._11 = transform.mat00; diff --git a/src/native/windows/juce_win32_Files.cpp b/src/native/windows/juce_win32_Files.cpp index 2864d43ac2..1b0e342353 100644 --- a/src/native/windows/juce_win32_Files.cpp +++ b/src/native/windows/juce_win32_Files.cpp @@ -58,8 +58,12 @@ namespace WindowsFileHelpers const String getDriveFromPath (const String& path) { - if (path.isNotEmpty() && path[1] == ':') - return path.substring (0, 2) + '\\'; + const int length = path.length(); + HeapBlock stringCopy (length + 1); + path.copyToUnicode (stringCopy, length); + + if (PathStripToRoot (stringCopy)) + return String (stringCopy); return path; } diff --git a/src/native/windows/juce_win32_NativeIncludes.h b/src/native/windows/juce_win32_NativeIncludes.h index e8ac941fab..331327391c 100644 --- a/src/native/windows/juce_win32_NativeIncludes.h +++ b/src/native/windows/juce_win32_NativeIncludes.h @@ -41,10 +41,6 @@ #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4100 4201 4514 4312 4995) - - #ifdef __INTEL_COMPILER - #pragma warning (disable: 1125) - #endif #endif #define _WIN32_WINNT 0x0500 @@ -73,6 +69,7 @@ #include #include #include +#include #if ! JUCE_MINGW #include diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index c76427df35..dd87d3dad4 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -1880,21 +1880,20 @@ int64 String::getHexValue64() const throw() //============================================================================== const String String::createStringFromData (const void* const data_, const int size) { - const char* const data = static_cast (data_); + const uint8* const data = static_cast (data_); if (size <= 0 || data == 0) { return empty; } - else if (size < 2) + else if (size == 1) { - return charToString (data[0]); + return charToString ((char) data[0]); } - else if ((data[0] == (char)-2 && data[1] == (char)-1) - || (data[0] == (char)-1 && data[1] == (char)-2)) + else if ((data[0] == (uint8) 0xfe && data[1] == (uint8) 0xff) // UTF-16 BOM + || (data[0] == (uint8) 0xff && data[1] == (uint8) 0xfe)) { - // assume it's 16-bit unicode - const bool bigEndian = (data[0] == (char)-2); + const bool bigEndian = (data[0] == (uint8) 0xfe); const int numChars = size / 2 - 1; String result; @@ -1919,7 +1918,10 @@ const String String::createStringFromData (const void* const data_, const int si } else { - return String::fromUTF8 (data, size); + if (size >= 3 && data[0] == (uint8) 0xef && data[1] == (uint8) 0xbb && data[2] == (uint8) 0xbf) // UTF-8 BOM + return String::fromUTF8 ((const char*) data + 3, size - 3); + + return String::fromUTF8 ((const char*) data, size); } } @@ -1968,17 +1970,7 @@ int String::copyToUTF8 (char* const buffer, const int maxBufferSizeBytes) const ++numExtraBytes; if (c >= 0x10000) - { ++numExtraBytes; - - if (c >= 0x200000) - { - ++numExtraBytes; - - if (c >= 0x4000000) - ++numExtraBytes; - } - } } if (buffer != 0) @@ -2040,15 +2032,7 @@ int String::getNumBytesAsUTF8() const throw() { ++num; if (c >= 0x10000) - { ++num; - if (c >= 0x200000) - { - ++num; - if (c >= 0x4000000) - ++num; - } - } } } else if (c == 0) @@ -2102,7 +2086,10 @@ const String String::fromUTF8 (const char* const buffer, int bufferSizeBytes) const char nextByte = buffer[i]; if ((nextByte & 0xc0) != 0x80) + { + n = c; // reset to original value if the input is invalid. break; + } n <<= 6; n |= (nextByte & 0x3f); @@ -2451,7 +2438,7 @@ public: zerostruct (wideBuffer); for (int i = 0; i < numElementsInArray (wideBuffer) - 1; ++i) - wideBuffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (std::numeric_limits::max() - 1)); + wideBuffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0x10ffff - 1)); String wide (wideBuffer); expect (wide == (const juce_wchar*) wideBuffer);