Browse Source

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.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
41c9c9e3be
15 changed files with 161 additions and 136 deletions
  1. +66
    -67
      juce_amalgamated.cpp
  2. +15
    -1
      juce_amalgamated.h
  3. +3
    -2
      src/audio/audio_sources/juce_AudioTransportSource.cpp
  4. +3
    -1
      src/audio/audio_sources/juce_AudioTransportSource.h
  5. +1
    -5
      src/containers/juce_Value.cpp
  6. +5
    -0
      src/containers/juce_Variant.cpp
  7. +5
    -0
      src/containers/juce_Variant.h
  8. +3
    -0
      src/core/juce_StandardHeader.h
  9. +6
    -0
      src/gui/components/controls/juce_ComboBox.cpp
  10. +3
    -0
      src/gui/components/controls/juce_ComboBox.h
  11. +1
    -0
      src/native/windows/juce_win32_AutoLinkLibraries.h
  12. +29
    -27
      src/native/windows/juce_win32_Direct2DGraphicsContext.cpp
  13. +6
    -2
      src/native/windows/juce_win32_Files.cpp
  14. +1
    -4
      src/native/windows/juce_win32_NativeIncludes.h
  15. +14
    -27
      src/text/juce_String.cpp

+ 66
- 67
juce_amalgamated.cpp View File

@@ -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 <Exdisp.h>
#include <exdispid.h>
#include <shlobj.h>
#include <shlwapi.h>

#if ! JUCE_MINGW
#include <crtdbg.h>
@@ -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 <const char*> (data_);
const uint8* const data = static_cast <const uint8*> (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<juce_wchar>::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 <WCHAR> 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 <ID2D1Bitmap> 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 <IDWriteFontFamily> fontFam;
fonts->GetFontFamily (fontIndex, &fontFam);
fonts->GetFontFamily (fontIndex, fontFam.resetAndGetPointerAddress());

ComSmartPtr <IDWriteFont> 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 <ID2D1GeometrySink> 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 <ID2D1GeometrySink> 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


+ 15
- 1
juce_amalgamated.h View File

@@ -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


+ 3
- 2
src/audio/audio_sources/juce_AudioTransportSource.cpp View File

@@ -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;


+ 3
- 1
src/audio/audio_sources/juce_AudioTransportSource.h View File

@@ -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.


+ 1
- 5
src/containers/juce_Value.cpp View File

@@ -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);


+ 5
- 0
src/containers/juce_Variant.cpp View File

@@ -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; }


+ 5
- 0
src/containers/juce_Variant.h View File

@@ -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;


+ 3
- 0
src/core/juce_StandardHeader.h View File

@@ -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")))


+ 6
- 0
src/gui/components/controls/juce_ComboBox.cpp View File

@@ -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);


+ 3
- 0
src/gui/components/controls/juce_ComboBox.h View File

@@ -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);


+ 1
- 0
src/native/windows/juce_win32_AutoLinkLibraries.h View File

@@ -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


+ 29
- 27
src/native/windows/juce_win32_Direct2DGraphicsContext.cpp View File

@@ -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 <ID2D1Bitmap> 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 <IDWriteFontFamily> fontFam;
fonts->GetFontFamily (fontIndex, &fontFam);
fonts->GetFontFamily (fontIndex, fontFam.resetAndGetPointerAddress());
ComSmartPtr <IDWriteFont> 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 <ID2D1GeometrySink> 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 <ID2D1GeometrySink> 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;


+ 6
- 2
src/native/windows/juce_win32_Files.cpp View File

@@ -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 <WCHAR> stringCopy (length + 1);
path.copyToUnicode (stringCopy, length);
if (PathStripToRoot (stringCopy))
return String (stringCopy);
return path;
}


+ 1
- 4
src/native/windows/juce_win32_NativeIncludes.h View File

@@ -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 <Exdisp.h>
#include <exdispid.h>
#include <shlobj.h>
#include <shlwapi.h>
#if ! JUCE_MINGW
#include <crtdbg.h>


+ 14
- 27
src/text/juce_String.cpp View File

@@ -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 <const char*> (data_);
const uint8* const data = static_cast <const uint8*> (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<juce_wchar>::max() - 1));
wideBuffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0x10ffff - 1));
String wide (wideBuffer);
expect (wide == (const juce_wchar*) wideBuffer);


Loading…
Cancel
Save