mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-30 02:12:03 +00:00
Merge branch 'master' of git://github.com/280north/cappuccino
This commit is contained in:
commit
1c0a450b36
7 files changed
+141
-75
No files matched your search
+93
-52
@@ -49,21 +49,22 @@ var CPSplitViewHorizontalImage = nil,
|
||||
CPArray _DOMDividerElements;
|
||||
CPString _dividerImagePath;
|
||||
int _drawingDivider;
|
||||
|
||||
BOOL _needsResizeSubviews;
|
||||
}
|
||||
|
||||
/*
|
||||
@ignore
|
||||
*/
|
||||
//+ (void)initialize
|
||||
//{
|
||||
// if (self != [CPSplitView class])
|
||||
// return;
|
||||
//
|
||||
// var bundle = [CPBundle bundleForClass:self];
|
||||
//
|
||||
// CPSplitViewHorizontalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewHorizontal.png"] size:CPSizeMake(5.0, 10.0)];
|
||||
// CPSplitViewVerticalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewVertical.png"] size:CPSizeMake(10.0, 5.0)];
|
||||
//}
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self != [CPSplitView class])
|
||||
return;
|
||||
|
||||
var bundle = [CPBundle bundleForClass:self];
|
||||
CPSplitViewHorizontalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewHorizontal.png"] size:CPSizeMake(5.0, 10.0)];
|
||||
CPSplitViewVerticalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewVertical.png"] size:CPSizeMake(10.0, 5.0)];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
@@ -89,20 +90,45 @@ var CPSplitViewHorizontalImage = nil,
|
||||
return _isVertical;
|
||||
}
|
||||
|
||||
- (void)setVertical:(BOOL)flag
|
||||
- (void)setVertical:(BOOL)shouldBeVertical
|
||||
{
|
||||
[self _setVertical:flag];
|
||||
if (![self _setVertical:shouldBeVertical])
|
||||
return;
|
||||
|
||||
[self adjustSubviews];
|
||||
// Just re-adjust evenly.
|
||||
var frame = [self frame],
|
||||
dividerThickness = [self dividerThickness];
|
||||
|
||||
[self _postNotificationWillResize];
|
||||
|
||||
var eachSize = ROUND((frame.size[_sizeComponent] - dividerThickness * (_subviews.length - 1)) / _subviews.length),
|
||||
index = 0,
|
||||
count = _subviews.length;
|
||||
|
||||
if ([self isVertical])
|
||||
for (; index < count; ++index)
|
||||
[_subviews[index] setFrame:CGRectMake(ROUND((eachSize + dividerThickness) * index), 0, eachSize, frame.size.height)];
|
||||
else
|
||||
for (; index < count; ++index)
|
||||
[_subviews[index] setFrame:CGRectMake(0, ROUND((eachSize + dividerThickness) * index), frame.size.width, eachSize)];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
[self _postNotificationDidResize];
|
||||
|
||||
}
|
||||
|
||||
- (void)_setVertical:(BOOL)flag
|
||||
- (BOOL)_setVertical:(BOOL)shouldBeVertical
|
||||
{
|
||||
_isVertical = flag;
|
||||
var changed = (_isVertical != shouldBeVertical);
|
||||
|
||||
_originComponent = [self isVertical] ? "x" : "y";
|
||||
_sizeComponent = [self isVertical] ? "width" : "height";
|
||||
_dividerImagePath = [self isVertical] ? [CPSplitViewVerticalImage filename] : [CPSplitViewHorizontalImage filename];
|
||||
_isVertical = shouldBeVertical;
|
||||
|
||||
_originComponent = [self isVertical] ? "x" : "y";
|
||||
_sizeComponent = [self isVertical] ? "width" : "height";
|
||||
_dividerImagePath = [self isVertical] ? [CPSplitViewVerticalImage filename] : [CPSplitViewHorizontalImage filename];
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
- (BOOL)isPaneSplitter
|
||||
@@ -124,32 +150,10 @@ var CPSplitViewHorizontalImage = nil,
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)didAddSubview:(CPView)subview
|
||||
- (void)didAddSubview:(CPView)aSubview
|
||||
{
|
||||
[self adjustSubviews];
|
||||
}
|
||||
|
||||
- (void)adjustSubviews
|
||||
{
|
||||
var frame = [self frame],
|
||||
dividerThickness = [self dividerThickness];
|
||||
|
||||
[self _postNotificationWillResize];
|
||||
|
||||
var eachSize = ROUND((frame.size[_sizeComponent] - dividerThickness * (_subviews.length - 1)) / _subviews.length),
|
||||
index = 0,
|
||||
count = _subviews.length;
|
||||
|
||||
if ([self isVertical])
|
||||
for (; index < count; ++index)
|
||||
[_subviews[index] setFrame:CGRectMake(ROUND((eachSize + dividerThickness) * index), 0, eachSize, frame.size.height)];
|
||||
else
|
||||
for (; index < count; ++index)
|
||||
[_subviews[index] setFrame:CGRectMake(0, ROUND((eachSize + dividerThickness) * index), frame.size.width, eachSize)];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
[self _postNotificationDidResize];
|
||||
_needsResizeSubviews = YES;
|
||||
// [self adjustSubviews];
|
||||
}
|
||||
|
||||
- (BOOL)isSubviewCollapsed:(CPView)subview
|
||||
@@ -219,6 +223,39 @@ var CPSplitViewHorizontalImage = nil,
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)viewWillDraw
|
||||
{
|
||||
[self _adjustSubviewsWithCalculatedSize];
|
||||
}
|
||||
|
||||
- (void)_adjustSubviewsWithCalculatedSize
|
||||
{
|
||||
if (!_needsResizeSubviews)
|
||||
return;
|
||||
|
||||
_needsResizeSubviews = NO;
|
||||
|
||||
var subviews = [self subviews],
|
||||
count = subviews.length,
|
||||
oldSize = CGSizeMakeZero();
|
||||
|
||||
if ([self isVertical])
|
||||
{
|
||||
oldSize.width += [self dividerThickness] * (count - 1);
|
||||
oldSize.height = CGRectGetHeight([self frame]);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldSize.width = CGRectGetWidth([self frame]);
|
||||
oldSize.height += [self dividerThickness] * (count - 1);
|
||||
}
|
||||
|
||||
while (count--)
|
||||
oldSize[_sizeComponent] += [subviews[count] frame].size[_sizeComponent];
|
||||
|
||||
[self resizeSubviewsWithOldSize:oldSize];
|
||||
}
|
||||
|
||||
- (BOOL)cursorAtPoint:(CPPoint)aPoint hitDividerAtIndex:(int)anIndex
|
||||
{
|
||||
var frame = [_subviews[anIndex] frame],
|
||||
@@ -354,6 +391,8 @@ var CPSplitViewHorizontalImage = nil,
|
||||
|
||||
- (void)setPosition:(float)position ofDividerAtIndex:(int)dividerIndex
|
||||
{
|
||||
[self _adjustSubviewsWithCalculatedSize];
|
||||
|
||||
// not sure where this should override other positions?
|
||||
if ([_delegate respondsToSelector:@selector(splitView:constrainSplitPosition:ofSubviewAt:)])
|
||||
position = [_delegate splitView:self constrainSplitPosition:position ofSubviewAt:dividerIndex];
|
||||
@@ -387,13 +426,22 @@ var CPSplitViewHorizontalImage = nil,
|
||||
|
||||
frameB.size[_sizeComponent] = frameB.origin[_originComponent] + frameB.size[_sizeComponent] - realPosition - [self dividerThickness];
|
||||
frameB.origin[_originComponent] = realPosition + [self dividerThickness];
|
||||
[_subviews[dividerIndex+1] setFrame:frameB];
|
||||
[_subviews[dividerIndex + 1] setFrame:frameB];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)setFrameSize:(CGSize)aSize
|
||||
{
|
||||
[self _adjustSubviewsWithCalculatedSize];
|
||||
|
||||
[super setFrameSize:aSize];
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)resizeSubviewsWithOldSize:(CPSize)oldSize
|
||||
{
|
||||
{
|
||||
if ([_delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
|
||||
{
|
||||
[_delegate splitView:self resizeSubviewsWithOldSize:oldSize];
|
||||
@@ -422,8 +470,6 @@ var CPSplitViewHorizontalImage = nil,
|
||||
|
||||
[view setFrame:newFrame];
|
||||
}
|
||||
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
[self _postNotificationDidResize];
|
||||
}
|
||||
@@ -505,8 +551,3 @@ var CPSplitViewDelegateKey = "CPSplitViewDelegateKey",
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// FIXME: once +initialize is fixed for superclasses, remove this and uncomment +initialize
|
||||
var bundle = [CPBundle bundleForClass:CPSplitView];
|
||||
CPSplitViewHorizontalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewHorizontal.png"] size:CPSizeMake(5.0, 10.0)];
|
||||
CPSplitViewVerticalImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSplitView/CPSplitViewVertical.png"] size:CPSizeMake(10.0, 5.0)];
|
||||
+16
-6
@@ -173,11 +173,6 @@ var DOMElementPrototype = nil,
|
||||
*/
|
||||
+ (void)initialize
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if ([self instanceMethodForSelector:@selector(drawRect:)] != [CPView instanceMethodForSelector:@selector(drawRect:)])
|
||||
CustomDrawRectViews[[self hash]] = YES;
|
||||
#endif
|
||||
|
||||
if (self != [CPView class])
|
||||
return;
|
||||
|
||||
@@ -1380,7 +1375,16 @@ setBoundsOrigin:
|
||||
- (void)setNeedsDisplayInRect:(CPRect)aRect
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!CustomDrawRectViews[[[self class] hash]])
|
||||
var hash = [[self class] hash],
|
||||
hasCustomDrawRect = CustomDrawRectViews[hash];
|
||||
|
||||
if (!hasCustomDrawRect && typeof hasCustomDrawRect === "undefined")
|
||||
{
|
||||
hasCustomDrawRect = [self methodForSelector:@selector(drawRect:)] != [CPView instanceMethodForSelector:@selector(drawRect:)];
|
||||
CustomDrawRectViews[hash] = hasCustomDrawRect;
|
||||
}
|
||||
|
||||
if (!hasCustomDrawRect)
|
||||
return;
|
||||
#endif
|
||||
|
||||
@@ -1431,6 +1435,8 @@ setBoundsOrigin:
|
||||
*/
|
||||
- (void)displayRect:(CPRect)aRect
|
||||
{
|
||||
[self viewWillDraw];
|
||||
|
||||
[self displayRectIgnoringOpacity:aRect inContext:nil];
|
||||
|
||||
_dirtyRect = NULL;
|
||||
@@ -1446,6 +1452,10 @@ setBoundsOrigin:
|
||||
[self unlockFocus];
|
||||
}
|
||||
|
||||
- (void)viewWillDraw
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
Locks focus on the receiver, so drawing commands apply to it.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -24,8 +24,8 @@ import <Foundation/CPObject.j>
|
||||
import <Foundation/CPURLConnection.j>
|
||||
import <Foundation/CPURLRequest.j>
|
||||
|
||||
import "CPCustomView.j"
|
||||
import "_CPCibCustomObject.j"
|
||||
import "_CPCibCustomView.j"
|
||||
import "_CPCibKeyedUnarchiver.j"
|
||||
import "_CPCibObjectData.j"
|
||||
import "_CPCibWindowTemplate.j"
|
||||
|
||||
File renamed without changes.
@@ -340,7 +340,7 @@ function CPPropertyListCreateFromXMLData(XMLNodeOrData)
|
||||
if (XMLNode.string)
|
||||
{
|
||||
#if RHINO
|
||||
XMLNode = DOCUMENT_ELEMENT(Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
|
||||
XMLNode = DOCUMENT_ELEMENT(_documentBuilder.parse(
|
||||
new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(XMLNode.string))));
|
||||
#else
|
||||
if (window.ActiveXObject)
|
||||
|
||||
+29
-14
@@ -107,11 +107,11 @@ if (typeof readFile == "undefined") {
|
||||
var f = new Packages.java.io.File(path);
|
||||
|
||||
if (!f.canRead()) {
|
||||
//alert("can't read: " + f.path)
|
||||
alert("can't read: " + f.path)
|
||||
return "";
|
||||
}
|
||||
|
||||
//alert("reading: " + f.getAbsolutePath());
|
||||
alert("reading: " + f.getAbsolutePath());
|
||||
|
||||
var fis = new Packages.java.io.FileInputStream(f);
|
||||
|
||||
@@ -119,12 +119,11 @@ if (typeof readFile == "undefined") {
|
||||
fis.read(b);
|
||||
|
||||
fis.close();
|
||||
|
||||
//return String(new Packages.java.lang.String(b));
|
||||
|
||||
if (characterCoding)
|
||||
return new Packages.java.lang.String(b, characterCoding);
|
||||
return String(new Packages.java.lang.String(b, characterCoding));
|
||||
else
|
||||
return new Packages.java.lang.String(b);
|
||||
return String(new Packages.java.lang.String(b));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -283,9 +282,25 @@ if (typeof Packages != "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
var xhr_builder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
xhr_builder.setErrorHandler(function(exception, methodName) {
|
||||
//print("xml error!");
|
||||
var _documentBuilderFactory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
|
||||
// setValidating to false doesn't seem to prevent it from downloading the DTD, but lets do it anyway
|
||||
_documentBuilderFactory.setValidating(false);
|
||||
|
||||
_documentBuilder = _documentBuilderFactory.newDocumentBuilder();
|
||||
// prevent the Java XML parser from downloading the plist DTD from Apple every time we parse a plist
|
||||
_documentBuilder.setEntityResolver(new Packages.org.xml.sax.EntityResolver({
|
||||
resolveEntity: function(publicId, systemId) {
|
||||
//Packages.java.lang.System.out.println("publicId=" + publicId + " systemId=" + systemId);
|
||||
|
||||
// TODO: return a local copy of the DTD?
|
||||
if (String(systemId) == "http://www.apple.com/DTDs/PropertyList-1.0.dtd")
|
||||
return new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(""));
|
||||
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
// throw an exception on error
|
||||
_documentBuilder.setErrorHandler(function(exception, methodName) {
|
||||
throw exception;
|
||||
});
|
||||
|
||||
@@ -372,7 +387,7 @@ if (typeof Packages != "undefined") {
|
||||
}
|
||||
|
||||
parseXMLString = function(string) {
|
||||
return (Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
|
||||
return (_documentBuilder.parse(
|
||||
new Packages.org.xml.sax.InputSource(
|
||||
new Packages.java.io.StringReader(string))).getDocumentElement());
|
||||
}
|
||||
@@ -435,23 +450,23 @@ XMLHttpRequest.prototype.send = function(body) {
|
||||
|
||||
try {
|
||||
this.responseText = readFile(this.url);
|
||||
alert("xhr: " + this.url);
|
||||
alert("xhr response: " + this.url + " (length="+this.responseText.length+")");
|
||||
} catch (e) {
|
||||
alert("read exception: " + this.url);
|
||||
alert("xhr exception: " + this.url);
|
||||
this.responseText = "";
|
||||
this.responseXML = null;
|
||||
}
|
||||
|
||||
if (this.responseText.length > 0) {
|
||||
try {
|
||||
this.responseXML = xhr_builder.parse(new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(this.responseText)));
|
||||
this.responseXML = _documentBuilder.parse(new Packages.org.xml.sax.InputSource(new Packages.java.io.StringReader(this.responseText)));
|
||||
} catch (e) {
|
||||
this.responseXML = null;
|
||||
}
|
||||
this.status = 200;
|
||||
}
|
||||
else {
|
||||
alert("empty file: " + this.url);
|
||||
alert("xhr empty: " + this.url);
|
||||
this.status = 404;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
import <AppKit/CPCustomView.j>
|
||||
import <AppKit/_CPCibCustomView.j>
|
||||
|
||||
import "NSView.j"
|
||||
|
||||
|
||||
Reference in new issue
Block a user