diff --git a/AppKit/CPCursor.j b/AppKit/CPCursor.j
index ce7e47b24..f5e67f692 100755
--- a/AppKit/CPCursor.j
+++ b/AppKit/CPCursor.j
@@ -12,6 +12,8 @@ Implemented class methods:
Opera : All except resizeLeftRightCursor resizeUpDownCursor operationNotAllowedCursor dragCopyCursor dragLinkCursor contextualMenuCursor openHandCursor closedHandCursor disappearingItemCursor // Opera does not support url cursors so these won't work with images
*/
+#include "Platform/Platform.h"
+
var currentCursor = nil,
cursorStack = [],
cursors = {},
@@ -186,12 +188,12 @@ var currentCursor = nil,
+ (void)hide
{
- document.body.style.cursor = 'none'; // Not supported in IE
+ [self _setCursorCSS:"none"]; // Not supported in IE
}
+ (void)unhide
{
- document.body.style.cursor = [currentCursor _cssString];
+ [self _setCursorCSS:[currentCursor _cssString]]
}
+ (void)setHiddenUntilMouseMoves:(BOOL)flag
@@ -217,17 +219,25 @@ var currentCursor = nil,
- (void)set
{
- document.body.style.cursor = _cssString;
currentCursor = self;
#if PLATFORM(DOM)
- var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
- for (var i = 0, count = [platformWindows count]; i < count; i++)
- platformWindows[i]._DOMWindow.document.body.style.cursor = _cssString;
+ [[self class] _setCursorCSS:_cssString];
#endif
}
++ (void)_setCursorCSS:(CPString)aString
+{
+#if PLATFORM(DOM)
+ [CPPlatformWindow primaryPlatformWindow]._DOMBodyElement.style.cursor = aString;
+
+ var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
+ for (var i = 0, count = [platformWindows count]; i < count; i++)
+ platformWindows[i]._DOMBodyElement.style.cursor = aString;
+#endif
+}
+
- (void)push
{
currentCursor = cursorStack.push(self);
diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j
index ff6f6e56d..3a2b505e8 100644
--- a/AppKit/CPTableView.j
+++ b/AppKit/CPTableView.j
@@ -137,7 +137,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
BOOL _reloadAllRows;
Object _objectValues;
- CPRange _exposedRows;
+ CPIndexSet _exposedRows;
CPIndexSet _exposedColumns;
Object _dataViewsForTableColumns;
@@ -1057,10 +1057,6 @@ window.setTimeout(function(){
{
var y = aPoint.y;
- if (NO)
- {
- }
-
var row = FLOOR(y / (_rowHeight + _intercellSpacing.height));
if (row >= _numberOfRows)
@@ -1269,28 +1265,13 @@ window.setTimeout(function(){
- (void)scrollRowToVisible:(int)rowIndex
{
- var scrollView = [[self superview] superview];
-
- if ([scrollView isKindOfClass:[CPScrollView class]] && [scrollView documentView] === self)
- {
- var rect = CGRectMake([scrollView._contentView bounds].origin.x, rowIndex*[self rowHeight], 1, [self rowHeight]);
- [[[scrollView contentView] documentView] scrollRectToVisible: rect];
- }
+ [self scrollRectToVisible:[self rectOfRow:rowIndex]];
}
- (void)scrollColumnToVisible:(int)columnIndex
{
- var rect = [self rectOfColumn:columnIndex];
-
- var scrollView = [[self superview] superview];
-
- if ([scrollView isKindOfClass:[CPScrollView class]] && [scrollView documentView] === self)
- {
- var rect = CGRectMake(rect.origin.x, [scrollView._contentView bounds].origin.y, rect.size.width, 1);
- [[[scrollView contentView] documentView] scrollRectToVisible: rect];
-
- /*FIX ME: tableview header isn't rendered until you click the horizontal scroller (or scroll)*/
- }
+ [self scrollRectToVisible:[self rectOfColumn:columnIndex]];
+ /*FIX ME: tableview header isn't rendered until you click the horizontal scroller (or scroll)*/
}
//Persistence
@@ -1404,7 +1385,7 @@ window.setTimeout(function(){
if ([_delegate respondsToSelector:@selector(tableViewColumnDidResize:)])
[defaultCenter
addObserver:_delegate
- selector:@selector(tableViewColumnDidMove:)
+ selector:@selector(tableViewColumnDidResize:)
name:CPTableViewColumnDidResizeNotification
object:self];
@@ -1837,7 +1818,11 @@ window.setTimeout(function(){
[self drawBackgroundInClipRect:exposedRect];
[self drawGridInClipRect:exposedRect];
[self highlightSelectionInClipRect:exposedRect];
+}
+- (void)drawRect:(CGRect)aRect
+{
+ [_tableDrawView display];
}
- (void)drawBackgroundInClipRect:(CGRect)aRect
@@ -2141,7 +2126,7 @@ window.setTimeout(function(){
var row = [self rowAtPoint:aPoint];
//if the user clicks outside a row then deslect everything
- if(row < 0 && _allowsEmptySelection)
+ if (row < 0 && _allowsEmptySelection)
[self selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
[self _noteSelectionIsChanging];
@@ -2225,6 +2210,7 @@ window.setTimeout(function(){
}
[self dragView:view at:offset offset:CPPointMakeZero() event:[CPApp currentEvent] pasteboard:pboard source:self slideBack:YES];
+
return NO;
}
}
@@ -2318,7 +2304,28 @@ window.setTimeout(function(){
*/
- (CPDragOperation)draggingEntered:(id)sender
{
+ var dropOperation = [self _proposedDropOperation],
+ draggingLocation = [sender draggingLocation],
+ row;
+ var location = [self convertPoint:draggingLocation fromView:nil];
+
+ row = [self _proposedRowAtPoint:location];
+
+ if(_retargetedDropRow !== nil)
+ row = _retargetedDropRow;
+
+ var draggedTypes = [self registeredDraggedTypes],
+ count = [draggedTypes count],
+ i;
+
+ for (i = 0; i < count; i++)
+ {
+ if ([[[sender draggingPasteboard] types] containsObject:[draggedTypes objectAtIndex: i]])
+ return [self _validateDrop:sender proposedRow:row proposedDropOperation:dropOperation];
+ }
+
+ return CPDragOperationNone;
}
/*
@@ -2334,11 +2341,16 @@ window.setTimeout(function(){
*/
- (void)draggingEnded:(id)sender
{
- _retargetedDropOperation = nil;
- _retargetedDropRow = nil;
- [_dropOperationFeedbackView setHidden:YES];
+ [self _draggingEnded];
}
+- (void)_draggingEnded
+{
+ _retargetedDropOperation = nil;
+ _retargetedDropRow = nil;
+ _draggedRowIndexes = [CPIndexSet indexSet];
+ [_dropOperationFeedbackView setHidden:YES];
+}
/*
@ignore
*/
@@ -2363,58 +2375,75 @@ window.setTimeout(function(){
/*
@ignore
*/
+- (CPInteger)_proposedRowAtPoint:(CGPoint)dragPoint
+{
+ var numberOfRows = [self numberOfRows],
+ row;
+ // cocoa seems to jump to the next row when we approach the below row
+ dragPoint.y += FLOOR(_rowHeight/4);
+
+ if (dragPoint.y > numberOfRows * (_rowHeight + _intercellSpacing.height))
+ {
+ if ([self _proposedDropOperation] === CPTableViewDropAbove)
+ row = numberOfRows;
+ else
+ row = numberOfRows - 1;
+ }
+ else
+ row = [self rowAtPoint:dragPoint];
+
+ return row;
+}
+
+- (void)_validateDrop:(id)info proposedRow:(CPInteger)row proposedDropOperation:(CPTableViewDropOperation)dropOperation
+{
+ if(_implementedDataSourceMethods & CPTableViewDataSource_tableView_validateDrop_proposedRow_proposedDropOperation_)
+ return [_dataSource tableView:self validateDrop:info proposedRow:row proposedDropOperation:dropOperation];
+
+ return CPDragOperationNone;
+}
+
- (CPDragOperation)draggingUpdated:(id)sender
{
+ var dropOperation = [self _proposedDropOperation],
+ numberOfRows = [self numberOfRows],
+ draggingLocation = [sender draggingLocation],
+ dragOperation,
+ row;
+ var location = [self convertPoint:draggingLocation fromView:nil];
- var location = [sender draggingLocation],
- scrollview = [[self superview] superview],
- contentview = [scrollview contentView],
- dropOperation = [self _proposedDropOperation];
-
- location = [contentview convertPoint:location fromView:nil];
- if(_headerView)
- location.y += CGRectGetHeight([_headerView bounds]);
-
- var row = [self rowAtPoint:location] - 1;
-
- //FIX ME: if the operation is CPTableViewDropAbove, we should be able to drop BELOW...
- if(row < 0 && dropOperation === CPTableViewDropOn)
- row = [self numberOfRows] - 1;
- else if(row < 0)
- row = [self numberOfRows] - 1;
-
- if(!(_implementedDataSourceMethods & CPTableViewDataSource_tableView_validateDrop_proposedRow_proposedDropOperation_))
- var operation = CPDragOperationNone;
- else
- var operation = [_dataSource tableView:self validateDrop:sender proposedRow:row proposedDropOperation:dropOperation];
-
-
-
+ row = [self _proposedRowAtPoint:location];
+ dragOperation = [self _validateDrop:sender proposedRow:row proposedDropOperation:dropOperation];
+
if(_retargetedDropRow !== nil)
row = _retargetedDropRow;
//if the user forces -1 then we should highlight the whole tabelview
+ var rowRect;
if(_retargetedDropRow === -1)
- var rowRect = [self exposedClipRect];
+ rowRect = [self exposedClipRect];
else
- var rowRect = [self rectOfRow:row];
+ rowRect = [self rectOfRow:row];
+
+ var exposedClipRect = [self exposedClipRect];
+ var visibleWidth = _CGRectGetWidth(exposedClipRect);
- if([[[self superview] superview] isKindOfClass:[CPScrollView class]])
- var visibleWidth = _CGRectGetWidth([[[self superview] superview] bounds]);
- else
- var visibleWidth = row.size.width;
+ rowRect = _CGRectMake(_CGRectGetMinX(exposedClipRect), rowRect.origin.y, visibleWidth, rowRect.size.height);
- rowRect = _CGRectMake(_CGRectGetMinX([self _exposedRect]), rowRect.origin.y, visibleWidth, rowRect.size.height);
-
- [_dropOperationFeedbackView setDropOperation:[self _proposedDropOperation]];
- [_dropOperationFeedbackView setHidden:NO];
+ [_dropOperationFeedbackView setDropOperation:dropOperation];
+ [_dropOperationFeedbackView setHidden:(dragOperation == CPDragOperationNone)];
[_dropOperationFeedbackView setFrame:rowRect];
[_dropOperationFeedbackView setCurrentRow:row];
[self addSubview:_dropOperationFeedbackView];
-
- return operation;
-
+
+ // FIXME : Maybe we should do this in a timer outside this method. Problem: we don't know when the scroll ends and neighter when the next -draggingUpdated is called. Which one will come first ?
+ if (row > 0 && location.y - CGRectGetMinY(exposedClipRect) < _rowHeight)
+ [self scrollRowToVisible:row - 1];
+ else if (row < numberOfRows && CGRectGetMaxY(exposedClipRect) - location.y < _rowHeight)
+ [self scrollRowToVisible:row + 1];
+
+ return dragOperation;
}
/*
@@ -2435,11 +2464,9 @@ window.setTimeout(function(){
- (BOOL)performDragOperation:(id)sender
{
var operation = [self _proposedDropOperation],
- location = [sender draggingLocation],
- scrollview = [[self superview] superview],
- contentview = [scrollview contentView];
+ draggingLocation = [sender draggingLocation];
- location = [contentview convertPoint:location fromView:scrollview];
+ var location = [self convertPoint:draggingLocation fromView:nil];
if(_retargetedDropRow !== nil)
var row = _retargetedDropRow;
@@ -2471,7 +2498,8 @@ window.setTimeout(function(){
we're using this because we drag views instead of images so we can get the rows themselves to actually drag
*/
- (void)draggedView:(CPImage)aView endedAt:(CGPoint)aLocation operation:(CPDragOperation)anOperation
-{
+{
+ [self _draggingEnded];
[self draggedImage:aView endedAt:aLocation operation:anOperation];
}
@@ -2897,4 +2925,4 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
//CGContextStrokeLineSegments(context, [aRect.origin.x + 8, aRect.origin.y + 8, 300 , aRect.origin.y + 8]);
}
}
-@end
\ No newline at end of file
+@end
diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j
index 619c12d08..e647e542f 100644
--- a/AppKit/CPTextField.j
+++ b/AppKit/CPTextField.j
@@ -501,11 +501,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (document.attachEvent)
{
- CPTextFieldCachedSelectStartFunction = document.body.onselectstart;
- CPTextFieldCachedDragFunction = document.body.ondrag;
+ CPTextFieldCachedSelectStartFunction = [[self window] platformWindow]._DOMBodyElement.onselectstart;
+ CPTextFieldCachedDragFunction = [[self window] platformWindow]._DOMBodyElement.ondrag;
- document.body.ondrag = function () {};
- document.body.onselectstart = function () {};
+ [[self window] platformWindow]._DOMBodyElement.ondrag = function () {};
+ [[self window] platformWindow]._DOMBodyElement.onselectstart = function () {};
}
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
@@ -548,8 +548,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
CPTextFieldCachedSelectStartFunction = nil;
CPTextFieldCachedDragFunction = nil;
- document.body.ondrag = CPTextFieldCachedDragFunction
- document.body.onselectstart = CPTextFieldCachedSelectStartFunction
+ [[self window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction;
+ [[self window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction;
}
#endif
diff --git a/AppKit/Jakefile b/AppKit/Jakefile
index bed91b589..169c19d20 100644
--- a/AppKit/Jakefile
+++ b/AppKit/Jakefile
@@ -6,6 +6,9 @@ $BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit');
AppKitFiles = new FileList("**/*.j").exclude('CoreGraphics/CGContextCanvas.j', 'CoreGraphics/CGContextVML.j', 'Themes/**/*', 'Tools/**/*', "Platform/DOM/CPPlatform.j", "Platform/DOM/CPPlatformString.j");
+FIXME_fileDependency (FILE.join("Platform", "CPPlatform.j"), FILE.join("Platform", "DOM", "CPPlatform.j"));
+FIXME_fileDependency (FILE.join("Platform", "CPPlatformString.j"), FILE.join("Platform", "DOM", "CPPlatformString.j"));
+
appKitTask = framework ("AppKit", function(appKitTask)
{
appKitTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "AppKit.build", $CONFIGURATION))
diff --git a/AppKit/Platform/DOM/CPPlatform.j b/AppKit/Platform/DOM/CPPlatform.j
index e22819943..535644ea2 100644
--- a/AppKit/Platform/DOM/CPPlatform.j
+++ b/AppKit/Platform/DOM/CPPlatform.j
@@ -22,7 +22,8 @@
CPPlatformDidClearBodyElementNotification = @"CPPlatformDidClearBodyElementNotification";
-var screenNeedsInitialization = NO;
+var screenNeedsInitialization = NO,
+ mainBodyElement = nil;
@implementation CPPlatform : CPBasePlatform
{
@@ -75,6 +76,14 @@ var screenNeedsInitialization = NO;
window.cpHide();
}
++ (DOMElement)mainBodyElement
+{
+ if (!mainBodyElement)
+ mainBodyElement = document.getElementById("cappuccino-body") || document.body;
+
+ return mainBodyElement;
+}
+
+ (void)initializeScreenIfNecessary
{
if (!screenNeedsInitialization)
@@ -82,11 +91,11 @@ var screenNeedsInitialization = NO;
screenNeedsInitialization = NO;
- var DOMBodyElement = document.body;
+ var bodyElement = [self mainBodyElement];
// Get rid of any of the original contents of the page.
- DOMBodyElement.innerHTML = "";
- DOMBodyElement.style.overflow = "hidden";
+ bodyElement.innerHTML = "";
+ bodyElement.style.overflow = "hidden";
if (document.documentElement)
document.documentElement.style.overflow = "hidden";
diff --git a/AppKit/Platform/DOM/CPPlatformString.j b/AppKit/Platform/DOM/CPPlatformString.j
index 595ae184c..e0431b0d4 100644
--- a/AppKit/Platform/DOM/CPPlatformString.j
+++ b/AppKit/Platform/DOM/CPPlatformString.j
@@ -44,34 +44,40 @@ var DOMSpanElement = nil,
+ (void)createDOMElements
{
var DOMIFrameElement = document.createElement("iframe");
-
- DOMIFrameElement.name = name = "iframe_" + FLOOR(RAND() * 10000);
+ // necessary for Safari caching bug:
+ DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000);
DOMIFrameElement.style.position = "absolute";
- DOMIFrameElement.style.left = "-1000px";
- DOMIFrameElement.style.top = "-1000px";
- // TODO: investigate a better way to make this work in IE:
- DOMIFrameElement.style.width = "1000px";
- DOMIFrameElement.style.height = "1000px";
+ DOMIFrameElement.style.left = "-100px";
+ DOMIFrameElement.style.top = "-100px";
+ DOMIFrameElement.style.width = "1px";
+ DOMIFrameElement.style.height = "1px";
DOMIFrameElement.style.borderWidth = "0px";
DOMIFrameElement.style.overflow = "hidden";
DOMIFrameElement.style.zIndex = 100000000000;
- document.body.appendChild(DOMIFrameElement);
+ var bodyElement = [CPPlatform mainBodyElement];
+
+ bodyElement.appendChild(DOMIFrameElement);
var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document);
-
DOMIFrameDocument.write("
");
DOMIFrameDocument.close();
- DOMSpanElement = DOMIFrameDocument.createElement("span");
+ // IE needs this wide to prevent unwanted text wrapping:
+ var DOMDivElement = DOMIFrameDocument.createElement("div");
+ DOMDivElement.style.position = "absolute";
+ DOMDivElement.style.width = "100000px";
+ DOMIFrameDocument.body.appendChild(DOMDivElement);
+
+ DOMSpanElement = DOMIFrameDocument.createElement("span");
DOMSpanElement.style.position = "absolute";
DOMSpanElement.style.whiteSpace = "pre";
DOMSpanElement.style.visibility = "visible";
DOMSpanElement.style.padding = "0px";
DOMSpanElement.style.margin = "0px";
- DOMIFrameDocument.body.appendChild(DOMSpanElement);
+ DOMDivElement.appendChild(DOMSpanElement);
}
+ (void)platformDidClearBodyElement:(CPNotification)aNotification
diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j
index 4184247c6..152373698 100644
--- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j
+++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j
@@ -264,7 +264,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
{
var theDocument = _DOMWindow.document;
- _DOMBodyElement = theDocument.body;
+ _DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
// FIXME: Always do this?
if ([CPPlatform supportsDragAndDrop])
@@ -401,8 +401,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMWindow.onmousewheel = scrollEventCallback;
theDocument.onmousewheel = scrollEventCallback;
- theDocument.body.ondrag = function () { return NO; };
- theDocument.body.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; };
+ _DOMBodyElement.ondrag = function () { return NO; };
+ _DOMBodyElement.onselectstart = function () { return _DOMWindow.event.srcElement === _DOMPasteboardElement; };
_DOMWindow.attachEvent("onbeforeunload", function()
{
@@ -423,8 +423,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMWindow.onmousewheel = NULL;
theDocument.onmousewheel = NULL;
- theDocument.body.ondrag = NULL;
- theDocument.body.onselectstart = NULL;
+ _DOMBodyElement.ondrag = NULL;
+ _DOMBodyElement.onselectstart = NULL;
//_DOMWindow.removeEvent("beforeunload", this);
@@ -462,7 +462,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
_DOMWindow.cpSetShadowStyle(_shadowStyle);
}
- _DOMWindow.document.body.style.cursor = [[CPCursor currentCursor] _cssString];
+ _DOMBodyElement.style.cursor = [[CPCursor currentCursor] _cssString];
[self registerDOMWindow];
}
@@ -497,7 +497,7 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
DOMDragElement.style.left = -_CGRectGetWidth(draggedWindowFrame) + "px";
DOMDragElement.style.top = -_CGRectGetHeight(draggedWindowFrame) + "px";
- document.body.appendChild(DOMDragElement);
+ _DOMBodyElement.appendChild(DOMDragElement);
var draggingOffset = [dragServer draggingOffset];
diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j
index 7554c0562..d709b2142 100644
--- a/AppKit/Themes/Aristo/ThemeDescriptors.j
+++ b/AppKit/Themes/Aristo/ThemeDescriptors.j
@@ -882,16 +882,16 @@
]
isVertical:NO]);
- var knobDisabledColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices:
+ /*var knobDisabledColor = PatternColor([[CPThreePartImage alloc] initWithImageSlices:
[
[_CPCibCustomResource imageResourceWithName:"HUD/scroller-horizontal-knob-disabled-left.png" size:CGSizeMake(10.0, 15.0)],
[_CPCibCustomResource imageResourceWithName:"HUD/scroller-horizontal-knob-disabled-center.png" size:CGSizeMake(1.0, 15.0)],
[_CPCibCustomResource imageResourceWithName:"HUD/scroller-horizontal-knob-disabled-right.png" size:CGSizeMake(10.0, 15.0)]
]
- isVertical:NO]);
+ isVertical:NO]);*/
[scroller setValue:knobColor forThemeAttribute:@"knob-color"];
- [scroller setValue:knobDisabledColor forThemeAttribute:@"knob-color" inState:CPThemeStateDisabled];
+ //[scroller setValue:knobDisabledColor forThemeAttribute:@"knob-color" inState:CPThemeStateDisabled];
[scroller setFloatValue:0.1];
[scroller setKnobProportion:0.5];
diff --git a/Tests/Manual/CPCursor/index.html b/Tests/Manual/CPCursor/index.html
index ffac21241..6d8fd04a1 100644
--- a/Tests/Manual/CPCursor/index.html
+++ b/Tests/Manual/CPCursor/index.html
@@ -39,29 +39,31 @@
-
-
-
-