diff --git a/src/containers/juce_ReferenceCountedObject.h b/src/containers/juce_ReferenceCountedObject.h index 9e4f10a908..6dfa4471e4 100644 --- a/src/containers/juce_ReferenceCountedObject.h +++ b/src/containers/juce_ReferenceCountedObject.h @@ -216,7 +216,6 @@ public: } /** Returns the object that this pointer references. - The pointer returned may be zero, of course. */ inline operator ReferenceCountedObjectClass*() const throw() @@ -242,6 +241,13 @@ public: return referencedObject; } + /** Returns the object that this pointer references. + The pointer returned may be zero, of course. + */ + inline ReferenceCountedObjectClass* getObject() const throw() + { + return referencedObject; + } private: //============================================================================== diff --git a/src/events/juce_ActionListenerList.cpp b/src/events/juce_ActionListenerList.cpp index 8bbd0cca61..38759a332c 100644 --- a/src/events/juce_ActionListenerList.cpp +++ b/src/events/juce_ActionListenerList.cpp @@ -95,10 +95,7 @@ void ActionListenerList::sendActionMessage (const String& message) const const ScopedLock sl (actionListenerLock_); for (int i = actionListeners_.size(); --i >= 0;) - { - postMessage (new ActionMessage (message, - (ActionListener*) actionListeners_.getUnchecked(i))); - } + postMessage (new ActionMessage (message, static_cast (actionListeners_.getUnchecked(i)))); } void ActionListenerList::handleMessage (const Message& message) @@ -106,7 +103,7 @@ void ActionListenerList::handleMessage (const Message& message) const ActionMessage& am = (const ActionMessage&) message; if (actionListeners_.contains (am.pointerParameter)) - ((ActionListener*) am.pointerParameter)->actionListenerCallback (am.message); + static_cast (am.pointerParameter)->actionListenerCallback (am.message); } END_JUCE_NAMESPACE diff --git a/src/events/juce_ChangeListenerList.cpp b/src/events/juce_ChangeListenerList.cpp index d18352ea29..ea5e9cf5a8 100644 --- a/src/events/juce_ChangeListenerList.cpp +++ b/src/events/juce_ChangeListenerList.cpp @@ -87,7 +87,7 @@ void ChangeListenerList::sendSynchronousChangeMessage (void* const objectThatHas for (int i = listeners.size(); --i >= 0;) { - ChangeListener* const l = (ChangeListener*) listeners.getUnchecked (i); + ChangeListener* const l = static_cast (listeners.getUnchecked (i)); { const ScopedUnlock tempUnlocker (lock); diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 3833d4d893..15428a066b 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -71,7 +71,7 @@ struct TextAtom //============================================================================== // a run of text with a single font and colour -class UniformTextSection +class TextEditor::UniformTextSection { public: //============================================================================== @@ -92,7 +92,7 @@ public: atoms.ensureStorageAllocated (other.atoms.size()); for (int i = 0; i < other.atoms.size(); ++i) - atoms.add (new TextAtom (*(const TextAtom*) other.atoms.getUnchecked(i))); + atoms.add (new TextAtom (*other.atoms.getUnchecked(i))); } ~UniformTextSection() @@ -113,16 +113,16 @@ public: return atoms.size(); } - TextAtom* getAtom (const int index) const + TextAtom* getAtom (const int index) const throw() { - return (TextAtom*) atoms.getUnchecked (index); + return atoms.getUnchecked (index); } void append (const UniformTextSection& other, const juce_wchar passwordCharacter) { if (other.atoms.size() > 0) { - TextAtom* const lastAtom = (TextAtom*) atoms.getLast(); + TextAtom* const lastAtom = atoms.getLast(); int i = 0; if (lastAtom != 0) @@ -256,7 +256,7 @@ public: for (int i = atoms.size(); --i >= 0;) { - TextAtom* const atom = (TextAtom*) atoms.getUnchecked(i); + TextAtom* const atom = atoms.getUnchecked(i); atom->width = newFont.getStringWidthFloat (atom->getText (passwordCharacter)); } } @@ -269,7 +269,7 @@ public: Colour colour; private: - VoidArray atoms; + Array atoms; //============================================================================== void initialiseAtoms (const String& textToParse, @@ -333,13 +333,13 @@ private: }; //============================================================================== -class TextEditorIterator +class TextEditor::Iterator { public: //============================================================================== - TextEditorIterator (const VoidArray& sections_, - const float wordWrapWidth_, - const juce_wchar passwordCharacter_) + Iterator (const Array & sections_, + const float wordWrapWidth_, + const juce_wchar passwordCharacter_) : indexInText (0), lineY (0), lineHeight (0), @@ -358,14 +358,14 @@ public: if (sections.size() > 0) { - currentSection = (const UniformTextSection*) sections.getUnchecked (sectionIndex); + currentSection = sections.getUnchecked (sectionIndex); if (currentSection != 0) beginNewLine(); } } - TextEditorIterator (const TextEditorIterator& other) + Iterator (const Iterator& other) : indexInText (other.indexInText), lineY (other.lineY), lineHeight (other.lineHeight), @@ -383,7 +383,7 @@ public: { } - ~TextEditorIterator() + ~Iterator() { } @@ -441,7 +441,7 @@ public: } atomIndex = 0; - currentSection = (const UniformTextSection*) sections.getUnchecked (sectionIndex); + currentSection = sections.getUnchecked (sectionIndex); } else { @@ -457,7 +457,7 @@ public: for (int section = sectionIndex + 1; section < sections.size(); ++section) { - const UniformTextSection* const s = (const UniformTextSection*) sections.getUnchecked (section); + const UniformTextSection* const s = sections.getUnchecked (section); if (s->getNumAtoms() == 0) break; @@ -540,7 +540,7 @@ public: int tempSectionIndex = sectionIndex; int tempAtomIndex = atomIndex; - const UniformTextSection* section = (const UniformTextSection*) sections.getUnchecked (tempSectionIndex); + const UniformTextSection* section = sections.getUnchecked (tempSectionIndex); lineHeight = section->font.getHeight(); maxDescent = section->font.getDescent(); @@ -560,7 +560,7 @@ public: break; tempAtomIndex = 0; - section = (const UniformTextSection*) sections.getUnchecked (tempSectionIndex); + section = sections.getUnchecked (tempSectionIndex); checkSize = true; } @@ -727,13 +727,13 @@ public: const UniformTextSection* currentSection; private: - const VoidArray& sections; + const Array & sections; int sectionIndex, atomIndex; const float wordWrapWidth; const juce_wchar passwordCharacter; TextAtom tempAtom; - TextEditorIterator& operator= (const TextEditorIterator&); + Iterator& operator= (const Iterator&); void moveToEndOfLastAtom() { @@ -757,7 +757,7 @@ private: //============================================================================== -class TextEditorInsertAction : public UndoableAction +class TextEditor::InsertAction : public UndoableAction { TextEditor& owner; const String text; @@ -765,17 +765,17 @@ class TextEditorInsertAction : public UndoableAction const Font font; const Colour colour; - TextEditorInsertAction (const TextEditorInsertAction&); - TextEditorInsertAction& operator= (const TextEditorInsertAction&); + InsertAction (const InsertAction&); + InsertAction& operator= (const InsertAction&); public: - TextEditorInsertAction (TextEditor& owner_, - const String& text_, - const int insertIndex_, - const Font& font_, - const Colour& colour_, - const int oldCaretPos_, - const int newCaretPos_) + InsertAction (TextEditor& owner_, + const String& text_, + const int insertIndex_, + const Font& font_, + const Colour& colour_, + const int oldCaretPos_, + const int newCaretPos_) : owner (owner_), text (text_), insertIndex (insertIndex_), @@ -786,7 +786,7 @@ public: { } - ~TextEditorInsertAction() + ~InsertAction() { } @@ -809,22 +809,22 @@ public: }; //============================================================================== -class TextEditorRemoveAction : public UndoableAction +class TextEditor::RemoveAction : public UndoableAction { TextEditor& owner; const Range range; const int oldCaretPos, newCaretPos; - VoidArray removedSections; + Array removedSections; - TextEditorRemoveAction (const TextEditorRemoveAction&); - TextEditorRemoveAction& operator= (const TextEditorRemoveAction&); + RemoveAction (const RemoveAction&); + RemoveAction& operator= (const RemoveAction&); public: - TextEditorRemoveAction (TextEditor& owner_, - const Range range_, - const int oldCaretPos_, - const int newCaretPos_, - const VoidArray& removedSections_) + RemoveAction (TextEditor& owner_, + const Range range_, + const int oldCaretPos_, + const int newCaretPos_, + const Array & removedSections_) : owner (owner_), range (range_), oldCaretPos (oldCaretPos_), @@ -833,11 +833,11 @@ public: { } - ~TextEditorRemoveAction() + ~RemoveAction() { for (int i = removedSections.size(); --i >= 0;) { - UniformTextSection* const section = (UniformTextSection*) removedSections.getUnchecked (i); + UniformTextSection* const section = removedSections.getUnchecked (i); section->clear(); delete section; } @@ -861,25 +861,17 @@ public: int n = 0; for (int i = removedSections.size(); --i >= 0;) - { - UniformTextSection* const section = (UniformTextSection*) removedSections.getUnchecked (i); - n += section->getTotalLength(); - } + n += removedSections.getUnchecked (i)->getTotalLength(); return n + 16; } }; //============================================================================== -class TextHolderComponent : public Component, - public Timer, - public Value::Listener +class TextEditor::TextHolderComponent : public Component, + public Timer, + public Value::Listener { - TextEditor& owner; - - TextHolderComponent (const TextHolderComponent&); - TextHolderComponent& operator= (const TextHolderComponent&); - public: TextHolderComponent (TextEditor& owner_) : owner (owner_) @@ -914,17 +906,17 @@ public: { owner.textWasChangedByValue(); } + +private: + TextEditor& owner; + + TextHolderComponent (const TextHolderComponent&); + TextHolderComponent& operator= (const TextHolderComponent&); }; //============================================================================== class TextEditorViewport : public Viewport { - TextEditor* const owner; - float lastWordWrapWidth; - - TextEditorViewport (const TextEditorViewport&); - TextEditorViewport& operator= (const TextEditorViewport&); - public: TextEditorViewport (TextEditor* const owner_) : owner (owner_), @@ -946,6 +938,13 @@ public: owner->updateTextHolderSize(); } } + +private: + TextEditor* const owner; + float lastWordWrapWidth; + + TextEditorViewport (const TextEditorViewport&); + TextEditorViewport& operator= (const TextEditorViewport&); }; //============================================================================== @@ -1113,7 +1112,7 @@ void TextEditor::applyFontToAllText (const Font& newFont) for (int i = sections.size(); --i >= 0;) { - UniformTextSection* const uts = (UniformTextSection*) sections.getUnchecked(i); + UniformTextSection* const uts = sections.getUnchecked (i); uts->setFont (newFont, passwordCharacter); uts->colour = overallColour; } @@ -1311,7 +1310,7 @@ void TextEditor::repaintText (const Range& range) if (wordWrapWidth > 0) { - TextEditorIterator i (sections, wordWrapWidth, passwordCharacter); + Iterator i (sections, wordWrapWidth, passwordCharacter); i.getCharPosition (range.getStart(), x, y, lh); @@ -1429,7 +1428,7 @@ void TextEditor::updateTextHolderSize() { float maxWidth = 0.0f; - TextEditorIterator i (sections, wordWrapWidth, passwordCharacter); + Iterator i (sections, wordWrapWidth, passwordCharacter); while (i.next()) maxWidth = jmax (maxWidth, i.atomRight); @@ -1665,7 +1664,7 @@ void TextEditor::drawContent (Graphics& g) const Rectangle clip (g.getClipBounds()); Colour selectedTextColour; - TextEditorIterator i (sections, wordWrapWidth, passwordCharacter); + Iterator i (sections, wordWrapWidth, passwordCharacter); while (i.lineY + 200.0 < clip.getY() && i.next()) {} @@ -1677,7 +1676,7 @@ void TextEditor::drawContent (Graphics& g) selectedTextColour = findColour (highlightedTextColourId); - TextEditorIterator i2 (i); + Iterator i2 (i); while (i2.next() && i2.lineY < clip.getBottom()) { @@ -2223,13 +2222,8 @@ void TextEditor::insert (const String& text, if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) newTransaction(); - um->perform (new TextEditorInsertAction (*this, - text, - insertIndex, - font, - colour, - caretPosition, - caretPositionToMoveTo)); + um->perform (new InsertAction (*this, text, insertIndex, font, colour, + caretPosition, caretPositionToMoveTo)); } else { @@ -2241,7 +2235,7 @@ void TextEditor::insert (const String& text, for (int i = 0; i < sections.size(); ++i) { - nextIndex = index + ((UniformTextSection*) sections.getUnchecked(i))->getTotalLength(); + nextIndex = index + sections.getUnchecked (i)->getTotalLength(); if (insertIndex == index) { @@ -2279,19 +2273,19 @@ void TextEditor::insert (const String& text, } void TextEditor::reinsert (const int insertIndex, - const VoidArray& sectionsToInsert) + const Array & sectionsToInsert) { int index = 0; int nextIndex = 0; for (int i = 0; i < sections.size(); ++i) { - nextIndex = index + ((UniformTextSection*) sections.getUnchecked(i))->getTotalLength(); + nextIndex = index + sections.getUnchecked (i)->getTotalLength(); if (insertIndex == index) { for (int j = sectionsToInsert.size(); --j >= 0;) - sections.insert (i, new UniformTextSection (*(UniformTextSection*) sectionsToInsert.getUnchecked(j))); + sections.insert (i, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); break; } @@ -2300,7 +2294,7 @@ void TextEditor::reinsert (const int insertIndex, splitSection (i, insertIndex - index); for (int j = sectionsToInsert.size(); --j >= 0;) - sections.insert (i + 1, new UniformTextSection (*(UniformTextSection*) sectionsToInsert.getUnchecked(j))); + sections.insert (i + 1, new UniformTextSection (*sectionsToInsert.getUnchecked(j))); break; } @@ -2311,7 +2305,7 @@ void TextEditor::reinsert (const int insertIndex, if (nextIndex == insertIndex) { for (int j = 0; j < sectionsToInsert.size(); ++j) - sections.add (new UniformTextSection (*(UniformTextSection*) sectionsToInsert.getUnchecked(j))); + sections.add (new UniformTextSection (*sectionsToInsert.getUnchecked(j))); } coalesceSimilarSections(); @@ -2329,7 +2323,7 @@ void TextEditor::remove (const Range& range, for (int i = 0; i < sections.size(); ++i) { - const int nextIndex = index + ((UniformTextSection*) sections[i])->getTotalLength(); + const int nextIndex = index + sections.getUnchecked(i)->getTotalLength(); if (range.getStart() > index && range.getStart() < nextIndex) { @@ -2354,14 +2348,14 @@ void TextEditor::remove (const Range& range, if (um != 0) { - VoidArray removedSections; + Array removedSections; for (int i = 0; i < sections.size(); ++i) { if (range.getEnd() <= range.getStart()) break; - UniformTextSection* const section = (UniformTextSection*) sections.getUnchecked (i); + UniformTextSection* const section = sections.getUnchecked (i); const int nextIndex = index + section->getTotalLength(); @@ -2374,11 +2368,8 @@ void TextEditor::remove (const Range& range, if (um->getNumActionsInCurrentTransaction() > TextEditorDefs::maxActionsPerTransaction) newTransaction(); - um->perform (new TextEditorRemoveAction (*this, - range, - caretPosition, - caretPositionToMoveTo, - removedSections)); + um->perform (new RemoveAction (*this, range, caretPosition, + caretPositionToMoveTo, removedSections)); } else { @@ -2386,7 +2377,7 @@ void TextEditor::remove (const Range& range, for (int i = 0; i < sections.size(); ++i) { - UniformTextSection* const section = (UniformTextSection*) sections.getUnchecked (i); + UniformTextSection* const section = sections.getUnchecked (i); const int nextIndex = index + section->getTotalLength(); @@ -2427,7 +2418,7 @@ const String TextEditor::getText() const String::Concatenator concatenator (t); for (int i = 0; i < sections.size(); ++i) - ((const UniformTextSection*) sections.getUnchecked(i))->appendAllText (concatenator); + sections.getUnchecked (i)->appendAllText (concatenator); return t; } @@ -2444,7 +2435,7 @@ const String TextEditor::getTextInRange (const Range& range) const for (int i = 0; i < sections.size(); ++i) { - const UniformTextSection* const s = (const UniformTextSection*) sections.getUnchecked(i); + const UniformTextSection* const s = sections.getUnchecked (i); const int nextIndex = index + s->getTotalLength(); if (range.getStart() < nextIndex) @@ -2474,7 +2465,7 @@ int TextEditor::getTotalNumChars() const totalNumChars = 0; for (int i = sections.size(); --i >= 0;) - totalNumChars += ((const UniformTextSection*) sections.getUnchecked(i))->getTotalLength(); + totalNumChars += sections.getUnchecked (i)->getTotalLength(); } return totalNumChars; @@ -2491,7 +2482,7 @@ void TextEditor::getCharPosition (const int index, float& cx, float& cy, float& if (wordWrapWidth > 0 && sections.size() > 0) { - TextEditorIterator i (sections, wordWrapWidth, passwordCharacter); + Iterator i (sections, wordWrapWidth, passwordCharacter); i.getCharPosition (index, cx, cy, lineHeight); } @@ -2508,7 +2499,7 @@ int TextEditor::indexAtPosition (const float x, const float y) if (wordWrapWidth > 0) { - TextEditorIterator i (sections, wordWrapWidth, passwordCharacter); + Iterator i (sections, wordWrapWidth, passwordCharacter); while (i.next()) { @@ -2589,16 +2580,15 @@ void TextEditor::splitSection (const int sectionIndex, jassert (sections[sectionIndex] != 0); sections.insert (sectionIndex + 1, - ((UniformTextSection*) sections.getUnchecked (sectionIndex)) - ->split (charToSplitAt, passwordCharacter)); + sections.getUnchecked (sectionIndex)->split (charToSplitAt, passwordCharacter)); } void TextEditor::coalesceSimilarSections() { for (int i = 0; i < sections.size() - 1; ++i) { - UniformTextSection* const s1 = (UniformTextSection*) sections.getUnchecked (i); - UniformTextSection* const s2 = (UniformTextSection*) sections.getUnchecked (i + 1); + UniformTextSection* const s1 = sections.getUnchecked (i); + UniformTextSection* const s2 = sections.getUnchecked (i + 1); if (s1->font == s2->font && s1->colour == s2->colour) diff --git a/src/gui/components/controls/juce_TextEditor.h b/src/gui/components/controls/juce_TextEditor.h index 9448645e30..dbb01ae98a 100644 --- a/src/gui/components/controls/juce_TextEditor.h +++ b/src/gui/components/controls/juce_TextEditor.h @@ -35,7 +35,6 @@ #include "../../../containers/juce_Value.h" #include "../keyboard/juce_TextInputTarget.h" class TextEditor; -class TextHolderComponent; //============================================================================== @@ -609,6 +608,14 @@ protected: private: //============================================================================== + class Iterator; + class UniformTextSection; + class TextHolderComponent; + class InsertAction; + class RemoveAction; + friend class InsertAction; + friend class RemoveAction; + ScopedPointer viewport; TextHolderComponent* textHolder; BorderSize borderSize; @@ -637,7 +644,7 @@ private: Font currentFont; mutable int totalNumChars; int caretPosition; - VoidArray sections; + Array sections; String textToShowWhenEmpty; Colour colourForTextWhenEmpty; juce_wchar passwordCharacter; @@ -653,15 +660,12 @@ private: String allowedCharacters; ListenerList listeners; - friend class TextEditorInsertAction; - friend class TextEditorRemoveAction; - void coalesceSimilarSections(); void splitSection (int sectionIndex, int charToSplitAt); void clearInternal (UndoManager* um); void insert (const String& text, int insertIndex, const Font& font, const Colour& colour, UndoManager* um, int caretPositionToMoveTo); - void reinsert (int insertIndex, const VoidArray& sections); + void reinsert (int insertIndex, const Array & sections); void remove (const Range& range, UndoManager* um, int caretPositionToMoveTo); void getCharPosition (int index, float& x, float& y, float& lineHeight) const; void updateCaretPosition(); diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 19e230fc74..62c0524740 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -1321,7 +1321,7 @@ void Component::internalHierarchyChanged() //============================================================================== void* Component::runModalLoopCallback (void* userData) { - return (void*) (pointer_sized_int) ((Component*) userData)->runModalLoop(); + return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); } int Component::runModalLoop() @@ -2092,7 +2092,7 @@ void Component::addMouseListener (MouseListener* const newListener, checkMessageManagerIsLocked if (mouseListeners_ == 0) - mouseListeners_ = new VoidArray(); + mouseListeners_ = new Array(); if (! mouseListeners_->contains (newListener)) { @@ -2168,7 +2168,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point& { for (int i = mouseListeners_->size(); --i >= 0;) { - ((MouseListener*) mouseListeners_->getUnchecked(i))->mouseEnter (me); + mouseListeners_->getUnchecked(i)->mouseEnter (me); if (checker.shouldBailOut()) return; @@ -2187,7 +2187,7 @@ void Component::internalMouseEnter (MouseInputSource& source, const Point& for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked(i)))->mouseEnter (me); + p->mouseListeners_->getUnchecked(i)->mouseEnter (me); if (checker.shouldBailOut()) return; @@ -2259,7 +2259,7 @@ void Component::internalMouseExit (MouseInputSource& source, const Point& r for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseExit (me); + p->mouseListeners_->getUnchecked (i)->mouseExit (me); if (checker.shouldBailOut()) return; @@ -2426,7 +2426,7 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDown (me); + p->mouseListeners_->getUnchecked (i)->mouseDown (me); if (checker.shouldBailOut()) return; @@ -2495,7 +2495,7 @@ void Component::internalMouseUp (MouseInputSource& source, const Point& rel for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseUp (me); + p->mouseListeners_->getUnchecked (i)->mouseUp (me); if (checker.shouldBailOut()) return; @@ -2546,7 +2546,7 @@ void Component::internalMouseUp (MouseInputSource& source, const Point& rel for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDoubleClick (me); + p->mouseListeners_->getUnchecked (i)->mouseDoubleClick (me); if (checker.shouldBailOut()) return; @@ -2612,7 +2612,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point& r for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseDrag (me); + p->mouseListeners_->getUnchecked (i)->mouseDrag (me); if (checker.shouldBailOut()) return; @@ -2678,7 +2678,7 @@ void Component::internalMouseMove (MouseInputSource& source, const Point& r for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseMove (me); + p->mouseListeners_->getUnchecked (i)->mouseMove (me); if (checker.shouldBailOut()) return; @@ -2744,7 +2744,7 @@ void Component::internalMouseWheel (MouseInputSource& source, const Point& for (int i = p->numDeepMouseListeners; --i >= 0;) { - ((MouseListener*) (p->mouseListeners_->getUnchecked (i)))->mouseWheelMove (me, wheelIncrementX, wheelIncrementY); + p->mouseListeners_->getUnchecked (i)->mouseWheelMove (me, wheelIncrementX, wheelIncrementY); if (checker.shouldBailOut()) return; diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index c2ac825f0c..b6143ae727 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -2001,7 +2001,7 @@ private: MouseCursor cursor_; ImageEffectFilter* effect_; Image* bufferedImage_; - VoidArray* mouseListeners_; + Array * mouseListeners_; VoidArray* keyListeners_; ListenerList componentListeners; NamedValueSet properties; diff --git a/src/gui/components/layout/juce_ComponentMovementWatcher.cpp b/src/gui/components/layout/juce_ComponentMovementWatcher.cpp index 8a2806ddf6..2c3c5d35f7 100644 --- a/src/gui/components/layout/juce_ComponentMovementWatcher.cpp +++ b/src/gui/components/layout/juce_ComponentMovementWatcher.cpp @@ -116,7 +116,7 @@ void ComponentMovementWatcher::registerWithParentComps() throw() void ComponentMovementWatcher::unregister() throw() { for (int i = registeredParentComps.size(); --i >= 0;) - ((Component*) registeredParentComps.getUnchecked(i))->removeComponentListener (this); + static_cast (registeredParentComps.getUnchecked(i))->removeComponentListener (this); registeredParentComps.clear(); } diff --git a/src/gui/components/menus/juce_MenuBarComponent.cpp b/src/gui/components/menus/juce_MenuBarComponent.cpp index 8af0d72107..205de89f1a 100644 --- a/src/gui/components/menus/juce_MenuBarComponent.cpp +++ b/src/gui/components/menus/juce_MenuBarComponent.cpp @@ -340,7 +340,7 @@ void MenuBarComponent::mouseUp (const MouseEvent& e) updateItemUnderMouse (e2.x, e2.y); - if (itemUnderMouse < 0 && dynamic_cast ((Component*) currentPopup) != 0) + if (itemUnderMouse < 0 && dynamic_cast (static_cast (currentPopup)) != 0) hideCurrentMenu(); } diff --git a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp index 5354789783..2d4d6a6483 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp @@ -196,7 +196,7 @@ namespace JPEGHelpers static void jpegWriteTerminate (j_compress_ptr cinfo) { - JuceJpegDest* const dest = (JuceJpegDest*) cinfo->dest; + JuceJpegDest* const dest = static_cast (cinfo->dest); const size_t numToWrite = jpegBufferSize - dest->free_in_buffer; dest->output->write (dest->buffer, (int) numToWrite); @@ -204,11 +204,11 @@ namespace JPEGHelpers static boolean jpegWriteFlush (j_compress_ptr cinfo) { - JuceJpegDest* const dest = (JuceJpegDest*) cinfo->dest; + JuceJpegDest* const dest = static_cast (cinfo->dest); const int numToWrite = jpegBufferSize; - dest->next_output_byte = (JOCTET*) dest->buffer; + dest->next_output_byte = reinterpret_cast (dest->buffer); dest->free_in_buffer = jpegBufferSize; return dest->output->write (dest->buffer, numToWrite); @@ -245,7 +245,7 @@ Image* juce_loadJPEGImageFromStream (InputStream& in) jpegDecompStruct.src->resync_to_restart = jpeg_resync_to_restart; jpegDecompStruct.src->term_source = dummyCallback1; - jpegDecompStruct.src->next_input_byte = (const unsigned char*) mb.getData(); + jpegDecompStruct.src->next_input_byte = static_cast (mb.getData()); jpegDecompStruct.src->bytes_in_buffer = mb.getSize(); try @@ -341,7 +341,7 @@ bool juce_writeJPEGImageToStream (const Image& image, dest.output = &out; HeapBlock tempBuffer (jpegBufferSize); - dest.buffer = (char*) tempBuffer; + dest.buffer = tempBuffer; dest.next_output_byte = (JOCTET*) dest.buffer; dest.free_in_buffer = jpegBufferSize; dest.init_destination = jpegWriteInit; diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index d39f469709..442c614442 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -272,7 +272,7 @@ bool juce_writePNGImageToStream (const Image& image, OutputStream& out) PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - HeapBlock rowData (width * 4); + HeapBlock rowData (width * 4); png_color_8 sig_bit; sig_bit.red = 8; @@ -290,7 +290,7 @@ bool juce_writePNGImageToStream (const Image& image, OutputStream& out) for (int y = 0; y < height; ++y) { - uint8* dst = (uint8*) rowData; + uint8* dst = rowData; const uint8* src = srcData.getLinePointer (y); if (image.hasAlphaChannel()) diff --git a/src/native/mac/juce_mac_CoreAudio.cpp b/src/native/mac/juce_mac_CoreAudio.cpp index 2198864288..c5678fbed8 100644 --- a/src/native/mac/juce_mac_CoreAudio.cpp +++ b/src/native/mac/juce_mac_CoreAudio.cpp @@ -806,13 +806,13 @@ private: const AudioTimeStamp* inOutputTime, void* device) { - ((CoreAudioInternal*) device)->audioCallback (inInputData, outOutputData); + static_cast (device)->audioCallback (inInputData, outOutputData); return noErr; } static OSStatus deviceListenerProc (AudioDeviceID /*inDevice*/, UInt32 /*inLine*/, const AudioObjectPropertyAddress* pa, void* inClientData) { - CoreAudioInternal* const intern = (CoreAudioInternal*) inClientData; + CoreAudioInternal* const intern = static_cast (inClientData); switch (pa->mSelector) { @@ -1090,7 +1090,7 @@ private: static OSStatus hardwareListenerProc (AudioDeviceID /*inDevice*/, UInt32 /*inLine*/, const AudioObjectPropertyAddress* pa, void* inClientData) { - CoreAudioInternal* const intern = (CoreAudioInternal*) inClientData; + CoreAudioInternal* const intern = static_cast (inClientData); switch (pa->mSelector) { diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index 1565a578b9..1f313bc560 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -485,7 +485,7 @@ public: state->fontRef = 0; state->font = newFont; - MacTypeface* mf = dynamic_cast ((Typeface*) state->font.getTypeface()); + MacTypeface* mf = dynamic_cast (state->font.getTypeface()); if (mf != 0) { @@ -579,7 +579,7 @@ private: static void gradientCallback (void* info, const CGFloat* inData, CGFloat* outData) { - const CoreGraphicsContext* const g = (const CoreGraphicsContext*) info; + const CoreGraphicsContext* const g = static_cast (info); const int index = roundToInt (g->numGradientLookupEntries * inData[0]); PixelARGB colour (g->gradientLookupTable [jlimit (0, g->numGradientLookupEntries, index)]); diff --git a/src/native/mac/juce_mac_Fonts.mm b/src/native/mac/juce_mac_Fonts.mm index 965d4ce81e..3f9544be8a 100644 --- a/src/native/mac/juce_mac_Fonts.mm +++ b/src/native/mac/juce_mac_Fonts.mm @@ -135,7 +135,7 @@ public: if (atsFont == 0) atsFont = ATSFontFindFromPostScriptName ((CFStringRef) [nsFont fontName], kATSOptionFlagsDefault); - fontRef = CGFontCreateWithPlatformFont ((void*) &atsFont); + fontRef = CGFontCreateWithPlatformFont (&atsFont); const float totalHeight = fabsf ([nsFont ascender]) + fabsf([nsFont descender]); unitsToHeightScaleFactor = 1.0f / totalHeight; @@ -149,7 +149,7 @@ public: if (atsFont == 0) atsFont = ATSFontFindFromPostScriptName ((CFStringRef) [nsFont fontName], kATSOptionFlagsDefault); - fontRef = CGFontCreateWithPlatformFont ((void*) &atsFont); + fontRef = CGFontCreateWithPlatformFont (&atsFont); const float totalHeight = fabsf ([nsFont ascender]) + fabsf([nsFont descender]); unitsToHeightScaleFactor = 1.0f / totalHeight; diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index dc9fa8e733..3a595425d1 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -210,7 +210,7 @@ void* juce_openInternetFile (const String& url, if (bytesToDo > 0 && ! InternetWriteFile (request, - ((const char*) postData.getData()) + bytesSent, + static_cast (postData.getData()) + bytesSent, bytesToDo, &bytesDone)) { break; @@ -248,8 +248,7 @@ void* juce_openInternetFile (const String& url, int juce_readFromInternetFile (void* handle, void* buffer, int bytesToRead) { DWORD bytesRead = 0; - - const ConnectionAndRequestStruct* const crs = (const ConnectionAndRequestStruct*) handle; + const ConnectionAndRequestStruct* const crs = static_cast (handle); if (crs != 0) InternetReadFile (crs->request, @@ -263,11 +262,8 @@ int juce_seekInInternetFile (void* handle, int newPosition) { if (handle != 0) { - const ConnectionAndRequestStruct* const crs = (const ConnectionAndRequestStruct*) handle; - - return InternetSetFilePointer (crs->request, - newPosition, 0, - FILE_BEGIN, 0); + const ConnectionAndRequestStruct* const crs = static_cast (handle); + return InternetSetFilePointer (crs->request, newPosition, 0, FILE_BEGIN, 0); } else { @@ -277,19 +273,14 @@ int juce_seekInInternetFile (void* handle, int newPosition) int64 juce_getInternetFileContentLength (void* handle) { - const ConnectionAndRequestStruct* const crs = (const ConnectionAndRequestStruct*) handle; + const ConnectionAndRequestStruct* const crs = static_cast (handle); if (crs != 0) { - DWORD index = 0; - DWORD result = 0; - DWORD size = sizeof (result); + DWORD index = 0, result = 0, size = sizeof (result); - if (HttpQueryInfo (crs->request, - HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, - &result, - &size, - &index)) + if (HttpQueryInfo (crs->request, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, + &result, &size, &index)) { return (int64) result; } @@ -302,7 +293,7 @@ void juce_closeInternetFile (void* handle) { if (handle != 0) { - ConnectionAndRequestStruct* const crs = (ConnectionAndRequestStruct*) handle; + ConnectionAndRequestStruct* const crs = static_cast (handle); InternetCloseHandle (crs->request); InternetCloseHandle (crs->connection); delete crs; @@ -457,9 +448,8 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd message.nRecipCount = 1; message.lpRecips = &recip; - MemoryBlock mb (sizeof (MapiFileDesc) * filesToAttach.size()); - mb.fillWith (0); - MapiFileDesc* files = (MapiFileDesc*) mb.getData(); + HeapBlock files; + files.calloc (filesToAttach.size()); message.nFileCount = filesToAttach.size(); message.lpFiles = files; diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 6fcae38941..bf0f51c36e 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -313,7 +313,7 @@ void* PlatformUtilities::loadDynamicLibrary (const String& name) JUCE_TRY { - result = (void*) LoadLibrary (name); + result = LoadLibrary (name); } JUCE_CATCH_ALL