- updated
git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@117 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -91,6 +91,7 @@ namespace juce
|
||||
#include "misc/juce_SplashScreen.cpp"
|
||||
#include "misc/juce_SystemTrayIconComponent.cpp"
|
||||
#include "misc/juce_LiveConstantEditor.cpp"
|
||||
#include "misc/juce_AnimatedAppComponent.cpp"
|
||||
|
||||
}
|
||||
|
||||
@@ -146,5 +147,6 @@ namespace juce
|
||||
bool WebBrowserComponent::pageAboutToLoad (const String&) { return true; }
|
||||
void WebBrowserComponent::pageFinishedLoading (const String&) {}
|
||||
void WebBrowserComponent::windowCloseRequest() {}
|
||||
void WebBrowserComponent::newWindowAttemptingToLoad (const String&) {}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace juce
|
||||
#include "misc/juce_SystemTrayIconComponent.h"
|
||||
#include "misc/juce_WebBrowserComponent.h"
|
||||
#include "misc/juce_LiveConstantEditor.h"
|
||||
#include "misc/juce_AnimatedAppComponent.h"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "juce_gui_extra",
|
||||
"name": "JUCE extended GUI classes",
|
||||
"version": "3.0.8",
|
||||
"version": "3.1.1",
|
||||
"description": "Miscellaneous GUI classes for specialised tasks.",
|
||||
"website": "http://www.juce.com/juce",
|
||||
"license": "GPL/Commercial",
|
||||
|
||||
@@ -98,6 +98,12 @@ public:
|
||||
*/
|
||||
virtual void windowCloseRequest();
|
||||
|
||||
/** This callback occurs when the browser attempts to load a URL in a new window.
|
||||
This won't actually load the window but gives you a chance to either launch a
|
||||
new window yourself or just load the URL into the current window with goToURL().
|
||||
*/
|
||||
virtual void newWindowAttemptingToLoad (const String& newURL);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics&) override;
|
||||
@@ -107,6 +113,8 @@ public:
|
||||
void parentHierarchyChanged() override;
|
||||
/** @internal */
|
||||
void visibilityChanged() override;
|
||||
/** @internal */
|
||||
void focusGained (FocusChangeType) override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
||||
@@ -107,3 +107,7 @@ void WebBrowserComponent::visibilityChanged()
|
||||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
void WebBrowserComponent::focusGained (FocusChangeType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -112,3 +112,7 @@ void WebBrowserComponent::visibilityChanged()
|
||||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
void WebBrowserComponent::focusGained (FocusChangeType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ private:
|
||||
target->viewResized();
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (ViewFrameChangeCallbackClass);
|
||||
JUCE_DECLARE_NON_COPYABLE (ViewFrameChangeCallbackClass)
|
||||
};
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewResizeWatcher)
|
||||
|
||||
@@ -24,14 +24,16 @@
|
||||
|
||||
#if JUCE_MAC
|
||||
|
||||
struct DownloadClickDetectorClass : public ObjCClass <NSObject>
|
||||
struct DownloadClickDetectorClass : public ObjCClass<NSObject>
|
||||
{
|
||||
DownloadClickDetectorClass() : ObjCClass <NSObject> ("JUCEWebClickDetector_")
|
||||
DownloadClickDetectorClass() : ObjCClass<NSObject> ("JUCEWebClickDetector_")
|
||||
{
|
||||
addIvar <WebBrowserComponent*> ("owner");
|
||||
addIvar<WebBrowserComponent*> ("owner");
|
||||
|
||||
addMethod (@selector (webView:decidePolicyForNavigationAction:request:frame:decisionListener:),
|
||||
decidePolicyForNavigationAction, "v@:@@@@@");
|
||||
addMethod (@selector (webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:),
|
||||
decidePolicyForNewWindowAction, "v@:@@@@@");
|
||||
addMethod (@selector (webView:didFinishLoadForFrame:), didFinishLoadForFrame, "v@:@@");
|
||||
addMethod (@selector (webView:willCloseFrame:), willCloseFrame, "v@:@@");
|
||||
addMethod (@selector (webView:runOpenPanelForFileButtonWithResultListener:allowMultipleFiles:), runOpenPanel, "v@:@@", @encode (BOOL));
|
||||
@@ -43,17 +45,30 @@ struct DownloadClickDetectorClass : public ObjCClass <NSObject>
|
||||
static WebBrowserComponent* getOwner (id self) { return getIvar<WebBrowserComponent*> (self, "owner"); }
|
||||
|
||||
private:
|
||||
static void decidePolicyForNavigationAction (id self, SEL, WebView*, NSDictionary* actionInformation,
|
||||
NSURLRequest*, WebFrame*, id <WebPolicyDecisionListener> listener)
|
||||
static String getOriginalURL (NSDictionary* actionInformation)
|
||||
{
|
||||
NSURL* url = [actionInformation valueForKey: nsStringLiteral ("WebActionOriginalURLKey")];
|
||||
if (NSURL* url = [actionInformation valueForKey: nsStringLiteral ("WebActionOriginalURLKey")])
|
||||
return nsStringToJuce ([url absoluteString]);
|
||||
|
||||
if (getOwner (self)->pageAboutToLoad (nsStringToJuce ([url absoluteString])))
|
||||
return String();
|
||||
}
|
||||
|
||||
static void decidePolicyForNavigationAction (id self, SEL, WebView*, NSDictionary* actionInformation,
|
||||
NSURLRequest*, WebFrame*, id<WebPolicyDecisionListener> listener)
|
||||
{
|
||||
if (getOwner (self)->pageAboutToLoad (getOriginalURL (actionInformation)))
|
||||
[listener use];
|
||||
else
|
||||
[listener ignore];
|
||||
}
|
||||
|
||||
static void decidePolicyForNewWindowAction (id self, SEL, WebView*, NSDictionary* actionInformation,
|
||||
NSURLRequest*, NSString*, id<WebPolicyDecisionListener> listener)
|
||||
{
|
||||
getOwner (self)->newWindowAttemptingToLoad (getOriginalURL (actionInformation));
|
||||
[listener ignore];
|
||||
}
|
||||
|
||||
static void didFinishLoadForFrame (id self, SEL, WebView* sender, WebFrame* frame)
|
||||
{
|
||||
if ([frame isEqual: [sender mainFrame]])
|
||||
@@ -94,7 +109,7 @@ private:
|
||||
} // (juce namespace)
|
||||
|
||||
//==============================================================================
|
||||
@interface WebViewTapDetector : NSObject <UIGestureRecognizerDelegate>
|
||||
@interface WebViewTapDetector : NSObject<UIGestureRecognizerDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -115,30 +130,38 @@ private:
|
||||
@end
|
||||
|
||||
//==============================================================================
|
||||
@interface WebViewURLChangeDetector : NSObject <UIWebViewDelegate>
|
||||
@interface WebViewURLChangeDetector : NSObject<UIWebViewDelegate>
|
||||
{
|
||||
juce::WebBrowserComponent* ownerComponent;
|
||||
}
|
||||
|
||||
- (WebViewURLChangeDetector*) initWithWebBrowserOwner: (juce::WebBrowserComponent*) ownerComponent;
|
||||
- (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request navigationType: (UIWebViewNavigationType) navigationType;
|
||||
- (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request
|
||||
navigationType: (UIWebViewNavigationType) navigationType;
|
||||
- (void) webViewDidFinishLoad: (UIWebView*) webView;
|
||||
@end
|
||||
|
||||
@implementation WebViewURLChangeDetector
|
||||
|
||||
- (WebViewURLChangeDetector*) initWithWebBrowserOwner: (juce::WebBrowserComponent*) ownerComponent_
|
||||
- (WebViewURLChangeDetector*) initWithWebBrowserOwner: (juce::WebBrowserComponent*) ownerComp
|
||||
{
|
||||
[super init];
|
||||
ownerComponent = ownerComponent_;
|
||||
ownerComponent = ownerComp;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request navigationType: (UIWebViewNavigationType) navigationType
|
||||
- (BOOL) webView: (UIWebView*) webView shouldStartLoadWithRequest: (NSURLRequest*) request
|
||||
navigationType: (UIWebViewNavigationType) navigationType
|
||||
{
|
||||
(void) webView;
|
||||
(void) navigationType;
|
||||
return ownerComponent->pageAboutToLoad (nsStringToJuce (request.URL.absoluteString));
|
||||
}
|
||||
|
||||
- (void) webViewDidFinishLoad: (UIWebView*) webView
|
||||
{
|
||||
ownerComponent->pageFinishedLoading (nsStringToJuce (webView.request.URL.absoluteString));
|
||||
}
|
||||
@end
|
||||
|
||||
namespace juce {
|
||||
@@ -201,37 +224,45 @@ public:
|
||||
const StringArray* headers,
|
||||
const MemoryBlock* postData)
|
||||
{
|
||||
NSMutableURLRequest* r
|
||||
= [NSMutableURLRequest requestWithURL: [NSURL URLWithString: juceStringToNS (url)]
|
||||
cachePolicy: NSURLRequestUseProtocolCachePolicy
|
||||
timeoutInterval: 30.0];
|
||||
|
||||
if (postData != nullptr && postData->getSize() > 0)
|
||||
{
|
||||
[r setHTTPMethod: nsStringLiteral ("POST")];
|
||||
[r setHTTPBody: [NSData dataWithBytes: postData->getData()
|
||||
length: postData->getSize()]];
|
||||
}
|
||||
|
||||
if (headers != nullptr)
|
||||
{
|
||||
for (int i = 0; i < headers->size(); ++i)
|
||||
{
|
||||
const String headerName ((*headers)[i].upToFirstOccurrenceOf (":", false, false).trim());
|
||||
const String headerValue ((*headers)[i].fromFirstOccurrenceOf (":", false, false).trim());
|
||||
|
||||
[r setValue: juceStringToNS (headerValue)
|
||||
forHTTPHeaderField: juceStringToNS (headerName)];
|
||||
}
|
||||
}
|
||||
|
||||
stop();
|
||||
|
||||
#if JUCE_MAC
|
||||
[[webView mainFrame] loadRequest: r];
|
||||
#else
|
||||
[webView loadRequest: r];
|
||||
#endif
|
||||
if (url.trimStart().startsWithIgnoreCase ("javascript:"))
|
||||
{
|
||||
[webView stringByEvaluatingJavaScriptFromString:
|
||||
juceStringToNS (url.fromFirstOccurrenceOf (":", false, false))];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableURLRequest* r
|
||||
= [NSMutableURLRequest requestWithURL: [NSURL URLWithString: juceStringToNS (url)]
|
||||
cachePolicy: NSURLRequestUseProtocolCachePolicy
|
||||
timeoutInterval: 30.0];
|
||||
|
||||
if (postData != nullptr && postData->getSize() > 0)
|
||||
{
|
||||
[r setHTTPMethod: nsStringLiteral ("POST")];
|
||||
[r setHTTPBody: [NSData dataWithBytes: postData->getData()
|
||||
length: postData->getSize()]];
|
||||
}
|
||||
|
||||
if (headers != nullptr)
|
||||
{
|
||||
for (int i = 0; i < headers->size(); ++i)
|
||||
{
|
||||
const String headerName ((*headers)[i].upToFirstOccurrenceOf (":", false, false).trim());
|
||||
const String headerValue ((*headers)[i].fromFirstOccurrenceOf (":", false, false).trim());
|
||||
|
||||
[r setValue: juceStringToNS (headerValue)
|
||||
forHTTPHeaderField: juceStringToNS (headerName)];
|
||||
}
|
||||
}
|
||||
|
||||
#if JUCE_MAC
|
||||
[[webView mainFrame] loadRequest: r];
|
||||
#else
|
||||
[webView loadRequest: r];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void goBack() { [webView goBack]; }
|
||||
@@ -377,3 +408,7 @@ void WebBrowserComponent::visibilityChanged()
|
||||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
void WebBrowserComponent::focusGained (FocusChangeType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
if (connectionPoint != nullptr)
|
||||
{
|
||||
WebBrowserComponent* const owner = dynamic_cast <WebBrowserComponent*> (getParentComponent());
|
||||
WebBrowserComponent* const owner = dynamic_cast<WebBrowserComponent*> (getParentComponent());
|
||||
jassert (owner != nullptr);
|
||||
|
||||
EventHandler* handler = new EventHandler (*owner);
|
||||
@@ -129,13 +129,11 @@ private:
|
||||
DWORD adviseCookie;
|
||||
|
||||
//==============================================================================
|
||||
class EventHandler : public ComBaseClassHelper <IDispatch>,
|
||||
class EventHandler : public ComBaseClassHelper<IDispatch>,
|
||||
public ComponentMovementWatcher
|
||||
{
|
||||
public:
|
||||
EventHandler (WebBrowserComponent& owner_)
|
||||
: ComponentMovementWatcher (&owner_),
|
||||
owner (owner_)
|
||||
EventHandler (WebBrowserComponent& w) : ComponentMovementWatcher (&w), owner (w)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -153,6 +151,13 @@ private:
|
||||
: VARIANT_TRUE;
|
||||
return S_OK;
|
||||
}
|
||||
else if (dispIdMember == DISPID_NEWWINDOW3)
|
||||
{
|
||||
owner.newWindowAttemptingToLoad (pDispParams->rgvarg[0].bstrVal);
|
||||
*pDispParams->rgvarg[3].pboolVal = VARIANT_TRUE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
else if (dispIdMember == DISPID_DOCUMENTCOMPLETE)
|
||||
{
|
||||
owner.pageFinishedLoading (getStringFromVariant (pDispParams->rgvarg[0].pvarVal));
|
||||
@@ -323,3 +328,26 @@ void WebBrowserComponent::visibilityChanged()
|
||||
{
|
||||
checkWindowAssociation();
|
||||
}
|
||||
|
||||
void WebBrowserComponent::focusGained (FocusChangeType)
|
||||
{
|
||||
if (IOleObject* oleObject = (IOleObject*) browser->queryInterface (&IID_IOleObject))
|
||||
{
|
||||
if (IOleWindow* oleWindow = (IOleWindow*) browser->queryInterface (&IID_IOleWindow))
|
||||
{
|
||||
IOleClientSite* oleClientSite = nullptr;
|
||||
|
||||
if (SUCCEEDED (oleObject->GetClientSite (&oleClientSite)))
|
||||
{
|
||||
HWND hwnd;
|
||||
oleWindow->GetWindow (&hwnd);
|
||||
oleObject->DoVerb (OLEIVERB_UIACTIVATE, nullptr, oleClientSite, 0, hwnd, nullptr);
|
||||
oleClientSite->Release();
|
||||
}
|
||||
|
||||
oleWindow->Release();
|
||||
}
|
||||
|
||||
oleObject->Release();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user