mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
New: added method initWithWindow in CPPlatformWindow
The constructor initWithWindow: initializes a new CPPlatformWindow and set the given CPWindow as a fullPlatformWindow and bridgless window. When using this constructor, you don't need to work with the platformWindow anymore, you can use the method orderFront: and orderOut: of the CPWindow to open or close the CPPlatformWindow. You can also use the method setFrame: of the CPWindow to automatically change the contentRect of the CPPlatformWindow. In one word we assume that the given CPWindow and the CPPlatformWindow will have the same behavior. When not using the constructor initWithWindow:, the method setFrame: of the given CPWindow won't do anything to the CPPlateformWindow. Test app in Tests/Manual/CPPlatformWindow/
This commit is contained in:
@@ -569,6 +569,9 @@ CPTexturedBackgroundWindowMask
|
||||
var fullPlatformWindowViewClass = [[self class] _windowViewClassForFullPlatformWindowStyleMask:_styleMask],
|
||||
windowView = [[fullPlatformWindowViewClass alloc] initWithFrame:CGRectMakeZero() styleMask:_styleMask];
|
||||
|
||||
if (_platformWindow != [CPPlatformWindow primaryPlatformWindow])
|
||||
[_platformWindow setContentRect:[self frame]];
|
||||
|
||||
[self _setWindowView:windowView];
|
||||
|
||||
[self setLevel:CPBackgroundWindowLevel];
|
||||
@@ -753,6 +756,9 @@ CPTexturedBackgroundWindowMask
|
||||
if (originMoved)
|
||||
[self _moveChildWindows:delta];
|
||||
}
|
||||
|
||||
if ([_platformWindow _shouldUpdateContentRect] && _isFullPlatformWindow && _platformWindow != [CPPlatformWindow primaryPlatformWindow])
|
||||
[_platformWindow setContentRect:aFrame];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -904,6 +910,10 @@ CPTexturedBackgroundWindowMask
|
||||
[[self contentView] _addObservers];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
if (!_isVisible)
|
||||
[_platformWindow _setShouldUpdateContentRect:NO];
|
||||
|
||||
// -dw- if a sheet is clicked, the parent window should come up too
|
||||
if (_isSheet)
|
||||
[_parentView orderFront:self];
|
||||
@@ -923,6 +933,8 @@ CPTexturedBackgroundWindowMask
|
||||
|
||||
if (!CPApp._mainWindow)
|
||||
[self makeMainWindow];
|
||||
|
||||
[_platformWindow _setShouldUpdateContentRect:YES];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -40,6 +40,8 @@ var PrimaryPlatformWindow = NULL;
|
||||
BOOL _hasShadow;
|
||||
unsigned _shadowStyle;
|
||||
CPString _title;
|
||||
BOOL _shouldUpdateContentRect;
|
||||
BOOL _hasInitializeInstanceWithWindow;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMWindow _DOMWindow;
|
||||
@@ -116,6 +118,17 @@ var PrimaryPlatformWindow = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithWindow:(CPWindow)aWindow
|
||||
{
|
||||
self = [self initWithContentRect:CGRectMakeCopy([aWindow frame])];
|
||||
|
||||
[aWindow setPlatformWindow:self];
|
||||
[aWindow setFullPlatformWindow:YES];
|
||||
_hasInitializeInstanceWithWindow = YES;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithContentRect:CGRectMake(0.0, 0.0, 400.0, 500.0)];
|
||||
@@ -281,6 +294,17 @@ var PrimaryPlatformWindow = NULL;
|
||||
return _title;
|
||||
}
|
||||
|
||||
- (BOOL)_shouldUpdateContentRect
|
||||
{
|
||||
// We onyl update the contentRect with the frame of the bridgeless window if we have initialized the platform with the method initWithWindow:
|
||||
return _shouldUpdateContentRect && _hasInitializeInstanceWithWindow;
|
||||
}
|
||||
|
||||
- (void)_setShouldUpdateContentRect:(BOOL)aBoolean
|
||||
{
|
||||
_shouldUpdateContentRect = aBoolean;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#if PLATFORM(BROWSER)
|
||||
|
||||
@@ -988,6 +988,7 @@ var PreventScroll = true;
|
||||
|
||||
- (void)_actualResizeEvent
|
||||
{
|
||||
_shouldUpdateContentRect = NO;
|
||||
resizeTimer = nil;
|
||||
|
||||
// FIXME: This is not the right way to do this.
|
||||
@@ -1021,6 +1022,8 @@ var PreventScroll = true;
|
||||
//window.liveResize = NO;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
_shouldUpdateContentRect = YES;
|
||||
}
|
||||
|
||||
- (void)touchEvent:(DOMEvent)aDOMEvent
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
// This is called when the application is done loading.
|
||||
|
||||
platformWindow = [[CPPlatformWindow alloc] init];
|
||||
[platformWindow setContentRect:[windowPlatformWindow contentRectForFrameRect:[windowPlatformWindow frame]]];
|
||||
|
||||
[windowPlatformWindow setPlatformWindow:platformWindow];
|
||||
[windowPlatformWindow setFullPlatformWindow:YES]
|
||||
[[CPPlatformWindow alloc] initWithWindow:windowPlatformWindow];
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
@@ -52,7 +47,7 @@
|
||||
|
||||
- (IBAction)changeFrame:(id)sender
|
||||
{
|
||||
[platformWindow setContentRect:CGRectMake(50, 50, 200, 200)];
|
||||
[windowPlatformWindow setFrame:CGRectMake(250, 250, 200, 200)];
|
||||
}
|
||||
|
||||
- (IBAction)showAlert:(id)sender
|
||||
|
||||
Reference in New Issue
Block a user