diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index cec90a1ea0..651f2be0e5 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -5611,23 +5611,23 @@ int OutputStream::writeFromInputStream (InputStream& source, int numBytesToWrite return numWritten; } -OutputStream& operator<< (OutputStream& stream, const int number) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const int number) { return stream << String (number); } -OutputStream& operator<< (OutputStream& stream, const double number) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const double number) { return stream << String (number); } -OutputStream& operator<< (OutputStream& stream, const char character) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char character) { stream.writeByte (character); return stream; } -OutputStream& operator<< (OutputStream& stream, const char* const text) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const text) { stream.write (text, (int) strlen (text)); return stream; @@ -10842,52 +10842,52 @@ String& String::operator= (const String& other) throw() return *this; } -bool operator== (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator== (const String& string1, const String& string2) throw() { return string1.compare (string2) == 0; } -bool operator== (const String& string1, const char* string2) throw() +bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw() { return string1.compare (string2) == 0; } -bool operator== (const String& string1, const juce_wchar* string2) throw() +bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw() { return string1.compare (string2) == 0; } -bool operator!= (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) throw() { return string1.compare (string2) != 0; } -bool operator!= (const String& string1, const char* string2) throw() +bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw() { return string1.compare (string2) != 0; } -bool operator!= (const String& string1, const juce_wchar* string2) throw() +bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw() { return string1.compare (string2) != 0; } -bool operator> (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) throw() { return string1.compare (string2) > 0; } -bool operator< (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator< (const String& string1, const String& string2) throw() { return string1.compare (string2) < 0; } -bool operator>= (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator>= (const String& string1, const String& string2) throw() { return string1.compare (string2) >= 0; } -bool operator<= (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator<= (const String& string1, const String& string2) throw() { return string1.compare (string2) <= 0; } @@ -10998,114 +10998,114 @@ void String::append (const tchar* const other, const int howMany) } } -const String operator+ (const char* const string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const char* const string1, const String& string2) { String s (string1); return s += string2; } -const String operator+ (const juce_wchar* const string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const juce_wchar* const string1, const String& string2) { String s (string1); return s += string2; } -const String operator+ (const char string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const char string1, const String& string2) { return String::charToString (string1) + string2; } -const String operator+ (const juce_wchar string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) { return String::charToString (string1) + string2; } -const String operator+ (String string1, const String& string2) +const String JUCE_CALLTYPE operator+ (String string1, const String& string2) { return string1 += string2; } -const String operator+ (String string1, const char* const string2) +const String JUCE_CALLTYPE operator+ (String string1, const char* const string2) { return string1 += string2; } -const String operator+ (String string1, const juce_wchar* const string2) +const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* const string2) { return string1 += string2; } -const String operator+ (String string1, const char string2) +const String JUCE_CALLTYPE operator+ (String string1, const char string2) { return string1 += string2; } -const String operator+ (String string1, const juce_wchar string2) +const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar string2) { return string1 += string2; } -String& operator<< (String& string1, const char characterToAppend) +String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend) { return string1 += characterToAppend; } -String& operator<< (String& string1, const juce_wchar characterToAppend) +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend) { return string1 += characterToAppend; } -String& operator<< (String& string1, const char* const string2) +String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2) { return string1 += string2; } -String& operator<< (String& string1, const juce_wchar* const string2) +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2) { return string1 += string2; } -String& operator<< (String& string1, const String& string2) +String& JUCE_CALLTYPE operator<< (String& string1, const String& string2) { return string1 += string2; } -String& operator<< (String& string1, const short number) +String& JUCE_CALLTYPE operator<< (String& string1, const short number) { return string1 += (int) number; } -String& operator<< (String& string1, const int number) +String& JUCE_CALLTYPE operator<< (String& string1, const int number) { return string1 += number; } -String& operator<< (String& string1, const unsigned int number) +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned int number) { return string1 += number; } -String& operator<< (String& string1, const long number) +String& JUCE_CALLTYPE operator<< (String& string1, const long number) { return string1 += (int) number; } -String& operator<< (String& string1, const unsigned long number) +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned long number) { return string1 += (unsigned int) number; } -String& operator<< (String& string1, const float number) +String& JUCE_CALLTYPE operator<< (String& string1, const float number) { return string1 += String (number); } -String& operator<< (String& string1, const double number) +String& JUCE_CALLTYPE operator<< (String& string1, const double number) { return string1 += String (number); } -OutputStream& operator<< (OutputStream& stream, const String& text) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text) { // (This avoids using toUTF8() to prevent the memory bloat that it would leave behind // if lots of large, persistent strings were to be written to streams). @@ -40015,108 +40015,95 @@ void Component::internalRepaint (int x, int y, int w, int h) } } -void Component::paintEntireComponent (Graphics& originalContext) +void Component::renderComponent (Graphics& g) { - jassert (! originalContext.isClipEmpty()); + const Rectangle clipBounds (g.getClipBounds()); -#ifdef JUCE_DEBUG - flags.isInsidePaintCall = true; -#endif + g.saveState(); + clipObscuredRegions (g, clipBounds, 0, 0); - Graphics* g = &originalContext; - Image* effectImage = 0; - - if (effect_ != 0) + if (! g.isClipEmpty()) { - effectImage = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - getWidth(), getHeight(), - ! flags.opaqueFlag); - - g = new Graphics (*effectImage); - } - - g->saveState(); - clipObscuredRegions (*g, g->getClipBounds(), 0, 0); - - if (! g->isClipEmpty()) - { - if (bufferedImage_ != 0) + if (flags.bufferToImageFlag) { - g->setColour (Colours::black); - g->drawImageAt (bufferedImage_, 0, 0); + if (bufferedImage_ == 0) + { + bufferedImage_ = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, + getWidth(), getHeight(), ! flags.opaqueFlag); + + Graphics imG (*bufferedImage_); + paint (imG); + } + + g.setColour (Colours::black); + g.drawImageAt (bufferedImage_, 0, 0); } else { - if (flags.bufferToImageFlag) - { - if (bufferedImage_ == 0) - { - bufferedImage_ = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - getWidth(), getHeight(), ! flags.opaqueFlag); - - Graphics imG (*bufferedImage_); - paint (imG); - } - - g->setColour (Colours::black); - g->drawImageAt (bufferedImage_, 0, 0); - } - else - { - paint (*g); - g->resetToDefaultState(); - } + paint (g); } } - g->restoreState(); + g.restoreState(); for (int i = 0; i < childComponentList_.size(); ++i) { Component* const child = childComponentList_.getUnchecked (i); - if (child->isVisible()) + if (child->isVisible() && clipBounds.intersects (child->getBounds())) { - g->saveState(); + g.saveState(); - if (g->reduceClipRegion (child->getX(), child->getY(), - child->getWidth(), child->getHeight())) + if (g.reduceClipRegion (child->getX(), child->getY(), + child->getWidth(), child->getHeight())) { for (int j = i + 1; j < childComponentList_.size(); ++j) { const Component* const sibling = childComponentList_.getUnchecked (j); if (sibling->flags.opaqueFlag && sibling->isVisible()) - g->excludeClipRegion (sibling->getX(), sibling->getY(), - sibling->getWidth(), sibling->getHeight()); + g.excludeClipRegion (sibling->getBounds()); } - if (! g->isClipEmpty()) + if (! g.isClipEmpty()) { - g->setOrigin (child->getX(), child->getY()); - - child->paintEntireComponent (*g); + g.setOrigin (child->getX(), child->getY()); + child->paintEntireComponent (g); } } - g->restoreState(); + g.restoreState(); } } - JUCE_TRY - { - g->saveState(); - paintOverChildren (*g); - g->restoreState(); - } - JUCE_CATCH_EXCEPTION + g.saveState(); + paintOverChildren (g); + g.restoreState(); +} + +void Component::paintEntireComponent (Graphics& g) +{ + jassert (! g.isClipEmpty()); + +#ifdef JUCE_DEBUG + flags.isInsidePaintCall = true; +#endif if (effect_ != 0) { - delete g; + ScopedPointer effectImage (Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, + getWidth(), getHeight(), + ! flags.opaqueFlag)); + { + Graphics g2 (*effectImage); + renderComponent (g2); + } - effect_->applyEffect (*effectImage, originalContext); - delete effectImage; + effect_->applyEffect (*effectImage, g); + } + else + { + renderComponent (g); } #ifdef JUCE_DEBUG @@ -40132,18 +40119,16 @@ Image* Component::createComponentSnapshot (const Rectangle& areaToGrab, if (clipImageToComponentBounds) r = r.getIntersection (Rectangle (0, 0, getWidth(), getHeight())); - Image* const componentImage = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - jmax (1, r.getWidth()), - jmax (1, r.getHeight()), - true); + ScopedPointer componentImage (Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, + jmax (1, r.getWidth()), + jmax (1, r.getHeight()), + true)); Graphics imageContext (*componentImage); - imageContext.setOrigin (-r.getX(), - -r.getY()); - + imageContext.setOrigin (-r.getX(), -r.getY()); paintEntireComponent (imageContext); - return componentImage; + return componentImage.release(); } void Component::setComponentEffect (ImageEffectFilter* const effect) @@ -40297,21 +40282,17 @@ void Component::clipObscuredRegions (Graphics& g, const Rectangle& clipRect if (c->isVisible()) { - Rectangle newClip (clipRect.getIntersection (c->bounds_)); + const Rectangle newClip (clipRect.getIntersection (c->bounds_)); if (! newClip.isEmpty()) { if (c->isOpaque()) { - g.excludeClipRegion (deltaX + newClip.getX(), - deltaY + newClip.getY(), - newClip.getWidth(), - newClip.getHeight()); + g.excludeClipRegion (newClip.translated (deltaX, deltaY)); } else { - newClip.translate (-c->getX(), -c->getY()); - c->clipObscuredRegions (g, newClip, + c->clipObscuredRegions (g, newClip.translated (-c->getX(), -c->getY()), c->getX() + deltaX, c->getY() + deltaY); } @@ -40929,6 +40910,9 @@ void Component::internalMouseUp (MouseInputSource& source, const Point& rel mouseDoubleClick (me); + if (checker.shouldBailOut()) + return; + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); if (checker.shouldBailOut()) @@ -40939,9 +40923,6 @@ void Component::internalMouseUp (MouseInputSource& source, const Point& rel if (checker.shouldBailOut()) return; - if (mouseListeners_ == 0) - return; - MouseListener* const ml = (MouseListener*)((*mouseListeners_)[i]); if (ml != 0) ml->mouseDoubleClick (me); @@ -76051,7 +76032,6 @@ ComponentPeer::ComponentPeer (Component* const component_, styleFlags (styleFlags_), lastPaintTime (0), constrainer (0), - lastFocusedComponent (0), lastDragAndDropCompUnderMouse (0), fakeMouseMessageSent (false), isWindowMinimised (false) @@ -76366,7 +76346,7 @@ void ComponentPeer::handleFocusLoss() Component* ComponentPeer::getLastFocusedSubcomponent() const throw() { return (component->isParentOf (lastFocusedComponent) && lastFocusedComponent->isShowing()) - ? lastFocusedComponent + ? static_cast (lastFocusedComponent) : component; } @@ -79943,14 +79923,12 @@ Graphics::Graphics (Image& imageToDrawOnto) throw() contextToDelete (context), saveStatePending (false) { - resetToDefaultState(); } Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw() : context (internalContext), saveStatePending (false) { - resetToDefaultState(); } Graphics::~Graphics() throw() @@ -79997,11 +79975,10 @@ bool Graphics::reduceClipRegion (const Image& image, const Rectangle& sourc return ! context->isClipEmpty(); } -void Graphics::excludeClipRegion (const int x, const int y, - const int w, const int h) throw() +void Graphics::excludeClipRegion (const Rectangle& rectangleToExclude) throw() { saveStateIfPending(); - context->excludeClipRectangle (Rectangle (x, y, w, h)); + context->excludeClipRectangle (rectangleToExclude); } bool Graphics::isClipEmpty() const throw() @@ -227334,7 +227311,7 @@ public: const int rw = roundToInt (dw), rh = roundToInt (dh); g.saveState(); - g.excludeClipRegion (rx, ry, rw, rh); + g.excludeClipRegion (Rectangle (rx, ry, rw, rh)); g.fillAll (Colours::black); g.restoreState(); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 4edc763f2f..b5e349595b 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -1397,49 +1397,49 @@ private: void dupeInternalIfMultiplyReferenced() throw(); }; -const String operator+ (const char* string1, const String& string2); -const String operator+ (const juce_wchar* string1, const String& string2); -const String operator+ (char string1, const String& string2); -const String operator+ (juce_wchar string1, const String& string2); +const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); +const String JUCE_CALLTYPE operator+ (const juce_wchar* string1, const String& string2); +const String JUCE_CALLTYPE operator+ (char string1, const String& string2); +const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); -const String operator+ (String string1, const String& string2); -const String operator+ (String string1, const char* string2); -const String operator+ (String string1, const juce_wchar* string2); -const String operator+ (String string1, char characterToAppend); -const String operator+ (String string1, juce_wchar characterToAppend); +const String JUCE_CALLTYPE operator+ (String string1, const String& string2); +const String JUCE_CALLTYPE operator+ (String string1, const char* string2); +const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* string2); +const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); +const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); -String& operator<< (String& string1, const char characterToAppend); -String& operator<< (String& string1, const juce_wchar characterToAppend); -String& operator<< (String& string1, const char* const string2); -String& operator<< (String& string1, const juce_wchar* const string2); -String& operator<< (String& string1, const String& string2); +String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend); +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend); +String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2); +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2); +String& JUCE_CALLTYPE operator<< (String& string1, const String& string2); -String& operator<< (String& string1, const short number); -String& operator<< (String& string1, const int number); -String& operator<< (String& string1, const unsigned int number); -String& operator<< (String& string1, const long number); -String& operator<< (String& string1, const unsigned long number); -String& operator<< (String& string1, const float number); -String& operator<< (String& string1, const double number); +String& JUCE_CALLTYPE operator<< (String& string1, const short number); +String& JUCE_CALLTYPE operator<< (String& string1, const int number); +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned int number); +String& JUCE_CALLTYPE operator<< (String& string1, const long number); +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned long number); +String& JUCE_CALLTYPE operator<< (String& string1, const float number); +String& JUCE_CALLTYPE operator<< (String& string1, const double number); -bool operator== (const String& string1, const String& string2) throw(); -bool operator== (const String& string1, const char* string2) throw(); -bool operator== (const String& string1, const juce_wchar* string2) throw(); -bool operator!= (const String& string1, const String& string2) throw(); -bool operator!= (const String& string1, const char* string2) throw(); -bool operator!= (const String& string1, const juce_wchar* string2) throw(); -bool operator> (const String& string1, const String& string2) throw(); -bool operator< (const String& string1, const String& string2) throw(); -bool operator>= (const String& string1, const String& string2) throw(); -bool operator<= (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator== (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw(); +bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw(); +bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw(); +bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw(); +bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator< (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator>= (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator<= (const String& string1, const String& string2) throw(); template -std::basic_ostream & operator<< (std::basic_ostream & stream, const String& stringToWrite) +std::basic_ostream & JUCE_CALLTYPE operator<< (std::basic_ostream & stream, const String& stringToWrite) { return stream << stringToWrite.toUTF8(); } -OutputStream& operator<< (OutputStream& stream, const String& text); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text); #endif // __JUCE_STRING_JUCEHEADER__ /*** End of inlined file: juce_String.h ***/ @@ -2860,13 +2860,13 @@ public: juce_UseDebuggingNewOperator }; -OutputStream& operator<< (OutputStream& stream, const int number); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const int number); -OutputStream& operator<< (OutputStream& stream, const double number); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const double number); -OutputStream& operator<< (OutputStream& stream, const char character); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char character); -OutputStream& operator<< (OutputStream& stream, const char* const text); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const text); #endif // __JUCE_OUTPUTSTREAM_JUCEHEADER__ /*** End of inlined file: juce_OutputStream.h ***/ @@ -11976,8 +11976,7 @@ public: bool reduceClipRegion (const Image& image, const Rectangle& sourceClipRegion, const AffineTransform& transform) throw(); - void excludeClipRegion (const int x, const int y, - const int width, const int height) throw(); + void excludeClipRegion (const Rectangle& rectangleToExclude) throw(); bool isClipEmpty() const throw(); @@ -12696,6 +12695,7 @@ private: void internalModifierKeysChanged(); void internalChildrenChanged(); void internalHierarchyChanged(); + void renderComponent (Graphics& context); void sendMovedResizedMessages (const bool wasMoved, const bool wasResized); void repaintParent() throw(); void sendFakeMouseMove() const; @@ -27214,8 +27214,7 @@ protected: private: - Component* lastFocusedComponent; - Component::SafePointer dragAndDropTargetComponent; + Component::SafePointer lastFocusedComponent, dragAndDropTargetComponent; Component* lastDragAndDropCompUnderMouse; bool fakeMouseMessageSent : 1, isWindowMinimised : 1; diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 708ca18bbb..07f6660620 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -1595,108 +1595,95 @@ void Component::internalRepaint (int x, int y, int w, int h) } //============================================================================== -void Component::paintEntireComponent (Graphics& originalContext) +void Component::renderComponent (Graphics& g) { - jassert (! originalContext.isClipEmpty()); + const Rectangle clipBounds (g.getClipBounds()); -#ifdef JUCE_DEBUG - flags.isInsidePaintCall = true; -#endif + g.saveState(); + clipObscuredRegions (g, clipBounds, 0, 0); - Graphics* g = &originalContext; - Image* effectImage = 0; - - if (effect_ != 0) + if (! g.isClipEmpty()) { - effectImage = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - getWidth(), getHeight(), - ! flags.opaqueFlag); - - g = new Graphics (*effectImage); - } - - g->saveState(); - clipObscuredRegions (*g, g->getClipBounds(), 0, 0); - - if (! g->isClipEmpty()) - { - if (bufferedImage_ != 0) + if (flags.bufferToImageFlag) { - g->setColour (Colours::black); - g->drawImageAt (bufferedImage_, 0, 0); + if (bufferedImage_ == 0) + { + bufferedImage_ = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, + getWidth(), getHeight(), ! flags.opaqueFlag); + + Graphics imG (*bufferedImage_); + paint (imG); + } + + g.setColour (Colours::black); + g.drawImageAt (bufferedImage_, 0, 0); } else { - if (flags.bufferToImageFlag) - { - if (bufferedImage_ == 0) - { - bufferedImage_ = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - getWidth(), getHeight(), ! flags.opaqueFlag); - - Graphics imG (*bufferedImage_); - paint (imG); - } - - g->setColour (Colours::black); - g->drawImageAt (bufferedImage_, 0, 0); - } - else - { - paint (*g); - g->resetToDefaultState(); - } + paint (g); } } - g->restoreState(); + g.restoreState(); for (int i = 0; i < childComponentList_.size(); ++i) { Component* const child = childComponentList_.getUnchecked (i); - if (child->isVisible()) + if (child->isVisible() && clipBounds.intersects (child->getBounds())) { - g->saveState(); + g.saveState(); - if (g->reduceClipRegion (child->getX(), child->getY(), - child->getWidth(), child->getHeight())) + if (g.reduceClipRegion (child->getX(), child->getY(), + child->getWidth(), child->getHeight())) { for (int j = i + 1; j < childComponentList_.size(); ++j) { const Component* const sibling = childComponentList_.getUnchecked (j); if (sibling->flags.opaqueFlag && sibling->isVisible()) - g->excludeClipRegion (sibling->getX(), sibling->getY(), - sibling->getWidth(), sibling->getHeight()); + g.excludeClipRegion (sibling->getBounds()); } - if (! g->isClipEmpty()) + if (! g.isClipEmpty()) { - g->setOrigin (child->getX(), child->getY()); - - child->paintEntireComponent (*g); + g.setOrigin (child->getX(), child->getY()); + child->paintEntireComponent (g); } } - g->restoreState(); + g.restoreState(); } } - JUCE_TRY - { - g->saveState(); - paintOverChildren (*g); - g->restoreState(); - } - JUCE_CATCH_EXCEPTION + g.saveState(); + paintOverChildren (g); + g.restoreState(); +} + +void Component::paintEntireComponent (Graphics& g) +{ + jassert (! g.isClipEmpty()); + +#ifdef JUCE_DEBUG + flags.isInsidePaintCall = true; +#endif if (effect_ != 0) { - delete g; + ScopedPointer effectImage (Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, + getWidth(), getHeight(), + ! flags.opaqueFlag)); + { + Graphics g2 (*effectImage); + renderComponent (g2); + } - effect_->applyEffect (*effectImage, originalContext); - delete effectImage; + effect_->applyEffect (*effectImage, g); + } + else + { + renderComponent (g); } #ifdef JUCE_DEBUG @@ -1713,18 +1700,16 @@ Image* Component::createComponentSnapshot (const Rectangle& areaToGrab, if (clipImageToComponentBounds) r = r.getIntersection (Rectangle (0, 0, getWidth(), getHeight())); - Image* const componentImage = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, - jmax (1, r.getWidth()), - jmax (1, r.getHeight()), - true); + ScopedPointer componentImage (Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB, + jmax (1, r.getWidth()), + jmax (1, r.getHeight()), + true)); Graphics imageContext (*componentImage); - imageContext.setOrigin (-r.getX(), - -r.getY()); - + imageContext.setOrigin (-r.getX(), -r.getY()); paintEntireComponent (imageContext); - return componentImage; + return componentImage.release(); } void Component::setComponentEffect (ImageEffectFilter* const effect) @@ -1880,21 +1865,17 @@ void Component::clipObscuredRegions (Graphics& g, const Rectangle& clipRect if (c->isVisible()) { - Rectangle newClip (clipRect.getIntersection (c->bounds_)); + const Rectangle newClip (clipRect.getIntersection (c->bounds_)); if (! newClip.isEmpty()) { if (c->isOpaque()) { - g.excludeClipRegion (deltaX + newClip.getX(), - deltaY + newClip.getY(), - newClip.getWidth(), - newClip.getHeight()); + g.excludeClipRegion (newClip.translated (deltaX, deltaY)); } else { - newClip.translate (-c->getX(), -c->getY()); - c->clipObscuredRegions (g, newClip, + c->clipObscuredRegions (g, newClip.translated (-c->getX(), -c->getY()), c->getX() + deltaX, c->getY() + deltaY); } @@ -2526,6 +2507,9 @@ void Component::internalMouseUp (MouseInputSource& source, const Point& rel mouseDoubleClick (me); + if (checker.shouldBailOut()) + return; + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); if (checker.shouldBailOut()) @@ -2536,9 +2520,6 @@ void Component::internalMouseUp (MouseInputSource& source, const Point& rel if (checker.shouldBailOut()) return; - if (mouseListeners_ == 0) - return; - MouseListener* const ml = (MouseListener*)((*mouseListeners_)[i]); if (ml != 0) ml->mouseDoubleClick (me); diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index bca18df31f..af8c739c2a 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -2055,6 +2055,7 @@ private: void internalModifierKeysChanged(); void internalChildrenChanged(); void internalHierarchyChanged(); + void renderComponent (Graphics& context); void sendMovedResizedMessages (const bool wasMoved, const bool wasResized); void repaintParent() throw(); void sendFakeMouseMove() const; diff --git a/src/gui/components/windows/juce_ComponentPeer.cpp b/src/gui/components/windows/juce_ComponentPeer.cpp index 1bfa5eba95..101840e9d5 100644 --- a/src/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/gui/components/windows/juce_ComponentPeer.cpp @@ -51,7 +51,6 @@ ComponentPeer::ComponentPeer (Component* const component_, styleFlags (styleFlags_), lastPaintTime (0), constrainer (0), - lastFocusedComponent (0), lastDragAndDropCompUnderMouse (0), fakeMouseMessageSent (false), isWindowMinimised (false) @@ -370,7 +369,7 @@ void ComponentPeer::handleFocusLoss() Component* ComponentPeer::getLastFocusedSubcomponent() const throw() { return (component->isParentOf (lastFocusedComponent) && lastFocusedComponent->isShowing()) - ? lastFocusedComponent + ? static_cast (lastFocusedComponent) : component; } diff --git a/src/gui/components/windows/juce_ComponentPeer.h b/src/gui/components/windows/juce_ComponentPeer.h index 89aa636e4b..178a75830c 100644 --- a/src/gui/components/windows/juce_ComponentPeer.h +++ b/src/gui/components/windows/juce_ComponentPeer.h @@ -365,8 +365,7 @@ protected: private: //============================================================================== - Component* lastFocusedComponent; - Component::SafePointer dragAndDropTargetComponent; + Component::SafePointer lastFocusedComponent, dragAndDropTargetComponent; Component* lastDragAndDropCompUnderMouse; bool fakeMouseMessageSent : 1, isWindowMinimised : 1; diff --git a/src/gui/graphics/contexts/juce_Graphics.cpp b/src/gui/graphics/contexts/juce_Graphics.cpp index 8bb2f40490..883f7f47a3 100644 --- a/src/gui/graphics/contexts/juce_Graphics.cpp +++ b/src/gui/graphics/contexts/juce_Graphics.cpp @@ -61,14 +61,12 @@ Graphics::Graphics (Image& imageToDrawOnto) throw() contextToDelete (context), saveStatePending (false) { - resetToDefaultState(); } Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw() : context (internalContext), saveStatePending (false) { - resetToDefaultState(); } Graphics::~Graphics() throw() @@ -116,11 +114,10 @@ bool Graphics::reduceClipRegion (const Image& image, const Rectangle& sourc return ! context->isClipEmpty(); } -void Graphics::excludeClipRegion (const int x, const int y, - const int w, const int h) throw() +void Graphics::excludeClipRegion (const Rectangle& rectangleToExclude) throw() { saveStateIfPending(); - context->excludeClipRectangle (Rectangle (x, y, w, h)); + context->excludeClipRectangle (rectangleToExclude); } bool Graphics::isClipEmpty() const throw() diff --git a/src/gui/graphics/contexts/juce_Graphics.h b/src/gui/graphics/contexts/juce_Graphics.h index b3f2cd3916..9b54fa82fa 100644 --- a/src/gui/graphics/contexts/juce_Graphics.h +++ b/src/gui/graphics/contexts/juce_Graphics.h @@ -665,8 +665,7 @@ public: const AffineTransform& transform) throw(); /** Excludes a rectangle to stop it being drawn into. */ - void excludeClipRegion (const int x, const int y, - const int width, const int height) throw(); + void excludeClipRegion (const Rectangle& rectangleToExclude) throw(); /** Returns true if no drawing can be done because the clip region is zero. */ bool isClipEmpty() const throw(); diff --git a/src/io/streams/juce_OutputStream.cpp b/src/io/streams/juce_OutputStream.cpp index 1d7b96f3e4..387ebea483 100644 --- a/src/io/streams/juce_OutputStream.cpp +++ b/src/io/streams/juce_OutputStream.cpp @@ -254,23 +254,23 @@ int OutputStream::writeFromInputStream (InputStream& source, int numBytesToWrite } //============================================================================== -OutputStream& operator<< (OutputStream& stream, const int number) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const int number) { return stream << String (number); } -OutputStream& operator<< (OutputStream& stream, const double number) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const double number) { return stream << String (number); } -OutputStream& operator<< (OutputStream& stream, const char character) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char character) { stream.writeByte (character); return stream; } -OutputStream& operator<< (OutputStream& stream, const char* const text) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const text) { stream.write (text, (int) strlen (text)); return stream; diff --git a/src/io/streams/juce_OutputStream.h b/src/io/streams/juce_OutputStream.h index 5ee7d5f9dc..8446dab571 100644 --- a/src/io/streams/juce_OutputStream.h +++ b/src/io/streams/juce_OutputStream.h @@ -207,16 +207,16 @@ public: //============================================================================== /** Writes a number to a stream as 8-bit characters in the default system encoding. */ -OutputStream& operator<< (OutputStream& stream, const int number); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const int number); /** Writes a number to a stream as 8-bit characters in the default system encoding. */ -OutputStream& operator<< (OutputStream& stream, const double number); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const double number); /** Writes a character to a stream. */ -OutputStream& operator<< (OutputStream& stream, const char character); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char character); /** Writes a null-terminated text string to a stream. */ -OutputStream& operator<< (OutputStream& stream, const char* const text); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const text); diff --git a/src/native/windows/juce_win32_CameraDevice.cpp b/src/native/windows/juce_win32_CameraDevice.cpp index b7f7ada39f..98f254e4b0 100644 --- a/src/native/windows/juce_win32_CameraDevice.cpp +++ b/src/native/windows/juce_win32_CameraDevice.cpp @@ -244,7 +244,7 @@ public: const int rw = roundToInt (dw), rh = roundToInt (dh); g.saveState(); - g.excludeClipRegion (rx, ry, rw, rh); + g.excludeClipRegion (Rectangle (rx, ry, rw, rh)); g.fillAll (Colours::black); g.restoreState(); diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index aec8bad7cf..5ced2e7490 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -507,52 +507,52 @@ String& String::operator= (const String& other) throw() } //============================================================================== -bool operator== (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator== (const String& string1, const String& string2) throw() { return string1.compare (string2) == 0; } -bool operator== (const String& string1, const char* string2) throw() +bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw() { return string1.compare (string2) == 0; } -bool operator== (const String& string1, const juce_wchar* string2) throw() +bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw() { return string1.compare (string2) == 0; } -bool operator!= (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) throw() { return string1.compare (string2) != 0; } -bool operator!= (const String& string1, const char* string2) throw() +bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw() { return string1.compare (string2) != 0; } -bool operator!= (const String& string1, const juce_wchar* string2) throw() +bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw() { return string1.compare (string2) != 0; } -bool operator> (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) throw() { return string1.compare (string2) > 0; } -bool operator< (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator< (const String& string1, const String& string2) throw() { return string1.compare (string2) < 0; } -bool operator>= (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator>= (const String& string1, const String& string2) throw() { return string1.compare (string2) >= 0; } -bool operator<= (const String& string1, const String& string2) throw() +bool JUCE_CALLTYPE operator<= (const String& string1, const String& string2) throw() { return string1.compare (string2) <= 0; } @@ -665,114 +665,114 @@ void String::append (const tchar* const other, const int howMany) } //============================================================================== -const String operator+ (const char* const string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const char* const string1, const String& string2) { String s (string1); return s += string2; } -const String operator+ (const juce_wchar* const string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const juce_wchar* const string1, const String& string2) { String s (string1); return s += string2; } -const String operator+ (const char string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const char string1, const String& string2) { return String::charToString (string1) + string2; } -const String operator+ (const juce_wchar string1, const String& string2) +const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) { return String::charToString (string1) + string2; } -const String operator+ (String string1, const String& string2) +const String JUCE_CALLTYPE operator+ (String string1, const String& string2) { return string1 += string2; } -const String operator+ (String string1, const char* const string2) +const String JUCE_CALLTYPE operator+ (String string1, const char* const string2) { return string1 += string2; } -const String operator+ (String string1, const juce_wchar* const string2) +const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* const string2) { return string1 += string2; } -const String operator+ (String string1, const char string2) +const String JUCE_CALLTYPE operator+ (String string1, const char string2) { return string1 += string2; } -const String operator+ (String string1, const juce_wchar string2) +const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar string2) { return string1 += string2; } -String& operator<< (String& string1, const char characterToAppend) +String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend) { return string1 += characterToAppend; } -String& operator<< (String& string1, const juce_wchar characterToAppend) +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend) { return string1 += characterToAppend; } -String& operator<< (String& string1, const char* const string2) +String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2) { return string1 += string2; } -String& operator<< (String& string1, const juce_wchar* const string2) +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2) { return string1 += string2; } -String& operator<< (String& string1, const String& string2) +String& JUCE_CALLTYPE operator<< (String& string1, const String& string2) { return string1 += string2; } -String& operator<< (String& string1, const short number) +String& JUCE_CALLTYPE operator<< (String& string1, const short number) { return string1 += (int) number; } -String& operator<< (String& string1, const int number) +String& JUCE_CALLTYPE operator<< (String& string1, const int number) { return string1 += number; } -String& operator<< (String& string1, const unsigned int number) +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned int number) { return string1 += number; } -String& operator<< (String& string1, const long number) +String& JUCE_CALLTYPE operator<< (String& string1, const long number) { return string1 += (int) number; } -String& operator<< (String& string1, const unsigned long number) +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned long number) { return string1 += (unsigned int) number; } -String& operator<< (String& string1, const float number) +String& JUCE_CALLTYPE operator<< (String& string1, const float number) { return string1 += String (number); } -String& operator<< (String& string1, const double number) +String& JUCE_CALLTYPE operator<< (String& string1, const double number) { return string1 += String (number); } -OutputStream& operator<< (OutputStream& stream, const String& text) +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text) { // (This avoids using toUTF8() to prevent the memory bloat that it would leave behind // if lots of large, persistent strings were to be written to streams). diff --git a/src/text/juce_String.h b/src/text/juce_String.h index b57a948ff8..6803030c22 100644 --- a/src/text/juce_String.h +++ b/src/text/juce_String.h @@ -1082,86 +1082,86 @@ private: //============================================================================== /** Concatenates two strings. */ -const String operator+ (const char* string1, const String& string2); +const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); /** Concatenates two strings. */ -const String operator+ (const juce_wchar* string1, const String& string2); +const String JUCE_CALLTYPE operator+ (const juce_wchar* string1, const String& string2); /** Concatenates two strings. */ -const String operator+ (char string1, const String& string2); +const String JUCE_CALLTYPE operator+ (char string1, const String& string2); /** Concatenates two strings. */ -const String operator+ (juce_wchar string1, const String& string2); +const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); /** Concatenates two strings. */ -const String operator+ (String string1, const String& string2); +const String JUCE_CALLTYPE operator+ (String string1, const String& string2); /** Concatenates two strings. */ -const String operator+ (String string1, const char* string2); +const String JUCE_CALLTYPE operator+ (String string1, const char* string2); /** Concatenates two strings. */ -const String operator+ (String string1, const juce_wchar* string2); +const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* string2); /** Concatenates two strings. */ -const String operator+ (String string1, char characterToAppend); +const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); /** Concatenates two strings. */ -const String operator+ (String string1, juce_wchar characterToAppend); +const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); //============================================================================== /** Appends a character at the end of a string. */ -String& operator<< (String& string1, const char characterToAppend); +String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend); /** Appends a character at the end of a string. */ -String& operator<< (String& string1, const juce_wchar characterToAppend); +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend); /** Appends a string to the end of the first one. */ -String& operator<< (String& string1, const char* const string2); +String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2); /** Appends a string to the end of the first one. */ -String& operator<< (String& string1, const juce_wchar* const string2); +String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2); /** Appends a string to the end of the first one. */ -String& operator<< (String& string1, const String& string2); +String& JUCE_CALLTYPE operator<< (String& string1, const String& string2); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const short number); +String& JUCE_CALLTYPE operator<< (String& string1, const short number); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const int number); +String& JUCE_CALLTYPE operator<< (String& string1, const int number); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const unsigned int number); +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned int number); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const long number); +String& JUCE_CALLTYPE operator<< (String& string1, const long number); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const unsigned long number); +String& JUCE_CALLTYPE operator<< (String& string1, const unsigned long number); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const float number); +String& JUCE_CALLTYPE operator<< (String& string1, const float number); /** Appends a decimal number at the end of a string. */ -String& operator<< (String& string1, const double number); +String& JUCE_CALLTYPE operator<< (String& string1, const double number); //============================================================================== /** Case-sensitive comparison of two strings. */ -bool operator== (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator== (const String& string1, const String& string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator== (const String& string1, const char* string2) throw(); +bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator== (const String& string1, const juce_wchar* string2) throw(); +bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator!= (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator!= (const String& string1, const char* string2) throw(); +bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator!= (const String& string1, const juce_wchar* string2) throw(); +bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator> (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator< (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator< (const String& string1, const String& string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator>= (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator>= (const String& string1, const String& string2) throw(); /** Case-sensitive comparison of two strings. */ -bool operator<= (const String& string1, const String& string2) throw(); +bool JUCE_CALLTYPE operator<= (const String& string1, const String& string2) throw(); //============================================================================== /** This streaming override allows you to pass a juce String directly into std output streams. This is very handy for writing strings to std::cout, std::cerr, etc. */ template -std::basic_ostream & operator<< (std::basic_ostream & stream, const String& stringToWrite) +std::basic_ostream & JUCE_CALLTYPE operator<< (std::basic_ostream & stream, const String& stringToWrite) { return stream << stringToWrite.toUTF8(); } /** Writes a string to an OutputStream as UTF8. */ -OutputStream& operator<< (OutputStream& stream, const String& text); +OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text); #endif // __JUCE_STRING_JUCEHEADER__