diff --git a/src/juce_appframework/gui/components/controls/juce_ComboBox.cpp b/src/juce_appframework/gui/components/controls/juce_ComboBox.cpp index c3a253984b..cd5f54774e 100644 --- a/src/juce_appframework/gui/components/controls/juce_ComboBox.cpp +++ b/src/juce_appframework/gui/components/controls/juce_ComboBox.cpp @@ -51,12 +51,6 @@ ComboBox::ComboBox (const String& name) label (0) { noChoicesMessage = TRANS("(no choices)"); - - addAndMakeVisible (label = new Label (String::empty, String::empty)); - label->addListener (this); - label->addMouseListener (this, false); - - setEditableText (false); setRepaintsOnMouseActivity (true); lookAndFeelChanged(); @@ -453,13 +447,33 @@ void ComboBox::lookAndFeelChanged() { repaint(); - label->setColour (Label::backgroundColourId, Colours::transparentBlack); - label->setColour (Label::textColourId, findColour (ComboBox::textColourId)); + Label* const newLabel = getLookAndFeel().createComboBoxTextBox (*this); - label->setColour (TextEditor::textColourId, findColour (ComboBox::textColourId)); - label->setColour (TextEditor::backgroundColourId, Colours::transparentBlack); - label->setColour (TextEditor::highlightColourId, findColour (TextEditor::highlightColourId)); - label->setColour (TextEditor::outlineColourId, Colours::transparentBlack); + if (label != 0) + { + newLabel->setEditable (label->isEditable()); + newLabel->setJustificationType (label->getJustificationType()); + newLabel->setTooltip (label->getTooltip()); + newLabel->setText (label->getText(), false); + } + + delete label; + label = newLabel; + + addAndMakeVisible (newLabel); + + newLabel->addListener (this); + newLabel->addMouseListener (this, false); + + newLabel->setColour (Label::backgroundColourId, Colours::transparentBlack); + newLabel->setColour (Label::textColourId, findColour (ComboBox::textColourId)); + + newLabel->setColour (TextEditor::textColourId, findColour (ComboBox::textColourId)); + newLabel->setColour (TextEditor::backgroundColourId, Colours::transparentBlack); + newLabel->setColour (TextEditor::highlightColourId, findColour (TextEditor::highlightColourId)); + newLabel->setColour (TextEditor::outlineColourId, Colours::transparentBlack); + + resized(); } void ComboBox::colourChanged() diff --git a/src/juce_appframework/gui/components/juce_Component.cpp b/src/juce_appframework/gui/components/juce_Component.cpp index b5dccc754e..499b3cffd3 100644 --- a/src/juce_appframework/gui/components/juce_Component.cpp +++ b/src/juce_appframework/gui/components/juce_Component.cpp @@ -875,6 +875,11 @@ void Component::setBounds (int x, int y, int w, int h) const bool wasResized = (getWidth() != w || getHeight() != h); const bool wasMoved = (getX() != x || getY() != y); +#ifdef JUCE_DEBUG + // It's a very bad idea to try to resize a component during its paint() method! + jassert (! (flags.isInsidePaintCall && wasResized)); +#endif + if (wasMoved || wasResized) { if (flags.visibleFlag) @@ -1680,6 +1685,10 @@ void Component::paintEntireComponent (Graphics& originalContext) { jassert (! originalContext.isClipEmpty()); +#ifdef JUCE_DEBUG + flags.isInsidePaintCall = true; +#endif + Graphics* g = &originalContext; Image* effectImage = 0; @@ -1775,6 +1784,10 @@ void Component::paintEntireComponent (Graphics& originalContext) effect_->applyEffect (*effectImage, originalContext); delete effectImage; } + +#ifdef JUCE_DEBUG + flags.isInsidePaintCall = false; +#endif } //============================================================================== diff --git a/src/juce_appframework/gui/components/juce_Component.h b/src/juce_appframework/gui/components/juce_Component.h index 91d4b0fcd5..bcece888ad 100644 --- a/src/juce_appframework/gui/components/juce_Component.h +++ b/src/juce_appframework/gui/components/juce_Component.h @@ -2038,6 +2038,9 @@ private: bool currentlyModalFlag : 1; bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; +#ifdef JUCE_DEBUG + bool isInsidePaintCall : 1; +#endif }; union diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp index 3e39bbe114..7d184c6060 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -1121,6 +1121,11 @@ const Font LookAndFeel::getComboBoxFont (ComboBox& box) return f; } +Label* LookAndFeel::createComboBoxTextBox (ComboBox& box) +{ + return new Label (String::empty, String::empty); +} + //============================================================================== void LookAndFeel::drawLinearSlider (Graphics& g, int x, int y, diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h index 4ce5b6a119..afda0cbbc9 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h @@ -326,6 +326,8 @@ public: virtual const Font getComboBoxFont (ComboBox& box); + virtual Label* createComboBoxTextBox (ComboBox& box); + //============================================================================== virtual void drawLinearSlider (Graphics& g, int x, int y,