mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-03 15:46:16 +00:00
Merge branch 'master' of git@github.com:280north/cappuccino
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
@import "CPDocumentController.j"
|
||||
@import "CPThemeBlend.j"
|
||||
@import "CPCibLoading.j"
|
||||
@import "CPPlatform.j"
|
||||
|
||||
|
||||
var CPMainCibFile = @"CPMainCibFile",
|
||||
CPMainCibFileHumanFriendly = @"Main cib file base name";
|
||||
@@ -809,7 +811,7 @@ var _CPAppBootstrapperActions = nil;
|
||||
|
||||
+ (void)actions
|
||||
{
|
||||
return [@selector(loadDefaultTheme), @selector(loadMainCibFile)];
|
||||
return [@selector(bootstrapPlatform), @selector(loadDefaultTheme), @selector(loadMainCibFile)];
|
||||
}
|
||||
|
||||
+ (void)performActions
|
||||
@@ -828,6 +830,11 @@ var _CPAppBootstrapperActions = nil;
|
||||
[CPApp run];
|
||||
}
|
||||
|
||||
+ (BOOL)bootstrapPlatform
|
||||
{
|
||||
return [CPPlatform bootstrap];
|
||||
}
|
||||
|
||||
+ (BOOL)loadDefaultTheme
|
||||
{
|
||||
var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:@"Aristo.blend"]];
|
||||
|
||||
+12
-4
@@ -26,6 +26,7 @@
|
||||
@import <AppKit/CPImageView.j>
|
||||
|
||||
#import "CoreGraphics/CGGeometry.h"
|
||||
#import "Platform/Platform.h"
|
||||
|
||||
|
||||
#define DRAGGING_WINDOW(anObject) ([anObject isKindOfClass:[CPWindow class]] ? anObject : [anObject window])
|
||||
@@ -111,7 +112,7 @@ var CPDragServerUpdateDragging = function(anEvent)
|
||||
bridgeLocation = [[anEvent window] convertBaseToBridge:location];
|
||||
|
||||
// We have to convert base to bridge since the drag event comes from the source window, not the drag window.
|
||||
var draggingDestination = [[CPDOMWindowBridge sharedDOMWindowBridge] _dragHitTest:bridgeLocation pasteboard:CPDragServerPasteboard];
|
||||
var draggingDestination = [[CPPlatformWindow primaryPlatformWindow] _dragHitTest:bridgeLocation pasteboard:CPDragServerPasteboard];
|
||||
|
||||
CPDragServerLocation = [DRAGGING_WINDOW(draggingDestination) convertBridgeToBase:bridgeLocation];
|
||||
|
||||
@@ -241,14 +242,21 @@ var CPDragServerUpdateDragging = function(anEvent)
|
||||
- (void)dragView:(CPView)aView fromWindow:(CPWindow)aWindow at:(CGPoint)viewLocation offset:(CGSize)mouseOffset event:(CPEvent)anEvent pasteboard:(CPPasteboard)aPasteboard source:(id)aSourceObject slideBack:(BOOL)slideBack
|
||||
{
|
||||
var eventLocation = [anEvent locationInWindow];
|
||||
|
||||
|
||||
CPDragServerView = aView;
|
||||
CPDragServerSource = aSourceObject;
|
||||
CPDragServerWindow = aWindow;
|
||||
CPDragServerOffset = CPPointMake(eventLocation.x - viewLocation.x, eventLocation.y - viewLocation.y);
|
||||
CPDragServerPasteboard = [CPPasteboard pasteboardWithName:CPDragPboard];//aPasteboard;
|
||||
|
||||
[_dragWindow setFrameSize:CGSizeMakeCopy([[CPDOMWindowBridge sharedDOMWindowBridge] frame].size)];
|
||||
#if PLATFORM(BROWSER)
|
||||
var platformWindow = [aWindow platformWindow];
|
||||
|
||||
// FIXME: We should just have the window be the size of the view and move the window around.
|
||||
[_dragWindow setPlatformWindow:platformWindow];
|
||||
[_dragWindow setFrameSize:[platformWindow contentBounds].size];
|
||||
#endif
|
||||
|
||||
[_dragWindow orderFront:self];
|
||||
|
||||
[aView setFrameOrigin:viewLocation];
|
||||
@@ -318,7 +326,7 @@ var CPDragServerUpdateDragging = function(anEvent)
|
||||
return nil;
|
||||
|
||||
// We don't need to do this because the only place this gets called
|
||||
// -_dragHitTest: in CPDOMWindowBridge does this already. Perhaps to
|
||||
// -_dragHitTest: in CPPlatformWindow does this already. Perhaps to
|
||||
// be safe?
|
||||
// if (![self containsPoint:aPoint])
|
||||
// return nil;
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CPDOMWindowBridge.j"
|
||||
@import "CPFlashMovie.j"
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
*/
|
||||
@@ -96,17 +96,17 @@
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+5
-5
@@ -119,7 +119,7 @@ var _CPMenuBarVisible = NO,
|
||||
|
||||
// FIXME: There must be a better way to do this.
|
||||
#if PLATFORM(DOM)
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _bridgeResizeEvent:nil];
|
||||
[[CPPlatformWindow primaryPlatformWindow] resizeEvent:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1078,7 +1078,7 @@ var STICKY_TIME_INTERVAL = 500,
|
||||
{
|
||||
_unconstrainedFrame = CGRectMakeCopy([self frame]);
|
||||
|
||||
var screenBounds = CGRectInset([[CPDOMWindowBridge sharedDOMWindowBridge] contentBounds], 5.0, 5.0),
|
||||
var screenBounds = CGRectInset([[self platformWindow] contentBounds], 5.0, 5.0),
|
||||
constrainedFrame = CGRectIntersection(_unconstrainedFrame, screenBounds),
|
||||
menuViewOrigin = [self convertBaseToBridge:CGPointMake(LEFT_MARGIN, TOP_MARGIN)];
|
||||
|
||||
@@ -1158,7 +1158,7 @@ var STICKY_TIME_INTERVAL = 500,
|
||||
|
||||
if (type == CPPeriodic)
|
||||
{
|
||||
var constrainedBounds = CGRectInset([[CPDOMWindowBridge sharedDOMWindowBridge] contentBounds], 5.0, 5.0);
|
||||
var constrainedBounds = CGRectInset([[self platformWindow] contentBounds], 5.0, 5.0);
|
||||
|
||||
if (_scrollingState == _CPMenuWindowScrollingStateUp)
|
||||
{
|
||||
@@ -1447,9 +1447,9 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
|
||||
- (id)init
|
||||
{
|
||||
var bridgeWidth = CGRectGetWidth([[CPDOMWindowBridge sharedDOMWindowBridge] contentBounds]);
|
||||
var platformWindowWidth = CGRectGetWidth([[CPPlatformWindow primaryPlatformWindow] contentBounds]);
|
||||
|
||||
self = [super initWithContentRect:CGRectMake(0.0, 0.0, bridgeWidth, MENUBAR_HEIGHT) styleMask:CPBorderlessWindowMask];
|
||||
self = [super initWithContentRect:CGRectMake(0.0, 0.0, platformWindowWidth, MENUBAR_HEIGHT) styleMask:CPBorderlessWindowMask];
|
||||
|
||||
if (self)
|
||||
{
|
||||
|
||||
@@ -22,13 +22,9 @@
|
||||
|
||||
@import <Foundation/CPString.j>
|
||||
|
||||
#include "CoreGraphics/CGGeometry.h"
|
||||
#include "Platform/Platform.h"
|
||||
@import "CPPlatformString.j"
|
||||
|
||||
|
||||
var CPStringReferenceElement = nil,
|
||||
CPStringDefaultFont = nil;
|
||||
|
||||
@implementation CPString (CPStringDrawing)
|
||||
|
||||
/*!
|
||||
@@ -46,75 +42,7 @@ var CPStringReferenceElement = nil,
|
||||
|
||||
- (CGSize)sizeWithFont:(CPFont)aFont inWidth:(float)aWidth
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!CPStringReferenceElement)
|
||||
{
|
||||
CPStringReferenceElement = document.createElement("span");
|
||||
|
||||
var style = CPStringReferenceElement.style;
|
||||
|
||||
style.position = "absolute";
|
||||
style.whiteSpace = "pre";
|
||||
style.visibility = "visible";
|
||||
style.padding = "0px";
|
||||
style.margin = "0px";
|
||||
|
||||
style.left = "-100000px";
|
||||
style.top = "-100000px";
|
||||
style.zIndex = "10000";
|
||||
style.background = "red";
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(CPStringReferenceElement);
|
||||
}
|
||||
|
||||
if (!aFont)
|
||||
{
|
||||
if (!CPStringDefaultFont)
|
||||
CPStringDefaultFont = [CPFont systemFontOfSize:12.0];
|
||||
|
||||
aFont = CPStringDefaultFont;
|
||||
}
|
||||
|
||||
var style = CPStringReferenceElement.style;
|
||||
|
||||
if (aWidth === NULL)
|
||||
{
|
||||
style.width = "";
|
||||
style.whiteSpace = "pre";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
style.width = ROUND(aWidth) + "px";
|
||||
|
||||
if (document.attachEvent)
|
||||
style.wordWrap = "break-word";
|
||||
|
||||
else
|
||||
{
|
||||
style.whiteSpace = "-o-pre-wrap";
|
||||
style.whiteSpace = "-pre-wrap";
|
||||
style.whiteSpace = "-moz-pre-wrap";
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
}
|
||||
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
|
||||
CPStringReferenceElement.innerText = self;
|
||||
|
||||
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
|
||||
CPStringReferenceElement.textContent = self;
|
||||
|
||||
return _CGSizeMake(CPStringReferenceElement.clientWidth, CPStringReferenceElement.clientHeight);
|
||||
#endif
|
||||
return _CGSizeMakeZero();
|
||||
}
|
||||
|
||||
+ (void)_resetSize
|
||||
{
|
||||
CPStringReferenceElement = nil;
|
||||
return [CPPlatformString sizeOfString:self withFont:aFont forWidth:aWidth];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -597,7 +597,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
//post CPControlTextDidBeginEditingNotification
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
|
||||
CPTextFieldInputIsActive = YES;
|
||||
|
||||
|
||||
+1
-1
@@ -970,7 +970,7 @@ var DOMElementPrototype = nil,
|
||||
{
|
||||
_fullScreenModeState = _CPViewFullScreenModeStateMake(self);
|
||||
|
||||
var fullScreenWindow = [[CPWindow alloc] initWithContentRect:[[CPDOMWindowBridge sharedDOMWindowBridge] contentBounds] styleMask:CPBorderlessWindowMask];
|
||||
var fullScreenWindow = [[CPWindow alloc] initWithContentRect:[[CPPlatformWindow primaryPlatformWindow] contentBounds] styleMask:CPBorderlessWindowMask];
|
||||
|
||||
[fullScreenWindow setLevel:CPScreenSaverWindowLevel];
|
||||
[fullScreenWindow setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
+29
-62
@@ -27,6 +27,7 @@
|
||||
@import "CGGeometry.j"
|
||||
@import "CPAnimation.j"
|
||||
@import "CPResponder.j"
|
||||
@import "CPPlatformWindow.j"
|
||||
|
||||
#include "../Platform/Platform.h"
|
||||
#include "../Platform/DOM/CPDOMDisplayServer.h"
|
||||
@@ -235,6 +236,8 @@ var CPWindowSaveImage = nil,
|
||||
*/
|
||||
@implementation CPWindow : CPResponder
|
||||
{
|
||||
CPPlatformWindow _platformWindow;
|
||||
|
||||
int _windowNumber;
|
||||
unsigned _styleMask;
|
||||
CGRect _frame;
|
||||
@@ -289,7 +292,7 @@ var CPWindowSaveImage = nil,
|
||||
#if PLATFORM(DOM)
|
||||
DOMElement _DOMElement;
|
||||
#endif
|
||||
CPDOMWindowBridge _bridge;
|
||||
|
||||
unsigned _autoresizingMask;
|
||||
|
||||
BOOL _delegateRespondsToWindowWillReturnUndoManagerSelector;
|
||||
@@ -328,37 +331,13 @@ CPTexturedBackgroundWindowMask
|
||||
@return the initialized window
|
||||
*/
|
||||
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
return [self initWithContentRect:aContentRect styleMask:aStyleMask bridge:[CPDOMWindowBridge sharedDOMWindowBridge]];
|
||||
#else
|
||||
return [self initWithContentRect:aContentRect styleMask:aStyleMask bridge:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Initializes the window. The method also takes a style bit mask made up
|
||||
of any of the following values:
|
||||
<pre>
|
||||
CPBorderlessWindowMask
|
||||
CPTitledWindowMask
|
||||
CPClosableWindowMask
|
||||
CPMiniaturizableWindowMask
|
||||
CPResizableWindowMask
|
||||
CPTexturedBackgroundWindowMask
|
||||
</pre>
|
||||
@param aContentRect the size and location of the window in screen space
|
||||
@param aStyleMask a style mask
|
||||
@param aBridge a DOM-Window bridge object
|
||||
@return the initialized window
|
||||
@ignore
|
||||
*/
|
||||
- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask bridge:(CPDOMWindowBridge)aBridge
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self setPlatformWindow:[CPPlatformWindow primaryPlatformWindow]];
|
||||
|
||||
_isFullBridge = NO;
|
||||
_registeredDraggedTypes = [CPSet set];
|
||||
_registeredDraggedTypesArray = [];
|
||||
@@ -402,8 +381,6 @@ CPTexturedBackgroundWindowMask
|
||||
CPDOMDisplayServerAppendChild(_DOMElement, _windowView._DOMElement);
|
||||
#endif
|
||||
|
||||
[self setBridge:aBridge];
|
||||
|
||||
[self setNextResponder:CPApp];
|
||||
|
||||
[self setHasShadow:aStyleMask !== CPBorderlessWindowMask];
|
||||
@@ -418,6 +395,17 @@ CPTexturedBackgroundWindowMask
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPPlatformWindow)platformWindow
|
||||
{
|
||||
return _platformWindow;
|
||||
}
|
||||
|
||||
- (void)setPlatformWindow:(CPPlatformWindow)aPlatformWindow
|
||||
{
|
||||
// FIXME: already visible.
|
||||
_platformWindow = aPlatformWindow;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
@@ -503,7 +491,7 @@ CPTexturedBackgroundWindowMask
|
||||
[self setLevel:CPBackgroundWindowLevel];
|
||||
[self setHasShadow:NO];
|
||||
[self setAutoresizingMask:CPWindowWidthSizable | CPWindowHeightSizable];
|
||||
[self setFrame:[_bridge visibleFrame]];
|
||||
[self setFrame:[_platformWindow usableContentFrame]];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -649,7 +637,8 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)orderFront:(id)aSender
|
||||
{
|
||||
[_bridge order:CPWindowAbove window:self relativeTo:nil];
|
||||
[_platformWindow orderFront:self];
|
||||
[_platformWindow order:CPWindowAbove window:self relativeTo:nil];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -659,7 +648,7 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)orderBack:(id)aSender
|
||||
{
|
||||
//[_bridge order:CPWindowBelow
|
||||
//[_platformWindow order:CPWindowBelow
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -671,7 +660,7 @@ CPTexturedBackgroundWindowMask
|
||||
if ([_delegate respondsToSelector:@selector(windowWillClose:)])
|
||||
[_delegate windowWillClose:self];
|
||||
|
||||
[_bridge order:CPWindowOut window:self relativeTo:nil];
|
||||
[_platformWindow order:CPWindowOut window:self relativeTo:nil];
|
||||
|
||||
if ([CPApp keyWindow] == self)
|
||||
{
|
||||
@@ -688,7 +677,7 @@ CPTexturedBackgroundWindowMask
|
||||
*/
|
||||
- (void)orderWindow:(CPWindowOrderingMode)aPlace relativeTo:(int)otherWindowNumber
|
||||
{
|
||||
[_bridge order:aPlace window:self relativeTo:CPApp._windows[otherWindowNumber]];
|
||||
[_platformWindow order:aPlace window:self relativeTo:CPApp._windows[otherWindowNumber]];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1153,9 +1142,9 @@ CPTexturedBackgroundWindowMask
|
||||
- (void)center
|
||||
{
|
||||
var size = [self frame].size,
|
||||
bridgeSize = [_bridge contentBounds].size;
|
||||
containerSize = [_platformWindow contentBounds].size;
|
||||
|
||||
[self setFrameOrigin:CGPointMake((bridgeSize.width - size.width) / 2.0, (bridgeSize.height - size.height) / 2.0)];
|
||||
[self setFrameOrigin:CGPointMake((containerSize.width - size.width) / 2.0, (containerSize.height - size.height) / 2.0)];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1640,7 +1629,7 @@ CPTexturedBackgroundWindowMask
|
||||
[_windowView noteToolbarChanged];
|
||||
|
||||
if (_isFullBridge)
|
||||
newFrame = [_bridge visibleFrame];
|
||||
newFrame = [_platformWindow usableContentFrame];
|
||||
else
|
||||
{
|
||||
newFrame = CGRectMakeCopy([self frame]);
|
||||
@@ -1707,7 +1696,7 @@ CPTexturedBackgroundWindowMask
|
||||
[self _setAttachedSheetFrameOrigin];
|
||||
|
||||
// Place this window above ourselves.
|
||||
[_bridge order:CPWindowAbove window:aSheet relativeTo:self];
|
||||
[_platformWindow order:CPWindowAbove window:aSheet relativeTo:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1928,39 +1917,18 @@ var keyViewComparator = function(a, b, context)
|
||||
|
||||
@implementation CPWindow (BridgeSupport)
|
||||
|
||||
/*
|
||||
Sets the DOM-Window bridge for this window.
|
||||
@ignore
|
||||
*/
|
||||
- (void)setBridge:(CPDOMWindowBridge)aBridge
|
||||
{
|
||||
if (_bridge == aBridge)
|
||||
return;
|
||||
|
||||
if (_bridge)
|
||||
{
|
||||
[self orderOut:self];
|
||||
// FIXME: If the bridge changes, then we have to recreate all of our subviews' DOM Elements.
|
||||
}
|
||||
|
||||
_bridge = aBridge;
|
||||
|
||||
if ([self isFullBridge])
|
||||
[self setFrame:[aBridge contentBounds]];
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
- (void)resizeWithOldBridgeSize:(CGSize)aSize
|
||||
{
|
||||
if ([self isFullBridge])
|
||||
return [self setFrame:[_bridge visibleFrame]];
|
||||
return [self setFrame:[_platformWindow usableContentFrame]];
|
||||
|
||||
if (_autoresizingMask == CPWindowNotSizable)
|
||||
return;
|
||||
|
||||
var frame = [_bridge contentBounds],
|
||||
var frame = [_platformWindow contentBounds],
|
||||
newFrame = CGRectMakeCopy(_frame),
|
||||
dX = (CGRectGetWidth(frame) - aSize.width) /
|
||||
(((_autoresizingMask & CPWindowMinXMargin) ? 1 : 0) + (_autoresizingMask & CPWindowWidthSizable ? 1 : 0) + (_autoresizingMask & CPWindowMaxXMargin ? 1 : 0)),
|
||||
@@ -2118,5 +2086,4 @@ function _CPWindowFullBridgeSessionMake(aWindowView, aContentRect, hasShadow, aL
|
||||
@import "_CPBorderlessWindowView.j"
|
||||
@import "_CPBorderlessBridgeWindowView.j"
|
||||
@import "CPDragServer.j"
|
||||
@import "CPDOMWindowBridge.j"
|
||||
@import "CPView.j"
|
||||
|
||||
@@ -145,7 +145,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
var visibleFrame = _cachedScreenFrame;
|
||||
|
||||
if (!visibleFrame)
|
||||
visibleFrame = [[CPDOMWindowBridge sharedDOMWindowBridge] visibleFrame];
|
||||
visibleFrame = [[CPPlatformWindow primaryPlatformWindow] usableContentFrame];
|
||||
|
||||
var restrictedPoint = CGPointMake(0, 0);
|
||||
|
||||
@@ -167,7 +167,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
|
||||
else if (type === CPLeftMouseDown)
|
||||
{
|
||||
_mouseDraggedPoint = [[self window] convertBaseToBridge:[anEvent locationInWindow]];
|
||||
_cachedScreenFrame = [[CPDOMWindowBridge sharedDOMWindowBridge] visibleFrame];
|
||||
_cachedScreenFrame = [[CPPlatformWindow primaryPlatformWindow] usableContentFrame];
|
||||
}
|
||||
else if (type === CPLeftMouseDragged)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
@implementation CPPlatform : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)bootstrap
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
|
||||
body.innerHTML = ""; // Get rid of anything that might be lingering in the body element.
|
||||
body.style.overflow = "hidden";
|
||||
|
||||
if (document.documentElement)
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
#endif
|
||||
|
||||
[CPPlatformString bootstrap];
|
||||
[CPPlatformWindow setPrimaryPlatformWindow:[[CPPlatformWindow alloc] _init]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,104 @@
|
||||
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
#include "../CoreGraphics/CGGeometry.h"
|
||||
#include "Platform.h"
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var DOMIFrameElement = nil,
|
||||
DOMSpanElement = nil,
|
||||
DefaultFont = nil;
|
||||
#endif
|
||||
|
||||
@implementation CPPlatformString : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
+ (void)bootstrap
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
DOMIFrameElement = document.createElement("iframe");
|
||||
|
||||
DOMIFrameElement.name = name = "iframe_" + FLOOR(RAND() * 10000);
|
||||
DOMIFrameElement.style.position = "absolute";
|
||||
DOMIFrameElement.style.left = "-100px";
|
||||
DOMIFrameElement.style.top = "-100px";
|
||||
DOMIFrameElement.style.width = "1px";
|
||||
DOMIFrameElement.style.height = "1px";
|
||||
DOMIFrameElement.style.borderWidth = "0px";
|
||||
DOMIFrameElement.style.background = "blue";
|
||||
DOMIFrameElement.style.overflow = "hidden";
|
||||
DOMIFrameElement.style.zIndex = 100000000000;
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(DOMIFrameElement);
|
||||
|
||||
var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document);
|
||||
|
||||
DOMIFrameDocument.write("<html><head></head><body></body></html>");
|
||||
DOMIFrameDocument.close();
|
||||
|
||||
DOMSpanElement = DOMIFrameDocument.createElement("span");
|
||||
|
||||
DOMSpanElement.style.position = "absolute";
|
||||
DOMSpanElement.style.whiteSpace = "pre";
|
||||
DOMSpanElement.style.visibility = "visible";
|
||||
DOMSpanElement.style.padding = "0px";
|
||||
DOMSpanElement.style.margin = "0px";
|
||||
DOMSpanElement.style.background = "red";
|
||||
|
||||
DOMIFrameDocument.getElementsByTagName("body")[0].appendChild(DOMSpanElement);
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!aFont)
|
||||
{
|
||||
if (!DefaultFont)
|
||||
DefaultFont = [CPFont systemFontOfSize:12.0];
|
||||
|
||||
aFont = DefaultFont;
|
||||
}
|
||||
|
||||
var style = DOMSpanElement.style;
|
||||
|
||||
if (aWidth === NULL)
|
||||
{
|
||||
style.width = "";
|
||||
style.whiteSpace = "pre";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
style.width = ROUND(aWidth) + "px";
|
||||
|
||||
if (document.attachEvent)
|
||||
style.wordWrap = "break-word";
|
||||
|
||||
else
|
||||
{
|
||||
style.whiteSpace = "-o-pre-wrap";
|
||||
style.whiteSpace = "-pre-wrap";
|
||||
style.whiteSpace = "-moz-pre-wrap";
|
||||
style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
}
|
||||
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
|
||||
DOMSpanElement.innerText = aString;
|
||||
|
||||
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
|
||||
DOMSpanElement.textContent = aString;
|
||||
|
||||
return _CGSizeMake(DOMSpanElement.clientWidth, DOMSpanElement.clientHeight);
|
||||
#else
|
||||
return _CGSizeMakeZero();
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,168 @@
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
#import "Platform.h"
|
||||
#import "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
var PrimaryPlatformWindow = NULL;
|
||||
|
||||
@implementation CPPlatformWindow : CPObject
|
||||
{
|
||||
CGRect _contentRect;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMWindow _DOMWindow;
|
||||
|
||||
DOMElement _DOMBodyElement;
|
||||
DOMElement _DOMFocusElement;
|
||||
|
||||
CPArray _windowLevels;
|
||||
CPDictionary _windowLayers;
|
||||
|
||||
BOOL _mouseIsDown;
|
||||
CPWindow _mouseDownWindow;
|
||||
CPTimeInterval _lastMouseUp;
|
||||
CPTimeInterval _lastMouseDown;
|
||||
|
||||
Object _charCodes;
|
||||
unsigned _keyCode;
|
||||
|
||||
BOOL _DOMEventMode;
|
||||
|
||||
// Native Pasteboard Support
|
||||
DOMElement _DOMPasteboardElement;
|
||||
CPEvent _pasteboardKeyDownEvent;
|
||||
|
||||
CPString _overriddenEventType;
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (CPPlatformWindow)primaryPlatformWindow
|
||||
{
|
||||
return PrimaryPlatformWindow;
|
||||
}
|
||||
|
||||
+ (void)setPrimaryPlatformWindow:(CPPlatformWindow)aPlatformWindow
|
||||
{
|
||||
PrimaryPlatformWindow = aPlatformWindow;
|
||||
}
|
||||
|
||||
- (id)initWithContentRect:(CGRect)aRect
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_contentRect = _CGRectMakeCopy(aRect);
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_windowLevels = [];
|
||||
_windowLayers = [CPDictionary dictionary];
|
||||
|
||||
_charCodes = {};
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithContentRect:_CGRectMake(0.0, 0.0, 400.0, 500.0)];
|
||||
}
|
||||
|
||||
- (CGRect)contentRect
|
||||
{
|
||||
return _CGRectMakeCopy(_contentRect);
|
||||
}
|
||||
|
||||
- (CGRect)contentBounds
|
||||
{
|
||||
var contentBounds = [self contentRect];
|
||||
|
||||
contentBounds.origin = _CGPointMakeZero();
|
||||
|
||||
return contentBounds;
|
||||
}
|
||||
|
||||
- (void)usableContentFrame
|
||||
{
|
||||
var frame = [self contentBounds];
|
||||
|
||||
frame.origin = CGPointMakeZero();
|
||||
|
||||
if ([CPMenu menuBarVisible])
|
||||
{
|
||||
var menuBarHeight = [[CPApp mainMenu] menuBarHeight];
|
||||
|
||||
frame.origin.y += menuBarHeight;
|
||||
frame.size.height -= menuBarHeight;
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
- (void)setContentRect:(CGRect)aRect
|
||||
{
|
||||
if (!aRect || _CGRectEqualToRect(_contentRect, aRect))
|
||||
return;
|
||||
|
||||
[self setContentOrigin:aRect.origin];
|
||||
[self setContentSize:aRect.size];
|
||||
}
|
||||
|
||||
- (void)setContentOrigin:(CGPoint)aPoint
|
||||
{
|
||||
var origin = _contentRect.origin;
|
||||
|
||||
if (!aPoint || _CGPointEqualToPoint(origin, aPoint))
|
||||
return;
|
||||
|
||||
origin.x = aPoint.x;
|
||||
origin.y = aPoint.y;
|
||||
|
||||
[self updateNativeContentOrigin];
|
||||
}
|
||||
|
||||
- (void)setContentSize:(CGSize)aSize
|
||||
{
|
||||
var size = _contentRect.size;
|
||||
|
||||
if (!aSize || _CGSizeEqualToSize(size, aSize))
|
||||
return;
|
||||
|
||||
var delta = _CGSizeMake(aSize.width - size.width, aSize.height - size.height);
|
||||
|
||||
size.width = aSize.width;
|
||||
size.height = aSize.height;
|
||||
|
||||
[self updateNativeContentSize];
|
||||
}
|
||||
|
||||
- (void)updateFromNativeContentRect
|
||||
{
|
||||
[self setContentRect:[self nativeContentRect]];
|
||||
}
|
||||
/*
|
||||
- (BOOL)isVisible
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
+ (BOOL)supportsMultipleWindows
|
||||
{
|
||||
#if PLATFORM(BROWSER)
|
||||
return YES;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
#if PLATFORM(BROWSER)
|
||||
@import "CPPlatformWindow+DOM.j"
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -115,7 +115,7 @@
|
||||
aWindow._isVisible = YES;
|
||||
|
||||
if ([aWindow isFullBridge])
|
||||
[aWindow setFrame:[aWindow._bridge visibleFrame]];
|
||||
[aWindow setFrame:[aWindow._platformWindow usableContentFrame]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user