diff --git a/extras/juce demo/Source/demos/TreeViewDemo.cpp b/extras/juce demo/Source/demos/TreeViewDemo.cpp index 74db5b550d..ddd746eaef 100644 --- a/extras/juce demo/Source/demos/TreeViewDemo.cpp +++ b/extras/juce demo/Source/demos/TreeViewDemo.cpp @@ -150,6 +150,8 @@ public: ~TreeViewDemo() { + fileTreeComp = 0; + directoryList = 0; // (need to make sure this is deleted before the TimeSliceThread) } void paint (Graphics& g) diff --git a/extras/juce demo/Source/demos/WidgetsDemo.cpp b/extras/juce demo/Source/demos/WidgetsDemo.cpp index bdae8400ec..47985ceecc 100644 --- a/extras/juce demo/Source/demos/WidgetsDemo.cpp +++ b/extras/juce demo/Source/demos/WidgetsDemo.cpp @@ -1065,39 +1065,17 @@ public: switch (buttonId) { - case menuButton: - desc = "menu button (short)"; - break; - case playButton: - desc = "play button"; - break; - case plusButton: - desc = "plus button"; - break; - case minusButton: - desc = "minus button"; - break; - case rightButton: - desc = "right button (short)"; - break; - case leftButton: - desc = "left button (short)"; - break; - case rightButton_Long: - desc = "right button (long)"; - break; - case leftButton_Long: - desc = "left button (long)"; - break; - case menuButton_Long: - desc = "menu button (long)"; - break; - case playButtonSleepMode: - desc = "play (sleep mode)"; - break; - case switched: - desc = "remote switched"; - break; + case menuButton: desc = "menu button (short)"; break; + case playButton: desc = "play button"; break; + case plusButton: desc = "plus button"; break; + case minusButton: desc = "minus button"; break; + case rightButton: desc = "right button (short)"; break; + case leftButton: desc = "left button (short)"; break; + case rightButton_Long: desc = "right button (long)"; break; + case leftButton_Long: desc = "left button (long)"; break; + case menuButton_Long: desc = "menu button (long)"; break; + case playButtonSleepMode: desc = "play (sleep mode)"; break; + case switched: desc = "remote switched"; break; } if (isDown) diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h index ce47587c07..cbf0936da6 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h @@ -76,7 +76,7 @@ public: if (image != 0) { - image->drawWithin (g, r.getX(), r.getY(), r.getWidth(), r.getHeight(), + image->drawWithin (g, r.toFloat(), mode == stretched ? RectanglePlacement::stretchToFit : (mode == proportionalReducingOnly ? (RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize) : RectanglePlacement::centred), diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index a02f216efa..2c1910c7b7 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -10424,7 +10424,7 @@ public: if (file_.inputSource != 0) { - inputStream = file.inputSource->createInputStream(); + inputStream = streamToDelete = file.inputSource->createInputStream(); } else { @@ -10451,9 +10451,6 @@ public: if (inputStream != 0 && inputStream == file.inputStream) file.numOpenStreams--; #endif - - if (inputStream != file.inputStream) - delete inputStream; } int64 getTotalLength() @@ -10512,6 +10509,7 @@ private: int64 pos; int headerSize; InputStream* inputStream; + ScopedPointer streamToDelete; ZipInputStream (const ZipInputStream&); ZipInputStream& operator= (const ZipInputStream&); @@ -10554,11 +10552,11 @@ ZipFile::~ZipFile() #if JUCE_DEBUG entries.clear(); - // If you hit this assertion, it means you've created a stream to read - // one of the items in the zipfile, but you've forgotten to delete that - // stream object before deleting the file.. Streams can't be kept open - // after the file is deleted because they need to share the input - // stream that the file uses to read itself. + /* If you hit this assertion, it means you've created a stream to read one of the items in the + zipfile, but you've forgotten to delete that stream object before deleting the file.. + Streams can't be kept open after the file is deleted because they need to share the input + stream that the file uses to read itself. + */ jassert (numOpenStreams == 0); #endif } @@ -30939,13 +30937,15 @@ PluginListComponent::PluginListComponent (KnownPluginList& listToEdit, PropertiesFile* const propertiesToUse_) : list (listToEdit), deadMansPedalFile (deadMansPedalFile_), + optionsButton ("Options..."), propertiesToUse (propertiesToUse_) { - addAndMakeVisible (listBox = new ListBox (String::empty, this)); + listBox.setModel (this); + addAndMakeVisible (&listBox); - addAndMakeVisible (optionsButton = new TextButton ("Options...")); - optionsButton->addButtonListener (this); - optionsButton->setTriggeredOnMouseDown (true); + addAndMakeVisible (&optionsButton); + optionsButton.addButtonListener (this); + optionsButton.setTriggeredOnMouseDown (true); setSize (400, 600); list.addChangeListener (this); @@ -30955,20 +30955,19 @@ PluginListComponent::PluginListComponent (KnownPluginList& listToEdit, PluginListComponent::~PluginListComponent() { list.removeChangeListener (this); - deleteAllChildren(); } void PluginListComponent::resized() { - listBox->setBounds (0, 0, getWidth(), getHeight() - 30); - optionsButton->changeWidthToFitText (24); - optionsButton->setTopLeftPosition (8, getHeight() - 28); + listBox.setBounds (0, 0, getWidth(), getHeight() - 30); + optionsButton.changeWidthToFitText (24); + optionsButton.setTopLeftPosition (8, getHeight() - 28); } void PluginListComponent::changeListenerCallback (void*) { - listBox->updateContent(); - listBox->repaint(); + listBox.updateContent(); + listBox.repaint(); } int PluginListComponent::getNumRows() @@ -31026,14 +31025,14 @@ void PluginListComponent::deleteKeyPressed (int lastRowSelected) list.removeType (lastRowSelected); } -void PluginListComponent::buttonClicked (Button* b) +void PluginListComponent::buttonClicked (Button* button) { - if (optionsButton == b) + if (button == &optionsButton) { PopupMenu menu; menu.addItem (1, TRANS("Clear list")); - menu.addItem (5, TRANS("Remove selected plugin from list"), listBox->getNumSelectedRows() > 0); - menu.addItem (6, TRANS("Show folder containing selected plugin"), listBox->getNumSelectedRows() > 0); + menu.addItem (5, TRANS("Remove selected plugin from list"), listBox.getNumSelectedRows() > 0); + menu.addItem (6, TRANS("Show folder containing selected plugin"), listBox.getNumSelectedRows() > 0); menu.addItem (7, TRANS("Remove any plugins whose files no longer exist")); menu.addSeparator(); menu.addItem (2, TRANS("Sort alphabetically")); @@ -31049,7 +31048,7 @@ void PluginListComponent::buttonClicked (Button* b) menu.addItem (10 + i, "Scan for new or updated " + format->getName() + " plugins..."); } - const int r = menu.showAt (optionsButton); + const int r = menu.showAt (&optionsButton); if (r == 1) { @@ -31069,7 +31068,7 @@ void PluginListComponent::buttonClicked (Button* b) } else if (r == 5) { - const SparseSet selected (listBox->getSelectedRows()); + const SparseSet selected (listBox.getSelectedRows()); for (int i = list.getNumTypes(); --i >= 0;) if (selected.contains (i)) @@ -31077,7 +31076,7 @@ void PluginListComponent::buttonClicked (Button* b) } else if (r == 6) { - const PluginDescription* const desc = list.getType (listBox->getSelectedRow()); + const PluginDescription* const desc = list.getType (listBox.getSelectedRow()); if (desc != 0) { @@ -45739,10 +45738,6 @@ public: setInterceptsMouseClicks (false, false); } - ~CaretComponent() - { - } - void paint (Graphics& g) { g.fillAll (findColour (CodeEditorComponent::caretColourId)); @@ -45989,6 +45984,8 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_, columnToTryToMaintain (-1), useSpacesForTabs (false), xOffset (0), + verticalScrollBar (true), + horizontalScrollBar (false), codeTokeniser (codeTokeniser_) { caretPos = CodeDocument::Position (&document_, 0, 0); @@ -46004,11 +46001,11 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_, setMouseCursor (MouseCursor (MouseCursor::IBeamCursor)); setWantsKeyboardFocus (true); - addAndMakeVisible (verticalScrollBar = new ScrollBar (true)); - verticalScrollBar->setSingleStepSize (1.0); + addAndMakeVisible (&verticalScrollBar); + verticalScrollBar.setSingleStepSize (1.0); - addAndMakeVisible (horizontalScrollBar = new ScrollBar (false)); - horizontalScrollBar->setSingleStepSize (1.0); + addAndMakeVisible (&horizontalScrollBar); + horizontalScrollBar.setSingleStepSize (1.0); addAndMakeVisible (caret = new CaretComponent (*this)); @@ -46018,15 +46015,14 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_, resetToDefaultColours(); - verticalScrollBar->addListener (this); - horizontalScrollBar->addListener (this); + verticalScrollBar.addListener (this); + horizontalScrollBar.addListener (this); document.addListener (this); } CodeEditorComponent::~CodeEditorComponent() { document.removeListener (this); - deleteAllChildren(); } void CodeEditorComponent::loadContent (const String& newContent) @@ -46075,8 +46071,8 @@ void CodeEditorComponent::resized() rebuildLineTokens(); caret->updatePosition(); - verticalScrollBar->setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness); - horizontalScrollBar->setBounds (gutter, getHeight() - scrollbarThickness, getWidth() - scrollbarThickness - gutter, scrollbarThickness); + verticalScrollBar.setBounds (getWidth() - scrollbarThickness, 0, scrollbarThickness, getHeight() - scrollbarThickness); + horizontalScrollBar.setBounds (gutter, getHeight() - scrollbarThickness, getWidth() - scrollbarThickness - gutter, scrollbarThickness); updateScrollBars(); } @@ -46086,7 +46082,7 @@ void CodeEditorComponent::paint (Graphics& g) g.fillAll (findColour (CodeEditorComponent::backgroundColourId)); - g.reduceClipRegion (gutter, 0, verticalScrollBar->getX() - gutter, horizontalScrollBar->getY()); + g.reduceClipRegion (gutter, 0, verticalScrollBar.getX() - gutter, horizontalScrollBar.getY()); g.setFont (font); const int baselineOffset = (int) font.getAscent(); @@ -46160,7 +46156,7 @@ void CodeEditorComponent::rebuildLineTokens() if (minLineToRepaint <= maxLineToRepaint) { repaint (gutter, lineHeight * minLineToRepaint - 1, - verticalScrollBar->getX() - gutter, + verticalScrollBar.getX() - gutter, lineHeight * (1 + maxLineToRepaint - minLineToRepaint) + 2); } } @@ -46231,11 +46227,11 @@ void CodeEditorComponent::deselectAll() void CodeEditorComponent::updateScrollBars() { - verticalScrollBar->setRangeLimits (0, jmax (document.getNumLines(), firstLineOnScreen + linesOnScreen)); - verticalScrollBar->setCurrentRange (firstLineOnScreen, linesOnScreen); + verticalScrollBar.setRangeLimits (0, jmax (document.getNumLines(), firstLineOnScreen + linesOnScreen)); + verticalScrollBar.setCurrentRange (firstLineOnScreen, linesOnScreen); - horizontalScrollBar->setRangeLimits (0, jmax ((double) document.getMaximumLineLength(), xOffset + columnsOnScreen)); - horizontalScrollBar->setCurrentRange (xOffset, columnsOnScreen); + horizontalScrollBar.setRangeLimits (0, jmax ((double) document.getMaximumLineLength(), xOffset + columnsOnScreen)); + horizontalScrollBar.setCurrentRange (xOffset, columnsOnScreen); } void CodeEditorComponent::scrollToLineInternal (int newFirstLineOnScreen) @@ -46766,11 +46762,11 @@ void CodeEditorComponent::mouseDoubleClick (const MouseEvent& e) void CodeEditorComponent::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) { - if ((verticalScrollBar->isVisible() && wheelIncrementY != 0) - || (horizontalScrollBar->isVisible() && wheelIncrementX != 0)) + if ((verticalScrollBar.isVisible() && wheelIncrementY != 0) + || (horizontalScrollBar.isVisible() && wheelIncrementX != 0)) { - verticalScrollBar->mouseWheelMove (e, 0, wheelIncrementY); - horizontalScrollBar->mouseWheelMove (e, wheelIncrementX, 0); + verticalScrollBar.mouseWheelMove (e, 0, wheelIncrementY); + horizontalScrollBar.mouseWheelMove (e, wheelIncrementX, 0); } else { @@ -46780,7 +46776,7 @@ void CodeEditorComponent::mouseWheelMove (const MouseEvent& e, float wheelIncrem void CodeEditorComponent::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart) { - if (scrollBarThatHasMoved == verticalScrollBar) + if (scrollBarThatHasMoved == &verticalScrollBar) scrollToLineInternal ((int) newRangeStart); else scrollToColumnInternal (newRangeStart); @@ -48584,18 +48580,11 @@ class ListBoxRowComponent : public Component, { public: ListBoxRowComponent (ListBox& owner_) - : owner (owner_), - row (-1), - selected (false), - isDragging (false) + : owner (owner_), row (-1), + selected (false), isDragging (false), selectRowOnMouseUp (false) { } - ~ListBoxRowComponent() - { - deleteAllChildren(); - } - void paint (Graphics& g) { if (owner.getModel() != 0) @@ -48613,20 +48602,12 @@ public: if (owner.getModel() != 0) { - Component* const customComp = owner.getModel()->refreshComponentForRow (row_, selected_, getChildComponent (0)); + customComponent = owner.getModel()->refreshComponentForRow (row_, selected_, customComponent.release()); - if (customComp != 0) + if (customComponent != 0) { - addAndMakeVisible (customComp); - customComp->setBounds (getLocalBounds()); - - for (int i = getNumChildComponents(); --i >= 0;) - if (getChildComponent (i) != customComp) - delete getChildComponent (i); - } - else - { - deleteAllChildren(); + addAndMakeVisible (customComponent); + customComponent->setBounds (getLocalBounds()); } } } @@ -48690,8 +48671,8 @@ public: void resized() { - if (getNumChildComponents() > 0) - getChildComponent(0)->setBounds (getLocalBounds()); + if (customComponent != 0) + customComponent->setBounds (getLocalBounds()); } const String getTooltip() @@ -48704,7 +48685,7 @@ public: juce_UseDebuggingNewOperator - bool neededFlag; + ScopedPointer customComponent; private: ListBox& owner; @@ -48718,35 +48699,37 @@ private: class ListViewport : public Viewport { public: - int firstIndex, firstWholeIndex, lastWholeIndex; - bool hasUpdated; ListViewport (ListBox& owner_) : owner (owner_) { setWantsKeyboardFocus (false); - setViewedComponent (new Component()); - getViewedComponent()->addMouseListener (this, false); - getViewedComponent()->setWantsKeyboardFocus (false); + Component* const content = new Component(); + setViewedComponent (content); + content->addMouseListener (this, false); + content->setWantsKeyboardFocus (false); } ~ListViewport() { - getViewedComponent()->removeMouseListener (this); - getViewedComponent()->deleteAllChildren(); } ListBoxRowComponent* getComponentForRow (const int row) const throw() { - return static_cast - (getViewedComponent()->getChildComponent (row % jmax (1, getViewedComponent()->getNumChildComponents()))); + return rows [row % jmax (1, rows.size())]; + } + + ListBoxRowComponent* getComponentForRowIfOnscreen (const int row) const throw() + { + return (row >= firstIndex && row < firstIndex + rows.size()) + ? getComponentForRow (row) : 0; } int getRowNumberOfComponent (Component* const rowComponent) const throw() { const int index = getIndexOfChildComponent (rowComponent); - const int num = getViewedComponent()->getNumChildComponents(); + const int num = rows.size(); for (int i = num; --i >= 0;) if (((firstIndex + i) % jmax (1, num)) == index) @@ -48755,12 +48738,6 @@ public: return -1; } - Component* getComponentForRowIfOnscreen (const int row) const throw() - { - return (row >= firstIndex && row < firstIndex + getViewedComponent()->getNumChildComponents()) - ? getComponentForRow (row) : 0; - } - void visibleAreaChanged (int, int, int, int) { updateVisibleArea (true); @@ -48798,18 +48775,13 @@ public: const int w = getViewedComponent()->getWidth(); const int numNeeded = 2 + getMaximumVisibleHeight() / rowHeight; + rows.removeRange (numNeeded, rows.size()); - while (numNeeded > getViewedComponent()->getNumChildComponents()) - getViewedComponent()->addAndMakeVisible (new ListBoxRowComponent (owner)); - - jassert (numNeeded >= 0); - - while (numNeeded < getViewedComponent()->getNumChildComponents()) + while (numNeeded > rows.size()) { - Component* const rowToRemove - = getViewedComponent()->getChildComponent (getViewedComponent()->getNumChildComponents() - 1); - - delete rowToRemove; + ListBoxRowComponent* newRow = new ListBoxRowComponent (owner); + rows.add (newRow); + getViewedComponent()->addAndMakeVisible (newRow); } firstIndex = y / rowHeight; @@ -48837,6 +48809,50 @@ public: owner.headerComponent->getHeight()); } + void selectRow (const int row, const int rowHeight, const bool dontScroll, + const int lastRowSelected, const int totalItems, const bool isMouseClick) + { + hasUpdated = false; + + if (row < firstWholeIndex && ! dontScroll) + { + setViewPosition (getViewPositionX(), row * rowHeight); + } + else if (row >= lastWholeIndex && ! dontScroll) + { + const int rowsOnScreen = lastWholeIndex - firstWholeIndex; + + if (row >= lastRowSelected + rowsOnScreen + && rowsOnScreen < totalItems - 1 + && ! isMouseClick) + { + setViewPosition (getViewPositionX(), + jlimit (0, jmax (0, totalItems - rowsOnScreen), row) * rowHeight); + } + else + { + setViewPosition (getViewPositionX(), + jmax (0, (row + 1) * rowHeight - getMaximumVisibleHeight())); + } + } + + if (! hasUpdated) + updateContents(); + } + + void scrollToEnsureRowIsOnscreen (const int row, const int rowHeight) + { + if (row < firstWholeIndex) + { + setViewPosition (getViewPositionX(), row * rowHeight); + } + else if (row >= lastWholeIndex) + { + setViewPosition (getViewPositionX(), + jmax (0, (row + 1) * rowHeight - getMaximumVisibleHeight())); + } + } + void paint (Graphics& g) { if (isOpaque()) @@ -48864,6 +48880,9 @@ public: private: ListBox& owner; + OwnedArray rows; + int firstIndex, firstWholeIndex, lastWholeIndex; + bool hasUpdated; ListViewport (const ListViewport&); ListViewport& operator= (const ListViewport&); @@ -49003,34 +49022,8 @@ void ListBox::selectRowInternal (const int row, if (getHeight() == 0 || getWidth() == 0) dontScroll = true; - viewport->hasUpdated = false; - - if (row < viewport->firstWholeIndex && ! dontScroll) - { - viewport->setViewPosition (viewport->getViewPositionX(), - row * getRowHeight()); - } - else if (row >= viewport->lastWholeIndex && ! dontScroll) - { - const int rowsOnScreen = viewport->lastWholeIndex - viewport->firstWholeIndex; - - if (row >= lastRowSelected + rowsOnScreen - && rowsOnScreen < totalItems - 1 - && ! isMouseClick) - { - viewport->setViewPosition (viewport->getViewPositionX(), - jlimit (0, jmax (0, totalItems - rowsOnScreen), row) - * getRowHeight()); - } - else - { - viewport->setViewPosition (viewport->getViewPositionX(), - jmax (0, (row + 1) * getRowHeight() - viewport->getMaximumVisibleHeight())); - } - } - - if (! viewport->hasUpdated) - viewport->updateContents(); + viewport->selectRow (row, getRowHeight(), dontScroll, + lastRowSelected, totalItems, isMouseClick); lastRowSelected = row; model->selectedRowsChanged (row); @@ -49180,8 +49173,8 @@ int ListBox::getInsertionIndexForPosition (const int x, const int y) const throw Component* ListBox::getComponentForRowNumber (const int row) const throw() { - Component* const listRowComp = viewport->getComponentForRowIfOnscreen (row); - return listRowComp != 0 ? listRowComp->getChildComponent (0) : 0; + ListBoxRowComponent* const listRowComp = viewport->getComponentForRowIfOnscreen (row); + return listRowComp != 0 ? static_cast (listRowComp->customComponent) : 0; } int ListBox::getRowNumberOfComponent (Component* const rowComponent) const throw() @@ -49224,16 +49217,7 @@ int ListBox::getVisibleRowWidth() const throw() void ListBox::scrollToEnsureRowIsOnscreen (const int row) { - if (row < viewport->firstWholeIndex) - { - viewport->setViewPosition (viewport->getViewPositionX(), - row * getRowHeight()); - } - else if (row >= viewport->lastWholeIndex) - { - viewport->setViewPosition (viewport->getViewPositionX(), - jmax (0, (row + 1) * getRowHeight() - viewport->getMaximumVisibleHeight())); - } + viewport->scrollToEnsureRowIsOnscreen (row, getRowHeight()); } bool ListBox::keyPressed (const KeyPress& key) @@ -49483,43 +49467,15 @@ Component* ListBoxModel::refreshComponentForRow (int, bool, Component* existingC return 0; } -void ListBoxModel::listBoxItemClicked (int, const MouseEvent&) -{ -} - -void ListBoxModel::listBoxItemDoubleClicked (int, const MouseEvent&) -{ -} - -void ListBoxModel::backgroundClicked() -{ -} - -void ListBoxModel::selectedRowsChanged (int) -{ -} - -void ListBoxModel::deleteKeyPressed (int) -{ -} - -void ListBoxModel::returnKeyPressed (int) -{ -} - -void ListBoxModel::listWasScrolled() -{ -} - -const String ListBoxModel::getDragSourceDescription (const SparseSet&) -{ - return String::empty; -} - -const String ListBoxModel::getTooltipForRow (int) -{ - return String::empty; -} +void ListBoxModel::listBoxItemClicked (int, const MouseEvent&) {} +void ListBoxModel::listBoxItemDoubleClicked (int, const MouseEvent&) {} +void ListBoxModel::backgroundClicked() {} +void ListBoxModel::selectedRowsChanged (int) {} +void ListBoxModel::deleteKeyPressed (int) {} +void ListBoxModel::returnKeyPressed (int) {} +void ListBoxModel::listWasScrolled() {} +const String ListBoxModel::getDragSourceDescription (const SparseSet&) { return String::empty; } +const String ListBoxModel::getTooltipForRow (int) { return String::empty; } END_JUCE_NAMESPACE /*** End of inlined file: juce_ListBox.cpp ***/ @@ -52147,16 +52103,12 @@ public: { } - ~TableListBoxHeader() - { - } - void addMenuItems (PopupMenu& menu, int columnIdClicked) { if (owner.isAutoSizeMenuOptionShown()) { - menu.addItem (0xf836743, TRANS("Auto-size this column"), columnIdClicked != 0); - menu.addItem (0xf836744, TRANS("Auto-size all columns"), owner.getHeader()->getNumColumns (true) > 0); + menu.addItem (autoSizeColumnId, TRANS("Auto-size this column"), columnIdClicked != 0); + menu.addItem (autoSizeAllId, TRANS("Auto-size all columns"), owner.getHeader()->getNumColumns (true) > 0); menu.addSeparator(); } @@ -52165,11 +52117,11 @@ public: void reactToMenuItem (int menuReturnId, int columnIdClicked) { - if (menuReturnId == 0xf836743) + if (menuReturnId == autoSizeColumnId) { owner.autoSizeColumn (columnIdClicked); } - else if (menuReturnId == 0xf836744) + else if (menuReturnId == autoSizeAllId) { owner.autoSizeAllColumns(); } @@ -52184,6 +52136,8 @@ public: private: TableListBox& owner; + enum { autoSizeColumnId = 0xf836743, autoSizeAllId = 0xf836744 }; + TableListBoxHeader (const TableListBoxHeader&); TableListBoxHeader& operator= (const TableListBoxHeader&); }; @@ -55759,63 +55713,59 @@ private: const int optionFlags) : factory (factory_), toolbar (toolbar_), - styleBox (0), - defaultButton (0) + palette (factory_, toolbar_), + instructions (String::empty, TRANS ("You can drag the items above and drop them onto a toolbar to add them.\n\n" + "Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")), + defaultButton (TRANS ("Restore to default set of items")) { - addAndMakeVisible (palette = new ToolbarItemPalette (factory, toolbar)); + addAndMakeVisible (&palette); if ((optionFlags & (Toolbar::allowIconsOnlyChoice | Toolbar::allowIconsWithTextChoice | Toolbar::allowTextOnlyChoice)) != 0) { - addAndMakeVisible (styleBox = new ComboBox (String::empty)); - styleBox->setEditableText (false); + addAndMakeVisible (&styleBox); + styleBox.setEditableText (false); - if ((optionFlags & Toolbar::allowIconsOnlyChoice) != 0) - styleBox->addItem (TRANS("Show icons only"), 1); - if ((optionFlags & Toolbar::allowIconsWithTextChoice) != 0) - styleBox->addItem (TRANS("Show icons and descriptions"), 2); - if ((optionFlags & Toolbar::allowTextOnlyChoice) != 0) - styleBox->addItem (TRANS("Show descriptions only"), 3); + if ((optionFlags & Toolbar::allowIconsOnlyChoice) != 0) styleBox.addItem (TRANS("Show icons only"), 1); + if ((optionFlags & Toolbar::allowIconsWithTextChoice) != 0) styleBox.addItem (TRANS("Show icons and descriptions"), 2); + if ((optionFlags & Toolbar::allowTextOnlyChoice) != 0) styleBox.addItem (TRANS("Show descriptions only"), 3); - if (toolbar_->getStyle() == Toolbar::iconsOnly) - styleBox->setSelectedId (1); - else if (toolbar_->getStyle() == Toolbar::iconsWithText) - styleBox->setSelectedId (2); - else if (toolbar_->getStyle() == Toolbar::textOnly) - styleBox->setSelectedId (3); + int selectedStyle = 0; + switch (toolbar_->getStyle()) + { + case Toolbar::iconsOnly: selectedStyle = 1; break; + case Toolbar::iconsWithText: selectedStyle = 2; break; + case Toolbar::textOnly: selectedStyle = 3; break; + } - styleBox->addListener (this); + styleBox.setSelectedId (selectedStyle); + + styleBox.addListener (this); } if ((optionFlags & Toolbar::showResetToDefaultsButton) != 0) { - addAndMakeVisible (defaultButton = new TextButton (TRANS ("Restore to default set of items"))); - defaultButton->addButtonListener (this); + addAndMakeVisible (&defaultButton); + defaultButton.addButtonListener (this); } - addAndMakeVisible (instructions = new Label (String::empty, - TRANS ("You can drag the items above and drop them onto a toolbar to add them.\n\nItems on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them."))); - instructions->setFont (Font (13.0f)); + addAndMakeVisible (&instructions); + instructions.setFont (Font (13.0f)); setSize (500, 300); } - ~CustomiserPanel() - { - deleteAllChildren(); - } - void comboBoxChanged (ComboBox*) { - if (styleBox->getSelectedId() == 1) - toolbar->setStyle (Toolbar::iconsOnly); - else if (styleBox->getSelectedId() == 2) - toolbar->setStyle (Toolbar::iconsWithText); - else if (styleBox->getSelectedId() == 3) - toolbar->setStyle (Toolbar::textOnly); + switch (styleBox.getSelectedId()) + { + case 1: toolbar->setStyle (Toolbar::iconsOnly); break; + case 2: toolbar->setStyle (Toolbar::iconsWithText); break; + case 3: toolbar->setStyle (Toolbar::textOnly); break; + } - palette->resized(); // to make it update the styles + palette.resized(); // to make it update the styles } void buttonClicked (Button*) @@ -55833,33 +55783,28 @@ private: background = dw->getBackgroundColour(); g.setColour (background.contrasting().withAlpha (0.3f)); - g.fillRect (palette->getX(), palette->getBottom() - 1, palette->getWidth(), 1); + g.fillRect (palette.getX(), palette.getBottom() - 1, palette.getWidth(), 1); } void resized() { - palette->setBounds (0, 0, getWidth(), getHeight() - 120); + palette.setBounds (0, 0, getWidth(), getHeight() - 120); + styleBox.setBounds (10, getHeight() - 110, 200, 22); - if (styleBox != 0) - styleBox->setBounds (10, getHeight() - 110, 200, 22); + defaultButton.changeWidthToFitText (22); + defaultButton.setTopLeftPosition (240, getHeight() - 110); - if (defaultButton != 0) - { - defaultButton->changeWidthToFitText (22); - defaultButton->setTopLeftPosition (240, getHeight() - 110); - } - - instructions->setBounds (10, getHeight() - 80, getWidth() - 20, 80); + instructions.setBounds (10, getHeight() - 80, getWidth() - 20, 80); } private: ToolbarItemFactory& factory; Toolbar* const toolbar; - Label* instructions; - ToolbarItemPalette* palette; - ComboBox* styleBox; - TextButton* defaultButton; + ToolbarItemPalette palette; + Label instructions; + ComboBox styleBox; + TextButton defaultButton; }; }; @@ -56119,6 +56064,7 @@ ToolbarItemPalette::ToolbarItemPalette (ToolbarItemFactory& factory_, toolbar (toolbar_) { Component* const itemHolder = new Component(); + viewport.setViewedComponent (itemHolder); Array allIds; factory_.getAllToolbarItemIds (allIds); @@ -56135,25 +56081,22 @@ ToolbarItemPalette::ToolbarItemPalette (ToolbarItemFactory& factory_, } } - viewport = new Viewport(); - viewport->setViewedComponent (itemHolder); - addAndMakeVisible (viewport); + addAndMakeVisible (&viewport); } ToolbarItemPalette::~ToolbarItemPalette() { - viewport->getViewedComponent()->deleteAllChildren(); - deleteAllChildren(); + viewport.getViewedComponent()->deleteAllChildren(); } void ToolbarItemPalette::resized() { - viewport->setBoundsInset (BorderSize (1)); + viewport.setBoundsInset (BorderSize (1)); - Component* const itemHolder = viewport->getViewedComponent(); + Component* const itemHolder = viewport.getViewedComponent(); const int indent = 8; - const int preferredWidth = viewport->getWidth() - viewport->getScrollBarThickness() - indent; + const int preferredWidth = viewport.getWidth() - viewport.getScrollBarThickness() - indent; const int height = toolbar->getThickness(); int x = indent; int y = indent; @@ -56199,7 +56142,7 @@ void ToolbarItemPalette::replaceComponent (ToolbarItemComponent* const comp) tc->setBounds (comp->getBounds()); tc->setStyle (toolbar->getStyle()); tc->setEditingMode (comp->getEditingMode()); - viewport->getViewedComponent()->addAndMakeVisible (tc, getIndexOfChildComponent (comp)); + viewport.getViewedComponent()->addAndMakeVisible (tc, getIndexOfChildComponent (comp)); } } @@ -56223,7 +56166,6 @@ public: ~TreeViewContentComponent() { - deleteAllChildren(); } void mouseDown (const MouseEvent& e) @@ -56378,7 +56320,10 @@ public: const int visibleTop = -getY(); const int visibleBottom = visibleTop + getParentHeight(); - BigInteger itemsToKeep; + { + for (int i = items.size(); --i >= 0;) + items.getUnchecked(i)->shouldKeep = false; + } { TreeViewItem* item = owner.rootItem; @@ -56390,66 +56335,56 @@ public: if (y >= visibleTop) { - const int index = rowComponentIds.indexOf (item->uid); + RowItem* const ri = findItem (item->uid); - if (index < 0) + if (ri != 0) + { + ri->shouldKeep = true; + } + else { Component* const comp = item->createItemComponent(); if (comp != 0) { + items.add (new RowItem (item, comp, item->uid)); addAndMakeVisible (comp); - itemsToKeep.setBit (rowComponentItems.size()); - rowComponentItems.add (item); - rowComponentIds.add (item->uid); - rowComponents.add (comp); } } - else - { - itemsToKeep.setBit (index); - } } item = item->getNextVisibleItem (true); } } - for (int i = rowComponentItems.size(); --i >= 0;) + for (int i = items.size(); --i >= 0;) { - Component* const comp = rowComponents.getUnchecked(i); + RowItem* const ri = items.getUnchecked(i); bool keep = false; - if (isParentOf (comp)) + if (isParentOf (ri->component)) { - if (itemsToKeep[i]) + if (ri->shouldKeep) { - const TreeViewItem* const item = rowComponentItems.getUnchecked(i); - - Rectangle pos (item->getItemPosition (false)); - pos.setSize (pos.getWidth(), item->itemHeight); + Rectangle pos (ri->item->getItemPosition (false)); + pos.setSize (pos.getWidth(), ri->item->itemHeight); if (pos.getBottom() >= visibleTop && pos.getY() < visibleBottom) { keep = true; - comp->setBounds (pos); + ri->component->setBounds (pos); } } - if ((! keep) && isMouseDraggingInChildCompOf (comp)) + if ((! keep) && isMouseDraggingInChildCompOf (ri->component)) { keep = true; - comp->setSize (0, 0); + ri->component->setSize (0, 0); } } if (! keep) - { - delete comp; - rowComponents.remove (i); - rowComponentIds.remove (i); - rowComponentItems.remove (i); - } + items.remove (i); } } @@ -56514,9 +56449,27 @@ public: private: TreeView& owner; - Array rowComponentItems; - Array rowComponentIds; - Array rowComponents; + + struct RowItem + { + RowItem (TreeViewItem* const item_, Component* const component_, const int itemUID) + : component (component_), item (item_), uid (itemUID), shouldKeep (true) + { + } + + ~RowItem() + { + component.deleteAndZero(); + } + + Component::SafePointer component; + TreeViewItem* item; + int uid; + bool shouldKeep; + }; + + OwnedArray items; + TreeViewItem* buttonUnderMouse; bool isDragging, needSelectionOnMouseUp; @@ -56550,15 +56503,27 @@ private: } } - bool containsItem (TreeViewItem* const item) const + bool containsItem (TreeViewItem* const item) const throw() { - for (int i = rowComponentItems.size(); --i >= 0;) - if (rowComponentItems.getUnchecked(i) == item) + for (int i = items.size(); --i >= 0;) + if (items.getUnchecked(i)->item == item) return true; return false; } + RowItem* findItem (const int uid) const throw() + { + for (int i = items.size(); --i >= 0;) + { + RowItem* const ri = items.getUnchecked(i); + if (ri->uid == uid) + return ri; + } + + return 0; + } + static bool isMouseDraggingInChildCompOf (Component* const comp) { for (int i = Desktop::getInstance().getNumMouseSources(); --i >= 0;) @@ -57021,8 +56986,6 @@ public: setInterceptsMouseClicks (false, false); } - ~InsertPointHighlight() {} - void setTargetPosition (TreeViewItem* const item, int insertIndex, const int x, const int y, const int width) throw() { lastItem = item; @@ -57060,8 +57023,6 @@ public: setInterceptsMouseClicks (false, false); } - ~TargetGroupHighlight() {} - void setTargetPosition (TreeViewItem* const item) throw() { Rectangle r (item->getItemPosition (true)); @@ -57378,7 +57339,6 @@ void TreeViewItem::setOpen (const bool shouldBeOpen) { openness = shouldBeOpen ? opennessOpen : opennessClosed; - treeHasChanged(); itemOpennessChanged (isOpen()); @@ -57690,21 +57650,19 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) bool TreeViewItem::isLastOfSiblings() const throw() { return parentItem == 0 - || parentItem->subItems.getLast() == this; + || parentItem->subItems.getLast() == this; } int TreeViewItem::getIndexInParent() const throw() { - if (parentItem == 0) - return 0; - - return parentItem->subItems.indexOf (this); + return parentItem == 0 ? 0 + : parentItem->subItems.indexOf (this); } TreeViewItem* TreeViewItem::getTopLevelItem() throw() { - return (parentItem == 0) ? this - : parentItem->getTopLevelItem(); + return parentItem == 0 ? this + : parentItem->getTopLevelItem(); } int TreeViewItem::getNumRows() const throw() @@ -57778,10 +57736,7 @@ TreeViewItem* TreeViewItem::findItemRecursively (int targetY) throw() int TreeViewItem::countSelectedItemsRecursively() const throw() { - int total = 0; - - if (isSelected()) - ++total; + int total = isSelected() ? 1 : 0; for (int i = subItems.size(); --i >= 0;) total += subItems.getUnchecked(i)->countSelectedItemsRecursively(); @@ -58266,6 +58221,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_, fileFilter (fileFilter_), flags (flags_), previewComp (previewComp_), + currentPathBox ("path"), + fileLabel ("f", TRANS ("file:")), thread ("Juce FileBrowser") { // You need to specify one or other of the open/save flags.. @@ -58297,29 +58254,29 @@ FileBrowserComponent::FileBrowserComponent (int flags_, if ((flags & useTreeView) != 0) { FileTreeComponent* const tree = new FileTreeComponent (*fileList); + fileListComponent = tree; if ((flags & canSelectMultipleItems) != 0) tree->setMultiSelectEnabled (true); addAndMakeVisible (tree); - fileListComponent = tree; } else { FileListComponent* const list = new FileListComponent (*fileList); + fileListComponent = list; list->setOutlineThickness (1); if ((flags & canSelectMultipleItems) != 0) list->setMultipleSelectionEnabled (true); addAndMakeVisible (list); - fileListComponent = list; } fileListComponent->addListener (this); - addAndMakeVisible (currentPathBox = new ComboBox ("path")); - currentPathBox->setEditableText (true); + addAndMakeVisible (¤tPathBox); + currentPathBox.setEditableText (true); StringArray rootNames, rootPaths; const BigInteger separators (getRoots (rootNames, rootPaths)); @@ -58327,28 +58284,25 @@ FileBrowserComponent::FileBrowserComponent (int flags_, for (int i = 0; i < rootNames.size(); ++i) { if (separators [i]) - currentPathBox->addSeparator(); + currentPathBox.addSeparator(); - currentPathBox->addItem (rootNames[i], i + 1); + currentPathBox.addItem (rootNames[i], i + 1); } - currentPathBox->addSeparator(); - currentPathBox->addListener (this); + currentPathBox.addSeparator(); + currentPathBox.addListener (this); - addAndMakeVisible (filenameBox = new TextEditor()); - filenameBox->setMultiLine (false); - filenameBox->setSelectAllWhenFocused (true); - filenameBox->setText (filename, false); + addAndMakeVisible (&filenameBox); + filenameBox.setMultiLine (false); + filenameBox.setSelectAllWhenFocused (true); + filenameBox.setText (filename, false); + filenameBox.addListener (this); + filenameBox.setReadOnly ((flags & (filenameBoxIsReadOnly | canSelectMultipleItems)) != 0); - filenameBox->addListener (this); - filenameBox->setReadOnly ((flags & (filenameBoxIsReadOnly | canSelectMultipleItems)) != 0); - - Label* label = new Label ("f", TRANS("file:")); - addAndMakeVisible (label); - label->attachToComponent (filenameBox, true); + addAndMakeVisible (&fileLabel); + fileLabel.attachToComponent (&filenameBox, true); addAndMakeVisible (goUpButton = getLookAndFeel().createFileBrowserGoUpButton()); - goUpButton->addButtonListener (this); goUpButton->setTooltip (TRANS ("go up to parent directory")); @@ -58362,10 +58316,6 @@ FileBrowserComponent::FileBrowserComponent (int flags_, FileBrowserComponent::~FileBrowserComponent() { - if (previewComp != 0) - removeChildComponent (previewComp); - - deleteAllChildren(); fileList = 0; thread.stopThread (10000); } @@ -58395,11 +58345,11 @@ int FileBrowserComponent::getNumSelectedFiles() const throw() const File FileBrowserComponent::getSelectedFile (int index) const throw() { - if ((flags & canSelectDirectories) != 0 && filenameBox->getText().isEmpty()) + if ((flags & canSelectDirectories) != 0 && filenameBox.getText().isEmpty()) return currentRoot; - if (! filenameBox->isReadOnly()) - return currentRoot.getChildFile (filenameBox->getText()); + if (! filenameBox.isReadOnly()) + return currentRoot.getChildFile (filenameBox.getText()); return chosenFiles[index]; } @@ -58424,8 +58374,7 @@ void FileBrowserComponent::deselectAllFiles() bool FileBrowserComponent::isFileSuitable (const File& file) const { - return (flags & canSelectFiles) != 0 ? (fileFilter == 0 || fileFilter->isFileSuitable (file)) - : false; + return (flags & canSelectFiles) != 0 && (fileFilter == 0 || fileFilter->isFileSuitable (file)); } bool FileBrowserComponent::isDirectorySuitable (const File&) const @@ -58439,7 +58388,7 @@ bool FileBrowserComponent::isFileOrDirSuitable (const File& f) const return (flags & canSelectDirectories) != 0 && (fileFilter == 0 || fileFilter->isDirectorySuitable (f)); return (flags & canSelectFiles) != 0 && f.exists() - && (fileFilter == 0 || fileFilter->isFileSuitable (f)); + && (fileFilter == 0 || fileFilter->isFileSuitable (f)); } const File FileBrowserComponent::getRoot() const @@ -58465,9 +58414,9 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) { bool alreadyListed = false; - for (int i = currentPathBox->getNumItems(); --i >= 0;) + for (int i = currentPathBox.getNumItems(); --i >= 0;) { - if (currentPathBox->getItemText (i).equalsIgnoreCase (path)) + if (currentPathBox.getItemText (i).equalsIgnoreCase (path)) { alreadyListed = true; break; @@ -58475,7 +58424,7 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) } if (! alreadyListed) - currentPathBox->addItem (path, currentPathBox->getNumItems() + 2); + currentPathBox.addItem (path, currentPathBox.getNumItems() + 2); } } @@ -58486,7 +58435,7 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) if (currentRootName.isEmpty()) currentRootName = File::separatorString; - currentPathBox->setText (currentRootName, true); + currentPathBox.setText (currentRootName, true); goUpButton->setEnabled (currentRoot.getParentDirectory().isDirectory() && currentRoot.getParentDirectory() != currentRoot); @@ -58515,9 +58464,8 @@ FilePreviewComponent* FileBrowserComponent::getPreviewComponent() const throw() void FileBrowserComponent::resized() { getLookAndFeel() - .layoutFileBrowserComponent (*this, fileListComponent, - previewComp, currentPathBox, - filenameBox, goUpButton); + .layoutFileBrowserComponent (*this, fileListComponent, previewComp, + ¤tPathBox, &filenameBox, goUpButton); } void FileBrowserComponent::sendListenerChangeMessage() @@ -58556,7 +58504,7 @@ void FileBrowserComponent::selectionChanged() } if (newFilenames.size() > 0) - filenameBox->setText (newFilenames.joinIntoString (", "), false); + filenameBox.setText (newFilenames.joinIntoString (", "), false); sendListenerChangeMessage(); } @@ -58574,7 +58522,7 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) setRoot (f); if ((flags & canSelectDirectories) != 0) - filenameBox->setText (String::empty); + filenameBox.setText (String::empty); } else { @@ -58607,22 +58555,22 @@ void FileBrowserComponent::textEditorTextChanged (TextEditor&) void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&) { - if (filenameBox->getText().containsChar (File::separator)) + if (filenameBox.getText().containsChar (File::separator)) { - const File f (currentRoot.getChildFile (filenameBox->getText())); + const File f (currentRoot.getChildFile (filenameBox.getText())); if (f.isDirectory()) { setRoot (f); chosenFiles.clear(); - filenameBox->setText (String::empty); + filenameBox.setText (String::empty); } else { setRoot (f.getParentDirectory()); chosenFiles.clear(); chosenFiles.add (f); - filenameBox->setText (f.getFileName()); + filenameBox.setText (f.getFileName()); } } else @@ -58648,11 +58596,11 @@ void FileBrowserComponent::buttonClicked (Button*) void FileBrowserComponent::comboBoxChanged (ComboBox*) { - const String newText (currentPathBox->getText().trim().unquoted()); + const String newText (currentPathBox.getText().trim().unquoted()); if (newText.isNotEmpty()) { - const int index = currentPathBox->getSelectedId() - 1; + const int index = currentPathBox.getSelectedId() - 1; StringArray rootNames, rootPaths; getRoots (rootNames, rootPaths); @@ -58705,7 +58653,7 @@ const BigInteger FileBrowserComponent::getRoots (StringArray& rootNames, StringA if (volume.isEmpty()) volume = TRANS("Hard Drive"); - name << " [" << drive.getVolumeLabel() << ']'; + name << " [" << volume << ']'; } else if (drive.isOnCDRomDrive()) { @@ -59550,25 +59498,31 @@ END_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE FileSearchPathListComponent::FileSearchPathListComponent() + : addButton ("+"), + removeButton ("-"), + changeButton (TRANS ("change...")), + upButton (String::empty, DrawableButton::ImageOnButtonBackground), + downButton (String::empty, DrawableButton::ImageOnButtonBackground) { - addAndMakeVisible (listBox = new ListBox (String::empty, this)); - listBox->setColour (ListBox::backgroundColourId, Colours::black.withAlpha (0.02f)); - listBox->setColour (ListBox::outlineColourId, Colours::black.withAlpha (0.1f)); - listBox->setOutlineThickness (1); + listBox.setModel (this); + addAndMakeVisible (&listBox); + listBox.setColour (ListBox::backgroundColourId, Colours::black.withAlpha (0.02f)); + listBox.setColour (ListBox::outlineColourId, Colours::black.withAlpha (0.1f)); + listBox.setOutlineThickness (1); - addAndMakeVisible (addButton = new TextButton ("+")); - addButton->addButtonListener (this); - addButton->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop); + addAndMakeVisible (&addButton); + addButton.addButtonListener (this); + addButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop); - addAndMakeVisible (removeButton = new TextButton ("-")); - removeButton->addButtonListener (this); - removeButton->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop); + addAndMakeVisible (&removeButton); + removeButton.addButtonListener (this); + removeButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop); - addAndMakeVisible (changeButton = new TextButton (TRANS("change..."))); - changeButton->addButtonListener (this); + addAndMakeVisible (&changeButton); + changeButton.addButtonListener (this); - addAndMakeVisible (upButton = new DrawableButton (String::empty, DrawableButton::ImageOnButtonBackground)); - upButton->addButtonListener (this); + addAndMakeVisible (&upButton); + upButton.addButtonListener (this); { Path arrowPath; @@ -59577,11 +59531,11 @@ FileSearchPathListComponent::FileSearchPathListComponent() arrowImage.setFill (Colours::black.withAlpha (0.4f)); arrowImage.setPath (arrowPath); - upButton->setImages (&arrowImage); + upButton.setImages (&arrowImage); } - addAndMakeVisible (downButton = new DrawableButton (String::empty, DrawableButton::ImageOnButtonBackground)); - downButton->addButtonListener (this); + addAndMakeVisible (&downButton); + downButton.addButtonListener (this); { Path arrowPath; @@ -59590,7 +59544,7 @@ FileSearchPathListComponent::FileSearchPathListComponent() arrowImage.setFill (Colours::black.withAlpha (0.4f)); arrowImage.setPath (arrowPath); - downButton->setImages (&arrowImage); + downButton.setImages (&arrowImage); } updateButtons(); @@ -59598,23 +59552,22 @@ FileSearchPathListComponent::FileSearchPathListComponent() FileSearchPathListComponent::~FileSearchPathListComponent() { - deleteAllChildren(); } void FileSearchPathListComponent::updateButtons() { - const bool anythingSelected = listBox->getNumSelectedRows() > 0; + const bool anythingSelected = listBox.getNumSelectedRows() > 0; - removeButton->setEnabled (anythingSelected); - changeButton->setEnabled (anythingSelected); - upButton->setEnabled (anythingSelected); - downButton->setEnabled (anythingSelected); + removeButton.setEnabled (anythingSelected); + changeButton.setEnabled (anythingSelected); + upButton.setEnabled (anythingSelected); + downButton.setEnabled (anythingSelected); } void FileSearchPathListComponent::changed() { - listBox->updateContent(); - listBox->repaint(); + listBox.updateContent(); + listBox.repaint(); updateButtons(); } @@ -59692,18 +59645,18 @@ void FileSearchPathListComponent::resized() { const int buttonH = 22; const int buttonY = getHeight() - buttonH - 4; - listBox->setBounds (2, 2, getWidth() - 4, buttonY - 5); + listBox.setBounds (2, 2, getWidth() - 4, buttonY - 5); - addButton->setBounds (2, buttonY, buttonH, buttonH); - removeButton->setBounds (addButton->getRight(), buttonY, buttonH, buttonH); + addButton.setBounds (2, buttonY, buttonH, buttonH); + removeButton.setBounds (addButton.getRight(), buttonY, buttonH, buttonH); - changeButton->changeWidthToFitText (buttonH); - downButton->setSize (buttonH * 2, buttonH); - upButton->setSize (buttonH * 2, buttonH); + changeButton.changeWidthToFitText (buttonH); + downButton.setSize (buttonH * 2, buttonH); + upButton.setSize (buttonH * 2, buttonH); - downButton->setTopRightPosition (getWidth() - 2, buttonY); - upButton->setTopRightPosition (downButton->getX() - 4, buttonY); - changeButton->setTopRightPosition (upButton->getX() - 8, buttonY); + downButton.setTopRightPosition (getWidth() - 2, buttonY); + upButton.setTopRightPosition (downButton.getX() - 4, buttonY); + changeButton.setTopRightPosition (upButton.getX() - 8, buttonY); } bool FileSearchPathListComponent::isInterestedInFileDrag (const StringArray&) @@ -59719,7 +59672,7 @@ void FileSearchPathListComponent::filesDropped (const StringArray& filenames, in if (f.isDirectory()) { - const int row = listBox->getRowContainingPosition (0, mouseY - listBox->getY()); + const int row = listBox.getRowContainingPosition (0, mouseY - listBox.getY()); path.add (f, row); changed(); } @@ -59728,13 +59681,13 @@ void FileSearchPathListComponent::filesDropped (const StringArray& filenames, in void FileSearchPathListComponent::buttonClicked (Button* button) { - const int currentRow = listBox->getSelectedRow(); + const int currentRow = listBox.getSelectedRow(); - if (button == removeButton) + if (button == &removeButton) { deleteKeyPressed (currentRow); } - else if (button == addButton) + else if (button == &addButton) { File start (defaultBrowseTarget); @@ -59751,28 +59704,28 @@ void FileSearchPathListComponent::buttonClicked (Button* button) path.add (chooser.getResult(), currentRow); } } - else if (button == changeButton) + else if (button == &changeButton) { returnKeyPressed (currentRow); } - else if (button == upButton) + else if (button == &upButton) { if (currentRow > 0 && currentRow < path.getNumPaths()) { const File f (path[currentRow]); path.remove (currentRow); path.add (f, currentRow - 1); - listBox->selectRow (currentRow - 1); + listBox.selectRow (currentRow - 1); } } - else if (button == downButton) + else if (button == &downButton) { if (currentRow >= 0 && currentRow < path.getNumPaths() - 1) { const File f (path[currentRow]); path.remove (currentRow); path.add (f, currentRow + 1); - listBox->selectRow (currentRow + 1); + listBox.selectRow (currentRow + 1); } } @@ -60311,12 +60264,10 @@ BEGIN_JUCE_NAMESPACE // N.B. these two includes are put here deliberately to avoid problems with // old GCCs failing on long include paths -const int maxKeys = 3; - class KeyMappingChangeButton : public Button { public: - KeyMappingChangeButton (KeyMappingEditorComponent* const owner_, + KeyMappingChangeButton (KeyMappingEditorComponent& owner_, const CommandID commandID_, const String& keyName, const int keyNum_) @@ -60328,14 +60279,8 @@ public: setWantsKeyboardFocus (false); setTriggeredOnMouseDown (keyNum >= 0); - if (keyNum_ < 0) - setTooltip (TRANS("adds a new key-mapping")); - else - setTooltip (TRANS("click to change this key-mapping")); - } - - ~KeyMappingChangeButton() - { + setTooltip (keyNum_ < 0 ? TRANS("adds a new key-mapping") + : TRANS("click to change this key-mapping")); } void paintButton (Graphics& g, bool /*isOver*/, bool /*isDown*/) @@ -60358,17 +60303,17 @@ public: if (res == 1) { - owner->assignNewKey (commandID, keyNum); + owner.assignNewKey (commandID, keyNum); } else if (res == 2) { - owner->getMappings()->removeKeyPress (commandID, keyNum); + owner.getMappings()->removeKeyPress (commandID, keyNum); } } else { // + button pressed.. - owner->assignNewKey (commandID, -1); + owner.assignNewKey (commandID, -1); } } @@ -60388,7 +60333,7 @@ public: juce_UseDebuggingNewOperator private: - KeyMappingEditorComponent* const owner; + KeyMappingEditorComponent& owner; const CommandID commandID; const int keyNum; @@ -60399,32 +60344,30 @@ private: class KeyMappingItemComponent : public Component { public: - KeyMappingItemComponent (KeyMappingEditorComponent* const owner_, - const CommandID commandID_) - : owner (owner_), - commandID (commandID_) + KeyMappingItemComponent (KeyMappingEditorComponent& owner_, const CommandID commandID_) + : owner (owner_), commandID (commandID_) { setInterceptsMouseClicks (false, true); - const bool isReadOnly = owner_->isCommandReadOnly (commandID); + const bool isReadOnly = owner.isCommandReadOnly (commandID); - const Array keyPresses (owner_->getMappings()->getKeyPressesAssignedToCommand (commandID)); + const Array keyPresses (owner.getMappings()->getKeyPressesAssignedToCommand (commandID)); - for (int i = 0; i < jmin (maxKeys, keyPresses.size()); ++i) + for (int i = 0; i < jmin ((int) maxNumAssignments, keyPresses.size()); ++i) { KeyMappingChangeButton* const kb - = new KeyMappingChangeButton (owner_, commandID, - owner_->getDescriptionForKeyPress (keyPresses.getReference (i)), i); + = new KeyMappingChangeButton (owner, commandID, + owner.getDescriptionForKeyPress (keyPresses.getReference (i)), i); kb->setEnabled (! isReadOnly); addAndMakeVisible (kb); } KeyMappingChangeButton* const kb - = new KeyMappingChangeButton (owner_, commandID, String::empty, -1); + = new KeyMappingChangeButton (owner, commandID, String::empty, -1); addChildComponent (kb); - kb->setVisible (keyPresses.size() < maxKeys && ! isReadOnly); + kb->setVisible (keyPresses.size() < (int) maxNumAssignments && ! isReadOnly); } ~KeyMappingItemComponent() @@ -60437,7 +60380,7 @@ public: g.setFont (getHeight() * 0.7f); g.setColour (findColour (KeyMappingEditorComponent::textColourId)); - g.drawFittedText (owner->getMappings()->getCommandManager()->getNameOfCommand (commandID), + g.drawFittedText (owner.getMappings()->getCommandManager()->getNameOfCommand (commandID), 4, 0, jmax (40, getChildComponent (0)->getX() - 5), getHeight(), Justification::centredLeft, true); } @@ -60456,10 +60399,12 @@ public: } } + enum { maxNumAssignments = 3 }; + juce_UseDebuggingNewOperator private: - KeyMappingEditorComponent* const owner; + KeyMappingEditorComponent& owner; const CommandID commandID; KeyMappingItemComponent (const KeyMappingItemComponent&); @@ -60469,14 +60414,8 @@ private: class KeyMappingTreeViewItem : public TreeViewItem { public: - KeyMappingTreeViewItem (KeyMappingEditorComponent* const owner_, - const CommandID commandID_) - : owner (owner_), - commandID (commandID_) - { - } - - ~KeyMappingTreeViewItem() + KeyMappingTreeViewItem (KeyMappingEditorComponent& owner_, const CommandID commandID_) + : owner (owner_), commandID (commandID_) { } @@ -60492,7 +60431,7 @@ public: juce_UseDebuggingNewOperator private: - KeyMappingEditorComponent* const owner; + KeyMappingEditorComponent& owner; const CommandID commandID; KeyMappingTreeViewItem (const KeyMappingTreeViewItem&); @@ -60502,14 +60441,8 @@ private: class KeyCategoryTreeViewItem : public TreeViewItem { public: - KeyCategoryTreeViewItem (KeyMappingEditorComponent* const owner_, - const String& name) - : owner (owner_), - categoryName (name) - { - } - - ~KeyCategoryTreeViewItem() + KeyCategoryTreeViewItem (KeyMappingEditorComponent& owner_, const String& name) + : owner (owner_), categoryName (name) { } @@ -60520,7 +60453,7 @@ public: void paintItem (Graphics& g, int width, int height) { g.setFont (height * 0.6f, Font::bold); - g.setColour (owner->findColour (KeyMappingEditorComponent::textColourId)); + g.setColour (owner.findColour (KeyMappingEditorComponent::textColourId)); g.drawText (categoryName, 2, 0, width - 2, height, @@ -60533,11 +60466,11 @@ public: { if (getNumSubItems() == 0) { - Array commands (owner->getMappings()->getCommandManager()->getCommandsInCategory (categoryName)); + Array commands (owner.getMappings()->getCommandManager()->getCommandsInCategory (categoryName)); for (int i = 0; i < commands.size(); ++i) { - if (owner->shouldCommandBeIncluded (commands[i])) + if (owner.shouldCommandBeIncluded (commands[i])) addSubItem (new KeyMappingTreeViewItem (owner, commands[i])); } } @@ -60551,7 +60484,7 @@ public: juce_UseDebuggingNewOperator private: - KeyMappingEditorComponent* owner; + KeyMappingEditorComponent& owner; String categoryName; KeyCategoryTreeViewItem (const KeyCategoryTreeViewItem&); @@ -60659,7 +60592,7 @@ void KeyMappingEditorComponent::changeListenerCallback (void*) ++count; if (count > 0) - addSubItem (new KeyCategoryTreeViewItem (this, categories[i])); + addSubItem (new KeyCategoryTreeViewItem (*this, categories[i])); } if (oldOpenness != 0) @@ -60669,7 +60602,7 @@ void KeyMappingEditorComponent::changeListenerCallback (void*) class KeyEntryWindow : public AlertWindow { public: - KeyEntryWindow (KeyMappingEditorComponent* const owner_) + KeyEntryWindow (KeyMappingEditorComponent& owner_) : AlertWindow (TRANS("New key-mapping"), TRANS("Please press a key combination now..."), AlertWindow::NoIcon), @@ -60693,15 +60626,15 @@ public: bool keyPressed (const KeyPress& key) { lastPress = key; - String message (TRANS("Key: ") + owner->getDescriptionForKeyPress (key)); + String message (TRANS("Key: ") + owner.getDescriptionForKeyPress (key)); - const CommandID previousCommand = owner->getMappings()->findCommandForKeyPress (key); + const CommandID previousCommand = owner.getMappings()->findCommandForKeyPress (key); if (previousCommand != 0) { message << "\n\n" << TRANS("(Currently assigned to \"") - << owner->getMappings()->getCommandManager()->getNameOfCommand (previousCommand) + << owner.getMappings()->getCommandManager()->getNameOfCommand (previousCommand) << "\")"; } @@ -60720,7 +60653,7 @@ public: juce_UseDebuggingNewOperator private: - KeyMappingEditorComponent* owner; + KeyMappingEditorComponent& owner; KeyEntryWindow (const KeyEntryWindow&); KeyEntryWindow& operator= (const KeyEntryWindow&); @@ -60728,7 +60661,7 @@ private: void KeyMappingEditorComponent::assignNewKey (const CommandID commandID, const int index) { - KeyEntryWindow entryWindow (this); + KeyEntryWindow entryWindow (*this); if (entryWindow.runModalLoop() != 0) { @@ -74494,10 +74427,6 @@ public: setRange (0.0, 255.0, 1.0); } - ~ColourComponentSlider() - { - } - const String getTextFromValue (double value) { return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2); @@ -74521,10 +74450,6 @@ public: setInterceptsMouseClicks (false, false); } - ~ColourSpaceMarker() - { - } - void paint (Graphics& g) { g.setColour (Colour::greyLevel (0.1f)); @@ -74541,7 +74466,7 @@ private: class ColourSelector::ColourSpaceView : public Component { public: - ColourSpaceView (ColourSelector* owner_, + ColourSpaceView (ColourSelector& owner_, float& h_, float& s_, float& v_, const int edgeSize) : owner (owner_), @@ -74553,10 +74478,6 @@ public: setMouseCursor (MouseCursor::CrosshairCursor); } - ~ColourSpaceView() - { - } - void paint (Graphics& g) { if (colours.isNull()) @@ -74595,7 +74516,7 @@ public: const float sat = (e.x - edge) / (float) (getWidth() - edge * 2); const float val = 1.0f - (e.y - edge) / (float) (getHeight() - edge * 2); - owner->setSV (sat, val); + owner.setSV (sat, val); } void updateIfNeeded() @@ -74617,7 +74538,7 @@ public: } private: - ColourSelector* const owner; + ColourSelector& owner; float& h; float& s; float& v; @@ -74645,10 +74566,6 @@ public: setInterceptsMouseClicks (false, false); } - ~HueSelectorMarker() - { - } - void paint (Graphics& g) { Path p; @@ -74675,7 +74592,7 @@ private: class ColourSelector::HueSelectorComp : public Component { public: - HueSelectorComp (ColourSelector* owner_, + HueSelectorComp (ColourSelector& owner_, float& h_, float& s_, float& v_, const int edgeSize) : owner (owner_), @@ -74686,10 +74603,6 @@ public: addAndMakeVisible (&marker); } - ~HueSelectorComp() - { - } - void paint (Graphics& g) { const float yScale = 1.0f / (getHeight() - edge * 2); @@ -74718,7 +74631,7 @@ public: { const float hue = (e.y - edge) / (float) (getHeight() - edge * 2); - owner->setHue (hue); + owner.setHue (hue); } void updateIfNeeded() @@ -74727,7 +74640,7 @@ public: } private: - ColourSelector* const owner; + ColourSelector& owner; float& h; float& s; float& v; @@ -74742,19 +74655,14 @@ private: class ColourSelector::SwatchComponent : public Component { public: - SwatchComponent (ColourSelector* owner_, int index_) - : owner (owner_), - index (index_) - { - } - - ~SwatchComponent() + SwatchComponent (ColourSelector& owner_, int index_) + : owner (owner_), index (index_) { } void paint (Graphics& g) { - const Colour colour (owner->getSwatchColour (index)); + const Colour colour (owner.getSwatchColour (index)); g.fillCheckerBoard (getLocalBounds(), 6, 6, Colour (0xffdddddd).overlaidWith (colour), @@ -74772,20 +74680,20 @@ public: if (r == 1) { - owner->setCurrentColour (owner->getSwatchColour (index)); + owner.setCurrentColour (owner.getSwatchColour (index)); } else if (r == 2) { - if (owner->getSwatchColour (index) != owner->getCurrentColour()) + if (owner.getSwatchColour (index) != owner.getCurrentColour()) { - owner->setSwatchColour (index, owner->getCurrentColour()); + owner.setSwatchColour (index, owner.getCurrentColour()); repaint(); } } } private: - ColourSelector* const owner; + ColourSelector& owner; const int index; SwatchComponent (const SwatchComponent&); @@ -74825,8 +74733,8 @@ ColourSelector::ColourSelector (const int flags_, if ((flags & showColourspace) != 0) { - addAndMakeVisible (colourSpace = new ColourSpaceView (this, h, s, v, gapAroundColourSpaceComponent)); - addAndMakeVisible (hueSelector = new HueSelectorComp (this, h, s, v, gapAroundColourSpaceComponent)); + addAndMakeVisible (colourSpace = new ColourSpaceView (*this, h, s, v, gapAroundColourSpaceComponent)); + addAndMakeVisible (hueSelector = new HueSelectorComp (*this, h, s, v, gapAroundColourSpaceComponent)); } update(); @@ -75002,7 +74910,7 @@ void ColourSelector::resized() for (int i = 0; i < numSwatches; ++i) { - SwatchComponent* const sc = new SwatchComponent (this, i); + SwatchComponent* const sc = new SwatchComponent (*this, i); swatchComponents.add (sc); addAndMakeVisible (sc); } @@ -75688,8 +75596,7 @@ BEGIN_JUCE_NAMESPACE class MidiKeyboardUpDownButton : public Button { public: - MidiKeyboardUpDownButton (MidiKeyboardComponent* const owner_, - const int delta_) + MidiKeyboardUpDownButton (MidiKeyboardComponent& owner_, const int delta_) : Button (String::empty), owner (owner_), delta (delta_) @@ -75697,33 +75604,27 @@ public: setOpaque (true); } - ~MidiKeyboardUpDownButton() - { - } - void clicked() { - int note = owner->getLowestVisibleKey(); + int note = owner.getLowestVisibleKey(); if (delta < 0) note = (note - 1) / 12; else note = note / 12 + 1; - owner->setLowestVisibleKey (note * 12); + owner.setLowestVisibleKey (note * 12); } - void paintButton (Graphics& g, - bool isMouseOverButton, - bool isButtonDown) + void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) { - owner->drawUpDownButton (g, getWidth(), getHeight(), - isMouseOverButton, isButtonDown, - delta > 0); + owner.drawUpDownButton (g, getWidth(), getHeight(), + isMouseOverButton, isButtonDown, + delta > 0); } private: - MidiKeyboardComponent* const owner; + MidiKeyboardComponent& owner; const int delta; MidiKeyboardUpDownButton (const MidiKeyboardUpDownButton&); @@ -75751,8 +75652,8 @@ MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& state_, keyMappingOctave (6), octaveNumForMiddleC (3) { - addChildComponent (scrollDown = new MidiKeyboardUpDownButton (this, -1)); - addChildComponent (scrollUp = new MidiKeyboardUpDownButton (this, 1)); + addChildComponent (scrollDown = new MidiKeyboardUpDownButton (*this, -1)); + addChildComponent (scrollUp = new MidiKeyboardUpDownButton (*this, 1)); // initialise with a default set of querty key-mappings.. const char* const keymap = "awsedftgyhujkolp;"; @@ -75770,8 +75671,6 @@ MidiKeyboardComponent::~MidiKeyboardComponent() { state.removeListener (this); jassert (mouseDownNote < 0 && keysPressed.countNumberOfSetBits() == 0); // leaving stuck notes! - - deleteAllChildren(); } void MidiKeyboardComponent::setKeyWidth (const float widthInPixels) @@ -76842,8 +76741,6 @@ PreferencesPanel::PreferencesPanel() PreferencesPanel::~PreferencesPanel() { - currentPage = 0; - deleteAllChildren(); } void PreferencesPanel::addSettingsPage (const String& title, @@ -76851,7 +76748,9 @@ void PreferencesPanel::addSettingsPage (const String& title, const Drawable* overIcon, const Drawable* downIcon) { - DrawableButton* button = new DrawableButton (title, DrawableButton::ImageAboveTextLabel); + DrawableButton* const button = new DrawableButton (title, DrawableButton::ImageAboveTextLabel); + buttons.add (button); + button->setImages (icon, overIcon, downIcon); button->setRadioGroupId (1); button->addButtonListener (this); @@ -76865,9 +76764,7 @@ void PreferencesPanel::addSettingsPage (const String& title, setCurrentPage (title); } -void PreferencesPanel::addSettingsPage (const String& title, - const void* imageData, - const int imageDataSize) +void PreferencesPanel::addSettingsPage (const String& title, const void* imageData, const int imageDataSize) { DrawableImage icon, iconOver, iconDown; icon.setImage (ImageCache::getFromMemory (imageData, imageDataSize)); @@ -76881,62 +76778,19 @@ void PreferencesPanel::addSettingsPage (const String& title, addSettingsPage (title, &icon, &iconOver, &iconDown); } -class PrefsDialogWindow : public DialogWindow -{ -public: - PrefsDialogWindow (const String& dialogtitle, - const Colour& backgroundColour) - : DialogWindow (dialogtitle, backgroundColour, true) - { - } - - ~PrefsDialogWindow() - { - } - - void closeButtonPressed() - { - exitModalState (0); - } - -private: - PrefsDialogWindow (const PrefsDialogWindow&); - PrefsDialogWindow& operator= (const PrefsDialogWindow&); -}; - -void PreferencesPanel::showInDialogBox (const String& dialogtitle, - int dialogWidth, - int dialogHeight, - const Colour& backgroundColour) +void PreferencesPanel::showInDialogBox (const String& dialogTitle, int dialogWidth, int dialogHeight, const Colour& backgroundColour) { setSize (dialogWidth, dialogHeight); - - PrefsDialogWindow dw (dialogtitle, backgroundColour); - - dw.setContentComponent (this, true, true); - dw.centreAroundComponent (0, dw.getWidth(), dw.getHeight()); - dw.runModalLoop(); - dw.setContentComponent (0, false, false); + DialogWindow::showModalDialog (dialogTitle, this, 0, backgroundColour, false); } void PreferencesPanel::resized() { - int x = 0; + for (int i = 0; i < buttons.size(); ++i) + buttons.getUnchecked(i)->setBounds (i * buttonSize, 0, buttonSize, buttonSize); - for (int i = 0; i < getNumChildComponents(); ++i) - { - Component* c = getChildComponent (i); - - if (dynamic_cast (c) == 0) - { - c->setBounds (0, buttonSize + 5, getWidth(), getHeight() - buttonSize - 5); - } - else - { - c->setBounds (x, 0, buttonSize, buttonSize); - x += buttonSize; - } - } + if (currentPage != 0) + currentPage->setBounds (getLocalBounds().withTop (buttonSize + 5)); } void PreferencesPanel::paint (Graphics& g) @@ -76961,13 +76815,11 @@ void PreferencesPanel::setCurrentPage (const String& pageName) resized(); } - for (int i = 0; i < getNumChildComponents(); ++i) + for (int i = 0; i < buttons.size(); ++i) { - DrawableButton* db = dynamic_cast (getChildComponent (i)); - - if (db != 0 && db->getName() == pageName) + if (buttons.getUnchecked(i)->getName() == pageName) { - db->setToggleState (true, false); + buttons.getUnchecked(i)->setToggleState (true, false); break; } } @@ -76976,13 +76828,11 @@ void PreferencesPanel::setCurrentPage (const String& pageName) void PreferencesPanel::buttonClicked (Button*) { - for (int i = 0; i < getNumChildComponents(); ++i) + for (int i = 0; i < buttons.size(); ++i) { - DrawableButton* db = dynamic_cast (getChildComponent (i)); - - if (db != 0 && db->getToggleState()) + if (buttons.getUnchecked(i)->getToggleState()) { - setCurrentPage (db->getName()); + setCurrentPage (buttons.getUnchecked(i)->getName()); break; } } @@ -273392,7 +273242,11 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r) Rectangle pos (convertToRectInt (r)); Rectangle original (convertToRectInt (current)); + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_6 if ([window inLiveResize]) + #else + if ([window performSelector: @selector (inLiveResize)]) + #endif { constrainer->checkBounds (pos, original, Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 41e78b4f19..9ab280ecb2 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 81 +#define JUCE_BUILDNUMBER 82 /** Current Juce version number. @@ -21128,6 +21128,7 @@ public: /** Moves the x position, adjusting the width so that the right-hand edge remains in the same place. If the x is moved to be on the right of the current right-hand edge, the width will be set to zero. + @see withLeft */ void setLeft (const ValueType newLeft) throw() { @@ -21135,8 +21136,15 @@ public: x = newLeft; } + /** Returns a new rectangle with a different x position, but the same right-hand edge as this one. + If the new x is beyond the right of the current right-hand edge, the width will be set to zero. + @see setLeft + */ + const Rectangle withLeft (const ValueType newLeft) const throw() { return Rectangle (newLeft, y, jmax (ValueType(), x + w - newLeft), h); } + /** Moves the y position, adjusting the height so that the bottom edge remains in the same place. If the y is moved to be below the current bottom edge, the height will be set to zero. + @see withTop */ void setTop (const ValueType newTop) throw() { @@ -21144,9 +21152,15 @@ public: y = newTop; } + /** Returns a new rectangle with a different y position, but the same bottom edge as this one. + If the new y is beyond the bottom of the current rectangle, the height will be set to zero. + @see setTop + */ + const Rectangle withTop (const ValueType newTop) const throw() { return Rectangle (x, newTop, w, jmax (ValueType(), y + h - newTop)); } + /** Adjusts the width so that the right-hand edge of the rectangle has this new value. If the new right is below the current X value, the X will be pushed down to match it. - @see getRight + @see getRight, withRight */ void setRight (const ValueType newRight) throw() { @@ -21154,9 +21168,15 @@ public: w = newRight - x; } + /** Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one. + If the new right edge is below the current left-hand edge, the width will be set to zero. + @see setRight + */ + const Rectangle withRight (const ValueType newRight) const throw() { return Rectangle (jmin (x, newRight), y, jmax (ValueType(), newRight - x), h); } + /** Adjusts the height so that the bottom edge of the rectangle has this new value. If the new bottom is lower than the current Y value, the Y will be pushed down to match it. - @see getBottom + @see getBottom, withBottom */ void setBottom (const ValueType newBottom) throw() { @@ -21164,6 +21184,12 @@ public: h = newBottom - y; } + /** Returns a new rectangle with a different bottom edge position, but the same top edge as this one. + If the new y is beyond the bottom of the current rectangle, the height will be set to zero. + @see setBottom + */ + const Rectangle withBottom (const ValueType newBottom) const throw() { return Rectangle (x, jmin (y, newBottom), w, jmax (ValueType(), newBottom - y)); } + /** Moves the rectangle's position by adding amount to its x and y co-ordinates. */ void translate (const ValueType deltaX, const ValueType deltaY) throw() @@ -41867,8 +41893,8 @@ public: private: KnownPluginList& list; File deadMansPedalFile; - ListBox* listBox; - TextButton* optionsButton; + ListBox listBox; + TextButton optionsButton; PropertiesFile* propertiesToUse; int typeToScan; @@ -46797,10 +46823,11 @@ private: CodeDocument::Position caretPos; CodeDocument::Position selectionStart, selectionEnd; + class CaretComponent; - CaretComponent* caret; - ScrollBar* verticalScrollBar; - ScrollBar* horizontalScrollBar; + friend class ScopedPointer ; + ScopedPointer caret; + ScrollBar verticalScrollBar, horizontalScrollBar; enum DragType { @@ -48628,7 +48655,7 @@ public: private: ToolbarItemFactory& factory; Toolbar* toolbar; - Viewport* viewport; + Viewport viewport; friend class Toolbar; void replaceComponent (ToolbarItemComponent* comp); @@ -50045,11 +50072,12 @@ private: Array chosenFiles; ListenerList listeners; - DirectoryContentsDisplayComponent* fileListComponent; + ScopedPointer fileListComponent; FilePreviewComponent* previewComp; - ComboBox* currentPathBox; - TextEditor* filenameBox; - Button* goUpButton; + ComboBox currentPathBox; + TextEditor filenameBox; + Label fileLabel; + ScopedPointer