From d4435ca8b812384264d89a3c6974ff1db6867037 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Wed, 14 Apr 2010 20:08:21 +0100 Subject: [PATCH] Minor clean-ups. Jucer development. --- .../Source/model/jucer_ComponentDocument.cpp | 113 +++- .../jucer_ComponentEditor.cpp | 276 ++++++++-- .../Source/utility/jucer_UtilityFunctions.cpp | 10 + .../Source/utility/jucer_UtilityFunctions.h | 9 +- .../utility/jucer_ValueRemapperSource.h | 13 +- juce_amalgamated.cpp | 484 +++++++++--------- juce_amalgamated.h | 44 +- src/application/juce_Application.cpp | 2 +- .../audio_file_formats/juce_AudioFormat.cpp | 2 +- .../audio_file_formats/juce_AudioFormat.h | 2 +- .../juce_AudioThumbnail.cpp | 6 +- .../juce_AudioThumbnailCache.cpp | 5 +- .../juce_FlacAudioFormat.cpp | 4 +- .../juce_OggVorbisAudioFormat.cpp | 6 +- .../juce_WavAudioFormat.cpp | 8 +- .../juce_BufferingAudioSource.cpp | 10 +- .../audio_sources/juce_MixerAudioSource.cpp | 2 +- src/audio/dsp/juce_AudioDataConverters.cpp | 38 +- src/audio/midi/juce_MidiFile.cpp | 12 +- src/audio/midi/juce_MidiFile.h | 2 +- src/audio/midi/juce_MidiMessage.cpp | 4 +- src/containers/juce_BitArray.cpp | 2 +- src/containers/juce_MemoryBlock.cpp | 8 +- src/containers/juce_Variant.cpp | 2 +- src/events/juce_InterprocessConnection.cpp | 2 +- src/events/juce_MessageManager.cpp | 6 +- .../code_editor/juce_CodeDocument.cpp | 18 +- .../code_editor/juce_CodeDocument.h | 4 +- .../code_editor/juce_CodeEditorComponent.cpp | 18 +- .../code_editor/juce_CodeEditorComponent.h | 3 +- src/gui/components/controls/juce_ListBox.cpp | 4 +- src/gui/components/controls/juce_Slider.h | 1 - .../components/controls/juce_TableListBox.cpp | 2 +- .../components/controls/juce_TextEditor.cpp | 2 +- src/gui/components/controls/juce_TreeView.cpp | 64 ++- src/gui/components/controls/juce_TreeView.h | 11 +- .../juce_FileSearchPathListComponent.cpp | 8 +- .../juce_FileSearchPathListComponent.h | 9 +- src/gui/components/juce_Component.cpp | 2 +- src/gui/components/layout/juce_ScrollBar.cpp | 16 +- src/gui/components/layout/juce_ScrollBar.h | 5 +- src/gui/components/menus/juce_PopupMenu.cpp | 2 +- src/gui/components/mouse/juce_MouseCursor.cpp | 2 +- .../properties/juce_PropertyPanel.cpp | 22 +- .../properties/juce_PropertyPanel.h | 3 +- .../special/juce_ColourSelector.cpp | 24 +- .../components/special/juce_ColourSelector.h | 9 +- .../windows/juce_ResizableWindow.cpp | 2 +- .../windows/juce_TopLevelWindow.cpp | 2 +- src/gui/graphics/drawables/juce_SVGParser.cpp | 2 +- .../graphics/fonts/juce_GlyphArrangement.cpp | 2 +- src/gui/graphics/fonts/juce_Typeface.cpp | 4 +- .../image_file_formats/juce_GIFLoader.cpp | 6 +- src/io/files/juce_ZipFile.cpp | 7 +- src/io/streams/juce_BufferedInputStream.cpp | 2 +- .../juce_GZIPCompressorOutputStream.cpp | 8 +- .../juce_GZIPDecompressorInputStream.cpp | 4 +- src/io/streams/juce_OutputStream.cpp | 2 +- src/native/linux/juce_linux_Audio.cpp | 4 +- src/native/linux/juce_linux_Network.cpp | 2 +- src/native/linux/juce_linux_Threads.cpp | 2 +- src/native/linux/juce_linux_Windowing.cpp | 2 +- src/native/mac/juce_mac_CoreAudio.cpp | 6 +- .../mac/juce_mac_CoreGraphicsContext.mm | 2 +- src/native/mac/juce_mac_CoreMidi.cpp | 8 +- src/native/mac/juce_mac_MouseCursor.mm | 4 +- .../mac/juce_mac_NSViewComponentPeer.mm | 14 +- src/native/mac/juce_mac_OpenGLComponent.mm | 2 +- src/native/mac/juce_mac_Strings.mm | 5 +- .../windows/juce_win32_AudioCDReader.cpp | 8 +- .../juce_win32_DynamicLibraryLoader.cpp | 2 +- src/native/windows/juce_win32_Files.cpp | 2 +- src/native/windows/juce_win32_Messaging.cpp | 2 +- src/native/windows/juce_win32_Midi.cpp | 6 +- src/native/windows/juce_win32_Misc.cpp | 2 +- .../juce_win32_QuickTimeMovieComponent.cpp | 4 +- src/native/windows/juce_win32_Threads.cpp | 2 +- src/native/windows/juce_win32_Windowing.cpp | 22 +- src/text/juce_String.cpp | 10 +- src/text/juce_StringArray.cpp | 2 +- src/text/juce_XmlDocument.cpp | 4 +- src/text/juce_XmlElement.cpp | 2 +- src/threads/juce_Thread.cpp | 4 +- src/threads/juce_ThreadPool.cpp | 2 +- src/utilities/juce_DeletedAtShutdown.cpp | 2 +- 85 files changed, 900 insertions(+), 569 deletions(-) diff --git a/extras/Jucer (experimental)/Source/model/jucer_ComponentDocument.cpp b/extras/Jucer (experimental)/Source/model/jucer_ComponentDocument.cpp index a4cf56cf88..f7913739b6 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ComponentDocument.cpp +++ b/extras/Jucer (experimental)/Source/model/jucer_ComponentDocument.cpp @@ -27,7 +27,6 @@ #include "Component Types/jucer_TextButton.h" #include "Component Types/jucer_ToggleButton.h" - //============================================================================== static const char* const componentDocumentTag = "COMPONENT"; static const char* const componentGroupTag = "COMPONENTS"; @@ -40,6 +39,112 @@ static const char* const compNameProperty = "name"; static const char* const metadataTagStart = "JUCER_" "COMPONENT_METADATA_START"; // written like this to avoid thinking this file is a component! static const char* const metadataTagEnd = "JUCER_" "COMPONENT_METADATA_END"; + +//============================================================================== +class ComponentBoundsEditor : public PropertyComponent +{ +public: + enum Type + { + left, top, right, bottom + }; + + //============================================================================== + ComponentBoundsEditor (const String& name, Type type_, const Value& state_) + : PropertyComponent (name, 40), type (type_), state (state_) + { + addAndMakeVisible (label = new Label (String::empty, String::empty)); + + label->setEditable (true, true, false); + label->setColour (Label::backgroundColourId, Colours::white); + label->setColour (Label::outlineColourId, findColour (ComboBox::outlineColourId)); + label->getTextValue().referTo (Value (new BoundsCoordValueSource (state, type))); + } + + ~ComponentBoundsEditor() + { + } + + void resized() + { + const Rectangle content (getLookAndFeel().getPropertyComponentContentPosition (*this)); + + label->setBounds (content.getX(), content.getY(), content.getWidth(), content.getHeight() / 2); + } + + void refresh() + { + } + + //============================================================================== + class BoundsCoordValueSource : public Value::ValueSource, + public Value::Listener + { + public: + BoundsCoordValueSource (const Value& sourceValue_, Type type_) + : sourceValue (sourceValue_), type (type_) + { + sourceValue.addListener (this); + } + + ~BoundsCoordValueSource() {} + + const var getValue() const + { + RectangleCoordinates r (sourceValue.toString()); + Coordinate& coord = getCoord (r); + return coord.getEditableValue(); + } + + void setValue (const var& newValue) + { + RectangleCoordinates r (sourceValue.toString()); + Coordinate& coord = getCoord (r); + + coord.setEditableValue ((double) newValue); + + const String newVal (r.toString()); + if (sourceValue != newVal) + sourceValue = newVal; + } + + void valueChanged (Value&) + { + sendChangeMessage (true); + } + + //============================================================================== + juce_UseDebuggingNewOperator + + protected: + Value sourceValue; + Type type; + + Coordinate& getCoord (RectangleCoordinates& r) const + { + switch (type) + { + case left: return r.left; + case right: return r.right; + case top: return r.top; + case bottom: return r.bottom; + default: jassertfalse; break; + } + + return r.left; + } + + BoundsCoordValueSource (const BoundsCoordValueSource&); + const BoundsCoordValueSource& operator= (const BoundsCoordValueSource&); + }; + +private: + Type type; + Value state; + Label* label; +}; + + //============================================================================== ComponentTypeHandler::ComponentTypeHandler (const String& name_, const String& xmlTag_, const String& memberNameRoot_) @@ -82,8 +187,10 @@ void ComponentTypeHandler::initialiseNewItem (ComponentDocument& document, Value void ComponentTypeHandler::createPropertyEditors (ComponentDocument& document, ValueTree& state, Array & props) { - props.add (new TextPropertyComponent (getValue (compBoundsProperty, state, document), "Bounds", 512, false)); - props.getLast()->setTooltip ("The component's position."); + props.add (new ComponentBoundsEditor ("Left", ComponentBoundsEditor::left, getValue (compBoundsProperty, state, document))); + props.add (new ComponentBoundsEditor ("Right", ComponentBoundsEditor::right, getValue (compBoundsProperty, state, document))); + props.add (new ComponentBoundsEditor ("Top", ComponentBoundsEditor::top, getValue (compBoundsProperty, state, document))); + props.add (new ComponentBoundsEditor ("Bottom", ComponentBoundsEditor::bottom, getValue (compBoundsProperty, state, document))); } //============================================================================== diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditor.cpp b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditor.cpp index b0746d45a4..794dce1994 100644 --- a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditor.cpp +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditor.cpp @@ -38,14 +38,14 @@ public: }; SizeGuideComponent (ComponentDocument& document_, const ValueTree& state_, Component* component_, - Component* parentForOverlays, Type type_) + Component& parentForOverlays, Type type_) : document (document_), state (state_), component (component_), type (type_), font (10.0f) { component->addComponentListener (this); setAlwaysOnTop (true); - parentForOverlays->addAndMakeVisible (this); + parentForOverlays.addAndMakeVisible (this); updatePosition(); } @@ -72,55 +72,64 @@ public: setName (coord.toString()); - ScopedPointer markers (document.createMarkerResolver (state, component->getParentComponent())); - int anchor1 = roundToInt (coord.getAnchorPoint1().resolve (*markers)); - int anchor2 = roundToInt (coord.getAnchorPoint2().resolve (*markers)); + //ScopedPointer markers (document.createMarkerResolver (state, component->getParentComponent())); + //int anchor1 = roundToInt (coord.getAnchorPoint1().resolve (*markers)); + //int anchor2 = roundToInt (coord.getAnchorPoint2().resolve (*markers)); + + int textW = (int) font.getStringWidth (getName()); + int textH = (int) font.getHeight(); Point p1, p2; switch (type) { - case left: p1 = Point (component->getX(), component->getY() + component->proportionOfHeight (0.33f)); - p2 = Point (anchor1, p1.getY()); break; - case right: p1 = Point (component->getRight(), component->getY() + component->proportionOfHeight (0.66f)); - p2 = Point (anchor1, p1.getY()); break; - case top: p1 = Point (component->getX() + component->proportionOfWidth (0.33f), component->getY()); - p2 = Point (p1.getX(), anchor1); break; - case bottom: p1 = Point (component->getX() + component->proportionOfWidth (0.66f), component->getBottom()); - p2 = Point (p1.getX(), anchor1); break; - default: jassertfalse; break; + case left: + p1 = Point (component->getX(), 0); + p2 = Point (component->getX(), component->getY()); + textArea.setBounds (p1.getX() - textW - 2, 4, textW, textH); + break; + + case right: + p1 = Point (component->getRight(), 0); + p2 = Point (component->getRight(), component->getY()); + textArea.setBounds (p1.getX() + 2, 4, textW, textH); + break; + + case top: + p1 = Point (0, component->getY()); + p2 = Point (component->getX(), component->getY()); + textArea.setBounds (4, p1.getY() - textH - 2, textW, textH); + break; + + case bottom: + p1 = Point (0, component->getBottom()); + p2 = Point (component->getX(), component->getBottom()); + textArea.setBounds (4, p1.getY() + 2, textW, textH); + break; + + default: + jassertfalse; + break; } - Rectangle bounds (Rectangle (p1, p2).expanded (4, 4)); - Point textPos ((p1.getX() + p2.getX()) / 2, - (p1.getY() + p2.getY()) / 2); - int textW = (int) font.getStringWidth (getName()); - int textH = (int) font.getHeight(); - Rectangle textRect (textPos.getX() - textW / 2, textPos.getY() - textH / 2, textW, textH); - - if (isHorizontal) - textRect = textRect - Point (0, textH / 2 + 4); - - bounds = bounds.getUnion (textRect); + Rectangle bounds (Rectangle (p1, p2).expanded (2, 2).getUnion (textArea)); + bounds.setPosition (component->getParentComponent()->relativePositionToOtherComponent (getParentComponent(), bounds.getPosition())); setBounds (bounds); - lineEnd1 = p1 - bounds.getPosition(); - lineEnd2 = p2 - bounds.getPosition(); - textArea = textRect - bounds.getPosition(); + lineEnd1 = component->getParentComponent()->relativePositionToOtherComponent (this, p1); + lineEnd2 = component->getParentComponent()->relativePositionToOtherComponent (this, p2); + textArea.setPosition (component->getParentComponent()->relativePositionToOtherComponent (this, textArea.getPosition())); repaint(); } void paint (Graphics& g) { - Path p; - p.addLineSegment ((float) lineEnd1.getX(), (float) lineEnd1.getY(), (float) lineEnd2.getX(), (float) lineEnd2.getY(), 1.6f); - const float startBlobSize = 2.0f; - p.addEllipse (lineEnd1.getX() - startBlobSize, lineEnd1.getY() - startBlobSize, startBlobSize * 2.0f, startBlobSize * 2.0f); - const float endBlobSize = 4.0f; - p.addEllipse (lineEnd2.getX() - endBlobSize, lineEnd2.getY() - endBlobSize, endBlobSize * 2.0f, endBlobSize * 2.0f); + const float dashes[] = { 4.0f, 3.0f }; - g.setColour (Colours::black.withAlpha (0.3f)); - g.fillPath (p); + g.setColour (Colours::grey.withAlpha (0.4f)); + g.drawDashedLine (lineEnd1.getX() + 0.5f, lineEnd1.getY() + 0.5f, + lineEnd2.getX() + 0.5f, lineEnd2.getY() + 0.5f, + dashes, 2, 1.0f); g.setFont (font); g.setColour (Colours::white); @@ -154,6 +163,111 @@ private: Rectangle textArea; }; +//============================================================================== +static const double tickSizes[] = { 1.0, 2.0, 5.0, + 10.0, 20.0, 50.0, + 100.0, 200.0, 500.0, 1000.0 }; + +class TickIterator +{ +public: + TickIterator (const double startValue_, const double endValue_, const double valuePerPixel_, + int minPixelsPerTick, int minWidthForLabels) + : startValue (startValue_), + endValue (endValue_), + valuePerPixel (valuePerPixel_) + { + tickLevelIndex = findLevelIndexForValue (valuePerPixel * minPixelsPerTick); + labelLevelIndex = findLevelIndexForValue (valuePerPixel * minWidthForLabels); + + tickPosition = pixelsToValue (-minWidthForLabels); + tickPosition = snapValueDown (tickPosition, tickLevelIndex); + } + + bool getNextTick (float& pixelX, float& tickLength, String& label) + { + const double tickUnits = tickSizes [tickLevelIndex]; + tickPosition += tickUnits; + + const int totalLevels = sizeof (tickSizes) / sizeof (*tickSizes); + int highestIndex = tickLevelIndex; + + while (++highestIndex < totalLevels) + { + const double ticksAtThisLevel = tickPosition / tickSizes [highestIndex]; + + if (fabs (ticksAtThisLevel - floor (ticksAtThisLevel + 0.5)) > 0.000001) + break; + } + + --highestIndex; + + if (highestIndex >= labelLevelIndex) + label = getDescriptionOfValue (tickPosition, labelLevelIndex); + else + label = String::empty; + + tickLength = (highestIndex + 1 - tickLevelIndex) / (float) (totalLevels + 1 - tickLevelIndex); + pixelX = valueToPixels (tickPosition); + + return tickPosition < endValue; + } + +private: + double tickPosition; + int tickLevelIndex, labelLevelIndex; + const double startValue, endValue, valuePerPixel; + + int findLevelIndexForValue (const double value) const + { + int i; + for (i = 0; i < sizeof (tickSizes) / sizeof (*tickSizes); ++i) + if (tickSizes [i] >= value) + break; + + return i; + } + + double pixelsToValue (int pixels) const + { + return startValue + pixels * valuePerPixel; + } + + float valueToPixels (double value) const + { + return (float) ((value - startValue) / valuePerPixel); + } + + static double snapValueToNearest (const double t, const int valueLevelIndex) + { + const double unitsPerInterval = tickSizes [valueLevelIndex]; + return unitsPerInterval * floor (t / unitsPerInterval + 0.5); + } + + static double snapValueDown (const double t, const int valueLevelIndex) + { + const double unitsPerInterval = tickSizes [valueLevelIndex]; + return unitsPerInterval * floor (t / unitsPerInterval); + } + + static inline int roundDoubleToInt (const double value) + { + union { int asInt[2]; double asDouble; } n; + n.asDouble = value + 6755399441055744.0; + + #if TARGET_RT_BIG_ENDIAN + return n.asInt [1]; + #else + return n.asInt [0]; + #endif + } + + static const String getDescriptionOfValue (const double value, const int valueLevelIndex) + { + return String (roundToInt (value)); + } +}; + //============================================================================== class ComponentEditor::Canvas : public Component, @@ -162,7 +276,7 @@ class ComponentEditor::Canvas : public Component, { public: Canvas (ComponentEditor& editor_) - : editor (editor_), borderThickness (4) + : editor (editor_), border (14), resizerThickness (4) { setOpaque (true); addAndMakeVisible (componentHolder = new Component()); @@ -184,12 +298,61 @@ public: { g.fillAll (Colours::white); g.setColour (Colour::greyLevel (0.9f)); - g.drawRect (0, 0, getWidth(), getHeight(), borderThickness); + + g.drawRect (getContentArea().expanded (resizerThickness, resizerThickness), resizerThickness); + + g.setFont (border.getBottom() - 5.0f); + g.setColour (Colours::grey); + g.drawText (String (componentHolder->getWidth()) + " x " + String (componentHolder->getHeight()), + 0, 0, getWidth() - border.getRight(), getHeight(), Justification::bottomRight, false); + + g.setFont (border.getTop() - 5.0f); + g.setColour (Colours::darkgrey); + + const float x = border.getLeft(); + const float y = border.getTop(); + + g.drawHorizontalLine (y, 2.0f, getWidth() - border.getRight()); + g.drawVerticalLine (x, 2.0f, getHeight() - border.getBottom()); + + { + TickIterator ticks (0, componentHolder->getWidth(), 1.0, 10, 50); + + float pos, tickLength; + String label; + + while (ticks.getNextTick (pos, tickLength, label)) + { + if (pos > 0) + { + g.drawVerticalLine (x + pos, y - tickLength * y, y); + g.drawSingleLineText (label, x + pos + 2, y - 6); + } + } + } + + { + TickIterator ticks (0, componentHolder->getHeight(), 1.0, 10, 80); + + float pos, tickLength; + String label; + + while (ticks.getNextTick (pos, tickLength, label)) + { + if (pos > 0) + { + g.drawHorizontalLine (y + pos, x - tickLength * x, x); + + g.drawTextAsPath (label, AffineTransform::rotation (float_Pi / -2.0f) + .translated (x - 6, y + pos - 2)); + } + } + } } void resized() { - componentHolder->setBounds (getLocalBounds().reduced (borderThickness, borderThickness)); + componentHolder->setBounds (getContentArea()); overlay->setBounds (componentHolder->getBounds()); updateComponents(); } @@ -310,15 +473,17 @@ public: { updateDragZone (e.getPosition()); dragStartSize = getBounds(); + showSizeGuides(); } void mouseDrag (const MouseEvent& e) { if (dragZone.isDraggingRightEdge() || dragZone.isDraggingBottomEdge()) { - showSizeGuides(); - setSize (jmax (0, dragStartSize.getWidth() + e.getDistanceFromDragStartX()), - jmax (0, dragStartSize.getHeight() + e.getDistanceFromDragStartY())); + setSize (dragZone.isDraggingRightEdge() ? jmax (0, dragStartSize.getWidth() + e.getDistanceFromDragStartX()) + : dragStartSize.getWidth(), + dragZone.isDraggingBottomEdge() ? jmax (0, dragStartSize.getHeight() + e.getDistanceFromDragStartY()) + : dragStartSize.getHeight()); } } @@ -331,11 +496,8 @@ public: void updateDragZone (const Point& p) { ResizableBorderComponent::Zone newZone - = ResizableBorderComponent::Zone::fromPositionOnBorder (getLocalBounds(), - BorderSize (borderThickness), p); - - newZone = ResizableBorderComponent::Zone (newZone.getZoneFlags() - & (ResizableBorderComponent::Zone::right | ResizableBorderComponent::Zone::bottom)); + = ResizableBorderComponent::Zone::fromPositionOnBorder (getContentArea().expanded (resizerThickness, resizerThickness), + BorderSize (0, 0, resizerThickness, resizerThickness), p); if (dragZone != newZone) { @@ -349,10 +511,16 @@ public: private: ComponentEditor& editor; - const int borderThickness; + const BorderSize border; + const int resizerThickness; ResizableBorderComponent::Zone dragZone; Rectangle dragStartSize; + const Rectangle getContentArea() const + { + return border.subtractedFrom (getLocalBounds()); + } + //============================================================================== class ComponentResizeFrame : public Component, public ComponentListener @@ -405,16 +573,14 @@ private: { updateDragZone (e.getPosition()); canvas.getDocument().beginDrag (canvas.getSelectedComps(), e, getParentComponent(), dragZone); + canvas.showSizeGuides(); } } void mouseDrag (const MouseEvent& e) { if (component != 0) - { - canvas.showSizeGuides(); canvas.getDocument().continueDrag (e); - } } void mouseUp (const MouseEvent& e) @@ -445,10 +611,10 @@ private: if (sizeGuides.size() == 0) { const ValueTree v (canvas.getDocument().getComponentState (component)); - sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, getParentComponent(), SizeGuideComponent::left)); - sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, getParentComponent(), SizeGuideComponent::right)); - sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, getParentComponent(), SizeGuideComponent::top)); - sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, getParentComponent(), SizeGuideComponent::bottom)); + sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, canvas, SizeGuideComponent::left)); + sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, canvas, SizeGuideComponent::right)); + sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, canvas, SizeGuideComponent::top)); + sizeGuides.add (new SizeGuideComponent (canvas.getDocument(), v, component, canvas, SizeGuideComponent::bottom)); } } diff --git a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp index 5cb45168da..c2e98e21ef 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp +++ b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp @@ -774,6 +774,16 @@ const String Coordinate::toString() const } } +const double Coordinate::getEditableValue() const +{ + return isProportion ? value * 100.0 : value; +} + +void Coordinate::setEditableValue (const double newValue) +{ + value = isProportion ? newValue / 100.0 : newValue; +} + //============================================================================== RectangleCoordinates::RectangleCoordinates() : left (true), right (true), top (false), bottom (false) diff --git a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.h b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.h index 8390aef2d9..310024cb53 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.h +++ b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.h @@ -120,13 +120,13 @@ class Coordinate public: //============================================================================== /** Creates a zero coordinate. */ - Coordinate (bool isHorizontal); + explicit Coordinate (bool isHorizontal); /** Recreates a coordinate from its stringified version. */ - explicit Coordinate (const String& stringVersion, bool isHorizontal); + Coordinate (const String& stringVersion, bool isHorizontal); /** Creates an absolute position from the parent origin. */ - explicit Coordinate (double absoluteDistanceFromOrigin, bool isHorizontal); + Coordinate (double absoluteDistanceFromOrigin, bool isHorizontal); /** Creates an absolute position relative to a named marker. */ Coordinate (double absolutePosition, const String& relativeToMarker, bool isHorizontal); @@ -160,6 +160,9 @@ public: const Coordinate getAnchorPoint1() const; const Coordinate getAnchorPoint2() const; + const double getEditableValue() const; + void setEditableValue (const double newValue); + //============================================================================== /* Position string formats: diff --git a/extras/Jucer (experimental)/Source/utility/jucer_ValueRemapperSource.h b/extras/Jucer (experimental)/Source/utility/jucer_ValueRemapperSource.h index fd761dd7c7..edd97934a9 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_ValueRemapperSource.h +++ b/extras/Jucer (experimental)/Source/utility/jucer_ValueRemapperSource.h @@ -37,12 +37,14 @@ public: ValueRemapperSource (const Value& sourceValue_) : sourceValue (sourceValue_) { + sourceValue.addListener (this); } ValueRemapperSource (const Value& sourceValue_, const char** mappings) : sourceValue (sourceValue_) { addMappings (mappings); + sourceValue.addListener (this); } ~ValueRemapperSource() {} @@ -75,21 +77,24 @@ public: void setValue (const var& newValue) { + var remappedVal (newValue); + for (int i = 1; i < mappings.size(); i += 2) { if (newValue == mappings.getReference(i)) { - sourceValue = mappings.getReference (i - 1); - return; + remappedVal = mappings.getReference (i - 1); + break; } } - sourceValue = newValue; + if (remappedVal != sourceValue) + sourceValue = remappedVal; } void valueChanged (Value&) { - sendChangeMessage (false); + sendChangeMessage (true); } //============================================================================== diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index a2adc284b2..b1e1691420 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -2924,7 +2924,7 @@ const String BigInteger::toString (const int base, const int minimumNumCharacter void BigInteger::parseString (const String& text, const int base) { clear(); - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; if (base == 2 || base == 8 || base == 16) { @@ -3200,7 +3200,7 @@ void MemoryBlock::removeSection (size_t startByte, size_t numBytesToRemove) thro const String MemoryBlock::toString() const throw() { - return String ((const char*) data, size); + return String (static_cast (getData()), size); } int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const throw() @@ -3306,7 +3306,8 @@ const String MemoryBlock::toBase64Encoding() const throw() const int initialLen = destString.length(); destString.preallocateStorage (initialLen + 2 + numChars); - tchar* d = const_cast (((const tchar*) destString) + initialLen); + juce_wchar* d = destString; + d += initialLen; *d++ = '.'; for (size_t i = 0; i < numChars; ++i) @@ -3329,7 +3330,8 @@ bool MemoryBlock::fromBase64Encoding (const String& s) throw() setSize (numBytesNeeded, true); const int numChars = s.length() - startPos; - const tchar* const srcChars = ((const tchar*) s) + startPos; + const juce_wchar* srcChars = s; + srcChars += startPos; int pos = 0; for (int i = 0; i < numChars; ++i) @@ -3810,7 +3812,7 @@ const var var::readFromStream (InputStream& input) { MemoryBlock mb; input.readIntoMemoryBlock (mb, numBytes - 1); - return var (String::fromUTF8 ((const char*) mb.getData(), (int) mb.getSize())); + return var (String::fromUTF8 (static_cast (mb.getData()), (int) mb.getSize())); } default: input.skipNextBytes (numBytes - 1); break; @@ -5359,7 +5361,7 @@ void OutputStream::writeText (const String& text, const bool asUnicode, if (writeUnicodeHeaderBytes) write ("\x0ff\x0fe", 2); - const juce_wchar* src = (const juce_wchar*) text; + const juce_wchar* src = text; bool lastCharWasReturn = false; while (*src != 0) @@ -8376,7 +8378,7 @@ int BufferedInputStream::read (void* destBuffer, int maxBytesToRead) maxBytesToRead -= bytesAvailable; bytesRead += bytesAvailable; position += bytesAvailable; - destBuffer = (void*) (((char*) destBuffer) + bytesAvailable); + destBuffer = static_cast (destBuffer) + bytesAvailable; } const int64 oldLastReadPos = lastReadPos; @@ -9029,10 +9031,9 @@ int ZipFile::getNumEntries() const throw() const ZipFile::ZipEntry* ZipFile::getEntry (const int index) const throw() { - ZipEntryInfo* const zei = (ZipEntryInfo*) entries [index]; + ZipEntryInfo* const zei = entries [index]; - return (zei != 0) ? &(zei->entry) - : 0; + return zei != 0 ? &(zei->entry) : 0; } int ZipFile::getIndexOfFileName (const String& fileName) const throw() @@ -9118,7 +9119,7 @@ void ZipFile::init() if (pos + 46 > size) break; - const char* const buffer = ((const char*) headerData.getData()) + pos; + const char* const buffer = static_cast (headerData.getData()) + pos; const int fileNameLen = ByteOrder::littleEndianShort (buffer + 28); @@ -10723,13 +10724,13 @@ String& String::operator+= (const String& other) String& String::operator+= (const char ch) { const juce_wchar asString[] = { (juce_wchar) ch, 0 }; - return operator+= ((const juce_wchar*) asString); + return operator+= (static_cast (asString)); } String& String::operator+= (const juce_wchar ch) { const juce_wchar asString[] = { (juce_wchar) ch, 0 }; - return operator+= ((const juce_wchar*) asString); + return operator+= (static_cast (asString)); } String& String::operator+= (const int number) @@ -11965,7 +11966,7 @@ int64 String::getHexValue64() const throw() const String String::createStringFromData (const void* const data_, const int size) { - const char* const data = (const char*) data_; + const char* const data = static_cast (data_); if (size <= 0 || data == 0) { @@ -11986,7 +11987,7 @@ const String String::createStringFromData (const void* const data_, const int si result.preallocateStorage (numChars + 2); const uint16* const src = (const uint16*) (data + 2); - juce_wchar* const dst = const_cast ((const juce_wchar*) result); + juce_wchar* const dst = const_cast (static_cast (result)); if (bigEndian) { @@ -12266,7 +12267,7 @@ void String::Concatenator::append (const String& s) if (len > 0) { result.preallocateStorage (nextIndex + len); - s.copyToUnicode (((juce_wchar*) result) + nextIndex, len); + s.copyToUnicode (static_cast (result) + nextIndex, len); nextIndex += len; } } @@ -12548,7 +12549,7 @@ const String StringArray::joinIntoString (const String& separator, int start, in String result; result.preallocateStorage (charsNeeded); - juce_wchar* dest = (juce_wchar*) result; + juce_wchar* dest = result; while (start < last) { @@ -12921,11 +12922,11 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle && ((data[0] == (char)-2 && data[1] == (char)-1) || (data[0] == (char)-1 && data[1] == (char)-2))) { - textToParse = String::createStringFromData ((const char*) data.getData(), (int) data.getSize()); + textToParse = String::createStringFromData (static_cast (data.getData()), (int) data.getSize()); } else { - textToParse = String::fromUTF8 ((const char*) data.getData(), (int) data.getSize()); + textToParse = String::fromUTF8 (static_cast (data.getData()), (int) data.getSize()); } if (! onlyReadOuterDocumentElement) @@ -13853,7 +13854,7 @@ namespace XmlOutputFunctions static void escapeIllegalXmlChars (OutputStream& outputStream, const String& text, const bool changeNewLines) { - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; for (;;) { @@ -15004,7 +15005,7 @@ void Thread::threadEntryPoint (Thread* const thread) // used to wrap the incoming call from the platform-specific code void JUCE_API juce_threadEntryPoint (void* userData) { - Thread::threadEntryPoint ((Thread*) userData); + Thread::threadEntryPoint (static_cast (userData)); } Thread::Thread (const String& threadName) @@ -15030,7 +15031,7 @@ void Thread::startThread() if (threadHandle_ == 0) { - threadHandle_ = juce_createThread ((void*) this); + threadHandle_ = juce_createThread (this); juce_setThreadPriority (threadHandle_, threadPriority_); startSuspensionEvent_.signal(); } @@ -15350,7 +15351,7 @@ int ThreadPool::getNumJobs() const ThreadPoolJob* ThreadPool::getJob (const int index) const { const ScopedLock sl (lock); - return (ThreadPoolJob*) jobs [index]; + return jobs [index]; } bool ThreadPool::contains (const ThreadPoolJob* const job) const @@ -16778,7 +16779,7 @@ int JUCEApplication::shutdownAppAndClearUp() ScopedPointer app (appInstance); int returnValue = 0; - MessageManager::getInstance()->deregisterBroadcastListener ((JUCEApplication*) app); + MessageManager::getInstance()->deregisterBroadcastListener (static_cast (app)); static bool reentrancyCheck = false; @@ -17580,7 +17581,7 @@ void DeletedAtShutdown::deleteAll() { JUCE_TRY { - DeletedAtShutdown* deletee = (DeletedAtShutdown*) localCopy.getUnchecked(i); + DeletedAtShutdown* deletee = static_cast (localCopy.getUnchecked(i)); // double-check that it's not already been deleted during another object's destructor. { @@ -19992,7 +19993,7 @@ bool AudioFormatWriter::writeFromAudioSource (AudioSource& source, } AudioFormat::AudioFormat (const String& name, - const tchar** const extensions) + const juce_wchar** const extensions) : formatName (name), fileExtensions (extensions) { @@ -20643,7 +20644,7 @@ void AudioThumbnail::refillCache (const int numSamples, { startTimer (timeBeforeDeletingReader); - char* cacheData = (char*) cachedLevels.getData(); + char* cacheData = static_cast (cachedLevels.getData()); int sample = roundToInt (startTime * d->sampleRate); for (int i = numSamples; --i >= 0;) @@ -20682,7 +20683,7 @@ void AudioThumbnail::refillCache (const int numSamples, for (int channelNum = 0; channelNum < numChannelsCached; ++channelNum) { char* const channelData = getChannelData (channelNum); - char* cacheData = ((char*) cachedLevels.getData()) + channelNum * 2; + char* cacheData = static_cast (cachedLevels.getData()) + channelNum * 2; const double timeToThumbSampleFactor = d->sampleRate / (double) d->samplesPerThumbSample; @@ -20765,7 +20766,7 @@ void AudioThumbnail::drawChannel (Graphics& g, w -= skipLeft; x += skipLeft; - const char* cacheData = ((const char*) cachedLevels.getData()) + const char* cacheData = static_cast (cachedLevels.getData()) + (channelNum << 1) + skipLeft * (numChannelsCached << 1); @@ -20820,10 +20821,7 @@ bool AudioThumbnailCache::loadThumb (AudioThumbnail& thumb, const int64 hashCode { if (thumbs[i]->hash == hashCode) { - MemoryInputStream in ((const char*) thumbs[i]->data.getData(), - thumbs[i]->data.getSize(), - false); - + MemoryInputStream in (thumbs[i]->data, false); thumb.loadFrom (in); thumbs[i]->lastUsed = Time::getMillisecondCounter(); @@ -21629,7 +21627,7 @@ public: if (bitsPerSample == 16) { - const short* src = (const short*) tempBuffer; + const short* src = reinterpret_cast (tempBuffer); if (numChannels > 1) { @@ -21668,7 +21666,7 @@ public: } else if (bitsPerSample == 24) { - const char* src = (const char*) tempBuffer; + const char* src = tempBuffer; if (numChannels > 1) { @@ -21906,7 +21904,7 @@ public: const int bytes = numChannels * numSamples * bitsPerSample / 8; tempBlock.ensureSize (bytes, false); - char* buffer = (char*) tempBlock.getData(); + char* buffer = static_cast (tempBlock.getData()); const int* left = data[0]; const int* right = data[1]; @@ -21935,7 +21933,7 @@ public: } else if (bitsPerSample == 24) { - char* b = (char*) buffer; + char* b = buffer; if (numChannels > 1) { @@ -22718,9 +22716,9 @@ public: { const ScopedLock sl (lock); - if (! sources.contains ((void*) source)) + if (! sources.contains (source)) { - sources.add ((void*) source); + sources.add (source); startThread(); stopTimer(); @@ -22732,14 +22730,14 @@ public: void removeSource (BufferingAudioSource* source) { const ScopedLock sl (lock); - sources.removeValue ((void*) source); + sources.removeValue (source); if (sources.size() == 0) startTimer (5000); } private: - VoidArray sources; + Array sources; CriticalSection lock; void run() @@ -22755,7 +22753,7 @@ private: const ScopedLock sl (lock); - BufferingAudioSource* const b = (BufferingAudioSource*) sources[i]; + BufferingAudioSource* const b = sources[i]; if (b != 0 && b->readNextBufferChunk()) busy = true; @@ -23303,7 +23301,7 @@ void MixerAudioSource::removeInputSource (AudioSource* input, const bool deleteI { const ScopedLock sl (lock); - index = inputs.indexOf ((void*) input); + index = inputs.indexOf (input); if (index >= 0) { @@ -24827,13 +24825,13 @@ BEGIN_JUCE_NAMESPACE void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { for (int i = 0; i < numSamples; ++i) { - *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); intData += destBytesPerSample; } } @@ -24844,7 +24842,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -24852,7 +24850,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -24869,7 +24867,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint16*)intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -24877,7 +24875,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -24902,7 +24900,7 @@ void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -24927,7 +24925,7 @@ void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -24952,7 +24950,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -24978,7 +24976,7 @@ void AudioDataConverters::convertFloatToFloat32LE (const float* source, void* de { jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data! - char* d = (char*) dest; + char* d = static_cast (dest); for (int i = 0; i < numSamples; ++i) { @@ -24996,7 +24994,7 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de { jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data! - char* d = (char*) dest; + char* d = static_cast (dest); for (int i = 0; i < numSamples; ++i) { @@ -25013,7 +25011,7 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de void AudioDataConverters::convertInt16LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -25038,7 +25036,7 @@ void AudioDataConverters::convertInt16LEToFloat (const void* const source, float void AudioDataConverters::convertInt16BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -25063,7 +25061,7 @@ void AudioDataConverters::convertInt16BEToFloat (const void* const source, float void AudioDataConverters::convertInt24LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -25088,7 +25086,7 @@ void AudioDataConverters::convertInt24LEToFloat (const void* const source, float void AudioDataConverters::convertInt24BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -25113,7 +25111,7 @@ void AudioDataConverters::convertInt24BEToFloat (const void* const source, float void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -25138,7 +25136,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* const source, float void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -25162,7 +25160,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* const source, float void AudioDataConverters::convertFloat32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const char* s = (const char*) source; + const char* s = static_cast (source); for (int i = 0; i < numSamples; ++i) { @@ -25179,7 +25177,7 @@ void AudioDataConverters::convertFloat32LEToFloat (const void* const source, flo void AudioDataConverters::convertFloat32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const char* s = (const char*) source; + const char* s = static_cast (source); for (int i = 0; i < numSamples; ++i) { @@ -26514,7 +26512,7 @@ namespace MidiFileHelpers } } - static bool parseMidiHeader (const char* &data, short& timeFormat, short& fileType, short& numberOfTracks) throw() + static bool parseMidiHeader (const uint8* &data, short& timeFormat, short& fileType, short& numberOfTracks) throw() { unsigned int ch = (int) ByteOrder::bigEndianInt (data); data += 4; @@ -26720,12 +26718,12 @@ bool MidiFile::readFrom (InputStream& sourceStream) if (sourceStream.readIntoMemoryBlock (data, maxSensibleMidiFileSize)) { size_t size = data.getSize(); - const char* d = (char*) data.getData(); + const uint8* d = static_cast (data.getData()); short fileType, expectedTracks; if (size > 16 && MidiFileHelpers::parseMidiHeader (d, timeFormat, fileType, expectedTracks)) { - size -= (int) (d - (char*) data.getData()); + size -= (int) (d - static_cast (data.getData())); int track = 0; @@ -26780,7 +26778,7 @@ int MidiFile::compareElements (const MidiMessageSequence::MidiEventHolder* const } } -void MidiFile::readNextTrack (const char* data, int size) +void MidiFile::readNextTrack (const uint8* data, int size) { double time = 0; char lastStatusByte = 0; @@ -26790,13 +26788,13 @@ void MidiFile::readNextTrack (const char* data, int size) while (size > 0) { int bytesUsed; - const int delay = MidiMessage::readVariableLengthVal ((const uint8*) data, bytesUsed); + const int delay = MidiMessage::readVariableLengthVal (data, bytesUsed); data += bytesUsed; size -= bytesUsed; time += delay; int messSize = 0; - const MidiMessage mm ((const uint8*) data, size, messSize, lastStatusByte, time); + const MidiMessage mm (data, size, messSize, lastStatusByte, time); if (messSize <= 0) break; @@ -27588,7 +27586,7 @@ bool MidiMessage::isSysEx() const throw() const MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const int dataSize) { MemoryBlock mm (dataSize + 2); - uint8* const m = (uint8*) mm.getData(); + uint8* const m = static_cast (mm.getData()); m[0] = 0xf0; memcpy (m + 1, sysexData, dataSize); @@ -27663,7 +27661,7 @@ bool MidiMessage::isTextMetaEvent() const throw() const String MidiMessage::getTextFromTextMetaEvent() const { - return String ((const char*) getMetaEventData(), getMetaEventLength()); + return String (reinterpret_cast (getMetaEventData()), getMetaEventLength()); } bool MidiMessage::isTrackNameEvent() const throw() @@ -37102,7 +37100,7 @@ void InterprocessConnection::handleMessage (const Message& message) { case 0: { - ScopedPointer data ((MemoryBlock*) message.pointerParameter); + ScopedPointer data (static_cast (message.pointerParameter)); messageReceived (*data); break; } @@ -37449,9 +37447,9 @@ void MessageManager::postCallbackMessage (Message* const message) } // not for public use.. -void MessageManager::deliverMessage (void* message) +void MessageManager::deliverMessage (void* const message) { - const ScopedPointer m ((Message*) message); + const ScopedPointer m (static_cast (message)); MessageListener* const recipient = m->messageRecipient; JUCE_TRY @@ -37468,7 +37466,7 @@ void MessageManager::deliverMessage (void* message) } else { - CallbackMessage* const cm = dynamic_cast ((Message*) m); + CallbackMessage* const cm = dynamic_cast (static_cast (m)); if (cm != 0) cm->messageCallback(); @@ -39445,7 +39443,7 @@ int Component::runModalLoop() // use a callback so this can be called from non-gui threads return (int) (pointer_sized_int) MessageManager::getInstance() - ->callFunctionOnMessageThread (&runModalLoopCallback, (void*) this); + ->callFunctionOnMessageThread (&runModalLoopCallback, this); } SafePointer prevFocused (getCurrentlyFocusedComponent()); @@ -43136,7 +43134,7 @@ public: static void createLines (Array & newLines, const String& text) { - const tchar* const t = (const tchar*) text; + const juce_wchar* const t = text; int pos = 0; while (t [pos] != 0) @@ -43789,26 +43787,20 @@ void CodeDocument::checkLastLineStatus() void CodeDocument::addListener (CodeDocument::Listener* const listener) throw() { - listeners.addIfNotAlreadyThere (listener); + listeners.add (listener); } void CodeDocument::removeListener (CodeDocument::Listener* const listener) throw() { - listeners.removeValue (listener); + listeners.remove (listener); } void CodeDocument::sendListenerChangeMessage (const int startLine, const int endLine) { - const Position startPos (this, startLine, 0); - const Position endPos (this, endLine, 0); + Position startPos (this, startLine, 0); + Position endPos (this, endLine, 0); - for (int i = listeners.size(); --i >= 0;) - { - Listener* const l = (Listener*) listeners[i]; - - if (l != 0) - l->codeDocumentChanged (startPos, endPos); - } + listeners.call (&Listener::codeDocumentChanged, startPos, endPos); } class CodeDocumentInsertAction : public UndoableAction @@ -44029,8 +44021,8 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_CodeEditorComponent.cpp ***/ BEGIN_JUCE_NAMESPACE -class CaretComponent : public Component, - public Timer +class CodeEditorComponent::CaretComponent : public Component, + public Timer { public: CaretComponent() @@ -44062,6 +44054,10 @@ public: const Rectangle pos (owner.getCharacterBounds (owner.getCaretPos())); setBounds (pos.getX(), pos.getY(), 2, pos.getHeight()); } + +private: + CaretComponent (const CaretComponent&); + CaretComponent& operator= (const CaretComponent&); }; class CodeEditorComponent::CodeEditorLine @@ -44341,7 +44337,7 @@ void CodeEditorComponent::codeDocumentChanged (const CodeDocument::Position& aff triggerAsyncUpdate(); - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); columnToTryToMaintain = -1; if (affectedTextEnd.getPosition() >= selectionStart.getPosition() @@ -44361,7 +44357,7 @@ void CodeEditorComponent::resized() columnsOnScreen = (int) ((getWidth() - scrollbarThickness) / charWidth); lines.clear(); rebuildLineTokens(); - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); verticalScrollBar->setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness); horizontalScrollBar->setBounds (gutter, getHeight() - scrollbarThickness, getWidth() - scrollbarThickness - gutter, scrollbarThickness); @@ -44503,7 +44499,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con deselectAll(); } - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); scrollToKeepCaretOnScreen(); updateScrollBars(); } @@ -44534,7 +44530,7 @@ void CodeEditorComponent::scrollToLineInternal (int newFirstLineOnScreen) if (newFirstLineOnScreen != firstLineOnScreen) { firstLineOnScreen = newFirstLineOnScreen; - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); updateCachedIterators (firstLineOnScreen); triggerAsyncUpdate(); @@ -44548,7 +44544,7 @@ void CodeEditorComponent::scrollToColumnInternal (double column) if (xOffset != newOffset) { xOffset = newOffset; - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); repaint(); } } @@ -46963,8 +46959,8 @@ public: ListBoxRowComponent* getComponentForRow (const int row) const throw() { - return (ListBoxRowComponent*) getViewedComponent() - ->getChildComponent (row % jmax (1, getViewedComponent()->getNumChildComponents())); + return static_cast + (getViewedComponent()->getChildComponent (row % jmax (1, getViewedComponent()->getNumChildComponents()))); } int getRowNumberOfComponent (Component* const rowComponent) const throw() @@ -50519,7 +50515,7 @@ Component* TableListBox::refreshComponentForRow (int rowNumber, bool isRowSelect if (existingComponentToUpdate == 0) existingComponentToUpdate = new TableListRowComp (*this); - ((TableListRowComp*) existingComponentToUpdate)->update (rowNumber, isRowSelected_); + static_cast (existingComponentToUpdate)->update (rowNumber, isRowSelected_); return existingComponentToUpdate; } @@ -50899,7 +50895,7 @@ private: { int i = 0; const int len = textToParse.length(); - const tchar* const text = (const tchar*) textToParse; + const juce_wchar* const text = textToParse; while (i < len) { @@ -54588,7 +54584,7 @@ public: for (int i = rowComponentItems.size(); --i >= 0;) { - Component* const comp = (Component*) rowComponents.getUnchecked(i); + Component* const comp = rowComponents.getUnchecked(i); bool keep = false; @@ -54596,7 +54592,7 @@ public: { if (itemsToKeep[i]) { - const TreeViewItem* const item = (TreeViewItem*) rowComponentItems.getUnchecked(i); + const TreeViewItem* const item = rowComponentItems.getUnchecked(i); Rectangle pos (item->getItemPosition (false)); pos.setSize (pos.getWidth(), item->itemHeight); @@ -54687,9 +54683,9 @@ public: private: TreeView* const owner; - VoidArray rowComponentItems; + Array rowComponentItems; Array rowComponentIds; - VoidArray rowComponents; + Array rowComponents; TreeViewItem* buttonUnderMouse; bool isDragging, needSelectionOnMouseUp; @@ -54730,14 +54726,14 @@ private: bool containsItem (TreeViewItem* const item) const { for (int i = rowComponentItems.size(); --i >= 0;) - if ((TreeViewItem*) rowComponentItems.getUnchecked (i) == item) + if (rowComponentItems.getUnchecked(i) == item) return true; return false; } }; -class TreeViewport : public Viewport +class TreeView::TreeViewport : public Viewport { public: TreeViewport() throw() {} @@ -54745,8 +54741,9 @@ public: void updateComponents() { - if (getViewedComponent() != 0) - ((TreeViewContentComponent*) getViewedComponent())->updateComponents(); + TreeViewContentComponent* const tvc = static_cast (getViewedComponent()); + if (tvc != 0) + tvc->updateComponents(); repaint(); } @@ -54877,6 +54874,11 @@ void TreeView::setOpenCloseButtonsVisible (const bool shouldBeVisible) } } +Viewport* TreeView::getViewport() const throw() +{ + return viewport; +} + void TreeView::clearSelectedItems() { if (rootItem != 0) @@ -54914,7 +54916,7 @@ TreeViewItem* TreeView::getItemOnRow (int index) const TreeViewItem* TreeView::getItemAt (int y) const throw() { - TreeViewContentComponent* const tc = (TreeViewContentComponent*) viewport->getViewedComponent(); + TreeViewContentComponent* const tc = static_cast (viewport->getViewedComponent()); Rectangle pos; return tc->findItemAt (relativePositionToOtherComponent (tc, Point (0, y)).getY(), pos); } @@ -55140,7 +55142,7 @@ void TreeView::handleAsyncUpdate() if (rootItem != 0) rootItem->updatePositions (rootItemVisible ? 0 : -rootItem->itemHeight); - ((TreeViewport*) viewport)->updateComponents(); + viewport->updateComponents(); if (rootItem != 0) { @@ -55155,10 +55157,10 @@ void TreeView::handleAsyncUpdate() } } -class TreeViewDragInsertPointHighlight : public Component +class TreeView::InsertPointHighlight : public Component { public: - TreeViewDragInsertPointHighlight() + InsertPointHighlight() : lastItem (0) { setSize (100, 12); @@ -55166,7 +55168,7 @@ public: setInterceptsMouseClicks (false, false); } - ~TreeViewDragInsertPointHighlight() {} + ~InsertPointHighlight() {} void setTargetPosition (TreeViewItem* const item, int insertIndex, const int x, const int y, const int width) throw() { @@ -55190,18 +55192,22 @@ public: TreeViewItem* lastItem; int lastIndex; + +private: + InsertPointHighlight (const InsertPointHighlight&); + InsertPointHighlight& operator= (const InsertPointHighlight&); }; -class TreeViewDragTargetGroupHighlight : public Component +class TreeView::TargetGroupHighlight : public Component { public: - TreeViewDragTargetGroupHighlight() + TargetGroupHighlight() { setAlwaysOnTop (true); setInterceptsMouseClicks (false, false); } - ~TreeViewDragTargetGroupHighlight() {} + ~TargetGroupHighlight() {} void setTargetPosition (TreeViewItem* const item) throw() { @@ -55215,6 +55221,10 @@ public: g.setColour (findColour (TreeView::dragAndDropIndicatorColourId, true)); g.drawRoundedRectangle (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 3.0f, 2.0f); } + +private: + TargetGroupHighlight (const TargetGroupHighlight&); + TargetGroupHighlight& operator= (const TargetGroupHighlight&); }; void TreeView::showDragHighlight (TreeViewItem* item, int insertIndex, int x, int y) throw() @@ -55223,15 +55233,12 @@ void TreeView::showDragHighlight (TreeViewItem* item, int insertIndex, int x, in if (dragInsertPointHighlight == 0) { - addAndMakeVisible (dragInsertPointHighlight = new TreeViewDragInsertPointHighlight()); - addAndMakeVisible (dragTargetGroupHighlight = new TreeViewDragTargetGroupHighlight()); + addAndMakeVisible (dragInsertPointHighlight = new InsertPointHighlight()); + addAndMakeVisible (dragTargetGroupHighlight = new TargetGroupHighlight()); } - ((TreeViewDragInsertPointHighlight*) dragInsertPointHighlight) - ->setTargetPosition (item, insertIndex, x, y, viewport->getViewWidth()); - - ((TreeViewDragTargetGroupHighlight*) dragTargetGroupHighlight) - ->setTargetPosition (item); + dragInsertPointHighlight->setTargetPosition (item, insertIndex, x, y, viewport->getViewWidth()); + dragTargetGroupHighlight->setTargetPosition (item); } void TreeView::hideDragHighlight() throw() @@ -55304,8 +55311,8 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip if (item != 0) { if (scrolled || dragInsertPointHighlight == 0 - || ((TreeViewDragInsertPointHighlight*) dragInsertPointHighlight)->lastItem != item - || ((TreeViewDragInsertPointHighlight*) dragInsertPointHighlight)->lastIndex != insertIndex) + || dragInsertPointHighlight->lastItem != item + || dragInsertPointHighlight->lastIndex != insertIndex) { if (files.size() > 0 ? item->isInterestedInFileDrag (files) : item->isInterestedInDragSource (sourceDescription, sourceComponent)) @@ -55816,7 +55823,7 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) g.reduceClipRegion (0, 0, indentWidth, itemHeight); paintOpenCloseButton (g, indentWidth, itemHeight, - ((TreeViewContentComponent*) ownerView->viewport->getViewedComponent()) + static_cast (ownerView->viewport->getViewedComponent()) ->isMouseOverButton (this)); g.restoreState(); @@ -57768,7 +57775,7 @@ FileSearchPathListComponent::FileSearchPathListComponent() arrowImage.setFill (Colours::black.withAlpha (0.4f)); arrowImage.setPath (arrowPath); - ((DrawableButton*) upButton)->setImages (&arrowImage); + upButton->setImages (&arrowImage); } addAndMakeVisible (downButton = new DrawableButton (String::empty, DrawableButton::ImageOnButtonBackground)); @@ -57781,7 +57788,7 @@ FileSearchPathListComponent::FileSearchPathListComponent() arrowImage.setFill (Colours::black.withAlpha (0.4f)); arrowImage.setPath (arrowPath); - ((DrawableButton*) downButton)->setImages (&arrowImage); + downButton->setImages (&arrowImage); } updateButtons(); @@ -57888,7 +57895,7 @@ void FileSearchPathListComponent::resized() addButton->setBounds (2, buttonY, buttonH, buttonH); removeButton->setBounds (addButton->getRight(), buttonY, buttonH, buttonH); - ((TextButton*) changeButton)->changeWidthToFitText (buttonH); + changeButton->changeWidthToFitText (buttonH); downButton->setSize (buttonH * 2, buttonH); upButton->setSize (buttonH * 2, buttonH); @@ -61128,7 +61135,7 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_ScrollBar.cpp ***/ BEGIN_JUCE_NAMESPACE -class ScrollbarButton : public Button +class ScrollBar::ScrollbarButton : public Button { public: int direction; @@ -61335,8 +61342,8 @@ void ScrollBar::setOrientation (const bool shouldBeVertical) if (upButton != 0) { - ((ScrollbarButton*) upButton)->direction = (vertical) ? 0 : 3; - ((ScrollbarButton*) downButton)->direction = (vertical) ? 2 : 1; + upButton->direction = vertical ? 0 : 3; + downButton->direction = vertical ? 2 : 1; } updateThumbPosition(); @@ -61345,13 +61352,15 @@ void ScrollBar::setOrientation (const bool shouldBeVertical) void ScrollBar::setButtonVisibility (const bool buttonsAreVisible) { - deleteAndZero (upButton); - deleteAndZero (downButton); + delete upButton; + upButton = 0; + delete downButton; + downButton = 0; if (buttonsAreVisible) { - addAndMakeVisible (upButton = new ScrollbarButton ((vertical) ? 0 : 3, *this)); - addAndMakeVisible (downButton = new ScrollbarButton ((vertical) ? 2 : 1, *this)); + addAndMakeVisible (upButton = new ScrollbarButton (vertical ? 0 : 3, *this)); + addAndMakeVisible (downButton = new ScrollbarButton (vertical ? 2 : 1, *this)); setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs); } @@ -68112,7 +68121,7 @@ private: for (int i = getNumChildComponents(); --i >= 0;) { - PopupMenu::ItemComponent* const m = (PopupMenu::ItemComponent*) getChildComponent (i); + PopupMenu::ItemComponent* const m = static_cast (getChildComponent (i)); if (m != 0 && m->itemInfo.itemId == itemId @@ -69455,7 +69464,7 @@ public: { for (int i = activeCursors.size(); --i >= 0;) { - SharedMouseCursorInternal* const r = (SharedMouseCursorInternal*) activeCursors.getUnchecked(i); + SharedMouseCursorInternal* const r = static_cast (activeCursors.getUnchecked(i)); if (r->standardType == type) return r; @@ -70552,7 +70561,7 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_PropertyPanel.cpp ***/ BEGIN_JUCE_NAMESPACE -class PropertyHolderComponent : public Component +class PropertyPanel::PropertyHolderComponent : public Component { public: PropertyHolderComponent() @@ -70568,9 +70577,12 @@ public: { } - void updateLayout (const int width); - + void updateLayout (int width); void refreshAll() const; + +private: + PropertyHolderComponent (const PropertyHolderComponent&); + PropertyHolderComponent& operator= (const PropertyHolderComponent&); }; class PropertySectionComponent : public Component @@ -70698,9 +70710,12 @@ public: private: int titleHeight; bool isOpen_; + + PropertySectionComponent (const PropertySectionComponent&); + PropertySectionComponent& operator= (const PropertySectionComponent&); }; -void PropertyHolderComponent::updateLayout (const int width) +void PropertyPanel::PropertyHolderComponent::updateLayout (const int width) { int y = 0; @@ -70721,7 +70736,7 @@ void PropertyHolderComponent::updateLayout (const int width) repaint(); } -void PropertyHolderComponent::refreshAll() const +void PropertyPanel::PropertyHolderComponent::refreshAll() const { for (int i = getNumChildComponents(); --i >= 0;) { @@ -70804,19 +70819,19 @@ void PropertyPanel::addSection (const String& sectionTitle, void PropertyPanel::updatePropHolderLayout() const { const int maxWidth = viewport->getMaximumVisibleWidth(); - ((PropertyHolderComponent*) propertyHolderComponent)->updateLayout (maxWidth); + propertyHolderComponent->updateLayout (maxWidth); const int newMaxWidth = viewport->getMaximumVisibleWidth(); if (maxWidth != newMaxWidth) { // need to do this twice because of scrollbars changing the size, etc. - ((PropertyHolderComponent*) propertyHolderComponent)->updateLayout (newMaxWidth); + propertyHolderComponent->updateLayout (newMaxWidth); } } void PropertyPanel::refreshAll() const { - ((PropertyHolderComponent*) propertyHolderComponent)->refreshAll(); + propertyHolderComponent->refreshAll(); } const StringArray PropertyPanel::getSectionNames() const @@ -72600,16 +72615,8 @@ private: ColourSpaceMarker& operator= (const ColourSpaceMarker&); }; -class ColourSpaceView : public Component +class ColourSelector::ColourSpaceView : public Component { - ColourSelector* const owner; - float& h; - float& s; - float& v; - float lastHue; - ColourSpaceMarker* marker; - const int edge; - public: ColourSpaceView (ColourSelector* owner_, float& h_, float& s_, float& v_, @@ -72690,6 +72697,14 @@ public: } private: + ColourSelector* const owner; + float& h; + float& s; + float& v; + float lastHue; + ColourSpaceMarker* marker; + const int edge; + ScopedPointer colours; void updateMarker() const throw() @@ -72738,7 +72753,7 @@ private: HueSelectorMarker& operator= (const HueSelectorMarker&); }; -class HueSelectorComp : public Component +class ColourSelector::HueSelectorComp : public Component { public: HueSelectorComp (ColourSelector* owner_, @@ -72971,8 +72986,8 @@ void ColourSelector::update() if (colourSpace != 0) { - ((ColourSpaceView*) colourSpace)->updateIfNeeded(); - ((HueSelectorComp*) hueSelector)->updateIfNeeded(); + colourSpace->updateIfNeeded(); + hueSelector->updateIfNeeded(); } if ((flags & showColourAtTop) != 0) @@ -76730,7 +76745,7 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent, { resizeToFitContent = resizeToFit; - if (newContentComponent != (Component*) contentComponent) + if (newContentComponent != static_cast (contentComponent)) { if (! deleteOldOne) removeChildComponent (contentComponent.release()); @@ -77776,7 +77791,7 @@ int TopLevelWindow::getNumTopLevelWindows() throw() TopLevelWindow* TopLevelWindow::getTopLevelWindow (const int index) throw() { - return (TopLevelWindow*) TopLevelWindowManager::getInstance()->windows [index]; + return static_cast (TopLevelWindowManager::getInstance()->windows [index]); } TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow() throw() @@ -84338,7 +84353,7 @@ private: static bool parseNextNumber (const String& source, String& value, int& index, const bool allowUnits) { - const tchar* const s = (const tchar*) source; + const juce_wchar* const s = source; while (CharacterFunctions::isWhitespace (s[index]) || s[index] == ',') ++index; @@ -85321,7 +85336,7 @@ void GlyphArrangement::addCurtailedLineOfText (const Font& font, font.getGlyphPositions (text, newGlyphs, xOffsets); const int textLen = newGlyphs.size(); - const juce_wchar* const unicodeText = (const juce_wchar*) text; + const juce_wchar* const unicodeText = text; for (int i = 0; i < textLen; ++i) { @@ -86567,7 +86582,7 @@ float CustomTypeface::getDescent() const float CustomTypeface::getStringWidth (const String& text) { float x = 0; - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; while (*t != 0) { @@ -86584,7 +86599,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array & resultG { xOffsets.add (0); float x = 0; - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; while (*t != 0) { @@ -91778,12 +91793,12 @@ GIFLoader::~GIFLoader() bool GIFLoader::getSizeFromHeader (int& w, int& h) { - unsigned char b [8]; + char b[8]; if (input.read (b, 6) == 6) { - if ((strncmp ("GIF87a", (char*) b, 6) == 0) - || (strncmp ("GIF89a", (char*) b, 6) == 0)) + if ((strncmp ("GIF87a", b, 6) == 0) + || (strncmp ("GIF89a", b, 6) == 0)) { if (input.read (b, 4) == 4) { @@ -92754,7 +92769,7 @@ public: return dataSize <= 0; } - void setInput (uint8* const newData, const int size) throw() + void setInput (const uint8* const newData, const int size) throw() { data = newData; dataSize = size; @@ -92765,7 +92780,7 @@ public: using namespace zlibNamespace; if (streamIsValid) { - stream.next_in = data; + stream.next_in = const_cast (data); stream.next_out = dest; stream.avail_in = dataSize; stream.avail_out = destSize; @@ -92796,7 +92811,7 @@ public: private: zlibNamespace::z_stream stream; - uint8* data; + const uint8* data; int dataSize, compLevel, strategy; bool setParams, streamIsValid; @@ -92842,7 +92857,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) { if (! helper->finished) { - helper->setInput ((uint8*) destBuffer, howMany); + helper->setInput (static_cast (destBuffer), howMany); while (! helper->needsInput()) { @@ -98592,7 +98607,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) if (destBuffer != 0) { int numRead = 0; - uint8* d = (uint8*) destBuffer; + uint8* d = static_cast (destBuffer); while (! helper->error) { @@ -98613,7 +98628,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) if (activeBufferSize > 0) { - helper->setInput ((uint8*) buffer, activeBufferSize); + helper->setInput (buffer, activeBufferSize); } else { @@ -114276,7 +114291,7 @@ public: ok = FLAC__stream_decoder_init_stream (decoder, readCallback_, seekCallback_, tellCallback_, lengthCallback_, eofCallback_, writeCallback_, metadataCallback_, errorCallback_, - (void*) this) == FLAC__STREAM_DECODER_INIT_STATUS_OK; + this) == FLAC__STREAM_DECODER_INIT_STATUS_OK; if (ok) { @@ -114507,7 +114522,7 @@ public: ok = FLAC__stream_encoder_init_stream (encoder, encodeWriteCallback, encodeSeekCallback, encodeTellCallback, encodeMetadataCallback, - (void*) this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK; + this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK; } ~FlacWriter() @@ -171131,12 +171146,12 @@ public: static size_t oggReadCallback (void* ptr, size_t size, size_t nmemb, void* datasource) { - return (size_t) (((InputStream*) datasource)->read (ptr, (int) (size * nmemb)) / size); + return (size_t) (static_cast (datasource)->read (ptr, (int) (size * nmemb)) / size); } static int oggSeekCallback (void* datasource, OggVorbisNamespace::ogg_int64_t offset, int whence) { - InputStream* const in = (InputStream*) datasource; + InputStream* const in = static_cast (datasource); if (whence == SEEK_CUR) offset += in->getPosition(); @@ -171154,7 +171169,7 @@ public: static long oggTellCallback (void* datasource) { - return (long) ((InputStream*) datasource)->getPosition(); + return (long) static_cast (datasource)->getPosition(); } juce_UseDebuggingNewOperator @@ -211069,7 +211084,7 @@ DynamicLibraryLoader::~DynamicLibraryLoader() void* DynamicLibraryLoader::findProcAddress (const String& functionName) { - return (void*) GetProcAddress ((HMODULE) libHandle, functionName.toCString()); + return GetProcAddress ((HMODULE) libHandle, functionName.toCString()); } #endif @@ -211742,7 +211757,7 @@ void PlatformUtilities::freeDynamicLibrary (void* h) void* PlatformUtilities::getProcedureEntryPoint (void* h, const String& name) { - return (h != 0) ? (void*) GetProcAddress ((HMODULE) h, name.toCString()) : 0; + return (h != 0) ? GetProcAddress ((HMODULE) h, name.toCString()) : 0; } class InterProcessLock::Pimpl @@ -211971,7 +211986,7 @@ void* juce_fileOpen (const String& fileName, bool forWriting) h = 0; } - return (void*) h; + return h; } void juce_fileClose (void* handle) @@ -213494,7 +213509,7 @@ void MessageManager::broadcastMessage (const String& value) throw() COPYDATASTRUCT data; data.dwData = broadcastId; data.cbData = (localCopy.length() + 1) * sizeof (juce_wchar); - data.lpData = (void*) (const juce_wchar*) localCopy; + data.lpData = (void*) static_cast (localCopy); for (int i = windows.size(); --i >= 0;) { @@ -213915,7 +213930,7 @@ public: taskBarIcon (0), dropTarget (0) { - callFunctionIfNotLocked (&createWindowCallback, (void*) this); + callFunctionIfNotLocked (&createWindowCallback, this); setTitle (component->getName()); @@ -213956,7 +213971,7 @@ public: void* getNativeHandle() const { - return (void*) hwnd; + return hwnd; } void setVisible (bool shouldBeVisible) @@ -214179,9 +214194,7 @@ public: const bool oldDeactivate = shouldDeactivateTitleBar; shouldDeactivateTitleBar = ((styleFlags & windowIsTemporary) == 0); - callFunctionIfNotLocked (makeActive ? &toFrontCallback1 - : &toFrontCallback2, - (void*) hwnd); + callFunctionIfNotLocked (makeActive ? &toFrontCallback1 : &toFrontCallback2, hwnd); shouldDeactivateTitleBar = oldDeactivate; @@ -214223,7 +214236,7 @@ public: const bool oldDeactivate = shouldDeactivateTitleBar; shouldDeactivateTitleBar = ((styleFlags & windowIsTemporary) == 0); - callFunctionIfNotLocked (&setFocusCallback, (void*) hwnd); + callFunctionIfNotLocked (&setFocusCallback, hwnd); shouldDeactivateTitleBar = oldDeactivate; } @@ -214464,7 +214477,7 @@ private: static void* createWindowCallback (void* userData) { - ((Win32ComponentPeer*) userData)->createWindow(); + static_cast (userData)->createWindow(); return 0; } @@ -214566,7 +214579,7 @@ private: static void* getFocusCallback (void*) { - return (void*) GetFocus(); + return GetFocus(); } void offsetWithinParent (int& x, int& y) const @@ -216014,7 +216027,7 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot if (os == SystemStats::WinXP) { - cursorH = (void*) createHICONFromImage (*im, FALSE, hotspotX, hotspotY); + cursorH = createHICONFromImage (*im, FALSE, hotspotX, hotspotY); } else { @@ -216137,7 +216150,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro if (cursorH == 0) cursorH = LoadCursor (0, IDC_ARROW); - return (void*) cursorH; + return cursorH; } void MouseCursor::showInWindow (ComponentPeer*) const throw() @@ -216473,9 +216486,9 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text) const int numChars = text.length(); medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, (numChars + 2) * sizeof (WCHAR)); - char* d = (char*) GlobalLock (medium.hGlobal); + WCHAR* const data = static_cast (GlobalLock (medium.hGlobal)); - text.copyToUnicode ((WCHAR*) d, numChars + 1); + text.copyToUnicode (data, numChars + 1); format.cfFormat = CF_UNICODETEXT; GlobalUnlock (medium.hGlobal); @@ -217182,7 +217195,7 @@ void SystemClipboard::copyTextToClipboard (const String& text) if (bufH != 0) { - WCHAR* const data = (WCHAR*) GlobalLock (bufH); + WCHAR* const data = static_cast (GlobalLock (bufH)); text.copyToUnicode (data, len); GlobalUnlock (bufH); @@ -218037,7 +218050,7 @@ static Handle createHandleDataRef (Handle dataHandle, const char* fileName) static CFStringRef juceStringToCFString (const String& s) { const int len = s.length(); - const juce_wchar* const t = (const juce_wchar*) s; + const juce_wchar* const t = s; HeapBlock temp (len + 2); for (int i = 0; i <= len; ++i) @@ -218092,7 +218105,7 @@ bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle props[prop].propClass = kQTPropertyClass_DataLocation; props[prop].propID = kQTDataLocationPropertyID_DataReference; props[prop].propValueSize = sizeof (dr); - props[prop].propValueAddress = (void*) &dr; + props[prop].propValueAddress = &dr; ++prop; FileInputStream* const fin = dynamic_cast (input); @@ -220038,7 +220051,7 @@ void CDController::prepare (SRB_ExecSCSICmd& s) void CDController::perform (SRB_ExecSCSICmd& s) { HANDLE event = CreateEvent (0, TRUE, FALSE, 0); - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; ResetEvent (event); @@ -220198,7 +220211,7 @@ bool CDDeviceHandle::readTOC (TOC* lpToc, bool useMSF) s.SRB_BufPointer = (BYTE*)lpToc; s.SRB_SenseLen = 0x0E; s.SRB_CDBLen = 0x0A; - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; s.CDBByte[0] = 0x43; s.CDBByte[1] = (BYTE)(useMSF ? 0x02 : 0x00); s.CDBByte[7] = 0x03; @@ -220277,7 +220290,7 @@ void CDDeviceHandle::openDrawer (bool shouldBeOpen) s.CDBByte[4] = (BYTE)((shouldBeOpen) ? 2 : 3); HANDLE event = CreateEvent (0, TRUE, FALSE, 0); - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; ResetEvent (event); @@ -220357,7 +220370,7 @@ static void GetAspiDeviceInfo (CDDeviceInfo* dev, BYTE ha, BYTE tgt, BYTE lun) s.SRB_BufPointer = buffer; s.SRB_SenseLen = SENSE_LEN; s.SRB_CDBLen = 6; - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; s.CDBByte[0] = SCSI_INQUIRY; s.CDBByte[4] = 100; @@ -221803,7 +221816,7 @@ MidiInput* MidiInput::openDevice (const int index, MidiInputCallback* const call if (err == MMSYSERR_NOERROR) { thread->hIn = h; - in->internal = (void*) thread.release(); + in->internal = thread.release(); return in.release(); } @@ -221920,7 +221933,7 @@ MidiOutput* MidiOutput::openDevice (int index) han->refCount++; MidiOutput* const out = new MidiOutput(); - out->internal = (void*) han; + out->internal = han; return out; } } @@ -221939,7 +221952,7 @@ MidiOutput* MidiOutput::openDevice (int index) MidiOutHandle::activeHandles.add (han); MidiOutput* const out = new MidiOutput(); - out->internal = (void*) han; + out->internal = han; return out; } else if (res == MMSYSERR_ALLOCATED) @@ -228793,7 +228806,7 @@ public: struct sockaddr_in address; zerostruct (address); - memcpy ((void*) &address.sin_addr, (const void*) host->h_addr, host->h_length); + memcpy (&address.sin_addr, host->h_addr, host->h_length); address.sin_family = host->h_addrtype; address.sin_port = htons (port); @@ -229354,7 +229367,7 @@ void* juce_createThread (void* userData) if (pthread_create (&handle, 0, threadEntryProc, userData) == 0) { pthread_detach (handle); - return (void*)handle; + return (void*) handle; } return 0; @@ -231987,7 +232000,7 @@ public: ::setlocale (LC_ALL, oldLocale); } - const juce_wchar unicodeChar = *(const juce_wchar*) String::fromUTF8 (utf8, sizeof (utf8) - 1); + const juce_wchar unicodeChar = String::fromUTF8 (utf8, sizeof (utf8) - 1) [0]; int keyCode = (int) unicodeChar; if (keyCode < 0x20) @@ -234462,7 +234475,7 @@ public: AudioDataConverters::interleaveSamples ((const float**) data, interleaved, numSamples, numChannelsRunning); AudioDataConverters::convertFloatToFormat (sampleFormat, interleaved, interleaved, numSamples * numChannelsRunning); - snd_pcm_sframes_t num = snd_pcm_writei (handle, (void*) interleaved, numSamples); + snd_pcm_sframes_t num = snd_pcm_writei (handle, interleaved, numSamples); if (failed (num) && num != -EPIPE && num != -ESTRPIPE) return false; @@ -234497,7 +234510,7 @@ public: scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); float* interleaved = static_cast (scratch.getData()); - snd_pcm_sframes_t num = snd_pcm_readi (handle, (void*) interleaved, numSamples); + snd_pcm_sframes_t num = snd_pcm_readi (handle, interleaved, numSamples); if (failed (num)) { @@ -236542,11 +236555,10 @@ const String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) CFStringRef PlatformUtilities::juceStringToCFString (const String& s) { const int len = s.length(); - const juce_wchar* t = (const juce_wchar*) s; HeapBlock temp (len + 2); for (int i = 0; i <= len; ++i) - temp[i] = t[i]; + temp[i] = s[i]; return CFStringCreateWithCharacters (kCFAllocatorDefault, temp, len); } @@ -236595,7 +236607,7 @@ const String PlatformUtilities::convertToPrecomposedUnicode (const String& s) { result.preallocateStorage (bytesRead / sizeof (UniChar) + 2); - tchar* t = const_cast ((const tchar*) result); + tchar* t = result; unsigned int i; for (i = 0; i < bytesRead / sizeof (UniChar); ++i) @@ -240142,7 +240154,7 @@ private: --numGradientLookupEntries; CGShadingRef result = 0; - CGFunctionRef function = CGFunctionCreate ((void*) this, 1, 0, 4, 0, &gradientCallbacks); + CGFunctionRef function = CGFunctionCreate (this, 1, 0, 4, 0, &gradientCallbacks); CGPoint p1 (CGPointMake (gradient.x1, gradient.y1)); if (gradient.isRadial) @@ -241972,7 +241984,7 @@ public: } const OpenGLPixelFormat getPixelFormat() const { return pixelFormat; } - void* getRawContext() const throw() { return (void*) glLayer; } + void* getRawContext() const throw() { return glLayer; } void updateWindowPosition (int x, int y, int w, int h, int outerWindowHeight) { @@ -242117,7 +242129,7 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot hotSpot: NSMakePoint (hotspotX, hotspotY)]; [im release]; - return (void*) c; + return c; } static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw() @@ -242213,7 +242225,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro } [c retain]; - return (void*) c; + return c; } void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() @@ -243345,7 +243357,7 @@ MidiOutput* MidiOutput::openDevice (int index) if (OK (MIDIOutputPortCreate (globalMidiClient, pname, &port))) { mo = new MidiOutput(); - mo->internal = (void*) new MidiPortAndEndpoint (port, endPoint); + mo->internal = new MidiPortAndEndpoint (port, endPoint); } } @@ -243368,7 +243380,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) if (OK (MIDISourceCreate (globalMidiClient, name, &endPoint))) { mo = new MidiOutput(); - mo->internal = (void*) new MidiPortAndEndpoint (0, endPoint); + mo->internal = new MidiPortAndEndpoint (0, endPoint); } CFRelease (name); @@ -243629,7 +243641,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) mi = new MidiInput (getDevices() [index]); mpc->input = mi; - mi->internal = (void*) mpc; + mi->internal = mpc; const ScopedLock sl (CoreMidiCallbacks::callbackLock); CoreMidiCallbacks::activeCallbacks.add (mpc.release()); @@ -243669,7 +243681,7 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba mi = new MidiInput (deviceName); mpc->input = mi; - mi->internal = (void*) mpc; + mi->internal = mpc; const ScopedLock sl (CoreMidiCallbacks::callbackLock); CoreMidiCallbacks::activeCallbacks.add (mpc.release()); @@ -244834,7 +244846,7 @@ private: --numGradientLookupEntries; CGShadingRef result = 0; - CGFunctionRef function = CGFunctionCreate ((void*) this, 1, 0, 4, 0, &gradientCallbacks); + CGFunctionRef function = CGFunctionCreate (this, 1, 0, 4, 0, &gradientCallbacks); CGPoint p1 (CGPointMake (gradient.x1, gradient.y1)); if (gradient.isRadial) @@ -245205,7 +245217,7 @@ public: static ModifierKeys currentModifiers; static ComponentPeer* currentlyFocusedPeer; - static VoidArray keysCurrentlyDown; + static Array keysCurrentlyDown; }; END_JUCE_NAMESPACE @@ -245684,19 +245696,19 @@ BEGIN_JUCE_NAMESPACE ModifierKeys NSViewComponentPeer::currentModifiers; ComponentPeer* NSViewComponentPeer::currentlyFocusedPeer = 0; -VoidArray NSViewComponentPeer::keysCurrentlyDown; +Array NSViewComponentPeer::keysCurrentlyDown; bool KeyPress::isKeyCurrentlyDown (const int keyCode) { - if (NSViewComponentPeer::keysCurrentlyDown.contains ((void*) keyCode)) + if (NSViewComponentPeer::keysCurrentlyDown.contains (keyCode)) return true; if (keyCode >= 'A' && keyCode <= 'Z' - && NSViewComponentPeer::keysCurrentlyDown.contains ((void*) (int) CharacterFunctions::toLowerCase ((tchar) keyCode))) + && NSViewComponentPeer::keysCurrentlyDown.contains ((int) CharacterFunctions::toLowerCase ((tchar) keyCode))) return true; if (keyCode >= 'a' && keyCode <= 'z' - && NSViewComponentPeer::keysCurrentlyDown.contains ((void*) (int) CharacterFunctions::toUpperCase ((tchar) keyCode))) + && NSViewComponentPeer::keysCurrentlyDown.contains ((int) CharacterFunctions::toUpperCase ((tchar) keyCode))) return true; return false; @@ -245722,9 +245734,9 @@ void NSViewComponentPeer::updateKeysDown (NSEvent* ev, bool isKeyDown) if (keyCode != 0) { if (isKeyDown) - keysCurrentlyDown.addIfNotAlreadyThere ((void*) keyCode); + keysCurrentlyDown.addIfNotAlreadyThere (keyCode); else - keysCurrentlyDown.removeValue ((void*) keyCode); + keysCurrentlyDown.removeValue (keyCode); } } @@ -246652,7 +246664,7 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot hotSpot: NSMakePoint (hotspotX, hotspotY)]; [im release]; - return (void*) c; + return c; } static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw() @@ -246748,7 +246760,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro } [c retain]; - return (void*) c; + return c; } void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() @@ -247524,7 +247536,7 @@ public: } const OpenGLPixelFormat getPixelFormat() const { return pixelFormat; } - void* getRawContext() const throw() { return (void*) glLayer; } + void* getRawContext() const throw() { return glLayer; } void updateWindowPosition (int x, int y, int w, int h, int outerWindowHeight) { @@ -250290,7 +250302,7 @@ public: AudioValueTranslation avt; char buffer[256]; - avt.mInputData = (void*) &(types[i]); + avt.mInputData = &(types[i]); avt.mInputDataSize = sizeof (UInt32); avt.mOutputData = buffer; avt.mOutputDataSize = 256; @@ -250446,9 +250458,9 @@ public: if (deviceID != 0) { #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - if (OK (AudioDeviceAddIOProc (deviceID, audioIOProc, (void*) this))) + if (OK (AudioDeviceAddIOProc (deviceID, audioIOProc, this))) #else - if (OK (AudioDeviceCreateIOProcID (deviceID, audioIOProc, (void*) this, &audioProcID))) + if (OK (AudioDeviceCreateIOProcID (deviceID, audioIOProc, this, &audioProcID))) #endif { if (OK (AudioDeviceStart (deviceID, audioIOProc))) @@ -251508,7 +251520,7 @@ MidiOutput* MidiOutput::openDevice (int index) if (OK (MIDIOutputPortCreate (globalMidiClient, pname, &port))) { mo = new MidiOutput(); - mo->internal = (void*) new MidiPortAndEndpoint (port, endPoint); + mo->internal = new MidiPortAndEndpoint (port, endPoint); } } @@ -251531,7 +251543,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) if (OK (MIDISourceCreate (globalMidiClient, name, &endPoint))) { mo = new MidiOutput(); - mo->internal = (void*) new MidiPortAndEndpoint (0, endPoint); + mo->internal = new MidiPortAndEndpoint (0, endPoint); } CFRelease (name); @@ -251792,7 +251804,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) mi = new MidiInput (getDevices() [index]); mpc->input = mi; - mi->internal = (void*) mpc; + mi->internal = mpc; const ScopedLock sl (CoreMidiCallbacks::callbackLock); CoreMidiCallbacks::activeCallbacks.add (mpc.release()); @@ -251832,7 +251844,7 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba mi = new MidiInput (deviceName); mpc->input = mi; - mi->internal = (void*) mpc; + mi->internal = mpc; const ScopedLock sl (CoreMidiCallbacks::callbackLock); CoreMidiCallbacks::activeCallbacks.add (mpc.release()); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 2b9a8e7122..123aae782b 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -13943,7 +13943,7 @@ public: protected: AudioFormat (const String& formatName, - const tchar** const fileExtensions); + const juce_wchar** const fileExtensions); private: @@ -16189,8 +16189,9 @@ private: int dragStartMousePos, lastMousePos; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; bool vertical, isDraggingThumb, alwaysVisible; - Button* upButton; - Button* downButton; + class ScrollbarButton; + ScrollbarButton* upButton; + ScrollbarButton* downButton; ListenerList listeners; void updateThumbPosition(); @@ -17469,7 +17470,7 @@ private: MidiFile (const MidiFile&); MidiFile& operator= (const MidiFile&); - void readNextTrack (const char* data, int size); + void readNextTrack (const uint8* data, int size); void writeTrack (OutputStream& mainOut, const int trackNum); }; @@ -19149,7 +19150,8 @@ public: private: Viewport* viewport; - Component* propertyHolderComponent; + class PropertyHolderComponent; + PropertyHolderComponent* propertyHolderComponent; String messageWhenEmpty; void updatePropHolderLayout() const; @@ -20803,7 +20805,7 @@ private: UndoManager undoManager; int currentActionIndex, indexOfSavedState; int maximumLineLength; - VoidArray listeners; + ListenerList listeners; String newLineChars; void sendListenerChangeMessage (int startLine, int endLine); @@ -20979,7 +20981,8 @@ private: CodeDocument::Position caretPos; CodeDocument::Position selectionStart, selectionEnd; - Component* caret; + class CaretComponent; + CaretComponent* caret; ScrollBar* verticalScrollBar; ScrollBar* horizontalScrollBar; @@ -21419,7 +21422,6 @@ private: bool incDecButtonsSideBySide : 1, sendChangeOnlyOnRelease : 1, popupDisplayEnabled : 1; bool menuEnabled : 1, menuShown : 1, mouseWasHidden : 1, incDecDragged : 1; bool scrollWheelEnabled : 1, snapsToMousePos : 1; - Font font; Label* valueBox; Button* incButton; Button* decButton; @@ -22031,7 +22033,7 @@ public: void scrollToKeepItemVisible (TreeViewItem* item); - Viewport* getViewport() const throw() { return viewport; } + Viewport* getViewport() const throw(); int getIndentSize() const throw() { return indentSize; } @@ -22071,11 +22073,14 @@ public: private: friend class TreeViewItem; friend class TreeViewContentComponent; - Viewport* viewport; + class TreeViewport; + TreeViewport* viewport; CriticalSection nodeAlterationLock; TreeViewItem* rootItem; - Component* dragInsertPointHighlight; - Component* dragTargetGroupHighlight; + class InsertPointHighlight; + class TargetGroupHighlight; + InsertPointHighlight* dragInsertPointHighlight; + TargetGroupHighlight* dragTargetGroupHighlight; int indentSize; bool defaultOpenness : 1; bool needsRecalculating : 1; @@ -23459,9 +23464,9 @@ private: ListBox* listBox; Button* addButton; Button* removeButton; - Button* changeButton; - Button* upButton; - Button* downButton; + TextButton* changeButton; + DrawableButton* upButton; + DrawableButton* downButton; void changed(); void updateButtons(); @@ -26401,14 +26406,17 @@ public: juce_UseDebuggingNewOperator private: + class ColourSpaceView; + class HueSelectorComp; + class SwatchComponent; friend class ColourSpaceView; friend class HueSelectorComp; + Colour colour; float h, s, v; Slider* sliders[4]; - Component* colourSpace; - Component* hueSelector; - class SwatchComponent; + ColourSpaceView* colourSpace; + HueSelectorComp* hueSelector; OwnedArray swatchComponents; const int flags; int topSpace, edgeGap; diff --git a/src/application/juce_Application.cpp b/src/application/juce_Application.cpp index b78452aa22..f7eaa78115 100644 --- a/src/application/juce_Application.cpp +++ b/src/application/juce_Application.cpp @@ -230,7 +230,7 @@ int JUCEApplication::shutdownAppAndClearUp() ScopedPointer app (appInstance); int returnValue = 0; - MessageManager::getInstance()->deregisterBroadcastListener ((JUCEApplication*) app); + MessageManager::getInstance()->deregisterBroadcastListener (static_cast (app)); static bool reentrancyCheck = false; diff --git a/src/audio/audio_file_formats/juce_AudioFormat.cpp b/src/audio/audio_file_formats/juce_AudioFormat.cpp index ca04dd1b90..b0dbb0f641 100644 --- a/src/audio/audio_file_formats/juce_AudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_AudioFormat.cpp @@ -512,7 +512,7 @@ bool AudioFormatWriter::writeFromAudioSource (AudioSource& source, //============================================================================== AudioFormat::AudioFormat (const String& name, - const tchar** const extensions) + const juce_wchar** const extensions) : formatName (name), fileExtensions (extensions) { diff --git a/src/audio/audio_file_formats/juce_AudioFormat.h b/src/audio/audio_file_formats/juce_AudioFormat.h index 213d200b95..5ac151c73f 100644 --- a/src/audio/audio_file_formats/juce_AudioFormat.h +++ b/src/audio/audio_file_formats/juce_AudioFormat.h @@ -161,7 +161,7 @@ protected: be returned by getFileExtension() */ AudioFormat (const String& formatName, - const tchar** const fileExtensions); + const juce_wchar** const fileExtensions); private: //============================================================================== diff --git a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp index 99ed7767f8..05a4ea6336 100644 --- a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp +++ b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp @@ -382,7 +382,7 @@ void AudioThumbnail::refillCache (const int numSamples, { startTimer (timeBeforeDeletingReader); - char* cacheData = (char*) cachedLevels.getData(); + char* cacheData = static_cast (cachedLevels.getData()); int sample = roundToInt (startTime * d->sampleRate); for (int i = numSamples; --i >= 0;) @@ -421,7 +421,7 @@ void AudioThumbnail::refillCache (const int numSamples, for (int channelNum = 0; channelNum < numChannelsCached; ++channelNum) { char* const channelData = getChannelData (channelNum); - char* cacheData = ((char*) cachedLevels.getData()) + channelNum * 2; + char* cacheData = static_cast (cachedLevels.getData()) + channelNum * 2; const double timeToThumbSampleFactor = d->sampleRate / (double) d->samplesPerThumbSample; @@ -504,7 +504,7 @@ void AudioThumbnail::drawChannel (Graphics& g, w -= skipLeft; x += skipLeft; - const char* cacheData = ((const char*) cachedLevels.getData()) + const char* cacheData = static_cast (cachedLevels.getData()) + (channelNum << 1) + skipLeft * (numChannelsCached << 1); diff --git a/src/audio/audio_file_formats/juce_AudioThumbnailCache.cpp b/src/audio/audio_file_formats/juce_AudioThumbnailCache.cpp index f9317cc2f5..450a868936 100644 --- a/src/audio/audio_file_formats/juce_AudioThumbnailCache.cpp +++ b/src/audio/audio_file_formats/juce_AudioThumbnailCache.cpp @@ -60,10 +60,7 @@ bool AudioThumbnailCache::loadThumb (AudioThumbnail& thumb, const int64 hashCode { if (thumbs[i]->hash == hashCode) { - MemoryInputStream in ((const char*) thumbs[i]->data.getData(), - thumbs[i]->data.getSize(), - false); - + MemoryInputStream in (thumbs[i]->data, false); thumb.loadFrom (in); thumbs[i]->lastUsed = Time::getMillisecondCounter(); diff --git a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp index 39a392b208..6b85228877 100644 --- a/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_FlacAudioFormat.cpp @@ -109,7 +109,7 @@ public: ok = FLAC__stream_decoder_init_stream (decoder, readCallback_, seekCallback_, tellCallback_, lengthCallback_, eofCallback_, writeCallback_, metadataCallback_, errorCallback_, - (void*) this) == FLAC__STREAM_DECODER_INIT_STATUS_OK; + this) == FLAC__STREAM_DECODER_INIT_STATUS_OK; if (ok) { @@ -343,7 +343,7 @@ public: ok = FLAC__stream_encoder_init_stream (encoder, encodeWriteCallback, encodeSeekCallback, encodeTellCallback, encodeMetadataCallback, - (void*) this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK; + this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK; } ~FlacWriter() diff --git a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp index ffddd026d2..c1d420bfa4 100644 --- a/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_OggVorbisAudioFormat.cpp @@ -215,12 +215,12 @@ public: //============================================================================== static size_t oggReadCallback (void* ptr, size_t size, size_t nmemb, void* datasource) { - return (size_t) (((InputStream*) datasource)->read (ptr, (int) (size * nmemb)) / size); + return (size_t) (static_cast (datasource)->read (ptr, (int) (size * nmemb)) / size); } static int oggSeekCallback (void* datasource, OggVorbisNamespace::ogg_int64_t offset, int whence) { - InputStream* const in = (InputStream*) datasource; + InputStream* const in = static_cast (datasource); if (whence == SEEK_CUR) offset += in->getPosition(); @@ -238,7 +238,7 @@ public: static long oggTellCallback (void* datasource) { - return (long) ((InputStream*) datasource)->getPosition(); + return (long) static_cast (datasource)->getPosition(); } juce_UseDebuggingNewOperator diff --git a/src/audio/audio_file_formats/juce_WavAudioFormat.cpp b/src/audio/audio_file_formats/juce_WavAudioFormat.cpp index 2a225d0138..456733cecd 100644 --- a/src/audio/audio_file_formats/juce_WavAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_WavAudioFormat.cpp @@ -426,7 +426,7 @@ public: if (bitsPerSample == 16) { - const short* src = (const short*) tempBuffer; + const short* src = reinterpret_cast (tempBuffer); if (numChannels > 1) { @@ -465,7 +465,7 @@ public: } else if (bitsPerSample == 24) { - const char* src = (const char*) tempBuffer; + const char* src = tempBuffer; if (numChannels > 1) { @@ -705,7 +705,7 @@ public: const int bytes = numChannels * numSamples * bitsPerSample / 8; tempBlock.ensureSize (bytes, false); - char* buffer = (char*) tempBlock.getData(); + char* buffer = static_cast (tempBlock.getData()); const int* left = data[0]; const int* right = data[1]; @@ -734,7 +734,7 @@ public: } else if (bitsPerSample == 24) { - char* b = (char*) buffer; + char* b = buffer; if (numChannels > 1) { diff --git a/src/audio/audio_sources/juce_BufferingAudioSource.cpp b/src/audio/audio_sources/juce_BufferingAudioSource.cpp index f2aa94f818..9e168ba96f 100644 --- a/src/audio/audio_sources/juce_BufferingAudioSource.cpp +++ b/src/audio/audio_sources/juce_BufferingAudioSource.cpp @@ -58,9 +58,9 @@ public: { const ScopedLock sl (lock); - if (! sources.contains ((void*) source)) + if (! sources.contains (source)) { - sources.add ((void*) source); + sources.add (source); startThread(); stopTimer(); @@ -72,14 +72,14 @@ public: void removeSource (BufferingAudioSource* source) { const ScopedLock sl (lock); - sources.removeValue ((void*) source); + sources.removeValue (source); if (sources.size() == 0) startTimer (5000); } private: - VoidArray sources; + Array sources; CriticalSection lock; void run() @@ -95,7 +95,7 @@ private: const ScopedLock sl (lock); - BufferingAudioSource* const b = (BufferingAudioSource*) sources[i]; + BufferingAudioSource* const b = sources[i]; if (b != 0 && b->readNextBufferChunk()) busy = true; diff --git a/src/audio/audio_sources/juce_MixerAudioSource.cpp b/src/audio/audio_sources/juce_MixerAudioSource.cpp index 30ae1b24fc..9b21f3a15f 100644 --- a/src/audio/audio_sources/juce_MixerAudioSource.cpp +++ b/src/audio/audio_sources/juce_MixerAudioSource.cpp @@ -77,7 +77,7 @@ void MixerAudioSource::removeInputSource (AudioSource* input, const bool deleteI { const ScopedLock sl (lock); - index = inputs.indexOf ((void*) input); + index = inputs.indexOf (input); if (index >= 0) { diff --git a/src/audio/dsp/juce_AudioDataConverters.cpp b/src/audio/dsp/juce_AudioDataConverters.cpp index b63d16e04d..019896fedc 100644 --- a/src/audio/dsp/juce_AudioDataConverters.cpp +++ b/src/audio/dsp/juce_AudioDataConverters.cpp @@ -34,13 +34,13 @@ BEGIN_JUCE_NAMESPACE void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { for (int i = 0; i < numSamples; ++i) { - *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); intData += destBytesPerSample; } } @@ -51,7 +51,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint16*)intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -59,7 +59,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -76,7 +76,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest for (int i = numSamples; --i >= 0;) { intData -= destBytesPerSample; - *(uint16*)intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); + *(uint16*) intData = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); } } } @@ -84,7 +84,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -109,7 +109,7 @@ void AudioDataConverters::convertFloatToInt24LE (const float* source, void* dest void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -134,7 +134,7 @@ void AudioDataConverters::convertFloatToInt24BE (const float* source, void* dest void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -159,7 +159,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest, int numSamples, const int destBytesPerSample) { const double maxVal = (double) 0x7fffffff; - char* intData = (char*) dest; + char* intData = static_cast (dest); if (dest != (void*) source || destBytesPerSample <= 4) { @@ -185,7 +185,7 @@ void AudioDataConverters::convertFloatToFloat32LE (const float* source, void* de { jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data! - char* d = (char*) dest; + char* d = static_cast (dest); for (int i = 0; i < numSamples; ++i) { @@ -203,7 +203,7 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de { jassert (dest != (void*) source || destBytesPerSample <= 4); // This op can't be performed on in-place data! - char* d = (char*) dest; + char* d = static_cast (dest); for (int i = 0; i < numSamples; ++i) { @@ -221,7 +221,7 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de void AudioDataConverters::convertInt16LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -246,7 +246,7 @@ void AudioDataConverters::convertInt16LEToFloat (const void* const source, float void AudioDataConverters::convertInt16BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -271,7 +271,7 @@ void AudioDataConverters::convertInt16BEToFloat (const void* const source, float void AudioDataConverters::convertInt24LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -296,7 +296,7 @@ void AudioDataConverters::convertInt24LEToFloat (const void* const source, float void AudioDataConverters::convertInt24BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -321,7 +321,7 @@ void AudioDataConverters::convertInt24BEToFloat (const void* const source, float void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -346,7 +346,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* const source, float void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { const float scale = 1.0f / 0x7fffffff; - const char* intData = (const char*) source; + const char* intData = static_cast (source); if (source != (void*) dest || srcBytesPerSample >= 4) { @@ -370,7 +370,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* const source, float void AudioDataConverters::convertFloat32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const char* s = (const char*) source; + const char* s = static_cast (source); for (int i = 0; i < numSamples; ++i) { @@ -387,7 +387,7 @@ void AudioDataConverters::convertFloat32LEToFloat (const void* const source, flo void AudioDataConverters::convertFloat32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample) { - const char* s = (const char*) source; + const char* s = static_cast (source); for (int i = 0; i < numSamples; ++i) { diff --git a/src/audio/midi/juce_MidiFile.cpp b/src/audio/midi/juce_MidiFile.cpp index 475c78d7bd..79d94db489 100644 --- a/src/audio/midi/juce_MidiFile.cpp +++ b/src/audio/midi/juce_MidiFile.cpp @@ -55,7 +55,7 @@ namespace MidiFileHelpers } } - static bool parseMidiHeader (const char* &data, short& timeFormat, short& fileType, short& numberOfTracks) throw() + static bool parseMidiHeader (const uint8* &data, short& timeFormat, short& fileType, short& numberOfTracks) throw() { unsigned int ch = (int) ByteOrder::bigEndianInt (data); data += 4; @@ -266,12 +266,12 @@ bool MidiFile::readFrom (InputStream& sourceStream) if (sourceStream.readIntoMemoryBlock (data, maxSensibleMidiFileSize)) { size_t size = data.getSize(); - const char* d = (char*) data.getData(); + const uint8* d = static_cast (data.getData()); short fileType, expectedTracks; if (size > 16 && MidiFileHelpers::parseMidiHeader (d, timeFormat, fileType, expectedTracks)) { - size -= (int) (d - (char*) data.getData()); + size -= (int) (d - static_cast (data.getData())); int track = 0; @@ -326,7 +326,7 @@ int MidiFile::compareElements (const MidiMessageSequence::MidiEventHolder* const } } -void MidiFile::readNextTrack (const char* data, int size) +void MidiFile::readNextTrack (const uint8* data, int size) { double time = 0; char lastStatusByte = 0; @@ -336,13 +336,13 @@ void MidiFile::readNextTrack (const char* data, int size) while (size > 0) { int bytesUsed; - const int delay = MidiMessage::readVariableLengthVal ((const uint8*) data, bytesUsed); + const int delay = MidiMessage::readVariableLengthVal (data, bytesUsed); data += bytesUsed; size -= bytesUsed; time += delay; int messSize = 0; - const MidiMessage mm ((const uint8*) data, size, messSize, lastStatusByte, time); + const MidiMessage mm (data, size, messSize, lastStatusByte, time); if (messSize <= 0) break; diff --git a/src/audio/midi/juce_MidiFile.h b/src/audio/midi/juce_MidiFile.h index e952015952..2e0cbecf50 100644 --- a/src/audio/midi/juce_MidiFile.h +++ b/src/audio/midi/juce_MidiFile.h @@ -188,7 +188,7 @@ private: MidiFile (const MidiFile&); MidiFile& operator= (const MidiFile&); - void readNextTrack (const char* data, int size); + void readNextTrack (const uint8* data, int size); void writeTrack (OutputStream& mainOut, const int trackNum); }; diff --git a/src/audio/midi/juce_MidiMessage.cpp b/src/audio/midi/juce_MidiMessage.cpp index 417e7180da..b906f9aa34 100644 --- a/src/audio/midi/juce_MidiMessage.cpp +++ b/src/audio/midi/juce_MidiMessage.cpp @@ -548,7 +548,7 @@ bool MidiMessage::isSysEx() const throw() const MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const int dataSize) { MemoryBlock mm (dataSize + 2); - uint8* const m = (uint8*) mm.getData(); + uint8* const m = static_cast (mm.getData()); m[0] = 0xf0; memcpy (m + 1, sysexData, dataSize); @@ -624,7 +624,7 @@ bool MidiMessage::isTextMetaEvent() const throw() const String MidiMessage::getTextFromTextMetaEvent() const { - return String ((const char*) getMetaEventData(), getMetaEventLength()); + return String (reinterpret_cast (getMetaEventData()), getMetaEventLength()); } bool MidiMessage::isTrackNameEvent() const throw() diff --git a/src/containers/juce_BitArray.cpp b/src/containers/juce_BitArray.cpp index 6048f14f2a..3f0fce8b2c 100644 --- a/src/containers/juce_BitArray.cpp +++ b/src/containers/juce_BitArray.cpp @@ -920,7 +920,7 @@ const String BigInteger::toString (const int base, const int minimumNumCharacter void BigInteger::parseString (const String& text, const int base) { clear(); - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; if (base == 2 || base == 8 || base == 16) { diff --git a/src/containers/juce_MemoryBlock.cpp b/src/containers/juce_MemoryBlock.cpp index 670bb944cb..64465019f0 100644 --- a/src/containers/juce_MemoryBlock.cpp +++ b/src/containers/juce_MemoryBlock.cpp @@ -239,7 +239,7 @@ void MemoryBlock::removeSection (size_t startByte, size_t numBytesToRemove) thro const String MemoryBlock::toString() const throw() { - return String ((const char*) data, size); + return String (static_cast (getData()), size); } //============================================================================== @@ -348,7 +348,8 @@ const String MemoryBlock::toBase64Encoding() const throw() const int initialLen = destString.length(); destString.preallocateStorage (initialLen + 2 + numChars); - tchar* d = const_cast (((const tchar*) destString) + initialLen); + juce_wchar* d = destString; + d += initialLen; *d++ = '.'; for (size_t i = 0; i < numChars; ++i) @@ -371,7 +372,8 @@ bool MemoryBlock::fromBase64Encoding (const String& s) throw() setSize (numBytesNeeded, true); const int numChars = s.length() - startPos; - const tchar* const srcChars = ((const tchar*) s) + startPos; + const juce_wchar* srcChars = s; + srcChars += startPos; int pos = 0; for (int i = 0; i < numChars; ++i) diff --git a/src/containers/juce_Variant.cpp b/src/containers/juce_Variant.cpp index 9bec0e3335..bc7cd03a44 100644 --- a/src/containers/juce_Variant.cpp +++ b/src/containers/juce_Variant.cpp @@ -273,7 +273,7 @@ const var var::readFromStream (InputStream& input) { MemoryBlock mb; input.readIntoMemoryBlock (mb, numBytes - 1); - return var (String::fromUTF8 ((const char*) mb.getData(), (int) mb.getSize())); + return var (String::fromUTF8 (static_cast (mb.getData()), (int) mb.getSize())); } default: input.skipNextBytes (numBytes - 1); break; diff --git a/src/events/juce_InterprocessConnection.cpp b/src/events/juce_InterprocessConnection.cpp index 71d2ea0aa0..d8114b899e 100644 --- a/src/events/juce_InterprocessConnection.cpp +++ b/src/events/juce_InterprocessConnection.cpp @@ -217,7 +217,7 @@ void InterprocessConnection::handleMessage (const Message& message) { case 0: { - ScopedPointer data ((MemoryBlock*) message.pointerParameter); + ScopedPointer data (static_cast (message.pointerParameter)); messageReceived (*data); break; } diff --git a/src/events/juce_MessageManager.cpp b/src/events/juce_MessageManager.cpp index b11fb6e788..8bc0d76552 100644 --- a/src/events/juce_MessageManager.cpp +++ b/src/events/juce_MessageManager.cpp @@ -99,9 +99,9 @@ void MessageManager::postCallbackMessage (Message* const message) //============================================================================== // not for public use.. -void MessageManager::deliverMessage (void* message) +void MessageManager::deliverMessage (void* const message) { - const ScopedPointer m ((Message*) message); + const ScopedPointer m (static_cast (message)); MessageListener* const recipient = m->messageRecipient; JUCE_TRY @@ -118,7 +118,7 @@ void MessageManager::deliverMessage (void* message) } else { - CallbackMessage* const cm = dynamic_cast ((Message*) m); + CallbackMessage* const cm = dynamic_cast (static_cast (m)); if (cm != 0) cm->messageCallback(); diff --git a/src/gui/components/code_editor/juce_CodeDocument.cpp b/src/gui/components/code_editor/juce_CodeDocument.cpp index 7f5c45da76..0a43699d67 100644 --- a/src/gui/components/code_editor/juce_CodeDocument.cpp +++ b/src/gui/components/code_editor/juce_CodeDocument.cpp @@ -51,7 +51,7 @@ public: static void createLines (Array & newLines, const String& text) { - const tchar* const t = (const tchar*) text; + const juce_wchar* const t = text; int pos = 0; while (t [pos] != 0) @@ -709,26 +709,20 @@ void CodeDocument::checkLastLineStatus() //============================================================================== void CodeDocument::addListener (CodeDocument::Listener* const listener) throw() { - listeners.addIfNotAlreadyThere (listener); + listeners.add (listener); } void CodeDocument::removeListener (CodeDocument::Listener* const listener) throw() { - listeners.removeValue (listener); + listeners.remove (listener); } void CodeDocument::sendListenerChangeMessage (const int startLine, const int endLine) { - const Position startPos (this, startLine, 0); - const Position endPos (this, endLine, 0); + Position startPos (this, startLine, 0); + Position endPos (this, endLine, 0); - for (int i = listeners.size(); --i >= 0;) - { - Listener* const l = (Listener*) listeners[i]; - - if (l != 0) - l->codeDocumentChanged (startPos, endPos); - } + listeners.call (&Listener::codeDocumentChanged, startPos, endPos); } //============================================================================== diff --git a/src/gui/components/code_editor/juce_CodeDocument.h b/src/gui/components/code_editor/juce_CodeDocument.h index ad7bd15485..f8ccf2f751 100644 --- a/src/gui/components/code_editor/juce_CodeDocument.h +++ b/src/gui/components/code_editor/juce_CodeDocument.h @@ -28,7 +28,7 @@ #include "../../../utilities/juce_UndoManager.h" #include "../../graphics/colour/juce_Colour.h" -#include "../../../containers/juce_VoidArray.h" +#include "../../../events/juce_ListenerList.h" #include "../../../io/streams/juce_InputStream.h" #include "../../../io/streams/juce_OutputStream.h" class CodeDocumentLine; @@ -392,7 +392,7 @@ private: UndoManager undoManager; int currentActionIndex, indexOfSavedState; int maximumLineLength; - VoidArray listeners; + ListenerList listeners; String newLineChars; void sendListenerChangeMessage (int startLine, int endLine); diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp index 6977589d1f..1b648bb246 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp @@ -33,8 +33,8 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -class CaretComponent : public Component, - public Timer +class CodeEditorComponent::CaretComponent : public Component, + public Timer { public: CaretComponent() @@ -66,6 +66,10 @@ public: const Rectangle pos (owner.getCharacterBounds (owner.getCaretPos())); setBounds (pos.getX(), pos.getY(), 2, pos.getHeight()); } + +private: + CaretComponent (const CaretComponent&); + CaretComponent& operator= (const CaretComponent&); }; //============================================================================== @@ -348,7 +352,7 @@ void CodeEditorComponent::codeDocumentChanged (const CodeDocument::Position& aff triggerAsyncUpdate(); - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); columnToTryToMaintain = -1; if (affectedTextEnd.getPosition() >= selectionStart.getPosition() @@ -368,7 +372,7 @@ void CodeEditorComponent::resized() columnsOnScreen = (int) ((getWidth() - scrollbarThickness) / charWidth); lines.clear(); rebuildLineTokens(); - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); verticalScrollBar->setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness); horizontalScrollBar->setBounds (gutter, getHeight() - scrollbarThickness, getWidth() - scrollbarThickness - gutter, scrollbarThickness); @@ -511,7 +515,7 @@ void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, con deselectAll(); } - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); scrollToKeepCaretOnScreen(); updateScrollBars(); } @@ -542,7 +546,7 @@ void CodeEditorComponent::scrollToLineInternal (int newFirstLineOnScreen) if (newFirstLineOnScreen != firstLineOnScreen) { firstLineOnScreen = newFirstLineOnScreen; - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); updateCachedIterators (firstLineOnScreen); triggerAsyncUpdate(); @@ -556,7 +560,7 @@ void CodeEditorComponent::scrollToColumnInternal (double column) if (xOffset != newOffset) { xOffset = newOffset; - ((CaretComponent*) caret)->updatePosition (*this); + caret->updatePosition (*this); repaint(); } } diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.h b/src/gui/components/code_editor/juce_CodeEditorComponent.h index 8cc8bf171b..e221e97f50 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.h +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.h @@ -260,7 +260,8 @@ private: CodeDocument::Position caretPos; CodeDocument::Position selectionStart, selectionEnd; - Component* caret; + class CaretComponent; + CaretComponent* caret; ScrollBar* verticalScrollBar; ScrollBar* horizontalScrollBar; diff --git a/src/gui/components/controls/juce_ListBox.cpp b/src/gui/components/controls/juce_ListBox.cpp index ddd0b7af47..91d29ba35a 100644 --- a/src/gui/components/controls/juce_ListBox.cpp +++ b/src/gui/components/controls/juce_ListBox.cpp @@ -197,8 +197,8 @@ public: ListBoxRowComponent* getComponentForRow (const int row) const throw() { - return (ListBoxRowComponent*) getViewedComponent() - ->getChildComponent (row % jmax (1, getViewedComponent()->getNumChildComponents())); + return static_cast + (getViewedComponent()->getChildComponent (row % jmax (1, getViewedComponent()->getNumChildComponents()))); } int getRowNumberOfComponent (Component* const rowComponent) const throw() diff --git a/src/gui/components/controls/juce_Slider.h b/src/gui/components/controls/juce_Slider.h index e0268b71de..a3f4bad8a4 100644 --- a/src/gui/components/controls/juce_Slider.h +++ b/src/gui/components/controls/juce_Slider.h @@ -775,7 +775,6 @@ private: bool incDecButtonsSideBySide : 1, sendChangeOnlyOnRelease : 1, popupDisplayEnabled : 1; bool menuEnabled : 1, menuShown : 1, mouseWasHidden : 1, incDecDragged : 1; bool scrollWheelEnabled : 1, snapsToMousePos : 1; - Font font; Label* valueBox; Button* incButton; Button* decButton; diff --git a/src/gui/components/controls/juce_TableListBox.cpp b/src/gui/components/controls/juce_TableListBox.cpp index e46d881c4c..5be8d42986 100644 --- a/src/gui/components/controls/juce_TableListBox.cpp +++ b/src/gui/components/controls/juce_TableListBox.cpp @@ -426,7 +426,7 @@ Component* TableListBox::refreshComponentForRow (int rowNumber, bool isRowSelect if (existingComponentToUpdate == 0) existingComponentToUpdate = new TableListRowComp (*this); - ((TableListRowComp*) existingComponentToUpdate)->update (rowNumber, isRowSelected_); + static_cast (existingComponentToUpdate)->update (rowNumber, isRowSelected_); return existingComponentToUpdate; } diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index f85a69fe41..5680ce6932 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -277,7 +277,7 @@ private: { int i = 0; const int len = textToParse.length(); - const tchar* const text = (const tchar*) textToParse; + const juce_wchar* const text = textToParse; while (i < len) { diff --git a/src/gui/components/controls/juce_TreeView.cpp b/src/gui/components/controls/juce_TreeView.cpp index 032d9c5335..20cbe99784 100644 --- a/src/gui/components/controls/juce_TreeView.cpp +++ b/src/gui/components/controls/juce_TreeView.cpp @@ -228,7 +228,7 @@ public: for (int i = rowComponentItems.size(); --i >= 0;) { - Component* const comp = (Component*) rowComponents.getUnchecked(i); + Component* const comp = rowComponents.getUnchecked(i); bool keep = false; @@ -236,7 +236,7 @@ public: { if (itemsToKeep[i]) { - const TreeViewItem* const item = (TreeViewItem*) rowComponentItems.getUnchecked(i); + const TreeViewItem* const item = rowComponentItems.getUnchecked(i); Rectangle pos (item->getItemPosition (false)); pos.setSize (pos.getWidth(), item->itemHeight); @@ -328,9 +328,9 @@ public: private: TreeView* const owner; - VoidArray rowComponentItems; + Array rowComponentItems; Array rowComponentIds; - VoidArray rowComponents; + Array rowComponents; TreeViewItem* buttonUnderMouse; bool isDragging, needSelectionOnMouseUp; @@ -371,7 +371,7 @@ private: bool containsItem (TreeViewItem* const item) const { for (int i = rowComponentItems.size(); --i >= 0;) - if ((TreeViewItem*) rowComponentItems.getUnchecked (i) == item) + if (rowComponentItems.getUnchecked(i) == item) return true; return false; @@ -379,7 +379,7 @@ private: }; //============================================================================== -class TreeViewport : public Viewport +class TreeView::TreeViewport : public Viewport { public: TreeViewport() throw() {} @@ -387,8 +387,9 @@ public: void updateComponents() { - if (getViewedComponent() != 0) - ((TreeViewContentComponent*) getViewedComponent())->updateComponents(); + TreeViewContentComponent* const tvc = static_cast (getViewedComponent()); + if (tvc != 0) + tvc->updateComponents(); repaint(); } @@ -522,6 +523,11 @@ void TreeView::setOpenCloseButtonsVisible (const bool shouldBeVisible) } } +Viewport* TreeView::getViewport() const throw() +{ + return viewport; +} + //============================================================================== void TreeView::clearSelectedItems() { @@ -560,7 +566,7 @@ TreeViewItem* TreeView::getItemOnRow (int index) const TreeViewItem* TreeView::getItemAt (int y) const throw() { - TreeViewContentComponent* const tc = (TreeViewContentComponent*) viewport->getViewedComponent(); + TreeViewContentComponent* const tc = static_cast (viewport->getViewedComponent()); Rectangle pos; return tc->findItemAt (relativePositionToOtherComponent (tc, Point (0, y)).getY(), pos); } @@ -788,7 +794,7 @@ void TreeView::handleAsyncUpdate() if (rootItem != 0) rootItem->updatePositions (rootItemVisible ? 0 : -rootItem->itemHeight); - ((TreeViewport*) viewport)->updateComponents(); + viewport->updateComponents(); if (rootItem != 0) { @@ -804,10 +810,10 @@ void TreeView::handleAsyncUpdate() } //============================================================================== -class TreeViewDragInsertPointHighlight : public Component +class TreeView::InsertPointHighlight : public Component { public: - TreeViewDragInsertPointHighlight() + InsertPointHighlight() : lastItem (0) { setSize (100, 12); @@ -815,7 +821,7 @@ public: setInterceptsMouseClicks (false, false); } - ~TreeViewDragInsertPointHighlight() {} + ~InsertPointHighlight() {} void setTargetPosition (TreeViewItem* const item, int insertIndex, const int x, const int y, const int width) throw() { @@ -839,18 +845,23 @@ public: TreeViewItem* lastItem; int lastIndex; + +private: + InsertPointHighlight (const InsertPointHighlight&); + InsertPointHighlight& operator= (const InsertPointHighlight&); }; -class TreeViewDragTargetGroupHighlight : public Component +//============================================================================== +class TreeView::TargetGroupHighlight : public Component { public: - TreeViewDragTargetGroupHighlight() + TargetGroupHighlight() { setAlwaysOnTop (true); setInterceptsMouseClicks (false, false); } - ~TreeViewDragTargetGroupHighlight() {} + ~TargetGroupHighlight() {} void setTargetPosition (TreeViewItem* const item) throw() { @@ -864,6 +875,10 @@ public: g.setColour (findColour (TreeView::dragAndDropIndicatorColourId, true)); g.drawRoundedRectangle (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 3.0f, 2.0f); } + +private: + TargetGroupHighlight (const TargetGroupHighlight&); + TargetGroupHighlight& operator= (const TargetGroupHighlight&); }; //============================================================================== @@ -873,15 +888,12 @@ void TreeView::showDragHighlight (TreeViewItem* item, int insertIndex, int x, in if (dragInsertPointHighlight == 0) { - addAndMakeVisible (dragInsertPointHighlight = new TreeViewDragInsertPointHighlight()); - addAndMakeVisible (dragTargetGroupHighlight = new TreeViewDragTargetGroupHighlight()); + addAndMakeVisible (dragInsertPointHighlight = new InsertPointHighlight()); + addAndMakeVisible (dragTargetGroupHighlight = new TargetGroupHighlight()); } - ((TreeViewDragInsertPointHighlight*) dragInsertPointHighlight) - ->setTargetPosition (item, insertIndex, x, y, viewport->getViewWidth()); - - ((TreeViewDragTargetGroupHighlight*) dragTargetGroupHighlight) - ->setTargetPosition (item); + dragInsertPointHighlight->setTargetPosition (item, insertIndex, x, y, viewport->getViewWidth()); + dragTargetGroupHighlight->setTargetPosition (item); } void TreeView::hideDragHighlight() throw() @@ -954,8 +966,8 @@ void TreeView::handleDrag (const StringArray& files, const String& sourceDescrip if (item != 0) { if (scrolled || dragInsertPointHighlight == 0 - || ((TreeViewDragInsertPointHighlight*) dragInsertPointHighlight)->lastItem != item - || ((TreeViewDragInsertPointHighlight*) dragInsertPointHighlight)->lastIndex != insertIndex) + || dragInsertPointHighlight->lastItem != item + || dragInsertPointHighlight->lastIndex != insertIndex) { if (files.size() > 0 ? item->isInterestedInFileDrag (files) : item->isInterestedInDragSource (sourceDescription, sourceComponent)) @@ -1470,7 +1482,7 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) g.reduceClipRegion (0, 0, indentWidth, itemHeight); paintOpenCloseButton (g, indentWidth, itemHeight, - ((TreeViewContentComponent*) ownerView->viewport->getViewedComponent()) + static_cast (ownerView->viewport->getViewedComponent()) ->isMouseOverButton (this)); g.restoreState(); diff --git a/src/gui/components/controls/juce_TreeView.h b/src/gui/components/controls/juce_TreeView.h index d28f02321f..6e1de843e9 100644 --- a/src/gui/components/controls/juce_TreeView.h +++ b/src/gui/components/controls/juce_TreeView.h @@ -650,7 +650,7 @@ public: void scrollToKeepItemVisible (TreeViewItem* item); /** Returns the treeview's Viewport object. */ - Viewport* getViewport() const throw() { return viewport; } + Viewport* getViewport() const throw(); /** Returns the number of pixels by which each nested level of the tree is indented. @see setIndentSize @@ -751,11 +751,14 @@ public: private: friend class TreeViewItem; friend class TreeViewContentComponent; - Viewport* viewport; + class TreeViewport; + TreeViewport* viewport; CriticalSection nodeAlterationLock; TreeViewItem* rootItem; - Component* dragInsertPointHighlight; - Component* dragTargetGroupHighlight; + class InsertPointHighlight; + class TargetGroupHighlight; + InsertPointHighlight* dragInsertPointHighlight; + TargetGroupHighlight* dragTargetGroupHighlight; int indentSize; bool defaultOpenness : 1; bool needsRecalculating : 1; diff --git a/src/gui/components/filebrowser/juce_FileSearchPathListComponent.cpp b/src/gui/components/filebrowser/juce_FileSearchPathListComponent.cpp index 52be811e06..abfff966ec 100644 --- a/src/gui/components/filebrowser/juce_FileSearchPathListComponent.cpp +++ b/src/gui/components/filebrowser/juce_FileSearchPathListComponent.cpp @@ -31,8 +31,6 @@ BEGIN_JUCE_NAMESPACE #include "../lookandfeel/juce_LookAndFeel.h" #include "../filebrowser/juce_FileChooser.h" #include "../../../text/juce_LocalisedStrings.h" -#include "../buttons/juce_TextButton.h" -#include "../buttons/juce_DrawableButton.h" #include "../../graphics/drawables/juce_DrawablePath.h" @@ -65,7 +63,7 @@ FileSearchPathListComponent::FileSearchPathListComponent() arrowImage.setFill (Colours::black.withAlpha (0.4f)); arrowImage.setPath (arrowPath); - ((DrawableButton*) upButton)->setImages (&arrowImage); + upButton->setImages (&arrowImage); } addAndMakeVisible (downButton = new DrawableButton (String::empty, DrawableButton::ImageOnButtonBackground)); @@ -78,7 +76,7 @@ FileSearchPathListComponent::FileSearchPathListComponent() arrowImage.setFill (Colours::black.withAlpha (0.4f)); arrowImage.setPath (arrowPath); - ((DrawableButton*) downButton)->setImages (&arrowImage); + downButton->setImages (&arrowImage); } updateButtons(); @@ -187,7 +185,7 @@ void FileSearchPathListComponent::resized() addButton->setBounds (2, buttonY, buttonH, buttonH); removeButton->setBounds (addButton->getRight(), buttonY, buttonH, buttonH); - ((TextButton*) changeButton)->changeWidthToFitText (buttonH); + changeButton->changeWidthToFitText (buttonH); downButton->setSize (buttonH * 2, buttonH); upButton->setSize (buttonH * 2, buttonH); diff --git a/src/gui/components/filebrowser/juce_FileSearchPathListComponent.h b/src/gui/components/filebrowser/juce_FileSearchPathListComponent.h index dca10ad283..15df28d414 100644 --- a/src/gui/components/filebrowser/juce_FileSearchPathListComponent.h +++ b/src/gui/components/filebrowser/juce_FileSearchPathListComponent.h @@ -27,7 +27,8 @@ #define __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__ #include "../controls/juce_ListBox.h" -#include "../buttons/juce_Button.h" +#include "../buttons/juce_DrawableButton.h" +#include "../buttons/juce_TextButton.h" #include "../mouse/juce_FileDragAndDropTarget.h" #include "../../../io/files/juce_FileSearchPath.h" @@ -116,9 +117,9 @@ private: ListBox* listBox; Button* addButton; Button* removeButton; - Button* changeButton; - Button* upButton; - Button* downButton; + TextButton* changeButton; + DrawableButton* upButton; + DrawableButton* downButton; void changed(); void updateButtons(); diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index cd1620c8de..19e230fc74 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -1331,7 +1331,7 @@ int Component::runModalLoop() // use a callback so this can be called from non-gui threads return (int) (pointer_sized_int) MessageManager::getInstance() - ->callFunctionOnMessageThread (&runModalLoopCallback, (void*) this); + ->callFunctionOnMessageThread (&runModalLoopCallback, this); } SafePointer prevFocused (getCurrentlyFocusedComponent()); diff --git a/src/gui/components/layout/juce_ScrollBar.cpp b/src/gui/components/layout/juce_ScrollBar.cpp index a2fb1c0e14..a0bc26eb9e 100644 --- a/src/gui/components/layout/juce_ScrollBar.cpp +++ b/src/gui/components/layout/juce_ScrollBar.cpp @@ -33,7 +33,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -class ScrollbarButton : public Button +class ScrollBar::ScrollbarButton : public Button { public: int direction; @@ -246,8 +246,8 @@ void ScrollBar::setOrientation (const bool shouldBeVertical) if (upButton != 0) { - ((ScrollbarButton*) upButton)->direction = (vertical) ? 0 : 3; - ((ScrollbarButton*) downButton)->direction = (vertical) ? 2 : 1; + upButton->direction = vertical ? 0 : 3; + downButton->direction = vertical ? 2 : 1; } updateThumbPosition(); @@ -256,13 +256,15 @@ void ScrollBar::setOrientation (const bool shouldBeVertical) void ScrollBar::setButtonVisibility (const bool buttonsAreVisible) { - deleteAndZero (upButton); - deleteAndZero (downButton); + delete upButton; + upButton = 0; + delete downButton; + downButton = 0; if (buttonsAreVisible) { - addAndMakeVisible (upButton = new ScrollbarButton ((vertical) ? 0 : 3, *this)); - addAndMakeVisible (downButton = new ScrollbarButton ((vertical) ? 2 : 1, *this)); + addAndMakeVisible (upButton = new ScrollbarButton (vertical ? 0 : 3, *this)); + addAndMakeVisible (downButton = new ScrollbarButton (vertical ? 2 : 1, *this)); setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs); } diff --git a/src/gui/components/layout/juce_ScrollBar.h b/src/gui/components/layout/juce_ScrollBar.h index 4c26445f34..408a329b47 100644 --- a/src/gui/components/layout/juce_ScrollBar.h +++ b/src/gui/components/layout/juce_ScrollBar.h @@ -316,8 +316,9 @@ private: int dragStartMousePos, lastMousePos; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; bool vertical, isDraggingThumb, alwaysVisible; - Button* upButton; - Button* downButton; + class ScrollbarButton; + ScrollbarButton* upButton; + ScrollbarButton* downButton; ListenerList listeners; void updateThumbPosition(); diff --git a/src/gui/components/menus/juce_PopupMenu.cpp b/src/gui/components/menus/juce_PopupMenu.cpp index a9d7c23041..d60afca556 100644 --- a/src/gui/components/menus/juce_PopupMenu.cpp +++ b/src/gui/components/menus/juce_PopupMenu.cpp @@ -968,7 +968,7 @@ private: for (int i = getNumChildComponents(); --i >= 0;) { - PopupMenu::ItemComponent* const m = (PopupMenu::ItemComponent*) getChildComponent (i); + PopupMenu::ItemComponent* const m = static_cast (getChildComponent (i)); if (m != 0 && m->itemInfo.itemId == itemId diff --git a/src/gui/components/mouse/juce_MouseCursor.cpp b/src/gui/components/mouse/juce_MouseCursor.cpp index 924b425f7a..fe6954bacd 100644 --- a/src/gui/components/mouse/juce_MouseCursor.cpp +++ b/src/gui/components/mouse/juce_MouseCursor.cpp @@ -77,7 +77,7 @@ public: { for (int i = activeCursors.size(); --i >= 0;) { - SharedMouseCursorInternal* const r = (SharedMouseCursorInternal*) activeCursors.getUnchecked(i); + SharedMouseCursorInternal* const r = static_cast (activeCursors.getUnchecked(i)); if (r->standardType == type) return r; diff --git a/src/gui/components/properties/juce_PropertyPanel.cpp b/src/gui/components/properties/juce_PropertyPanel.cpp index ac3b3e0ab7..ded38378f0 100644 --- a/src/gui/components/properties/juce_PropertyPanel.cpp +++ b/src/gui/components/properties/juce_PropertyPanel.cpp @@ -33,7 +33,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -class PropertyHolderComponent : public Component +class PropertyPanel::PropertyHolderComponent : public Component { public: PropertyHolderComponent() @@ -49,9 +49,12 @@ public: { } - void updateLayout (const int width); - + void updateLayout (int width); void refreshAll() const; + +private: + PropertyHolderComponent (const PropertyHolderComponent&); + PropertyHolderComponent& operator= (const PropertyHolderComponent&); }; //============================================================================== @@ -180,9 +183,12 @@ public: private: int titleHeight; bool isOpen_; + + PropertySectionComponent (const PropertySectionComponent&); + PropertySectionComponent& operator= (const PropertySectionComponent&); }; -void PropertyHolderComponent::updateLayout (const int width) +void PropertyPanel::PropertyHolderComponent::updateLayout (const int width) { int y = 0; @@ -203,7 +209,7 @@ void PropertyHolderComponent::updateLayout (const int width) repaint(); } -void PropertyHolderComponent::refreshAll() const +void PropertyPanel::PropertyHolderComponent::refreshAll() const { for (int i = getNumChildComponents(); --i >= 0;) { @@ -289,19 +295,19 @@ void PropertyPanel::addSection (const String& sectionTitle, void PropertyPanel::updatePropHolderLayout() const { const int maxWidth = viewport->getMaximumVisibleWidth(); - ((PropertyHolderComponent*) propertyHolderComponent)->updateLayout (maxWidth); + propertyHolderComponent->updateLayout (maxWidth); const int newMaxWidth = viewport->getMaximumVisibleWidth(); if (maxWidth != newMaxWidth) { // need to do this twice because of scrollbars changing the size, etc. - ((PropertyHolderComponent*) propertyHolderComponent)->updateLayout (newMaxWidth); + propertyHolderComponent->updateLayout (newMaxWidth); } } void PropertyPanel::refreshAll() const { - ((PropertyHolderComponent*) propertyHolderComponent)->refreshAll(); + propertyHolderComponent->refreshAll(); } //============================================================================== diff --git a/src/gui/components/properties/juce_PropertyPanel.h b/src/gui/components/properties/juce_PropertyPanel.h index 3ec75d591b..12724f98fe 100644 --- a/src/gui/components/properties/juce_PropertyPanel.h +++ b/src/gui/components/properties/juce_PropertyPanel.h @@ -153,7 +153,8 @@ public: private: Viewport* viewport; - Component* propertyHolderComponent; + class PropertyHolderComponent; + PropertyHolderComponent* propertyHolderComponent; String messageWhenEmpty; void updatePropHolderLayout() const; diff --git a/src/gui/components/special/juce_ColourSelector.cpp b/src/gui/components/special/juce_ColourSelector.cpp index 608a10909f..68252779ea 100644 --- a/src/gui/components/special/juce_ColourSelector.cpp +++ b/src/gui/components/special/juce_ColourSelector.cpp @@ -92,16 +92,8 @@ private: }; //============================================================================== -class ColourSpaceView : public Component +class ColourSelector::ColourSpaceView : public Component { - ColourSelector* const owner; - float& h; - float& s; - float& v; - float lastHue; - ColourSpaceMarker* marker; - const int edge; - public: ColourSpaceView (ColourSelector* owner_, float& h_, float& s_, float& v_, @@ -182,6 +174,14 @@ public: } private: + ColourSelector* const owner; + float& h; + float& s; + float& v; + float lastHue; + ColourSpaceMarker* marker; + const int edge; + ScopedPointer colours; void updateMarker() const throw() @@ -232,7 +232,7 @@ private: }; //============================================================================== -class HueSelectorComp : public Component +class ColourSelector::HueSelectorComp : public Component { public: HueSelectorComp (ColourSelector* owner_, @@ -469,8 +469,8 @@ void ColourSelector::update() if (colourSpace != 0) { - ((ColourSpaceView*) colourSpace)->updateIfNeeded(); - ((HueSelectorComp*) hueSelector)->updateIfNeeded(); + colourSpace->updateIfNeeded(); + hueSelector->updateIfNeeded(); } if ((flags & showColourAtTop) != 0) diff --git a/src/gui/components/special/juce_ColourSelector.h b/src/gui/components/special/juce_ColourSelector.h index db76633e0b..86e0cfcce8 100644 --- a/src/gui/components/special/juce_ColourSelector.h +++ b/src/gui/components/special/juce_ColourSelector.h @@ -136,14 +136,17 @@ public: juce_UseDebuggingNewOperator private: + class ColourSpaceView; + class HueSelectorComp; + class SwatchComponent; friend class ColourSpaceView; friend class HueSelectorComp; + Colour colour; float h, s, v; Slider* sliders[4]; - Component* colourSpace; - Component* hueSelector; - class SwatchComponent; + ColourSpaceView* colourSpace; + HueSelectorComp* hueSelector; OwnedArray swatchComponents; const int flags; int topSpace, edgeGap; diff --git a/src/gui/components/windows/juce_ResizableWindow.cpp b/src/gui/components/windows/juce_ResizableWindow.cpp index e4e2a6717c..3a7daff251 100644 --- a/src/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/gui/components/windows/juce_ResizableWindow.cpp @@ -103,7 +103,7 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent, { resizeToFitContent = resizeToFit; - if (newContentComponent != (Component*) contentComponent) + if (newContentComponent != static_cast (contentComponent)) { if (! deleteOldOne) removeChildComponent (contentComponent.release()); diff --git a/src/gui/components/windows/juce_TopLevelWindow.cpp b/src/gui/components/windows/juce_TopLevelWindow.cpp index 19f7592f4f..bd7fa2e48f 100644 --- a/src/gui/components/windows/juce_TopLevelWindow.cpp +++ b/src/gui/components/windows/juce_TopLevelWindow.cpp @@ -319,7 +319,7 @@ int TopLevelWindow::getNumTopLevelWindows() throw() TopLevelWindow* TopLevelWindow::getTopLevelWindow (const int index) throw() { - return (TopLevelWindow*) TopLevelWindowManager::getInstance()->windows [index]; + return static_cast (TopLevelWindowManager::getInstance()->windows [index]); } TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow() throw() diff --git a/src/gui/graphics/drawables/juce_SVGParser.cpp b/src/gui/graphics/drawables/juce_SVGParser.cpp index 9dd18c1a22..14a5486869 100644 --- a/src/gui/graphics/drawables/juce_SVGParser.cpp +++ b/src/gui/graphics/drawables/juce_SVGParser.cpp @@ -1034,7 +1034,7 @@ private: //============================================================================== static bool parseNextNumber (const String& source, String& value, int& index, const bool allowUnits) { - const tchar* const s = (const tchar*) source; + const juce_wchar* const s = source; while (CharacterFunctions::isWhitespace (s[index]) || s[index] == ',') ++index; diff --git a/src/gui/graphics/fonts/juce_GlyphArrangement.cpp b/src/gui/graphics/fonts/juce_GlyphArrangement.cpp index 59bb4dff96..a46693cd2a 100644 --- a/src/gui/graphics/fonts/juce_GlyphArrangement.cpp +++ b/src/gui/graphics/fonts/juce_GlyphArrangement.cpp @@ -200,7 +200,7 @@ void GlyphArrangement::addCurtailedLineOfText (const Font& font, font.getGlyphPositions (text, newGlyphs, xOffsets); const int textLen = newGlyphs.size(); - const juce_wchar* const unicodeText = (const juce_wchar*) text; + const juce_wchar* const unicodeText = text; for (int i = 0; i < textLen; ++i) { diff --git a/src/gui/graphics/fonts/juce_Typeface.cpp b/src/gui/graphics/fonts/juce_Typeface.cpp index d9cf68e545..a649986a54 100644 --- a/src/gui/graphics/fonts/juce_Typeface.cpp +++ b/src/gui/graphics/fonts/juce_Typeface.cpp @@ -326,7 +326,7 @@ float CustomTypeface::getDescent() const float CustomTypeface::getStringWidth (const String& text) { float x = 0; - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; while (*t != 0) { @@ -343,7 +343,7 @@ void CustomTypeface::getGlyphPositions (const String& text, Array & resultG { xOffsets.add (0); float x = 0; - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; while (*t != 0) { diff --git a/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp index 053b22d1a9..757b9f5129 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp @@ -114,12 +114,12 @@ GIFLoader::~GIFLoader() bool GIFLoader::getSizeFromHeader (int& w, int& h) { - unsigned char b [8]; + char b[8]; if (input.read (b, 6) == 6) { - if ((strncmp ("GIF87a", (char*) b, 6) == 0) - || (strncmp ("GIF89a", (char*) b, 6) == 0)) + if ((strncmp ("GIF87a", b, 6) == 0) + || (strncmp ("GIF89a", b, 6) == 0)) { if (input.read (b, 4) == 4) { diff --git a/src/io/files/juce_ZipFile.cpp b/src/io/files/juce_ZipFile.cpp index f73f5ed9cf..0188a01243 100644 --- a/src/io/files/juce_ZipFile.cpp +++ b/src/io/files/juce_ZipFile.cpp @@ -213,10 +213,9 @@ int ZipFile::getNumEntries() const throw() const ZipFile::ZipEntry* ZipFile::getEntry (const int index) const throw() { - ZipEntryInfo* const zei = (ZipEntryInfo*) entries [index]; + ZipEntryInfo* const zei = entries [index]; - return (zei != 0) ? &(zei->entry) - : 0; + return zei != 0 ? &(zei->entry) : 0; } int ZipFile::getIndexOfFileName (const String& fileName) const throw() @@ -303,7 +302,7 @@ void ZipFile::init() if (pos + 46 > size) break; - const char* const buffer = ((const char*) headerData.getData()) + pos; + const char* const buffer = static_cast (headerData.getData()) + pos; const int fileNameLen = ByteOrder::littleEndianShort (buffer + 28); diff --git a/src/io/streams/juce_BufferedInputStream.cpp b/src/io/streams/juce_BufferedInputStream.cpp index 7ce791a90d..323477caca 100644 --- a/src/io/streams/juce_BufferedInputStream.cpp +++ b/src/io/streams/juce_BufferedInputStream.cpp @@ -140,7 +140,7 @@ int BufferedInputStream::read (void* destBuffer, int maxBytesToRead) maxBytesToRead -= bytesAvailable; bytesRead += bytesAvailable; position += bytesAvailable; - destBuffer = (void*) (((char*) destBuffer) + bytesAvailable); + destBuffer = static_cast (destBuffer) + bytesAvailable; } const int64 oldLastReadPos = lastReadPos; diff --git a/src/io/streams/juce_GZIPCompressorOutputStream.cpp b/src/io/streams/juce_GZIPCompressorOutputStream.cpp index de44e50c4a..b331a1ff98 100644 --- a/src/io/streams/juce_GZIPCompressorOutputStream.cpp +++ b/src/io/streams/juce_GZIPCompressorOutputStream.cpp @@ -78,7 +78,7 @@ public: return dataSize <= 0; } - void setInput (uint8* const newData, const int size) throw() + void setInput (const uint8* const newData, const int size) throw() { data = newData; dataSize = size; @@ -89,7 +89,7 @@ public: using namespace zlibNamespace; if (streamIsValid) { - stream.next_in = data; + stream.next_in = const_cast (data); stream.next_out = dest; stream.avail_in = dataSize; stream.avail_out = destSize; @@ -120,7 +120,7 @@ public: private: zlibNamespace::z_stream stream; - uint8* data; + const uint8* data; int dataSize, compLevel, strategy; bool setParams, streamIsValid; @@ -169,7 +169,7 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) { if (! helper->finished) { - helper->setInput ((uint8*) destBuffer, howMany); + helper->setInput (static_cast (destBuffer), howMany); while (! helper->needsInput()) { diff --git a/src/io/streams/juce_GZIPDecompressorInputStream.cpp b/src/io/streams/juce_GZIPDecompressorInputStream.cpp index fd2bb6c35b..fba6335c3d 100644 --- a/src/io/streams/juce_GZIPDecompressorInputStream.cpp +++ b/src/io/streams/juce_GZIPDecompressorInputStream.cpp @@ -196,7 +196,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) if (destBuffer != 0) { int numRead = 0; - uint8* d = (uint8*) destBuffer; + uint8* d = static_cast (destBuffer); while (! helper->error) { @@ -217,7 +217,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) if (activeBufferSize > 0) { - helper->setInput ((uint8*) buffer, activeBufferSize); + helper->setInput (buffer, activeBufferSize); } else { diff --git a/src/io/streams/juce_OutputStream.cpp b/src/io/streams/juce_OutputStream.cpp index 4b0f25c131..7dabd94954 100644 --- a/src/io/streams/juce_OutputStream.cpp +++ b/src/io/streams/juce_OutputStream.cpp @@ -183,7 +183,7 @@ void OutputStream::writeText (const String& text, const bool asUnicode, if (writeUnicodeHeaderBytes) write ("\x0ff\x0fe", 2); - const juce_wchar* src = (const juce_wchar*) text; + const juce_wchar* src = text; bool lastCharWasReturn = false; while (*src != 0) diff --git a/src/native/linux/juce_linux_Audio.cpp b/src/native/linux/juce_linux_Audio.cpp index ac6aa44039..18ce9ea280 100644 --- a/src/native/linux/juce_linux_Audio.cpp +++ b/src/native/linux/juce_linux_Audio.cpp @@ -239,7 +239,7 @@ public: AudioDataConverters::interleaveSamples ((const float**) data, interleaved, numSamples, numChannelsRunning); AudioDataConverters::convertFloatToFormat (sampleFormat, interleaved, interleaved, numSamples * numChannelsRunning); - snd_pcm_sframes_t num = snd_pcm_writei (handle, (void*) interleaved, numSamples); + snd_pcm_sframes_t num = snd_pcm_writei (handle, interleaved, numSamples); if (failed (num) && num != -EPIPE && num != -ESTRPIPE) return false; @@ -274,7 +274,7 @@ public: scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); float* interleaved = static_cast (scratch.getData()); - snd_pcm_sframes_t num = snd_pcm_readi (handle, (void*) interleaved, numSamples); + snd_pcm_sframes_t num = snd_pcm_readi (handle, interleaved, numSamples); if (failed (num)) { diff --git a/src/native/linux/juce_linux_Network.cpp b/src/native/linux/juce_linux_Network.cpp index fb0f0b1d67..40f2f10158 100644 --- a/src/native/linux/juce_linux_Network.cpp +++ b/src/native/linux/juce_linux_Network.cpp @@ -150,7 +150,7 @@ public: struct sockaddr_in address; zerostruct (address); - memcpy ((void*) &address.sin_addr, (const void*) host->h_addr, host->h_length); + memcpy (&address.sin_addr, host->h_addr, host->h_length); address.sin_family = host->h_addrtype; address.sin_port = htons (port); diff --git a/src/native/linux/juce_linux_Threads.cpp b/src/native/linux/juce_linux_Threads.cpp index 9e36d293cb..bea32d3a6e 100644 --- a/src/native/linux/juce_linux_Threads.cpp +++ b/src/native/linux/juce_linux_Threads.cpp @@ -51,7 +51,7 @@ void* juce_createThread (void* userData) if (pthread_create (&handle, 0, threadEntryProc, userData) == 0) { pthread_detach (handle); - return (void*)handle; + return (void*) handle; } return 0; diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index c0bd2bbbd4..39e84c153f 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -1246,7 +1246,7 @@ public: ::setlocale (LC_ALL, oldLocale); } - const juce_wchar unicodeChar = *(const juce_wchar*) String::fromUTF8 (utf8, sizeof (utf8) - 1); + const juce_wchar unicodeChar = String::fromUTF8 (utf8, sizeof (utf8) - 1) [0]; int keyCode = (int) unicodeChar; if (keyCode < 0x20) diff --git a/src/native/mac/juce_mac_CoreAudio.cpp b/src/native/mac/juce_mac_CoreAudio.cpp index b24dfb68b5..2198864288 100644 --- a/src/native/mac/juce_mac_CoreAudio.cpp +++ b/src/native/mac/juce_mac_CoreAudio.cpp @@ -345,7 +345,7 @@ public: AudioValueTranslation avt; char buffer[256]; - avt.mInputData = (void*) &(types[i]); + avt.mInputData = &(types[i]); avt.mInputDataSize = sizeof (UInt32); avt.mOutputData = buffer; avt.mOutputDataSize = 256; @@ -502,9 +502,9 @@ public: if (deviceID != 0) { #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - if (OK (AudioDeviceAddIOProc (deviceID, audioIOProc, (void*) this))) + if (OK (AudioDeviceAddIOProc (deviceID, audioIOProc, this))) #else - if (OK (AudioDeviceCreateIOProcID (deviceID, audioIOProc, (void*) this, &audioProcID))) + if (OK (AudioDeviceCreateIOProcID (deviceID, audioIOProc, this, &audioProcID))) #endif { if (OK (AudioDeviceStart (deviceID, audioIOProc))) diff --git a/src/native/mac/juce_mac_CoreGraphicsContext.mm b/src/native/mac/juce_mac_CoreGraphicsContext.mm index 38ebdd364a..1565a578b9 100644 --- a/src/native/mac/juce_mac_CoreGraphicsContext.mm +++ b/src/native/mac/juce_mac_CoreGraphicsContext.mm @@ -597,7 +597,7 @@ private: --numGradientLookupEntries; CGShadingRef result = 0; - CGFunctionRef function = CGFunctionCreate ((void*) this, 1, 0, 4, 0, &gradientCallbacks); + CGFunctionRef function = CGFunctionCreate (this, 1, 0, 4, 0, &gradientCallbacks); CGPoint p1 (CGPointMake (gradient.x1, gradient.y1)); if (gradient.isRadial) diff --git a/src/native/mac/juce_mac_CoreMidi.cpp b/src/native/mac/juce_mac_CoreMidi.cpp index 55b23c87bd..6a1c674920 100644 --- a/src/native/mac/juce_mac_CoreMidi.cpp +++ b/src/native/mac/juce_mac_CoreMidi.cpp @@ -274,7 +274,7 @@ MidiOutput* MidiOutput::openDevice (int index) if (OK (MIDIOutputPortCreate (globalMidiClient, pname, &port))) { mo = new MidiOutput(); - mo->internal = (void*) new MidiPortAndEndpoint (port, endPoint); + mo->internal = new MidiPortAndEndpoint (port, endPoint); } } @@ -297,7 +297,7 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) if (OK (MIDISourceCreate (globalMidiClient, name, &endPoint))) { mo = new MidiOutput(); - mo->internal = (void*) new MidiPortAndEndpoint (0, endPoint); + mo->internal = new MidiPortAndEndpoint (0, endPoint); } CFRelease (name); @@ -560,7 +560,7 @@ MidiInput* MidiInput::openDevice (int index, MidiInputCallback* callback) mi = new MidiInput (getDevices() [index]); mpc->input = mi; - mi->internal = (void*) mpc; + mi->internal = mpc; const ScopedLock sl (CoreMidiCallbacks::callbackLock); CoreMidiCallbacks::activeCallbacks.add (mpc.release()); @@ -600,7 +600,7 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba mi = new MidiInput (deviceName); mpc->input = mi; - mi->internal = (void*) mpc; + mi->internal = mpc; const ScopedLock sl (CoreMidiCallbacks::callbackLock); CoreMidiCallbacks::activeCallbacks.add (mpc.release()); diff --git a/src/native/mac/juce_mac_MouseCursor.mm b/src/native/mac/juce_mac_MouseCursor.mm index 13fbc22ca7..0882fdeeb2 100644 --- a/src/native/mac/juce_mac_MouseCursor.mm +++ b/src/native/mac/juce_mac_MouseCursor.mm @@ -39,7 +39,7 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot hotSpot: NSMakePoint (hotspotX, hotspotY)]; [im release]; - return (void*) c; + return c; } static void* juce_cursorFromData (const unsigned char* data, const size_t size, float hx, float hy) throw() @@ -135,7 +135,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro } [c retain]; - return (void*) c; + return c; } void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) throw() diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index f1979fc09d..b4f0141895 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -265,7 +265,7 @@ public: static ModifierKeys currentModifiers; static ComponentPeer* currentlyFocusedPeer; - static VoidArray keysCurrentlyDown; + static Array keysCurrentlyDown; }; //============================================================================== @@ -755,20 +755,20 @@ BEGIN_JUCE_NAMESPACE //============================================================================== ModifierKeys NSViewComponentPeer::currentModifiers; ComponentPeer* NSViewComponentPeer::currentlyFocusedPeer = 0; -VoidArray NSViewComponentPeer::keysCurrentlyDown; +Array NSViewComponentPeer::keysCurrentlyDown; //============================================================================== bool KeyPress::isKeyCurrentlyDown (const int keyCode) { - if (NSViewComponentPeer::keysCurrentlyDown.contains ((void*) keyCode)) + if (NSViewComponentPeer::keysCurrentlyDown.contains (keyCode)) return true; if (keyCode >= 'A' && keyCode <= 'Z' - && NSViewComponentPeer::keysCurrentlyDown.contains ((void*) (int) CharacterFunctions::toLowerCase ((tchar) keyCode))) + && NSViewComponentPeer::keysCurrentlyDown.contains ((int) CharacterFunctions::toLowerCase ((tchar) keyCode))) return true; if (keyCode >= 'a' && keyCode <= 'z' - && NSViewComponentPeer::keysCurrentlyDown.contains ((void*) (int) CharacterFunctions::toUpperCase ((tchar) keyCode))) + && NSViewComponentPeer::keysCurrentlyDown.contains ((int) CharacterFunctions::toUpperCase ((tchar) keyCode))) return true; return false; @@ -794,9 +794,9 @@ void NSViewComponentPeer::updateKeysDown (NSEvent* ev, bool isKeyDown) if (keyCode != 0) { if (isKeyDown) - keysCurrentlyDown.addIfNotAlreadyThere ((void*) keyCode); + keysCurrentlyDown.addIfNotAlreadyThere (keyCode); else - keysCurrentlyDown.removeValue ((void*) keyCode); + keysCurrentlyDown.removeValue (keyCode); } } diff --git a/src/native/mac/juce_mac_OpenGLComponent.mm b/src/native/mac/juce_mac_OpenGLComponent.mm index cbf542dbfb..e05e650171 100644 --- a/src/native/mac/juce_mac_OpenGLComponent.mm +++ b/src/native/mac/juce_mac_OpenGLComponent.mm @@ -398,7 +398,7 @@ public: } const OpenGLPixelFormat getPixelFormat() const { return pixelFormat; } - void* getRawContext() const throw() { return (void*) glLayer; } + void* getRawContext() const throw() { return glLayer; } void updateWindowPosition (int x, int y, int w, int h, int outerWindowHeight) { diff --git a/src/native/mac/juce_mac_Strings.mm b/src/native/mac/juce_mac_Strings.mm index 5897392d78..f30afec280 100644 --- a/src/native/mac/juce_mac_Strings.mm +++ b/src/native/mac/juce_mac_Strings.mm @@ -69,11 +69,10 @@ const String PlatformUtilities::cfStringToJuceString (CFStringRef cfString) CFStringRef PlatformUtilities::juceStringToCFString (const String& s) { const int len = s.length(); - const juce_wchar* t = (const juce_wchar*) s; HeapBlock temp (len + 2); for (int i = 0; i <= len; ++i) - temp[i] = t[i]; + temp[i] = s[i]; return CFStringCreateWithCharacters (kCFAllocatorDefault, temp, len); } @@ -122,7 +121,7 @@ const String PlatformUtilities::convertToPrecomposedUnicode (const String& s) { result.preallocateStorage (bytesRead / sizeof (UniChar) + 2); - tchar* t = const_cast ((const tchar*) result); + tchar* t = result; unsigned int i; for (i = 0; i < bytesRead / sizeof (UniChar); ++i) diff --git a/src/native/windows/juce_win32_AudioCDReader.cpp b/src/native/windows/juce_win32_AudioCDReader.cpp index 6753499856..8aa8a63c0b 100644 --- a/src/native/windows/juce_win32_AudioCDReader.cpp +++ b/src/native/windows/juce_win32_AudioCDReader.cpp @@ -1066,7 +1066,7 @@ void CDController::prepare (SRB_ExecSCSICmd& s) void CDController::perform (SRB_ExecSCSICmd& s) { HANDLE event = CreateEvent (0, TRUE, FALSE, 0); - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; ResetEvent (event); @@ -1227,7 +1227,7 @@ bool CDDeviceHandle::readTOC (TOC* lpToc, bool useMSF) s.SRB_BufPointer = (BYTE*)lpToc; s.SRB_SenseLen = 0x0E; s.SRB_CDBLen = 0x0A; - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; s.CDBByte[0] = 0x43; s.CDBByte[1] = (BYTE)(useMSF ? 0x02 : 0x00); s.CDBByte[7] = 0x03; @@ -1306,7 +1306,7 @@ void CDDeviceHandle::openDrawer (bool shouldBeOpen) s.CDBByte[4] = (BYTE)((shouldBeOpen) ? 2 : 3); HANDLE event = CreateEvent (0, TRUE, FALSE, 0); - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; ResetEvent (event); @@ -1388,7 +1388,7 @@ static void GetAspiDeviceInfo (CDDeviceInfo* dev, BYTE ha, BYTE tgt, BYTE lun) s.SRB_BufPointer = buffer; s.SRB_SenseLen = SENSE_LEN; s.SRB_CDBLen = 6; - s.SRB_PostProc = (void*)event; + s.SRB_PostProc = event; s.CDBByte[0] = SCSI_INQUIRY; s.CDBByte[4] = 100; diff --git a/src/native/windows/juce_win32_DynamicLibraryLoader.cpp b/src/native/windows/juce_win32_DynamicLibraryLoader.cpp index 315a3b3c89..45381d6a6e 100644 --- a/src/native/windows/juce_win32_DynamicLibraryLoader.cpp +++ b/src/native/windows/juce_win32_DynamicLibraryLoader.cpp @@ -43,7 +43,7 @@ DynamicLibraryLoader::~DynamicLibraryLoader() void* DynamicLibraryLoader::findProcAddress (const String& functionName) { - return (void*) GetProcAddress ((HMODULE) libHandle, functionName.toCString()); + return GetProcAddress ((HMODULE) libHandle, functionName.toCString()); } diff --git a/src/native/windows/juce_win32_Files.cpp b/src/native/windows/juce_win32_Files.cpp index 2866aa62a7..0e3587c50f 100644 --- a/src/native/windows/juce_win32_Files.cpp +++ b/src/native/windows/juce_win32_Files.cpp @@ -163,7 +163,7 @@ void* juce_fileOpen (const String& fileName, bool forWriting) h = 0; } - return (void*) h; + return h; } void juce_fileClose (void* handle) diff --git a/src/native/windows/juce_win32_Messaging.cpp b/src/native/windows/juce_win32_Messaging.cpp index 4b1b78a564..2fff02114f 100644 --- a/src/native/windows/juce_win32_Messaging.cpp +++ b/src/native/windows/juce_win32_Messaging.cpp @@ -228,7 +228,7 @@ void MessageManager::broadcastMessage (const String& value) throw() COPYDATASTRUCT data; data.dwData = broadcastId; data.cbData = (localCopy.length() + 1) * sizeof (juce_wchar); - data.lpData = (void*) (const juce_wchar*) localCopy; + data.lpData = (void*) static_cast (localCopy); for (int i = windows.size(); --i >= 0;) { diff --git a/src/native/windows/juce_win32_Midi.cpp b/src/native/windows/juce_win32_Midi.cpp index 00a6529f70..f32e046934 100644 --- a/src/native/windows/juce_win32_Midi.cpp +++ b/src/native/windows/juce_win32_Midi.cpp @@ -378,7 +378,7 @@ MidiInput* MidiInput::openDevice (const int index, MidiInputCallback* const call if (err == MMSYSERR_NOERROR) { thread->hIn = h; - in->internal = (void*) thread.release(); + in->internal = thread.release(); return in.release(); } @@ -498,7 +498,7 @@ MidiOutput* MidiOutput::openDevice (int index) han->refCount++; MidiOutput* const out = new MidiOutput(); - out->internal = (void*) han; + out->internal = han; return out; } } @@ -517,7 +517,7 @@ MidiOutput* MidiOutput::openDevice (int index) MidiOutHandle::activeHandles.add (han); MidiOutput* const out = new MidiOutput(); - out->internal = (void*) han; + out->internal = han; return out; } else if (res == MMSYSERR_ALLOCATED) diff --git a/src/native/windows/juce_win32_Misc.cpp b/src/native/windows/juce_win32_Misc.cpp index 1b7cde6547..4577d1e351 100644 --- a/src/native/windows/juce_win32_Misc.cpp +++ b/src/native/windows/juce_win32_Misc.cpp @@ -44,7 +44,7 @@ void SystemClipboard::copyTextToClipboard (const String& text) if (bufH != 0) { - WCHAR* const data = (WCHAR*) GlobalLock (bufH); + WCHAR* const data = static_cast (GlobalLock (bufH)); text.copyToUnicode (data, len); GlobalUnlock (bufH); diff --git a/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp b/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp index 5735ecda48..f74681f87c 100644 --- a/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp +++ b/src/native/windows/juce_win32_QuickTimeMovieComponent.cpp @@ -335,7 +335,7 @@ static Handle createHandleDataRef (Handle dataHandle, const char* fileName) static CFStringRef juceStringToCFString (const String& s) { const int len = s.length(); - const juce_wchar* const t = (const juce_wchar*) s; + const juce_wchar* const t = s; HeapBlock temp (len + 2); for (int i = 0; i <= len; ++i) @@ -390,7 +390,7 @@ bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle props[prop].propClass = kQTPropertyClass_DataLocation; props[prop].propID = kQTDataLocationPropertyID_DataReference; props[prop].propValueSize = sizeof (dr); - props[prop].propValueAddress = (void*) &dr; + props[prop].propValueAddress = &dr; ++prop; FileInputStream* const fin = dynamic_cast (input); diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 7c23a6ad62..6fcae38941 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -332,7 +332,7 @@ void PlatformUtilities::freeDynamicLibrary (void* h) void* PlatformUtilities::getProcedureEntryPoint (void* h, const String& name) { - return (h != 0) ? (void*) GetProcAddress ((HMODULE) h, name.toCString()) : 0; + return (h != 0) ? GetProcAddress ((HMODULE) h, name.toCString()) : 0; } diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 207d7cf1ef..d154b50080 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -381,7 +381,7 @@ public: taskBarIcon (0), dropTarget (0) { - callFunctionIfNotLocked (&createWindowCallback, (void*) this); + callFunctionIfNotLocked (&createWindowCallback, this); setTitle (component->getName()); @@ -423,7 +423,7 @@ public: //============================================================================== void* getNativeHandle() const { - return (void*) hwnd; + return hwnd; } void setVisible (bool shouldBeVisible) @@ -646,9 +646,7 @@ public: const bool oldDeactivate = shouldDeactivateTitleBar; shouldDeactivateTitleBar = ((styleFlags & windowIsTemporary) == 0); - callFunctionIfNotLocked (makeActive ? &toFrontCallback1 - : &toFrontCallback2, - (void*) hwnd); + callFunctionIfNotLocked (makeActive ? &toFrontCallback1 : &toFrontCallback2, hwnd); shouldDeactivateTitleBar = oldDeactivate; @@ -690,7 +688,7 @@ public: const bool oldDeactivate = shouldDeactivateTitleBar; shouldDeactivateTitleBar = ((styleFlags & windowIsTemporary) == 0); - callFunctionIfNotLocked (&setFocusCallback, (void*) hwnd); + callFunctionIfNotLocked (&setFocusCallback, hwnd); shouldDeactivateTitleBar = oldDeactivate; } @@ -940,7 +938,7 @@ private: //============================================================================== static void* createWindowCallback (void* userData) { - ((Win32ComponentPeer*) userData)->createWindow(); + static_cast (userData)->createWindow(); return 0; } @@ -1042,7 +1040,7 @@ private: static void* getFocusCallback (void*) { - return (void*) GetFocus(); + return GetFocus(); } void offsetWithinParent (int& x, int& y) const @@ -2536,7 +2534,7 @@ void* juce_createMouseCursorFromImage (const Image& image, int hotspotX, int hot if (os == SystemStats::WinXP) { - cursorH = (void*) createHICONFromImage (*im, FALSE, hotspotX, hotspotY); + cursorH = createHICONFromImage (*im, FALSE, hotspotX, hotspotY); } else { @@ -2659,7 +2657,7 @@ void* juce_createStandardMouseCursor (MouseCursor::StandardCursorType type) thro if (cursorH == 0) cursorH = LoadCursor (0, IDC_ARROW); - return (void*) cursorH; + return cursorH; } //============================================================================== @@ -2999,9 +2997,9 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text) const int numChars = text.length(); medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, (numChars + 2) * sizeof (WCHAR)); - char* d = (char*) GlobalLock (medium.hGlobal); + WCHAR* const data = static_cast (GlobalLock (medium.hGlobal)); - text.copyToUnicode ((WCHAR*) d, numChars + 1); + text.copyToUnicode (data, numChars + 1); format.cfFormat = CF_UNICODETEXT; GlobalUnlock (medium.hGlobal); diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index 3414b4dbf1..fa338ddcd0 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -630,13 +630,13 @@ String& String::operator+= (const String& other) String& String::operator+= (const char ch) { const juce_wchar asString[] = { (juce_wchar) ch, 0 }; - return operator+= ((const juce_wchar*) asString); + return operator+= (static_cast (asString)); } String& String::operator+= (const juce_wchar ch) { const juce_wchar asString[] = { (juce_wchar) ch, 0 }; - return operator+= ((const juce_wchar*) asString); + return operator+= (static_cast (asString)); } String& String::operator+= (const int number) @@ -1884,7 +1884,7 @@ int64 String::getHexValue64() const throw() //============================================================================== const String String::createStringFromData (const void* const data_, const int size) { - const char* const data = (const char*) data_; + const char* const data = static_cast (data_); if (size <= 0 || data == 0) { @@ -1905,7 +1905,7 @@ const String String::createStringFromData (const void* const data_, const int si result.preallocateStorage (numChars + 2); const uint16* const src = (const uint16*) (data + 2); - juce_wchar* const dst = const_cast ((const juce_wchar*) result); + juce_wchar* const dst = const_cast (static_cast (result)); if (bigEndian) { @@ -2190,7 +2190,7 @@ void String::Concatenator::append (const String& s) if (len > 0) { result.preallocateStorage (nextIndex + len); - s.copyToUnicode (((juce_wchar*) result) + nextIndex, len); + s.copyToUnicode (static_cast (result) + nextIndex, len); nextIndex += len; } } diff --git a/src/text/juce_StringArray.cpp b/src/text/juce_StringArray.cpp index 596fecca7a..39c37cc267 100644 --- a/src/text/juce_StringArray.cpp +++ b/src/text/juce_StringArray.cpp @@ -307,7 +307,7 @@ const String StringArray::joinIntoString (const String& separator, int start, in String result; result.preallocateStorage (charsNeeded); - juce_wchar* dest = (juce_wchar*) result; + juce_wchar* dest = result; while (start < last) { diff --git a/src/text/juce_XmlDocument.cpp b/src/text/juce_XmlDocument.cpp index 49ebd580e3..ea4728e5f0 100644 --- a/src/text/juce_XmlDocument.cpp +++ b/src/text/juce_XmlDocument.cpp @@ -87,11 +87,11 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle && ((data[0] == (char)-2 && data[1] == (char)-1) || (data[0] == (char)-1 && data[1] == (char)-2))) { - textToParse = String::createStringFromData ((const char*) data.getData(), (int) data.getSize()); + textToParse = String::createStringFromData (static_cast (data.getData()), (int) data.getSize()); } else { - textToParse = String::fromUTF8 ((const char*) data.getData(), (int) data.getSize()); + textToParse = String::fromUTF8 (static_cast (data.getData()), (int) data.getSize()); } if (! onlyReadOuterDocumentElement) diff --git a/src/text/juce_XmlElement.cpp b/src/text/juce_XmlElement.cpp index 259f6e37c2..d82db3c23d 100644 --- a/src/text/juce_XmlElement.cpp +++ b/src/text/juce_XmlElement.cpp @@ -198,7 +198,7 @@ namespace XmlOutputFunctions static void escapeIllegalXmlChars (OutputStream& outputStream, const String& text, const bool changeNewLines) { - const juce_wchar* t = (const juce_wchar*) text; + const juce_wchar* t = text; for (;;) { diff --git a/src/threads/juce_Thread.cpp b/src/threads/juce_Thread.cpp index adee333de5..af93862e03 100644 --- a/src/threads/juce_Thread.cpp +++ b/src/threads/juce_Thread.cpp @@ -85,7 +85,7 @@ void Thread::threadEntryPoint (Thread* const thread) // used to wrap the incoming call from the platform-specific code void JUCE_API juce_threadEntryPoint (void* userData) { - Thread::threadEntryPoint ((Thread*) userData); + Thread::threadEntryPoint (static_cast (userData)); } @@ -114,7 +114,7 @@ void Thread::startThread() if (threadHandle_ == 0) { - threadHandle_ = juce_createThread ((void*) this); + threadHandle_ = juce_createThread (this); juce_setThreadPriority (threadHandle_, threadPriority_); startSuspensionEvent_.signal(); } diff --git a/src/threads/juce_ThreadPool.cpp b/src/threads/juce_ThreadPool.cpp index ed3b4eaede..d8778bff1b 100644 --- a/src/threads/juce_ThreadPool.cpp +++ b/src/threads/juce_ThreadPool.cpp @@ -183,7 +183,7 @@ int ThreadPool::getNumJobs() const ThreadPoolJob* ThreadPool::getJob (const int index) const { const ScopedLock sl (lock); - return (ThreadPoolJob*) jobs [index]; + return jobs [index]; } bool ThreadPool::contains (const ThreadPoolJob* const job) const diff --git a/src/utilities/juce_DeletedAtShutdown.cpp b/src/utilities/juce_DeletedAtShutdown.cpp index 94de2752b1..20b2cdf408 100644 --- a/src/utilities/juce_DeletedAtShutdown.cpp +++ b/src/utilities/juce_DeletedAtShutdown.cpp @@ -65,7 +65,7 @@ void DeletedAtShutdown::deleteAll() { JUCE_TRY { - DeletedAtShutdown* deletee = (DeletedAtShutdown*) localCopy.getUnchecked(i); + DeletedAtShutdown* deletee = static_cast (localCopy.getUnchecked(i)); // double-check that it's not already been deleted during another object's destructor. {