32 changeButton (
TRANS (
"change...")),
36 listBox.setModel (
this);
37 addAndMakeVisible (listBox);
40 listBox.setOutlineThickness (1);
42 addAndMakeVisible (addButton);
43 addButton.onClick = [
this] { addPath(); };
44 addButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop);
46 addAndMakeVisible (removeButton);
47 removeButton.onClick = [
this] { deleteSelected(); };
48 removeButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop);
50 addAndMakeVisible (changeButton);
51 changeButton.onClick = [
this] { editSelected(); };
53 addAndMakeVisible (upButton);
54 upButton.onClick = [
this] { moveSelection (-1); };
60 arrowPath.addArrow ({ 50.0f, 100.0f, 50.0f, 0.0f }, 40.0f, 100.0f, 50.0f);
68 addAndMakeVisible (downButton);
69 downButton.onClick = [
this] { moveSelection (1); };
73 arrowPath.addArrow ({ 50.0f, 0.0f, 50.0f, 100.0f }, 40.0f, 100.0f, 50.0f);
84void FileSearchPathListComponent::updateButtons()
94void FileSearchPathListComponent::changed()
128 Font f ((
float) height * 0.7f);
133 4, 0, width - 6, height,
148 chooser = std::make_unique<FileChooser> (
TRANS (
"Change folder..."), path.
getRawString (row),
"*");
153 if (
fc.getResult() ==
File{})
157 path.
add (
fc.getResult(), row);
202 for (
int i =
filenames.size(); --i >= 0;)
215void FileSearchPathListComponent::addPath()
217 auto start = defaultBrowseTarget;
225 chooser = std::make_unique<FileChooser> (
TRANS (
"Add a folder..."), start,
"*");
230 if (
fc.getResult() ==
File{})
238void FileSearchPathListComponent::deleteSelected()
244void FileSearchPathListComponent::editSelected()
250void FileSearchPathListComponent::moveSelection (
int delta)
252 jassert (delta == -1 || delta == 1);
int getHeight() const noexcept
Returns the component's height in pixels.
int getX() const noexcept
Returns the x coordinate of the component's left edge.
void setTopRightPosition(int x, int y)
Moves the component to a new position.
void setEnabled(bool shouldBeEnabled)
Enables or disables this component.
void repaint()
Marks the whole component as needing to be redrawn.
int getY() const noexcept
Returns the y coordinate of the top of this component.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
int getWidth() const noexcept
Returns the component's width in pixels.
int getRight() const noexcept
Returns the x coordinate of the component's right-hand edge.
@ canSelectDirectories
specifies that the user can select directories (can be used in conjunction with canSelectFiles).
@ openMode
specifies that the component should allow the user to choose an existing file with the intention of o...
Creates a dialog box to choose a file or directory to load or save.
void deleteKeyPressed(int lastRowSelected) override
Override this to be informed when the delete key is pressed.
bool isInterestedInFileDrag(const StringArray &) override
Callback to check whether this target is interested in the set of files being offered.
int getNumRows() override
This has to return the number of items in the list.
@ backgroundColourId
The background colour to fill the component with.
void setPath(const FileSearchPath &newPath)
Changes the current path.
void resized() override
Called when this component's size has been changed.
void paintListBoxItem(int rowNumber, Graphics &g, int width, int height, bool rowIsSelected) override
This method must be implemented to draw a row of the list.
FileSearchPathListComponent()
Creates an empty FileSearchPathListComponent.
void selectedRowsChanged(int lastRowSelected) override
Override this to be informed when rows are selected or deselected.
void setDefaultBrowseTarget(const File &newDefaultDirectory)
Sets a file or directory to be the default starting point for the browser to show.
void listBoxItemDoubleClicked(int row, const MouseEvent &) override
This can be overridden to react to the user double-clicking on a row.
void returnKeyPressed(int lastRowSelected) override
Override this to be informed when the return key is pressed.
void paint(Graphics &) override
Components can override this method to draw their content.
void filesDropped(const StringArray &files, int, int) override
Callback to indicate that the user has dropped the files onto this component.
Represents a set of folders that make up a search path.
void add(const File &directoryToAdd, int insertIndex=-1)
Adds a new directory to the search path.
void remove(int indexToRemove)
Removes a directory from the search path.
String toString() const
Returns the search path as a semicolon-separated list of directories.
int getNumPaths() const
Returns the number of folders in this search path.
String getRawString(int index) const
Returns the unaltered text of the folder at the specified index.
Represents a local file or directory.
bool isDirectory() const
Checks whether the file is a directory that exists.
static File getCurrentWorkingDirectory()
Returns the current working directory.
static File createFileWithoutCheckingPath(const String &absolutePath) noexcept
Creates a file that simply contains this string, without doing the sanity-checking that the normal co...
Represents a particular font, including its size, style, etc.
void setHorizontalScale(float scaleFactor)
Changes the font's horizontal scale factor.
A graphics context, used for drawing a component or image.
void drawText(const String &text, int x, int y, int width, int height, Justification justificationType, bool useEllipsesIfTooBig=true) const
Draws a line of text within a specified rectangle.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setColour(Colour newColour)
Changes the current drawing colour.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
int getRowContainingPosition(int x, int y) const noexcept
Finds the row index that contains a given x,y position.
int getSelectedRow(int index=0) const
Returns the row number of a selected row.
@ textColourId
The preferred colour to use for drawing text in the listbox.
@ backgroundColourId
The background colour to fill the list with.
@ outlineColourId
An optional colour to use to draw a border around the list.
void updateContent()
Causes the list to refresh its content.
int getNumSelectedRows() const
Returns the number of rows that are currently selected.
void selectRow(int rowNumber, bool dontScrollToShowThisRow=false, bool deselectOthersFirst=true)
Selects a row.
Contains position and status information about a mouse event.
A special array for holding a list of strings.
void changeWidthToFitText()
Changes this button's width to fit neatly around its current text, without changing its height.
@ highlightColourId
The colour with which to fill the background of highlighted sections of the text - this can be transp...
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.