diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 183cd5ecb4..dcb488a752 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -4374,14 +4374,14 @@ MD5& MD5::operator= (const MD5& other) MD5::MD5 (const MemoryBlock& data) { ProcessContext context; - context.processBlock ((const uint8*) data.getData(), data.getSize()); + context.processBlock (data.getData(), data.getSize()); context.finish (result); } -MD5::MD5 (const char* data, const size_t numBytes) +MD5::MD5 (const void* data, const size_t numBytes) { ProcessContext context; - context.processBlock ((const uint8*) data, numBytes); + context.processBlock (data, numBytes); context.finish (result); } @@ -4396,11 +4396,9 @@ MD5::MD5 (const String& text) { // force the string into integer-sized unicode characters, to try to make it // get the same results on all platforms + compilers. - uint32 unicodeChar = (uint32) t[i]; - ByteOrder::swapIfBigEndian (unicodeChar); + uint32 unicodeChar = ByteOrder::swapIfBigEndian ((uint32) t[i]); - context.processBlock ((const uint8*) &unicodeChar, - sizeof (unicodeChar)); + context.processBlock (&unicodeChar, sizeof (unicodeChar)); } context.finish (result); @@ -4415,7 +4413,7 @@ void MD5::processStream (InputStream& input, int64 numBytesToRead) while (numBytesToRead > 0) { - char tempBuffer [512]; + uint8 tempBuffer [512]; const int bytesRead = input.read (tempBuffer, (int) jmin (numBytesToRead, (int64) sizeof (tempBuffer))); if (bytesRead <= 0) @@ -4423,7 +4421,7 @@ void MD5::processStream (InputStream& input, int64 numBytesToRead) numBytesToRead -= bytesRead; - context.processBlock ((const uint8*) tempBuffer, bytesRead); + context.processBlock (tempBuffer, bytesRead); } context.finish (result); @@ -4450,18 +4448,10 @@ MD5::~MD5() namespace MD5Functions { - static void encode (uint8* const output, const uint32* const input, const int numBytes) throw() - { - uint32* const o = (uint32*) output; - - for (int i = 0; i < (numBytes >> 2); ++i) - o[i] = ByteOrder::swapIfBigEndian (input [i]); - } - - static void decode (uint32* const output, const uint8* const input, const int numBytes) throw() + static void encode (void* const output, const void* const input, const int numBytes) throw() { for (int i = 0; i < (numBytes >> 2); ++i) - output[i] = ByteOrder::littleEndianInt ((const char*) input + (i << 2)); + static_cast (output)[i] = ByteOrder::swapIfBigEndian (static_cast (input) [i]); } static inline uint32 F (const uint32 x, const uint32 y, const uint32 z) throw() { return (x & y) | (~x & z); } @@ -4507,7 +4497,7 @@ MD5::ProcessContext::ProcessContext() count[1] = 0; } -void MD5::ProcessContext::processBlock (const uint8* const data, size_t dataSize) +void MD5::ProcessContext::processBlock (const void* const data, const size_t dataSize) { int bufferPos = ((count[0] >> 3) & 0x3F); @@ -4519,30 +4509,23 @@ void MD5::ProcessContext::processBlock (const uint8* const data, size_t dataSize count[1] += (uint32) (dataSize >> 29); const size_t spaceLeft = 64 - bufferPos; - size_t i = 0; if (dataSize >= spaceLeft) { memcpy (buffer + bufferPos, data, spaceLeft); - transform (buffer); - i = spaceLeft; - - while (i + 64 <= dataSize) - { - transform (data + i); - i += 64; - } + for (i = spaceLeft; i + 64 <= dataSize; i += 64) + transform (static_cast (data) + i); bufferPos = 0; } - memcpy (buffer + bufferPos, data + i, dataSize - i); + memcpy (buffer + bufferPos, static_cast (data) + i, dataSize - i); } -void MD5::ProcessContext::finish (uint8* const result) +void MD5::ProcessContext::finish (void* const result) { unsigned char encodedLength[8]; MD5Functions::encode (encodedLength, count, 8); @@ -4564,7 +4547,7 @@ void MD5::ProcessContext::finish (uint8* const result) zerostruct (buffer); } -void MD5::ProcessContext::transform (const uint8* const bufferToTransform) +void MD5::ProcessContext::transform (const void* const bufferToTransform) { using namespace MD5Functions; @@ -4574,7 +4557,7 @@ void MD5::ProcessContext::transform (const uint8* const bufferToTransform) uint32 d = state[3]; uint32 x[16]; - decode (x, bufferToTransform, 64); + encode (x, bufferToTransform, 64); enum Constants { @@ -4582,73 +4565,41 @@ void MD5::ProcessContext::transform (const uint8* const bufferToTransform) S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21 }; - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); + FF (c, d, a, b, x[ 2], S13, 0x242070db); FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); FF (d, a, b, c, x[ 5], S12, 0x4787c62a); + FF (c, d, a, b, x[ 6], S13, 0xa8304613); FF (b, c, d, a, x[ 7], S14, 0xfd469501); + FF (a, b, c, d, x[ 8], S11, 0x698098d8); FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); + FF (c, d, a, b, x[10], S13, 0xffff5bb1); FF (b, c, d, a, x[11], S14, 0x895cd7be); + FF (a, b, c, d, x[12], S11, 0x6b901122); FF (d, a, b, c, x[13], S12, 0xfd987193); + FF (c, d, a, b, x[14], S13, 0xa679438e); FF (b, c, d, a, x[15], S14, 0x49b40821); + + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); GG (d, a, b, c, x[ 6], S22, 0xc040b340); + GG (c, d, a, b, x[11], S23, 0x265e5a51); GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); GG (d, a, b, c, x[10], S22, 0x02441453); + GG (c, d, a, b, x[15], S23, 0xd8a1e681); GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); GG (d, a, b, c, x[14], S22, 0xc33707d6); + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); GG (b, c, d, a, x[ 8], S24, 0x455a14ed); + GG (a, b, c, d, x[13], S21, 0xa9e3e905); GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); + + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); HH (d, a, b, c, x[ 8], S32, 0x8771f681); + HH (c, d, a, b, x[11], S33, 0x6d9d6122); HH (b, c, d, a, x[14], S34, 0xfde5380c); + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); HH (b, c, d, a, x[10], S34, 0xbebfbc70); + HH (a, b, c, d, x[13], S31, 0x289b7ec6); HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); HH (b, c, d, a, x[ 6], S34, 0x04881d05); + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); HH (d, a, b, c, x[12], S32, 0xe6db99e5); + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); + + II (a, b, c, d, x[ 0], S41, 0xf4292244); II (d, a, b, c, x[ 7], S42, 0x432aff97); + II (c, d, a, b, x[14], S43, 0xab9423a7); II (b, c, d, a, x[ 5], S44, 0xfc93a039); + II (a, b, c, d, x[12], S41, 0x655b59c3); II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); + II (c, d, a, b, x[10], S43, 0xffeff47d); II (b, c, d, a, x[ 1], S44, 0x85845dd1); + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); II (d, a, b, c, x[15], S42, 0xfe2ce6e0); + II (c, d, a, b, x[ 6], S43, 0xa3014314); II (b, c, d, a, x[13], S44, 0x4e0811a1); + II (a, b, c, d, x[ 4], S41, 0xf7537e82); II (d, a, b, c, x[11], S42, 0xbd3af235); + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); II (b, c, d, a, x[ 9], S44, 0xeb86d391); state[0] += a; state[1] += b; @@ -8868,7 +8819,7 @@ bool Uuid::isNull() const throw() const String Uuid::toString() const { - return String::toHexString (value.asBytes, 16, 0); + return String::toHexString (value.asBytes, sizeof (value.asBytes), 0); } Uuid::Uuid (const String& uuidString) @@ -8878,48 +8829,11 @@ Uuid::Uuid (const String& uuidString) Uuid& Uuid::operator= (const String& uuidString) { - int destIndex = 0; - int i = 0; - - for (;;) - { - int byte = 0; - - for (int loop = 2; --loop >= 0;) - { - byte <<= 4; - - for (;;) - { - const tchar c = uuidString [i++]; - - if (c >= '0' && c <= '9') - { - byte |= c - '0'; - break; - } - else if (c >= 'a' && c <= 'z') - { - byte |= c - ('a' - 10); - break; - } - else if (c >= 'A' && c <= 'Z') - { - byte |= c - ('A' - 10); - break; - } - else if (c == 0) - { - while (destIndex < 16) - value.asBytes [destIndex++] = 0; - - return *this; - } - } - } - - value.asBytes [destIndex++] = (uint8) byte; - } + MemoryBlock mb; + mb.loadFromHexString (uuidString); + mb.ensureSize (sizeof (value.asBytes), true); + mb.copyTo (value.asBytes, 0, sizeof (value.asBytes)); + return *this; } Uuid::Uuid (const uint8* const rawData) @@ -8930,9 +8844,9 @@ Uuid::Uuid (const uint8* const rawData) Uuid& Uuid::operator= (const uint8* const rawData) { if (rawData != 0) - memcpy (value.asBytes, rawData, 16); + memcpy (value.asBytes, rawData, sizeof (value.asBytes)); else - zeromem (value.asBytes, 16); + zeromem (value.asBytes, sizeof (value.asBytes)); return *this; } @@ -29508,8 +29422,7 @@ void PluginListComponent::paintListBoxItem (int row, g.setColour (Colours::black); ga.draw (g); - float x, y, r, b; - ga.getBoundingBox (0, -1, x, y, r, b, false); + const Rectangle bb (ga.getBoundingBox (0, -1, false)); String desc; desc << pd->pluginFormatName @@ -29531,7 +29444,7 @@ void PluginListComponent::paintListBoxItem (int row, g.setColour (Colours::grey); ga.clear(); - ga.addCurtailedLineOfText (Font (height * 0.6f), desc, r + 10.0f, height * 0.8f, width - r - 12.0f, true); + ga.addCurtailedLineOfText (Font (height * 0.6f), desc, bb.getRight() + 10.0f, height * 0.8f, width - bb.getRight() - 12.0f, true); ga.draw (g); } } @@ -57318,10 +57231,9 @@ void FileChooserDialogBox::ContentComponent::resized() { getLookAndFeel().createFileChooserHeaderText (getName(), instructions, text, getWidth()); - float left, top, right, bottom; - text.getBoundingBox (0, text.getNumGlyphs(), left, top, right, bottom, false); + const Rectangle bb (text.getBoundingBox (0, text.getNumGlyphs(), false)); - const int y = roundToInt (bottom) + 10; + const int y = roundToInt (bb.getBottom()) + 10; const int buttonHeight = 26; const int buttonY = getHeight() - buttonHeight - 8; @@ -60510,7 +60422,7 @@ public: { } - void currentTabChanged (const int, const String&) + void currentTabChanged (int, const String&) { // (unable to use the syntax findParentComponentOfClass () because of a VC6 compiler bug) MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) 0); @@ -62620,13 +62532,13 @@ public: { } - void currentTabChanged (const int newCurrentTabIndex, + void currentTabChanged (int newCurrentTabIndex, const String& newTabName) { owner->changeCallback (newCurrentTabIndex, newTabName); } - void popupMenuClickOnTab (const int tabIndex, + void popupMenuClickOnTab (int tabIndex, const String& tabName) { owner->popupMenuClickOnTab (tabIndex, tabName); @@ -62637,7 +62549,7 @@ public: return owner->tabs->getTabBackgroundColour (tabIndex); } - TabBarButton* createTabButton (const String& tabName, const int tabIndex) + TabBarButton* createTabButton (const String& tabName, int tabIndex) { return owner->createTabButton (tabName, tabIndex); } @@ -83442,11 +83354,7 @@ void DrawableText::render (const Drawable::RenderingContext& context) const const Rectangle DrawableText::getBounds() const { - float x, y, w, h; - text.getBoundingBox (0, -1, x, y, w, h, false); // (really returns top, left, bottom, right) - w -= x; - h -= y; - return Rectangle (x, y, w, h); + return text.getBoundingBox (0, -1, false); } bool DrawableText::hitTest (float x, float y) const @@ -85364,9 +85272,7 @@ void PositionedGlyph::createPath (Path& path) const bool PositionedGlyph::hitTest (float px, float py) const { - if (px >= getLeft() && px < getRight() - && py >= getTop() && py < getBottom() - && ! isWhitespace()) + if (getBounds().contains (px, py) && ! isWhitespace()) { Typeface* const t = font.getTypeface(); @@ -85631,15 +85537,14 @@ void GlyphArrangement::addFittedText (const Font& f, GlyphArrangement ga; ga.addJustifiedText (f, text, x, y, width, layout); - float l, t, r, b; - ga.getBoundingBox (0, -1, l, t, r, b, false); + const Rectangle bb (ga.getBoundingBox (0, -1, false)); - float dy = y - t; + float dy = y - bb.getY(); if (layout.testFlags (Justification::verticallyCentred)) - dy += (height - (b - t)) * 0.5f; + dy += (height - bb.getHeight()) * 0.5f; else if (layout.testFlags (Justification::bottom)) - dy += height - (b - t); + dy += height - bb.getHeight(); ga.moveRangeOfGlyphs (0, -1, 0.0f, dy); @@ -85874,22 +85779,14 @@ void GlyphArrangement::stretchRangeOfGlyphs (int startIndex, int num, } } -void GlyphArrangement::getBoundingBox (int startIndex, int num, - float& left, - float& top, - float& right, - float& bottom, - const bool includeWhitespace) const +const Rectangle GlyphArrangement::getBoundingBox (int startIndex, int num, const bool includeWhitespace) const { jassert (startIndex >= 0); if (num < 0 || startIndex + num > glyphs.size()) num = glyphs.size() - startIndex; - left = 0.0f; - top = 0.0f; - right = 0.0f; - bottom = 0.0f; + Rectangle result; bool isFirst = true; while (--num >= 0) @@ -85901,56 +85798,47 @@ void GlyphArrangement::getBoundingBox (int startIndex, int num, if (isFirst) { isFirst = false; - left = pg->getLeft(); - top = pg->getTop(); - right = pg->getRight(); - bottom = pg->getBottom(); + result = pg->getBounds(); } else { - left = jmin (left, pg->getLeft()); - top = jmin (top, pg->getTop()); - right = jmax (right, pg->getRight()); - bottom = jmax (bottom, pg->getBottom()); + result = result.getUnion (pg->getBounds()); } } } + + return result; } -void GlyphArrangement::justifyGlyphs (const int startIndex, - const int num, - const float x, const float y, - const float width, const float height, +void GlyphArrangement::justifyGlyphs (const int startIndex, const int num, + const float x, const float y, const float width, const float height, const Justification& justification) { jassert (num >= 0 && startIndex >= 0); if (glyphs.size() > 0 && num > 0) { - float left, top, right, bottom; - getBoundingBox (startIndex, num, left, top, right, bottom, - ! justification.testFlags (Justification::horizontallyJustified - | Justification::horizontallyCentred)); - + const Rectangle bb (getBoundingBox (startIndex, num, ! justification.testFlags (Justification::horizontallyJustified + | Justification::horizontallyCentred))); float deltaX = 0.0f; if (justification.testFlags (Justification::horizontallyJustified)) - deltaX = x - left; + deltaX = x - bb.getX(); else if (justification.testFlags (Justification::horizontallyCentred)) - deltaX = x + (width - (right - left)) * 0.5f - left; + deltaX = x + (width - bb.getWidth()) * 0.5f - bb.getX(); else if (justification.testFlags (Justification::right)) - deltaX = (x + width) - right; + deltaX = (x + width) - bb.getRight(); else - deltaX = x - left; + deltaX = x - bb.getX(); float deltaY = 0.0f; if (justification.testFlags (Justification::top)) - deltaY = y - top; + deltaY = y - bb.getY(); else if (justification.testFlags (Justification::bottom)) - deltaY = (y + height) - bottom; + deltaY = (y + height) - bb.getBottom(); else - deltaY = y + (height - (bottom - top)) * 0.5f - top; + deltaY = y + (height - bb.getHeight()) * 0.5f - bb.getY(); moveRangeOfGlyphs (startIndex, num, deltaX, deltaY); @@ -210945,12 +210833,14 @@ namespace PNGHelpers static void readCallback (png_structp png, png_bytep data, png_size_t length) { - static_cast (png->io_ptr)->read (data, (int) length); + if (png != 0 && png->io_ptr != 0) + static_cast (png->io_ptr)->read (data, (int) length); } static void writeDataCallback (png_structp png, png_bytep data, png_size_t length) { - static_cast (png->io_ptr)->write (data, (int) length); + if (png != 0 && png->io_ptr != 0) + static_cast (png->io_ptr)->write (data, (int) length); } struct PNGErrorStruct {}; @@ -218908,7 +218798,7 @@ public: SwapBuffers (dc); } - bool setSwapInterval (const int numFramesPerSwap) + bool setSwapInterval (int numFramesPerSwap) { makeActive(); @@ -230877,10 +230767,11 @@ namespace Atoms enum ProtocolItems { TAKE_FOCUS = 0, - DELETE_WINDOW = 1 + DELETE_WINDOW = 1, + PING = 2 }; - static Atom Protocols, ProtocolList[2], ChangeState, State, + static Atom Protocols, ProtocolList[3], ChangeState, State, ActiveWin, Pid, WindowType, WindowState, XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus, XdndDrop, XdndFinished, XdndSelection, XdndTypeList, XdndActionList, @@ -230901,12 +230792,13 @@ namespace Atoms Protocols = XInternAtom (display, "WM_PROTOCOLS", True); ProtocolList [TAKE_FOCUS] = XInternAtom (display, "WM_TAKE_FOCUS", True); ProtocolList [DELETE_WINDOW] = XInternAtom (display, "WM_DELETE_WINDOW", True); + ProtocolList [PING] = XInternAtom (display, "_NET_WM_PING", True); ChangeState = XInternAtom (display, "WM_CHANGE_STATE", True); State = XInternAtom (display, "WM_STATE", True); ActiveWin = XInternAtom (display, "_NET_ACTIVE_WINDOW", False); Pid = XInternAtom (display, "_NET_WM_PID", False); WindowType = XInternAtom (display, "_NET_WM_WINDOW_TYPE", True); - WindowState = XInternAtom (display, "_NET_WM_WINDOW_STATE", True); + WindowState = XInternAtom (display, "_NET_WM_STATE", True); XdndAware = XInternAtom (display, "XdndAware", False); XdndEnter = XInternAtom (display, "XdndEnter", False); @@ -232408,7 +232300,6 @@ public: } case ReparentNotify: - case GravityNotify: { parentWindow = 0; Window wRoot = 0; @@ -232429,6 +232320,14 @@ public: break; } + case GravityNotify: + { + updateBounds(); + updateBorderSize(); + handleMovedOrResized(); + break; + } + case MapNotify: mapped = true; handleBroughtToFront(); @@ -232461,7 +232360,16 @@ public: { const Atom atom = (Atom) clientMsg->data.l[0]; - if (atom == Atoms::ProtocolList [Atoms::TAKE_FOCUS]) + if (atom == Atoms::ProtocolList [Atoms::PING]) + { + Window root = RootWindow (display, DefaultScreen (display)); + + event->xclient.window = root; + + XSendEvent (display, root, False, NoEventMask, event); + XFlush (display); + } + else if (atom == Atoms::ProtocolList [Atoms::TAKE_FOCUS]) { XWindowAttributes atts; @@ -233000,6 +232908,10 @@ private: if ((styleFlags & windowAppearsOnTaskbar) == 0) { + Atom skipTaskbar = XInternAtom (display, "_NET_WM_STATE_SKIP_TASKBAR", False); + + XChangeProperty (display, wndH, Atoms::WindowState, XA_ATOM, 32, PropModeReplace, + (unsigned char*) &skipTaskbar, 1); } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index db4ea1704a..284b9ac920 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -840,6 +840,26 @@ inline int roundFloatToInt (const float value) throw() return roundToInt (value); } +namespace TypeHelpers +{ + template struct ParameterType { typedef const Type& type; }; + template struct ParameterType { typedef Type& type; }; + template struct ParameterType { typedef Type* type; }; + template <> struct ParameterType { typedef char type; }; + template <> struct ParameterType { typedef unsigned char type; }; + template <> struct ParameterType { typedef short type; }; + template <> struct ParameterType { typedef unsigned short type; }; + template <> struct ParameterType { typedef int type; }; + template <> struct ParameterType { typedef unsigned int type; }; + template <> struct ParameterType { typedef long type; }; + template <> struct ParameterType { typedef unsigned long type; }; + template <> struct ParameterType { typedef int64 type; }; + template <> struct ParameterType { typedef uint64 type; }; + template <> struct ParameterType { typedef bool type; }; + template <> struct ParameterType { typedef float type; }; + template <> struct ParameterType { typedef double type; }; +} + #endif // __JUCE_MATHSFUNCTIONS_JUCEHEADER__ /*** End of inlined file: juce_MathsFunctions.h ***/ @@ -2065,7 +2085,7 @@ public: : ElementType(); } - int indexOf (const ElementType& elementToLookFor) const + int indexOf (typename TypeHelpers::ParameterType::type elementToLookFor) const { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); @@ -2082,7 +2102,7 @@ public: return -1; } - bool contains (const ElementType& elementToLookFor) const + bool contains (typename TypeHelpers::ParameterType::type elementToLookFor) const { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); @@ -2099,14 +2119,14 @@ public: return false; } - void add (const ElementType& newElement) + void add (typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); new (data.elements + numUsed++) ElementType (newElement); } - void insert (int indexToInsertAt, const ElementType& newElement) + void insert (int indexToInsertAt, typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); @@ -2128,7 +2148,7 @@ public: } } - void insertMultiple (int indexToInsertAt, const ElementType& newElement, + void insertMultiple (int indexToInsertAt, typename TypeHelpers::ParameterType::type newElement, int numberOfTimesToInsertIt) { if (numberOfTimesToInsertIt > 0) @@ -2183,7 +2203,7 @@ public: } } - void addIfNotAlreadyThere (const ElementType& newElement) + void addIfNotAlreadyThere (typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); @@ -2191,7 +2211,7 @@ public: add (newElement); } - void set (const int indexToChange, const ElementType& newValue) + void set (const int indexToChange, typename TypeHelpers::ParameterType::type newValue) { jassert (indexToChange >= 0); const ScopedLockType lock (getLock()); @@ -2207,7 +2227,7 @@ public: } } - void setUnchecked (const int indexToChange, const ElementType& newValue) + void setUnchecked (const int indexToChange, typename TypeHelpers::ParameterType::type newValue) { const ScopedLockType lock (getLock()); jassert (((unsigned int) indexToChange) < (unsigned int) numUsed); @@ -2258,14 +2278,14 @@ public: } template - void addSorted (ElementComparator& comparator, const ElementType& newElement) + void addSorted (ElementComparator& comparator, typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed), newElement); } template - int indexOfSorted (ElementComparator& comparator, const ElementType& elementToLookFor) const + int indexOfSorted (ElementComparator& comparator, typename TypeHelpers::ParameterType::type elementToLookFor) const { (void) comparator; // if you pass in an object with a static compareElements() method, this // avoids getting warning messages about the parameter being unused @@ -2325,7 +2345,7 @@ public: } } - void removeValue (const ElementType& valueToRemove) + void removeValue (typename TypeHelpers::ParameterType::type valueToRemove) { const ScopedLockType lock (getLock()); ElementType* e = data.elements; @@ -3125,21 +3145,19 @@ private: #elif JUCE_LINUX // Linux... #if __INTEL_COMPILER - inline void Atomic::increment (int32& variable) { _InterlockedIncrement (static_cast (&variable)); } - inline int32 Atomic::incrementAndReturn (int32& variable) { return _InterlockedIncrement (static_cast (&variable)); } - inline void Atomic::decrement (int32& variable) { _InterlockedDecrement (static_cast (&variable)); } - inline int32 Atomic::decrementAndReturn (int32& variable) { return _InterlockedDecrement (static_cast (&variable)); } + inline void Atomic::increment (int32& variable) { _InterlockedIncrement (&variable); } + inline int32 Atomic::incrementAndReturn (int32& variable) { return _InterlockedIncrement (&variable); } + inline void Atomic::decrement (int32& variable) { _InterlockedDecrement (&variable); } + inline int32 Atomic::decrementAndReturn (int32& variable) { return _InterlockedDecrement (&variable); } inline int32 Atomic::compareAndExchange (int32& destination, int32 newValue, int32 oldValue) - { return _InterlockedCompareExchange (static_cast (&destination), newValue, oldValue); } + { return _InterlockedCompareExchange (&destination, newValue, oldValue); } inline void* Atomic::swapPointers (void* volatile* value1, void* value2) { #if __ia64__ - return reinterpret_cast (_InterlockedExchange64 (reinterpret_cast (value1), - reinterpret_cast<__int64> (value2))); + return reinterpret_cast (_InterlockedExchange64 (const_cast (value1), reinterpret_cast<__int64> (value2))); #else - return reinterpret_cast (_InterlockedExchange (reinterpret_cast (value1), - reinterpret_cast (value2))); + return reinterpret_cast (_InterlockedExchange (const_cast (value1), reinterpret_cast (value2))); #endif } @@ -4082,7 +4100,7 @@ class JUCE_API RelativeTime { public: - explicit RelativeTime (const double seconds = 0.0) throw(); + explicit RelativeTime (double seconds = 0.0) throw(); RelativeTime (const RelativeTime& other) throw(); @@ -4090,17 +4108,17 @@ public: ~RelativeTime() throw(); - static const RelativeTime milliseconds (const int milliseconds) throw(); + static const RelativeTime milliseconds (int milliseconds) throw(); - static const RelativeTime milliseconds (const int64 milliseconds) throw(); + static const RelativeTime milliseconds (int64 milliseconds) throw(); - static const RelativeTime minutes (const double numberOfMinutes) throw(); + static const RelativeTime minutes (double numberOfMinutes) throw(); - static const RelativeTime hours (const double numberOfHours) throw(); + static const RelativeTime hours (double numberOfHours) throw(); - static const RelativeTime days (const double numberOfDays) throw(); + static const RelativeTime days (double numberOfDays) throw(); - static const RelativeTime weeks (const double numberOfWeeks) throw(); + static const RelativeTime weeks (double numberOfWeeks) throw(); int64 inMilliseconds() const throw(); @@ -4127,15 +4145,15 @@ public: const RelativeTime operator+ (const RelativeTime& timeToAdd) const throw(); const RelativeTime operator- (const RelativeTime& timeToSubtract) const throw(); - const RelativeTime operator+ (const double secondsToAdd) const throw(); - const RelativeTime operator- (const double secondsToSubtract) const throw(); + const RelativeTime operator+ (double secondsToAdd) const throw(); + const RelativeTime operator- (double secondsToSubtract) const throw(); const RelativeTime& operator+= (const RelativeTime& timeToAdd) throw(); const RelativeTime& operator-= (const RelativeTime& timeToSubtract) throw(); - const RelativeTime& operator+= (const double secondsToAdd) throw(); + const RelativeTime& operator+= (double secondsToAdd) throw(); - const RelativeTime& operator-= (const double secondsToSubtract) throw(); + const RelativeTime& operator-= (double secondsToSubtract) throw(); juce_UseDebuggingNewOperator @@ -6147,86 +6165,106 @@ public: (iter.getListener()->*callbackFunction) (); } - template + template void call (void (ListenerClass::*callbackFunction) (P1), - P2& param1) + typename TypeHelpers::ParameterType::type param1) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1); } - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1), - P2& param1) + typename TypeHelpers::ParameterType::type param1) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1); } - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2), - P3& param1, P4& param2) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2); } - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2), - P3& param1, P4& param2) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2); } - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2, P3), - P4& param1, P5& param2, P6& param3) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3); } - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2, P3), - P4& param1, P5& param2, P6& param3) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3); } - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2, P3, P4), - P5& param1, P6& param2, P7& param3, P8& param4) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4); } - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2, P3, P4), - P5& param1, P6& param2, P7& param3, P8& param4) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4); } - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2, P3, P4, P5), - P6& param1, P7& param2, P8& param3, P9& param4, P10& param5) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4, + typename TypeHelpers::ParameterType::type param5) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5); } - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2, P3, P4, P5), - P6& param1, P7& param2, P8& param3, P9& param4, P10& param5) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4, + typename TypeHelpers::ParameterType::type param5) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5); @@ -7386,9 +7424,9 @@ public: static int getMACAddresses (int64* addresses, int maxNum, #if JUCE_MAC - const bool littleEndian = true); + bool littleEndian = true); #else - const bool littleEndian = false); + bool littleEndian = false); #endif static const StringArray getMACAddressStrings(); @@ -7520,7 +7558,7 @@ public: explicit MD5 (const MemoryBlock& data); - MD5 (const char* data, const size_t numBytes); + MD5 (const void* data, const size_t numBytes); explicit MD5 (const String& text); @@ -7551,9 +7589,9 @@ private: ProcessContext(); - void processBlock (const uint8* const data, size_t dataSize); - void transform (const uint8* const buffer); - void finish (uint8* const result); + void processBlock (const void* data, size_t dataSize); + void transform (const void* buffer); + void finish (void* const result); }; void processStream (InputStream& input, int64 numBytesToRead); @@ -11649,6 +11687,8 @@ private: // this isn't a class you should ever instantiate - it's just here for the // static values in it. Colours(); + Colours (const Colours&); + Colours& operator= (const Colours&); }; #endif // __JUCE_COLOURS_JUCEHEADER__ @@ -16130,15 +16170,13 @@ public: ~Viewport(); - void setViewedComponent (Component* const newViewedComponent); + void setViewedComponent (Component* newViewedComponent); Component* getViewedComponent() const throw() { return contentComp; } - void setViewPosition (const int xPixelsOffset, - const int yPixelsOffset); + void setViewPosition (int xPixelsOffset, int yPixelsOffset); - void setViewPositionProportionately (const double proportionX, - const double proportionY); + void setViewPositionProportionately (double proportionX, double proportionY); bool autoScroll (int mouseX, int mouseY, int distanceFromEdge, int maximumSpeed); @@ -16157,20 +16195,20 @@ public: virtual void visibleAreaChanged (int visibleX, int visibleY, int visibleW, int visibleH); - void setScrollBarsShown (const bool showVerticalScrollbarIfNeeded, - const bool showHorizontalScrollbarIfNeeded); + void setScrollBarsShown (bool showVerticalScrollbarIfNeeded, + bool showHorizontalScrollbarIfNeeded); bool isVerticalScrollBarShown() const throw() { return showVScrollbar; } bool isHorizontalScrollBarShown() const throw() { return showHScrollbar; } - void setScrollBarThickness (const int thickness); + void setScrollBarThickness (int thickness); int getScrollBarThickness() const throw(); - void setSingleStepSizes (const int stepX, const int stepY); + void setSingleStepSizes (int stepX, int stepY); - void setScrollBarButtonVisibility (const bool buttonsVisible); + void setScrollBarButtonVisibility (bool buttonsVisible); ScrollBar* getVerticalScrollBar() const throw() { return verticalScrollBar; } @@ -20302,18 +20340,18 @@ public: ~ComponentAnimator(); - void animateComponent (Component* const component, + void animateComponent (Component* component, const Rectangle& finalPosition, - const int millisecondsToSpendMoving, - const double startSpeed = 1.0, - const double endSpeed = 1.0); + int millisecondsToSpendMoving, + double startSpeed = 1.0, + double endSpeed = 1.0); - void cancelAnimation (Component* const component, - const bool moveComponentToItsFinalPosition); + void cancelAnimation (Component* component, + bool moveComponentToItsFinalPosition); - void cancelAllAnimations (const bool moveComponentsToTheirFinalPositions); + void cancelAllAnimations (bool moveComponentsToTheirFinalPositions); - const Rectangle getComponentDestination (Component* const component); + const Rectangle getComponentDestination (Component* component); bool isAnimating (Component* component) const; @@ -20323,7 +20361,7 @@ private: VoidArray tasks; uint32 lastTime; - void* findTaskFor (Component* const component) const; + void* findTaskFor (Component* component) const; void timerCallback(); }; @@ -22771,8 +22809,8 @@ class JUCE_API ResizableBorderComponent : public Component { public: - ResizableBorderComponent (Component* const componentToResize, - ComponentBoundsConstrainer* const constrainer); + ResizableBorderComponent (Component* componentToResize, + ComponentBoundsConstrainer* constrainer); ~ResizableBorderComponent(); @@ -22816,8 +22854,8 @@ class JUCE_API ResizableCornerComponent : public Component { public: - ResizableCornerComponent (Component* const componentToResize, - ComponentBoundsConstrainer* const constrainer); + ResizableCornerComponent (Component* componentToResize, + ComponentBoundsConstrainer* constrainer); ~ResizableCornerComponent(); @@ -22972,9 +23010,9 @@ public: float getBaselineY() const { return y; } float getTop() const { return y - font.getAscent(); } float getBottom() const { return y + font.getDescent(); } + const Rectangle getBounds() const { return Rectangle (x, getTop(), w, font.getHeight()); } - void moveBy (const float deltaX, - const float deltaY); + void moveBy (float deltaX, float deltaY); void draw (const Graphics& g) const; @@ -23010,37 +23048,34 @@ public: ~GlyphArrangement(); - int getNumGlyphs() const { return glyphs.size(); } + int getNumGlyphs() const throw() { return glyphs.size(); } - PositionedGlyph& getGlyph (const int index) const; + PositionedGlyph& getGlyph (int index) const; void clear(); void addLineOfText (const Font& font, const String& text, - const float x, - const float y); + float x, float y); void addCurtailedLineOfText (const Font& font, const String& text, - float x, - const float y, - const float maxWidthPixels, - const bool useEllipsis); + float x, float y, + float maxWidthPixels, + bool useEllipsis); void addJustifiedText (const Font& font, const String& text, float x, float y, - const float maxLineWidth, + float maxLineWidth, const Justification& horizontalLayout); void addFittedText (const Font& font, const String& text, - const float x, const float y, - const float width, const float height, + float x, float y, float width, float height, const Justification& layout, int maximumLinesToUse, - const float minimumHorizontalScale = 0.7f); + float minimumHorizontalScale = 0.7f); void addGlyphArrangement (const GlyphArrangement& other); @@ -23052,28 +23087,18 @@ public: int findGlyphIndexAt (float x, float y) const; - void getBoundingBox (int startIndex, - int numGlyphs, - float& left, - float& top, - float& right, - float& bottom, - const bool includeWhitespace) const; + const Rectangle getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const; void moveRangeOfGlyphs (int startIndex, int numGlyphs, - const float deltaX, - const float deltaY); + float deltaX, float deltaY); void removeRangeOfGlyphs (int startIndex, int numGlyphs); void stretchRangeOfGlyphs (int startIndex, int numGlyphs, - const float horizontalScaleFactor); + float horizontalScaleFactor); - void justifyGlyphs (const int startIndex, const int numGlyphs, - const float x, - const float y, - const float width, - const float height, + void justifyGlyphs (int startIndex, int numGlyphs, + float x, float y, float width, float height, const Justification& justification); juce_UseDebuggingNewOperator @@ -23081,10 +23106,10 @@ public: private: OwnedArray glyphs; - int insertEllipsis (const Font& font, const float maxXPos, const int startIndex, int endIndex); + int insertEllipsis (const Font& font, float maxXPos, int startIndex, int endIndex); int fitLineIntoSpace (int start, int numGlyphs, float x, float y, float w, float h, const Font& font, const Justification& justification, float minimumHorizontalScale); - void spreadOutLine (const int start, const int numGlyphs, const float targetWidth); + void spreadOutLine (int start, int numGlyphs, float targetWidth); }; #endif // __JUCE_GLYPHARRANGEMENT_JUCEHEADER__ @@ -23773,12 +23798,12 @@ class JUCE_API TabBarButton : public Button public: TabBarButton (const String& name, - TabbedButtonBar* const ownerBar, - const int tabIndex); + TabbedButtonBar* ownerBar, + int tabIndex); ~TabBarButton(); - virtual int getBestTabLength (const int depth); + virtual int getBestTabLength (int depth); void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown); void clicked (const ModifierKeys& mods); @@ -23813,11 +23838,11 @@ public: TabsAtRight }; - TabbedButtonBar (const Orientation orientation); + TabbedButtonBar (Orientation orientation); ~TabbedButtonBar(); - void setOrientation (const Orientation orientation); + void setOrientation (Orientation orientation); Orientation getOrientation() const throw() { return orientation; } @@ -23827,35 +23852,33 @@ public: const Colour& tabBackgroundColour, int insertIndex = -1); - void setTabName (const int tabIndex, + void setTabName (int tabIndex, const String& newName); - void removeTab (const int tabIndex); + void removeTab (int tabIndex); - void moveTab (const int currentIndex, - const int newIndex); + void moveTab (int currentIndex, int newIndex); int getNumTabs() const; const StringArray getTabNames() const; - void setCurrentTabIndex (int newTabIndex, const bool sendChangeMessage = true); + void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true); const String& getCurrentTabName() const throw() { return tabs [currentTabIndex]; } int getCurrentTabIndex() const throw() { return currentTabIndex; } - TabBarButton* getTabButton (const int index) const; + TabBarButton* getTabButton (int index) const; - virtual void currentTabChanged (const int newCurrentTabIndex, + virtual void currentTabChanged (int newCurrentTabIndex, const String& newCurrentTabName); - virtual void popupMenuClickOnTab (const int tabIndex, - const String& tabName); + virtual void popupMenuClickOnTab (int tabIndex, const String& tabName); - const Colour getTabBackgroundColour (const int tabIndex); + const Colour getTabBackgroundColour (int tabIndex); - void setTabBackgroundColour (const int tabIndex, const Colour& newColour); + void setTabBackgroundColour (int tabIndex, const Colour& newColour); enum ColourIds { @@ -23876,8 +23899,7 @@ public: protected: - virtual TabBarButton* createTabButton (const String& tabName, - const int tabIndex); + virtual TabBarButton* createTabButton (const String& tabName, int tabIndex); private: Orientation orientation; @@ -23899,46 +23921,45 @@ class JUCE_API TabbedComponent : public Component { public: - explicit TabbedComponent (const TabbedButtonBar::Orientation orientation); + explicit TabbedComponent (TabbedButtonBar::Orientation orientation); ~TabbedComponent(); - void setOrientation (const TabbedButtonBar::Orientation orientation); + void setOrientation (TabbedButtonBar::Orientation orientation); TabbedButtonBar::Orientation getOrientation() const throw(); - void setTabBarDepth (const int newDepth); + void setTabBarDepth (int newDepth); int getTabBarDepth() const throw() { return tabDepth; } - void setOutline (const int newThickness); + void setOutline (int newThickness); - void setIndent (const int indentThickness); + void setIndent (int indentThickness); void clearTabs(); void addTab (const String& tabName, const Colour& tabBackgroundColour, - Component* const contentComponent, - const bool deleteComponentWhenNotNeeded, - const int insertIndex = -1); + Component* contentComponent, + bool deleteComponentWhenNotNeeded, + int insertIndex = -1); - void setTabName (const int tabIndex, - const String& newName); + void setTabName (int tabIndex, const String& newName); - void removeTab (const int tabIndex); + void removeTab (int tabIndex); int getNumTabs() const; const StringArray getTabNames() const; - Component* getTabContentComponent (const int tabIndex) const throw(); + Component* getTabContentComponent (int tabIndex) const throw(); - const Colour getTabBackgroundColour (const int tabIndex) const throw(); + const Colour getTabBackgroundColour (int tabIndex) const throw(); - void setTabBackgroundColour (const int tabIndex, const Colour& newColour); + void setTabBackgroundColour (int tabIndex, const Colour& newColour); - void setCurrentTabIndex (const int newTabIndex, const bool sendChangeMessage = true); + void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true); int getCurrentTabIndex() const; @@ -23946,10 +23967,10 @@ public: Component* getCurrentContentComponent() const throw() { return panelComponent; } - virtual void currentTabChanged (const int newCurrentTabIndex, + virtual void currentTabChanged (int newCurrentTabIndex, const String& newCurrentTabName); - virtual void popupMenuClickOnTab (const int tabIndex, + virtual void popupMenuClickOnTab (int tabIndex, const String& tabName); TabbedButtonBar& getTabbedButtonBar() const throw() { return *tabs; } @@ -23971,8 +23992,7 @@ protected: TabbedButtonBar* tabs; - virtual TabBarButton* createTabButton (const String& tabName, - const int tabIndex); + virtual TabBarButton* createTabButton (const String& tabName, int tabIndex); private: @@ -23982,7 +24002,7 @@ private: int outlineThickness, edgeIndent; friend class TabCompButtonBar; - void changeCallback (const int newCurrentTabIndex, const String& newTabName); + void changeCallback (int newCurrentTabIndex, const String& newTabName); TabbedComponent (const TabbedComponent&); TabbedComponent& operator= (const TabbedComponent&); @@ -24244,18 +24264,18 @@ public: ~MultiDocumentPanel(); - bool closeAllDocuments (const bool checkItsOkToCloseFirst); + bool closeAllDocuments (bool checkItsOkToCloseFirst); - bool addDocument (Component* const component, + bool addDocument (Component* component, const Colour& backgroundColour, - const bool deleteWhenRemoved); + bool deleteWhenRemoved); bool closeDocument (Component* component, - const bool checkItsOkToCloseFirst); + bool checkItsOkToCloseFirst); int getNumDocuments() const throw(); - Component* getDocument (const int index) const throw(); + Component* getDocument (int index) const throw(); Component* getActiveDocument() const throw(); @@ -24263,9 +24283,9 @@ public: virtual void activeDocumentChanged(); - void setMaximumNumDocuments (const int maximumNumDocuments); + void setMaximumNumDocuments (int maximumNumDocuments); - void useFullscreenWhenOneDocument (const bool shouldUseTabs); + void useFullscreenWhenOneDocument (bool shouldUseTabs); bool isFullscreenWhenOneDocument() const throw(); @@ -24275,7 +24295,7 @@ public: MaximisedWindowsWithTabs /**< In this mode, a TabbedComponent is used to show one document at a time. */ }; - void setLayoutMode (const LayoutMode newLayoutMode); + void setLayoutMode (LayoutMode newLayoutMode); LayoutMode getLayoutMode() const throw() { return mode; } @@ -24337,31 +24357,31 @@ public: ~StretchableLayoutManager(); - void setItemLayout (const int itemIndex, - const double minimumSize, - const double maximumSize, - const double preferredSize); + void setItemLayout (int itemIndex, + double minimumSize, + double maximumSize, + double preferredSize); - bool getItemLayout (const int itemIndex, + bool getItemLayout (int itemIndex, double& minimumSize, double& maximumSize, double& preferredSize) const; void clearAllItems(); - void layOutComponents (Component** const components, + void layOutComponents (Component** components, int numComponents, int x, int y, int width, int height, - const bool vertically, - const bool resizeOtherDimension); + bool vertically, + bool resizeOtherDimension); - int getItemCurrentPosition (const int itemIndex) const; + int getItemCurrentPosition (int itemIndex) const; - int getItemCurrentAbsoluteSize (const int itemIndex) const; + int getItemCurrentAbsoluteSize (int itemIndex) const; - double getItemCurrentRelativeSize (const int itemIndex) const; + double getItemCurrentRelativeSize (int itemIndex) const; - void setItemPosition (const int itemIndex, + void setItemPosition (int itemIndex, int newPosition); juce_UseDebuggingNewOperator @@ -24378,19 +24398,11 @@ private: int totalSize; static int sizeToRealSize (double size, int totalSpace); - - ItemLayoutProperties* getInfoFor (const int itemIndex) const; - - void setTotalSize (const int newTotalSize); - - int fitComponentsIntoSpace (const int startIndex, - const int endIndex, - const int availableSpace, - int startPos); - - int getMinimumSizeOfItems (const int startIndex, const int endIndex) const; - int getMaximumSizeOfItems (const int startIndex, const int endIndex) const; - + ItemLayoutProperties* getInfoFor (int itemIndex) const; + void setTotalSize (int newTotalSize); + int fitComponentsIntoSpace (int startIndex, int endIndex, int availableSpace, int startPos); + int getMinimumSizeOfItems (int startIndex, int endIndex) const; + int getMaximumSizeOfItems (int startIndex, int endIndex) const; void updatePrefSizesToMatchCurrentPositions(); StretchableLayoutManager (const StretchableLayoutManager&); @@ -24412,9 +24424,9 @@ class JUCE_API StretchableLayoutResizerBar : public Component { public: - StretchableLayoutResizerBar (StretchableLayoutManager* const layoutToUse, - const int itemIndexInLayout, - const bool isBarVertical); + StretchableLayoutResizerBar (StretchableLayoutManager* layoutToUse, + int itemIndexInLayout, + bool isBarVertical); ~StretchableLayoutResizerBar(); @@ -24454,16 +24466,16 @@ public: ~StretchableObjectResizer(); - void addItem (const double currentSize, - const double minSize, - const double maxSize, - const int order = 0); + void addItem (double currentSize, + double minSize, + double maxSize, + int order = 0); - void resizeToFit (const double targetSize); + void resizeToFit (double targetSize); int getNumItems() const throw() { return items.size(); } - double getItemSize (const int index) const throw(); + double getItemSize (int index) const throw(); juce_UseDebuggingNewOperator @@ -26630,10 +26642,10 @@ class JUCE_API OpenGLPixelFormat { public: - OpenGLPixelFormat (const int bitsPerRGBComponent = 8, - const int alphaBits = 8, - const int depthBufferBits = 16, - const int stencilBufferBits = 0); + OpenGLPixelFormat (int bitsPerRGBComponent = 8, + int alphaBits = 8, + int depthBufferBits = 16, + int stencilBufferBits = 0); OpenGLPixelFormat (const OpenGLPixelFormat&); OpenGLPixelFormat& operator= (const OpenGLPixelFormat&); @@ -26672,7 +26684,7 @@ public: virtual void swapBuffers() = 0; - virtual bool setSwapInterval (const int numFramesPerSwap) = 0; + virtual bool setSwapInterval (int numFramesPerSwap) = 0; virtual int getSwapInterval() const = 0; diff --git a/src/audio/plugins/juce_PluginListComponent.cpp b/src/audio/plugins/juce_PluginListComponent.cpp index d9f0b0f876..27c151a1a0 100644 --- a/src/audio/plugins/juce_PluginListComponent.cpp +++ b/src/audio/plugins/juce_PluginListComponent.cpp @@ -97,8 +97,7 @@ void PluginListComponent::paintListBoxItem (int row, g.setColour (Colours::black); ga.draw (g); - float x, y, r, b; - ga.getBoundingBox (0, -1, x, y, r, b, false); + const Rectangle bb (ga.getBoundingBox (0, -1, false)); String desc; desc << pd->pluginFormatName @@ -120,7 +119,7 @@ void PluginListComponent::paintListBoxItem (int row, g.setColour (Colours::grey); ga.clear(); - ga.addCurtailedLineOfText (Font (height * 0.6f), desc, r + 10.0f, height * 0.8f, width - r - 12.0f, true); + ga.addCurtailedLineOfText (Font (height * 0.6f), desc, bb.getRight() + 10.0f, height * 0.8f, width - bb.getRight() - 12.0f, true); ga.draw (g); } } diff --git a/src/containers/juce_Array.h b/src/containers/juce_Array.h index b7d85a3031..0feb99fab7 100644 --- a/src/containers/juce_Array.h +++ b/src/containers/juce_Array.h @@ -279,7 +279,7 @@ public: @param elementToLookFor the value or object to look for @returns the index of the object, or -1 if it's not found */ - int indexOf (const ElementType& elementToLookFor) const + int indexOf (typename TypeHelpers::ParameterType::type elementToLookFor) const { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); @@ -301,7 +301,7 @@ public: @param elementToLookFor the value or object to look for @returns true if the item is found */ - bool contains (const ElementType& elementToLookFor) const + bool contains (typename TypeHelpers::ParameterType::type elementToLookFor) const { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); @@ -324,7 +324,7 @@ public: @param newElement the new object to add to the array @see set, insert, addIfNotAlreadyThere, addSorted, addArray */ - void add (const ElementType& newElement) + void add (typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); @@ -343,7 +343,7 @@ public: @param newElement the new object to add to the array @see add, addSorted, set */ - void insert (int indexToInsertAt, const ElementType& newElement) + void insert (int indexToInsertAt, typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); @@ -377,7 +377,7 @@ public: @param numberOfTimesToInsertIt how many copies of the value to insert @see insert, add, addSorted, set */ - void insertMultiple (int indexToInsertAt, const ElementType& newElement, + void insertMultiple (int indexToInsertAt, typename TypeHelpers::ParameterType::type newElement, int numberOfTimesToInsertIt) { if (numberOfTimesToInsertIt > 0) @@ -452,7 +452,7 @@ public: @param newElement the new object to add to the array */ - void addIfNotAlreadyThere (const ElementType& newElement) + void addIfNotAlreadyThere (typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); @@ -469,7 +469,7 @@ public: @param newValue the new value to set for this index. @see add, insert */ - void set (const int indexToChange, const ElementType& newValue) + void set (const int indexToChange, typename TypeHelpers::ParameterType::type newValue) { jassert (indexToChange >= 0); const ScopedLockType lock (getLock()); @@ -494,7 +494,7 @@ public: @param newValue the new value to set for this index. @see set, getUnchecked */ - void setUnchecked (const int indexToChange, const ElementType& newValue) + void setUnchecked (const int indexToChange, typename TypeHelpers::ParameterType::type newValue) { const ScopedLockType lock (getLock()); jassert (((unsigned int) indexToChange) < (unsigned int) numUsed); @@ -576,7 +576,7 @@ public: @see add, sort */ template - void addSorted (ElementComparator& comparator, const ElementType& newElement) + void addSorted (ElementComparator& comparator, typename TypeHelpers::ParameterType::type newElement) { const ScopedLockType lock (getLock()); insert (findInsertIndexInSortedArray (comparator, data.elements.getData(), newElement, 0, numUsed), newElement); @@ -595,7 +595,7 @@ public: @see addSorted, sort */ template - int indexOfSorted (ElementComparator& comparator, const ElementType& elementToLookFor) const + int indexOfSorted (ElementComparator& comparator, typename TypeHelpers::ParameterType::type elementToLookFor) const { (void) comparator; // if you pass in an object with a static compareElements() method, this // avoids getting warning messages about the parameter being unused @@ -674,7 +674,7 @@ public: @param valueToRemove the object to try to remove @see remove, removeRange */ - void removeValue (const ElementType& valueToRemove) + void removeValue (typename TypeHelpers::ParameterType::type valueToRemove) { const ScopedLockType lock (getLock()); ElementType* e = data.elements; diff --git a/src/core/juce_MathsFunctions.h b/src/core/juce_MathsFunctions.h index 2b4e56c178..71b3c65020 100644 --- a/src/core/juce_MathsFunctions.h +++ b/src/core/juce_MathsFunctions.h @@ -300,6 +300,37 @@ inline int roundFloatToInt (const float value) throw() return roundToInt (value); } +//============================================================================== +/** The namespace contains a few template classes for helping work out class type variations. +*/ +namespace TypeHelpers +{ + /** The ParameterType struct is used to find the best type to use when passing some kind + of object as a parameter. + + E.g. "myFunction (typename TypeHelpers::ParameterType::type, typename TypeHelpers::ParameterType::type)" + would evaluate to "myfunction (int, const MyObject&)", keeping primitive types passed-by-value, but passing + objects as a const reference, to avoid copying. Of course, this is only useful in certain esoteric + template situations. + */ + template struct ParameterType { typedef const Type& type; }; + template struct ParameterType { typedef Type& type; }; + template struct ParameterType { typedef Type* type; }; + template <> struct ParameterType { typedef char type; }; + template <> struct ParameterType { typedef unsigned char type; }; + template <> struct ParameterType { typedef short type; }; + template <> struct ParameterType { typedef unsigned short type; }; + template <> struct ParameterType { typedef int type; }; + template <> struct ParameterType { typedef unsigned int type; }; + template <> struct ParameterType { typedef long type; }; + template <> struct ParameterType { typedef unsigned long type; }; + template <> struct ParameterType { typedef int64 type; }; + template <> struct ParameterType { typedef uint64 type; }; + template <> struct ParameterType { typedef bool type; }; + template <> struct ParameterType { typedef float type; }; + template <> struct ParameterType { typedef double type; }; +} + //============================================================================== diff --git a/src/core/juce_RelativeTime.h b/src/core/juce_RelativeTime.h index 13cba24ef2..d5b80d23c3 100644 --- a/src/core/juce_RelativeTime.h +++ b/src/core/juce_RelativeTime.h @@ -46,7 +46,7 @@ public: @param seconds the number of seconds, which may be +ve or -ve. @see milliseconds, minutes, hours, days, weeks */ - explicit RelativeTime (const double seconds = 0.0) throw(); + explicit RelativeTime (double seconds = 0.0) throw(); /** Copies another relative time. */ RelativeTime (const RelativeTime& other) throw(); @@ -62,37 +62,37 @@ public: @see minutes, hours, days, weeks */ - static const RelativeTime milliseconds (const int milliseconds) throw(); + static const RelativeTime milliseconds (int milliseconds) throw(); /** Creates a new RelativeTime object representing a number of milliseconds. @see minutes, hours, days, weeks */ - static const RelativeTime milliseconds (const int64 milliseconds) throw(); + static const RelativeTime milliseconds (int64 milliseconds) throw(); /** Creates a new RelativeTime object representing a number of minutes. @see milliseconds, hours, days, weeks */ - static const RelativeTime minutes (const double numberOfMinutes) throw(); + static const RelativeTime minutes (double numberOfMinutes) throw(); /** Creates a new RelativeTime object representing a number of hours. @see milliseconds, minutes, days, weeks */ - static const RelativeTime hours (const double numberOfHours) throw(); + static const RelativeTime hours (double numberOfHours) throw(); /** Creates a new RelativeTime object representing a number of days. @see milliseconds, minutes, hours, weeks */ - static const RelativeTime days (const double numberOfDays) throw(); + static const RelativeTime days (double numberOfDays) throw(); /** Creates a new RelativeTime object representing a number of weeks. @see milliseconds, minutes, hours, days */ - static const RelativeTime weeks (const double numberOfWeeks) throw(); + static const RelativeTime weeks (double numberOfWeeks) throw(); //============================================================================== /** Returns the number of milliseconds this time represents. @@ -171,9 +171,9 @@ public: const RelativeTime operator- (const RelativeTime& timeToSubtract) const throw(); /** Adds a number of seconds to this RelativeTime and returns the result. */ - const RelativeTime operator+ (const double secondsToAdd) const throw(); + const RelativeTime operator+ (double secondsToAdd) const throw(); /** Subtracts a number of seconds from this RelativeTime and returns the result. */ - const RelativeTime operator- (const double secondsToSubtract) const throw(); + const RelativeTime operator- (double secondsToSubtract) const throw(); /** Adds another RelativeTime to this one. */ const RelativeTime& operator+= (const RelativeTime& timeToAdd) throw(); @@ -181,10 +181,10 @@ public: const RelativeTime& operator-= (const RelativeTime& timeToSubtract) throw(); /** Adds a number of seconds to this time. */ - const RelativeTime& operator+= (const double secondsToAdd) throw(); + const RelativeTime& operator+= (double secondsToAdd) throw(); /** Subtracts a number of seconds from this time. */ - const RelativeTime& operator-= (const double secondsToSubtract) throw(); + const RelativeTime& operator-= (double secondsToSubtract) throw(); //============================================================================== diff --git a/src/core/juce_SystemStats.h b/src/core/juce_SystemStats.h index c5e4efca33..8d7740c4a2 100644 --- a/src/core/juce_SystemStats.h +++ b/src/core/juce_SystemStats.h @@ -174,9 +174,9 @@ public: */ static int getMACAddresses (int64* addresses, int maxNum, #if JUCE_MAC - const bool littleEndian = true); + bool littleEndian = true); #else - const bool littleEndian = false); + bool littleEndian = false); #endif /** Returns a list of MAC addresses found on this machine. diff --git a/src/core/juce_Uuid.cpp b/src/core/juce_Uuid.cpp index 6391e349c8..fabce01569 100644 --- a/src/core/juce_Uuid.cpp +++ b/src/core/juce_Uuid.cpp @@ -31,6 +31,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_Random.h" #include "juce_Time.h" #include "juce_SystemStats.h" +#include "../containers/juce_MemoryBlock.h" //============================================================================== @@ -99,7 +100,7 @@ bool Uuid::isNull() const throw() //============================================================================== const String Uuid::toString() const { - return String::toHexString (value.asBytes, 16, 0); + return String::toHexString (value.asBytes, sizeof (value.asBytes), 0); } Uuid::Uuid (const String& uuidString) @@ -109,48 +110,11 @@ Uuid::Uuid (const String& uuidString) Uuid& Uuid::operator= (const String& uuidString) { - int destIndex = 0; - int i = 0; - - for (;;) - { - int byte = 0; - - for (int loop = 2; --loop >= 0;) - { - byte <<= 4; - - for (;;) - { - const tchar c = uuidString [i++]; - - if (c >= '0' && c <= '9') - { - byte |= c - '0'; - break; - } - else if (c >= 'a' && c <= 'z') - { - byte |= c - ('a' - 10); - break; - } - else if (c >= 'A' && c <= 'Z') - { - byte |= c - ('A' - 10); - break; - } - else if (c == 0) - { - while (destIndex < 16) - value.asBytes [destIndex++] = 0; - - return *this; - } - } - } - - value.asBytes [destIndex++] = (uint8) byte; - } + MemoryBlock mb; + mb.loadFromHexString (uuidString); + mb.ensureSize (sizeof (value.asBytes), true); + mb.copyTo (value.asBytes, 0, sizeof (value.asBytes)); + return *this; } //============================================================================== @@ -162,9 +126,9 @@ Uuid::Uuid (const uint8* const rawData) Uuid& Uuid::operator= (const uint8* const rawData) { if (rawData != 0) - memcpy (value.asBytes, rawData, 16); + memcpy (value.asBytes, rawData, sizeof (value.asBytes)); else - zeromem (value.asBytes, 16); + zeromem (value.asBytes, sizeof (value.asBytes)); return *this; } diff --git a/src/cryptography/juce_MD5.cpp b/src/cryptography/juce_MD5.cpp index 16d4106c34..332efbd93c 100644 --- a/src/cryptography/juce_MD5.cpp +++ b/src/cryptography/juce_MD5.cpp @@ -54,14 +54,14 @@ MD5& MD5::operator= (const MD5& other) MD5::MD5 (const MemoryBlock& data) { ProcessContext context; - context.processBlock ((const uint8*) data.getData(), data.getSize()); + context.processBlock (data.getData(), data.getSize()); context.finish (result); } -MD5::MD5 (const char* data, const size_t numBytes) +MD5::MD5 (const void* data, const size_t numBytes) { ProcessContext context; - context.processBlock ((const uint8*) data, numBytes); + context.processBlock (data, numBytes); context.finish (result); } @@ -76,11 +76,9 @@ MD5::MD5 (const String& text) { // force the string into integer-sized unicode characters, to try to make it // get the same results on all platforms + compilers. - uint32 unicodeChar = (uint32) t[i]; - ByteOrder::swapIfBigEndian (unicodeChar); + uint32 unicodeChar = ByteOrder::swapIfBigEndian ((uint32) t[i]); - context.processBlock ((const uint8*) &unicodeChar, - sizeof (unicodeChar)); + context.processBlock (&unicodeChar, sizeof (unicodeChar)); } context.finish (result); @@ -95,7 +93,7 @@ void MD5::processStream (InputStream& input, int64 numBytesToRead) while (numBytesToRead > 0) { - char tempBuffer [512]; + uint8 tempBuffer [512]; const int bytesRead = input.read (tempBuffer, (int) jmin (numBytesToRead, (int64) sizeof (tempBuffer))); if (bytesRead <= 0) @@ -103,7 +101,7 @@ void MD5::processStream (InputStream& input, int64 numBytesToRead) numBytesToRead -= bytesRead; - context.processBlock ((const uint8*) tempBuffer, bytesRead); + context.processBlock (tempBuffer, bytesRead); } context.finish (result); @@ -131,18 +129,10 @@ MD5::~MD5() //============================================================================== namespace MD5Functions { - static void encode (uint8* const output, const uint32* const input, const int numBytes) throw() - { - uint32* const o = (uint32*) output; - - for (int i = 0; i < (numBytes >> 2); ++i) - o[i] = ByteOrder::swapIfBigEndian (input [i]); - } - - static void decode (uint32* const output, const uint8* const input, const int numBytes) throw() + static void encode (void* const output, const void* const input, const int numBytes) throw() { for (int i = 0; i < (numBytes >> 2); ++i) - output[i] = ByteOrder::littleEndianInt ((const char*) input + (i << 2)); + static_cast (output)[i] = ByteOrder::swapIfBigEndian (static_cast (input) [i]); } static inline uint32 F (const uint32 x, const uint32 y, const uint32 z) throw() { return (x & y) | (~x & z); } @@ -189,7 +179,7 @@ MD5::ProcessContext::ProcessContext() count[1] = 0; } -void MD5::ProcessContext::processBlock (const uint8* const data, size_t dataSize) +void MD5::ProcessContext::processBlock (const void* const data, const size_t dataSize) { int bufferPos = ((count[0] >> 3) & 0x3F); @@ -201,31 +191,24 @@ void MD5::ProcessContext::processBlock (const uint8* const data, size_t dataSize count[1] += (uint32) (dataSize >> 29); const size_t spaceLeft = 64 - bufferPos; - size_t i = 0; if (dataSize >= spaceLeft) { memcpy (buffer + bufferPos, data, spaceLeft); - transform (buffer); - i = spaceLeft; - - while (i + 64 <= dataSize) - { - transform (data + i); - i += 64; - } + for (i = spaceLeft; i + 64 <= dataSize; i += 64) + transform (static_cast (data) + i); bufferPos = 0; } - memcpy (buffer + bufferPos, data + i, dataSize - i); + memcpy (buffer + bufferPos, static_cast (data) + i, dataSize - i); } //============================================================================== -void MD5::ProcessContext::finish (uint8* const result) +void MD5::ProcessContext::finish (void* const result) { unsigned char encodedLength[8]; MD5Functions::encode (encodedLength, count, 8); @@ -247,7 +230,7 @@ void MD5::ProcessContext::finish (uint8* const result) zerostruct (buffer); } -void MD5::ProcessContext::transform (const uint8* const bufferToTransform) +void MD5::ProcessContext::transform (const void* const bufferToTransform) { using namespace MD5Functions; @@ -257,7 +240,7 @@ void MD5::ProcessContext::transform (const uint8* const bufferToTransform) uint32 d = state[3]; uint32 x[16]; - decode (x, bufferToTransform, 64); + encode (x, bufferToTransform, 64); enum Constants { @@ -265,73 +248,41 @@ void MD5::ProcessContext::transform (const uint8* const bufferToTransform) S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21 }; - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); + FF (c, d, a, b, x[ 2], S13, 0x242070db); FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); FF (d, a, b, c, x[ 5], S12, 0x4787c62a); + FF (c, d, a, b, x[ 6], S13, 0xa8304613); FF (b, c, d, a, x[ 7], S14, 0xfd469501); + FF (a, b, c, d, x[ 8], S11, 0x698098d8); FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); + FF (c, d, a, b, x[10], S13, 0xffff5bb1); FF (b, c, d, a, x[11], S14, 0x895cd7be); + FF (a, b, c, d, x[12], S11, 0x6b901122); FF (d, a, b, c, x[13], S12, 0xfd987193); + FF (c, d, a, b, x[14], S13, 0xa679438e); FF (b, c, d, a, x[15], S14, 0x49b40821); + + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); GG (d, a, b, c, x[ 6], S22, 0xc040b340); + GG (c, d, a, b, x[11], S23, 0x265e5a51); GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); GG (d, a, b, c, x[10], S22, 0x02441453); + GG (c, d, a, b, x[15], S23, 0xd8a1e681); GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); GG (d, a, b, c, x[14], S22, 0xc33707d6); + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); GG (b, c, d, a, x[ 8], S24, 0x455a14ed); + GG (a, b, c, d, x[13], S21, 0xa9e3e905); GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); + + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); HH (d, a, b, c, x[ 8], S32, 0x8771f681); + HH (c, d, a, b, x[11], S33, 0x6d9d6122); HH (b, c, d, a, x[14], S34, 0xfde5380c); + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); HH (b, c, d, a, x[10], S34, 0xbebfbc70); + HH (a, b, c, d, x[13], S31, 0x289b7ec6); HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); HH (b, c, d, a, x[ 6], S34, 0x04881d05); + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); HH (d, a, b, c, x[12], S32, 0xe6db99e5); + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); + + II (a, b, c, d, x[ 0], S41, 0xf4292244); II (d, a, b, c, x[ 7], S42, 0x432aff97); + II (c, d, a, b, x[14], S43, 0xab9423a7); II (b, c, d, a, x[ 5], S44, 0xfc93a039); + II (a, b, c, d, x[12], S41, 0x655b59c3); II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); + II (c, d, a, b, x[10], S43, 0xffeff47d); II (b, c, d, a, x[ 1], S44, 0x85845dd1); + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); II (d, a, b, c, x[15], S42, 0xfe2ce6e0); + II (c, d, a, b, x[ 6], S43, 0xa3014314); II (b, c, d, a, x[13], S44, 0x4e0811a1); + II (a, b, c, d, x[ 4], S41, 0xf7537e82); II (d, a, b, c, x[11], S42, 0xbd3af235); + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); II (b, c, d, a, x[ 9], S44, 0xeb86d391); state[0] += a; state[1] += b; diff --git a/src/cryptography/juce_MD5.h b/src/cryptography/juce_MD5.h index 80d70e645e..6c4594d8df 100644 --- a/src/cryptography/juce_MD5.h +++ b/src/cryptography/juce_MD5.h @@ -58,7 +58,7 @@ public: explicit MD5 (const MemoryBlock& data); /** Creates a checksum for a block of binary data. */ - MD5 (const char* data, const size_t numBytes); + MD5 (const void* data, const size_t numBytes); /** Creates a checksum for a string. @@ -114,9 +114,9 @@ private: ProcessContext(); - void processBlock (const uint8* const data, size_t dataSize); - void transform (const uint8* const buffer); - void finish (uint8* const result); + void processBlock (const void* data, size_t dataSize); + void transform (const void* buffer); + void finish (void* const result); }; void processStream (InputStream& input, int64 numBytesToRead); diff --git a/src/events/juce_ListenerList.h b/src/events/juce_ListenerList.h index 65379942b9..1c04e7bc2c 100644 --- a/src/events/juce_ListenerList.h +++ b/src/events/juce_ListenerList.h @@ -146,9 +146,9 @@ public: //============================================================================== /** Calls a member function on each listener in the list, with 1 parameter. */ - template + template void call (void (ListenerClass::*callbackFunction) (P1), - P2& param1) + typename TypeHelpers::ParameterType::type param1) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1); @@ -156,10 +156,10 @@ public: /** Calls a member function on each listener in the list, with one parameter and a bail-out-checker. See the class description for info about writing a bail-out checker. */ - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1), - P2& param1) + typename TypeHelpers::ParameterType::type param1) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1); @@ -167,9 +167,10 @@ public: //============================================================================== /** Calls a member function on each listener in the list, with 2 parameters. */ - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2), - P3& param1, P4& param2) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2); @@ -177,10 +178,11 @@ public: /** Calls a member function on each listener in the list, with 2 parameters and a bail-out-checker. See the class description for info about writing a bail-out checker. */ - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2), - P3& param1, P4& param2) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2); @@ -188,9 +190,11 @@ public: //============================================================================== /** Calls a member function on each listener in the list, with 3 parameters. */ - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2, P3), - P4& param1, P5& param2, P6& param3) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3); @@ -198,10 +202,12 @@ public: /** Calls a member function on each listener in the list, with 3 parameters and a bail-out-checker. See the class description for info about writing a bail-out checker. */ - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2, P3), - P4& param1, P5& param2, P6& param3) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3); @@ -209,9 +215,12 @@ public: //============================================================================== /** Calls a member function on each listener in the list, with 4 parameters. */ - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2, P3, P4), - P5& param1, P6& param2, P7& param3, P8& param4) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4); @@ -219,10 +228,13 @@ public: /** Calls a member function on each listener in the list, with 4 parameters and a bail-out-checker. See the class description for info about writing a bail-out checker. */ - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2, P3, P4), - P5& param1, P6& param2, P7& param3, P8& param4) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4); @@ -230,9 +242,13 @@ public: //============================================================================== /** Calls a member function on each listener in the list, with 5 parameters. */ - template + template void call (void (ListenerClass::*callbackFunction) (P1, P2, P3, P4, P5), - P6& param1, P7& param2, P8& param3, P9& param4, P10& param5) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4, + typename TypeHelpers::ParameterType::type param5) { for (Iterator iter (*this, DummyBailOutChecker()); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5); @@ -240,10 +256,14 @@ public: /** Calls a member function on each listener in the list, with 5 parameters and a bail-out-checker. See the class description for info about writing a bail-out checker. */ - template + template void callChecked (const BailOutCheckerType& bailOutChecker, void (ListenerClass::*callbackFunction) (P1, P2, P3, P4, P5), - P6& param1, P7& param2, P8& param3, P9& param4, P10& param5) + typename TypeHelpers::ParameterType::type param1, + typename TypeHelpers::ParameterType::type param2, + typename TypeHelpers::ParameterType::type param3, + typename TypeHelpers::ParameterType::type param4, + typename TypeHelpers::ParameterType::type param5) { for (Iterator iter (*this, bailOutChecker); iter.next();) (iter.getListener()->*callbackFunction) (param1, param2, param3, param4, param5); diff --git a/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp b/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp index c68255b959..7e2cfdbd39 100644 --- a/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp +++ b/src/gui/components/filebrowser/juce_FileChooserDialogBox.cpp @@ -164,10 +164,9 @@ void FileChooserDialogBox::ContentComponent::resized() { getLookAndFeel().createFileChooserHeaderText (getName(), instructions, text, getWidth()); - float left, top, right, bottom; - text.getBoundingBox (0, text.getNumGlyphs(), left, top, right, bottom, false); + const Rectangle bb (text.getBoundingBox (0, text.getNumGlyphs(), false)); - const int y = roundToInt (bottom) + 10; + const int y = roundToInt (bb.getBottom()) + 10; const int buttonHeight = 26; const int buttonY = getHeight() - buttonHeight - 8; diff --git a/src/gui/components/layout/juce_ComponentAnimator.h b/src/gui/components/layout/juce_ComponentAnimator.h index ed98ddc0b5..3fb8161dee 100644 --- a/src/gui/components/layout/juce_ComponentAnimator.h +++ b/src/gui/components/layout/juce_ComponentAnimator.h @@ -86,11 +86,11 @@ public: To move the component at a constant rate for its entire animation, set both the start and end speeds to 1.0 */ - void animateComponent (Component* const component, + void animateComponent (Component* component, const Rectangle& finalPosition, - const int millisecondsToSpendMoving, - const double startSpeed = 1.0, - const double endSpeed = 1.0); + int millisecondsToSpendMoving, + double startSpeed = 1.0, + double endSpeed = 1.0); /** Stops a component if it's currently being animated. @@ -98,8 +98,8 @@ public: be immediately moved to its destination position and size. If false, it will be left in whatever location it currently occupies. */ - void cancelAnimation (Component* const component, - const bool moveComponentToItsFinalPosition); + void cancelAnimation (Component* component, + bool moveComponentToItsFinalPosition); /** Clears all of the active animations. @@ -107,7 +107,7 @@ public: be immediately set to their final positions. If false, they will be left in whatever locations they currently occupy. */ - void cancelAllAnimations (const bool moveComponentsToTheirFinalPositions); + void cancelAllAnimations (bool moveComponentsToTheirFinalPositions); /** Returns the destination position for a component. @@ -117,7 +117,7 @@ public: If the specified component isn't currently being animated, this method will just return its current position. */ - const Rectangle getComponentDestination (Component* const component); + const Rectangle getComponentDestination (Component* component); /** Returns true if the specified component is currently being animated. */ @@ -130,7 +130,7 @@ private: VoidArray tasks; uint32 lastTime; - void* findTaskFor (Component* const component) const; + void* findTaskFor (Component* component) const; void timerCallback(); }; diff --git a/src/gui/components/layout/juce_MultiDocumentPanel.cpp b/src/gui/components/layout/juce_MultiDocumentPanel.cpp index e56b126c17..5fe08f2b5e 100644 --- a/src/gui/components/layout/juce_MultiDocumentPanel.cpp +++ b/src/gui/components/layout/juce_MultiDocumentPanel.cpp @@ -101,7 +101,7 @@ public: { } - void currentTabChanged (const int, const String&) + void currentTabChanged (int, const String&) { // (unable to use the syntax findParentComponentOfClass () because of a VC6 compiler bug) MultiDocumentPanel* const owner = findParentComponentOfClass ((MultiDocumentPanel*) 0); diff --git a/src/gui/components/layout/juce_MultiDocumentPanel.h b/src/gui/components/layout/juce_MultiDocumentPanel.h index 43438ec605..d48723bd58 100644 --- a/src/gui/components/layout/juce_MultiDocumentPanel.h +++ b/src/gui/components/layout/juce_MultiDocumentPanel.h @@ -118,7 +118,7 @@ public: @see closeDocument */ - bool closeAllDocuments (const bool checkItsOkToCloseFirst); + bool closeAllDocuments (bool checkItsOkToCloseFirst); /** Adds a document component to the panel. @@ -137,9 +137,9 @@ public: or closeAllDocuments(), then it will be deleted. If false, then the caller must handle the component's deletion */ - bool addDocument (Component* const component, + bool addDocument (Component* component, const Colour& backgroundColour, - const bool deleteWhenRemoved); + bool deleteWhenRemoved); /** Closes one of the documents. @@ -156,7 +156,7 @@ public: @see addDocument, closeAllDocuments */ bool closeDocument (Component* component, - const bool checkItsOkToCloseFirst); + bool checkItsOkToCloseFirst); /** Returns the number of open document windows. @@ -171,7 +171,7 @@ public: @see getNumDocuments */ - Component* getDocument (const int index) const throw(); + Component* getDocument (int index) const throw(); /** Returns the document component that is currently focused or on top. @@ -198,7 +198,7 @@ public: If this is zero or less there's no limit (the default). addDocument() will fail if this number is exceeded. */ - void setMaximumNumDocuments (const int maximumNumDocuments); + void setMaximumNumDocuments (int maximumNumDocuments); /** Sets an option to make the document fullscreen if there's only one document open. @@ -207,7 +207,7 @@ public: will always be shown, even if there's only one document. If there's more than one document open, then this option makes no difference. */ - void useFullscreenWhenOneDocument (const bool shouldUseTabs); + void useFullscreenWhenOneDocument (bool shouldUseTabs); /** Returns the result of the last time useFullscreenWhenOneDocument() was called. */ @@ -225,7 +225,7 @@ public: @see LayoutMode, getLayoutMode */ - void setLayoutMode (const LayoutMode newLayoutMode); + void setLayoutMode (LayoutMode newLayoutMode); /** Returns the current layout mode. */ LayoutMode getLayoutMode() const throw() { return mode; } diff --git a/src/gui/components/layout/juce_ResizableBorderComponent.h b/src/gui/components/layout/juce_ResizableBorderComponent.h index d1051836b9..73e2b36da1 100644 --- a/src/gui/components/layout/juce_ResizableBorderComponent.h +++ b/src/gui/components/layout/juce_ResizableBorderComponent.h @@ -66,8 +66,8 @@ public: @see ComponentBoundsConstrainer */ - ResizableBorderComponent (Component* const componentToResize, - ComponentBoundsConstrainer* const constrainer); + ResizableBorderComponent (Component* componentToResize, + ComponentBoundsConstrainer* constrainer); /** Destructor. */ ~ResizableBorderComponent(); diff --git a/src/gui/components/layout/juce_ResizableCornerComponent.h b/src/gui/components/layout/juce_ResizableCornerComponent.h index f41de52ee3..ab91a7dbe0 100644 --- a/src/gui/components/layout/juce_ResizableCornerComponent.h +++ b/src/gui/components/layout/juce_ResizableCornerComponent.h @@ -61,8 +61,8 @@ public: @see ComponentBoundsConstrainer */ - ResizableCornerComponent (Component* const componentToResize, - ComponentBoundsConstrainer* const constrainer); + ResizableCornerComponent (Component* componentToResize, + ComponentBoundsConstrainer* constrainer); /** Destructor. */ ~ResizableCornerComponent(); diff --git a/src/gui/components/layout/juce_StretchableLayoutManager.h b/src/gui/components/layout/juce_StretchableLayoutManager.h index 57314aa3a4..3740081f6c 100644 --- a/src/gui/components/layout/juce_StretchableLayoutManager.h +++ b/src/gui/components/layout/juce_StretchableLayoutManager.h @@ -109,10 +109,10 @@ public: indicates a proportion of the available space @see getItemLayout */ - void setItemLayout (const int itemIndex, - const double minimumSize, - const double maximumSize, - const double preferredSize); + void setItemLayout (int itemIndex, + double minimumSize, + double maximumSize, + double preferredSize); /** For a numbered item, this returns its size limits and preferred size. @@ -129,7 +129,7 @@ public: @returns false if the item's properties hadn't been set @see setItemLayout */ - bool getItemLayout (const int itemIndex, + bool getItemLayout (int itemIndex, double& minimumSize, double& maximumSize, double& preferredSize) const; @@ -170,11 +170,11 @@ public: the x and width parameters; if 'vertically' is false, their y-positions and heights are adjusted to fit the y and height parameters. */ - void layOutComponents (Component** const components, + void layOutComponents (Component** components, int numComponents, int x, int y, int width, int height, - const bool vertically, - const bool resizeOtherDimension); + bool vertically, + bool resizeOtherDimension); //============================================================================== /** Returns the current position of one of the items. @@ -190,7 +190,7 @@ public: @see getItemCurrentSize, setItemPosition */ - int getItemCurrentPosition (const int itemIndex) const; + int getItemCurrentPosition (int itemIndex) const; /** Returns the current size of one of the items. @@ -201,7 +201,7 @@ public: @see getItemCurrentRelativeSize */ - int getItemCurrentAbsoluteSize (const int itemIndex) const; + int getItemCurrentAbsoluteSize (int itemIndex) const; /** Returns the current size of one of the items. @@ -213,7 +213,7 @@ public: @see getItemCurrentAbsoluteSize */ - double getItemCurrentRelativeSize (const int itemIndex) const; + double getItemCurrentRelativeSize (int itemIndex) const; //============================================================================== /** Moves one of the items, shifting along any other items as necessary in @@ -231,7 +231,7 @@ public: because other items may have minimum sizes that constrain how far it can go */ - void setItemPosition (const int itemIndex, + void setItemPosition (int itemIndex, int newPosition); @@ -251,19 +251,11 @@ private: //============================================================================== static int sizeToRealSize (double size, int totalSpace); - - ItemLayoutProperties* getInfoFor (const int itemIndex) const; - - void setTotalSize (const int newTotalSize); - - int fitComponentsIntoSpace (const int startIndex, - const int endIndex, - const int availableSpace, - int startPos); - - int getMinimumSizeOfItems (const int startIndex, const int endIndex) const; - int getMaximumSizeOfItems (const int startIndex, const int endIndex) const; - + ItemLayoutProperties* getInfoFor (int itemIndex) const; + void setTotalSize (int newTotalSize); + int fitComponentsIntoSpace (int startIndex, int endIndex, int availableSpace, int startPos); + int getMinimumSizeOfItems (int startIndex, int endIndex) const; + int getMaximumSizeOfItems (int startIndex, int endIndex) const; void updatePrefSizesToMatchCurrentPositions(); StretchableLayoutManager (const StretchableLayoutManager&); diff --git a/src/gui/components/layout/juce_StretchableLayoutResizerBar.h b/src/gui/components/layout/juce_StretchableLayoutResizerBar.h index e74f6c06cb..ef40425c20 100644 --- a/src/gui/components/layout/juce_StretchableLayoutResizerBar.h +++ b/src/gui/components/layout/juce_StretchableLayoutResizerBar.h @@ -56,9 +56,9 @@ public: right; false for a horizontal one that you drag up and down */ - StretchableLayoutResizerBar (StretchableLayoutManager* const layoutToUse, - const int itemIndexInLayout, - const bool isBarVertical); + StretchableLayoutResizerBar (StretchableLayoutManager* layoutToUse, + int itemIndexInLayout, + bool isBarVertical); /** Destructor. */ ~StretchableLayoutResizerBar(); diff --git a/src/gui/components/layout/juce_StretchableObjectResizer.h b/src/gui/components/layout/juce_StretchableObjectResizer.h index c7642043f4..3592fe67b7 100644 --- a/src/gui/components/layout/juce_StretchableObjectResizer.h +++ b/src/gui/components/layout/juce_StretchableObjectResizer.h @@ -62,10 +62,10 @@ public: resized, and if that doesn't provide enough space to meet the requirements, the algorithm will then try resizing the items with an order of 1, then 2, and so on. */ - void addItem (const double currentSize, - const double minSize, - const double maxSize, - const int order = 0); + void addItem (double currentSize, + double minSize, + double maxSize, + int order = 0); /** Resizes all the items to fit this amount of space. @@ -76,13 +76,13 @@ public: After calling this method, you can retrieve the new sizes with the getItemSize() method. */ - void resizeToFit (const double targetSize); + void resizeToFit (double targetSize); /** Returns the number of items that have been added. */ int getNumItems() const throw() { return items.size(); } /** Returns the size of one of the items. */ - double getItemSize (const int index) const throw(); + double getItemSize (int index) const throw(); //============================================================================== diff --git a/src/gui/components/layout/juce_TabbedButtonBar.h b/src/gui/components/layout/juce_TabbedButtonBar.h index 67f8602bca..ad10e00f45 100644 --- a/src/gui/components/layout/juce_TabbedButtonBar.h +++ b/src/gui/components/layout/juce_TabbedButtonBar.h @@ -47,8 +47,8 @@ public: //============================================================================== /** Creates the tab button. */ TabBarButton (const String& name, - TabbedButtonBar* const ownerBar, - const int tabIndex); + TabbedButtonBar* ownerBar, + int tabIndex); /** Destructor. */ ~TabBarButton(); @@ -60,7 +60,7 @@ public: specifies its height. If it's vertical, it should return the height, and the depth is actually its width. */ - virtual int getBestTabLength (const int depth); + virtual int getBestTabLength (int depth); //============================================================================== void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown); @@ -126,7 +126,7 @@ public: You can change the orientation later if you need to. */ - TabbedButtonBar (const Orientation orientation); + TabbedButtonBar (Orientation orientation); /** Destructor. */ ~TabbedButtonBar(); @@ -138,7 +138,7 @@ public: but this determines which direction the tabs go in, and which side they're stuck to. */ - void setOrientation (const Orientation orientation); + void setOrientation (Orientation orientation); /** Returns the current orientation. @@ -164,18 +164,17 @@ public: int insertIndex = -1); /** Changes the name of one of the tabs. */ - void setTabName (const int tabIndex, + void setTabName (int tabIndex, const String& newName); /** Gets rid of one of the tabs. */ - void removeTab (const int tabIndex); + void removeTab (int tabIndex); /** Moves a tab to a new index in the list. Pass -1 as the index to move it to the end of the list. */ - void moveTab (const int currentIndex, - const int newIndex); + void moveTab (int currentIndex, int newIndex); /** Returns the number of tabs in the bar. */ int getNumTabs() const; @@ -191,7 +190,7 @@ public: To deselect all the tabs, use an index of -1. */ - void setCurrentTabIndex (int newTabIndex, const bool sendChangeMessage = true); + void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true); /** Returns the name of the currently selected tab. @@ -211,34 +210,33 @@ public: on to the pointer that is returned. A null pointer may be returned if the index is out of range. */ - TabBarButton* getTabButton (const int index) const; + TabBarButton* getTabButton (int index) const; //============================================================================== /** Callback method to indicate the selected tab has been changed. @see setCurrentTabIndex */ - virtual void currentTabChanged (const int newCurrentTabIndex, + virtual void currentTabChanged (int newCurrentTabIndex, const String& newCurrentTabName); /** Callback method to indicate that the user has right-clicked on a tab. (Or ctrl-clicked on the Mac) */ - virtual void popupMenuClickOnTab (const int tabIndex, - const String& tabName); + virtual void popupMenuClickOnTab (int tabIndex, const String& tabName); /** Returns the colour of a tab. This is the colour that was specified in addTab(). */ - const Colour getTabBackgroundColour (const int tabIndex); + const Colour getTabBackgroundColour (int tabIndex); /** Changes the background colour of a tab. @see addTab, getTabBackgroundColour */ - void setTabBackgroundColour (const int tabIndex, const Colour& newColour); + void setTabBackgroundColour (int tabIndex, const Colour& newColour); //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the component. @@ -276,8 +274,7 @@ protected: If you need to use custom tab components, you can override this method and return your own class instead of the default. */ - virtual TabBarButton* createTabButton (const String& tabName, - const int tabIndex); + virtual TabBarButton* createTabButton (const String& tabName, int tabIndex); private: Orientation orientation; diff --git a/src/gui/components/layout/juce_TabbedComponent.cpp b/src/gui/components/layout/juce_TabbedComponent.cpp index 72063b1820..cad234693a 100644 --- a/src/gui/components/layout/juce_TabbedComponent.cpp +++ b/src/gui/components/layout/juce_TabbedComponent.cpp @@ -46,13 +46,13 @@ public: { } - void currentTabChanged (const int newCurrentTabIndex, + void currentTabChanged (int newCurrentTabIndex, const String& newTabName) { owner->changeCallback (newCurrentTabIndex, newTabName); } - void popupMenuClickOnTab (const int tabIndex, + void popupMenuClickOnTab (int tabIndex, const String& tabName) { owner->popupMenuClickOnTab (tabIndex, tabName); @@ -63,7 +63,7 @@ public: return owner->tabs->getTabBackgroundColour (tabIndex); } - TabBarButton* createTabButton (const String& tabName, const int tabIndex) + TabBarButton* createTabButton (const String& tabName, int tabIndex) { return owner->createTabButton (tabName, tabIndex); } diff --git a/src/gui/components/layout/juce_TabbedComponent.h b/src/gui/components/layout/juce_TabbedComponent.h index fa9dfefefe..374834a1d4 100644 --- a/src/gui/components/layout/juce_TabbedComponent.h +++ b/src/gui/components/layout/juce_TabbedComponent.h @@ -47,7 +47,7 @@ public: Once created, add some tabs with the addTab() method. */ - explicit TabbedComponent (const TabbedButtonBar::Orientation orientation); + explicit TabbedComponent (TabbedButtonBar::Orientation orientation); /** Destructor. */ ~TabbedComponent(); @@ -60,7 +60,7 @@ public: @see TabbedButtonBar::setOrientation */ - void setOrientation (const TabbedButtonBar::Orientation orientation); + void setOrientation (TabbedButtonBar::Orientation orientation); /** Returns the current tab placement. @@ -74,7 +74,7 @@ public: of the bar; if they're along the left or right edges, it'll be the width of the bar. */ - void setTabBarDepth (const int newDepth); + void setTabBarDepth (int newDepth); /** Returns the current thickness of the tab bar. @@ -89,13 +89,13 @@ public: To set the colour of the line, use setColour (outlineColourId, ...). */ - void setOutline (const int newThickness); + void setOutline (int newThickness); /** Specifies a gap to leave around the edge of the content component. Each edge of the content component will be indented by the given number of pixels. */ - void setIndent (const int indentThickness); + void setIndent (int indentThickness); //============================================================================== /** Removes all the tabs from the bar. @@ -114,16 +114,15 @@ public: */ void addTab (const String& tabName, const Colour& tabBackgroundColour, - Component* const contentComponent, - const bool deleteComponentWhenNotNeeded, - const int insertIndex = -1); + Component* contentComponent, + bool deleteComponentWhenNotNeeded, + int insertIndex = -1); /** Changes the name of one of the tabs. */ - void setTabName (const int tabIndex, - const String& newName); + void setTabName (int tabIndex, const String& newName); /** Gets rid of one of the tabs. */ - void removeTab (const int tabIndex); + void removeTab (int tabIndex); /** Returns the number of tabs in the bar. */ int getNumTabs() const; @@ -136,13 +135,13 @@ public: Be sure not to use or delete the components that are returned, as this may interfere with the TabbedComponent's use of them. */ - Component* getTabContentComponent (const int tabIndex) const throw(); + Component* getTabContentComponent (int tabIndex) const throw(); /** Returns the colour of one of the tabs. */ - const Colour getTabBackgroundColour (const int tabIndex) const throw(); + const Colour getTabBackgroundColour (int tabIndex) const throw(); /** Changes the background colour of one of the tabs. */ - void setTabBackgroundColour (const int tabIndex, const Colour& newColour); + void setTabBackgroundColour (int tabIndex, const Colour& newColour); //============================================================================== /** Changes the currently-selected tab. @@ -151,7 +150,7 @@ public: @see TabbedButtonBar::setCurrentTabIndex */ - void setCurrentTabIndex (const int newTabIndex, const bool sendChangeMessage = true); + void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true); /** Returns the index of the currently selected tab. @@ -176,14 +175,14 @@ public: @see setCurrentTabIndex */ - virtual void currentTabChanged (const int newCurrentTabIndex, + virtual void currentTabChanged (int newCurrentTabIndex, const String& newCurrentTabName); /** Callback method to indicate that the user has right-clicked on a tab. (Or ctrl-clicked on the Mac) */ - virtual void popupMenuClickOnTab (const int tabIndex, + virtual void popupMenuClickOnTab (int tabIndex, const String& tabName); /** Returns the tab button bar component that is being used. @@ -225,8 +224,7 @@ protected: If you need to use custom tab components, you can override this method and return your own class instead of the default. */ - virtual TabBarButton* createTabButton (const String& tabName, - const int tabIndex); + virtual TabBarButton* createTabButton (const String& tabName, int tabIndex); private: //============================================================================== @@ -236,7 +234,7 @@ private: int outlineThickness, edgeIndent; friend class TabCompButtonBar; - void changeCallback (const int newCurrentTabIndex, const String& newTabName); + void changeCallback (int newCurrentTabIndex, const String& newTabName); TabbedComponent (const TabbedComponent&); TabbedComponent& operator= (const TabbedComponent&); diff --git a/src/gui/components/layout/juce_Viewport.h b/src/gui/components/layout/juce_Viewport.h index 0b34177826..63c8d2846b 100644 --- a/src/gui/components/layout/juce_Viewport.h +++ b/src/gui/components/layout/juce_Viewport.h @@ -72,7 +72,7 @@ public: by the Viewport when it's no longer needed @see getViewedComponent */ - void setViewedComponent (Component* const newViewedComponent); + void setViewedComponent (Component* newViewedComponent); /** Returns the component that's currently being used inside the Viewport. @@ -91,8 +91,7 @@ public: @see getViewPositionX, getViewPositionY, setViewPositionProportionately */ - void setViewPosition (const int xPixelsOffset, - const int yPixelsOffset); + void setViewPosition (int xPixelsOffset, int yPixelsOffset); /** Changes the view position as a proportion of the distance it can move. @@ -101,8 +100,7 @@ public: to the right as it's possible to go whilst keeping the child component on-screen. */ - void setViewPositionProportionately (const double proportionX, - const double proportionY); + void setViewPositionProportionately (double proportionX, double proportionY); /** If the specified position is at the edges of the viewport, this method scrolls the viewport to bring that position nearer to the centre. @@ -174,8 +172,8 @@ public: If set to false, the scrollbars won't ever appear. When true (the default) they will appear only when needed. */ - void setScrollBarsShown (const bool showVerticalScrollbarIfNeeded, - const bool showHorizontalScrollbarIfNeeded); + void setScrollBarsShown (bool showVerticalScrollbarIfNeeded, + bool showHorizontalScrollbarIfNeeded); /** True if the vertical scrollbar is enabled. @see setScrollBarsShown @@ -193,7 +191,7 @@ public: @see LookAndFeel::getDefaultScrollbarWidth */ - void setScrollBarThickness (const int thickness); + void setScrollBarThickness (int thickness); /** Returns the thickness of the scrollbars. @@ -204,13 +202,13 @@ public: /** Changes the distance that a single-step click on a scrollbar button will move the viewport. */ - void setSingleStepSizes (const int stepX, const int stepY); + void setSingleStepSizes (int stepX, int stepY); /** Shows or hides the buttons on any scrollbars that are used. @see ScrollBar::setButtonVisibility */ - void setScrollBarButtonVisibility (const bool buttonsVisible); + void setScrollBarButtonVisibility (bool buttonsVisible); /** Returns a pointer to the scrollbar component being used. diff --git a/src/gui/components/special/juce_OpenGLComponent.h b/src/gui/components/special/juce_OpenGLComponent.h index f22f011234..17525f367e 100644 --- a/src/gui/components/special/juce_OpenGLComponent.h +++ b/src/gui/components/special/juce_OpenGLComponent.h @@ -47,10 +47,10 @@ public: The default constructor just initialises the object as a simple 8-bit RGBA format. */ - OpenGLPixelFormat (const int bitsPerRGBComponent = 8, - const int alphaBits = 8, - const int depthBufferBits = 16, - const int stencilBufferBits = 0); + OpenGLPixelFormat (int bitsPerRGBComponent = 8, + int alphaBits = 8, + int depthBufferBits = 16, + int stencilBufferBits = 0); OpenGLPixelFormat (const OpenGLPixelFormat&); OpenGLPixelFormat& operator= (const OpenGLPixelFormat&); @@ -117,7 +117,7 @@ public: Returns true if it sets the value successfully. */ - virtual bool setSwapInterval (const int numFramesPerSwap) = 0; + virtual bool setSwapInterval (int numFramesPerSwap) = 0; /** Returns the current swap-sync interval. See setSwapInterval() for info about the value returned. diff --git a/src/gui/graphics/colour/juce_Colours.h b/src/gui/graphics/colour/juce_Colours.h index 458bd06881..c2b35a9270 100644 --- a/src/gui/graphics/colour/juce_Colours.h +++ b/src/gui/graphics/colour/juce_Colours.h @@ -104,6 +104,8 @@ private: // this isn't a class you should ever instantiate - it's just here for the // static values in it. Colours(); + Colours (const Colours&); + Colours& operator= (const Colours&); }; #endif // __JUCE_COLOURS_JUCEHEADER__ diff --git a/src/gui/graphics/drawables/juce_DrawableText.cpp b/src/gui/graphics/drawables/juce_DrawableText.cpp index fed0da9932..aa189805f0 100644 --- a/src/gui/graphics/drawables/juce_DrawableText.cpp +++ b/src/gui/graphics/drawables/juce_DrawableText.cpp @@ -67,11 +67,7 @@ void DrawableText::render (const Drawable::RenderingContext& context) const const Rectangle DrawableText::getBounds() const { - float x, y, w, h; - text.getBoundingBox (0, -1, x, y, w, h, false); // (really returns top, left, bottom, right) - w -= x; - h -= y; - return Rectangle (x, y, w, h); + return text.getBoundingBox (0, -1, false); } bool DrawableText::hitTest (float x, float y) const diff --git a/src/gui/graphics/fonts/juce_GlyphArrangement.cpp b/src/gui/graphics/fonts/juce_GlyphArrangement.cpp index b57e37dd81..59bb4dff96 100644 --- a/src/gui/graphics/fonts/juce_GlyphArrangement.cpp +++ b/src/gui/graphics/fonts/juce_GlyphArrangement.cpp @@ -94,9 +94,7 @@ void PositionedGlyph::createPath (Path& path) const bool PositionedGlyph::hitTest (float px, float py) const { - if (px >= getLeft() && px < getRight() - && py >= getTop() && py < getBottom() - && ! isWhitespace()) + if (getBounds().contains (px, py) && ! isWhitespace()) { Typeface* const t = font.getTypeface(); @@ -366,15 +364,14 @@ void GlyphArrangement::addFittedText (const Font& f, GlyphArrangement ga; ga.addJustifiedText (f, text, x, y, width, layout); - float l, t, r, b; - ga.getBoundingBox (0, -1, l, t, r, b, false); + const Rectangle bb (ga.getBoundingBox (0, -1, false)); - float dy = y - t; + float dy = y - bb.getY(); if (layout.testFlags (Justification::verticallyCentred)) - dy += (height - (b - t)) * 0.5f; + dy += (height - bb.getHeight()) * 0.5f; else if (layout.testFlags (Justification::bottom)) - dy += height - (b - t); + dy += height - bb.getHeight(); ga.moveRangeOfGlyphs (0, -1, 0.0f, dy); @@ -610,22 +607,14 @@ void GlyphArrangement::stretchRangeOfGlyphs (int startIndex, int num, } } -void GlyphArrangement::getBoundingBox (int startIndex, int num, - float& left, - float& top, - float& right, - float& bottom, - const bool includeWhitespace) const +const Rectangle GlyphArrangement::getBoundingBox (int startIndex, int num, const bool includeWhitespace) const { jassert (startIndex >= 0); if (num < 0 || startIndex + num > glyphs.size()) num = glyphs.size() - startIndex; - left = 0.0f; - top = 0.0f; - right = 0.0f; - bottom = 0.0f; + Rectangle result; bool isFirst = true; while (--num >= 0) @@ -637,56 +626,47 @@ void GlyphArrangement::getBoundingBox (int startIndex, int num, if (isFirst) { isFirst = false; - left = pg->getLeft(); - top = pg->getTop(); - right = pg->getRight(); - bottom = pg->getBottom(); + result = pg->getBounds(); } else { - left = jmin (left, pg->getLeft()); - top = jmin (top, pg->getTop()); - right = jmax (right, pg->getRight()); - bottom = jmax (bottom, pg->getBottom()); + result = result.getUnion (pg->getBounds()); } } } + + return result; } -void GlyphArrangement::justifyGlyphs (const int startIndex, - const int num, - const float x, const float y, - const float width, const float height, +void GlyphArrangement::justifyGlyphs (const int startIndex, const int num, + const float x, const float y, const float width, const float height, const Justification& justification) { jassert (num >= 0 && startIndex >= 0); if (glyphs.size() > 0 && num > 0) { - float left, top, right, bottom; - getBoundingBox (startIndex, num, left, top, right, bottom, - ! justification.testFlags (Justification::horizontallyJustified - | Justification::horizontallyCentred)); - + const Rectangle bb (getBoundingBox (startIndex, num, ! justification.testFlags (Justification::horizontallyJustified + | Justification::horizontallyCentred))); float deltaX = 0.0f; if (justification.testFlags (Justification::horizontallyJustified)) - deltaX = x - left; + deltaX = x - bb.getX(); else if (justification.testFlags (Justification::horizontallyCentred)) - deltaX = x + (width - (right - left)) * 0.5f - left; + deltaX = x + (width - bb.getWidth()) * 0.5f - bb.getX(); else if (justification.testFlags (Justification::right)) - deltaX = (x + width) - right; + deltaX = (x + width) - bb.getRight(); else - deltaX = x - left; + deltaX = x - bb.getX(); float deltaY = 0.0f; if (justification.testFlags (Justification::top)) - deltaY = y - top; + deltaY = y - bb.getY(); else if (justification.testFlags (Justification::bottom)) - deltaY = (y + height) - bottom; + deltaY = (y + height) - bb.getBottom(); else - deltaY = y + (height - (bottom - top)) * 0.5f - top; + deltaY = y + (height - bb.getHeight()) * 0.5f - bb.getY(); moveRangeOfGlyphs (startIndex, num, deltaX, deltaY); diff --git a/src/gui/graphics/fonts/juce_GlyphArrangement.h b/src/gui/graphics/fonts/juce_GlyphArrangement.h index 1664156687..0e1763d698 100644 --- a/src/gui/graphics/fonts/juce_GlyphArrangement.h +++ b/src/gui/graphics/fonts/juce_GlyphArrangement.h @@ -56,11 +56,12 @@ public: float getTop() const { return y - font.getAscent(); } /** Returns the y position of the bottom of the glyph. */ float getBottom() const { return y + font.getDescent(); } + /** Returns the bounds of the glyph. */ + const Rectangle getBounds() const { return Rectangle (x, getTop(), w, font.getHeight()); } //============================================================================== /** Shifts the glyph's position by a relative amount. */ - void moveBy (const float deltaX, - const float deltaY); + void moveBy (float deltaX, float deltaY); //============================================================================== /** Draws the glyph into a graphics context. */ @@ -125,7 +126,7 @@ public: //============================================================================== /** Returns the total number of glyphs in the arrangement. */ - int getNumGlyphs() const { return glyphs.size(); } + int getNumGlyphs() const throw() { return glyphs.size(); } /** Returns one of the glyphs from the arrangement. @@ -133,7 +134,7 @@ public: careful not to pass an out-of-range index here, as it doesn't do any bounds-checking. */ - PositionedGlyph& getGlyph (const int index) const; + PositionedGlyph& getGlyph (int index) const; //============================================================================== /** Clears all text from the arrangement and resets it. @@ -150,8 +151,7 @@ public: */ void addLineOfText (const Font& font, const String& text, - const float x, - const float y); + float x, float y); /** Adds a line of text, truncating it if it's wider than a specified size. @@ -161,10 +161,9 @@ public: */ void addCurtailedLineOfText (const Font& font, const String& text, - float x, - const float y, - const float maxWidthPixels, - const bool useEllipsis); + float x, float y, + float maxWidthPixels, + bool useEllipsis); /** Adds some multi-line text, breaking lines at word-boundaries if they are too wide. @@ -182,7 +181,7 @@ public: void addJustifiedText (const Font& font, const String& text, float x, float y, - const float maxLineWidth, + float maxLineWidth, const Justification& horizontalLayout); /** Tries to fit some text withing a given space. @@ -202,12 +201,10 @@ public: */ void addFittedText (const Font& font, const String& text, - const float x, const float y, - const float width, const float height, + float x, float y, float width, float height, const Justification& layout, int maximumLinesToUse, - const float minimumHorizontalScale = 0.7f); - + float minimumHorizontalScale = 0.7f); /** Appends another glyph arrangement to this one. */ void addGlyphArrangement (const GlyphArrangement& other); @@ -246,20 +243,10 @@ public: @param startIndex the first glyph to test @param numGlyphs the number of glyphs to include; if this is < 0, all glyphs after startIndex will be included - @param left on return, the leftmost co-ordinate of the rectangle - @param top on return, the top co-ordinate of the rectangle - @param right on return, the rightmost co-ordinate of the rectangle - @param bottom on return, the bottom co-ordinate of the rectangle @param includeWhitespace if true, the extent of any whitespace characters will also be taken into account */ - void getBoundingBox (int startIndex, - int numGlyphs, - float& left, - float& top, - float& right, - float& bottom, - const bool includeWhitespace) const; + const Rectangle getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const; /** Shifts a set of glyphs by a given amount. @@ -270,8 +257,7 @@ public: @param deltaY the amount to add to their y-positions */ void moveRangeOfGlyphs (int startIndex, int numGlyphs, - const float deltaX, - const float deltaY); + float deltaX, float deltaY); /** Removes a set of glyphs from the arrangement. @@ -289,7 +275,7 @@ public: @param horizontalScaleFactor how much to scale their horizontal width by */ void stretchRangeOfGlyphs (int startIndex, int numGlyphs, - const float horizontalScaleFactor); + float horizontalScaleFactor); /** Justifies a set of glyphs within a given space. @@ -299,11 +285,8 @@ public: If the Justification::horizontallyJustified flag is specified, each line will be stretched out to fill the specified width. */ - void justifyGlyphs (const int startIndex, const int numGlyphs, - const float x, - const float y, - const float width, - const float height, + void justifyGlyphs (int startIndex, int numGlyphs, + float x, float y, float width, float height, const Justification& justification); @@ -313,10 +296,10 @@ public: private: OwnedArray glyphs; - int insertEllipsis (const Font& font, const float maxXPos, const int startIndex, int endIndex); + int insertEllipsis (const Font& font, float maxXPos, int startIndex, int endIndex); int fitLineIntoSpace (int start, int numGlyphs, float x, float y, float w, float h, const Font& font, const Justification& justification, float minimumHorizontalScale); - void spreadOutLine (const int start, const int numGlyphs, const float targetWidth); + void spreadOutLine (int start, int numGlyphs, float targetWidth); }; diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index 890ec6af0c..694a27e0f6 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -115,12 +115,14 @@ namespace PNGHelpers static void readCallback (png_structp png, png_bytep data, png_size_t length) { - static_cast (png->io_ptr)->read (data, (int) length); + if (png != 0 && png->io_ptr != 0) + static_cast (png->io_ptr)->read (data, (int) length); } static void writeDataCallback (png_structp png, png_bytep data, png_size_t length) { - static_cast (png->io_ptr)->write (data, (int) length); + if (png != 0 && png->io_ptr != 0) + static_cast (png->io_ptr)->write (data, (int) length); } struct PNGErrorStruct {}; diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index 3463c98642..60fb0679db 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -38,10 +38,11 @@ namespace Atoms enum ProtocolItems { TAKE_FOCUS = 0, - DELETE_WINDOW = 1 + DELETE_WINDOW = 1, + PING = 2 }; - static Atom Protocols, ProtocolList[2], ChangeState, State, + static Atom Protocols, ProtocolList[3], ChangeState, State, ActiveWin, Pid, WindowType, WindowState, XdndAware, XdndEnter, XdndLeave, XdndPosition, XdndStatus, XdndDrop, XdndFinished, XdndSelection, XdndTypeList, XdndActionList, @@ -63,12 +64,13 @@ namespace Atoms Protocols = XInternAtom (display, "WM_PROTOCOLS", True); ProtocolList [TAKE_FOCUS] = XInternAtom (display, "WM_TAKE_FOCUS", True); ProtocolList [DELETE_WINDOW] = XInternAtom (display, "WM_DELETE_WINDOW", True); + ProtocolList [PING] = XInternAtom (display, "_NET_WM_PING", True); ChangeState = XInternAtom (display, "WM_CHANGE_STATE", True); State = XInternAtom (display, "WM_STATE", True); ActiveWin = XInternAtom (display, "_NET_ACTIVE_WINDOW", False); Pid = XInternAtom (display, "_NET_WM_PID", False); WindowType = XInternAtom (display, "_NET_WM_WINDOW_TYPE", True); - WindowState = XInternAtom (display, "_NET_WM_WINDOW_STATE", True); + WindowState = XInternAtom (display, "_NET_WM_STATE", True); XdndAware = XInternAtom (display, "XdndAware", False); XdndEnter = XInternAtom (display, "XdndEnter", False); @@ -1580,7 +1582,6 @@ public: } case ReparentNotify: - case GravityNotify: { parentWindow = 0; Window wRoot = 0; @@ -1601,6 +1602,14 @@ public: break; } + case GravityNotify: + { + updateBounds(); + updateBorderSize(); + handleMovedOrResized(); + break; + } + case MapNotify: mapped = true; handleBroughtToFront(); @@ -1633,7 +1642,16 @@ public: { const Atom atom = (Atom) clientMsg->data.l[0]; - if (atom == Atoms::ProtocolList [Atoms::TAKE_FOCUS]) + if (atom == Atoms::ProtocolList [Atoms::PING]) + { + Window root = RootWindow (display, DefaultScreen (display)); + + event->xclient.window = root; + + XSendEvent (display, root, False, NoEventMask, event); + XFlush (display); + } + else if (atom == Atoms::ProtocolList [Atoms::TAKE_FOCUS]) { XWindowAttributes atts; @@ -2175,11 +2193,10 @@ private: if ((styleFlags & windowAppearsOnTaskbar) == 0) { -/* Atom skipTaskbar = XInternAtom (display, "_NET_WM_STATE_SKIP_TASKBAR", False); + Atom skipTaskbar = XInternAtom (display, "_NET_WM_STATE_SKIP_TASKBAR", False); - XChangeProperty (display, wndH, wm_WindowState, XA_ATOM, 32, PropModeReplace, + XChangeProperty (display, wndH, Atoms::WindowState, XA_ATOM, 32, PropModeReplace, (unsigned char*) &skipTaskbar, 1); -*/ } } diff --git a/src/native/windows/juce_win32_OpenGLComponent.cpp b/src/native/windows/juce_win32_OpenGLComponent.cpp index 2ad42229b1..1232b0e5d1 100644 --- a/src/native/windows/juce_win32_OpenGLComponent.cpp +++ b/src/native/windows/juce_win32_OpenGLComponent.cpp @@ -297,7 +297,7 @@ public: SwapBuffers (dc); } - bool setSwapInterval (const int numFramesPerSwap) + bool setSwapInterval (int numFramesPerSwap) { makeActive(); diff --git a/src/threads/juce_Thread.h b/src/threads/juce_Thread.h index 58785fd056..488aee6b7f 100644 --- a/src/threads/juce_Thread.h +++ b/src/threads/juce_Thread.h @@ -126,9 +126,9 @@ public: Calling this means that the threadShouldExit() method will then return true. The thread should be regularly checking this to see whether it should exit. - + If your thread makes use of wait(), you might want to call notify() after calling - this method, to interrupt any waits that might be in progress, and allow it + this method, to interrupt any waits that might be in progress, and allow it to reach a point where it can exit. @see threadShouldExit