@@ -94,7 +94,7 @@ ProjectContentComponent::ProjectContentComponent() | |||||
setOpaque (true); | setOpaque (true); | ||||
setWantsKeyboardFocus (true); | setWantsKeyboardFocus (true); | ||||
treeSizeConstrainer.setMinimumWidth (100); | |||||
treeSizeConstrainer.setMinimumWidth (200); | |||||
treeSizeConstrainer.setMaximumWidth (500); | treeSizeConstrainer.setMaximumWidth (500); | ||||
treeViewTabs.setOutline (0); | treeViewTabs.setOutline (0); | ||||
@@ -203,7 +203,7 @@ void ProjectContentComponent::setProject (Project* newProject) | |||||
int lastTreeWidth = settings.getValue ("projectTreeviewWidth_" + project->getProjectUID()).getIntValue(); | int lastTreeWidth = settings.getValue ("projectTreeviewWidth_" + project->getProjectUID()).getIntValue(); | ||||
if (lastTreeWidth < 150) | if (lastTreeWidth < 150) | ||||
lastTreeWidth = 250; | |||||
lastTreeWidth = 240; | |||||
treeViewTabs.setBounds (0, 0, lastTreeWidth, getHeight()); | treeViewTabs.setBounds (0, 0, lastTreeWidth, getHeight()); | ||||
@@ -64,12 +64,12 @@ public: | |||||
if (peer != nullptr) | if (peer != nullptr) | ||||
{ | { | ||||
Component* const comp = peer->getComponent(); | |||||
const Point<int> relativePos (comp->getLocalPoint (nullptr, screenPos)); | |||||
Component& comp = peer->getComponent(); | |||||
const Point<int> relativePos (comp.getLocalPoint (nullptr, screenPos)); | |||||
// (the contains() call is needed to test for overlapping desktop windows) | // (the contains() call is needed to test for overlapping desktop windows) | ||||
if (comp->contains (relativePos)) | |||||
return comp->getComponentAt (relativePos); | |||||
if (comp.contains (relativePos)) | |||||
return comp.getComponentAt (relativePos); | |||||
} | } | ||||
return nullptr; | return nullptr; | ||||
@@ -104,8 +104,8 @@ DECLARE_JNI_CLASS (ComponentPeerView, JUCE_ANDROID_ACTIVITY_CLASSPATH "$Componen | |||||
class AndroidComponentPeer : public ComponentPeer | class AndroidComponentPeer : public ComponentPeer | ||||
{ | { | ||||
public: | public: | ||||
AndroidComponentPeer (Component* const component, const int windowStyleFlags) | |||||
: ComponentPeer (component, windowStyleFlags), | |||||
AndroidComponentPeer (Component& comp, const int windowStyleFlags) | |||||
: ComponentPeer (comp, windowStyleFlags), | |||||
usingAndroidGraphics (false), | usingAndroidGraphics (false), | ||||
fullScreen (false), | fullScreen (false), | ||||
sizeAllocated (0) | sizeAllocated (0) | ||||
@@ -113,7 +113,7 @@ public: | |||||
// NB: must not put this in the initialiser list, as it invokes a callback, | // NB: must not put this in the initialiser list, as it invokes a callback, | ||||
// which will fail if the peer is only half-constructed. | // which will fail if the peer is only half-constructed. | ||||
view = GlobalRef (android.activity.callObjectMethod (JuceAppActivity.createNewView, | view = GlobalRef (android.activity.callObjectMethod (JuceAppActivity.createNewView, | ||||
component->isOpaque())); | |||||
component.isOpaque())); | |||||
if (isFocused()) | if (isFocused()) | ||||
handleFocusGain(); | handleFocusGain(); | ||||
@@ -285,7 +285,7 @@ public: | |||||
if (! r.isEmpty()) | if (! r.isEmpty()) | ||||
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | ||||
component->repaint(); | |||||
component.repaint(); | |||||
} | } | ||||
bool isFullScreen() const | bool isFullScreen() const | ||||
@@ -300,8 +300,8 @@ public: | |||||
bool contains (const Point<int>& position, bool trueIfInAChildWindow) const | bool contains (const Point<int>& position, bool trueIfInAChildWindow) const | ||||
{ | { | ||||
return isPositiveAndBelow (position.x, component->getWidth()) | |||||
&& isPositiveAndBelow (position.y, component->getHeight()) | |||||
return isPositiveAndBelow (position.x, component.getWidth()) | |||||
&& isPositiveAndBelow (position.y, component.getHeight()) | |||||
&& ((! trueIfInAChildWindow) || view.callBooleanMethod (ComponentPeerView.containsPoint, | && ((! trueIfInAChildWindow) || view.callBooleanMethod (ComponentPeerView.containsPoint, | ||||
position.x, position.y)); | position.x, position.y)); | ||||
} | } | ||||
@@ -406,7 +406,7 @@ public: | |||||
{ | { | ||||
{ | { | ||||
Image temp (new PreallocatedImage (clip.getWidth(), clip.getHeight(), | Image temp (new PreallocatedImage (clip.getWidth(), clip.getHeight(), | ||||
dest, ! component->isOpaque())); | |||||
dest, ! component.isOpaque())); | |||||
{ | { | ||||
LowLevelGraphicsSoftwareRenderer g (temp); | LowLevelGraphicsSoftwareRenderer g (temp); | ||||
@@ -563,7 +563,7 @@ JUCE_VIEW_CALLBACK (void, focusChanged, (JNIEnv* env, jobject view, jboolean | |||||
//============================================================================== | //============================================================================== | ||||
ComponentPeer* Component::createNewPeer (int styleFlags, void*) | ComponentPeer* Component::createNewPeer (int styleFlags, void*) | ||||
{ | { | ||||
return new AndroidComponentPeer (this, styleFlags); | |||||
return new AndroidComponentPeer (*this, styleFlags); | |||||
} | } | ||||
jobject createOpenGLView (ComponentPeer* peer) | jobject createOpenGLView (ComponentPeer* peer) | ||||
@@ -81,10 +81,7 @@ class UIViewComponentPeer : public ComponentPeer, | |||||
public FocusChangeListener | public FocusChangeListener | ||||
{ | { | ||||
public: | public: | ||||
UIViewComponentPeer (Component* const component, | |||||
const int windowStyleFlags, | |||||
UIView* viewToAttachTo); | |||||
UIViewComponentPeer (Component& comp, int windowStyleFlags, UIView* viewToAttachTo); | |||||
~UIViewComponentPeer(); | ~UIViewComponentPeer(); | ||||
//============================================================================== | //============================================================================== | ||||
@@ -377,10 +374,8 @@ namespace juce | |||||
{ | { | ||||
//============================================================================== | //============================================================================== | ||||
UIViewComponentPeer::UIViewComponentPeer (Component* const component, | |||||
const int windowStyleFlags, | |||||
UIView* viewToAttachTo) | |||||
: ComponentPeer (component, windowStyleFlags), | |||||
UIViewComponentPeer::UIViewComponentPeer (Component& comp, const int windowStyleFlags, UIView* viewToAttachTo) | |||||
: ComponentPeer (comp, windowStyleFlags), | |||||
window (nil), | window (nil), | ||||
view (nil), | view (nil), | ||||
controller (nil), | controller (nil), | ||||
@@ -388,13 +383,13 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component, | |||||
fullScreen (false), | fullScreen (false), | ||||
insideDrawRect (false) | insideDrawRect (false) | ||||
{ | { | ||||
CGRect r = convertToCGRect (component->getLocalBounds()); | |||||
CGRect r = convertToCGRect (component.getLocalBounds()); | |||||
view = [[JuceUIView alloc] initWithOwner: this withFrame: r]; | view = [[JuceUIView alloc] initWithOwner: this withFrame: r]; | ||||
view.multipleTouchEnabled = YES; | view.multipleTouchEnabled = YES; | ||||
view.hidden = ! component->isVisible(); | |||||
view.opaque = component->isOpaque(); | |||||
view.hidden = ! component.isVisible(); | |||||
view.opaque = component.isOpaque(); | |||||
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0]; | view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0]; | ||||
if (isSharedWindow) | if (isSharedWindow) | ||||
@@ -407,17 +402,17 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component, | |||||
controller = [[JuceUIViewController alloc] init]; | controller = [[JuceUIViewController alloc] init]; | ||||
controller.view = view; | controller.view = view; | ||||
r = convertToCGRect (rotatedScreenPosToReal (component->getBounds())); | |||||
r = convertToCGRect (rotatedScreenPosToReal (component.getBounds())); | |||||
r.origin.y = [UIScreen mainScreen].bounds.size.height - (r.origin.y + r.size.height); | r.origin.y = [UIScreen mainScreen].bounds.size.height - (r.origin.y + r.size.height); | ||||
window = [[JuceUIWindow alloc] init]; | window = [[JuceUIWindow alloc] init]; | ||||
window.frame = r; | window.frame = r; | ||||
window.opaque = component->isOpaque(); | |||||
window.opaque = component.isOpaque(); | |||||
window.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0]; | window.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0]; | ||||
[((JuceUIWindow*) window) setOwner: this]; | [((JuceUIWindow*) window) setOwner: this]; | ||||
if (component->isAlwaysOnTop()) | |||||
if (component.isAlwaysOnTop()) | |||||
window.windowLevel = UIWindowLevelAlert; | window.windowLevel = UIWindowLevelAlert; | ||||
[window addSubview: view]; | [window addSubview: view]; | ||||
@@ -426,7 +421,7 @@ UIViewComponentPeer::UIViewComponentPeer (Component* const component, | |||||
window.hidden = view.hidden; | window.hidden = view.hidden; | ||||
} | } | ||||
setTitle (component->getName()); | |||||
setTitle (component.getName()); | |||||
Desktop::getInstance().addFocusChangeListener (this); | Desktop::getInstance().addFocusChangeListener (this); | ||||
} | } | ||||
@@ -468,12 +463,12 @@ void UIViewComponentPeer::setTitle (const String& title) | |||||
void UIViewComponentPeer::setPosition (int x, int y) | void UIViewComponentPeer::setPosition (int x, int y) | ||||
{ | { | ||||
setBounds (x, y, component->getWidth(), component->getHeight(), false); | |||||
setBounds (x, y, component.getWidth(), component.getHeight(), false); | |||||
} | } | ||||
void UIViewComponentPeer::setSize (int w, int h) | void UIViewComponentPeer::setSize (int w, int h) | ||||
{ | { | ||||
setBounds (component->getX(), component->getY(), w, h, false); | |||||
setBounds (component.getX(), component.getY(), w, h, false); | |||||
} | } | ||||
void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen) | void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNowFullScreen) | ||||
@@ -595,7 +590,7 @@ void UIViewComponentPeer::setFullScreen (bool shouldBeFullScreen) | |||||
if (! r.isEmpty()) | if (! r.isEmpty()) | ||||
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | ||||
component->repaint(); | |||||
component.repaint(); | |||||
} | } | ||||
} | } | ||||
@@ -642,7 +637,7 @@ BOOL UIViewComponentPeer::shouldRotate (UIInterfaceOrientation interfaceOrientat | |||||
void UIViewComponentPeer::displayRotated() | void UIViewComponentPeer::displayRotated() | ||||
{ | { | ||||
Desktop& desktop = Desktop::getInstance(); | Desktop& desktop = Desktop::getInstance(); | ||||
const Rectangle<int> oldArea (component->getBounds()); | |||||
const Rectangle<int> oldArea (component.getBounds()); | |||||
const Rectangle<int> oldDesktop (desktop.getDisplays().getMainDisplay().userArea); | const Rectangle<int> oldDesktop (desktop.getDisplays().getMainDisplay().userArea); | ||||
const_cast <Desktop::Displays&> (desktop.getDisplays()).refresh(); | const_cast <Desktop::Displays&> (desktop.getDisplays()).refresh(); | ||||
@@ -672,8 +667,8 @@ void UIViewComponentPeer::displayRotated() | |||||
bool UIViewComponentPeer::contains (const Point<int>& position, bool trueIfInAChildWindow) const | bool UIViewComponentPeer::contains (const Point<int>& position, bool trueIfInAChildWindow) const | ||||
{ | { | ||||
if (! (isPositiveAndBelow (position.getX(), component->getWidth()) | |||||
&& isPositiveAndBelow (position.getY(), component->getHeight()))) | |||||
if (! (isPositiveAndBelow (position.getX(), component.getWidth()) | |||||
&& isPositiveAndBelow (position.getY(), component.getHeight()))) | |||||
return false; | return false; | ||||
UIView* v = [view hitTest: CGPointMake ((CGFloat) position.getX(), (CGFloat) position.getY()) | UIView* v = [view hitTest: CGPointMake ((CGFloat) position.getX(), (CGFloat) position.getY()) | ||||
@@ -703,7 +698,7 @@ void UIViewComponentPeer::toFront (bool makeActiveWindow) | |||||
if (isSharedWindow) | if (isSharedWindow) | ||||
[[view superview] bringSubviewToFront: view]; | [[view superview] bringSubviewToFront: view]; | ||||
if (window != nil && component->isVisible()) | |||||
if (window != nil && component.isVisible()) | |||||
[window makeKeyAndVisible]; | [window makeKeyAndVisible]; | ||||
} | } | ||||
@@ -876,7 +871,7 @@ void UIViewComponentPeer::globalFocusChanged (Component*) | |||||
{ | { | ||||
Component* comp = dynamic_cast<Component*> (target); | Component* comp = dynamic_cast<Component*> (target); | ||||
Point<int> pos (component->getLocalPoint (comp, Point<int>())); | |||||
Point<int> pos (component.getLocalPoint (comp, Point<int>())); | |||||
view->hiddenTextView.frame = CGRectMake (pos.getX(), pos.getY(), 0, 0); | view->hiddenTextView.frame = CGRectMake (pos.getX(), pos.getY(), 0, 0); | ||||
updateHiddenTextContent (target); | updateHiddenTextContent (target); | ||||
@@ -897,7 +892,7 @@ void UIViewComponentPeer::drawRect (CGRect r) | |||||
CGContextRef cg = UIGraphicsGetCurrentContext(); | CGContextRef cg = UIGraphicsGetCurrentContext(); | ||||
if (! component->isOpaque()) | |||||
if (! component.isOpaque()) | |||||
CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); | CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); | ||||
CGContextConcatCTM (cg, CGAffineTransformMake (1, 0, 0, -1, 0, view.bounds.size.height)); | CGContextConcatCTM (cg, CGAffineTransformMake (1, 0, 0, -1, 0, view.bounds.size.height)); | ||||
@@ -978,7 +973,7 @@ void UIViewComponentPeer::performAnyPendingRepaintsNow() | |||||
ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) | ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) | ||||
{ | { | ||||
return new UIViewComponentPeer (this, styleFlags, (UIView*) windowToAttachTo); | |||||
return new UIViewComponentPeer (*this, styleFlags, (UIView*) windowToAttachTo); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -741,8 +741,8 @@ namespace PixmapHelpers | |||||
class LinuxComponentPeer : public ComponentPeer | class LinuxComponentPeer : public ComponentPeer | ||||
{ | { | ||||
public: | public: | ||||
LinuxComponentPeer (Component* const component, const int windowStyleFlags, Window parentToAddTo) | |||||
: ComponentPeer (component, windowStyleFlags), | |||||
LinuxComponentPeer (Component& comp, const int windowStyleFlags, Window parentToAddTo) | |||||
: ComponentPeer (comp, windowStyleFlags), | |||||
windowH (0), parentWindow (0), | windowH (0), parentWindow (0), | ||||
fullScreen (false), mapped (false), | fullScreen (false), mapped (false), | ||||
visual (0), depth (0) | visual (0), depth (0) | ||||
@@ -754,7 +754,7 @@ public: | |||||
createWindow (parentToAddTo); | createWindow (parentToAddTo); | ||||
setTitle (component->getName()); | |||||
setTitle (component.getName()); | |||||
} | } | ||||
~LinuxComponentPeer() | ~LinuxComponentPeer() | ||||
@@ -847,7 +847,7 @@ public: | |||||
{ | { | ||||
bounds.setBounds (x, y, jmax (1, w), jmax (1, h)); | bounds.setBounds (x, y, jmax (1, w), jmax (1, h)); | ||||
WeakReference<Component> deletionChecker (component); | |||||
WeakReference<Component> deletionChecker (&component); | |||||
ScopedXLock xlock; | ScopedXLock xlock; | ||||
XSizeHints* const hints = XAllocSizeHints(); | XSizeHints* const hints = XAllocSizeHints(); | ||||
@@ -964,7 +964,7 @@ public: | |||||
if (! r.isEmpty()) | if (! r.isEmpty()) | ||||
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | ||||
getComponent()->repaint(); | |||||
component.repaint(); | |||||
} | } | ||||
} | } | ||||
@@ -1029,7 +1029,7 @@ public: | |||||
{ | { | ||||
Component* const c = Desktop::getInstance().getComponent (i); | Component* const c = Desktop::getInstance().getComponent (i); | ||||
if (c == getComponent()) | |||||
if (c == &component) | |||||
break; | break; | ||||
if (c->contains (position + bounds.getPosition() - c->getScreenPosition())) | if (c->contains (position + bounds.getPosition() - c->getScreenPosition())) | ||||
@@ -1089,7 +1089,7 @@ public: | |||||
XWindowAttributes attr; | XWindowAttributes attr; | ||||
XGetWindowAttributes (display, windowH, &attr); | XGetWindowAttributes (display, windowH, &attr); | ||||
if (component->isAlwaysOnTop()) | |||||
if (component.isAlwaysOnTop()) | |||||
XRaiseWindow (display, windowH); | XRaiseWindow (display, windowH); | ||||
XSync (display, False); | XSync (display, False); | ||||
@@ -1145,7 +1145,7 @@ public: | |||||
void repaint (const Rectangle<int>& area) | void repaint (const Rectangle<int>& area) | ||||
{ | { | ||||
repainter->repaint (area.getIntersection (getComponent()->getLocalBounds())); | |||||
repainter->repaint (area.getIntersection (component.getLocalBounds())); | |||||
} | } | ||||
void performAnyPendingRepaintsNow() | void performAnyPendingRepaintsNow() | ||||
@@ -1569,7 +1569,7 @@ public: | |||||
// if the native title bar is dragged, need to tell any active menus, etc. | // if the native title bar is dragged, need to tell any active menus, etc. | ||||
if ((styleFlags & windowHasTitleBar) != 0 | if ((styleFlags & windowHasTitleBar) != 0 | ||||
&& component->isCurrentlyBlockedByAnotherModalComponent()) | |||||
&& component.isCurrentlyBlockedByAnotherModalComponent()) | |||||
{ | { | ||||
Component* const currentModalComp = Component::getCurrentlyModalComponent(); | Component* const currentModalComp = Component::getCurrentlyModalComponent(); | ||||
@@ -1796,7 +1796,7 @@ private: | |||||
} | } | ||||
{ | { | ||||
ScopedPointer<LowLevelGraphicsContext> context (peer->getComponent()->getLookAndFeel() | |||||
ScopedPointer<LowLevelGraphicsContext> context (peer->component.getLookAndFeel() | |||||
.createGraphicsContext (image, -totalArea.getPosition(), adjustedList)); | .createGraphicsContext (image, -totalArea.getPosition(), adjustedList)); | ||||
peer->handlePaint (*context); | peer->handlePaint (*context); | ||||
} | } | ||||
@@ -2081,7 +2081,7 @@ private: | |||||
if ((styleFlags & windowAppearsOnTaskbar) == 0) | if ((styleFlags & windowAppearsOnTaskbar) == 0) | ||||
netHints [numHints++] = Atoms::getIfExists ("_NET_WM_STATE_SKIP_TASKBAR"); | netHints [numHints++] = Atoms::getIfExists ("_NET_WM_STATE_SKIP_TASKBAR"); | ||||
if (component->isAlwaysOnTop()) | |||||
if (component.isAlwaysOnTop()) | |||||
netHints [numHints++] = Atoms::getIfExists ("_NET_WM_STATE_ABOVE"); | netHints [numHints++] = Atoms::getIfExists ("_NET_WM_STATE_ABOVE"); | ||||
if (numHints > 0) | if (numHints > 0) | ||||
@@ -2116,7 +2116,7 @@ private: | |||||
swa.border_pixel = 0; | swa.border_pixel = 0; | ||||
swa.background_pixmap = None; | swa.background_pixmap = None; | ||||
swa.colormap = colormap; | swa.colormap = colormap; | ||||
swa.override_redirect = (getComponent()->isAlwaysOnTop() && (styleFlags & windowIsTemporary) != 0) ? True : False; | |||||
swa.override_redirect = (component.isAlwaysOnTop() && (styleFlags & windowIsTemporary) != 0) ? True : False; | |||||
swa.event_mask = getAllEventsMask(); | swa.event_mask = getAllEventsMask(); | ||||
windowH = XCreateWindow (display, parentToAddTo != 0 ? parentToAddTo : root, | windowH = XCreateWindow (display, parentToAddTo != 0 ? parentToAddTo : root, | ||||
@@ -2157,7 +2157,7 @@ private: | |||||
else | else | ||||
addWindowButtons (windowH); | addWindowButtons (windowH); | ||||
setTitle (getComponent()->getName()); | |||||
setTitle (component.getName()); | |||||
// Associate the PID, allowing to be shut down when something goes wrong | // Associate the PID, allowing to be shut down when something goes wrong | ||||
unsigned long pid = getpid(); | unsigned long pid = getpid(); | ||||
@@ -2594,7 +2594,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis | |||||
//============================================================================== | //============================================================================== | ||||
ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) | ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) | ||||
{ | { | ||||
return new LinuxComponentPeer (this, styleFlags, (Window) nativeWindowToAttachTo); | |||||
return new LinuxComponentPeer (*this, styleFlags, (Window) nativeWindowToAttachTo); | |||||
} | } | ||||
@@ -46,7 +46,7 @@ namespace juce { | |||||
class NSViewComponentPeer : public ComponentPeer | class NSViewComponentPeer : public ComponentPeer | ||||
{ | { | ||||
public: | public: | ||||
NSViewComponentPeer (Component* const comp, const int windowStyleFlags, NSView* viewToAttachTo) | |||||
NSViewComponentPeer (Component& comp, const int windowStyleFlags, NSView* viewToAttachTo) | |||||
: ComponentPeer (comp, windowStyleFlags), | : ComponentPeer (comp, windowStyleFlags), | ||||
window (nil), | window (nil), | ||||
view (nil), | view (nil), | ||||
@@ -66,7 +66,7 @@ public: | |||||
appFocusChangeCallback = appFocusChanged; | appFocusChangeCallback = appFocusChanged; | ||||
isEventBlockedByModalComps = checkEventBlockedByModalComps; | isEventBlockedByModalComps = checkEventBlockedByModalComps; | ||||
NSRect r = NSMakeRect (0, 0, (CGFloat) component->getWidth(), (CGFloat) component->getHeight()); | |||||
NSRect r = NSMakeRect (0, 0, (CGFloat) component.getWidth(), (CGFloat) component.getHeight()); | |||||
view = [createViewInstance() initWithFrame: r]; | view = [createViewInstance() initWithFrame: r]; | ||||
setOwner (view, this); | setOwner (view, this); | ||||
@@ -95,8 +95,8 @@ public: | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
r.origin.x = (CGFloat) component->getX(); | |||||
r.origin.y = (CGFloat) component->getY(); | |||||
r.origin.x = (CGFloat) component.getX(); | |||||
r.origin.y = (CGFloat) component.getY(); | |||||
r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height); | r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height); | ||||
window = [createWindowInstance() initWithContentRect: r | window = [createWindowInstance() initWithContentRect: r | ||||
@@ -111,10 +111,10 @@ public: | |||||
#else | #else | ||||
[window setDelegate: window]; | [window setDelegate: window]; | ||||
#endif | #endif | ||||
[window setOpaque: component->isOpaque()]; | |||||
[window setOpaque: component.isOpaque()]; | |||||
[window setHasShadow: ((windowStyleFlags & windowHasDropShadow) != 0)]; | [window setHasShadow: ((windowStyleFlags & windowHasDropShadow) != 0)]; | ||||
if (component->isAlwaysOnTop()) | |||||
if (component.isAlwaysOnTop()) | |||||
[window setLevel: NSFloatingWindowLevel]; | [window setLevel: NSFloatingWindowLevel]; | ||||
[window setContentView: view]; | [window setContentView: view]; | ||||
@@ -135,11 +135,11 @@ public: | |||||
#endif | #endif | ||||
} | } | ||||
const float alpha = component->getAlpha(); | |||||
const float alpha = component.getAlpha(); | |||||
if (alpha < 1.0f) | if (alpha < 1.0f) | ||||
setAlpha (alpha); | setAlpha (alpha); | ||||
setTitle (component->getName()); | |||||
setTitle (component.getName()); | |||||
} | } | ||||
~NSViewComponentPeer() | ~NSViewComponentPeer() | ||||
@@ -190,12 +190,12 @@ public: | |||||
void setPosition (int x, int y) | void setPosition (int x, int y) | ||||
{ | { | ||||
setBounds (x, y, component->getWidth(), component->getHeight(), false); | |||||
setBounds (x, y, component.getWidth(), component.getHeight(), false); | |||||
} | } | ||||
void setSize (int w, int h) | void setSize (int w, int h) | ||||
{ | { | ||||
setBounds (component->getX(), component->getY(), w, h, false); | |||||
setBounds (component.getX(), component.getY(), w, h, false); | |||||
} | } | ||||
void setBounds (int x, int y, int w, int h, bool isNowFullScreen) | void setBounds (int x, int y, int w, int h, bool isNowFullScreen) | ||||
@@ -330,10 +330,10 @@ public: | |||||
else | else | ||||
{ | { | ||||
if (shouldBeFullScreen) | if (shouldBeFullScreen) | ||||
r = component->getParentMonitorArea(); | |||||
r = component.getParentMonitorArea(); | |||||
// (can't call the component's setBounds method because that'll reset our fullscreen flag) | // (can't call the component's setBounds method because that'll reset our fullscreen flag) | ||||
if (r != getComponent()->getBounds() && ! r.isEmpty()) | |||||
if (r != component.getBounds() && ! r.isEmpty()) | |||||
setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen); | ||||
} | } | ||||
} | } | ||||
@@ -347,8 +347,8 @@ public: | |||||
bool contains (const Point<int>& position, bool trueIfInAChildWindow) const | bool contains (const Point<int>& position, bool trueIfInAChildWindow) const | ||||
{ | { | ||||
if (! (isPositiveAndBelow (position.getX(), component->getWidth()) | |||||
&& isPositiveAndBelow (position.getY(), component->getHeight()))) | |||||
if (! (isPositiveAndBelow (position.getX(), component.getWidth()) | |||||
&& isPositiveAndBelow (position.getY(), component.getHeight()))) | |||||
return false; | return false; | ||||
NSRect frameRect = [view frame]; | NSRect frameRect = [view frame]; | ||||
@@ -384,8 +384,8 @@ public: | |||||
{ | { | ||||
if (hasNativeTitleBar()) | if (hasNativeTitleBar()) | ||||
{ | { | ||||
const Rectangle<int> screen (getFrameSize().subtractedFrom (component->getParentMonitorArea())); | |||||
const Rectangle<int> window (component->getScreenBounds()); | |||||
const Rectangle<int> screen (getFrameSize().subtractedFrom (component.getParentMonitorArea())); | |||||
const Rectangle<int> window (component.getScreenBounds()); | |||||
fullScreen = window.expanded (2, 2).contains (screen); | fullScreen = window.expanded (2, 2).contains (screen); | ||||
} | } | ||||
@@ -411,7 +411,7 @@ public: | |||||
positioned: NSWindowAbove | positioned: NSWindowAbove | ||||
relativeTo: nil]; | relativeTo: nil]; | ||||
if (window != nil && component->isVisible()) | |||||
if (window != nil && component.isVisible()) | |||||
{ | { | ||||
if (makeActiveWindow) | if (makeActiveWindow) | ||||
[window makeKeyAndOrderFront: nil]; | [window makeKeyAndOrderFront: nil]; | ||||
@@ -681,7 +681,7 @@ public: | |||||
bool isOpaque() | bool isOpaque() | ||||
{ | { | ||||
return component == nullptr || component->isOpaque(); | |||||
return component.isOpaque(); | |||||
} | } | ||||
void drawRect (NSRect r) | void drawRect (NSRect r) | ||||
@@ -691,7 +691,7 @@ public: | |||||
CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; | CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; | ||||
if (! component->isOpaque()) | |||||
if (! component.isOpaque()) | |||||
CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); | CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); | ||||
#if USE_COREGRAPHICS_RENDERING | #if USE_COREGRAPHICS_RENDERING | ||||
@@ -724,11 +724,11 @@ public: | |||||
if (! clip.isEmpty()) | if (! clip.isEmpty()) | ||||
{ | { | ||||
Image temp (getComponent()->isOpaque() ? Image::RGB : Image::ARGB, | |||||
clipW, clipH, ! getComponent()->isOpaque()); | |||||
Image temp (component.isOpaque() ? Image::RGB : Image::ARGB, | |||||
clipW, clipH, ! component.isOpaque()); | |||||
{ | { | ||||
ScopedPointer<LowLevelGraphicsContext> context (component->getLookAndFeel() | |||||
ScopedPointer<LowLevelGraphicsContext> context (component.getLookAndFeel() | |||||
.createGraphicsContext (temp, Point<int> (xOffset, yOffset), clip)); | .createGraphicsContext (temp, Point<int> (xOffset, yOffset), clip)); | ||||
insideDrawRect = true; | insideDrawRect = true; | ||||
@@ -1708,7 +1708,7 @@ private: | |||||
frameRect = owner->constrainRect (frameRect); | frameRect = owner->constrainRect (frameRect); | ||||
if (juce::Component::getCurrentlyModalComponent() != nullptr | if (juce::Component::getCurrentlyModalComponent() != nullptr | ||||
&& owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent() | |||||
&& owner->getComponent().isCurrentlyBlockedByAnotherModalComponent() | |||||
&& owner->hasNativeTitleBar()) | && owner->hasNativeTitleBar()) | ||||
juce::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); | juce::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); | ||||
@@ -1732,7 +1732,7 @@ private: | |||||
NSViewComponentPeer* const owner = getOwner (self); | NSViewComponentPeer* const owner = getOwner (self); | ||||
if (juce::Component::getCurrentlyModalComponent() != nullptr | if (juce::Component::getCurrentlyModalComponent() != nullptr | ||||
&& owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent() | |||||
&& owner->getComponent().isCurrentlyBlockedByAnotherModalComponent() | |||||
&& owner->hasNativeTitleBar()) | && owner->hasNativeTitleBar()) | ||||
juce::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); | juce::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); | ||||
} | } | ||||
@@ -1827,7 +1827,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis | |||||
if (peer->hasNativeTitleBar()) | if (peer->hasNativeTitleBar()) | ||||
{ | { | ||||
[peer->window setStyleMask: (NSViewComponentPeer::getNSWindowStyleMask (peer->getStyleFlags()))]; | [peer->window setStyleMask: (NSViewComponentPeer::getNSWindowStyleMask (peer->getStyleFlags()))]; | ||||
peer->setTitle (peer->component->getName()); // required to force the OS to update the title | |||||
peer->setTitle (peer->component.getName()); // required to force the OS to update the title | |||||
} | } | ||||
[NSApp setPresentationOptions: NSApplicationPresentationDefault]; | [NSApp setPresentationOptions: NSApplicationPresentationDefault]; | ||||
@@ -1853,7 +1853,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis | |||||
//============================================================================== | //============================================================================== | ||||
ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) | ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo) | ||||
{ | { | ||||
return new NSViewComponentPeer (this, styleFlags, (NSView*) windowToAttachTo); | |||||
return new NSViewComponentPeer (*this, styleFlags, (NSView*) windowToAttachTo); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -463,10 +463,8 @@ public: | |||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
HWNDComponentPeer (Component* const component, | |||||
const int windowStyleFlags, | |||||
HWND parentToAddTo_) | |||||
: ComponentPeer (component, windowStyleFlags), | |||||
HWNDComponentPeer (Component& comp, const int windowStyleFlags, HWND parentToAddTo_) | |||||
: ComponentPeer (comp, windowStyleFlags), | |||||
dontRepaint (false), | dontRepaint (false), | ||||
currentRenderingEngine (softwareRenderingEngine), | currentRenderingEngine (softwareRenderingEngine), | ||||
fullScreen (false), | fullScreen (false), | ||||
@@ -481,15 +479,15 @@ public: | |||||
{ | { | ||||
callFunctionIfNotLocked (&createWindowCallback, this); | callFunctionIfNotLocked (&createWindowCallback, this); | ||||
setTitle (component->getName()); | |||||
setTitle (component.getName()); | |||||
if ((windowStyleFlags & windowHasDropShadow) != 0 | if ((windowStyleFlags & windowHasDropShadow) != 0 | ||||
&& Desktop::canUseSemiTransparentWindows()) | && Desktop::canUseSemiTransparentWindows()) | ||||
{ | { | ||||
shadower = component->getLookAndFeel().createDropShadowerForComponent (component); | |||||
shadower = component.getLookAndFeel().createDropShadowerForComponent (&component); | |||||
if (shadower != nullptr) | if (shadower != nullptr) | ||||
shadower->setOwner (component); | |||||
shadower->setOwner (&component); | |||||
} | } | ||||
} | } | ||||
@@ -641,7 +639,7 @@ public: | |||||
{ | { | ||||
const uint8 intAlpha = (uint8) jlimit (0, 255, (int) (newAlpha * 255.0f)); | const uint8 intAlpha = (uint8) jlimit (0, 255, (int) (newAlpha * 255.0f)); | ||||
if (component->isOpaque()) | |||||
if (component.isOpaque()) | |||||
{ | { | ||||
if (newAlpha < 1.0f) | if (newAlpha < 1.0f) | ||||
{ | { | ||||
@@ -657,7 +655,7 @@ public: | |||||
else | else | ||||
{ | { | ||||
updateLayeredWindowAlpha = intAlpha; | updateLayeredWindowAlpha = intAlpha; | ||||
component->repaint(); | |||||
component.repaint(); | |||||
} | } | ||||
} | } | ||||
@@ -683,7 +681,7 @@ public: | |||||
if (isFullScreen() != shouldBeFullScreen) | if (isFullScreen() != shouldBeFullScreen) | ||||
{ | { | ||||
fullScreen = shouldBeFullScreen; | fullScreen = shouldBeFullScreen; | ||||
const WeakReference<Component> deletionChecker (component); | |||||
const WeakReference<Component> deletionChecker (&component); | |||||
if (! fullScreen) | if (! fullScreen) | ||||
{ | { | ||||
@@ -740,8 +738,8 @@ public: | |||||
bool contains (const Point<int>& position, bool trueIfInAChildWindow) const | bool contains (const Point<int>& position, bool trueIfInAChildWindow) const | ||||
{ | { | ||||
return isPositiveAndBelow (position.x, component->getWidth()) | |||||
&& isPositiveAndBelow (position.y, component->getHeight()) | |||||
return isPositiveAndBelow (position.x, component.getWidth()) | |||||
&& isPositiveAndBelow (position.y, component.getHeight()) | |||||
&& isWindowAtPoint (position, trueIfInAChildWindow); | && isWindowAtPoint (position, trueIfInAChildWindow); | ||||
} | } | ||||
@@ -797,12 +795,10 @@ public: | |||||
// Must be careful not to try to put a topmost window behind a normal one, or Windows | // Must be careful not to try to put a topmost window behind a normal one, or Windows | ||||
// promotes the normal one to be topmost! | // promotes the normal one to be topmost! | ||||
if (getComponent()->isAlwaysOnTop() == otherPeer->getComponent()->isAlwaysOnTop()) | |||||
SetWindowPos (hwnd, otherPeer->hwnd, 0, 0, 0, 0, | |||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); | |||||
else if (otherPeer->getComponent()->isAlwaysOnTop()) | |||||
SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, | |||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); | |||||
if (component.isAlwaysOnTop() == otherPeer->component.isAlwaysOnTop()) | |||||
SetWindowPos (hwnd, otherPeer->hwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); | |||||
else if (otherPeer->component.isAlwaysOnTop()) | |||||
SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); | |||||
} | } | ||||
} | } | ||||
@@ -847,7 +843,7 @@ public: | |||||
void performAnyPendingRepaintsNow() | void performAnyPendingRepaintsNow() | ||||
{ | { | ||||
MSG m; | MSG m; | ||||
if (component->isVisible() | |||||
if (component.isVisible() | |||||
&& (PeekMessage (&m, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE) || isUsingUpdateLayeredWindow())) | && (PeekMessage (&m, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE) || isUsingUpdateLayeredWindow())) | ||||
handlePaintMessage(); | handlePaintMessage(); | ||||
} | } | ||||
@@ -1308,7 +1304,7 @@ private: | |||||
// correctly enable the menu items that we specify in the wm_initmenu message. | // correctly enable the menu items that we specify in the wm_initmenu message. | ||||
GetSystemMenu (hwnd, false); | GetSystemMenu (hwnd, false); | ||||
const float alpha = component->getAlpha(); | |||||
const float alpha = component.getAlpha(); | |||||
if (alpha < 1.0f) | if (alpha < 1.0f) | ||||
setAlpha (alpha); | setAlpha (alpha); | ||||
} | } | ||||
@@ -1366,7 +1362,7 @@ private: | |||||
bool isUsingUpdateLayeredWindow() const | bool isUsingUpdateLayeredWindow() const | ||||
{ | { | ||||
return ! component->isOpaque(); | |||||
return ! component.isOpaque(); | |||||
} | } | ||||
inline bool hasTitleBar() const noexcept { return (styleFlags & windowHasTitleBar) != 0; } | inline bool hasTitleBar() const noexcept { return (styleFlags & windowHasTitleBar) != 0; } | ||||
@@ -1514,12 +1510,12 @@ private: | |||||
} | } | ||||
// if the component's not opaque, this won't draw properly unless the platform can support this | // if the component's not opaque, this won't draw properly unless the platform can support this | ||||
jassert (Desktop::canUseSemiTransparentWindows() || component->isOpaque()); | |||||
jassert (Desktop::canUseSemiTransparentWindows() || component.isOpaque()); | |||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
{ | { | ||||
ScopedPointer<LowLevelGraphicsContext> context (component->getLookAndFeel() | |||||
ScopedPointer<LowLevelGraphicsContext> context (component.getLookAndFeel() | |||||
.createGraphicsContext (offscreenImage, Point<int> (-x, -y), contextClip)); | .createGraphicsContext (offscreenImage, Point<int> (-x, -y), contextClip)); | ||||
handlePaint (*context); | handlePaint (*context); | ||||
} | } | ||||
@@ -1579,7 +1575,7 @@ private: | |||||
{ | { | ||||
currentRenderingEngine = index == 1 ? direct2DRenderingEngine : softwareRenderingEngine; | currentRenderingEngine = index == 1 ? direct2DRenderingEngine : softwareRenderingEngine; | ||||
updateDirect2DContext(); | updateDirect2DContext(); | ||||
repaint (component->getLocalBounds()); | |||||
repaint (component.getLocalBounds()); | |||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
@@ -2002,7 +1998,7 @@ private: | |||||
{ | { | ||||
Rectangle<int> pos (rectangleFromRECT (*r)); | Rectangle<int> pos (rectangleFromRECT (*r)); | ||||
constrainer->checkBounds (pos, windowBorder.addedTo (component->getBounds()), | |||||
constrainer->checkBounds (pos, windowBorder.addedTo (component.getBounds()), | |||||
Desktop::getInstance().getDisplays().getTotalBounds (true), | Desktop::getInstance().getDisplays().getTotalBounds (true), | ||||
wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT, | wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT, | ||||
wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT, | wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT, | ||||
@@ -2025,7 +2021,7 @@ private: | |||||
&& ! Component::isMouseButtonDownAnywhere()) | && ! Component::isMouseButtonDownAnywhere()) | ||||
{ | { | ||||
Rectangle<int> pos (wp->x, wp->y, wp->cx, wp->cy); | Rectangle<int> pos (wp->x, wp->y, wp->cx, wp->cy); | ||||
const Rectangle<int> current (windowBorder.addedTo (component->getBounds())); | |||||
const Rectangle<int> current (windowBorder.addedTo (component.getBounds())); | |||||
constrainer->checkBounds (pos, current, | constrainer->checkBounds (pos, current, | ||||
Desktop::getInstance().getDisplays().getTotalBounds (true), | Desktop::getInstance().getDisplays().getTotalBounds (true), | ||||
@@ -2050,17 +2046,17 @@ private: | |||||
if (isMinimised()) | if (isMinimised()) | ||||
{ | { | ||||
component->repaint(); | |||||
component.repaint(); | |||||
handleMovedOrResized(); | handleMovedOrResized(); | ||||
if (! ComponentPeer::isValidPeer (this)) | if (! ComponentPeer::isValidPeer (this)) | ||||
return; | return; | ||||
} | } | ||||
Component* underMouse = component->getComponentAt (component->getMouseXYRelative()); | |||||
Component* underMouse = component.getComponentAt (component.getMouseXYRelative()); | |||||
if (underMouse == nullptr) | if (underMouse == nullptr) | ||||
underMouse = component; | |||||
underMouse = &component; | |||||
if (underMouse->isCurrentlyBlockedByAnotherModalComponent()) | if (underMouse->isCurrentlyBlockedByAnotherModalComponent()) | ||||
{ | { | ||||
@@ -2125,7 +2121,7 @@ private: | |||||
if (fullScreen && ! isMinimised()) | if (fullScreen && ! isMinimised()) | ||||
{ | { | ||||
const Rectangle<int> r (component->getParentMonitorArea()); | |||||
const Rectangle<int> r (component.getParentMonitorArea()); | |||||
SetWindowPos (hwnd, 0, r.getX(), r.getY(), r.getWidth(), r.getHeight(), | SetWindowPos (hwnd, 0, r.getX(), r.getY(), r.getWidth(), r.getHeight(), | ||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSENDCHANGING); | SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSENDCHANGING); | ||||
@@ -2333,7 +2329,7 @@ private: | |||||
break; | break; | ||||
case WM_MOUSEACTIVATE: | case WM_MOUSEACTIVATE: | ||||
if (! component->getMouseClickGrabsKeyboardFocus()) | |||||
if (! component.getMouseClickGrabsKeyboardFocus()) | |||||
return MA_NOACTIVATE; | return MA_NOACTIVATE; | ||||
break; | break; | ||||
@@ -2345,7 +2341,7 @@ private: | |||||
break; | break; | ||||
case WM_CLOSE: | case WM_CLOSE: | ||||
if (! component->isCurrentlyBlockedByAnotherModalComponent()) | |||||
if (! component.isCurrentlyBlockedByAnotherModalComponent()) | |||||
handleUserClosingWindow(); | handleUserClosingWindow(); | ||||
return 0; | return 0; | ||||
@@ -2467,7 +2463,7 @@ private: | |||||
bool sendInputAttemptWhenModalMessage() | bool sendInputAttemptWhenModalMessage() | ||||
{ | { | ||||
if (component->isCurrentlyBlockedByAnotherModalComponent()) | |||||
if (component.isCurrentlyBlockedByAnotherModalComponent()) | |||||
{ | { | ||||
Component* const current = Component::getCurrentlyModalComponent(); | Component* const current = Component::getCurrentlyModalComponent(); | ||||
@@ -2695,8 +2691,7 @@ private: | |||||
if (targetComp != nullptr) | if (targetComp != nullptr) | ||||
{ | { | ||||
const Rectangle<int> area (peer.getComponent() | |||||
->getLocalArea (targetComp, target->getCaretRectangle())); | |||||
const Rectangle<int> area (peer.getComponent().getLocalArea (targetComp, target->getCaretRectangle())); | |||||
CANDIDATEFORM pos = { 0, CFS_CANDIDATEPOS, { area.getX(), area.getBottom() }, { 0, 0, 0, 0 } }; | CANDIDATEFORM pos = { 0, CFS_CANDIDATEPOS, { area.getX(), area.getBottom() }, { 0, 0, 0, 0 } }; | ||||
ImmSetCandidateWindow (hImc, &pos); | ImmSetCandidateWindow (hImc, &pos); | ||||
@@ -2717,12 +2712,14 @@ ModifierKeys HWNDComponentPeer::modifiersAtLastCallback; | |||||
ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) | ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo) | ||||
{ | { | ||||
return new HWNDComponentPeer (this, styleFlags, (HWND) nativeWindowToAttachTo); | |||||
return new HWNDComponentPeer (*this, styleFlags, (HWND) nativeWindowToAttachTo); | |||||
} | } | ||||
ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component* component, void* parent) | ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component* component, void* parent) | ||||
{ | { | ||||
HWNDComponentPeer* const p = new HWNDComponentPeer (component, ComponentPeer::windowIgnoresMouseClicks, (HWND) parent); | |||||
jassert (component != nullptr); | |||||
HWNDComponentPeer* const p = new HWNDComponentPeer (*component, ComponentPeer::windowIgnoresMouseClicks, (HWND) parent); | |||||
p->dontRepaint = true; | p->dontRepaint = true; | ||||
return p; | return p; | ||||
} | } | ||||
@@ -30,7 +30,7 @@ static Array <ComponentPeer*> heavyweightPeers; | |||||
static uint32 lastUniqueID = 1; | static uint32 lastUniqueID = 1; | ||||
//============================================================================== | //============================================================================== | ||||
ComponentPeer::ComponentPeer (Component* const component_, const int styleFlags_) | |||||
ComponentPeer::ComponentPeer (Component& component_, const int styleFlags_) | |||||
: component (component_), | : component (component_), | ||||
styleFlags (styleFlags_), | styleFlags (styleFlags_), | ||||
lastPaintTime (0), | lastPaintTime (0), | ||||
@@ -66,7 +66,7 @@ ComponentPeer* ComponentPeer::getPeerFor (const Component* const component) noex | |||||
{ | { | ||||
ComponentPeer* const peer = heavyweightPeers.getUnchecked(i); | ComponentPeer* const peer = heavyweightPeers.getUnchecked(i); | ||||
if (peer->getComponent() == component) | |||||
if (&(peer->getComponent()) == component) | |||||
return peer; | return peer; | ||||
} | } | ||||
@@ -111,7 +111,7 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) | |||||
JUCE_TRY | JUCE_TRY | ||||
{ | { | ||||
component->paintEntireComponent (g, true); | |||||
component.paintEntireComponent (g, true); | |||||
} | } | ||||
JUCE_CATCH_EXCEPTION | JUCE_CATCH_EXCEPTION | ||||
@@ -135,13 +135,21 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) | |||||
jassert (roundToInt (10.1f) == 10); | jassert (roundToInt (10.1f) == 10); | ||||
} | } | ||||
Component* ComponentPeer::getTargetForKeyPress() | |||||
{ | |||||
Component* c = Component::getCurrentlyFocusedComponent(); | |||||
if (c == nullptr) | |||||
c = &component; | |||||
return c; | |||||
} | |||||
bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textCharacter) | bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textCharacter) | ||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
Component* target = Component::getCurrentlyFocusedComponent() != nullptr | |||||
? Component::getCurrentlyFocusedComponent() | |||||
: component; | |||||
Component* target = getTargetForKeyPress(); | |||||
if (target->isCurrentlyBlockedByAnotherModalComponent()) | if (target->isCurrentlyBlockedByAnotherModalComponent()) | ||||
{ | { | ||||
@@ -206,9 +214,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown) | |||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
Component* target = Component::getCurrentlyFocusedComponent() != nullptr | |||||
? Component::getCurrentlyFocusedComponent() | |||||
: component; | |||||
Component* target = getTargetForKeyPress(); | |||||
if (target->isCurrentlyBlockedByAnotherModalComponent()) | if (target->isCurrentlyBlockedByAnotherModalComponent()) | ||||
{ | { | ||||
@@ -260,7 +266,7 @@ void ComponentPeer::handleModifierKeysChange() | |||||
target = Component::getCurrentlyFocusedComponent(); | target = Component::getCurrentlyFocusedComponent(); | ||||
if (target == nullptr) | if (target == nullptr) | ||||
target = component; | |||||
target = &component; | |||||
if (target != nullptr) | if (target != nullptr) | ||||
target->internalModifierKeysChanged(); | target->internalModifierKeysChanged(); | ||||
@@ -269,7 +275,7 @@ void ComponentPeer::handleModifierKeysChange() | |||||
TextInputTarget* ComponentPeer::findCurrentTextInputTarget() | TextInputTarget* ComponentPeer::findCurrentTextInputTarget() | ||||
{ | { | ||||
Component* const c = Component::getCurrentlyFocusedComponent(); | Component* const c = Component::getCurrentlyFocusedComponent(); | ||||
if (component->isParentOf (c)) | |||||
if (component.isParentOf (c)) | |||||
{ | { | ||||
TextInputTarget* const ti = dynamic_cast <TextInputTarget*> (c); | TextInputTarget* const ti = dynamic_cast <TextInputTarget*> (c); | ||||
if (ti != nullptr && ti->isTextInputActive()) | if (ti != nullptr && ti->isTextInputActive()) | ||||
@@ -287,9 +293,7 @@ void ComponentPeer::dismissPendingTextInput() | |||||
void ComponentPeer::handleBroughtToFront() | void ComponentPeer::handleBroughtToFront() | ||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
if (component != nullptr) | |||||
component->internalBroughtToFront(); | |||||
component.internalBroughtToFront(); | |||||
} | } | ||||
void ComponentPeer::setConstrainer (ComponentBoundsConstrainer* const newConstrainer) noexcept | void ComponentPeer::setConstrainer (ComponentBoundsConstrainer* const newConstrainer) noexcept | ||||
@@ -303,22 +307,22 @@ void ComponentPeer::handleMovedOrResized() | |||||
const bool nowMinimised = isMinimised(); | const bool nowMinimised = isMinimised(); | ||||
if (component->flags.hasHeavyweightPeerFlag && ! nowMinimised) | |||||
if (component.flags.hasHeavyweightPeerFlag && ! nowMinimised) | |||||
{ | { | ||||
const WeakReference<Component> deletionChecker (component); | |||||
const WeakReference<Component> deletionChecker (&component); | |||||
const Rectangle<int> newBounds (getBounds()); | const Rectangle<int> newBounds (getBounds()); | ||||
const bool wasMoved = (component->getPosition() != newBounds.getPosition()); | |||||
const bool wasResized = (component->getWidth() != newBounds.getWidth() || component->getHeight() != newBounds.getHeight()); | |||||
const bool wasMoved = (component.getPosition() != newBounds.getPosition()); | |||||
const bool wasResized = (component.getWidth() != newBounds.getWidth() || component.getHeight() != newBounds.getHeight()); | |||||
if (wasMoved || wasResized) | if (wasMoved || wasResized) | ||||
{ | { | ||||
component->bounds = newBounds; | |||||
component.bounds = newBounds; | |||||
if (wasResized) | if (wasResized) | ||||
component->repaint(); | |||||
component.repaint(); | |||||
component->sendMovedResizedMessages (wasMoved, wasResized); | |||||
component.sendMovedResizedMessages (wasMoved, wasResized); | |||||
if (deletionChecker == nullptr) | if (deletionChecker == nullptr) | ||||
return; | return; | ||||
@@ -328,19 +332,19 @@ void ComponentPeer::handleMovedOrResized() | |||||
if (isWindowMinimised != nowMinimised) | if (isWindowMinimised != nowMinimised) | ||||
{ | { | ||||
isWindowMinimised = nowMinimised; | isWindowMinimised = nowMinimised; | ||||
component->minimisationStateChanged (nowMinimised); | |||||
component->sendVisibilityChangeMessage(); | |||||
component.minimisationStateChanged (nowMinimised); | |||||
component.sendVisibilityChangeMessage(); | |||||
} | } | ||||
if (! isFullScreen()) | if (! isFullScreen()) | ||||
lastNonFullscreenBounds = component->getBounds(); | |||||
lastNonFullscreenBounds = component.getBounds(); | |||||
} | } | ||||
void ComponentPeer::handleFocusGain() | void ComponentPeer::handleFocusGain() | ||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
if (component->isParentOf (lastFocusedComponent)) | |||||
if (component.isParentOf (lastFocusedComponent)) | |||||
{ | { | ||||
Component::currentlyFocusedComponent = lastFocusedComponent; | Component::currentlyFocusedComponent = lastFocusedComponent; | ||||
Desktop::getInstance().triggerFocusCallback(); | Desktop::getInstance().triggerFocusCallback(); | ||||
@@ -348,8 +352,8 @@ void ComponentPeer::handleFocusGain() | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (! component->isCurrentlyBlockedByAnotherModalComponent()) | |||||
component->grabKeyboardFocus(); | |||||
if (! component.isCurrentlyBlockedByAnotherModalComponent()) | |||||
component.grabKeyboardFocus(); | |||||
else | else | ||||
ModalComponentManager::getInstance()->bringModalComponentsToFront(); | ModalComponentManager::getInstance()->bringModalComponentsToFront(); | ||||
} | } | ||||
@@ -359,7 +363,7 @@ void ComponentPeer::handleFocusLoss() | |||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
if (component->hasKeyboardFocus (true)) | |||||
if (component.hasKeyboardFocus (true)) | |||||
{ | { | ||||
lastFocusedComponent = Component::currentlyFocusedComponent; | lastFocusedComponent = Component::currentlyFocusedComponent; | ||||
@@ -374,16 +378,16 @@ void ComponentPeer::handleFocusLoss() | |||||
Component* ComponentPeer::getLastFocusedSubcomponent() const noexcept | Component* ComponentPeer::getLastFocusedSubcomponent() const noexcept | ||||
{ | { | ||||
return (component->isParentOf (lastFocusedComponent) && lastFocusedComponent->isShowing()) | |||||
return (component.isParentOf (lastFocusedComponent) && lastFocusedComponent->isShowing()) | |||||
? static_cast <Component*> (lastFocusedComponent) | ? static_cast <Component*> (lastFocusedComponent) | ||||
: component; | |||||
: &component; | |||||
} | } | ||||
void ComponentPeer::handleScreenSizeChange() | void ComponentPeer::handleScreenSizeChange() | ||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
component->parentSizeChanged(); | |||||
component.parentSizeChanged(); | |||||
handleMovedOrResized(); | handleMovedOrResized(); | ||||
} | } | ||||
@@ -468,7 +472,7 @@ bool ComponentPeer::handleDragMove (const ComponentPeer::DragInfo& info) | |||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
Component* const compUnderMouse = component->getComponentAt (info.position); | |||||
Component* const compUnderMouse = component.getComponentAt (info.position); | |||||
Component* const lastTarget = dragAndDropTargetComponent.get(); | Component* const lastTarget = dragAndDropTargetComponent.get(); | ||||
Component* newTarget = nullptr; | Component* newTarget = nullptr; | ||||
@@ -493,7 +497,7 @@ bool ComponentPeer::handleDragMove (const ComponentPeer::DragInfo& info) | |||||
if (DragHelpers::isSuitableTarget (info, newTarget)) | if (DragHelpers::isSuitableTarget (info, newTarget)) | ||||
{ | { | ||||
dragAndDropTargetComponent = newTarget; | dragAndDropTargetComponent = newTarget; | ||||
const Point<int> pos (newTarget->getLocalPoint (component, info.position)); | |||||
const Point<int> pos (newTarget->getLocalPoint (&component, info.position)); | |||||
if (DragHelpers::isFileDrag (info)) | if (DragHelpers::isFileDrag (info)) | ||||
dynamic_cast <FileDragAndDropTarget*> (newTarget)->fileDragEnter (info.files, pos.x, pos.y); | dynamic_cast <FileDragAndDropTarget*> (newTarget)->fileDragEnter (info.files, pos.x, pos.y); | ||||
@@ -510,7 +514,7 @@ bool ComponentPeer::handleDragMove (const ComponentPeer::DragInfo& info) | |||||
if (! DragHelpers::isSuitableTarget (info, newTarget)) | if (! DragHelpers::isSuitableTarget (info, newTarget)) | ||||
return false; | return false; | ||||
const Point<int> pos (newTarget->getLocalPoint (component, info.position)); | |||||
const Point<int> pos (newTarget->getLocalPoint (&component, info.position)); | |||||
if (DragHelpers::isFileDrag (info)) | if (DragHelpers::isFileDrag (info)) | ||||
dynamic_cast <FileDragAndDropTarget*> (newTarget)->fileDragMove (info.files, pos.x, pos.y); | dynamic_cast <FileDragAndDropTarget*> (newTarget)->fileDragMove (info.files, pos.x, pos.y); | ||||
@@ -553,7 +557,7 @@ bool ComponentPeer::handleDragDrop (const ComponentPeer::DragInfo& info) | |||||
} | } | ||||
ComponentPeer::DragInfo info2 (info); | ComponentPeer::DragInfo info2 (info); | ||||
info2.position = targetComp->getLocalPoint (component, info.position); | |||||
info2.position = targetComp->getLocalPoint (&component, info.position); | |||||
(new DragHelpers::AsyncDropMessage (targetComp, info2))->post(); | (new DragHelpers::AsyncDropMessage (targetComp, info2))->post(); | ||||
return true; | return true; | ||||
@@ -567,7 +571,7 @@ bool ComponentPeer::handleDragDrop (const ComponentPeer::DragInfo& info) | |||||
void ComponentPeer::handleUserClosingWindow() | void ComponentPeer::handleUserClosingWindow() | ||||
{ | { | ||||
updateCurrentModifiers(); | updateCurrentModifiers(); | ||||
component->userTriedToCloseWindow(); | |||||
component.userTriedToCloseWindow(); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -86,14 +86,14 @@ public: | |||||
The component is the one that we intend to represent, and the style flags are | The component is the one that we intend to represent, and the style flags are | ||||
a combination of the values in the StyleFlags enum | a combination of the values in the StyleFlags enum | ||||
*/ | */ | ||||
ComponentPeer (Component* component, int styleFlags); | |||||
ComponentPeer (Component& component, int styleFlags); | |||||
/** Destructor. */ | /** Destructor. */ | ||||
virtual ~ComponentPeer(); | virtual ~ComponentPeer(); | ||||
//============================================================================== | //============================================================================== | ||||
/** Returns the component being represented by this peer. */ | /** Returns the component being represented by this peer. */ | ||||
Component* getComponent() const noexcept { return component; } | |||||
Component& getComponent() noexcept { return component; } | |||||
/** Returns the set of style flags that were set when the window was created. | /** Returns the set of style flags that were set when the window was created. | ||||
@@ -324,10 +324,7 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Resets the masking region. | /** Resets the masking region. | ||||
The subclass should call this every time it's about to call the handlePaint | |||||
method. | |||||
The subclass should call this every time it's about to call the handlePaint method. | |||||
@see addMaskedRegion | @see addMaskedRegion | ||||
*/ | */ | ||||
void clearMaskedRegion(); | void clearMaskedRegion(); | ||||
@@ -345,19 +342,16 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns the number of currently-active peers. | /** Returns the number of currently-active peers. | ||||
@see getPeer | @see getPeer | ||||
*/ | */ | ||||
static int getNumPeers() noexcept; | static int getNumPeers() noexcept; | ||||
/** Returns one of the currently-active peers. | /** Returns one of the currently-active peers. | ||||
@see getNumPeers | @see getNumPeers | ||||
*/ | */ | ||||
static ComponentPeer* getPeer (int index) noexcept; | static ComponentPeer* getPeer (int index) noexcept; | ||||
/** Checks if this peer object is valid. | /** Checks if this peer object is valid. | ||||
@see getNumPeers | @see getNumPeers | ||||
*/ | */ | ||||
static bool isValidPeer (const ComponentPeer* peer) noexcept; | static bool isValidPeer (const ComponentPeer* peer) noexcept; | ||||
@@ -370,7 +364,7 @@ public: | |||||
protected: | protected: | ||||
//============================================================================== | //============================================================================== | ||||
Component* const component; | |||||
Component& component; | |||||
const int styleFlags; | const int styleFlags; | ||||
RectangleList maskedRegion; | RectangleList maskedRegion; | ||||
Rectangle<int> lastNonFullscreenBounds; | Rectangle<int> lastNonFullscreenBounds; | ||||
@@ -388,9 +382,10 @@ private: | |||||
friend class Component; | friend class Component; | ||||
friend class Desktop; | friend class Desktop; | ||||
static ComponentPeer* getPeerFor (const Component* component) noexcept; | |||||
static ComponentPeer* getPeerFor (const Component*) noexcept; | |||||
Component* getTargetForKeyPress(); | |||||
void setLastDragDropTarget (Component* comp); | |||||
void setLastDragDropTarget (Component*); | |||||
bool finishDrag (bool); | bool finishDrag (bool); | ||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentPeer); | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentPeer); | ||||
@@ -146,7 +146,7 @@ public: | |||||
if (peer != nullptr) | if (peer != nullptr) | ||||
{ | { | ||||
SystemTrayIconComponent* const iconComp = dynamic_cast<SystemTrayIconComponent*> (peer->getComponent()); | |||||
SystemTrayIconComponent* const iconComp = dynamic_cast<SystemTrayIconComponent*> (&(peer->getComponent())); | |||||
if (iconComp != nullptr) | if (iconComp != nullptr) | ||||
return iconComp->pimpl; | return iconComp->pimpl; | ||||
@@ -55,7 +55,7 @@ public: | |||||
ComponentPeer* const peer = component.getPeer(); | ComponentPeer* const peer = component.getPeer(); | ||||
jassert (peer != nullptr); | jassert (peer != nullptr); | ||||
const Rectangle<int> bounds (peer->getComponent()->getLocalArea (&component, component.getLocalBounds())); | |||||
const Rectangle<int> bounds (peer->getComponent().getLocalArea (&component, component.getLocalBounds())); | |||||
lastWidth = bounds.getWidth(); | lastWidth = bounds.getWidth(); | ||||
lastHeight = bounds.getHeight(); | lastHeight = bounds.getHeight(); | ||||
@@ -74,7 +74,7 @@ public: | |||||
ComponentPeer* const peer = component.getPeer(); | ComponentPeer* const peer = component.getPeer(); | ||||
if (peer != nullptr) | if (peer != nullptr) | ||||
peer->addMaskedRegion (peer->getComponent()->getLocalArea (&component, component.getLocalBounds())); | |||||
peer->addMaskedRegion (peer->getComponent().getLocalArea (&component, component.getLocalBounds())); | |||||
} | } | ||||
void invalidateAll() | void invalidateAll() | ||||