From 69b90487aace8c51d8c8b9331dcdbdb39ef9e530 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 22 Apr 2013 18:00:27 +0100 Subject: [PATCH] Added support for c++11 override and final keywords, and blank definitions for older compilers. --- .../Code Editor/jucer_SourceCodeEditor.cpp | 14 +++++------ modules/juce_core/system/juce_PlatformDefs.h | 19 +++++++++++++++ .../juce_gui_basics/widgets/juce_ListBox.cpp | 24 +++++++++---------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp index a4f90b1615..b1f11b0af6 100644 --- a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp +++ b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp @@ -341,7 +341,7 @@ public: findNext.setCommandToTrigger (cm, CommandIDs::findNext, true); } - void paint (Graphics& g) + void paint (Graphics& g) override { Path outline; outline.addRoundedRectangle (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 8.0f); @@ -352,7 +352,7 @@ public: g.strokePath (outline, PathStrokeType (1.0f)); } - void resized() + void resized() override { int y = 30; editor.setBounds (10, y, getWidth() - 20, 24); @@ -362,12 +362,12 @@ public: findPrev.setBounds (getWidth() - 70, y, 30, 22); } - void buttonClicked (Button*) + void buttonClicked (Button*) override { setCaseSensitiveSearch (caseButton.getToggleState()); } - void textEditorTextChanged (TextEditor&) + void textEditorTextChanged (TextEditor&) override { setSearchString (editor.getText()); @@ -375,14 +375,14 @@ public: ed->findNext (true, false); } - void textEditorFocusLost (TextEditor&) {} + void textEditorFocusLost (TextEditor&) override {} - void textEditorReturnKeyPressed (TextEditor&) + void textEditorReturnKeyPressed (TextEditor&) override { commandManager->invokeDirectly (CommandIDs::findNext, true); } - void textEditorEscapeKeyPressed (TextEditor&) + void textEditorEscapeKeyPressed (TextEditor&) override { if (GenericCodeEditorComponent* ed = getOwner()) ed->hideFindPanel(); diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index bb80b3749f..bf308138b6 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -305,6 +305,10 @@ namespace juce #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif + #ifndef JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL + #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 + #endif + #ifndef JUCE_COMPILER_SUPPORTS_ARC #define JUCE_COMPILER_SUPPORTS_ARC 1 #endif @@ -315,6 +319,14 @@ namespace juce #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1 #endif +#if defined (_MSC_VER) && _MSC_VER >= 1700 + #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 +#endif + +#if (! JUCE_CLANG) && defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 40700 + #define JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1 +#endif + //============================================================================== // Declare some fake versions of nullptr and noexcept, for older compilers: #if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_NOEXCEPT) @@ -334,4 +346,11 @@ namespace juce #define nullptr (0) #endif +#if ! (DOXYGEN || JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL) + #undef override + #define override + #undef final + #define final +#endif + #endif // __JUCE_PLATFORMDEFS_JUCEHEADER__ diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index a9f7397929..f38b9c9f1b 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -33,7 +33,7 @@ public: { } - void paint (Graphics& g) + void paint (Graphics& g) override { if (ListBoxModel* m = owner.getModel()) m->paintListBoxItem (row, g, getWidth(), getHeight(), selected); @@ -60,7 +60,7 @@ public: } } - void mouseDown (const MouseEvent& e) + void mouseDown (const MouseEvent& e) override { isDragging = false; selectRowOnMouseUp = false; @@ -81,7 +81,7 @@ public: } } - void mouseUp (const MouseEvent& e) + void mouseUp (const MouseEvent& e) override { if (isEnabled() && selectRowOnMouseUp && ! isDragging) { @@ -92,14 +92,14 @@ public: } } - void mouseDoubleClick (const MouseEvent& e) + void mouseDoubleClick (const MouseEvent& e) override { if (ListBoxModel* m = owner.getModel()) if (isEnabled()) m->listBoxItemDoubleClicked (row, e); } - void mouseDrag (const MouseEvent& e) + void mouseDrag (const MouseEvent& e) override { if (ListBoxModel* m = owner.getModel()) { @@ -121,13 +121,13 @@ public: } } - void resized() + void resized() override { if (customComponent != nullptr) customComponent->setBounds (getLocalBounds()); } - String getTooltip() + String getTooltip() override { if (ListBoxModel* m = owner.getModel()) return m->getTooltipForRow (row); @@ -183,7 +183,7 @@ public: return -1; } - void visibleAreaChanged (const Rectangle&) + void visibleAreaChanged (const Rectangle&) override { updateVisibleArea (true); @@ -297,13 +297,13 @@ public: } } - void paint (Graphics& g) + void paint (Graphics& g) override { if (isOpaque()) g.fillAll (owner.findColour (ListBox::backgroundColourId)); } - bool keyPressed (const KeyPress& key) + bool keyPressed (const KeyPress& key) override { if (key.isKeyCode (KeyPress::upKey) || key.isKeyCode (KeyPress::downKey) @@ -343,13 +343,13 @@ public: owner.addMouseListener (this, true); } - void mouseMove (const MouseEvent& e) + void mouseMove (const MouseEvent& e) override { const MouseEvent e2 (e.getEventRelativeTo (&owner)); owner.selectRow (owner.getRowContainingPosition (e2.x, e2.y), true); } - void mouseExit (const MouseEvent& e) + void mouseExit (const MouseEvent& e) override { mouseMove (e); }