@@ -1031,6 +1031,8 @@ public: | |||
{ | |||
const bool wasValid = isValid(); | |||
wrapper.setVisible (false); | |||
removeChildComponent (&wrapper); | |||
wrapper.setView (nil); | |||
if (wasValid) | |||
@@ -25,7 +25,6 @@ | |||
BEGIN_JUCE_NAMESPACE | |||
//============================================================================== | |||
bool NamedPipe::openExisting (const String& pipeName) | |||
{ | |||
currentPipeName = pipeName; | |||
@@ -26,8 +26,6 @@ | |||
#ifndef __JUCE_NAMEDPIPE_JUCEHEADER__ | |||
#define __JUCE_NAMEDPIPE_JUCEHEADER__ | |||
#include "../threads/juce_CriticalSection.h" | |||
//============================================================================== | |||
/** | |||
@@ -102,7 +100,6 @@ private: | |||
class Pimpl; | |||
ScopedPointer<Pimpl> pimpl; | |||
String currentPipeName; | |||
CriticalSection lock; | |||
bool openInternal (const String& pipeName, const bool createPipe); | |||
@@ -132,8 +132,8 @@ void Button::setToggleState (const bool shouldBeOn, | |||
{ | |||
if (shouldBeOn != lastToggleState) | |||
{ | |||
if (isOn != shouldBeOn) // this test means that if the value is void rather than explicitly set to | |||
isOn = shouldBeOn; // false, it won't be changed unless the required value is true. | |||
if (getToggleState() != shouldBeOn) // this test means that if the value is void rather than explicitly set to | |||
isOn = shouldBeOn; // false, it won't be changed unless the required value is true. | |||
lastToggleState = shouldBeOn; | |||
repaint(); | |||
@@ -346,11 +346,13 @@ Image juce_createIconForFile (const File& file) | |||
//============================================================================== | |||
void SystemClipboard::copyTextToClipboard (const String& text) | |||
{ | |||
[[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType] | |||
owner: nil]; | |||
NSPasteboard* pb = [NSPasteboard generalPasteboard]; | |||
[[NSPasteboard generalPasteboard] setString: juceStringToNS (text) | |||
forType: NSStringPboardType]; | |||
[pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] | |||
owner: nil]; | |||
[pb setString: juceStringToNS (text) | |||
forType: NSStringPboardType]; | |||
} | |||
String SystemClipboard::getTextFromClipboard() | |||
@@ -108,19 +108,13 @@ public: | |||
//============================================================================== | |||
/** @internal */ | |||
void paint (Graphics& g); | |||
/** @internal */ | |||
void* originalWndProc; | |||
private: | |||
class Pimpl; | |||
friend class Pimpl; | |||
friend class ScopedPointer <Pimpl>; | |||
ScopedPointer <Pimpl> control; | |||
bool mouseEventsAllowed; | |||
void setControlBounds (const Rectangle<int>& bounds) const; | |||
void setControlVisible (bool b) const; | |||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveXControlComponent); | |||
}; | |||
@@ -84,5 +84,4 @@ private: | |||
}; | |||
#endif | |||
#endif // __JUCE_UIVIEWCOMPONENT_JUCEHEADER__ |
@@ -75,9 +75,9 @@ public: | |||
if (wrapperWindow == 0) | |||
{ | |||
Rect r; | |||
r.left = getScreenX(); | |||
r.top = getScreenY(); | |||
r.right = r.left + getWidth(); | |||
r.left = getScreenX(); | |||
r.top = getScreenY(); | |||
r.right = r.left + getWidth(); | |||
r.bottom = r.top + getHeight(); | |||
CreateNewWindow (kDocumentWindowClass, | |||
@@ -101,10 +101,10 @@ public: | |||
{ kEventClassWindow, kEventWindowGetClickActivation }, | |||
{ kEventClassWindow, kEventWindowHandleDeactivate }, | |||
{ kEventClassWindow, kEventWindowBoundsChanging }, | |||
{ kEventClassMouse, kEventMouseDown }, | |||
{ kEventClassMouse, kEventMouseMoved }, | |||
{ kEventClassMouse, kEventMouseDragged }, | |||
{ kEventClassMouse, kEventMouseUp}, | |||
{ kEventClassMouse, kEventMouseDown }, | |||
{ kEventClassMouse, kEventMouseMoved }, | |||
{ kEventClassMouse, kEventMouseDragged }, | |||
{ kEventClassMouse, kEventMouseUp}, | |||
{ kEventClassWindow, kEventWindowDrawContent }, | |||
{ kEventClassWindow, kEventWindowShown }, | |||
{ kEventClassWindow, kEventWindowHidden } | |||
@@ -179,7 +179,7 @@ public: | |||
HIRect r; | |||
r.origin.x = 0; | |||
r.origin.y = 0; | |||
r.size.width = (float) getWidth(); | |||
r.size.width = (float) getWidth(); | |||
r.size.height = (float) getHeight(); | |||
HIViewSetFrame (embeddedView, &r); | |||
} | |||
@@ -187,9 +187,9 @@ public: | |||
if (wrapperWindow != 0) | |||
{ | |||
Rect wr; | |||
wr.left = getScreenX(); | |||
wr.top = getScreenY(); | |||
wr.right = wr.left + getWidth(); | |||
wr.left = getScreenX(); | |||
wr.top = getScreenY(); | |||
wr.right = wr.left + getWidth(); | |||
wr.bottom = wr.top + getHeight(); | |||
SetWindowBounds (wrapperWindow, kWindowContentRgn, &wr); | |||
@@ -40,7 +40,7 @@ public: | |||
~Pimpl() | |||
{ | |||
[view removeFromSuperview]; | |||
removeFromParent(); | |||
[view release]; | |||
} | |||
@@ -77,10 +77,7 @@ public: | |||
if (currentPeer != peer) | |||
{ | |||
if ([view superview] != nil) | |||
[view removeFromSuperview]; // Must be careful not to call this unless it's required - e.g. some Apple AU views | |||
// override the call and use it as a sign that they're being deleted, which breaks everything.. | |||
removeFromParent(); | |||
currentPeer = peer; | |||
if (peer != nullptr) | |||
@@ -111,6 +108,13 @@ private: | |||
Component& owner; | |||
ComponentPeer* currentPeer; | |||
void removeFromParent() | |||
{ | |||
if ([view superview] != nil) | |||
[view removeFromSuperview]; // Must be careful not to call this unless it's required - e.g. some Apple AU views | |||
// override the call and use it as a sign that they're being deleted, which breaks everything.. | |||
} | |||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl); | |||
}; | |||
@@ -205,14 +205,14 @@ namespace ActiveXHelpers | |||
class ActiveXControlComponent::Pimpl : public ComponentMovementWatcher | |||
{ | |||
public: | |||
//============================================================================== | |||
Pimpl (HWND hwnd, ActiveXControlComponent& owner_) | |||
: ComponentMovementWatcher (&owner_), | |||
owner (owner_), | |||
controlHWND (0), | |||
storage (new ActiveXHelpers::JuceIStorage()), | |||
clientSite (new ActiveXHelpers::JuceIOleClientSite (hwnd)), | |||
control (nullptr) | |||
control (nullptr), | |||
originalWndProc (0) | |||
{ | |||
} | |||
@@ -228,16 +228,25 @@ public: | |||
storage->Release(); | |||
} | |||
void setControlBounds (const Rectangle<int>& bounds) const | |||
{ | |||
if (controlHWND != 0) | |||
MoveWindow (controlHWND, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), TRUE); | |||
} | |||
void setControlVisible (bool shouldBeVisible) const | |||
{ | |||
if (controlHWND != 0) | |||
ShowWindow (controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE); | |||
} | |||
//============================================================================== | |||
void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) | |||
{ | |||
Component* const topComp = owner.getTopLevelComponent(); | |||
if (topComp->getPeer() != nullptr) | |||
{ | |||
const Point<int> pos (topComp->getLocalPoint (&owner, Point<int>())); | |||
owner.setControlBounds (Rectangle<int> (pos.getX(), pos.getY(), owner.getWidth(), owner.getHeight())); | |||
} | |||
setControlBounds (topComp->getLocalArea (&owner, owner.getLocalBounds())); | |||
} | |||
void componentPeerChanged() | |||
@@ -247,7 +256,7 @@ public: | |||
void componentVisibilityChanged() | |||
{ | |||
owner.setControlVisible (owner.isShowing()); | |||
setControlVisible (owner.isShowing()); | |||
componentPeerChanged(); | |||
} | |||
@@ -290,7 +299,7 @@ public: | |||
break; | |||
} | |||
return CallWindowProc ((WNDPROC) ax->originalWndProc, hwnd, message, wParam, lParam); | |||
return CallWindowProc (ax->control->originalWndProc, hwnd, message, wParam, lParam); | |||
} | |||
} | |||
@@ -305,12 +314,13 @@ public: | |||
IStorage* storage; | |||
IOleClientSite* clientSite; | |||
IOleObject* control; | |||
WNDPROC originalWndProc; | |||
}; | |||
//============================================================================== | |||
ActiveXControlComponent::ActiveXControlComponent() | |||
: originalWndProc (0), | |||
mouseEventsAllowed (true) | |||
: mouseEventsAllowed (true) | |||
{ | |||
ActiveXHelpers::activeXComps.add (this); | |||
} | |||
@@ -337,7 +347,7 @@ bool ActiveXControlComponent::createControl (const void* controlIID) | |||
if (peer != nullptr) | |||
{ | |||
const Point<int> pos (getTopLevelComponent()->getLocalPoint (this, Point<int>())); | |||
const Rectangle<int> bounds (getTopLevelComponent()->getLocalArea (this, getLocalBounds())); | |||
HWND hwnd = (HWND) peer->getNativeHandle(); | |||
ScopedPointer<Pimpl> newControl (new Pimpl (hwnd, *this)); | |||
@@ -352,21 +362,21 @@ bool ActiveXControlComponent::createControl (const void* controlIID) | |||
if (OleSetContainedObject (newControl->control, TRUE) == S_OK) | |||
{ | |||
RECT rect; | |||
rect.left = pos.getX(); | |||
rect.top = pos.getY(); | |||
rect.right = pos.getX() + getWidth(); | |||
rect.bottom = pos.getY() + getHeight(); | |||
rect.left = bounds.getX(); | |||
rect.top = bounds.getY(); | |||
rect.right = bounds.getRight(); | |||
rect.bottom = bounds.getBottom(); | |||
if (newControl->control->DoVerb (OLEIVERB_SHOW, 0, newControl->clientSite, 0, hwnd, &rect) == S_OK) | |||
{ | |||
control = newControl; | |||
setControlBounds (Rectangle<int> (pos.getX(), pos.getY(), getWidth(), getHeight())); | |||
control->controlHWND = ActiveXHelpers::getHWND (this); | |||
if (control->controlHWND != 0) | |||
{ | |||
originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC); | |||
control->setControlBounds (bounds); | |||
control->originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC); | |||
SetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC, (LONG_PTR) Pimpl::activeXHookWndProc); | |||
} | |||
@@ -382,7 +392,6 @@ bool ActiveXControlComponent::createControl (const void* controlIID) | |||
void ActiveXControlComponent::deleteControl() | |||
{ | |||
control = nullptr; | |||
originalWndProc = 0; | |||
} | |||
void* ActiveXControlComponent::queryInterface (const void* iid) const | |||
@@ -396,18 +405,6 @@ void* ActiveXControlComponent::queryInterface (const void* iid) const | |||
return nullptr; | |||
} | |||
void ActiveXControlComponent::setControlBounds (const Rectangle<int>& newBounds) const | |||
{ | |||
if (control->controlHWND != 0) | |||
MoveWindow (control->controlHWND, newBounds.getX(), newBounds.getY(), newBounds.getWidth(), newBounds.getHeight(), TRUE); | |||
} | |||
void ActiveXControlComponent::setControlVisible (const bool shouldBeVisible) const | |||
{ | |||
if (control->controlHWND != 0) | |||
ShowWindow (control->controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE); | |||
} | |||
void ActiveXControlComponent::setMouseEventsAllowed (const bool eventsCanReachControl) | |||
{ | |||
mouseEventsAllowed = eventsCanReachControl; | |||