58 button->setImages (icon, overIcon, downIcon);
59 button->setRadioGroupId (1);
60 button->onClick = [
this] { clickedPage(); };
61 button->setClickingTogglesState (
true);
62 button->setWantsKeyboardFocus (
false);
67 if (currentPage ==
nullptr)
88 setSize (dialogWidth, dialogHeight);
104 for (
int i = 0; i < buttons.size(); ++i)
105 buttons.getUnchecked (i)->setBounds (i * buttonSize, 0, buttonSize, buttonSize);
107 if (currentPage !=
nullptr)
108 currentPage->setBounds (
getLocalBounds().withTop (buttonSize + 5));
119 if (currentPageName != pageName)
121 currentPageName = pageName;
126 if (currentPage !=
nullptr)
129 currentPage->toBack();
133 for (
auto* b : buttons)
135 if (b->getName() == pageName)
144void PreferencesPanel::clickedPage()
146 for (
auto* b : buttons)
148 if (b->getToggleState())
Represents a colour, also including a transparency value.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
int getWidth() const noexcept
Returns the component's width in pixels.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
A drawable object which is a bitmap image.
void setOverlayColour(Colour newOverlayColour)
Sets a colour to draw over the image's alpha channel.
void setImage(const Image &imageToUse)
Sets the image that this drawable will render.
The base class for objects which can draw themselves, e.g.
A graphics context, used for drawing a component or image.
void fillRect(Rectangle< int > rectangle) const
Fills a rectangle with the current colour or brush.
void setColour(Colour newColour)
Changes the current drawing colour.
static Image getFromMemory(const void *imageData, int dataSize)
Loads an image from an in-memory image file, (or just returns the image if it's already cached).
void paint(Graphics &) override
Components can override this method to draw their content.
void showInDialogBox(const String &dialogTitle, int dialogWidth, int dialogHeight, Colour backgroundColour=Colours::white)
Utility method to display this panel in a DialogWindow.
int getButtonSize() const noexcept
Returns the size of the buttons shown along the top.
~PreferencesPanel() override
Destructor.
void setCurrentPage(const String &pageName)
Changes the current page being displayed.
void resized() override
Called when this component's size has been changed.
virtual Component * createComponentForPage(const String &pageName)=0
Subclasses must override this to return a component for each preferences page.
void setButtonSize(int newSize)
Changes the size of the buttons shown along the top.
void addSettingsPage(const String &pageTitle, const Drawable *normalIcon, const Drawable *overIcon, const Drawable *downIcon)
Creates a page using a set of drawables to define the page's icon.
PreferencesPanel()
Creates an empty panel.
@ dontSendNotification
No notification message should be sent.
This class defines a collection of settings to be used to open a DialogWindow.
Colour dialogBackgroundColour
The background colour for the window.
bool useNativeTitleBar
If true, the dialog will use a native title bar.
OptionalScopedPointer< Component > content
The content component to show in the window.
DialogWindow * launchAsync()
Launches a new modal dialog window.
bool resizable
If true, the window will be resizable.
bool escapeKeyTriggersCloseButton
If true, then the escape key will trigger the dialog's close button.
String dialogTitle
The title to give the window.