From f8e2eaccc39cf2fefd0c50246b2a7743325da53f Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 4 Aug 2009 19:56:55 +0000 Subject: [PATCH] fixed a bug with popup menus in browser plugins in IE8; added an option to change the time delay of a TooltipWindow; added a missing function to MagnifierComponent --- .../juce_win32_Windowing.cpp | 21 +++++++++++-- juce_amalgamated.cpp | 31 +++++++++++++++++-- juce_amalgamated.h | 7 ++++- .../special/juce_MagnifierComponent.cpp | 5 +++ .../components/windows/juce_TooltipWindow.cpp | 5 +++ .../components/windows/juce_TooltipWindow.h | 8 ++++- 6 files changed, 69 insertions(+), 8 deletions(-) diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index f7e83ee19e..7657b5c2bd 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -872,6 +872,11 @@ public: } } + bool isInside (HWND h) const + { + return GetAncestor (hwnd, GA_ROOT) == h; + } + //============================================================================== juce_UseDebuggingNewOperator @@ -2296,10 +2301,20 @@ bool Process::isForegroundProcess() throw() if (fg == 0) return true; - DWORD processId = 0; - GetWindowThreadProcessId (fg, &processId); + // when running as a plugin in IE8, the browser UI runs in a different process to the plugin, so + // process ID isn't a reliable way to check if the foreground window belongs to us - instead, we + // have to see if any of our windows are children of the foreground window + fg = GetAncestor (fg, GA_ROOT); - return processId == GetCurrentProcessId(); + for (int i = ComponentPeer::getNumPeers(); --i >= 0;) + { + Win32ComponentPeer* const wp = dynamic_cast (ComponentPeer::getPeer (i)); + + if (wp != 0 && wp->isInside (fg)) + return true; + } + + return false; } //============================================================================== diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index fe859535d1..3b7864abc4 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -70898,6 +70898,11 @@ void MagnifierComponent::setScaleFactor (double newScaleFactor) } } +void MagnifierComponent::setResamplingQuality (Graphics::ResamplingQuality newQuality) +{ + quality = newQuality; +} + void MagnifierComponent::paint (Graphics& g) { const int w = holderComp->getWidth(); @@ -74812,6 +74817,11 @@ TooltipWindow::~TooltipWindow() hide(); } +void TooltipWindow::setMillisecondsBeforeTipAppears (const int newTimeMs) throw() +{ + millisecondsBeforeTipAppears = newTimeMs; +} + void TooltipWindow::paint (Graphics& g) { getLookAndFeel().drawTooltip (g, tipShowing, getWidth(), getHeight()); @@ -244507,6 +244517,11 @@ public: } } + bool isInside (HWND h) const + { + return GetAncestor (hwnd, GA_ROOT) == h; + } + juce_UseDebuggingNewOperator bool dontRepaint; @@ -245908,10 +245923,20 @@ bool Process::isForegroundProcess() throw() if (fg == 0) return true; - DWORD processId = 0; - GetWindowThreadProcessId (fg, &processId); + // when running as a plugin in IE8, the browser UI runs in a different process to the plugin, so + // process ID isn't a reliable way to check if the foreground window belongs to us - instead, we + // have to see if any of our windows are children of the foreground window + fg = GetAncestor (fg, GA_ROOT); - return processId == GetCurrentProcessId(); + for (int i = ComponentPeer::getNumPeers(); --i >= 0;) + { + Win32ComponentPeer* const wp = dynamic_cast (ComponentPeer::getPeer (i)); + + if (wp != 0 && wp->isInside (fg)) + return true; + } + + return false; } bool AlertWindow::showNativeDialogBox (const String& title, diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 166631ecea..2930a55ef4 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -30241,6 +30241,11 @@ public: /** Destructor. */ ~TooltipWindow(); + /** Changes the time before the tip appears. + This lets you change the value that was set in the constructor. + */ + void setMillisecondsBeforeTipAppears (const int newTimeMs = 700) throw(); + /** A set of colour IDs to use to change the colour of various aspects of the tooltip. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() @@ -30259,7 +30264,7 @@ public: private: - const int millisecondsBeforeTipAppears; + int millisecondsBeforeTipAppears; int mouseX, mouseY, mouseClicks; unsigned int lastCompChangeTime, lastHideTime; Component* lastComponentUnderMouse; diff --git a/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp b/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp index c00596695d..4adc23efb1 100644 --- a/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp +++ b/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp @@ -245,6 +245,11 @@ void MagnifierComponent::setScaleFactor (double newScaleFactor) } } +void MagnifierComponent::setResamplingQuality (Graphics::ResamplingQuality newQuality) +{ + quality = newQuality; +} + void MagnifierComponent::paint (Graphics& g) { const int w = holderComp->getWidth(); diff --git a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp index adea6ed2ea..08619464e8 100644 --- a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp +++ b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp @@ -66,6 +66,11 @@ TooltipWindow::~TooltipWindow() hide(); } +void TooltipWindow::setMillisecondsBeforeTipAppears (const int newTimeMs) throw() +{ + millisecondsBeforeTipAppears = newTimeMs; +} + void TooltipWindow::paint (Graphics& g) { getLookAndFeel().drawTooltip (g, tipShowing, getWidth(), getHeight()); diff --git a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h index 306a72466a..a43c612480 100644 --- a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h +++ b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h @@ -79,6 +79,12 @@ public: /** Destructor. */ ~TooltipWindow(); + //============================================================================== + /** Changes the time before the tip appears. + This lets you change the value that was set in the constructor. + */ + void setMillisecondsBeforeTipAppears (const int newTimeMs = 700) throw(); + //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the tooltip. @@ -99,7 +105,7 @@ public: private: //============================================================================== - const int millisecondsBeforeTipAppears; + int millisecondsBeforeTipAppears; int mouseX, mouseY, mouseClicks; unsigned int lastCompChangeTime, lastHideTime; Component* lastComponentUnderMouse;