1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-27 02:20:05 +00:00

Cleaned up some compiler warings in the demo. Minor Viewport tweak.

This commit is contained in:
Julian Storer 2010-06-11 13:08:10 +01:00
parent 97d26439c8
commit ffd93c0343
20 changed files with 112 additions and 80 deletions

View file

@ -58,7 +58,7 @@ public:
}
//==============================================================================
void initialise (const String& commandLine)
void initialise (const String& /*commandLine*/)
{
// just create the main window...
theMainWindow = new MainDemoWindow();
@ -105,7 +105,7 @@ public:
return true;
}
void anotherInstanceStarted (const String& commandLine)
void anotherInstanceStarted (const String& /*commandLine*/)
{
// This will get called if the user launches another copy of the app, but
// there's nothing that the demo app needs to do here.

View file

@ -112,8 +112,7 @@ public:
return StringArray ((const tchar**) names);
}
const PopupMenu getMenuForIndex (int menuIndex,
const String& menuName)
const PopupMenu getMenuForIndex (int menuIndex, const String& /*menuName*/)
{
ApplicationCommandManager* const commandManager = mainWindow->commandManager;
@ -168,8 +167,7 @@ public:
return menu;
}
void menuItemSelected (int menuItemID,
int topLevelMenuIndex)
void menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/)
{
// most of our menu items are invoked automatically as commands, but we can handle the
// other special cases here..
@ -377,7 +375,7 @@ public:
break;
case showWidgets:
showDemo (createWidgetsDemo (mainWindow->commandManager));
showDemo (createWidgetsDemo());
currentDemoId = showWidgets;
break;
@ -522,7 +520,7 @@ public:
{
}
void mouseDown (const MouseEvent& e)
void mouseDown (const MouseEvent&)
{
PopupMenu m;
m.addItem (1, T("Quit the Juce demo"));

View file

@ -61,7 +61,7 @@ public:
}
}
void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY)
void mouseWheelMove (const MouseEvent&, float wheelIncrementX, float wheelIncrementY)
{
if (thumbnail.getTotalLength() > 0)
{
@ -298,11 +298,11 @@ void AudioDemoPlaybackPage::selectionChanged()
thumbnail->setFile (fileTreeComp->getSelectedFile());
}
void AudioDemoPlaybackPage::fileClicked (const File& file, const MouseEvent& e)
void AudioDemoPlaybackPage::fileClicked (const File&, const MouseEvent&)
{
}
void AudioDemoPlaybackPage::fileDoubleClicked (const File& file)
void AudioDemoPlaybackPage::fileDoubleClicked (const File&)
{
}
//[/MiscUserCode]

View file

@ -37,8 +37,8 @@ public:
{
}
bool appliesToNote (const int midiNoteNumber) { return true; }
bool appliesToChannel (const int midiChannel) { return true; }
bool appliesToNote (const int /*midiNoteNumber*/) { return true; }
bool appliesToChannel (const int /*midiChannel*/) { return true; }
};
@ -60,7 +60,7 @@ public:
}
void startNote (const int midiNoteNumber, const float velocity,
SynthesiserSound* sound, const int currentPitchWheelPosition)
SynthesiserSound* /*sound*/, const int /*currentPitchWheelPosition*/)
{
currentAngle = 0.0;
level = velocity * 0.15;
@ -92,12 +92,12 @@ public:
}
}
void pitchWheelMoved (const int newValue)
void pitchWheelMoved (const int /*newValue*/)
{
// can't be bothered implementing this for the demo!
}
void controllerMoved (const int controllerNumber, const int newValue)
void controllerMoved (const int /*controllerNumber*/, const int /*newValue*/)
{
// not interested in controllers in this case.
}
@ -215,8 +215,7 @@ public:
delete audioReader;
}
void prepareToPlay (int samplesPerBlockExpected,
double sampleRate)
void prepareToPlay (int /*samplesPerBlockExpected*/, double sampleRate)
{
midiCollector.reset (sampleRate);

View file

@ -65,7 +65,7 @@ void LiveAudioInputDisplayComp::timerCallback()
repaint();
}
void LiveAudioInputDisplayComp::audioDeviceAboutToStart (AudioIODevice* device)
void LiveAudioInputDisplayComp::audioDeviceAboutToStart (AudioIODevice*)
{
zeromem (samples, sizeof (samples));
}

View file

@ -55,7 +55,7 @@ public:
deleteAllChildren();
}
void filenameComponentChanged (FilenameComponent* fileComponentThatHasChanged)
void filenameComponentChanged (FilenameComponent*)
{
File f (fileChooser->getCurrentFile());
editor->loadContent (f.loadFileAsString());

View file

@ -146,8 +146,7 @@ public:
}
//==============================================================================
bool isInterestedInDragSource (const String& sourceDescription,
Component* sourceComponent)
bool isInterestedInDragSource (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
{
// normally you'd check the sourceDescription value to see if it's the
// sort of object that you're interested in before returning true, but for
@ -155,30 +154,23 @@ public:
return true;
}
void itemDragEnter (const String& sourceDescription,
Component* sourceComponent,
int x, int y)
void itemDragEnter (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
{
somethingIsBeingDraggedOver = true;
repaint();
}
void itemDragMove (const String& sourceDescription,
Component* sourceComponent,
int x, int y)
void itemDragMove (const String& /*sourceDescription*/, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
{
}
void itemDragExit (const String& sourceDescription,
Component* sourceComponent)
void itemDragExit (const String& /*sourceDescription*/, Component* /*sourceComponent*/)
{
somethingIsBeingDraggedOver = false;
repaint();
}
void itemDropped (const String& sourceDescription,
Component* sourceComponent,
int x, int y)
void itemDropped (const String& sourceDescription, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
{
message = T("last rows dropped: ") + sourceDescription;

View file

@ -176,12 +176,12 @@ public:
textBox->applyFontToAllText (font);
}
void selectedRowsChanged (int lastRowselected)
void selectedRowsChanged (int /*lastRowselected*/)
{
updatePreviewBoxText();
}
void buttonClicked (Button* button)
void buttonClicked (Button*)
{
updatePreviewBoxText();
}

View file

@ -197,7 +197,7 @@ private:
transform);
}
void drawPaths (Graphics& g, bool solid, bool linearGradient, bool radialGradient)
void drawPaths (Graphics& g, bool /*solid*/, bool linearGradient, bool radialGradient)
{
Path p;
p.addRectangle (-50, 0, 100, 100);

View file

@ -84,7 +84,7 @@ public:
}
// This is overloaded from TableListBoxModel, and should fill in the background of the whole row
void paintRowBackground (Graphics& g, int rowNumber, int width, int height, bool rowIsSelected)
void paintRowBackground (Graphics& g, int /*rowNumber*/, int /*width*/, int /*height*/, bool rowIsSelected)
{
if (rowIsSelected)
g.fillAll (Colours::lightblue);
@ -96,7 +96,7 @@ public:
int rowNumber,
int columnId,
int width, int height,
bool rowIsSelected)
bool /*rowIsSelected*/)
{
g.setColour (Colours::black);
g.setFont (font);
@ -128,7 +128,7 @@ public:
}
// This is overloaded from TableListBoxModel, and must update any custom components that we're using
Component* refreshComponentForCell (int rowNumber, int columnId, bool isRowSelected,
Component* refreshComponentForCell (int rowNumber, int columnId, bool /*isRowSelected*/,
Component* existingComponentToUpdate)
{
if (columnId == 5) // If it's the ratings column, we'll return our custom component..
@ -180,12 +180,12 @@ public:
// A couple of quick methods to set and get the "rating" value when the user
// changes the combo box
int getRating (const int rowNumber, const int columnId) const
int getRating (const int rowNumber) const
{
return dataList->getChildElement (rowNumber)->getIntAttribute ("Rating");
}
void setRating (const int rowNumber, const int columnId, const int newRating)
void setRating (const int rowNumber, const int newRating)
{
dataList->getChildElement (rowNumber)->setAttribute ("Rating", newRating);
}
@ -249,12 +249,12 @@ private:
{
row = newRow;
columnId = newColumn;
comboBox->setSelectedId (owner.getRating (row, columnId), true);
comboBox->setSelectedId (owner.getRating (row), true);
}
void comboBoxChanged (ComboBox* comboBoxThatHasChanged)
void comboBoxChanged (ComboBox* /*comboBoxThatHasChanged*/)
{
owner.setRating (row, columnId, comboBox->getSelectedId());
owner.setRating (row, comboBox->getSelectedId());
}
private:

View file

@ -108,9 +108,9 @@ public:
forwardButton->setBounds (55, 10, 35, 25);
}
void textEditorTextChanged (TextEditor& editor) {}
void textEditorEscapeKeyPressed (TextEditor& editor) {}
void textEditorFocusLost (TextEditor& editor) {}
void textEditorTextChanged (TextEditor&) {}
void textEditorEscapeKeyPressed (TextEditor&) {}
void textEditorFocusLost (TextEditor&) {}
void textEditorReturnKeyPressed (TextEditor&)
{

View file

@ -82,7 +82,7 @@ public:
setTopLeftPosition ((int) x, (int) y);
}
bool hitTest (int x, int y)
bool hitTest (int /*x*/, int /*y*/)
{
return false;
}
@ -110,7 +110,7 @@ public:
deleteAllChildren();
}
void mouseDown (const MouseEvent& e)
void mouseDown (const MouseEvent&)
{
dragger.startDraggingComponent (this, 0);
}
@ -647,7 +647,7 @@ class ToolbarDemoComp : public Component,
public ButtonListener
{
public:
ToolbarDemoComp (ApplicationCommandManager* commandManager)
ToolbarDemoComp()
{
// Create and add the toolbar...
addAndMakeVisible (toolbar = new Toolbar());
@ -701,7 +701,7 @@ public:
toolbar->setBounds (0, 0, getWidth(), (int) depthSlider->getValue());
}
void sliderValueChanged (Slider* slider)
void sliderValueChanged (Slider*)
{
resized();
}
@ -883,8 +883,7 @@ private:
delete comboBox;
}
bool getToolbarItemSizes (int toolbarDepth,
bool isToolbarVertical,
bool getToolbarItemSizes (int /*toolbarDepth*/, bool isToolbarVertical,
int& preferredSize, int& minSize, int& maxSize)
{
if (isToolbarVertical)
@ -921,11 +920,11 @@ class DemoTabbedComponent : public TabbedComponent,
public ButtonListener
{
public:
DemoTabbedComponent (ApplicationCommandManager* commandManager)
DemoTabbedComponent()
: TabbedComponent (TabbedButtonBar::TabsAtTop)
{
addTab ("sliders", getRandomBrightColour(), createSlidersPage(), true);
addTab ("toolbars", getRandomBrightColour(), new ToolbarDemoComp (commandManager), true);
addTab ("toolbars", getRandomBrightColour(), new ToolbarDemoComp(), true);
addTab ("buttons", getRandomBrightColour(), new ButtonsPage (this), true);
addTab ("radio buttons", getRandomBrightColour(), createRadioButtonPage(), true);
addTab ("misc widgets", getRandomBrightColour(), createMiscPage(), true);
@ -1125,11 +1124,11 @@ class WidgetsDemo : public Component,
public:
//==============================================================================
WidgetsDemo (ApplicationCommandManager* commandManager)
WidgetsDemo()
{
setName ("Widgets");
addAndMakeVisible (tabs = new DemoTabbedComponent (commandManager));
addAndMakeVisible (tabs = new DemoTabbedComponent());
//==============================================================================
menuButton = new TextButton ("click for a popup menu..",
@ -1432,7 +1431,7 @@ public:
//==============================================================================
Component* createWidgetsDemo (ApplicationCommandManager* commandManager)
Component* createWidgetsDemo()
{
return new WidgetsDemo (commandManager);
return new WidgetsDemo();
}

View file

@ -36,7 +36,7 @@
// Pre-declare the functions that create each of the demo components..
Component* createFontsAndTextDemo();
Component* createRenderingDemo();
Component* createWidgetsDemo (ApplicationCommandManager* commandManager);
Component* createWidgetsDemo();
Component* createThreadingDemo();
Component* createTreeViewDemo();
Component* createTableDemo();

View file

@ -63367,7 +63367,13 @@ int Viewport::getMaximumVisibleHeight() const
void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset)
{
if (contentComp != 0)
contentComp->setTopLeftPosition (-xPixelsOffset, -yPixelsOffset);
contentComp->setTopLeftPosition (jmax (jmin (0, contentHolder.getWidth() - contentComp->getWidth()), jmin (0, -xPixelsOffset)),
jmax (jmin (0, contentHolder.getHeight() - contentComp->getHeight()), jmin (0, -yPixelsOffset)));
}
void Viewport::setViewPosition (const Point<int>& newPosition)
{
setViewPosition (newPosition.getX(), newPosition.getY());
}
void Viewport::setViewPositionProportionately (const double x, const double y)
@ -92784,20 +92790,20 @@ namespace RelativeCoordinateHelpers
}
};
static void skipWhitespace (const String& s, int& i)
static void skipWhitespace (const juce_wchar* const s, int& i)
{
while (CharacterFunctions::isWhitespace (s[i]))
++i;
}
static void skipComma (const String& s, int& i)
static void skipComma (const juce_wchar* const s, int& i)
{
skipWhitespace (s, i);
if (s[i] == ',')
++i;
}
static const String readAnchorName (const String& s, int& i)
static const String readAnchorName (const juce_wchar* const s, int& i)
{
skipWhitespace (s, i);
@ -92807,13 +92813,13 @@ namespace RelativeCoordinateHelpers
while (CharacterFunctions::isLetterOrDigit (s[i]) || s[i] == '_' || s[i] == '.')
++i;
return s.substring (start, i);
return String (s + start, i - start);
}
return String::empty;
}
static double readNumber (const String& s, int& i)
static double readNumber (const juce_wchar* const s, int& i)
{
skipWhitespace (s, i);
@ -92835,14 +92841,14 @@ namespace RelativeCoordinateHelpers
++i;
}
const double value = s.substring (start, i).getDoubleValue();
const double value = String (s + start, i - start).getDoubleValue();
while (CharacterFunctions::isWhitespace (s[i]) || s[i] == ',')
++i;
return value;
}
static const RelativeCoordinate readNextCoordinate (const String& s, int& i, const bool isHorizontal)
static const RelativeCoordinate readNextCoordinate (const juce_wchar* const s, int& i, const bool isHorizontal)
{
String anchor1 (readAnchorName (s, i));
double value = 0;

View file

@ -64,7 +64,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 17
#define JUCE_BUILDNUMBER 18
/** Current Juce version number.
@ -1103,7 +1103,11 @@ inline void swapVariables (Type& variable1, Type& variable2)
@endcode
*/
template <typename Type>
inline int numElementsInArray (Type& array) { return static_cast<int> (sizeof (array) / sizeof (array[0])); }
inline int numElementsInArray (Type& array)
{
(void) array; // (required to avoid a spurious warning in MS compilers)
return static_cast<int> (sizeof (array) / sizeof (array[0]));
}
// Some useful maths functions that aren't always present with all compilers and build settings.
@ -34572,6 +34576,18 @@ public:
*/
void setViewPosition (int xPixelsOffset, int yPixelsOffset);
/** Changes the position of the viewed component.
The inner component will be moved so that the pixel at the top left of
the viewport will be the pixel at the specified coordinates within the
inner component.
This will update the scrollbars and might cause a call to visibleAreaChanged().
@see getViewPositionX, getViewPositionY, setViewPositionProportionately
*/
void setViewPosition (const Point<int>& newPosition);
/** Changes the view position as a proportion of the distance it can move.
The values here are from 0.0 to 1.0 - where (0, 0) would put the

View file

@ -173,7 +173,11 @@ inline void swapVariables (Type& variable1, Type& variable2)
@endcode
*/
template <typename Type>
inline int numElementsInArray (Type& array) { return static_cast<int> (sizeof (array) / sizeof (array[0])); }
inline int numElementsInArray (Type& array)
{
(void) array; // (required to avoid a spurious warning in MS compilers)
return static_cast<int> (sizeof (array) / sizeof (array[0]));
}
//==============================================================================
// Some useful maths functions that aren't always present with all compilers and build settings.

View file

@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 17
#define JUCE_BUILDNUMBER 18
/** Current Juce version number.

View file

@ -102,7 +102,13 @@ int Viewport::getMaximumVisibleHeight() const
void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset)
{
if (contentComp != 0)
contentComp->setTopLeftPosition (-xPixelsOffset, -yPixelsOffset);
contentComp->setTopLeftPosition (jmax (jmin (0, contentHolder.getWidth() - contentComp->getWidth()), jmin (0, -xPixelsOffset)),
jmax (jmin (0, contentHolder.getHeight() - contentComp->getHeight()), jmin (0, -yPixelsOffset)));
}
void Viewport::setViewPosition (const Point<int>& newPosition)
{
setViewPosition (newPosition.getX(), newPosition.getY());
}
void Viewport::setViewPositionProportionately (const double x, const double y)

View file

@ -93,6 +93,18 @@ public:
*/
void setViewPosition (int xPixelsOffset, int yPixelsOffset);
/** Changes the position of the viewed component.
The inner component will be moved so that the pixel at the top left of
the viewport will be the pixel at the specified coordinates within the
inner component.
This will update the scrollbars and might cause a call to visibleAreaChanged().
@see getViewPositionX, getViewPositionY, setViewPositionProportionately
*/
void setViewPosition (const Point<int>& newPosition);
/** Changes the view position as a proportion of the distance it can move.
The values here are from 0.0 to 1.0 - where (0, 0) would put the

View file

@ -79,20 +79,20 @@ namespace RelativeCoordinateHelpers
};
//==============================================================================
static void skipWhitespace (const String& s, int& i)
static void skipWhitespace (const juce_wchar* const s, int& i)
{
while (CharacterFunctions::isWhitespace (s[i]))
++i;
}
static void skipComma (const String& s, int& i)
static void skipComma (const juce_wchar* const s, int& i)
{
skipWhitespace (s, i);
if (s[i] == ',')
++i;
}
static const String readAnchorName (const String& s, int& i)
static const String readAnchorName (const juce_wchar* const s, int& i)
{
skipWhitespace (s, i);
@ -102,13 +102,13 @@ namespace RelativeCoordinateHelpers
while (CharacterFunctions::isLetterOrDigit (s[i]) || s[i] == '_' || s[i] == '.')
++i;
return s.substring (start, i);
return String (s + start, i - start);
}
return String::empty;
}
static double readNumber (const String& s, int& i)
static double readNumber (const juce_wchar* const s, int& i)
{
skipWhitespace (s, i);
@ -130,14 +130,14 @@ namespace RelativeCoordinateHelpers
++i;
}
const double value = s.substring (start, i).getDoubleValue();
const double value = String (s + start, i - start).getDoubleValue();
while (CharacterFunctions::isWhitespace (s[i]) || s[i] == ',')
++i;
return value;
}
static const RelativeCoordinate readNextCoordinate (const String& s, int& i, const bool isHorizontal)
static const RelativeCoordinate readNextCoordinate (const juce_wchar* const s, int& i, const bool isHorizontal)
{
String anchor1 (readAnchorName (s, i));
double value = 0;