From bd19111417f2ce6d9cdfcd558a78d3fa67adbc48 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Wed, 16 Feb 2011 14:45:10 +0000 Subject: [PATCH] Cleaned up some comments and uses of setContentComponent(). --- .../Source/GraphEditorPanel.cpp | 4 +-- .../Source/MainHostWindow.cpp | 12 ++++---- .../juce_StandaloneFilterWindow.cpp | 6 ++-- extras/example projects/Source/Main.cpp | 4 +-- extras/the jucer/src/ui/jucer_MainWindow.cpp | 4 +-- extras/the jucer/src/ui/jucer_PrefsPanel.cpp | 2 +- juce_amalgamated.cpp | 4 +-- juce_amalgamated.h | 30 ++++++++----------- .../components/windows/juce_DialogWindow.h | 9 +++--- .../components/windows/juce_DocumentWindow.h | 4 +-- .../windows/juce_ResizableWindow.cpp | 4 +-- .../components/windows/juce_ResizableWindow.h | 17 +++++------ 12 files changed, 44 insertions(+), 56 deletions(-) diff --git a/extras/audio plugin host/Source/GraphEditorPanel.cpp b/extras/audio plugin host/Source/GraphEditorPanel.cpp index 4dfff03fa7..95b6049b15 100644 --- a/extras/audio plugin host/Source/GraphEditorPanel.cpp +++ b/extras/audio plugin host/Source/GraphEditorPanel.cpp @@ -43,7 +43,7 @@ PluginWindow::PluginWindow (Component* const uiComp, { setSize (400, 300); - setContentComponent (uiComp, true, true); + setContentOwned (uiComp, true); setTopLeftPosition (owner->properties.getWithDefault ("uiLastX", Random::getSystemRandom().nextInt (500)), owner->properties.getWithDefault ("uiLastY", Random::getSystemRandom().nextInt (500))); @@ -104,7 +104,7 @@ PluginWindow* PluginWindow::getWindowFor (AudioProcessorGraph::Node* node, PluginWindow::~PluginWindow() { activePluginWindows.removeValue (this); - setContentComponent (0); + clearContentComponent(); } void PluginWindow::moved() diff --git a/extras/audio plugin host/Source/MainHostWindow.cpp b/extras/audio plugin host/Source/MainHostWindow.cpp index 3130b572b7..ed7c0b92a6 100644 --- a/extras/audio plugin host/Source/MainHostWindow.cpp +++ b/extras/audio plugin host/Source/MainHostWindow.cpp @@ -41,9 +41,9 @@ public: const File deadMansPedalFile (ApplicationProperties::getInstance()->getUserSettings() ->getFile().getSiblingFile ("RecentlyCrashedPluginsList")); - setContentComponent (new PluginListComponent (knownPluginList, - deadMansPedalFile, - ApplicationProperties::getInstance()->getUserSettings()), true, true); + setContentOwned (new PluginListComponent (knownPluginList, + deadMansPedalFile, + ApplicationProperties::getInstance()->getUserSettings()), true); setResizable (true, false); setResizeLimits (300, 400, 800, 1500); @@ -57,7 +57,7 @@ public: { ApplicationProperties::getInstance()->getUserSettings()->setValue ("listWindowPos", getWindowStateAsString()); - setContentComponent (0); + clearContentComponent(); jassert (currentPluginListWindow == this); currentPluginListWindow = 0; @@ -90,7 +90,7 @@ MainHostWindow::MainHostWindow() setResizeLimits (500, 400, 10000, 10000); centreWithSize (800, 600); - setContentComponent (new GraphDocumentComponent (&deviceManager)); + setContentOwned (new GraphDocumentComponent (&deviceManager), false); restoreWindowStateFromString (ApplicationProperties::getInstance()->getUserSettings()->getValue ("mainWindowPos")); @@ -138,7 +138,7 @@ MainHostWindow::~MainHostWindow() knownPluginList.removeChangeListener (this); ApplicationProperties::getInstance()->getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString()); - setContentComponent (0); + clearContentComponent(); } void MainHostWindow::closeButtonPressed() diff --git a/extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.cpp b/extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.cpp index 11c37d38f8..785fc016e0 100644 --- a/extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.cpp +++ b/extras/audio plugins/wrapper/Standalone/juce_StandaloneFilterWindow.cpp @@ -83,7 +83,7 @@ StandaloneFilterWindow::StandaloneFilterWindow (const String& title, } } - setContentComponent (filter->createEditorIfNeeded(), true, true); + setContentOwned (filter->createEditorIfNeeded(), true); const int x = globalSettings->getIntValue ("windowX", -100); const int y = globalSettings->getIntValue ("windowY", -100); @@ -138,7 +138,7 @@ void StandaloneFilterWindow::deleteFilter() if (filter != 0 && getContentComponent() != 0) { filter->editorBeingDeleted (dynamic_cast (getContentComponent())); - setContentComponent (0, true); + clearContentComponent(); } filter = 0; @@ -155,7 +155,7 @@ void StandaloneFilterWindow::resetFilter() if (deviceManager != 0) deviceManager->setFilter (filter); - setContentComponent (filter->createEditorIfNeeded(), true, true); + setContentOwned (filter->createEditorIfNeeded(), true); } PropertySet* const globalSettings = getGlobalSettings(); diff --git a/extras/example projects/Source/Main.cpp b/extras/example projects/Source/Main.cpp index 50c9968341..c4a053f2ef 100644 --- a/extras/example projects/Source/Main.cpp +++ b/extras/example projects/Source/Main.cpp @@ -21,7 +21,7 @@ class HelloWorldWindow : public DocumentWindow public: //============================================================================== HelloWorldWindow() - : DocumentWindow (T("JUCE Hello World!"), + : DocumentWindow ("JUCE Hello World!", Colours::lightgrey, DocumentWindow::allButtons, true) @@ -31,7 +31,7 @@ public: MainComponent* const contentComponent = new MainComponent(); - setContentComponent (contentComponent, true, true); + setContentOwned (contentComponent, true); centreWithSize (getWidth(), getHeight()); diff --git a/extras/the jucer/src/ui/jucer_MainWindow.cpp b/extras/the jucer/src/ui/jucer_MainWindow.cpp index 6e72deb7bb..398b383345 100644 --- a/extras/the jucer/src/ui/jucer_MainWindow.cpp +++ b/extras/the jucer/src/ui/jucer_MainWindow.cpp @@ -68,7 +68,7 @@ MainWindow::MainWindow() if (oldLook == 0) oldLook = new OldSchoolLookAndFeel(); - setContentComponent (multiDocHolder = new MultiDocHolder()); + setContentOwned (multiDocHolder = new MultiDocHolder(), false); setApplicationCommandManagerToWatch (commandManager); @@ -131,7 +131,7 @@ MainWindow::~MainWindow() StoredSettings::getInstance()->getProps() .setValue (T("lastMainWindowPos"), getWindowStateAsString()); - setContentComponent (0); + clearContentComponent(); LookAndFeel::setDefaultLookAndFeel (0); deleteAndZero (oldLook); diff --git a/extras/the jucer/src/ui/jucer_PrefsPanel.cpp b/extras/the jucer/src/ui/jucer_PrefsPanel.cpp index dd5bfd13f1..5c9ebe16d6 100644 --- a/extras/the jucer/src/ui/jucer_PrefsPanel.cpp +++ b/extras/the jucer/src/ui/jucer_PrefsPanel.cpp @@ -162,7 +162,7 @@ PrefsPanel::PrefsPanel() PrefsTabComp* const p = new PrefsTabComp(); p->setSize (456, 510); - setContentComponent (p, true, true); + setContentOwned (p, true); if (! restoreWindowStateFromString (prefsWindowPos)) centreAroundComponent (0, getWidth(), getHeight()); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index f7c33a649e..ccc798d24e 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -78605,7 +78605,7 @@ void ResizableWindow::addChildComponent (Component* const child, int zOrder) If you really know what you're doing and want to avoid this assertion, just call Component::addChildComponent directly. - */ + */ jassertfalse; Component::addChildComponent (child, zOrder); @@ -78622,7 +78622,7 @@ void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder) If you really know what you're doing and want to avoid this assertion, just call Component::addAndMakeVisible directly. - */ + */ jassertfalse; Component::addAndMakeVisible (child, zOrder); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 8facbed33a..442643cb92 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -55305,8 +55305,8 @@ private: /** A base class for top-level windows that can be dragged around and resized. - To add content to the window, use its setContentComponent() method to - give it a component that will remain positioned inside it (leaving a gap around + To add content to the window, use its setContentOwned() or setContentNonOwned() methods + to give it a component that will remain positioned inside it (leaving a gap around the edges for a border). It's not advisable to add child components directly to a ResizableWindow: put them @@ -55349,9 +55349,7 @@ public: bool addToDesktop); /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. + If a content component has been set with setContentOwned(), it will be deleted. */ ~ResizableWindow(); @@ -55492,10 +55490,10 @@ public: /** Returns the current content component. - This will be the component set by setContentComponent(), or 0 if none + This will be the component set by setContentOwned() or setContentNonOwned, or 0 if none has yet been specified. - @see setContentComponent + @see setContentOwned, setContentNonOwned */ Component* getContentComponent() const throw() { return contentComponent; } @@ -55604,20 +55602,19 @@ protected: #if JUCE_DEBUG /** Overridden to warn people about adding components directly to this component - instead of using setContentComponent(). + instead of using setContentOwned(). If you know what you're doing and are sure you really want to add a component, specify a base-class method call to Component::addAndMakeVisible(), to side-step this warning. */ void addChildComponent (Component* child, int zOrder = -1); /** Overridden to warn people about adding components directly to this component - instead of using setContentComponent(). + instead of using setContentOwned(). If you know what you're doing and are sure you really want to add a component, specify a base-class method call to Component::addAndMakeVisible(), to side-step this warning. */ void addAndMakeVisible (Component* child, int zOrder = -1); - #endif ScopedPointer resizableCorner; @@ -58342,9 +58339,7 @@ public: bool addToDesktop = true); /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. + If a content component has been set with setContentOwned(), it will be deleted. */ ~DocumentWindow(); @@ -63721,8 +63716,9 @@ private: Any of the methods available to a DocumentWindow or ResizableWindow are also available to this, so it can be made resizable, have a menu bar, etc. - To add items to the box, see the ResizableWindow::setContentComponent() method. - Don't add components directly to this class - always put them in a content component! + To add items to the box, see the ResizableWindow::setContentOwned() or + ResizableWindow::setContentNonOwned() methods. Don't add components directly to this + class - always put them in a content component! You'll need to override the DocumentWindow::closeButtonPressed() method to handle the user clicking the close button - for more info, see the DocumentWindow @@ -63751,9 +63747,7 @@ public: bool addToDesktop = true); /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. + If a content component has been set with setContentOwned(), it will be deleted. */ ~DialogWindow(); diff --git a/src/gui/components/windows/juce_DialogWindow.h b/src/gui/components/windows/juce_DialogWindow.h index fb7b92c5b8..f5c2f1b21e 100644 --- a/src/gui/components/windows/juce_DialogWindow.h +++ b/src/gui/components/windows/juce_DialogWindow.h @@ -40,8 +40,9 @@ Any of the methods available to a DocumentWindow or ResizableWindow are also available to this, so it can be made resizable, have a menu bar, etc. - To add items to the box, see the ResizableWindow::setContentComponent() method. - Don't add components directly to this class - always put them in a content component! + To add items to the box, see the ResizableWindow::setContentOwned() or + ResizableWindow::setContentNonOwned() methods. Don't add components directly to this + class - always put them in a content component! You'll need to override the DocumentWindow::closeButtonPressed() method to handle the user clicking the close button - for more info, see the DocumentWindow @@ -70,9 +71,7 @@ public: bool addToDesktop = true); /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. + If a content component has been set with setContentOwned(), it will be deleted. */ ~DialogWindow(); diff --git a/src/gui/components/windows/juce_DocumentWindow.h b/src/gui/components/windows/juce_DocumentWindow.h index f9eff6fd78..188f5d223b 100644 --- a/src/gui/components/windows/juce_DocumentWindow.h +++ b/src/gui/components/windows/juce_DocumentWindow.h @@ -95,9 +95,7 @@ public: bool addToDesktop = true); /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. + If a content component has been set with setContentOwned(), it will be deleted. */ ~DocumentWindow(); diff --git a/src/gui/components/windows/juce_ResizableWindow.cpp b/src/gui/components/windows/juce_ResizableWindow.cpp index 84b2ea8425..7267a41bbb 100644 --- a/src/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/gui/components/windows/juce_ResizableWindow.cpp @@ -592,7 +592,7 @@ void ResizableWindow::addChildComponent (Component* const child, int zOrder) If you really know what you're doing and want to avoid this assertion, just call Component::addChildComponent directly. - */ + */ jassertfalse; Component::addChildComponent (child, zOrder); @@ -609,7 +609,7 @@ void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder) If you really know what you're doing and want to avoid this assertion, just call Component::addAndMakeVisible directly. - */ + */ jassertfalse; Component::addAndMakeVisible (child, zOrder); diff --git a/src/gui/components/windows/juce_ResizableWindow.h b/src/gui/components/windows/juce_ResizableWindow.h index 0a98d8be14..da7ae306ae 100644 --- a/src/gui/components/windows/juce_ResizableWindow.h +++ b/src/gui/components/windows/juce_ResizableWindow.h @@ -36,8 +36,8 @@ /** A base class for top-level windows that can be dragged around and resized. - To add content to the window, use its setContentComponent() method to - give it a component that will remain positioned inside it (leaving a gap around + To add content to the window, use its setContentOwned() or setContentNonOwned() methods + to give it a component that will remain positioned inside it (leaving a gap around the edges for a border). It's not advisable to add child components directly to a ResizableWindow: put them @@ -80,9 +80,7 @@ public: bool addToDesktop); /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. + If a content component has been set with setContentOwned(), it will be deleted. */ ~ResizableWindow(); @@ -230,10 +228,10 @@ public: //============================================================================== /** Returns the current content component. - This will be the component set by setContentComponent(), or 0 if none + This will be the component set by setContentOwned() or setContentNonOwned, or 0 if none has yet been specified. - @see setContentComponent + @see setContentOwned, setContentNonOwned */ Component* getContentComponent() const throw() { return contentComponent; } @@ -344,20 +342,19 @@ protected: #if JUCE_DEBUG /** Overridden to warn people about adding components directly to this component - instead of using setContentComponent(). + instead of using setContentOwned(). If you know what you're doing and are sure you really want to add a component, specify a base-class method call to Component::addAndMakeVisible(), to side-step this warning. */ void addChildComponent (Component* child, int zOrder = -1); /** Overridden to warn people about adding components directly to this component - instead of using setContentComponent(). + instead of using setContentOwned(). If you know what you're doing and are sure you really want to add a component, specify a base-class method call to Component::addAndMakeVisible(), to side-step this warning. */ void addAndMakeVisible (Component* child, int zOrder = -1); - #endif ScopedPointer resizableCorner;