diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 3b65022429..76042f1ec7 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -52658,14 +52658,15 @@ public: g.fillRect (startX, y, endX - startX, nextY - y); } - void drawUnderline (Graphics& g, const Range& underline) const + void drawUnderline (Graphics& g, const Range& underline, const Colour& colour) const { - const float startX = indexToX (underline.getStart()); - const float endX = indexToX (underline.getEnd()); - const float baselineY = lineY + currentSection->font.getAscent(); - const float dashes[] = { 4.0f, 4.0f }; + const int startX = roundToInt (indexToX (underline.getStart())); + const int endX = roundToInt (indexToX (underline.getEnd())); + const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); - g.drawDashedLine (Line (startX, baselineY, endX, baselineY), dashes, 2, 1.0f, 0); + Graphics::ScopedSaveState state (g); + g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); + g.fillCheckerBoard (Rectangle (0, 0, endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); } void drawSelectedText (Graphics& g, @@ -53045,6 +53046,13 @@ TextEditor::TextEditor (const String& name, TextEditor::~TextEditor() { + if (wasFocused) + { + ComponentPeer* const peer = getPeer(); + if (peer != 0) + peer->dismissPendingTextInput(); + } + textValue.referTo (Value()); clearInternal (0); viewport = 0; @@ -53687,8 +53695,7 @@ void TextEditor::drawContent (Graphics& g) if (! selection.isEmpty()) { - g.setColour (findColour (highlightColourId) - .withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); + g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); selectedTextColour = findColour (highlightedTextColourId); @@ -53726,8 +53733,6 @@ void TextEditor::drawContent (Graphics& g) { const Range& underlinedSection = underlinedSections.getReference (i); - g.setColour (findColour (highlightColourId)); - Iterator i2 (sections, wordWrapWidth, passwordCharacter); while (i2.next() && i2.lineY < clip.getBottom()) @@ -53735,7 +53740,7 @@ void TextEditor::drawContent (Graphics& g) if (i2.lineY + i2.lineHeight >= clip.getY() && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) { - i2.drawUnderline (g, underlinedSection); + i2.drawUnderline (g, underlinedSection, findColour (textColourId)); } } } @@ -54170,7 +54175,7 @@ void TextEditor::focusLost (FocusChangeType) ComponentPeer* const peer = getPeer(); if (peer != 0) - peer->cancelPendingTextInput(); + peer->dismissPendingTextInput(); updateCaretPosition(); @@ -77480,7 +77485,7 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget() return 0; } -void ComponentPeer::cancelPendingTextInput() +void ComponentPeer::dismissPendingTextInput() { } @@ -246630,7 +246635,7 @@ public: SetCaretPos (0, 0); } - void cancelPendingTextInput() + void dismissPendingTextInput() { imeHandler.handleSetContext (hwnd, false); } @@ -247513,6 +247518,13 @@ private: return handleKeyPress (key, textChar); } + void forwardMessageToParent (UINT message, WPARAM wParam, LPARAM lParam) const + { + HWND parentH = GetParent (hwnd); + if (parentH != 0) + PostMessage (parentH, message, wParam, lParam); + } + bool doAppCommand (const LPARAM lParam) { int key = 0; @@ -247623,6 +247635,34 @@ private: } } + void handleLeftClickInNCArea (WPARAM wParam) + { + if (! sendInputAttemptWhenModalMessage()) + { + switch (wParam) + { + case HTBOTTOM: + case HTBOTTOMLEFT: + case HTBOTTOMRIGHT: + case HTGROWBOX: + case HTLEFT: + case HTRIGHT: + case HTTOP: + case HTTOPLEFT: + case HTTOPRIGHT: + if (isConstrainedNativeWindow()) + { + constrainerIsResizing = true; + constrainer->resizeStart(); + } + break; + + default: + break; + } + } + } + class JuceDropTarget : public ComBaseClassHelper { public: @@ -247862,6 +247902,8 @@ private: case WM_SYSKEYDOWN: if (doKeyDown (wParam)) return 0; + else + forwardMessageToParent (message, wParam, lParam); break; @@ -247869,12 +247911,16 @@ private: case WM_SYSKEYUP: if (doKeyUp (wParam)) return 0; + else + forwardMessageToParent (message, wParam, lParam); break; case WM_CHAR: if (doKeyChar ((int) wParam, lParam)) return 0; + else + forwardMessageToParent (message, wParam, lParam); break; @@ -248049,30 +248095,7 @@ private: break; case WM_NCLBUTTONDOWN: - if (! sendInputAttemptWhenModalMessage()) - { - switch (wParam) - { - case HTBOTTOM: - case HTBOTTOMLEFT: - case HTBOTTOMRIGHT: - case HTGROWBOX: - case HTLEFT: - case HTRIGHT: - case HTTOP: - case HTTOPLEFT: - case HTTOPRIGHT: - if (isConstrainedNativeWindow()) - { - constrainerIsResizing = true; - constrainer->resizeStart(); - } - break; - - default: - break; - }; - } + handleLeftClickInNCArea (wParam); break; case WM_NCRBUTTONDOWN: diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 7fbf514ec1..0de763f3bb 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 58 +#define JUCE_BUILDNUMBER 59 /** Current Juce version number. @@ -64328,8 +64328,8 @@ public: */ virtual void textInputRequired (const Point& position) = 0; - /** If there's some kind of OS input-method in progress, this should cancel it. */ - virtual void cancelPendingTextInput(); + /** If there's some kind of OS input-method in progress, this should dismiss it. */ + virtual void dismissPendingTextInput(); /** Returns the currently focused TextInputTarget, or null if none is found. */ TextInputTarget* findCurrentTextInputTarget(); diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index f2e249c1a1..740b5a8f56 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 58 +#define JUCE_BUILDNUMBER 59 /** Current Juce version number. diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 9833a32e74..1e9b33bcab 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -614,14 +614,15 @@ public: g.fillRect (startX, y, endX - startX, nextY - y); } - void drawUnderline (Graphics& g, const Range& underline) const + void drawUnderline (Graphics& g, const Range& underline, const Colour& colour) const { - const float startX = indexToX (underline.getStart()); - const float endX = indexToX (underline.getEnd()); - const float baselineY = lineY + currentSection->font.getAscent(); - const float dashes[] = { 4.0f, 4.0f }; + const int startX = roundToInt (indexToX (underline.getStart())); + const int endX = roundToInt (indexToX (underline.getEnd())); + const int baselineY = roundToInt (lineY + currentSection->font.getAscent() + 0.5f); - g.drawDashedLine (Line (startX, baselineY, endX, baselineY), dashes, 2, 1.0f, 0); + Graphics::ScopedSaveState state (g); + g.reduceClipRegion (Rectangle (startX, baselineY, endX - startX, 1)); + g.fillCheckerBoard (Rectangle (0, 0, endX, baselineY + 1), 3, 1, colour, Colours::transparentBlack); } void drawSelectedText (Graphics& g, @@ -1011,6 +1012,13 @@ TextEditor::TextEditor (const String& name, TextEditor::~TextEditor() { + if (wasFocused) + { + ComponentPeer* const peer = getPeer(); + if (peer != 0) + peer->dismissPendingTextInput(); + } + textValue.referTo (Value()); clearInternal (0); viewport = 0; @@ -1664,8 +1672,7 @@ void TextEditor::drawContent (Graphics& g) if (! selection.isEmpty()) { - g.setColour (findColour (highlightColourId) - .withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); + g.setColour (findColour (highlightColourId).withMultipliedAlpha (hasKeyboardFocus (true) ? 1.0f : 0.5f)); selectedTextColour = findColour (highlightedTextColourId); @@ -1703,8 +1710,6 @@ void TextEditor::drawContent (Graphics& g) { const Range& underlinedSection = underlinedSections.getReference (i); - g.setColour (findColour (highlightColourId)); - Iterator i2 (sections, wordWrapWidth, passwordCharacter); while (i2.next() && i2.lineY < clip.getBottom()) @@ -1712,7 +1717,7 @@ void TextEditor::drawContent (Graphics& g) if (i2.lineY + i2.lineHeight >= clip.getY() && underlinedSection.intersects (Range (i2.indexInText, i2.indexInText + i2.atom->numChars))) { - i2.drawUnderline (g, underlinedSection); + i2.drawUnderline (g, underlinedSection, findColour (textColourId)); } } } @@ -2151,7 +2156,7 @@ void TextEditor::focusLost (FocusChangeType) ComponentPeer* const peer = getPeer(); if (peer != 0) - peer->cancelPendingTextInput(); + peer->dismissPendingTextInput(); updateCaretPosition(); diff --git a/src/gui/components/windows/juce_ComponentPeer.cpp b/src/gui/components/windows/juce_ComponentPeer.cpp index 7c1dc07b3c..a4d2cade75 100644 --- a/src/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/gui/components/windows/juce_ComponentPeer.cpp @@ -286,7 +286,7 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget() return 0; } -void ComponentPeer::cancelPendingTextInput() +void ComponentPeer::dismissPendingTextInput() { } diff --git a/src/gui/components/windows/juce_ComponentPeer.h b/src/gui/components/windows/juce_ComponentPeer.h index 055a1ae61b..33eb565119 100644 --- a/src/gui/components/windows/juce_ComponentPeer.h +++ b/src/gui/components/windows/juce_ComponentPeer.h @@ -282,8 +282,8 @@ public: */ virtual void textInputRequired (const Point& position) = 0; - /** If there's some kind of OS input-method in progress, this should cancel it. */ - virtual void cancelPendingTextInput(); + /** If there's some kind of OS input-method in progress, this should dismiss it. */ + virtual void dismissPendingTextInput(); /** Returns the currently focused TextInputTarget, or null if none is found. */ TextInputTarget* findCurrentTextInputTarget(); diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 3aaabc30cd..0c42c3ba30 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -805,7 +805,7 @@ public: SetCaretPos (0, 0); } - void cancelPendingTextInput() + void dismissPendingTextInput() { imeHandler.handleSetContext (hwnd, false); } @@ -1700,6 +1700,13 @@ private: return handleKeyPress (key, textChar); } + void forwardMessageToParent (UINT message, WPARAM wParam, LPARAM lParam) const + { + HWND parentH = GetParent (hwnd); + if (parentH != 0) + PostMessage (parentH, message, wParam, lParam); + } + bool doAppCommand (const LPARAM lParam) { int key = 0; @@ -1810,6 +1817,34 @@ private: } } + void handleLeftClickInNCArea (WPARAM wParam) + { + if (! sendInputAttemptWhenModalMessage()) + { + switch (wParam) + { + case HTBOTTOM: + case HTBOTTOMLEFT: + case HTBOTTOMRIGHT: + case HTGROWBOX: + case HTLEFT: + case HTRIGHT: + case HTTOP: + case HTTOPLEFT: + case HTTOPRIGHT: + if (isConstrainedNativeWindow()) + { + constrainerIsResizing = true; + constrainer->resizeStart(); + } + break; + + default: + break; + } + } + } + //============================================================================== class JuceDropTarget : public ComBaseClassHelper { @@ -2055,6 +2090,8 @@ private: case WM_SYSKEYDOWN: if (doKeyDown (wParam)) return 0; + else + forwardMessageToParent (message, wParam, lParam); break; @@ -2062,12 +2099,16 @@ private: case WM_SYSKEYUP: if (doKeyUp (wParam)) return 0; + else + forwardMessageToParent (message, wParam, lParam); break; case WM_CHAR: if (doKeyChar ((int) wParam, lParam)) return 0; + else + forwardMessageToParent (message, wParam, lParam); break; @@ -2243,30 +2284,7 @@ private: break; case WM_NCLBUTTONDOWN: - if (! sendInputAttemptWhenModalMessage()) - { - switch (wParam) - { - case HTBOTTOM: - case HTBOTTOMLEFT: - case HTBOTTOMRIGHT: - case HTGROWBOX: - case HTLEFT: - case HTRIGHT: - case HTTOP: - case HTTOPLEFT: - case HTTOPRIGHT: - if (isConstrainedNativeWindow()) - { - constrainerIsResizing = true; - constrainer->resizeStart(); - } - break; - - default: - break; - }; - } + handleLeftClickInNCArea (wParam); break; case WM_NCRBUTTONDOWN: