diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index 41331b1aba..3fe94f9e25 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -114,14 +114,6 @@ void AlertWindow::setMessage (const String& message) if (text != newMessage) { text = newMessage; - - font = getLookAndFeel().getAlertWindowMessageFont(); - - AttributedString newText; - newText.append (getName() + "\n\n", Font (font.getHeight() * 1.1f, Font::bold)); - newText.append (text, font); - attributedText = newText; - updateLayout (true); repaint(); } @@ -191,7 +183,7 @@ void AlertWindow::addTextEditor (const String& name, allComps.add (tc); tc->setColour (TextEditor::outlineColourId, findColour (ComboBox::outlineColourId)); - tc->setFont (font); + tc->setFont (getLookAndFeel().getAlertWindowMessageFont()); tc->setText (initialContents); tc->setCaretPosition (initialContents.length()); addAndMakeVisible (tc); @@ -288,7 +280,7 @@ private: void AlertWindow::addTextBlock (const String& textBlock) { - AlertTextComp* const c = new AlertTextComp (textBlock, font); + AlertTextComp* const c = new AlertTextComp (textBlock, getLookAndFeel().getAlertWindowMessageFont()); textBlocks.add (c); allComps.add (c); @@ -391,6 +383,8 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) const int titleH = 24; const int iconWidth = 80; + const Font font (getLookAndFeel().getAlertWindowMessageFont()); + const int wid = jmax (font.getStringWidth (text), font.getStringWidth (getName())); @@ -400,6 +394,12 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) const int labelHeight = 18; int iconSpace = 0; + AttributedString attributedText; + attributedText.append (getName(), Font (font.getHeight() * 1.1f, Font::bold)); + + if (text.isNotEmpty()) + attributedText.append ("\n\n" + text, font); + attributedText.setColour (findColour (textColourId)); if (alertIconType == NoIcon) diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.h b/modules/juce_gui_basics/windows/juce_AlertWindow.h index 7637768c5c..9adc0938be 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.h +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.h @@ -446,7 +446,6 @@ protected: private: //============================================================================== String text; - AttributedString attributedText; TextLayout textLayout; AlertIconType alertIconType; ComponentBoundsConstrainer constrainer; @@ -460,7 +459,6 @@ private: OwnedArray textBlocks; Array allComps; StringArray textboxNames, comboBoxNames; - Font font; Component* associatedComponent; bool escapeKeyCancels;