| @@ -297,7 +297,7 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||
| if (usesFloatingPointData) | |||
| { | |||
| const float sample1 = fabsf (((float*) tempBuffer[0]) [index]); | |||
| const float sample1 = std::abs (((float*) tempBuffer[0]) [index]); | |||
| if (sample1 >= magnitudeRangeMinimum | |||
| && sample1 <= magnitudeRangeMaximum) | |||
| @@ -306,7 +306,7 @@ int64 AudioFormatReader::searchForLevel (int64 startSample, | |||
| } | |||
| else if (numChannels > 1) | |||
| { | |||
| const float sample2 = fabsf (((float*) tempBuffer[1]) [index]); | |||
| const float sample2 = std::abs (((float*) tempBuffer[1]) [index]); | |||
| matches = (sample2 >= magnitudeRangeMinimum | |||
| && sample2 <= magnitudeRangeMaximum); | |||
| @@ -205,14 +205,14 @@ void ResamplingAudioSource::createLowPass (const double frequencyRatio) | |||
| const double n = 1.0 / tan (double_Pi * jmax (0.001, proportionalRate)); | |||
| const double nSquared = n * n; | |||
| const double c1 = 1.0 / (1.0 + sqrt (2.0) * n + nSquared); | |||
| const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | |||
| setFilterCoefficients (c1, | |||
| c1 * 2.0f, | |||
| c1, | |||
| 1.0, | |||
| c1 * 2.0 * (1.0 - nSquared), | |||
| c1 * (1.0 - sqrt (2.0) * n + nSquared)); | |||
| c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); | |||
| } | |||
| void ResamplingAudioSource::setFilterCoefficients (double c1, double c2, double c3, double c4, double c5, double c6) | |||
| @@ -76,7 +76,7 @@ void ToneGeneratorAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& | |||
| for (int i = 0; i < info.numSamples; ++i) | |||
| { | |||
| const float sample = amplitude * (float) sin (currentPhase); | |||
| const float sample = amplitude * (float) std::sin (currentPhase); | |||
| currentPhase += phasePerSample; | |||
| for (int j = info.buffer->getNumChannels(); --j >= 0;) | |||
| @@ -645,7 +645,7 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat | |||
| float s = 0; | |||
| for (int i = 0; i < numInputChannels; ++i) | |||
| s += fabsf (inputChannelData[i][j]); | |||
| s += std::abs (inputChannelData[i][j]); | |||
| s /= numInputChannels; | |||
| @@ -946,7 +946,7 @@ void AudioDeviceManager::playTestSound() | |||
| const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); | |||
| for (int i = 0; i < soundLength; ++i) | |||
| samples[i] = amplitude * (float) sin (i * phasePerSample); | |||
| samples[i] = amplitude * (float) std::sin (i * phasePerSample); | |||
| newSound->applyGainRamp (0, 0, soundLength / 10, 0.0f, 1.0f); | |||
| newSound->applyGainRamp (0, soundLength - soundLength / 4, soundLength / 4, 1.0f, 0.0f); | |||
| @@ -566,7 +566,7 @@ float AudioSampleBuffer::getRMSLevel (const int channel, | |||
| sum += sample * sample; | |||
| } | |||
| return (float) sqrt (sum / numSamples); | |||
| return (float) std::sqrt (sum / numSamples); | |||
| } | |||
| void AudioSampleBuffer::readFromAudioReader (AudioFormatReader* reader, | |||
| @@ -122,14 +122,14 @@ void IIRFilter::makeLowPass (const double sampleRate, | |||
| const double n = 1.0 / tan (double_Pi * frequency / sampleRate); | |||
| const double nSquared = n * n; | |||
| const double c1 = 1.0 / (1.0 + sqrt (2.0) * n + nSquared); | |||
| const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | |||
| setCoefficients (c1, | |||
| c1 * 2.0f, | |||
| c1, | |||
| 1.0, | |||
| c1 * 2.0 * (1.0 - nSquared), | |||
| c1 * (1.0 - sqrt (2.0) * n + nSquared)); | |||
| c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); | |||
| } | |||
| void IIRFilter::makeHighPass (const double sampleRate, | |||
| @@ -137,14 +137,14 @@ void IIRFilter::makeHighPass (const double sampleRate, | |||
| { | |||
| const double n = tan (double_Pi * frequency / sampleRate); | |||
| const double nSquared = n * n; | |||
| const double c1 = 1.0 / (1.0 + sqrt (2.0) * n + nSquared); | |||
| const double c1 = 1.0 / (1.0 + std::sqrt (2.0) * n + nSquared); | |||
| setCoefficients (c1, | |||
| c1 * -2.0f, | |||
| c1, | |||
| 1.0, | |||
| c1 * 2.0 * (nSquared - 1.0), | |||
| c1 * (1.0 - sqrt (2.0) * n + nSquared)); | |||
| c1 * (1.0 - std::sqrt (2.0) * n + nSquared)); | |||
| } | |||
| void IIRFilter::makeLowShelf (const double sampleRate, | |||
| @@ -159,8 +159,8 @@ void IIRFilter::makeLowShelf (const double sampleRate, | |||
| const double aminus1 = A - 1.0; | |||
| const double aplus1 = A + 1.0; | |||
| const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate; | |||
| const double coso = cos (omega); | |||
| const double beta = sin (omega) * sqrt (A) / Q; | |||
| const double coso = std::cos (omega); | |||
| const double beta = std::sin (omega) * std::sqrt (A) / Q; | |||
| const double aminus1TimesCoso = aminus1 * coso; | |||
| setCoefficients (A * (aplus1 - aminus1TimesCoso + beta), | |||
| @@ -183,8 +183,8 @@ void IIRFilter::makeHighShelf (const double sampleRate, | |||
| const double aminus1 = A - 1.0; | |||
| const double aplus1 = A + 1.0; | |||
| const double omega = (double_Pi * 2.0 * jmax (cutOffFrequency, 2.0)) / sampleRate; | |||
| const double coso = cos (omega); | |||
| const double beta = sin (omega) * sqrt (A) / Q; | |||
| const double coso = std::cos (omega); | |||
| const double beta = std::sin (omega) * std::sqrt (A) / Q; | |||
| const double aminus1TimesCoso = aminus1 * coso; | |||
| setCoefficients (A * (aplus1 + aminus1TimesCoso + beta), | |||
| @@ -205,8 +205,8 @@ void IIRFilter::makeBandPass (const double sampleRate, | |||
| const double A = jmax (0.0f, gainFactor); | |||
| const double omega = (double_Pi * 2.0 * jmax (centreFrequency, 2.0)) / sampleRate; | |||
| const double alpha = 0.5 * sin (omega) / Q; | |||
| const double c2 = -2.0 * cos (omega); | |||
| const double alpha = 0.5 * std::sin (omega) / Q; | |||
| const double c2 = -2.0 * std::cos (omega); | |||
| const double alphaTimesA = alpha * A; | |||
| const double alphaOverA = alpha / A; | |||
| @@ -804,7 +804,7 @@ void ValueTree::writeToStream (OutputStream& output) | |||
| ValueTree ValueTree::readFromStream (InputStream& input) | |||
| { | |||
| String type (input.readString()); | |||
| const String type (input.readString()); | |||
| if (type.isEmpty()) | |||
| return ValueTree::invalid; | |||
| @@ -76,7 +76,7 @@ public: | |||
| This can be called directly, or by using the DBG() macro in | |||
| juce_PlatformDefs.h (which will avoid calling the method in non-debug builds). | |||
| */ | |||
| static void JUCE_CALLTYPE outputDebugString (const String& text) throw(); | |||
| static void JUCE_CALLTYPE outputDebugString (const String& text); | |||
| protected: | |||
| @@ -40,7 +40,7 @@ BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| const String SystemStats::getJUCEVersion() throw() | |||
| const String SystemStats::getJUCEVersion() | |||
| { | |||
| return "JUCE v" + String (JUCE_MAJOR_VERSION) | |||
| + "." + String (JUCE_MINOR_VERSION) | |||
| @@ -43,7 +43,7 @@ public: | |||
| See also the JUCE_VERSION, JUCE_MAJOR_VERSION and JUCE_MINOR_VERSION macros. | |||
| */ | |||
| static const String getJUCEVersion() throw(); | |||
| static const String getJUCEVersion(); | |||
| //============================================================================== | |||
| /** The set of possible results of the getOperatingSystemType() method. | |||
| @@ -75,18 +75,18 @@ public: | |||
| @returns one of the values from the OperatingSystemType enum. | |||
| @see getOperatingSystemName | |||
| */ | |||
| static OperatingSystemType getOperatingSystemType() throw(); | |||
| static OperatingSystemType getOperatingSystemType(); | |||
| /** Returns the name of the type of operating system we're running on. | |||
| @returns a string describing the OS type. | |||
| @see getOperatingSystemType | |||
| */ | |||
| static const String getOperatingSystemName() throw(); | |||
| static const String getOperatingSystemName(); | |||
| /** Returns true if the OS is 64-bit, or false for a 32-bit OS. | |||
| */ | |||
| static bool isOperatingSystem64Bit() throw(); | |||
| static bool isOperatingSystem64Bit(); | |||
| //============================================================================== | |||
| /** Returns the current user's name, if available. | |||
| @@ -108,39 +108,29 @@ public: | |||
| @returns the speed in megahertz, e.g. 1500, 2500, 32000 (depending on | |||
| what year you're reading this...) | |||
| */ | |||
| static int getCpuSpeedInMegaherz() throw(); | |||
| static int getCpuSpeedInMegaherz(); | |||
| /** Returns a string to indicate the CPU vendor. | |||
| Might not be known on some systems. | |||
| */ | |||
| static const String getCpuVendor() throw(); | |||
| static const String getCpuVendor(); | |||
| /** Checks whether Intel MMX instructions are available. */ | |||
| static bool hasMMX() throw(); | |||
| static bool hasMMX(); | |||
| /** Checks whether Intel SSE instructions are available. */ | |||
| static bool hasSSE() throw(); | |||
| static bool hasSSE(); | |||
| /** Checks whether Intel SSE2 instructions are available. */ | |||
| static bool hasSSE2() throw(); | |||
| static bool hasSSE2(); | |||
| /** Checks whether AMD 3DNOW instructions are available. */ | |||
| static bool has3DNow() throw(); | |||
| static bool has3DNow(); | |||
| /** Returns the number of CPUs. | |||
| */ | |||
| static int getNumCpus() throw(); | |||
| /** Returns a clock-cycle tick counter, if available. | |||
| If the machine can do it, this will return a tick-count | |||
| where each tick is one cpu clock cycle - used for profiling | |||
| code. | |||
| @returns the tick count, or zero if not available. | |||
| */ | |||
| static int64 getClockCycleCounter() throw(); | |||
| static int getNumCpus(); | |||
| //============================================================================== | |||
| /** Finds out how much RAM is in the machine. | |||
| @@ -148,13 +138,13 @@ public: | |||
| @returns the approximate number of megabytes of memory, or zero if | |||
| something goes wrong when finding out. | |||
| */ | |||
| static int getMemorySizeInMegabytes() throw(); | |||
| static int getMemorySizeInMegabytes(); | |||
| /** Returns the system page-size. | |||
| This is only used by programmers with beards. | |||
| */ | |||
| static int getPageSize() throw(); | |||
| static int getPageSize(); | |||
| //============================================================================== | |||
| /** Returns a list of MAC addresses found on this machine. | |||
| @@ -188,7 +178,7 @@ public: | |||
| //============================================================================== | |||
| // not-for-public-use platform-specific method gets called at startup to initialise things. | |||
| static void initialiseStats() throw(); | |||
| static void initialiseStats(); | |||
| private: | |||
| SystemStats(); | |||
| @@ -281,7 +281,7 @@ public: | |||
| @returns true if this succeeds, although depending on the system, the | |||
| application might not have sufficient privileges to do this. | |||
| */ | |||
| bool setSystemTimeToThisTime() const throw(); | |||
| bool setSystemTimeToThisTime() const; | |||
| //============================================================================== | |||
| /** Returns the name of a day of the week. | |||
| @@ -51,39 +51,70 @@ static bool isIdentifierStart (const juce_wchar c) throw() | |||
| static bool isIdentifierBody (const juce_wchar c) throw() | |||
| { | |||
| return CharacterFunctions::isLetter (c) | |||
| || CharacterFunctions::isDigit (c) | |||
| return CharacterFunctions::isLetterOrDigit (c) | |||
| || c == '_' || c == '@'; | |||
| } | |||
| static int parseIdentifier (CodeDocument::Iterator& source) throw() | |||
| static bool isReservedKeyword (const juce_wchar* const token, const int tokenLength) throw() | |||
| { | |||
| static const juce_wchar* keywords2Char[] = | |||
| { T("if"), T("do"), T("or"), 0 }; | |||
| static const juce_wchar* const keywords2Char[] = | |||
| { T("if"), T("do"), T("or"), T("id"), 0 }; | |||
| static const juce_wchar* keywords3Char[] = | |||
| static const juce_wchar* const keywords3Char[] = | |||
| { T("for"), T("int"), T("new"), T("try"), T("xor"), T("and"), T("asm"), T("not"), 0 }; | |||
| static const juce_wchar* keywords4Char[] = | |||
| static const juce_wchar* const keywords4Char[] = | |||
| { T("bool"), T("void"), T("this"), T("true"), T("long"), T("else"), T("char"), | |||
| T("enum"), T("case"), T("goto"), T("auto"), 0 }; | |||
| static const juce_wchar* keywords5Char[] = | |||
| static const juce_wchar* const keywords5Char[] = | |||
| { T("while"), T("bitor"), T("break"), T("catch"), T("class"), T("compl"), T("const"), T("false"), | |||
| T("float"), T("short"), T("throw"), T("union"), T("using"), T("or_eq"), 0 }; | |||
| static const juce_wchar* keywords6Char[] = | |||
| static const juce_wchar* const keywords6Char[] = | |||
| { T("return"), T("struct"), T("and_eq"), T("bitand"), T("delete"), T("double"), T("extern"), | |||
| T("friend"), T("inline"), T("not_eq"), T("public"), T("sizeof"), T("static"), T("signed"), | |||
| T("switch"), T("typeid"), T("wchar_t"), T("xor_eq"), 0}; | |||
| static const juce_wchar* keywordsOther[] = | |||
| static const juce_wchar* const keywordsOther[] = | |||
| { T("const_cast"), T("continue"), T("default"), T("explicit"), T("mutable"), T("namespace"), | |||
| T("operator"), T("private"), T("protected"), T("register"), T("reinterpret_cast"), T("static_cast"), | |||
| T("template"), T("typedef"), T("typename"), T("unsigned"), T("virtual"), T("volatile"), | |||
| T("@implementation"), T("@interface"), T("@end"), T("@synthesize"), T("@dynamic"), T("@public"), | |||
| T("@private"), T("@property"), T("@protected"), T("@class"), 0 }; | |||
| const juce_wchar* const* k; | |||
| switch (tokenLength) | |||
| { | |||
| case 2: k = keywords2Char; break; | |||
| case 3: k = keywords3Char; break; | |||
| case 4: k = keywords4Char; break; | |||
| case 5: k = keywords5Char; break; | |||
| case 6: k = keywords6Char; break; | |||
| default: | |||
| if (tokenLength < 2 || tokenLength > 16) | |||
| return false; | |||
| k = keywordsOther; | |||
| break; | |||
| } | |||
| int i = 0; | |||
| while (k[i] != 0) | |||
| { | |||
| if (k[i][0] == token[0] && CharacterFunctions::compare (k[i], token) == 0) | |||
| return true; | |||
| ++i; | |||
| } | |||
| return false; | |||
| } | |||
| static int parseIdentifier (CodeDocument::Iterator& source) throw() | |||
| { | |||
| int tokenLength = 0; | |||
| juce_wchar possibleIdentifier [19]; | |||
| @@ -100,26 +131,9 @@ static int parseIdentifier (CodeDocument::Iterator& source) throw() | |||
| if (tokenLength > 1 && tokenLength <= 16) | |||
| { | |||
| possibleIdentifier [tokenLength] = 0; | |||
| const juce_wchar** k; | |||
| switch (tokenLength) | |||
| { | |||
| case 2: k = keywords2Char; break; | |||
| case 3: k = keywords3Char; break; | |||
| case 4: k = keywords4Char; break; | |||
| case 5: k = keywords5Char; break; | |||
| case 6: k = keywords6Char; break; | |||
| default: k = keywordsOther; break; | |||
| } | |||
| int i = 0; | |||
| while (k[i] != 0) | |||
| { | |||
| if (k[i][0] == possibleIdentifier[0] && CharacterFunctions::compare (k[i], possibleIdentifier) == 0) | |||
| return CPlusPlusCodeTokeniser::tokenType_builtInKeyword; | |||
| ++i; | |||
| } | |||
| if (isReservedKeyword (possibleIdentifier, tokenLength)) | |||
| return CPlusPlusCodeTokeniser::tokenType_builtInKeyword; | |||
| } | |||
| return CPlusPlusCodeTokeniser::tokenType_identifier; | |||
| @@ -551,25 +565,28 @@ int CPlusPlusCodeTokeniser::readNextToken (CodeDocument::Iterator& source) | |||
| break; | |||
| } | |||
| //jassert (result != tokenType_unknown); | |||
| return result; | |||
| } | |||
| const StringArray CPlusPlusCodeTokeniser::getTokenTypes() | |||
| { | |||
| StringArray s; | |||
| s.add ("Error"); | |||
| s.add ("Comment"); | |||
| s.add ("C++ keyword"); | |||
| s.add ("Identifier"); | |||
| s.add ("Integer literal"); | |||
| s.add ("Float literal"); | |||
| s.add ("String literal"); | |||
| s.add ("Operator"); | |||
| s.add ("Bracket"); | |||
| s.add ("Punctuation"); | |||
| s.add ("Preprocessor line"); | |||
| return s; | |||
| const char* const types[] = | |||
| { | |||
| "Error", | |||
| "Comment", | |||
| "C++ keyword", | |||
| "Identifier", | |||
| "Integer literal", | |||
| "Float literal", | |||
| "String literal", | |||
| "Operator", | |||
| "Bracket", | |||
| "Punctuation", | |||
| "Preprocessor line", | |||
| 0 | |||
| }; | |||
| return StringArray (types); | |||
| } | |||
| const Colour CPlusPlusCodeTokeniser::getDefaultColour (const int tokenType) | |||
| @@ -595,5 +612,9 @@ const Colour CPlusPlusCodeTokeniser::getDefaultColour (const int tokenType) | |||
| return Colours::black; | |||
| } | |||
| bool CPlusPlusCodeTokeniser::isReservedKeyword (const String& token) throw() | |||
| { | |||
| return CppTokeniser::isReservedKeyword (token, token.length()); | |||
| } | |||
| END_JUCE_NAMESPACE | |||
| @@ -63,6 +63,9 @@ public: | |||
| const StringArray getTokenTypes(); | |||
| const Colour getDefaultColour (int tokenType); | |||
| /** This is a handy method for checking whether a string is a c++ reserved keyword. */ | |||
| static bool isReservedKeyword (const String& token) throw(); | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| }; | |||
| @@ -742,7 +742,7 @@ void Slider::buttonClicked (Button* button) | |||
| double Slider::constrainedValue (double value) const | |||
| { | |||
| if (interval > 0) | |||
| value = minimum + interval * floor ((value - minimum) / interval + 0.5); | |||
| value = minimum + interval * std::floor ((value - minimum) / interval + 0.5); | |||
| if (value <= minimum || maximum <= minimum) | |||
| value = minimum; | |||
| @@ -1053,9 +1053,9 @@ void Slider::mouseDown (const MouseEvent& e) | |||
| { | |||
| const float mousePos = (float) (isVertical() ? e.y : e.x); | |||
| const float normalPosDistance = fabsf (getLinearSliderPos (currentValue.getValue()) - mousePos); | |||
| const float minPosDistance = fabsf (getLinearSliderPos (valueMin.getValue()) - 0.1f - mousePos); | |||
| const float maxPosDistance = fabsf (getLinearSliderPos (valueMax.getValue()) + 0.1f - mousePos); | |||
| const float normalPosDistance = std::abs (getLinearSliderPos (currentValue.getValue()) - mousePos); | |||
| const float minPosDistance = std::abs (getLinearSliderPos (valueMin.getValue()) - 0.1f - mousePos); | |||
| const float maxPosDistance = std::abs (getLinearSliderPos (valueMax.getValue()) + 0.1f - mousePos); | |||
| if (style == TwoValueHorizontal || style == TwoValueVertical) | |||
| { | |||
| @@ -1187,9 +1187,9 @@ void Slider::modifierKeysChanged (const ModifierKeys& modifiers) | |||
| static double smallestAngleBetween (double a1, double a2) | |||
| { | |||
| return jmin (fabs (a1 - a2), | |||
| fabs (a1 + double_Pi * 2.0 - a2), | |||
| fabs (a2 + double_Pi * 2.0 - a1)); | |||
| 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) | |||
| @@ -1205,13 +1205,13 @@ void Slider::mouseDrag (const MouseEvent& e) | |||
| if (dx * dx + dy * dy > 25) | |||
| { | |||
| double angle = atan2 ((double) dx, (double) -dy); | |||
| double angle = std::atan2 ((double) dx, (double) -dy); | |||
| while (angle < 0.0) | |||
| angle += double_Pi * 2.0; | |||
| if (rotaryStop && ! e.mouseWasClicked()) | |||
| { | |||
| if (fabs (angle - lastAngle) > double_Pi) | |||
| if (std::abs (angle - lastAngle) > double_Pi) | |||
| { | |||
| if (angle >= lastAngle) | |||
| angle -= double_Pi * 2.0; | |||
| @@ -1314,7 +1314,7 @@ void Slider::mouseDrag (const MouseEvent& e) | |||
| if (speed != 0) | |||
| { | |||
| speed = 0.2 * velocityModeSensitivity | |||
| * (1.0 + sin (double_Pi * (1.5 + jmin (0.5, velocityModeOffset | |||
| * (1.0 + std::sin (double_Pi * (1.5 + jmin (0.5, velocityModeOffset | |||
| + jmax (0.0, (double) (speed - velocityModeThreshold)) | |||
| / maxSpeed)))); | |||
| @@ -1401,7 +1401,7 @@ void Slider::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float w | |||
| const double newValue = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta)); | |||
| double delta = (newValue != value) | |||
| ? jmax (fabs (newValue - value), interval) : 0; | |||
| ? jmax (std::abs (newValue - value), interval) : 0; | |||
| if (value > newValue) | |||
| delta = -delta; | |||
| @@ -357,7 +357,7 @@ void TableHeaderComponent::resizeColumnsToFit (int firstColumnIndex, int targetT | |||
| if (ci->isVisible()) | |||
| { | |||
| const int newWidth = jlimit (ci->minimumWidth, ci->maximumWidth, | |||
| (int) floor (sor.getItemSize (visIndex++))); | |||
| (int) std::floor (sor.getItemSize (visIndex++))); | |||
| if (newWidth != ci->width) | |||
| { | |||
| @@ -246,8 +246,8 @@ void ComponentBoundsConstrainer::checkBounds (Rectangle<int>& bounds, | |||
| } | |||
| else | |||
| { | |||
| const double oldRatio = (old.getHeight() > 0) ? fabs (old.getWidth() / (double) old.getHeight()) : 0.0; | |||
| const double newRatio = fabs (w / (double) h); | |||
| const double oldRatio = (old.getHeight() > 0) ? std::abs (old.getWidth() / (double) old.getHeight()) : 0.0; | |||
| const double newRatio = std::abs (w / (double) h); | |||
| adjustWidth = (oldRatio > newRatio); | |||
| } | |||
| @@ -253,9 +253,15 @@ void Viewport::setSingleStepSizes (const int stepX, const int stepY) | |||
| void Viewport::setScrollBarsShown (const bool showVerticalScrollbarIfNeeded, | |||
| const bool showHorizontalScrollbarIfNeeded) | |||
| { | |||
| showVScrollbar = showVerticalScrollbarIfNeeded; | |||
| showHScrollbar = showHorizontalScrollbarIfNeeded; | |||
| updateVisibleRegion(); | |||
| if (showVScrollbar != showVerticalScrollbarIfNeeded | |||
| || showHScrollbar != showHorizontalScrollbarIfNeeded) | |||
| { | |||
| showVScrollbar = showVerticalScrollbarIfNeeded; | |||
| showHScrollbar = showHorizontalScrollbarIfNeeded; | |||
| horizontalScrollBar->setVisible (true); | |||
| verticalScrollBar->setVisible (true); | |||
| updateVisibleRegion(); | |||
| } | |||
| } | |||
| void Viewport::setScrollBarThickness (const int thickness) | |||
| @@ -368,7 +368,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription, | |||
| for (int x = dragImage->getWidth(); --x >= 0;) | |||
| { | |||
| const int dx = x - clipped.getX(); | |||
| const int distance = roundToInt (sqrt (dx * dx + dy)); | |||
| const int distance = roundToInt (std::sqrt (dx * dx + dy)); | |||
| if (distance > lo) | |||
| { | |||
| @@ -57,7 +57,7 @@ public: | |||
| { | |||
| const float newLevel = (float) manager->getCurrentInputLevel(); | |||
| if (fabsf (level - newLevel) > 0.005f) | |||
| if (std::abs (level - newLevel) > 0.005f) | |||
| { | |||
| level = newLevel; | |||
| repaint(); | |||
| @@ -283,7 +283,7 @@ public: | |||
| setFont (font); | |||
| setText (message, false); | |||
| bestWidth = 2 * (int) sqrt (font.getHeight() * font.getStringWidth (message)); | |||
| bestWidth = 2 * (int) std::sqrt (font.getHeight() * font.getStringWidth (message)); | |||
| setColour (TextEditor::backgroundColourId, Colours::transparentBlack); | |||
| setColour (TextEditor::outlineColourId, Colours::transparentBlack); | |||
| @@ -421,7 +421,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) | |||
| const int wid = jmax (font.getStringWidth (text), | |||
| font.getStringWidth (getName())); | |||
| const int sw = (int) sqrt (font.getHeight() * wid); | |||
| const int sw = (int) std::sqrt (font.getHeight() * wid); | |||
| int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f)); | |||
| const int edgeGap = 10; | |||
| const int labelHeight = 18; | |||
| @@ -55,8 +55,8 @@ namespace ColourHelpers | |||
| { | |||
| s = jmin (1.0f, s); | |||
| h = jlimit (0.0f, 1.0f, h); | |||
| h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors | |||
| const float f = h - floorf (h); | |||
| h = (h - std::floor (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors | |||
| const float f = h - std::floor (h); | |||
| const uint8 x = (uint8) roundToInt (v * (1.0f - s)); | |||
| const float y = v * (1.0f - s * f); | |||
| @@ -405,7 +405,7 @@ const Colour Colour::withRotatedHue (const float amountToRotate) const throw() | |||
| getHSB (h, s, b); | |||
| h += amountToRotate; | |||
| h -= floorf (h); | |||
| h -= std::floor (h); | |||
| return Colour (h, s, b, getAlpha()); | |||
| } | |||
| @@ -511,8 +511,8 @@ const Colour Colour::contrasting (const Colour& colour1, | |||
| for (float i = 0.0f; i < 1.0f; i += 0.02f) | |||
| { | |||
| const float d1 = fabsf (i - b1); | |||
| const float d2 = fabsf (i - b2); | |||
| const float d1 = std::abs (i - b1); | |||
| const float d2 = std::abs (i - b2); | |||
| const float dist = jmin (d1, d2, 1.0f - d1, 1.0f - d2); | |||
| if (dist > bestDist) | |||
| @@ -1,211 +1,211 @@ | |||
| /* | |||
| ============================================================================== | |||
| This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||
| Copyright 2004-10 by Raw Material Software Ltd. | |||
| ------------------------------------------------------------------------------ | |||
| JUCE can be redistributed and/or modified under the terms of the GNU General | |||
| Public License (Version 2), as published by the Free Software Foundation. | |||
| A copy of the license is included in the JUCE distribution, or can be found | |||
| online at www.gnu.org/licenses. | |||
| JUCE is distributed in the hope that it will be useful, but WITHOUT ANY | |||
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |||
| A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |||
| ------------------------------------------------------------------------------ | |||
| To release a closed-source product which uses JUCE, commercial licenses are | |||
| available: visit www.rawmaterialsoftware.com/juce for more information. | |||
| ============================================================================== | |||
| */ | |||
| #ifndef __JUCE_EDGETABLE_JUCEHEADER__ | |||
| #define __JUCE_EDGETABLE_JUCEHEADER__ | |||
| #include "../geometry/juce_AffineTransform.h" | |||
| #include "../geometry/juce_Rectangle.h" | |||
| #include "../../../containers/juce_MemoryBlock.h" | |||
| class Path; | |||
| class RectangleList; | |||
| class Image; | |||
| //============================================================================== | |||
| /** | |||
| A table of horizontal scan-line segments - used for rasterising Paths. | |||
| @see Path, Graphics | |||
| */ | |||
| class JUCE_API EdgeTable | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Creates an edge table containing a path. | |||
| A table is created with a fixed vertical range, and only sections of the path | |||
| which lie within this range will be added to the table. | |||
| @param clipLimits only the region of the path that lies within this area will be added | |||
| @param pathToAdd the path to add to the table | |||
| @param transform a transform to apply to the path being added | |||
| */ | |||
| EdgeTable (const Rectangle<int>& clipLimits, | |||
| const Path& pathToAdd, | |||
| const AffineTransform& transform); | |||
| /** Creates an edge table containing a rectangle. | |||
| */ | |||
| EdgeTable (const Rectangle<int>& rectangleToAdd); | |||
| /** Creates an edge table containing a rectangle list. | |||
| */ | |||
| EdgeTable (const RectangleList& rectanglesToAdd); | |||
| /** Creates an edge table containing a rectangle. | |||
| */ | |||
| EdgeTable (float x, float y, float w, float h); | |||
| /** Creates a copy of another edge table. */ | |||
| EdgeTable (const EdgeTable& other); | |||
| /** Copies from another edge table. */ | |||
| EdgeTable& operator= (const EdgeTable& other); | |||
| /** Destructor. */ | |||
| ~EdgeTable(); | |||
| //============================================================================== | |||
| void clipToRectangle (const Rectangle<int>& r) throw(); | |||
| void excludeRectangle (const Rectangle<int>& r) throw(); | |||
| void clipToEdgeTable (const EdgeTable& other); | |||
| void clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels) throw(); | |||
| bool isEmpty() throw(); | |||
| const Rectangle<int>& getMaximumBounds() const throw() { return bounds; } | |||
| void translate (float dx, int dy) throw(); | |||
| /** Reduces the amount of space the table has allocated. | |||
| This will shrink the table down to use as little memory as possible - useful for | |||
| read-only tables that get stored and re-used for rendering. | |||
| */ | |||
| void optimiseTable() throw(); | |||
| //============================================================================== | |||
| /** Iterates the lines in the table, for rendering. | |||
| This function will iterate each line in the table, and call a user-defined class | |||
| to render each pixel or continuous line of pixels that the table contains. | |||
| @param iterationCallback this templated class must contain the following methods: | |||
| @code | |||
| inline void setEdgeTableYPos (int y); | |||
| inline void handleEdgeTablePixel (int x, int alphaLevel) const; | |||
| inline void handleEdgeTableLine (int x, int width, int alphaLevel) const; | |||
| @endcode | |||
| (these don't necessarily have to be 'const', but it might help it go faster) | |||
| */ | |||
| template <class EdgeTableIterationCallback> | |||
| void iterate (EdgeTableIterationCallback& iterationCallback) const throw() | |||
| { | |||
| const int* lineStart = table; | |||
| for (int y = 0; y < bounds.getHeight(); ++y) | |||
| { | |||
| const int* line = lineStart; | |||
| lineStart += lineStrideElements; | |||
| int numPoints = line[0]; | |||
| if (--numPoints > 0) | |||
| { | |||
| int x = *++line; | |||
| jassert ((x >> 8) >= bounds.getX() && (x >> 8) < bounds.getRight()); | |||
| int levelAccumulator = 0; | |||
| iterationCallback.setEdgeTableYPos (bounds.getY() + y); | |||
| while (--numPoints >= 0) | |||
| { | |||
| const int level = *++line; | |||
| jassert (((unsigned int) level) < (unsigned int) 256); | |||
| const int endX = *++line; | |||
| jassert (endX >= x); | |||
| const int endOfRun = (endX >> 8); | |||
| if (endOfRun == (x >> 8)) | |||
| { | |||
| // small segment within the same pixel, so just save it for the next | |||
| // time round.. | |||
| levelAccumulator += (endX - x) * level; | |||
| } | |||
| else | |||
| { | |||
| // plot the fist pixel of this segment, including any accumulated | |||
| // levels from smaller segments that haven't been drawn yet | |||
| levelAccumulator += (0xff - (x & 0xff)) * level; | |||
| levelAccumulator >>= 8; | |||
| x >>= 8; | |||
| if (levelAccumulator > 0) | |||
| { | |||
| if (levelAccumulator >> 8) | |||
| levelAccumulator = 0xff; | |||
| iterationCallback.handleEdgeTablePixel (x, levelAccumulator); | |||
| } | |||
| // if there's a run of similar pixels, do it all in one go.. | |||
| if (level > 0) | |||
| { | |||
| jassert (endOfRun <= bounds.getRight()); | |||
| const int numPix = endOfRun - ++x; | |||
| if (numPix > 0) | |||
| iterationCallback.handleEdgeTableLine (x, numPix, level); | |||
| } | |||
| // save the bit at the end to be drawn next time round the loop. | |||
| levelAccumulator = (endX & 0xff) * level; | |||
| } | |||
| x = endX; | |||
| } | |||
| if (levelAccumulator > 0) | |||
| { | |||
| levelAccumulator >>= 8; | |||
| if (levelAccumulator >> 8) | |||
| levelAccumulator = 0xff; | |||
| x >>= 8; | |||
| jassert (x >= bounds.getX() && x < bounds.getRight()); | |||
| iterationCallback.handleEdgeTablePixel (x, levelAccumulator); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| // table line format: number of points; point0 x, point0 levelDelta, point1 x, point1 levelDelta, etc | |||
| HeapBlock<int> table; | |||
| Rectangle<int> bounds; | |||
| int maxEdgesPerLine, lineStrideElements; | |||
| bool needToCheckEmptinesss; | |||
| void addEdgePoint (int x, int y, int winding) throw(); | |||
| void remapTableForNumEdges (int newNumEdgesPerLine) throw(); | |||
| void intersectWithEdgeTableLine (int y, const int* otherLine) throw(); | |||
| void clipEdgeTableLineToRange (int* line, int x1, int x2) throw(); | |||
| void sanitiseLevels (bool useNonZeroWinding) throw(); | |||
| static void copyEdgeTableData (int* dest, int destLineStride, const int* src, int srcLineStride, int numLines) throw(); | |||
| }; | |||
| #endif // __JUCE_EDGETABLE_JUCEHEADER__ | |||
| /* | |||
| ============================================================================== | |||
| This file is part of the JUCE library - "Jules' Utility Class Extensions" | |||
| Copyright 2004-10 by Raw Material Software Ltd. | |||
| ------------------------------------------------------------------------------ | |||
| JUCE can be redistributed and/or modified under the terms of the GNU General | |||
| Public License (Version 2), as published by the Free Software Foundation. | |||
| A copy of the license is included in the JUCE distribution, or can be found | |||
| online at www.gnu.org/licenses. | |||
| JUCE is distributed in the hope that it will be useful, but WITHOUT ANY | |||
| WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |||
| A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |||
| ------------------------------------------------------------------------------ | |||
| To release a closed-source product which uses JUCE, commercial licenses are | |||
| available: visit www.rawmaterialsoftware.com/juce for more information. | |||
| ============================================================================== | |||
| */ | |||
| #ifndef __JUCE_EDGETABLE_JUCEHEADER__ | |||
| #define __JUCE_EDGETABLE_JUCEHEADER__ | |||
| #include "../geometry/juce_AffineTransform.h" | |||
| #include "../geometry/juce_Rectangle.h" | |||
| #include "../geometry/juce_RectangleList.h" | |||
| #include "../../../containers/juce_MemoryBlock.h" | |||
| class Path; | |||
| class Image; | |||
| //============================================================================== | |||
| /** | |||
| A table of horizontal scan-line segments - used for rasterising Paths. | |||
| @see Path, Graphics | |||
| */ | |||
| class JUCE_API EdgeTable | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Creates an edge table containing a path. | |||
| A table is created with a fixed vertical range, and only sections of the path | |||
| which lie within this range will be added to the table. | |||
| @param clipLimits only the region of the path that lies within this area will be added | |||
| @param pathToAdd the path to add to the table | |||
| @param transform a transform to apply to the path being added | |||
| */ | |||
| EdgeTable (const Rectangle<int>& clipLimits, | |||
| const Path& pathToAdd, | |||
| const AffineTransform& transform); | |||
| /** Creates an edge table containing a rectangle. | |||
| */ | |||
| EdgeTable (const Rectangle<int>& rectangleToAdd); | |||
| /** Creates an edge table containing a rectangle list. | |||
| */ | |||
| EdgeTable (const RectangleList& rectanglesToAdd); | |||
| /** Creates an edge table containing a rectangle. | |||
| */ | |||
| EdgeTable (const Rectangle<float>& rectangleToAdd); | |||
| /** Creates a copy of another edge table. */ | |||
| EdgeTable (const EdgeTable& other); | |||
| /** Copies from another edge table. */ | |||
| EdgeTable& operator= (const EdgeTable& other); | |||
| /** Destructor. */ | |||
| ~EdgeTable(); | |||
| //============================================================================== | |||
| void clipToRectangle (const Rectangle<int>& r) throw(); | |||
| void excludeRectangle (const Rectangle<int>& r) throw(); | |||
| void clipToEdgeTable (const EdgeTable& other); | |||
| void clipLineToMask (int x, int y, const uint8* mask, int maskStride, int numPixels) throw(); | |||
| bool isEmpty() throw(); | |||
| const Rectangle<int>& getMaximumBounds() const throw() { return bounds; } | |||
| void translate (float dx, int dy) throw(); | |||
| /** Reduces the amount of space the table has allocated. | |||
| This will shrink the table down to use as little memory as possible - useful for | |||
| read-only tables that get stored and re-used for rendering. | |||
| */ | |||
| void optimiseTable() throw(); | |||
| //============================================================================== | |||
| /** Iterates the lines in the table, for rendering. | |||
| This function will iterate each line in the table, and call a user-defined class | |||
| to render each pixel or continuous line of pixels that the table contains. | |||
| @param iterationCallback this templated class must contain the following methods: | |||
| @code | |||
| inline void setEdgeTableYPos (int y); | |||
| inline void handleEdgeTablePixel (int x, int alphaLevel) const; | |||
| inline void handleEdgeTableLine (int x, int width, int alphaLevel) const; | |||
| @endcode | |||
| (these don't necessarily have to be 'const', but it might help it go faster) | |||
| */ | |||
| template <class EdgeTableIterationCallback> | |||
| void iterate (EdgeTableIterationCallback& iterationCallback) const throw() | |||
| { | |||
| const int* lineStart = table; | |||
| for (int y = 0; y < bounds.getHeight(); ++y) | |||
| { | |||
| const int* line = lineStart; | |||
| lineStart += lineStrideElements; | |||
| int numPoints = line[0]; | |||
| if (--numPoints > 0) | |||
| { | |||
| int x = *++line; | |||
| jassert ((x >> 8) >= bounds.getX() && (x >> 8) < bounds.getRight()); | |||
| int levelAccumulator = 0; | |||
| iterationCallback.setEdgeTableYPos (bounds.getY() + y); | |||
| while (--numPoints >= 0) | |||
| { | |||
| const int level = *++line; | |||
| jassert (((unsigned int) level) < (unsigned int) 256); | |||
| const int endX = *++line; | |||
| jassert (endX >= x); | |||
| const int endOfRun = (endX >> 8); | |||
| if (endOfRun == (x >> 8)) | |||
| { | |||
| // small segment within the same pixel, so just save it for the next | |||
| // time round.. | |||
| levelAccumulator += (endX - x) * level; | |||
| } | |||
| else | |||
| { | |||
| // plot the fist pixel of this segment, including any accumulated | |||
| // levels from smaller segments that haven't been drawn yet | |||
| levelAccumulator += (0xff - (x & 0xff)) * level; | |||
| levelAccumulator >>= 8; | |||
| x >>= 8; | |||
| if (levelAccumulator > 0) | |||
| { | |||
| if (levelAccumulator >> 8) | |||
| levelAccumulator = 0xff; | |||
| iterationCallback.handleEdgeTablePixel (x, levelAccumulator); | |||
| } | |||
| // if there's a run of similar pixels, do it all in one go.. | |||
| if (level > 0) | |||
| { | |||
| jassert (endOfRun <= bounds.getRight()); | |||
| const int numPix = endOfRun - ++x; | |||
| if (numPix > 0) | |||
| iterationCallback.handleEdgeTableLine (x, numPix, level); | |||
| } | |||
| // save the bit at the end to be drawn next time round the loop. | |||
| levelAccumulator = (endX & 0xff) * level; | |||
| } | |||
| x = endX; | |||
| } | |||
| if (levelAccumulator > 0) | |||
| { | |||
| levelAccumulator >>= 8; | |||
| if (levelAccumulator >> 8) | |||
| levelAccumulator = 0xff; | |||
| x >>= 8; | |||
| jassert (x >= bounds.getX() && x < bounds.getRight()); | |||
| iterationCallback.handleEdgeTablePixel (x, levelAccumulator); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| // table line format: number of points; point0 x, point0 levelDelta, point1 x, point1 levelDelta, etc | |||
| HeapBlock<int> table; | |||
| Rectangle<int> bounds; | |||
| int maxEdgesPerLine, lineStrideElements; | |||
| bool needToCheckEmptinesss; | |||
| void addEdgePoint (int x, int y, int winding) throw(); | |||
| void remapTableForNumEdges (int newNumEdgesPerLine) throw(); | |||
| void intersectWithEdgeTableLine (int y, const int* otherLine) throw(); | |||
| void clipEdgeTableLineToRange (int* line, int x1, int x2) throw(); | |||
| void sanitiseLevels (bool useNonZeroWinding) throw(); | |||
| static void copyEdgeTableData (int* dest, int destLineStride, const int* src, int srcLineStride, int numLines) throw(); | |||
| }; | |||
| #endif // __JUCE_EDGETABLE_JUCEHEADER__ | |||
| @@ -193,8 +193,8 @@ public: | |||
| p2 = l2.getPointAlongLineProportionally (l2.findNearestPointTo (p1)); | |||
| } | |||
| vertical = fabs (p1.getX() - p2.getX()) < 0.001f; | |||
| horizontal = fabs (p1.getY() - p2.getY()) < 0.001f; | |||
| vertical = std::abs (p1.getX() - p2.getX()) < 0.001f; | |||
| horizontal = std::abs (p1.getY() - p2.getY()) < 0.001f; | |||
| if (vertical) | |||
| { | |||
| @@ -257,8 +257,8 @@ public: | |||
| const float gdx = gradient.x1 - gradient.x2; | |||
| const float gdy = gradient.y1 - gradient.y2; | |||
| maxDist = gdx * gdx + gdy * gdy; | |||
| invScale = numEntries / sqrt (maxDist); | |||
| jassert (roundToInt (sqrt (maxDist) * invScale) <= numEntries); | |||
| invScale = numEntries / std::sqrt (maxDist); | |||
| jassert (roundToInt (std::sqrt (maxDist) * invScale) <= numEntries); | |||
| } | |||
| forcedinline void setY (const int y) throw() | |||
| @@ -273,7 +273,7 @@ public: | |||
| x *= x; | |||
| x += dy; | |||
| return lookupTable [x >= maxDist ? numEntries : roundToInt (sqrt (x) * invScale)]; | |||
| return lookupTable [x >= maxDist ? numEntries : roundToInt (std::sqrt (x) * invScale)]; | |||
| } | |||
| protected: | |||
| @@ -316,7 +316,7 @@ public: | |||
| if (x >= maxDist) | |||
| return lookupTable [numEntries]; | |||
| else | |||
| return lookupTable [jmin (numEntries, roundToInt (sqrt (x) * invScale))]; | |||
| return lookupTable [jmin (numEntries, roundToInt (std::sqrt (x) * invScale))]; | |||
| } | |||
| private: | |||
| @@ -888,6 +888,7 @@ private: | |||
| TransformedImageFillEdgeTableRenderer& operator= (const TransformedImageFillEdgeTableRenderer&); | |||
| }; | |||
| //============================================================================== | |||
| class LLGCSavedState | |||
| { | |||
| @@ -1475,7 +1476,10 @@ void LowLevelGraphicsSoftwareRenderer::drawVerticalLine (const int x, double top | |||
| { | |||
| if (bottom > top) | |||
| { | |||
| EdgeTable et ((float) (x + currentState->xOffset), (float) (top + currentState->yOffset), 1.0f, (float) (bottom - top)); | |||
| EdgeTable et (Rectangle<float> ((float) (x + currentState->xOffset), | |||
| (float) (top + currentState->yOffset), | |||
| 1.0f, (float) (bottom - top))); | |||
| currentState->fillEdgeTable (image, et); | |||
| } | |||
| } | |||
| @@ -1484,8 +1488,10 @@ void LowLevelGraphicsSoftwareRenderer::drawHorizontalLine (const int y, double l | |||
| { | |||
| if (right > left) | |||
| { | |||
| EdgeTable et ((float) (left + currentState->xOffset), (float) (y + currentState->yOffset), | |||
| (float) (right - left), 1.0f); | |||
| EdgeTable et (Rectangle<float> ((float) (left + currentState->xOffset), | |||
| (float) (y + currentState->yOffset), | |||
| (float) (right - left), 1.0f)); | |||
| currentState->fillEdgeTable (image, et); | |||
| } | |||
| } | |||
| @@ -1180,13 +1180,13 @@ private: | |||
| } | |||
| else if (t.startsWithIgnoreCase ("skewX")) | |||
| { | |||
| trans = AffineTransform (1.0f, tanf (numbers[0] * (float_Pi / 180.0f)), 0.0f, | |||
| trans = AffineTransform (1.0f, std::tan (numbers[0] * (float_Pi / 180.0f)), 0.0f, | |||
| 0.0f, 1.0f, 0.0f); | |||
| } | |||
| else if (t.startsWithIgnoreCase ("skewY")) | |||
| { | |||
| trans = AffineTransform (1.0f, 0.0f, 0.0f, | |||
| tanf (numbers[0] * (float_Pi / 180.0f)), 1.0f, 0.0f); | |||
| std::tan (numbers[0] * (float_Pi / 180.0f)), 1.0f, 0.0f); | |||
| } | |||
| result = trans.followedBy (result); | |||
| @@ -1222,15 +1222,15 @@ private: | |||
| if (s <= 1.0) | |||
| { | |||
| c = sqrt (jmax (0.0, ((rx2 * ry2) - (rx2 * yp2) - (ry2 * xp2)) | |||
| / (( rx2 * yp2) + (ry2 * xp2)))); | |||
| c = std::sqrt (jmax (0.0, ((rx2 * ry2) - (rx2 * yp2) - (ry2 * xp2)) | |||
| / (( rx2 * yp2) + (ry2 * xp2)))); | |||
| if (largeArc == sweep) | |||
| c = -c; | |||
| } | |||
| else | |||
| { | |||
| const double s2 = sqrt (s); | |||
| const double s2 = std::sqrt (s); | |||
| rx *= s2; | |||
| ry *= s2; | |||
| rx2 = rx * rx; | |||
| @@ -150,8 +150,8 @@ const AffineTransform AffineTransform::translation (const float dx, | |||
| const AffineTransform AffineTransform::rotated (const float rad) const throw() | |||
| { | |||
| const float cosRad = cosf (rad); | |||
| const float sinRad = sinf (rad); | |||
| const float cosRad = std::cos (rad); | |||
| const float sinRad = std::sin (rad); | |||
| return followedBy (cosRad, -sinRad, 0, | |||
| sinRad, cosRad, 0); | |||
| @@ -159,8 +159,8 @@ const AffineTransform AffineTransform::rotated (const float rad) const throw() | |||
| const AffineTransform AffineTransform::rotation (const float rad) throw() | |||
| { | |||
| const float cosRad = cosf (rad); | |||
| const float sinRad = sinf (rad); | |||
| const float cosRad = std::cos (rad); | |||
| const float sinRad = std::sin (rad); | |||
| return AffineTransform (cosRad, -sinRad, 0, | |||
| sinRad, cosRad, 0); | |||
| @@ -489,8 +489,8 @@ void Path::addCentredArc (const float centreX, const float centreY, | |||
| if (startAsNewSubPath) | |||
| { | |||
| float x = centreX + radiusX * sinf (angle); | |||
| float y = centreY - radiusY * cosf (angle); | |||
| float x = centreX + radiusX * std::sin (angle); | |||
| float y = centreY - radiusY * std::cos (angle); | |||
| if (rotationOfEllipse != 0) | |||
| rotation.transformPoint (x, y); | |||
| @@ -505,8 +505,8 @@ void Path::addCentredArc (const float centreX, const float centreY, | |||
| while (angle < toRadians) | |||
| { | |||
| float x = centreX + radiusX * sinf (angle); | |||
| float y = centreY - radiusY * cosf (angle); | |||
| float x = centreX + radiusX * std::sin (angle); | |||
| float y = centreY - radiusY * std::cos (angle); | |||
| if (rotationOfEllipse != 0) | |||
| rotation.transformPoint (x, y); | |||
| @@ -523,8 +523,8 @@ void Path::addCentredArc (const float centreX, const float centreY, | |||
| while (angle > toRadians) | |||
| { | |||
| float x = centreX + radiusX * sinf (angle); | |||
| float y = centreY - radiusY * cosf (angle); | |||
| float x = centreX + radiusX * std::sin (angle); | |||
| float y = centreY - radiusY * std::cos (angle); | |||
| if (rotationOfEllipse != 0) | |||
| rotation.transformPoint (x, y); | |||
| @@ -535,8 +535,8 @@ void Path::addCentredArc (const float centreX, const float centreY, | |||
| } | |||
| } | |||
| float x = centreX + radiusX * sinf (toRadians); | |||
| float y = centreY - radiusY * cosf (toRadians); | |||
| float x = centreX + radiusX * std::sin (toRadians); | |||
| float y = centreY - radiusY * std::cos (toRadians); | |||
| if (rotationOfEllipse != 0) | |||
| rotation.transformPoint (x, y); | |||
| @@ -556,12 +556,12 @@ void Path::addPieSegment (const float x, const float y, | |||
| const float centreX = x + hw; | |||
| const float centreY = y + hh; | |||
| startNewSubPath (centreX + hw * sinf (fromRadians), | |||
| centreY - hh * cosf (fromRadians)); | |||
| startNewSubPath (centreX + hw * std::sin (fromRadians), | |||
| centreY - hh * std::cos (fromRadians)); | |||
| addArc (x, y, width, height, fromRadians, toRadians); | |||
| if (fabs (fromRadians - toRadians) > float_Pi * 1.999f) | |||
| if (std::abs (fromRadians - toRadians) > float_Pi * 1.999f) | |||
| { | |||
| closeSubPath(); | |||
| @@ -570,8 +570,8 @@ void Path::addPieSegment (const float x, const float y, | |||
| hw *= innerCircleProportionalSize; | |||
| hh *= innerCircleProportionalSize; | |||
| startNewSubPath (centreX + hw * sinf (toRadians), | |||
| centreY - hh * cosf (toRadians)); | |||
| startNewSubPath (centreX + hw * std::sin (toRadians), | |||
| centreY - hh * std::cos (toRadians)); | |||
| addArc (centreX - hw, centreY - hh, hw * 2.0f, hh * 2.0f, | |||
| toRadians, fromRadians); | |||
| @@ -685,8 +685,8 @@ void Path::addStar (const float centreX, | |||
| { | |||
| float angle = startAngle + i * angleBetweenPoints; | |||
| const float x = centreX + outerRadius * sinf (angle); | |||
| const float y = centreY - outerRadius * cosf (angle); | |||
| const float x = centreX + outerRadius * std::sin (angle); | |||
| const float y = centreY - outerRadius * std::cos (angle); | |||
| if (i == 0) | |||
| startNewSubPath (x, y); | |||
| @@ -695,8 +695,8 @@ void Path::addStar (const float centreX, | |||
| angle += angleBetweenPoints * 0.5f; | |||
| lineTo (centreX + innerRadius * sinf (angle), | |||
| centreY - innerRadius * cosf (angle)); | |||
| lineTo (centreX + innerRadius * std::sin (angle), | |||
| centreY - innerRadius * std::cos (angle)); | |||
| } | |||
| closeSubPath(); | |||
| @@ -30,7 +30,6 @@ | |||
| #include "juce_Line.h" | |||
| #include "juce_Rectangle.h" | |||
| #include "../contexts/juce_Justification.h" | |||
| #include "../contexts/juce_EdgeTable.h" | |||
| #include "../../../containers/juce_Array.h" | |||
| #include "../../../io/streams/juce_InputStream.h" | |||
| #include "../../../io/streams/juce_OutputStream.h" | |||
| @@ -240,13 +240,13 @@ namespace PathFunctions | |||
| else | |||
| { | |||
| // curved joints | |||
| float angle1 = atan2f (x2 - midX, y2 - midY); | |||
| float angle2 = atan2f (x3 - midX, y3 - midY); | |||
| float angle1 = std::atan2 (x2 - midX, y2 - midY); | |||
| float angle2 = std::atan2 (x3 - midX, y3 - midY); | |||
| const float angleIncrement = 0.1f; | |||
| destPath.lineTo (x2, y2); | |||
| if (fabs (angle1 - angle2) > angleIncrement) | |||
| if (std::abs (angle1 - angle2) > angleIncrement) | |||
| { | |||
| if (angle2 > angle1 + float_Pi | |||
| || (angle2 < angle1 && angle2 >= angle1 - float_Pi)) | |||
| @@ -259,8 +259,8 @@ namespace PathFunctions | |||
| angle1 -= angleIncrement; | |||
| while (angle1 > angle2) | |||
| { | |||
| destPath.lineTo (midX + width * sinf (angle1), | |||
| midY + width * cosf (angle1)); | |||
| destPath.lineTo (midX + width * std::sin (angle1), | |||
| midY + width * std::cos (angle1)); | |||
| angle1 -= angleIncrement; | |||
| } | |||
| @@ -275,8 +275,8 @@ namespace PathFunctions | |||
| angle1 += angleIncrement; | |||
| while (angle1 < angle2) | |||
| { | |||
| destPath.lineTo (midX + width * sinf (angle1), | |||
| midY + width * cosf (angle1)); | |||
| destPath.lineTo (midX + width * std::sin (angle1), | |||
| midY + width * std::cos (angle1)); | |||
| angle1 += angleIncrement; | |||
| } | |||
| @@ -532,7 +532,7 @@ void PathStrokeType::createStrokedPath (Path& destPath, | |||
| if (it.closesSubPath || hypotSquared > minSegmentLength || it.isLastInSubpath()) | |||
| { | |||
| const float len = sqrtf (hypotSquared); | |||
| const float len = std::sqrt (hypotSquared); | |||
| if (len == 0) | |||
| { | |||
| @@ -121,7 +121,7 @@ public: | |||
| The return value is the number of radians clockwise from the 3 o'clock direction, | |||
| where this point is the centre and the other point is on the radius. | |||
| */ | |||
| ValueType getAngleToPoint (const Point& other) const throw() { return (ValueType) atan2 (other.x - x, other.y - y); } | |||
| ValueType getAngleToPoint (const Point& other) const throw() { return (ValueType) std::atan2 (other.x - x, other.y - y); } | |||
| /** Uses a transform to change the point's co-ordinates. | |||
| This will only compile if ValueType = float! | |||
| @@ -496,10 +496,10 @@ public: | |||
| */ | |||
| const Rectangle<int> getSmallestIntegerContainer() const throw() | |||
| { | |||
| const int x1 = (int) floorf ((float) x); | |||
| const int y1 = (int) floorf ((float) y); | |||
| const int x2 = (int) floorf ((float) (x + w + 0.9999f)); | |||
| const int y2 = (int) floorf ((float) (y + h + 0.9999f)); | |||
| const int x1 = (int) std::floor (static_cast<float> (x)); | |||
| const int y1 = (int) std::floor (static_cast<float> (y)); | |||
| const int x2 = (int) std::floor (static_cast<float> (x + w + 0.9999f)); | |||
| const int y2 = (int) std::floor (static_cast<float> (y + h + 0.9999f)); | |||
| return Rectangle<int> (x1, y1, x2 - x1, y2 - y1); | |||
| } | |||
| @@ -35,114 +35,105 @@ | |||
| extern Display* display; | |||
| extern Window juce_messageWindowHandle; | |||
| static String localClipboardContent; | |||
| static Atom atom_UTF8_STRING; | |||
| static Atom atom_CLIPBOARD; | |||
| static Atom atom_TARGETS; | |||
| //============================================================================== | |||
| static void initSelectionAtoms() | |||
| namespace ClipboardHelpers | |||
| { | |||
| static bool isInitialised = false; | |||
| if (! isInitialised) | |||
| { | |||
| atom_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False); | |||
| atom_CLIPBOARD = XInternAtom (display, "CLIPBOARD", False); | |||
| atom_TARGETS = XInternAtom (display, "TARGETS", False); | |||
| } | |||
| } | |||
| static String localClipboardContent; | |||
| static Atom atom_UTF8_STRING; | |||
| static Atom atom_CLIPBOARD; | |||
| static Atom atom_TARGETS; | |||
| //============================================================================== | |||
| // Read the content of a window property as either a locale-dependent string or an utf8 string | |||
| // works only for strings shorter than 1000000 bytes | |||
| static String juce_readWindowProperty (Window window, Atom prop, | |||
| Atom fmt, // XA_STRING or UTF8_STRING | |||
| bool deleteAfterReading) | |||
| { | |||
| String returnData; | |||
| char* clipData; | |||
| Atom actualType; | |||
| int actualFormat; | |||
| unsigned long numItems, bytesLeft; | |||
| if (XGetWindowProperty (display, window, prop, | |||
| 0L /* offset */, 1000000 /* length (max) */, False, | |||
| AnyPropertyType /* format */, | |||
| &actualType, &actualFormat, &numItems, &bytesLeft, | |||
| (unsigned char**) &clipData) == Success) | |||
| //============================================================================== | |||
| static void initSelectionAtoms() | |||
| { | |||
| if (actualType == atom_UTF8_STRING && actualFormat == 8) | |||
| static bool isInitialised = false; | |||
| if (! isInitialised) | |||
| { | |||
| returnData = String::fromUTF8 (clipData, numItems); | |||
| atom_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False); | |||
| atom_CLIPBOARD = XInternAtom (display, "CLIPBOARD", False); | |||
| atom_TARGETS = XInternAtom (display, "TARGETS", False); | |||
| } | |||
| else if (actualType == XA_STRING && actualFormat == 8) | |||
| } | |||
| //============================================================================== | |||
| // Read the content of a window property as either a locale-dependent string or an utf8 string | |||
| // works only for strings shorter than 1000000 bytes | |||
| static String readWindowProperty (Window window, Atom prop, Atom fmt) | |||
| { | |||
| String returnData; | |||
| char* clipData; | |||
| Atom actualType; | |||
| int actualFormat; | |||
| unsigned long numItems, bytesLeft; | |||
| if (XGetWindowProperty (display, window, prop, | |||
| 0L /* offset */, 1000000 /* length (max) */, False, | |||
| AnyPropertyType /* format */, | |||
| &actualType, &actualFormat, &numItems, &bytesLeft, | |||
| (unsigned char**) &clipData) == Success) | |||
| { | |||
| returnData = String (clipData, numItems); | |||
| } | |||
| if (actualType == atom_UTF8_STRING && actualFormat == 8) | |||
| returnData = String::fromUTF8 (clipData, numItems); | |||
| else if (actualType == XA_STRING && actualFormat == 8) | |||
| returnData = String (clipData, numItems); | |||
| if (clipData != 0) | |||
| XFree (clipData); | |||
| if (clipData != 0) | |||
| XFree (clipData); | |||
| jassert (bytesLeft == 0 || numItems == 1000000); | |||
| } | |||
| jassert (bytesLeft == 0 || numItems == 1000000); | |||
| } | |||
| if (deleteAfterReading) | |||
| XDeleteProperty (display, window, prop); | |||
| return returnData; | |||
| } | |||
| return returnData; | |||
| } | |||
| //============================================================================== | |||
| // Send a SelectionRequest to the window owning the selection and waits for its answer (with a timeout) */ | |||
| static bool juce_requestSelectionContent (String &selection_content, Atom selection, Atom requested_format) | |||
| { | |||
| Atom property_name = XInternAtom (display, "JUCE_SEL", false); | |||
| //============================================================================== | |||
| // Send a SelectionRequest to the window owning the selection and waits for its answer (with a timeout) */ | |||
| static bool requestSelectionContent (String& selectionContent, Atom selection, Atom requestedFormat) | |||
| { | |||
| Atom property_name = XInternAtom (display, "JUCE_SEL", false); | |||
| // The selection owner will be asked to set the JUCE_SEL property on the | |||
| // juce_messageWindowHandle with the selection content | |||
| XConvertSelection (display, selection, requested_format, property_name, | |||
| juce_messageWindowHandle, CurrentTime); | |||
| // The selection owner will be asked to set the JUCE_SEL property on the | |||
| // juce_messageWindowHandle with the selection content | |||
| XConvertSelection (display, selection, requestedFormat, property_name, | |||
| juce_messageWindowHandle, CurrentTime); | |||
| int timeoutMs = 200; // will wait at most for 200 ms | |||
| int count = 50; // will wait at most for 200 ms | |||
| do | |||
| { | |||
| XEvent event; | |||
| if (XCheckTypedWindowEvent (display, juce_messageWindowHandle, SelectionNotify, &event)) | |||
| while (--count >= 0) | |||
| { | |||
| if (event.xselection.property == property_name) | |||
| { | |||
| jassert (event.xselection.requestor == juce_messageWindowHandle); | |||
| selection_content = juce_readWindowProperty (event.xselection.requestor, | |||
| event.xselection.property, | |||
| requested_format, true); | |||
| return true; | |||
| } | |||
| else | |||
| XEvent event; | |||
| if (XCheckTypedWindowEvent (display, juce_messageWindowHandle, SelectionNotify, &event)) | |||
| { | |||
| return false; // the format we asked for was denied.. (event.xselection.property == None) | |||
| if (event.xselection.property == property_name) | |||
| { | |||
| jassert (event.xselection.requestor == juce_messageWindowHandle); | |||
| selectionContent = readWindowProperty (event.xselection.requestor, | |||
| event.xselection.property, | |||
| requestedFormat); | |||
| return true; | |||
| } | |||
| else | |||
| { | |||
| return false; // the format we asked for was denied.. (event.xselection.property == None) | |||
| } | |||
| } | |||
| // not very elegant.. we could do a select() or something like that... | |||
| // however clipboard content requesting is inherently slow on x11, it | |||
| // often takes 50ms or more so... | |||
| Thread::sleep (4); | |||
| } | |||
| // not very elegant.. we could do a select() or something like that... | |||
| // however clipboard content requesting is inherently slow on x11, it | |||
| // often takes 50ms or more so... | |||
| Thread::sleep (4); | |||
| timeoutMs -= 4; | |||
| return false; | |||
| } | |||
| while (timeoutMs > 0); | |||
| DBG("timeout for juce_requestSelectionContent"); | |||
| return false; | |||
| } | |||
| //============================================================================== | |||
| // Called from the event loop in juce_linux_Messaging in response to SelectionRequest events | |||
| void juce_handleSelectionRequest (XSelectionRequestEvent &evt) | |||
| { | |||
| initSelectionAtoms(); | |||
| ClipboardHelpers::initSelectionAtoms(); | |||
| // the selection content is sent to the target window as a window property | |||
| XSelectionEvent reply; | |||
| @@ -157,32 +148,32 @@ void juce_handleSelectionRequest (XSelectionRequestEvent &evt) | |||
| HeapBlock <char> data; | |||
| int propertyFormat = 0, numDataItems = 0; | |||
| if (evt.selection == XA_PRIMARY || evt.selection == atom_CLIPBOARD) | |||
| if (evt.selection == XA_PRIMARY || evt.selection == ClipboardHelpers::atom_CLIPBOARD) | |||
| { | |||
| if (evt.target == XA_STRING) | |||
| { | |||
| // format data according to system locale | |||
| numDataItems = localClipboardContent.getNumBytesAsCString() + 1; | |||
| numDataItems = ClipboardHelpers::localClipboardContent.getNumBytesAsCString() + 1; | |||
| data.calloc (numDataItems + 1); | |||
| localClipboardContent.copyToCString (data, numDataItems); | |||
| ClipboardHelpers::localClipboardContent.copyToCString (data, numDataItems); | |||
| propertyFormat = 8; // bits/item | |||
| } | |||
| else if (evt.target == atom_UTF8_STRING) | |||
| else if (evt.target == ClipboardHelpers::atom_UTF8_STRING) | |||
| { | |||
| // translate to utf8 | |||
| numDataItems = localClipboardContent.getNumBytesAsUTF8() + 1; | |||
| numDataItems = ClipboardHelpers::localClipboardContent.getNumBytesAsUTF8() + 1; | |||
| data.calloc (numDataItems + 1); | |||
| localClipboardContent.copyToUTF8 (data, numDataItems); | |||
| ClipboardHelpers::localClipboardContent.copyToUTF8 (data, numDataItems); | |||
| propertyFormat = 8; // bits/item | |||
| } | |||
| else if (evt.target == atom_TARGETS) | |||
| else if (evt.target == ClipboardHelpers::atom_TARGETS) | |||
| { | |||
| // another application wants to know what we are able to send | |||
| numDataItems = 2; | |||
| propertyFormat = 32; // atoms are 32-bit | |||
| data.calloc (numDataItems * 4); | |||
| Atom* atoms = reinterpret_cast<Atom*> (data.getData()); | |||
| atoms[0] = atom_UTF8_STRING; | |||
| atoms[0] = ClipboardHelpers::atom_UTF8_STRING; | |||
| atoms[1] = XA_STRING; | |||
| } | |||
| } | |||
| @@ -212,16 +203,16 @@ void juce_handleSelectionRequest (XSelectionRequestEvent &evt) | |||
| //============================================================================== | |||
| void SystemClipboard::copyTextToClipboard (const String& clipText) | |||
| { | |||
| initSelectionAtoms(); | |||
| localClipboardContent = clipText; | |||
| ClipboardHelpers::initSelectionAtoms(); | |||
| ClipboardHelpers::localClipboardContent = clipText; | |||
| XSetSelectionOwner (display, XA_PRIMARY, juce_messageWindowHandle, CurrentTime); | |||
| XSetSelectionOwner (display, atom_CLIPBOARD, juce_messageWindowHandle, CurrentTime); | |||
| XSetSelectionOwner (display, ClipboardHelpers::atom_CLIPBOARD, juce_messageWindowHandle, CurrentTime); | |||
| } | |||
| const String SystemClipboard::getTextFromClipboard() | |||
| { | |||
| initSelectionAtoms(); | |||
| ClipboardHelpers::initSelectionAtoms(); | |||
| /* 1) try to read from the "CLIPBOARD" selection first (the "high | |||
| level" clipboard that is supposed to be filled by ctrl-C | |||
| @@ -238,7 +229,7 @@ const String SystemClipboard::getTextFromClipboard() | |||
| if ((selectionOwner = XGetSelectionOwner (display, selection)) == None) | |||
| { | |||
| selection = atom_CLIPBOARD; | |||
| selection = ClipboardHelpers::atom_CLIPBOARD; | |||
| selectionOwner = XGetSelectionOwner (display, selection); | |||
| } | |||
| @@ -246,17 +237,17 @@ const String SystemClipboard::getTextFromClipboard() | |||
| { | |||
| if (selectionOwner == juce_messageWindowHandle) | |||
| { | |||
| content = localClipboardContent; | |||
| content = ClipboardHelpers::localClipboardContent; | |||
| } | |||
| else | |||
| { | |||
| // first try: we want an utf8 string | |||
| bool ok = juce_requestSelectionContent (content, selection, atom_UTF8_STRING); | |||
| bool ok = ClipboardHelpers::requestSelectionContent (content, selection, ClipboardHelpers::atom_UTF8_STRING); | |||
| if (! ok) | |||
| { | |||
| // second chance, ask for a good old locale-dependent string .. | |||
| ok = juce_requestSelectionContent (content, selection, XA_STRING); | |||
| ok = ClipboardHelpers::requestSelectionContent (content, selection, XA_STRING); | |||
| } | |||
| } | |||
| } | |||
| @@ -145,7 +145,7 @@ public: | |||
| return faces[i]; | |||
| if (! create) | |||
| return NULL; | |||
| return 0; | |||
| FreeTypeFontFace* newFace = new FreeTypeFontFace (familyName); | |||
| faces.add (newFace); | |||
| @@ -32,9 +32,8 @@ | |||
| #define JUCE_DEBUG_XERRORS 1 | |||
| #endif | |||
| Display* display = 0; // This is also referenced from WindowDriver.cpp | |||
| Display* display = 0; | |||
| Window juce_messageWindowHandle = None; | |||
| XContext windowHandleXContext; // This is referenced from Windowing.cpp | |||
| extern void juce_windowMessageReceive (XEvent* event); // Defined in Windowing.cpp | |||
| @@ -246,15 +245,15 @@ void MessageManager::doPlatformSpecificInitialisation() | |||
| saction.sa_handler = signalHandler; | |||
| saction.sa_mask = maskSet; | |||
| saction.sa_flags = 0; | |||
| sigaction (SIGINT, &saction, NULL); | |||
| sigaction (SIGINT, &saction, 0); | |||
| #ifndef _DEBUG | |||
| // Setup signal handlers for various fatal errors | |||
| sigaction (SIGILL, &saction, NULL); | |||
| sigaction (SIGBUS, &saction, NULL); | |||
| sigaction (SIGFPE, &saction, NULL); | |||
| sigaction (SIGSEGV, &saction, NULL); | |||
| sigaction (SIGSYS, &saction, NULL); | |||
| sigaction (SIGILL, &saction, 0); | |||
| sigaction (SIGBUS, &saction, 0); | |||
| sigaction (SIGFPE, &saction, 0); | |||
| sigaction (SIGSEGV, &saction, 0); | |||
| sigaction (SIGSYS, &saction, 0); | |||
| #endif | |||
| // Create the internal message queue | |||
| @@ -29,22 +29,23 @@ | |||
| //============================================================================== | |||
| void Logger::outputDebugString (const String& text) throw() | |||
| void Logger::outputDebugString (const String& text) | |||
| { | |||
| std::cerr << text << std::endl; | |||
| } | |||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() | |||
| //============================================================================== | |||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | |||
| { | |||
| return Linux; | |||
| } | |||
| const String SystemStats::getOperatingSystemName() throw() | |||
| const String SystemStats::getOperatingSystemName() | |||
| { | |||
| return "Linux"; | |||
| } | |||
| bool SystemStats::isOperatingSystem64Bit() throw() | |||
| bool SystemStats::isOperatingSystem64Bit() | |||
| { | |||
| #if JUCE_64BIT | |||
| return true; | |||
| @@ -54,84 +55,84 @@ bool SystemStats::isOperatingSystem64Bit() throw() | |||
| #endif | |||
| } | |||
| static const String getCpuInfo (const char* key, bool lastOne = false) throw() | |||
| //============================================================================== | |||
| static const String juce_getCpuInfo (const char* const key) | |||
| { | |||
| String info; | |||
| char buf [256]; | |||
| FILE* f = fopen ("/proc/cpuinfo", "r"); | |||
| StringArray lines; | |||
| lines.addLines (File ("/proc/cpuinfo").loadFileAsString()); | |||
| while (f != 0 && fgets (buf, sizeof(buf), f)) | |||
| { | |||
| if (strncmp (buf, key, strlen (key)) == 0) | |||
| { | |||
| char* p = buf; | |||
| 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(); | |||
| while (*p && *p != '\n') | |||
| ++p; | |||
| return String::empty; | |||
| } | |||
| if (*p != 0) | |||
| *p = 0; | |||
| bool SystemStats::hasMMX() { return juce_getCpuInfo ("flags").contains ("mmx"); } | |||
| bool SystemStats::hasSSE() { return juce_getCpuInfo ("flags").contains ("sse"); } | |||
| bool SystemStats::hasSSE2() { return juce_getCpuInfo ("flags").contains ("sse2"); } | |||
| bool SystemStats::has3DNow() { return juce_getCpuInfo ("flags").contains ("3dnow"); } | |||
| p = buf; | |||
| const String SystemStats::getCpuVendor() | |||
| { | |||
| return juce_getCpuInfo ("vendor_id"); | |||
| } | |||
| while (*p != 0 && *p != ':') | |||
| ++p; | |||
| int SystemStats::getCpuSpeedInMegaherz() | |||
| { | |||
| return roundToInt (juce_getCpuInfo ("cpu MHz").getFloatValue()); | |||
| } | |||
| if (*p != 0 && *(p + 1) != 0) | |||
| info = p + 2; | |||
| int SystemStats::getMemorySizeInMegabytes() | |||
| { | |||
| struct sysinfo sysi; | |||
| if (! lastOne) | |||
| break; | |||
| } | |||
| } | |||
| if (sysinfo (&sysi) == 0) | |||
| return (sysi.totalram * sysi.mem_unit / (1024 * 1024)); | |||
| fclose (f); | |||
| return info; | |||
| return 0; | |||
| } | |||
| bool SystemStats::hasMMX() throw() | |||
| int SystemStats::getPageSize() | |||
| { | |||
| return getCpuInfo ("flags").contains ("mmx"); | |||
| return sysconf (_SC_PAGESIZE); | |||
| } | |||
| bool SystemStats::hasSSE() throw() | |||
| int SystemStats::getNumCpus() | |||
| { | |||
| return getCpuInfo ("flags").contains ("sse"); | |||
| return juce_getCpuInfo ("processor").getIntValue() + 1; | |||
| } | |||
| bool SystemStats::hasSSE2() throw() | |||
| //============================================================================== | |||
| const String SystemStats::getLogonName() | |||
| { | |||
| return getCpuInfo ("flags").contains ("sse2"); | |||
| } | |||
| const char* user = getenv ("USER"); | |||
| bool SystemStats::has3DNow() throw() | |||
| { | |||
| return getCpuInfo ("flags").contains ("3dnow"); | |||
| if (user == 0) | |||
| { | |||
| struct passwd* const pw = getpwuid (getuid()); | |||
| if (pw != 0) | |||
| user = pw->pw_name; | |||
| } | |||
| return String::fromUTF8 (user); | |||
| } | |||
| const String SystemStats::getCpuVendor() throw() | |||
| const String SystemStats::getFullUserName() | |||
| { | |||
| return getCpuInfo ("vendor_id"); | |||
| return getLogonName(); | |||
| } | |||
| int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| //============================================================================== | |||
| void SystemStats::initialiseStats() | |||
| { | |||
| const String speed (getCpuInfo ("cpu MHz")); | |||
| return (int) (speed.getFloatValue() + 0.5f); | |||
| } | |||
| int SystemStats::getMemorySizeInMegabytes() throw() | |||
| void PlatformUtilities::fpuReset() | |||
| { | |||
| struct sysinfo sysi; | |||
| if (sysinfo (&sysi) == 0) | |||
| return (sysi.totalram * sysi.mem_unit / (1024 * 1024)); | |||
| return 0; | |||
| } | |||
| //============================================================================== | |||
| uint32 juce_millisecondsSinceStartup() throw() | |||
| { | |||
| static unsigned int calibrate = 0; | |||
| @@ -174,67 +175,17 @@ int64 Time::getHighResolutionTicks() throw() | |||
| int64 Time::getHighResolutionTicksPerSecond() throw() | |||
| { | |||
| // Microseconds | |||
| return 1000000; | |||
| return 1000000; // (microseconds) | |||
| } | |||
| bool Time::setSystemTimeToThisTime() const throw() | |||
| bool Time::setSystemTimeToThisTime() const | |||
| { | |||
| timeval t; | |||
| t.tv_sec = millisSinceEpoch % 1000000; | |||
| t.tv_usec = millisSinceEpoch - t.tv_sec; | |||
| return settimeofday (&t, NULL) ? false : true; | |||
| } | |||
| int SystemStats::getPageSize() throw() | |||
| { | |||
| static int systemPageSize = 0; | |||
| if (systemPageSize == 0) | |||
| systemPageSize = sysconf (_SC_PAGESIZE); | |||
| return systemPageSize; | |||
| } | |||
| int SystemStats::getNumCpus() throw() | |||
| { | |||
| const int lastCpu = getCpuInfo ("processor", true).getIntValue(); | |||
| return lastCpu + 1; | |||
| return settimeofday (&t, 0) ? false : true; | |||
| } | |||
| //============================================================================== | |||
| const String SystemStats::getLogonName() | |||
| { | |||
| const char* user = getenv ("USER"); | |||
| if (user == 0) | |||
| { | |||
| struct passwd* const pw = getpwuid (getuid()); | |||
| if (pw != 0) | |||
| user = pw->pw_name; | |||
| } | |||
| return String::fromUTF8 (user); | |||
| } | |||
| const String SystemStats::getFullUserName() | |||
| { | |||
| return getLogonName(); | |||
| } | |||
| //============================================================================== | |||
| void SystemStats::initialiseStats() throw() | |||
| { | |||
| // Process starts off as root when running suid | |||
| Process::lowerPrivilege(); | |||
| String s (SystemStats::getJUCEVersion()); | |||
| } | |||
| void PlatformUtilities::fpuReset() | |||
| { | |||
| } | |||
| #endif | |||
| @@ -37,9 +37,6 @@ void JUCE_API juce_threadEntryPoint (void*); | |||
| void* threadEntryProc (void* value) | |||
| { | |||
| // New threads start off as root when running suid | |||
| Process::lowerPrivilege(); | |||
| juce_threadEntryPoint (value); | |||
| return 0; | |||
| } | |||
| @@ -60,7 +57,7 @@ void* juce_createThread (void* userData) | |||
| void juce_killThread (void* handle) | |||
| { | |||
| if (handle != 0) | |||
| pthread_cancel ((pthread_t)handle); | |||
| pthread_cancel ((pthread_t) handle); | |||
| } | |||
| void juce_setCurrentThreadName (const String& /*name*/) | |||
| @@ -72,26 +69,25 @@ Thread::ThreadID Thread::getCurrentThreadId() | |||
| return (ThreadID) pthread_self(); | |||
| } | |||
| /* | |||
| * This is all a bit non-ideal... the trouble is that on Linux you | |||
| * need to call setpriority to affect the dynamic priority for | |||
| * non-realtime processes, but this requires the pid, which is not | |||
| * accessible from the pthread_t. We could get it by calling getpid | |||
| * once each thread has started, but then we would need a list of | |||
| * running threads etc etc. | |||
| * Also there is no such thing as IDLE priority on Linux. | |||
| * For the moment, map idle, low and normal process priorities to | |||
| * SCHED_OTHER, with the thread priority ignored for these classes. | |||
| * Map high priority processes to the lower half of the SCHED_RR | |||
| * range, and realtime to the upper half | |||
| */ | |||
| // priority 1 to 10 where 5=normal, 1=low. If the handle is 0, sets the | |||
| // priority of the current thread | |||
| /* This is all a bit non-ideal... the trouble is that on Linux you | |||
| need to call setpriority to affect the dynamic priority for | |||
| non-realtime processes, but this requires the pid, which is not | |||
| accessible from the pthread_t. We could get it by calling getpid | |||
| once each thread has started, but then we would need a list of | |||
| running threads etc etc. | |||
| Also there is no such thing as IDLE priority on Linux. | |||
| For the moment, map idle, low and normal process priorities to | |||
| SCHED_OTHER, with the thread priority ignored for these classes. | |||
| Map high priority processes to the lower half of the SCHED_RR | |||
| range, and realtime to the upper half. | |||
| priority 1 to 10 where 5=normal, 1=low. If the handle is 0, sets the | |||
| priority of the current thread | |||
| */ | |||
| bool juce_setThreadPriority (void* handle, int priority) | |||
| { | |||
| struct sched_param param; | |||
| int policy, maxp, minp, pri; | |||
| int policy; | |||
| if (handle == 0) | |||
| handle = (void*) pthread_self(); | |||
| @@ -99,20 +95,17 @@ bool juce_setThreadPriority (void* handle, int priority) | |||
| if (pthread_getschedparam ((pthread_t) handle, &policy, ¶m) == 0 | |||
| && policy != SCHED_OTHER) | |||
| { | |||
| minp = sched_get_priority_min(policy); | |||
| maxp = sched_get_priority_max(policy); | |||
| int minp = sched_get_priority_min (policy); | |||
| int maxp = sched_get_priority_max (policy); | |||
| pri = ((maxp - minp) / 2) * (priority - 1) / 9; | |||
| int pri = ((maxp - minp) / 2) * (priority - 1) / 9; | |||
| if (param.__sched_priority >= (minp + (maxp - minp) / 2)) | |||
| // Realtime process priority | |||
| param.__sched_priority = minp + ((maxp - minp) / 2) + pri; | |||
| param.__sched_priority = minp + ((maxp - minp) / 2) + pri; // (realtime) | |||
| else | |||
| // High process priority | |||
| param.__sched_priority = minp + pri; | |||
| param.__sched_priority = minp + pri; // (high) | |||
| param.sched_priority = jlimit (1, 127, 1 + (priority * 126) / 11); | |||
| return pthread_setschedparam ((pthread_t) handle, policy, ¶m) == 0; | |||
| } | |||
| @@ -28,7 +28,7 @@ | |||
| #if JUCE_INCLUDED_FILE | |||
| //============================================================================== | |||
| void Logger::outputDebugString (const String& text) throw() | |||
| void Logger::outputDebugString (const String& text) | |||
| { | |||
| std::cerr << text << std::endl; | |||
| } | |||
| @@ -117,8 +117,8 @@ public: | |||
| [nsFont retain]; | |||
| ascent = fabsf ((float) [nsFont ascender]); | |||
| float totalSize = ascent + fabsf ((float) [nsFont descender]); | |||
| ascent = std::abs ((float) [nsFont ascender]); | |||
| float totalSize = ascent + std::abs ((float) [nsFont descender]); | |||
| ascent /= totalSize; | |||
| pathTransform = AffineTransform::identity.scale (1.0f / totalSize, 1.0f / totalSize); | |||
| @@ -137,7 +137,7 @@ public: | |||
| fontRef = CGFontCreateWithPlatformFont (&atsFont); | |||
| const float totalHeight = fabsf ([nsFont ascender]) + fabsf([nsFont descender]); | |||
| const float totalHeight = std::abs ([nsFont ascender]) + std::abs ([nsFont descender]); | |||
| unitsToHeightScaleFactor = 1.0f / totalHeight; | |||
| fontHeightToCGSizeFactor = 1024.0f / totalHeight; | |||
| #else | |||
| @@ -151,7 +151,7 @@ public: | |||
| fontRef = CGFontCreateWithPlatformFont (&atsFont); | |||
| const float totalHeight = fabsf ([nsFont ascender]) + fabsf([nsFont descender]); | |||
| const float totalHeight = std::abs ([nsFont ascender]) + std::abs ([nsFont descender]); | |||
| unitsToHeightScaleFactor = 1.0f / totalHeight; | |||
| fontHeightToCGSizeFactor = 1024.0f / totalHeight; | |||
| } | |||
| @@ -79,7 +79,7 @@ namespace SystemStatsHelpers | |||
| } | |||
| //============================================================================== | |||
| void SystemStats::initialiseStats() throw() | |||
| void SystemStats::initialiseStats() | |||
| { | |||
| using namespace SystemStatsHelpers; | |||
| static bool initialised = false; | |||
| @@ -123,17 +123,17 @@ void SystemStats::initialiseStats() throw() | |||
| } | |||
| //============================================================================== | |||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() | |||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | |||
| { | |||
| return MacOSX; | |||
| } | |||
| const String SystemStats::getOperatingSystemName() throw() | |||
| const String SystemStats::getOperatingSystemName() | |||
| { | |||
| return "Mac OS X"; | |||
| } | |||
| bool SystemStats::isOperatingSystem64Bit() throw() | |||
| bool SystemStats::isOperatingSystem64Bit() | |||
| { | |||
| #if JUCE_64BIT | |||
| return true; | |||
| @@ -143,7 +143,7 @@ bool SystemStats::isOperatingSystem64Bit() throw() | |||
| #endif | |||
| } | |||
| int SystemStats::getMemorySizeInMegabytes() throw() | |||
| int SystemStats::getMemorySizeInMegabytes() | |||
| { | |||
| uint64 mem = 0; | |||
| size_t memSize = sizeof (mem); | |||
| @@ -152,7 +152,7 @@ int SystemStats::getMemorySizeInMegabytes() throw() | |||
| return (int) (mem / (1024 * 1024)); | |||
| } | |||
| bool SystemStats::hasMMX() throw() | |||
| bool SystemStats::hasMMX() | |||
| { | |||
| #if JUCE_INTEL | |||
| return SystemStatsHelpers::cpuFlags.hasMMX; | |||
| @@ -161,7 +161,7 @@ bool SystemStats::hasMMX() throw() | |||
| #endif | |||
| } | |||
| bool SystemStats::hasSSE() throw() | |||
| bool SystemStats::hasSSE() | |||
| { | |||
| #if JUCE_INTEL | |||
| return SystemStatsHelpers::cpuFlags.hasSSE; | |||
| @@ -170,7 +170,7 @@ bool SystemStats::hasSSE() throw() | |||
| #endif | |||
| } | |||
| bool SystemStats::hasSSE2() throw() | |||
| bool SystemStats::hasSSE2() | |||
| { | |||
| #if JUCE_INTEL | |||
| return SystemStatsHelpers::cpuFlags.hasSSE2; | |||
| @@ -179,7 +179,7 @@ bool SystemStats::hasSSE2() throw() | |||
| #endif | |||
| } | |||
| bool SystemStats::has3DNow() throw() | |||
| bool SystemStats::has3DNow() | |||
| { | |||
| #if JUCE_INTEL | |||
| return SystemStatsHelpers::cpuFlags.has3DNow; | |||
| @@ -188,7 +188,7 @@ bool SystemStats::has3DNow() throw() | |||
| #endif | |||
| } | |||
| const String SystemStats::getCpuVendor() throw() | |||
| const String SystemStats::getCpuVendor() | |||
| { | |||
| #if JUCE_INTEL | |||
| char v [16]; | |||
| @@ -199,7 +199,7 @@ const String SystemStats::getCpuVendor() throw() | |||
| #endif | |||
| } | |||
| int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| int SystemStats::getCpuSpeedInMegaherz() | |||
| { | |||
| uint64 speedHz = 0; | |||
| size_t speedSize = sizeof (speedHz); | |||
| @@ -213,7 +213,7 @@ int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| return (int) (speedHz / 1000000); | |||
| } | |||
| int SystemStats::getNumCpus() throw() | |||
| int SystemStats::getNumCpus() | |||
| { | |||
| #if JUCE_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) | |||
| return (int) [[NSProcessInfo processInfo] activeProcessorCount]; | |||
| @@ -254,19 +254,14 @@ int64 Time::getHighResolutionTicksPerSecond() throw() | |||
| return SystemStatsHelpers::highResTimerFrequency; | |||
| } | |||
| int64 SystemStats::getClockCycleCounter() throw() | |||
| { | |||
| return (int64) mach_absolute_time(); | |||
| } | |||
| bool Time::setSystemTimeToThisTime() const throw() | |||
| bool Time::setSystemTimeToThisTime() const | |||
| { | |||
| jassertfalse | |||
| return false; | |||
| } | |||
| //============================================================================== | |||
| int SystemStats::getPageSize() throw() | |||
| int SystemStats::getPageSize() | |||
| { | |||
| return (int) NSPageSize(); | |||
| } | |||
| @@ -31,7 +31,7 @@ extern void juce_initialiseThreadEvents(); | |||
| //============================================================================== | |||
| void Logger::outputDebugString (const String& text) throw() | |||
| void Logger::outputDebugString (const String& text) | |||
| { | |||
| OutputDebugString (text + "\n"); | |||
| } | |||
| @@ -49,7 +49,7 @@ static double hiResTicksScaleFactor; | |||
| #pragma intrinsic (__cpuid) | |||
| #pragma intrinsic (__rdtsc) | |||
| const String SystemStats::getCpuVendor() throw() | |||
| const String SystemStats::getCpuVendor() | |||
| { | |||
| int info [4]; | |||
| __cpuid (info, 0); | |||
| @@ -103,7 +103,7 @@ static void juce_getCpuVendor (char* const v) | |||
| memcpy (v, vendor, 16); | |||
| } | |||
| const String SystemStats::getCpuVendor() throw() | |||
| const String SystemStats::getCpuVendor() | |||
| { | |||
| char v [16]; | |||
| juce_getCpuVendor (v); | |||
| @@ -123,27 +123,27 @@ struct CPUFlags | |||
| static CPUFlags cpuFlags; | |||
| bool SystemStats::hasMMX() throw() | |||
| bool SystemStats::hasMMX() | |||
| { | |||
| return cpuFlags.hasMMX; | |||
| } | |||
| bool SystemStats::hasSSE() throw() | |||
| bool SystemStats::hasSSE() | |||
| { | |||
| return cpuFlags.hasSSE; | |||
| } | |||
| bool SystemStats::hasSSE2() throw() | |||
| bool SystemStats::hasSSE2() | |||
| { | |||
| return cpuFlags.hasSSE2; | |||
| } | |||
| bool SystemStats::has3DNow() throw() | |||
| bool SystemStats::has3DNow() | |||
| { | |||
| return cpuFlags.has3DNow; | |||
| } | |||
| void SystemStats::initialiseStats() throw() | |||
| void SystemStats::initialiseStats() | |||
| { | |||
| juce_initialiseThreadEvents(); | |||
| @@ -176,7 +176,7 @@ void SystemStats::initialiseStats() throw() | |||
| } | |||
| //============================================================================== | |||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() | |||
| SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() | |||
| { | |||
| OSVERSIONINFO info; | |||
| info.dwOSVersionInfoSize = sizeof (info); | |||
| @@ -200,7 +200,7 @@ SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() throw() | |||
| return UnknownOS; | |||
| } | |||
| const String SystemStats::getOperatingSystemName() throw() | |||
| const String SystemStats::getOperatingSystemName() | |||
| { | |||
| const char* name = "Unknown OS"; | |||
| @@ -217,7 +217,7 @@ const String SystemStats::getOperatingSystemName() throw() | |||
| return name; | |||
| } | |||
| bool SystemStats::isOperatingSystem64Bit() throw() | |||
| bool SystemStats::isOperatingSystem64Bit() | |||
| { | |||
| #ifdef _WIN64 | |||
| return true; | |||
| @@ -236,7 +236,7 @@ bool SystemStats::isOperatingSystem64Bit() throw() | |||
| //============================================================================== | |||
| int SystemStats::getMemorySizeInMegabytes() throw() | |||
| int SystemStats::getMemorySizeInMegabytes() | |||
| { | |||
| MEMORYSTATUSEX mem; | |||
| mem.dwLength = sizeof (mem); | |||
| @@ -244,7 +244,7 @@ int SystemStats::getMemorySizeInMegabytes() throw() | |||
| return (int) (mem.ullTotalPhys / (1024 * 1024)) + 1; | |||
| } | |||
| int SystemStats::getNumCpus() throw() | |||
| int SystemStats::getNumCpus() | |||
| { | |||
| SYSTEM_INFO systemInfo; | |||
| GetSystemInfo (&systemInfo); | |||
| @@ -287,7 +287,7 @@ int64 Time::getHighResolutionTicksPerSecond() throw() | |||
| return hiResTicksPerSecond; | |||
| } | |||
| int64 SystemStats::getClockCycleCounter() throw() | |||
| static int64 juce_getClockCycleCounter() throw() | |||
| { | |||
| #if JUCE_USE_INTRINSICS | |||
| // MS intrinsics version... | |||
| @@ -326,9 +326,9 @@ int64 SystemStats::getClockCycleCounter() throw() | |||
| #endif | |||
| } | |||
| int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| int SystemStats::getCpuSpeedInMegaherz() | |||
| { | |||
| const int64 cycles = SystemStats::getClockCycleCounter(); | |||
| const int64 cycles = juce_getClockCycleCounter(); | |||
| const uint32 millis = Time::getMillisecondCounter(); | |||
| int lastResult = 0; | |||
| @@ -338,7 +338,7 @@ int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| while (--n > 0) {} | |||
| const uint32 millisElapsed = Time::getMillisecondCounter() - millis; | |||
| const int64 cyclesNow = SystemStats::getClockCycleCounter(); | |||
| const int64 cyclesNow = juce_getClockCycleCounter(); | |||
| if (millisElapsed > 80) | |||
| { | |||
| @@ -354,7 +354,7 @@ int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| //============================================================================== | |||
| bool Time::setSystemTimeToThisTime() const throw() | |||
| bool Time::setSystemTimeToThisTime() const | |||
| { | |||
| SYSTEMTIME st; | |||
| @@ -373,7 +373,7 @@ bool Time::setSystemTimeToThisTime() const throw() | |||
| && SetLocalTime (&st) != 0; | |||
| } | |||
| int SystemStats::getPageSize() throw() | |||
| int SystemStats::getPageSize() | |||
| { | |||
| SYSTEM_INFO systemInfo; | |||
| GetSystemInfo (&systemInfo); | |||
| @@ -367,7 +367,7 @@ namespace NumberToStringConverters | |||
| { | |||
| juce_wchar* const end = buffer + numChars; | |||
| juce_wchar* t = end; | |||
| int64 v = (int64) (pow (10.0, numDecPlaces) * fabs (n) + 0.5); | |||
| int64 v = (int64) (pow (10.0, numDecPlaces) * std::abs (n) + 0.5); | |||
| *--t = (juce_wchar) 0; | |||
| while (numDecPlaces >= 0 || v > 0) | |||