| @@ -150,6 +150,8 @@ public: | |||
| ~TreeViewDemo() | |||
| { | |||
| fileTreeComp = 0; | |||
| directoryList = 0; // (need to make sure this is deleted before the TimeSliceThread) | |||
| } | |||
| void paint (Graphics& g) | |||
| @@ -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) | |||
| @@ -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), | |||
| @@ -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 <CaretComponent>; | |||
| ScopedPointer<CaretComponent> 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<File> chosenFiles; | |||
| ListenerList <FileBrowserListener> listeners; | |||
| DirectoryContentsDisplayComponent* fileListComponent; | |||
| ScopedPointer<DirectoryContentsDisplayComponent> fileListComponent; | |||
| FilePreviewComponent* previewComp; | |||
| ComboBox* currentPathBox; | |||
| TextEditor* filenameBox; | |||
| Button* goUpButton; | |||
| ComboBox currentPathBox; | |||
| TextEditor filenameBox; | |||
| Label fileLabel; | |||
| ScopedPointer<Button> goUpButton; | |||
| TimeSliceThread thread; | |||
| @@ -51944,9 +51972,7 @@ class JUCE_API FileSearchPathListComponent : public Component, | |||
| { | |||
| public: | |||
| /** Creates an empty FileSearchPathListComponent. | |||
| */ | |||
| /** Creates an empty FileSearchPathListComponent. */ | |||
| FileSearchPathListComponent(); | |||
| /** Destructor. */ | |||
| @@ -52007,12 +52033,9 @@ private: | |||
| FileSearchPath path; | |||
| File defaultBrowseTarget; | |||
| ListBox* listBox; | |||
| Button* addButton; | |||
| Button* removeButton; | |||
| TextButton* changeButton; | |||
| DrawableButton* upButton; | |||
| DrawableButton* downButton; | |||
| ListBox listBox; | |||
| TextButton addButton, removeButton, changeButton; | |||
| DrawableButton upButton, downButton; | |||
| void changed(); | |||
| void updateButtons(); | |||
| @@ -57860,8 +57883,7 @@ private: | |||
| int rangeStart, rangeEnd, firstKey; | |||
| bool canScroll, mouseDragging, useMousePositionForVelocity; | |||
| Button* scrollDown; | |||
| Button* scrollUp; | |||
| ScopedPointer<Button> scrollDown, scrollUp; | |||
| Array <KeyPress> keyPresses; | |||
| Array <int> keyPressNotes; | |||
| @@ -58368,7 +58390,7 @@ public: | |||
| given size and title, and will run it modally, returning when the user | |||
| closes the dialog box. | |||
| */ | |||
| void showInDialogBox (const String& dialogtitle, | |||
| void showInDialogBox (const String& dialogTitle, | |||
| int dialogWidth, | |||
| int dialogHeight, | |||
| const Colour& backgroundColour = Colours::white); | |||
| @@ -58399,6 +58421,7 @@ private: | |||
| String currentPageName; | |||
| ScopedPointer <Component> currentPage; | |||
| OwnedArray<DrawableButton> buttons; | |||
| int buttonSize; | |||
| PreferencesPanel (const PreferencesPanel&); | |||
| @@ -62506,12 +62529,12 @@ class UnitTestRunner; | |||
| @see UnitTestRunner | |||
| */ | |||
| class UnitTest | |||
| class JUCE_API UnitTest | |||
| { | |||
| public: | |||
| /** Creates a test with the given name. */ | |||
| UnitTest (const String& name); | |||
| explicit UnitTest (const String& name); | |||
| /** Destructor. */ | |||
| virtual ~UnitTest(); | |||
| @@ -62615,7 +62638,7 @@ private: | |||
| @see UnitTest | |||
| */ | |||
| class UnitTestRunner | |||
| class JUCE_API UnitTestRunner | |||
| { | |||
| public: | |||
| @@ -43,13 +43,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); | |||
| @@ -59,20 +61,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() | |||
| @@ -130,14 +131,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")); | |||
| @@ -153,7 +154,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) | |||
| { | |||
| @@ -173,7 +174,7 @@ void PluginListComponent::buttonClicked (Button* b) | |||
| } | |||
| else if (r == 5) | |||
| { | |||
| const SparseSet <int> selected (listBox->getSelectedRows()); | |||
| const SparseSet <int> selected (listBox.getSelectedRows()); | |||
| for (int i = list.getNumTypes(); --i >= 0;) | |||
| if (selected.contains (i)) | |||
| @@ -181,7 +182,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) | |||
| { | |||
| @@ -86,8 +86,8 @@ public: | |||
| private: | |||
| KnownPluginList& list; | |||
| File deadMansPedalFile; | |||
| ListBox* listBox; | |||
| TextButton* optionsButton; | |||
| ListBox listBox; | |||
| TextButton optionsButton; | |||
| PropertiesFile* propertiesToUse; | |||
| int typeToScan; | |||
| @@ -33,7 +33,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 52 | |||
| #define JUCE_BUILDNUMBER 81 | |||
| #define JUCE_BUILDNUMBER 82 | |||
| /** Current Juce version number. | |||
| @@ -44,10 +44,6 @@ public: | |||
| setInterceptsMouseClicks (false, false); | |||
| } | |||
| ~CaretComponent() | |||
| { | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| g.fillAll (findColour (CodeEditorComponent::caretColourId)); | |||
| @@ -296,6 +292,8 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_, | |||
| columnToTryToMaintain (-1), | |||
| useSpacesForTabs (false), | |||
| xOffset (0), | |||
| verticalScrollBar (true), | |||
| horizontalScrollBar (false), | |||
| codeTokeniser (codeTokeniser_) | |||
| { | |||
| caretPos = CodeDocument::Position (&document_, 0, 0); | |||
| @@ -311,11 +309,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)); | |||
| @@ -325,15 +323,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) | |||
| @@ -383,8 +380,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(); | |||
| } | |||
| @@ -394,7 +391,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(); | |||
| @@ -468,7 +465,7 @@ void CodeEditorComponent::rebuildLineTokens() | |||
| if (minLineToRepaint <= maxLineToRepaint) | |||
| { | |||
| repaint (gutter, lineHeight * minLineToRepaint - 1, | |||
| verticalScrollBar->getX() - gutter, | |||
| verticalScrollBar.getX() - gutter, | |||
| lineHeight * (1 + maxLineToRepaint - minLineToRepaint) + 2); | |||
| } | |||
| } | |||
| @@ -540,11 +537,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) | |||
| @@ -1079,11 +1076,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 | |||
| { | |||
| @@ -1093,7 +1090,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); | |||
| @@ -271,10 +271,11 @@ private: | |||
| CodeDocument::Position caretPos; | |||
| CodeDocument::Position selectionStart, selectionEnd; | |||
| class CaretComponent; | |||
| CaretComponent* caret; | |||
| ScrollBar* verticalScrollBar; | |||
| ScrollBar* horizontalScrollBar; | |||
| friend class ScopedPointer <CaretComponent>; | |||
| ScopedPointer<CaretComponent> caret; | |||
| ScrollBar verticalScrollBar, horizontalScrollBar; | |||
| enum DragType | |||
| { | |||
| @@ -39,18 +39,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) | |||
| @@ -68,20 +61,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()); | |||
| } | |||
| } | |||
| } | |||
| @@ -145,8 +130,8 @@ public: | |||
| void resized() | |||
| { | |||
| if (getNumChildComponents() > 0) | |||
| getChildComponent(0)->setBounds (getLocalBounds()); | |||
| if (customComponent != 0) | |||
| customComponent->setBounds (getLocalBounds()); | |||
| } | |||
| const String getTooltip() | |||
| @@ -159,7 +144,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| bool neededFlag; | |||
| ScopedPointer<Component> customComponent; | |||
| private: | |||
| ListBox& owner; | |||
| @@ -175,36 +160,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 <ListBoxRowComponent*> | |||
| (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) | |||
| @@ -213,12 +199,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); | |||
| @@ -256,18 +236,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; | |||
| @@ -295,6 +270,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()) | |||
| @@ -323,6 +342,9 @@ public: | |||
| private: | |||
| ListBox& owner; | |||
| OwnedArray<ListBoxRowComponent> rows; | |||
| int firstIndex, firstWholeIndex, lastWholeIndex; | |||
| bool hasUpdated; | |||
| ListViewport (const ListViewport&); | |||
| ListViewport& operator= (const ListViewport&); | |||
| @@ -467,34 +489,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); | |||
| @@ -645,8 +641,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 <Component*> (listRowComp->customComponent) : 0; | |||
| } | |||
| int ListBox::getRowNumberOfComponent (Component* const rowComponent) const throw() | |||
| @@ -689,16 +685,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()); | |||
| } | |||
| //============================================================================== | |||
| @@ -951,43 +938,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<int>&) | |||
| { | |||
| 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<int>&) { return String::empty; } | |||
| const String ListBoxModel::getTooltipForRow (int) { return String::empty; } | |||
| END_JUCE_NAMESPACE | |||
| @@ -272,16 +272,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(); | |||
| } | |||
| @@ -290,11 +286,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(); | |||
| } | |||
| @@ -309,6 +305,8 @@ public: | |||
| private: | |||
| TableListBox& owner; | |||
| enum { autoSizeColumnId = 0xf836743, autoSizeAllId = 0xf836744 }; | |||
| TableListBoxHeader (const TableListBoxHeader&); | |||
| TableListBoxHeader& operator= (const TableListBoxHeader&); | |||
| }; | |||
| @@ -791,63 +791,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); | |||
| 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); | |||
| styleBox->addListener (this); | |||
| 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); | |||
| 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.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); | |||
| palette->resized(); // to make it update the styles | |||
| 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 | |||
| } | |||
| void buttonClicked (Button*) | |||
| @@ -865,33 +861,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); | |||
| if (defaultButton != 0) | |||
| { | |||
| defaultButton->changeWidthToFitText (22); | |||
| defaultButton->setTopLeftPosition (240, getHeight() - 110); | |||
| } | |||
| 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; | |||
| }; | |||
| }; | |||
| @@ -38,6 +38,7 @@ ToolbarItemPalette::ToolbarItemPalette (ToolbarItemFactory& factory_, | |||
| toolbar (toolbar_) | |||
| { | |||
| Component* const itemHolder = new Component(); | |||
| viewport.setViewedComponent (itemHolder); | |||
| Array <int> allIds; | |||
| factory_.getAllToolbarItemIds (allIds); | |||
| @@ -54,27 +55,24 @@ 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; | |||
| @@ -120,7 +118,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)); | |||
| } | |||
| } | |||
| @@ -68,7 +68,7 @@ public: | |||
| private: | |||
| ToolbarItemFactory& factory; | |||
| Toolbar* toolbar; | |||
| Viewport* viewport; | |||
| Viewport viewport; | |||
| friend class Toolbar; | |||
| void replaceComponent (ToolbarItemComponent* comp); | |||
| @@ -49,7 +49,6 @@ public: | |||
| ~TreeViewContentComponent() | |||
| { | |||
| deleteAllChildren(); | |||
| } | |||
| void mouseDown (const MouseEvent& e) | |||
| @@ -204,7 +203,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; | |||
| @@ -216,66 +218,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<int> pos (item->getItemPosition (false)); | |||
| pos.setSize (pos.getWidth(), item->itemHeight); | |||
| Rectangle<int> 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); | |||
| } | |||
| } | |||
| @@ -341,9 +333,27 @@ public: | |||
| private: | |||
| TreeView& owner; | |||
| Array <TreeViewItem*> rowComponentItems; | |||
| Array <int> rowComponentIds; | |||
| Array <Component*> 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> component; | |||
| TreeViewItem* item; | |||
| int uid; | |||
| bool shouldKeep; | |||
| }; | |||
| OwnedArray <RowItem> items; | |||
| TreeViewItem* buttonUnderMouse; | |||
| bool isDragging, needSelectionOnMouseUp; | |||
| @@ -377,15 +387,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;) | |||
| @@ -856,8 +878,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; | |||
| @@ -896,8 +916,6 @@ public: | |||
| setInterceptsMouseClicks (false, false); | |||
| } | |||
| ~TargetGroupHighlight() {} | |||
| void setTargetPosition (TreeViewItem* const item) throw() | |||
| { | |||
| Rectangle<int> r (item->getItemPosition (true)); | |||
| @@ -1217,7 +1235,6 @@ void TreeViewItem::setOpen (const bool shouldBeOpen) | |||
| { | |||
| openness = shouldBeOpen ? opennessOpen | |||
| : opennessClosed; | |||
| treeHasChanged(); | |||
| itemOpennessChanged (isOpen()); | |||
| @@ -1530,21 +1547,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() | |||
| @@ -1618,10 +1633,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(); | |||
| @@ -45,6 +45,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.. | |||
| @@ -76,29 +78,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)); | |||
| @@ -106,28 +108,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")); | |||
| @@ -141,10 +140,6 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||
| FileBrowserComponent::~FileBrowserComponent() | |||
| { | |||
| if (previewComp != 0) | |||
| removeChildComponent (previewComp); | |||
| deleteAllChildren(); | |||
| fileList = 0; | |||
| thread.stopThread (10000); | |||
| } | |||
| @@ -176,11 +171,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]; | |||
| } | |||
| @@ -206,8 +201,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 | |||
| @@ -221,7 +215,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)); | |||
| } | |||
| //============================================================================== | |||
| @@ -248,9 +242,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; | |||
| @@ -258,7 +252,7 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) | |||
| } | |||
| if (! alreadyListed) | |||
| currentPathBox->addItem (path, currentPathBox->getNumItems() + 2); | |||
| currentPathBox.addItem (path, currentPathBox.getNumItems() + 2); | |||
| } | |||
| } | |||
| @@ -269,7 +263,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); | |||
| @@ -299,9 +293,8 @@ FilePreviewComponent* FileBrowserComponent::getPreviewComponent() const throw() | |||
| void FileBrowserComponent::resized() | |||
| { | |||
| getLookAndFeel() | |||
| .layoutFileBrowserComponent (*this, fileListComponent, | |||
| previewComp, currentPathBox, | |||
| filenameBox, goUpButton); | |||
| .layoutFileBrowserComponent (*this, fileListComponent, previewComp, | |||
| ¤tPathBox, &filenameBox, goUpButton); | |||
| } | |||
| //============================================================================== | |||
| @@ -341,7 +334,7 @@ void FileBrowserComponent::selectionChanged() | |||
| } | |||
| if (newFilenames.size() > 0) | |||
| filenameBox->setText (newFilenames.joinIntoString (", "), false); | |||
| filenameBox.setText (newFilenames.joinIntoString (", "), false); | |||
| sendListenerChangeMessage(); | |||
| } | |||
| @@ -359,7 +352,7 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) | |||
| setRoot (f); | |||
| if ((flags & canSelectDirectories) != 0) | |||
| filenameBox->setText (String::empty); | |||
| filenameBox.setText (String::empty); | |||
| } | |||
| else | |||
| { | |||
| @@ -393,22 +386,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 | |||
| @@ -436,11 +429,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); | |||
| @@ -493,7 +486,7 @@ const BigInteger FileBrowserComponent::getRoots (StringArray& rootNames, StringA | |||
| if (volume.isEmpty()) | |||
| volume = TRANS("Hard Drive"); | |||
| name << " [" << drive.getVolumeLabel() << ']'; | |||
| name << " [" << volume << ']'; | |||
| } | |||
| else if (drive.isOnCDRomDrive()) | |||
| { | |||
| @@ -219,11 +219,12 @@ private: | |||
| Array<File> chosenFiles; | |||
| ListenerList <FileBrowserListener> listeners; | |||
| DirectoryContentsDisplayComponent* fileListComponent; | |||
| ScopedPointer<DirectoryContentsDisplayComponent> fileListComponent; | |||
| FilePreviewComponent* previewComp; | |||
| ComboBox* currentPathBox; | |||
| TextEditor* filenameBox; | |||
| Button* goUpButton; | |||
| ComboBox currentPathBox; | |||
| TextEditor filenameBox; | |||
| Label fileLabel; | |||
| ScopedPointer<Button> goUpButton; | |||
| TimeSliceThread thread; | |||
| @@ -36,25 +36,31 @@ 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; | |||
| @@ -63,11 +69,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; | |||
| @@ -76,7 +82,7 @@ FileSearchPathListComponent::FileSearchPathListComponent() | |||
| arrowImage.setFill (Colours::black.withAlpha (0.4f)); | |||
| arrowImage.setPath (arrowPath); | |||
| downButton->setImages (&arrowImage); | |||
| downButton.setImages (&arrowImage); | |||
| } | |||
| updateButtons(); | |||
| @@ -84,23 +90,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(); | |||
| } | |||
| @@ -180,18 +185,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&) | |||
| @@ -207,7 +212,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(); | |||
| } | |||
| @@ -216,13 +221,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); | |||
| @@ -239,28 +244,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); | |||
| } | |||
| } | |||
| @@ -48,9 +48,7 @@ class JUCE_API FileSearchPathListComponent : public Component, | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Creates an empty FileSearchPathListComponent. | |||
| */ | |||
| /** Creates an empty FileSearchPathListComponent. */ | |||
| FileSearchPathListComponent(); | |||
| /** Destructor. */ | |||
| @@ -114,12 +112,9 @@ private: | |||
| FileSearchPath path; | |||
| File defaultBrowseTarget; | |||
| ListBox* listBox; | |||
| Button* addButton; | |||
| Button* removeButton; | |||
| TextButton* changeButton; | |||
| DrawableButton* upButton; | |||
| DrawableButton* downButton; | |||
| ListBox listBox; | |||
| TextButton addButton, removeButton, changeButton; | |||
| DrawableButton upButton, downButton; | |||
| void changed(); | |||
| void updateButtons(); | |||
| @@ -129,5 +124,4 @@ private: | |||
| }; | |||
| #endif // __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__ | |||
| @@ -38,13 +38,12 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../lookandfeel/juce_LookAndFeel.h" | |||
| #include "../../../text/juce_LocalisedStrings.h" | |||
| 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_) | |||
| @@ -56,14 +55,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*/) | |||
| @@ -86,17 +79,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); | |||
| } | |||
| } | |||
| @@ -116,7 +109,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| KeyMappingEditorComponent* const owner; | |||
| KeyMappingEditorComponent& owner; | |||
| const CommandID commandID; | |||
| const int keyNum; | |||
| @@ -128,32 +121,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 <KeyPress> keyPresses (owner_->getMappings()->getKeyPressesAssignedToCommand (commandID)); | |||
| const Array <KeyPress> 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() | |||
| @@ -166,7 +157,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); | |||
| } | |||
| @@ -185,10 +176,12 @@ public: | |||
| } | |||
| } | |||
| enum { maxNumAssignments = 3 }; | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| KeyMappingEditorComponent* const owner; | |||
| KeyMappingEditorComponent& owner; | |||
| const CommandID commandID; | |||
| KeyMappingItemComponent (const KeyMappingItemComponent&); | |||
| @@ -199,14 +192,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_) | |||
| { | |||
| } | |||
| @@ -222,7 +209,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| KeyMappingEditorComponent* const owner; | |||
| KeyMappingEditorComponent& owner; | |||
| const CommandID commandID; | |||
| KeyMappingTreeViewItem (const KeyMappingTreeViewItem&); | |||
| @@ -234,14 +221,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) | |||
| { | |||
| } | |||
| @@ -252,7 +233,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, | |||
| @@ -265,11 +246,11 @@ public: | |||
| { | |||
| if (getNumSubItems() == 0) | |||
| { | |||
| Array <CommandID> commands (owner->getMappings()->getCommandManager()->getCommandsInCategory (categoryName)); | |||
| Array <CommandID> 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])); | |||
| } | |||
| } | |||
| @@ -283,7 +264,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| KeyMappingEditorComponent* owner; | |||
| KeyMappingEditorComponent& owner; | |||
| String categoryName; | |||
| KeyCategoryTreeViewItem (const KeyCategoryTreeViewItem&); | |||
| @@ -394,7 +375,7 @@ void KeyMappingEditorComponent::changeListenerCallback (void*) | |||
| ++count; | |||
| if (count > 0) | |||
| addSubItem (new KeyCategoryTreeViewItem (this, categories[i])); | |||
| addSubItem (new KeyCategoryTreeViewItem (*this, categories[i])); | |||
| } | |||
| if (oldOpenness != 0) | |||
| @@ -405,7 +386,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), | |||
| @@ -429,15 +410,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) | |||
| << "\")"; | |||
| } | |||
| @@ -456,7 +437,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| KeyMappingEditorComponent* owner; | |||
| KeyMappingEditorComponent& owner; | |||
| KeyEntryWindow (const KeyEntryWindow&); | |||
| KeyEntryWindow& operator= (const KeyEntryWindow&); | |||
| @@ -465,7 +446,7 @@ private: | |||
| void KeyMappingEditorComponent::assignNewKey (const CommandID commandID, const int index) | |||
| { | |||
| KeyEntryWindow entryWindow (this); | |||
| KeyEntryWindow entryWindow (*this); | |||
| if (entryWindow.runModalLoop() != 0) | |||
| { | |||
| @@ -44,10 +44,6 @@ public: | |||
| setRange (0.0, 255.0, 1.0); | |||
| } | |||
| ~ColourComponentSlider() | |||
| { | |||
| } | |||
| const String getTextFromValue (double value) | |||
| { | |||
| return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2); | |||
| @@ -72,10 +68,6 @@ public: | |||
| setInterceptsMouseClicks (false, false); | |||
| } | |||
| ~ColourSpaceMarker() | |||
| { | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| g.setColour (Colour::greyLevel (0.1f)); | |||
| @@ -93,7 +85,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_), | |||
| @@ -105,10 +97,6 @@ public: | |||
| setMouseCursor (MouseCursor::CrosshairCursor); | |||
| } | |||
| ~ColourSpaceView() | |||
| { | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| if (colours.isNull()) | |||
| @@ -147,7 +135,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() | |||
| @@ -169,7 +157,7 @@ public: | |||
| } | |||
| private: | |||
| ColourSelector* const owner; | |||
| ColourSelector& owner; | |||
| float& h; | |||
| float& s; | |||
| float& v; | |||
| @@ -198,10 +186,6 @@ public: | |||
| setInterceptsMouseClicks (false, false); | |||
| } | |||
| ~HueSelectorMarker() | |||
| { | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| Path p; | |||
| @@ -229,7 +213,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_), | |||
| @@ -240,10 +224,6 @@ public: | |||
| addAndMakeVisible (&marker); | |||
| } | |||
| ~HueSelectorComp() | |||
| { | |||
| } | |||
| void paint (Graphics& g) | |||
| { | |||
| const float yScale = 1.0f / (getHeight() - edge * 2); | |||
| @@ -272,7 +252,7 @@ public: | |||
| { | |||
| const float hue = (e.y - edge) / (float) (getHeight() - edge * 2); | |||
| owner->setHue (hue); | |||
| owner.setHue (hue); | |||
| } | |||
| void updateIfNeeded() | |||
| @@ -281,7 +261,7 @@ public: | |||
| } | |||
| private: | |||
| ColourSelector* const owner; | |||
| ColourSelector& owner; | |||
| float& h; | |||
| float& s; | |||
| float& v; | |||
| @@ -297,19 +277,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), | |||
| @@ -327,20 +302,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&); | |||
| @@ -381,8 +356,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(); | |||
| @@ -561,7 +536,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); | |||
| } | |||
| @@ -34,8 +34,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_) | |||
| @@ -43,33 +42,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&); | |||
| @@ -98,8 +91,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;"; | |||
| @@ -117,8 +110,6 @@ MidiKeyboardComponent::~MidiKeyboardComponent() | |||
| { | |||
| state.removeListener (this); | |||
| jassert (mouseDownNote < 0 && keysPressed.countNumberOfSetBits() == 0); // leaving stuck notes! | |||
| deleteAllChildren(); | |||
| } | |||
| //============================================================================== | |||
| @@ -396,8 +396,7 @@ private: | |||
| int rangeStart, rangeEnd, firstKey; | |||
| bool canScroll, mouseDragging, useMousePositionForVelocity; | |||
| Button* scrollDown; | |||
| Button* scrollUp; | |||
| ScopedPointer<Button> scrollDown, scrollUp; | |||
| Array <KeyPress> keyPresses; | |||
| Array <int> keyPressNotes; | |||
| @@ -28,7 +28,6 @@ | |||
| BEGIN_JUCE_NAMESPACE | |||
| #include "juce_PreferencesPanel.h" | |||
| #include "../buttons/juce_DrawableButton.h" | |||
| #include "../windows/juce_DialogWindow.h" | |||
| #include "../../graphics/imaging/juce_ImageCache.h" | |||
| #include "../../graphics/drawables/juce_DrawableImage.h" | |||
| @@ -42,8 +41,6 @@ PreferencesPanel::PreferencesPanel() | |||
| PreferencesPanel::~PreferencesPanel() | |||
| { | |||
| currentPage = 0; | |||
| deleteAllChildren(); | |||
| } | |||
| //============================================================================== | |||
| @@ -52,7 +49,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); | |||
| @@ -66,9 +65,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)); | |||
| @@ -83,64 +80,20 @@ void PreferencesPanel::addSettingsPage (const String& title, | |||
| } | |||
| //============================================================================== | |||
| 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 <DrawableButton*> (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) | |||
| @@ -165,13 +118,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 <DrawableButton*> (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; | |||
| } | |||
| } | |||
| @@ -180,13 +131,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 <DrawableButton*> (getChildComponent (i)); | |||
| if (db != 0 && db->getToggleState()) | |||
| if (buttons.getUnchecked(i)->getToggleState()) | |||
| { | |||
| setCurrentPage (db->getName()); | |||
| setCurrentPage (buttons.getUnchecked(i)->getName()); | |||
| break; | |||
| } | |||
| } | |||
| @@ -27,7 +27,7 @@ | |||
| #define __JUCE_PREFERENCESPANEL_JUCEHEADER__ | |||
| #include "../juce_Component.h" | |||
| #include "../buttons/juce_Button.h" | |||
| #include "../buttons/juce_DrawableButton.h" | |||
| #include "../../graphics/drawables/juce_Drawable.h" | |||
| @@ -104,7 +104,7 @@ public: | |||
| given size and title, and will run it modally, returning when the user | |||
| closes the dialog box. | |||
| */ | |||
| void showInDialogBox (const String& dialogtitle, | |||
| void showInDialogBox (const String& dialogTitle, | |||
| int dialogWidth, | |||
| int dialogHeight, | |||
| const Colour& backgroundColour = Colours::white); | |||
| @@ -138,6 +138,7 @@ private: | |||
| //============================================================================== | |||
| String currentPageName; | |||
| ScopedPointer <Component> currentPage; | |||
| OwnedArray<DrawableButton> buttons; | |||
| int buttonSize; | |||
| PreferencesPanel (const PreferencesPanel&); | |||
| @@ -203,6 +203,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() | |||
| { | |||
| @@ -210,8 +211,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() | |||
| { | |||
| @@ -219,9 +227,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() | |||
| { | |||
| @@ -229,9 +243,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() | |||
| { | |||
| @@ -239,6 +259,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, | |||
| @@ -62,7 +62,7 @@ public: | |||
| if (file_.inputSource != 0) | |||
| { | |||
| inputStream = file.inputSource->createInputStream(); | |||
| inputStream = streamToDelete = file.inputSource->createInputStream(); | |||
| } | |||
| else | |||
| { | |||
| @@ -89,9 +89,6 @@ public: | |||
| if (inputStream != 0 && inputStream == file.inputStream) | |||
| file.numOpenStreams--; | |||
| #endif | |||
| if (inputStream != file.inputStream) | |||
| delete inputStream; | |||
| } | |||
| int64 getTotalLength() | |||
| @@ -151,6 +148,7 @@ private: | |||
| int64 pos; | |||
| int headerSize; | |||
| InputStream* inputStream; | |||
| ScopedPointer<InputStream> streamToDelete; | |||
| ZipInputStream (const ZipInputStream&); | |||
| ZipInputStream& operator= (const ZipInputStream&); | |||
| @@ -195,11 +193,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 | |||
| } | |||
| @@ -1072,7 +1072,11 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r) | |||
| Rectangle<int> pos (convertToRectInt (r)); | |||
| Rectangle<int> 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(), | |||
| @@ -69,12 +69,12 @@ class UnitTestRunner; | |||
| @see UnitTestRunner | |||
| */ | |||
| class UnitTest | |||
| class JUCE_API UnitTest | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Creates a test with the given name. */ | |||
| UnitTest (const String& name); | |||
| explicit UnitTest (const String& name); | |||
| /** Destructor. */ | |||
| virtual ~UnitTest(); | |||
| @@ -184,7 +184,7 @@ private: | |||
| @see UnitTest | |||
| */ | |||
| class UnitTestRunner | |||
| class JUCE_API UnitTestRunner | |||
| { | |||
| public: | |||
| //============================================================================== | |||