@@ -557,7 +557,7 @@ PopupMenu ComponentLayout::getRelativeTargetMenu (Component* comp, int whichDime | |||||
{ | { | ||||
Component* const c = components.getUnchecked(i); | Component* const c = components.getUnchecked(i); | ||||
if (c->getComponentUID() != comp->getComponentUID()) | |||||
if (c != comp) | |||||
{ | { | ||||
m.addItem (menuIdBase + i + 1, | m.addItem (menuIdBase + i + 1, | ||||
T("Relative to ") + getComponentMemberVariableName (c) | T("Relative to ") + getComponentMemberVariableName (c) | ||||
@@ -39862,18 +39862,158 @@ enum ComponentMessageNumbers | |||||
exitModalStateMessage = 0x7fff0002 | exitModalStateMessage = 0x7fff0002 | ||||
}; | }; | ||||
static uint32 nextComponentUID = 0; | |||||
Component* Component::currentlyFocusedComponent = 0; | Component* Component::currentlyFocusedComponent = 0; | ||||
class Component::MouseListenerList | |||||
{ | |||||
public: | |||||
MouseListenerList() | |||||
: numDeepMouseListeners (0) | |||||
{ | |||||
} | |||||
~MouseListenerList() | |||||
{ | |||||
} | |||||
void addListener (MouseListener* const newListener, const bool wantsEventsForAllNestedChildComponents) | |||||
{ | |||||
if (! listeners.contains (newListener)) | |||||
{ | |||||
if (wantsEventsForAllNestedChildComponents) | |||||
{ | |||||
listeners.insert (0, newListener); | |||||
++numDeepMouseListeners; | |||||
} | |||||
else | |||||
{ | |||||
listeners.add (newListener); | |||||
} | |||||
} | |||||
} | |||||
void removeListener (MouseListener* const listenerToRemove) | |||||
{ | |||||
const int index = listeners.indexOf (listenerToRemove); | |||||
if (index >= 0) | |||||
{ | |||||
if (index < numDeepMouseListeners) | |||||
--numDeepMouseListeners; | |||||
listeners.remove (index); | |||||
} | |||||
} | |||||
static void sendMouseEvent (Component* comp, BailOutChecker& checker, | |||||
void (MouseListener::*eventMethod) (const MouseEvent&), const MouseEvent& e) | |||||
{ | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
{ | |||||
MouseListenerList* const list = comp->mouseListeners_; | |||||
if (list != 0) | |||||
{ | |||||
for (int i = list->listeners.size(); --i >= 0;) | |||||
{ | |||||
(list->listeners.getUnchecked(i)->*eventMethod) (e); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->listeners.size()); | |||||
} | |||||
} | |||||
} | |||||
Component* p = comp->parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
MouseListenerList* const list = p->mouseListeners_; | |||||
if (list != 0 && list->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (comp, p); | |||||
for (int i = list->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
(list->listeners.getUnchecked(i)->*eventMethod) (e); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
} | |||||
static void sendWheelEvent (Component* comp, BailOutChecker& checker, const MouseEvent& e, | |||||
const float wheelIncrementX, const float wheelIncrementY) | |||||
{ | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
{ | |||||
MouseListenerList* const list = comp->mouseListeners_; | |||||
if (list != 0) | |||||
{ | |||||
for (int i = list->listeners.size(); --i >= 0;) | |||||
{ | |||||
list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->listeners.size()); | |||||
} | |||||
} | |||||
} | |||||
Component* p = comp->parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
MouseListenerList* const list = p->mouseListeners_; | |||||
if (list != 0 && list->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (comp, p); | |||||
for (int i = list->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
} | |||||
private: | |||||
Array <MouseListener*> listeners; | |||||
int numDeepMouseListeners; | |||||
MouseListenerList (const MouseListenerList&); | |||||
MouseListenerList& operator= (const MouseListenerList&); | |||||
}; | |||||
Component::Component() | Component::Component() | ||||
: parentComponent_ (0), | : parentComponent_ (0), | ||||
componentUID (++nextComponentUID), | |||||
numDeepMouseListeners (0), | |||||
lookAndFeel_ (0), | lookAndFeel_ (0), | ||||
effect_ (0), | effect_ (0), | ||||
bufferedImage_ (0), | bufferedImage_ (0), | ||||
mouseListeners_ (0), | |||||
keyListeners_ (0), | |||||
componentFlags_ (0), | componentFlags_ (0), | ||||
componentTransparency (0) | componentTransparency (0) | ||||
{ | { | ||||
@@ -39882,13 +40022,9 @@ Component::Component() | |||||
Component::Component (const String& name) | Component::Component (const String& name) | ||||
: componentName_ (name), | : componentName_ (name), | ||||
parentComponent_ (0), | parentComponent_ (0), | ||||
componentUID (++nextComponentUID), | |||||
numDeepMouseListeners (0), | |||||
lookAndFeel_ (0), | lookAndFeel_ (0), | ||||
effect_ (0), | effect_ (0), | ||||
bufferedImage_ (0), | bufferedImage_ (0), | ||||
mouseListeners_ (0), | |||||
keyListeners_ (0), | |||||
componentFlags_ (0), | componentFlags_ (0), | ||||
componentTransparency (0) | componentTransparency (0) | ||||
{ | { | ||||
@@ -39915,9 +40051,6 @@ Component::~Component() | |||||
for (int i = childComponentList_.size(); --i >= 0;) | for (int i = childComponentList_.size(); --i >= 0;) | ||||
childComponentList_.getUnchecked(i)->parentComponent_ = 0; | childComponentList_.getUnchecked(i)->parentComponent_ = 0; | ||||
delete mouseListeners_; | |||||
delete keyListeners_; | |||||
} | } | ||||
void Component::setName (const String& name) | void Component::setName (const String& name) | ||||
@@ -41756,20 +41889,9 @@ void Component::addMouseListener (MouseListener* const newListener, | |||||
jassert ((newListener != this) || wantsEventsForAllNestedChildComponents); | jassert ((newListener != this) || wantsEventsForAllNestedChildComponents); | ||||
if (mouseListeners_ == 0) | if (mouseListeners_ == 0) | ||||
mouseListeners_ = new Array<MouseListener*>(); | |||||
mouseListeners_ = new MouseListenerList(); | |||||
if (! mouseListeners_->contains (newListener)) | |||||
{ | |||||
if (wantsEventsForAllNestedChildComponents) | |||||
{ | |||||
mouseListeners_->insert (0, newListener); | |||||
++numDeepMouseListeners; | |||||
} | |||||
else | |||||
{ | |||||
mouseListeners_->add (newListener); | |||||
} | |||||
} | |||||
mouseListeners_->addListener (newListener, wantsEventsForAllNestedChildComponents); | |||||
} | } | ||||
void Component::removeMouseListener (MouseListener* const listenerToRemove) | void Component::removeMouseListener (MouseListener* const listenerToRemove) | ||||
@@ -41779,17 +41901,7 @@ void Component::removeMouseListener (MouseListener* const listenerToRemove) | |||||
checkMessageManagerIsLocked | checkMessageManagerIsLocked | ||||
if (mouseListeners_ != 0) | if (mouseListeners_ != 0) | ||||
{ | |||||
const int index = mouseListeners_->indexOf (listenerToRemove); | |||||
if (index >= 0) | |||||
{ | |||||
if (index < numDeepMouseListeners) | |||||
--numDeepMouseListeners; | |||||
mouseListeners_->remove (index); | |||||
} | |||||
} | |||||
mouseListeners_->removeListener (listenerToRemove); | |||||
} | } | ||||
void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& relativePos, const Time& time) | void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& relativePos, const Time& time) | ||||
@@ -41813,9 +41925,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& | |||||
repaint(); | repaint(); | ||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | ||||
this, this, time, relativePos, | |||||
time, 0, false); | |||||
this, this, time, relativePos, time, 0, false); | |||||
mouseEnter (me); | mouseEnter (me); | ||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
@@ -41824,43 +41934,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& | |||||
Desktop::getInstance().resetTimer(); | Desktop::getInstance().resetTimer(); | ||||
Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me); | Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
mouseListeners_->getUnchecked(i)->mouseEnter (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked(i)->mouseEnter (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseEnter, me); | |||||
} | } | ||||
} | } | ||||
@@ -41886,8 +41960,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r | |||||
repaint(); | repaint(); | ||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | ||||
this, this, time, relativePos, | |||||
time, 0, false); | |||||
this, this, time, relativePos, time, 0, false); | |||||
mouseExit (me); | mouseExit (me); | ||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
@@ -41896,43 +41969,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r | |||||
Desktop::getInstance().resetTimer(); | Desktop::getInstance().resetTimer(); | ||||
Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseExit, me); | Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseExit, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseExit (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseExit (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseExit, me); | |||||
} | } | ||||
} | } | ||||
@@ -42060,43 +42097,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseDown (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseDown (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseDown, me); | |||||
} | } | ||||
void Component::internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers) | void Component::internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers) | ||||
@@ -42127,95 +42128,21 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); | ||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseUp, me); | |||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
return; | return; | ||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseUp (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
{ | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseUp (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
} | |||||
// check for double-click | // check for double-click | ||||
if (me.getNumberOfClicks() >= 2) | if (me.getNumberOfClicks() >= 2) | ||||
{ | { | ||||
const int numListeners = (mouseListeners_ != 0) ? mouseListeners_->size() : 0; | |||||
mouseDoubleClick (me); | mouseDoubleClick (me); | ||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
return; | return; | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
for (int i = numListeners; --i >= 0;) | |||||
{ | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
MouseListener* const ml = (MouseListener*)((*mouseListeners_)[i]); | |||||
if (ml != 0) | |||||
ml->mouseDoubleClick (me); | |||||
} | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseDoubleClick (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseDoubleClick, me); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -42245,43 +42172,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseDrag (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseDrag (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseDrag, me); | |||||
} | } | ||||
} | } | ||||
@@ -42311,43 +42202,7 @@ void Component::internalMouseMove (MouseInputSource& source, const Point<int>& r | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseMove (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseMove (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseMove, me); | |||||
} | } | ||||
} | } | ||||
@@ -42377,43 +42232,7 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>& | |||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseWheelMove (me, wheelIncrementX, wheelIncrementY); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseWheelMove (me, wheelIncrementX, wheelIncrementY); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendWheelEvent (this, checker, me, wheelIncrementX, wheelIncrementY); | |||||
} | } | ||||
} | } | ||||
@@ -71403,15 +71222,13 @@ private: | |||||
}; | }; | ||||
MouseCursor::MouseCursor() | MouseCursor::MouseCursor() | ||||
: cursorHandle (SharedCursorHandle::createStandard (NormalCursor)) | |||||
: cursorHandle (0) | |||||
{ | { | ||||
jassert (cursorHandle != 0); | |||||
} | } | ||||
MouseCursor::MouseCursor (const StandardCursorType type) | MouseCursor::MouseCursor (const StandardCursorType type) | ||||
: cursorHandle (SharedCursorHandle::createStandard (type)) | |||||
: cursorHandle (type != MouseCursor::NormalCursor ? SharedCursorHandle::createStandard (type) : 0) | |||||
{ | { | ||||
jassert (cursorHandle != 0); | |||||
} | } | ||||
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) | MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) | ||||
@@ -71420,19 +71237,24 @@ MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotS | |||||
} | } | ||||
MouseCursor::MouseCursor (const MouseCursor& other) | MouseCursor::MouseCursor (const MouseCursor& other) | ||||
: cursorHandle (other.cursorHandle->retain()) | |||||
: cursorHandle (other.cursorHandle == 0 ? 0 : other.cursorHandle->retain()) | |||||
{ | { | ||||
} | } | ||||
MouseCursor::~MouseCursor() | MouseCursor::~MouseCursor() | ||||
{ | { | ||||
cursorHandle->release(); | |||||
if (cursorHandle != 0) | |||||
cursorHandle->release(); | |||||
} | } | ||||
MouseCursor& MouseCursor::operator= (const MouseCursor& other) | MouseCursor& MouseCursor::operator= (const MouseCursor& other) | ||||
{ | { | ||||
other.cursorHandle->retain(); | |||||
cursorHandle->release(); | |||||
if (other.cursorHandle != 0) | |||||
other.cursorHandle->retain(); | |||||
if (cursorHandle != 0) | |||||
cursorHandle->release(); | |||||
cursorHandle = other.cursorHandle; | cursorHandle = other.cursorHandle; | ||||
return *this; | return *this; | ||||
} | } | ||||
@@ -71449,7 +71271,7 @@ bool MouseCursor::operator!= (const MouseCursor& other) const throw() | |||||
void* MouseCursor::getHandle() const throw() | void* MouseCursor::getHandle() const throw() | ||||
{ | { | ||||
return cursorHandle->getHandle(); | |||||
return cursorHandle != 0 ? cursorHandle->getHandle() : 0; | |||||
} | } | ||||
void MouseCursor::showWaitCursor() | void MouseCursor::showWaitCursor() | ||||
@@ -244300,7 +244122,12 @@ void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorT | |||||
void MouseCursor::showInWindow (ComponentPeer*) const | void MouseCursor::showInWindow (ComponentPeer*) const | ||||
{ | { | ||||
SetCursor ((HCURSOR) getHandle()); | |||||
HCURSOR c = (HCURSOR) getHandle(); | |||||
if (c == 0) | |||||
c = LoadCursor (0, IDC_ARROW); | |||||
SetCursor (c); | |||||
} | } | ||||
void MouseCursor::showInAllWindows() const | void MouseCursor::showInAllWindows() const | ||||
@@ -258483,6 +258310,8 @@ public: | |||||
if (! XInitImage (xImage)) | if (! XInitImage (xImage)) | ||||
jassertfalse; | jassertfalse; | ||||
} | } | ||||
zeromem (imageData, h * lineStride); | |||||
} | } | ||||
~XBitmapImage() | ~XBitmapImage() | ||||
@@ -261493,7 +261322,8 @@ public: | |||||
bitDepth (16), | bitDepth (16), | ||||
numChannelsRunning (0), | numChannelsRunning (0), | ||||
latency (0), | latency (0), | ||||
isInput (forInput) | |||||
isInput (forInput), | |||||
isInterleaved (true) | |||||
{ | { | ||||
failed (snd_pcm_open (&handle, deviceID.toUTF8(), | failed (snd_pcm_open (&handle, deviceID.toUTF8(), | ||||
forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, | forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, | ||||
@@ -261654,6 +261484,7 @@ public: | |||||
if (isInterleaved) | if (isInterleaved) | ||||
{ | { | ||||
scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); | scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); | ||||
scratch.fillWith (0); // (not clearing this data causes warnings in valgrind) | |||||
snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), numSamples); | snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), numSamples); | ||||
@@ -269587,7 +269418,12 @@ void MouseCursor::showInAllWindows() const | |||||
void MouseCursor::showInWindow (ComponentPeer*) const | void MouseCursor::showInWindow (ComponentPeer*) const | ||||
{ | { | ||||
[((NSCursor*) getHandle()) set]; | |||||
NSCursor* c = (NSCursor*) getHandle(); | |||||
if (c == 0) | |||||
c = [NSCursor arrowCursor]; | |||||
[c set]; | |||||
} | } | ||||
#else | #else | ||||
@@ -274171,7 +274007,12 @@ void MouseCursor::showInAllWindows() const | |||||
void MouseCursor::showInWindow (ComponentPeer*) const | void MouseCursor::showInWindow (ComponentPeer*) const | ||||
{ | { | ||||
[((NSCursor*) getHandle()) set]; | |||||
NSCursor* c = (NSCursor*) getHandle(); | |||||
if (c == 0) | |||||
c = [NSCursor arrowCursor]; | |||||
[c set]; | |||||
} | } | ||||
#else | #else | ||||
@@ -27802,14 +27802,6 @@ public: | |||||
*/ | */ | ||||
void* getWindowHandle() const; | void* getWindowHandle() const; | ||||
/** When created, each component is given a number to uniquely identify it. | |||||
The number is incremented each time a new component is created, so it's a more | |||||
unique way of identifying a component than using its memory location (which | |||||
may be reused after the component is deleted, of course). | |||||
*/ | |||||
uint32 getComponentUID() const throw() { return componentUID; } | |||||
/** Holds a pointer to some type of Component, which automatically becomes null if | /** Holds a pointer to some type of Component, which automatically becomes null if | ||||
the component is deleted. | the component is deleted. | ||||
@@ -27918,16 +27910,18 @@ private: | |||||
String componentName_; | String componentName_; | ||||
Component* parentComponent_; | Component* parentComponent_; | ||||
uint32 componentUID; | |||||
Rectangle<int> bounds_; | Rectangle<int> bounds_; | ||||
int numDeepMouseListeners; | |||||
Array <Component*> childComponentList_; | Array <Component*> childComponentList_; | ||||
LookAndFeel* lookAndFeel_; | LookAndFeel* lookAndFeel_; | ||||
MouseCursor cursor_; | MouseCursor cursor_; | ||||
ImageEffectFilter* effect_; | ImageEffectFilter* effect_; | ||||
Image bufferedImage_; | Image bufferedImage_; | ||||
Array <MouseListener*>* mouseListeners_; | |||||
Array <KeyListener*>* keyListeners_; | |||||
class MouseListenerList; | |||||
friend class MouseListenerList; | |||||
friend class ScopedPointer <MouseListenerList>; | |||||
ScopedPointer <MouseListenerList> mouseListeners_; | |||||
ScopedPointer <Array <KeyListener*> > keyListeners_; | |||||
ListenerList <ComponentListener> componentListeners; | ListenerList <ComponentListener> componentListeners; | ||||
NamedValueSet properties; | NamedValueSet properties; | ||||
@@ -52,20 +52,161 @@ enum ComponentMessageNumbers | |||||
exitModalStateMessage = 0x7fff0002 | exitModalStateMessage = 0x7fff0002 | ||||
}; | }; | ||||
static uint32 nextComponentUID = 0; | |||||
Component* Component::currentlyFocusedComponent = 0; | Component* Component::currentlyFocusedComponent = 0; | ||||
//============================================================================== | |||||
class Component::MouseListenerList | |||||
{ | |||||
public: | |||||
MouseListenerList() | |||||
: numDeepMouseListeners (0) | |||||
{ | |||||
} | |||||
~MouseListenerList() | |||||
{ | |||||
} | |||||
void addListener (MouseListener* const newListener, const bool wantsEventsForAllNestedChildComponents) | |||||
{ | |||||
if (! listeners.contains (newListener)) | |||||
{ | |||||
if (wantsEventsForAllNestedChildComponents) | |||||
{ | |||||
listeners.insert (0, newListener); | |||||
++numDeepMouseListeners; | |||||
} | |||||
else | |||||
{ | |||||
listeners.add (newListener); | |||||
} | |||||
} | |||||
} | |||||
void removeListener (MouseListener* const listenerToRemove) | |||||
{ | |||||
const int index = listeners.indexOf (listenerToRemove); | |||||
if (index >= 0) | |||||
{ | |||||
if (index < numDeepMouseListeners) | |||||
--numDeepMouseListeners; | |||||
listeners.remove (index); | |||||
} | |||||
} | |||||
static void sendMouseEvent (Component* comp, BailOutChecker& checker, | |||||
void (MouseListener::*eventMethod) (const MouseEvent&), const MouseEvent& e) | |||||
{ | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
{ | |||||
MouseListenerList* const list = comp->mouseListeners_; | |||||
if (list != 0) | |||||
{ | |||||
for (int i = list->listeners.size(); --i >= 0;) | |||||
{ | |||||
(list->listeners.getUnchecked(i)->*eventMethod) (e); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->listeners.size()); | |||||
} | |||||
} | |||||
} | |||||
Component* p = comp->parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
MouseListenerList* const list = p->mouseListeners_; | |||||
if (list != 0 && list->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (comp, p); | |||||
for (int i = list->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
(list->listeners.getUnchecked(i)->*eventMethod) (e); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
} | |||||
static void sendWheelEvent (Component* comp, BailOutChecker& checker, const MouseEvent& e, | |||||
const float wheelIncrementX, const float wheelIncrementY) | |||||
{ | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
{ | |||||
MouseListenerList* const list = comp->mouseListeners_; | |||||
if (list != 0) | |||||
{ | |||||
for (int i = list->listeners.size(); --i >= 0;) | |||||
{ | |||||
list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->listeners.size()); | |||||
} | |||||
} | |||||
} | |||||
Component* p = comp->parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
MouseListenerList* const list = p->mouseListeners_; | |||||
if (list != 0 && list->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (comp, p); | |||||
for (int i = list->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, list->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
} | |||||
private: | |||||
Array <MouseListener*> listeners; | |||||
int numDeepMouseListeners; | |||||
MouseListenerList (const MouseListenerList&); | |||||
MouseListenerList& operator= (const MouseListenerList&); | |||||
}; | |||||
//============================================================================== | //============================================================================== | ||||
Component::Component() | Component::Component() | ||||
: parentComponent_ (0), | : parentComponent_ (0), | ||||
componentUID (++nextComponentUID), | |||||
numDeepMouseListeners (0), | |||||
lookAndFeel_ (0), | lookAndFeel_ (0), | ||||
effect_ (0), | effect_ (0), | ||||
bufferedImage_ (0), | bufferedImage_ (0), | ||||
mouseListeners_ (0), | |||||
keyListeners_ (0), | |||||
componentFlags_ (0), | componentFlags_ (0), | ||||
componentTransparency (0) | componentTransparency (0) | ||||
{ | { | ||||
@@ -74,13 +215,9 @@ Component::Component() | |||||
Component::Component (const String& name) | Component::Component (const String& name) | ||||
: componentName_ (name), | : componentName_ (name), | ||||
parentComponent_ (0), | parentComponent_ (0), | ||||
componentUID (++nextComponentUID), | |||||
numDeepMouseListeners (0), | |||||
lookAndFeel_ (0), | lookAndFeel_ (0), | ||||
effect_ (0), | effect_ (0), | ||||
bufferedImage_ (0), | bufferedImage_ (0), | ||||
mouseListeners_ (0), | |||||
keyListeners_ (0), | |||||
componentFlags_ (0), | componentFlags_ (0), | ||||
componentTransparency (0) | componentTransparency (0) | ||||
{ | { | ||||
@@ -107,9 +244,6 @@ Component::~Component() | |||||
for (int i = childComponentList_.size(); --i >= 0;) | for (int i = childComponentList_.size(); --i >= 0;) | ||||
childComponentList_.getUnchecked(i)->parentComponent_ = 0; | childComponentList_.getUnchecked(i)->parentComponent_ = 0; | ||||
delete mouseListeners_; | |||||
delete keyListeners_; | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -1980,20 +2114,9 @@ void Component::addMouseListener (MouseListener* const newListener, | |||||
jassert ((newListener != this) || wantsEventsForAllNestedChildComponents); | jassert ((newListener != this) || wantsEventsForAllNestedChildComponents); | ||||
if (mouseListeners_ == 0) | if (mouseListeners_ == 0) | ||||
mouseListeners_ = new Array<MouseListener*>(); | |||||
mouseListeners_ = new MouseListenerList(); | |||||
if (! mouseListeners_->contains (newListener)) | |||||
{ | |||||
if (wantsEventsForAllNestedChildComponents) | |||||
{ | |||||
mouseListeners_->insert (0, newListener); | |||||
++numDeepMouseListeners; | |||||
} | |||||
else | |||||
{ | |||||
mouseListeners_->add (newListener); | |||||
} | |||||
} | |||||
mouseListeners_->addListener (newListener, wantsEventsForAllNestedChildComponents); | |||||
} | } | ||||
void Component::removeMouseListener (MouseListener* const listenerToRemove) | void Component::removeMouseListener (MouseListener* const listenerToRemove) | ||||
@@ -2003,17 +2126,7 @@ void Component::removeMouseListener (MouseListener* const listenerToRemove) | |||||
checkMessageManagerIsLocked | checkMessageManagerIsLocked | ||||
if (mouseListeners_ != 0) | if (mouseListeners_ != 0) | ||||
{ | |||||
const int index = mouseListeners_->indexOf (listenerToRemove); | |||||
if (index >= 0) | |||||
{ | |||||
if (index < numDeepMouseListeners) | |||||
--numDeepMouseListeners; | |||||
mouseListeners_->remove (index); | |||||
} | |||||
} | |||||
mouseListeners_->removeListener (listenerToRemove); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -2038,9 +2151,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& | |||||
repaint(); | repaint(); | ||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | ||||
this, this, time, relativePos, | |||||
time, 0, false); | |||||
this, this, time, relativePos, time, 0, false); | |||||
mouseEnter (me); | mouseEnter (me); | ||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
@@ -2049,43 +2160,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point<int>& | |||||
Desktop::getInstance().resetTimer(); | Desktop::getInstance().resetTimer(); | ||||
Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me); | Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseEnter, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
mouseListeners_->getUnchecked(i)->mouseEnter (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked(i)->mouseEnter (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseEnter, me); | |||||
} | } | ||||
} | } | ||||
@@ -2111,8 +2186,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r | |||||
repaint(); | repaint(); | ||||
const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | const MouseEvent me (source, relativePos, source.getCurrentModifiers(), | ||||
this, this, time, relativePos, | |||||
time, 0, false); | |||||
this, this, time, relativePos, time, 0, false); | |||||
mouseExit (me); | mouseExit (me); | ||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
@@ -2121,43 +2195,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point<int>& r | |||||
Desktop::getInstance().resetTimer(); | Desktop::getInstance().resetTimer(); | ||||
Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseExit, me); | Desktop::getInstance().mouseListeners.callChecked (checker, &MouseListener::mouseExit, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseExit (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseExit (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseExit, me); | |||||
} | } | ||||
} | } | ||||
@@ -2288,43 +2326,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& r | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDown, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseDown (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseDown (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseDown, me); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -2356,95 +2358,21 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); | ||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseUp, me); | |||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
return; | return; | ||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseUp (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
{ | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseUp (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
} | |||||
// check for double-click | // check for double-click | ||||
if (me.getNumberOfClicks() >= 2) | if (me.getNumberOfClicks() >= 2) | ||||
{ | { | ||||
const int numListeners = (mouseListeners_ != 0) ? mouseListeners_->size() : 0; | |||||
mouseDoubleClick (me); | mouseDoubleClick (me); | ||||
if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
return; | return; | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDoubleClick, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
for (int i = numListeners; --i >= 0;) | |||||
{ | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
MouseListener* const ml = (MouseListener*)((*mouseListeners_)[i]); | |||||
if (ml != 0) | |||||
ml->mouseDoubleClick (me); | |||||
} | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseDoubleClick (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseDoubleClick, me); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -2474,43 +2402,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseDrag (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseDrag (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseDrag, me); | |||||
} | } | ||||
} | } | ||||
@@ -2540,43 +2432,7 @@ void Component::internalMouseMove (MouseInputSource& source, const Point<int>& r | |||||
desktop.resetTimer(); | desktop.resetTimer(); | ||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseMove, me); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseMove (me); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseMove (me); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendMouseEvent (this, checker, &MouseListener::mouseMove, me); | |||||
} | } | ||||
} | } | ||||
@@ -2606,43 +2462,7 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point<int>& | |||||
desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); | desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); | ||||
if (checker.shouldBailOut()) | |||||
return; | |||||
if (mouseListeners_ != 0) | |||||
{ | |||||
for (int i = mouseListeners_->size(); --i >= 0;) | |||||
{ | |||||
((MouseListener*) mouseListeners_->getUnchecked (i))->mouseWheelMove (me, wheelIncrementX, wheelIncrementY); | |||||
if (checker.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, mouseListeners_->size()); | |||||
} | |||||
} | |||||
Component* p = parentComponent_; | |||||
while (p != 0) | |||||
{ | |||||
if (p->numDeepMouseListeners > 0) | |||||
{ | |||||
BailOutChecker checker2 (this, p); | |||||
for (int i = p->numDeepMouseListeners; --i >= 0;) | |||||
{ | |||||
p->mouseListeners_->getUnchecked (i)->mouseWheelMove (me, wheelIncrementX, wheelIncrementY); | |||||
if (checker2.shouldBailOut()) | |||||
return; | |||||
i = jmin (i, p->numDeepMouseListeners); | |||||
} | |||||
} | |||||
p = p->parentComponent_; | |||||
} | |||||
MouseListenerList::sendWheelEvent (this, checker, me, wheelIncrementX, wheelIncrementY); | |||||
} | } | ||||
} | } | ||||
@@ -1898,14 +1898,6 @@ public: | |||||
*/ | */ | ||||
void* getWindowHandle() const; | void* getWindowHandle() const; | ||||
/** When created, each component is given a number to uniquely identify it. | |||||
The number is incremented each time a new component is created, so it's a more | |||||
unique way of identifying a component than using its memory location (which | |||||
may be reused after the component is deleted, of course). | |||||
*/ | |||||
uint32 getComponentUID() const throw() { return componentUID; } | |||||
//============================================================================== | //============================================================================== | ||||
/** Holds a pointer to some type of Component, which automatically becomes null if | /** Holds a pointer to some type of Component, which automatically becomes null if | ||||
the component is deleted. | the component is deleted. | ||||
@@ -2019,16 +2011,18 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
String componentName_; | String componentName_; | ||||
Component* parentComponent_; | Component* parentComponent_; | ||||
uint32 componentUID; | |||||
Rectangle<int> bounds_; | Rectangle<int> bounds_; | ||||
int numDeepMouseListeners; | |||||
Array <Component*> childComponentList_; | Array <Component*> childComponentList_; | ||||
LookAndFeel* lookAndFeel_; | LookAndFeel* lookAndFeel_; | ||||
MouseCursor cursor_; | MouseCursor cursor_; | ||||
ImageEffectFilter* effect_; | ImageEffectFilter* effect_; | ||||
Image bufferedImage_; | Image bufferedImage_; | ||||
Array <MouseListener*>* mouseListeners_; | |||||
Array <KeyListener*>* keyListeners_; | |||||
class MouseListenerList; | |||||
friend class MouseListenerList; | |||||
friend class ScopedPointer <MouseListenerList>; | |||||
ScopedPointer <MouseListenerList> mouseListeners_; | |||||
ScopedPointer <Array <KeyListener*> > keyListeners_; | |||||
ListenerList <ComponentListener> componentListeners; | ListenerList <ComponentListener> componentListeners; | ||||
NamedValueSet properties; | NamedValueSet properties; | ||||
@@ -125,15 +125,13 @@ private: | |||||
//============================================================================== | //============================================================================== | ||||
MouseCursor::MouseCursor() | MouseCursor::MouseCursor() | ||||
: cursorHandle (SharedCursorHandle::createStandard (NormalCursor)) | |||||
: cursorHandle (0) | |||||
{ | { | ||||
jassert (cursorHandle != 0); | |||||
} | } | ||||
MouseCursor::MouseCursor (const StandardCursorType type) | MouseCursor::MouseCursor (const StandardCursorType type) | ||||
: cursorHandle (SharedCursorHandle::createStandard (type)) | |||||
: cursorHandle (type != MouseCursor::NormalCursor ? SharedCursorHandle::createStandard (type) : 0) | |||||
{ | { | ||||
jassert (cursorHandle != 0); | |||||
} | } | ||||
MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) | MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotSpotY) | ||||
@@ -142,19 +140,24 @@ MouseCursor::MouseCursor (const Image& image, const int hotSpotX, const int hotS | |||||
} | } | ||||
MouseCursor::MouseCursor (const MouseCursor& other) | MouseCursor::MouseCursor (const MouseCursor& other) | ||||
: cursorHandle (other.cursorHandle->retain()) | |||||
: cursorHandle (other.cursorHandle == 0 ? 0 : other.cursorHandle->retain()) | |||||
{ | { | ||||
} | } | ||||
MouseCursor::~MouseCursor() | MouseCursor::~MouseCursor() | ||||
{ | { | ||||
cursorHandle->release(); | |||||
if (cursorHandle != 0) | |||||
cursorHandle->release(); | |||||
} | } | ||||
MouseCursor& MouseCursor::operator= (const MouseCursor& other) | MouseCursor& MouseCursor::operator= (const MouseCursor& other) | ||||
{ | { | ||||
other.cursorHandle->retain(); | |||||
cursorHandle->release(); | |||||
if (other.cursorHandle != 0) | |||||
other.cursorHandle->retain(); | |||||
if (cursorHandle != 0) | |||||
cursorHandle->release(); | |||||
cursorHandle = other.cursorHandle; | cursorHandle = other.cursorHandle; | ||||
return *this; | return *this; | ||||
} | } | ||||
@@ -171,7 +174,7 @@ bool MouseCursor::operator!= (const MouseCursor& other) const throw() | |||||
void* MouseCursor::getHandle() const throw() | void* MouseCursor::getHandle() const throw() | ||||
{ | { | ||||
return cursorHandle->getHandle(); | |||||
return cursorHandle != 0 ? cursorHandle->getHandle() : 0; | |||||
} | } | ||||
void MouseCursor::showWaitCursor() | void MouseCursor::showWaitCursor() | ||||
@@ -123,7 +123,8 @@ public: | |||||
bitDepth (16), | bitDepth (16), | ||||
numChannelsRunning (0), | numChannelsRunning (0), | ||||
latency (0), | latency (0), | ||||
isInput (forInput) | |||||
isInput (forInput), | |||||
isInterleaved (true) | |||||
{ | { | ||||
failed (snd_pcm_open (&handle, deviceID.toUTF8(), | failed (snd_pcm_open (&handle, deviceID.toUTF8(), | ||||
forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, | forInput ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, | ||||
@@ -285,6 +286,7 @@ public: | |||||
if (isInterleaved) | if (isInterleaved) | ||||
{ | { | ||||
scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); | scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); | ||||
scratch.fillWith (0); // (not clearing this data causes warnings in valgrind) | |||||
snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), numSamples); | snd_pcm_sframes_t num = snd_pcm_readi (handle, scratch.getData(), numSamples); | ||||
@@ -118,7 +118,12 @@ void MouseCursor::showInAllWindows() const | |||||
void MouseCursor::showInWindow (ComponentPeer*) const | void MouseCursor::showInWindow (ComponentPeer*) const | ||||
{ | { | ||||
[((NSCursor*) getHandle()) set]; | |||||
NSCursor* c = (NSCursor*) getHandle(); | |||||
if (c == 0) | |||||
c = [NSCursor arrowCursor]; | |||||
[c set]; | |||||
} | } | ||||
#else | #else | ||||
@@ -2681,7 +2681,12 @@ void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorT | |||||
//============================================================================== | //============================================================================== | ||||
void MouseCursor::showInWindow (ComponentPeer*) const | void MouseCursor::showInWindow (ComponentPeer*) const | ||||
{ | { | ||||
SetCursor ((HCURSOR) getHandle()); | |||||
HCURSOR c = (HCURSOR) getHandle(); | |||||
if (c == 0) | |||||
c = LoadCursor (0, IDC_ARROW); | |||||
SetCursor (c); | |||||
} | } | ||||
void MouseCursor::showInAllWindows() const | void MouseCursor::showInAllWindows() const | ||||