Added sample app. Corrected style (tabs)

This commit is contained in:
cacaodev authored and Ross Boucher committed 2009-10-08 12:02:35 -07:00
1 parent d79ed12b5c
commit 570a2a56ff
10 files changed
+380 -90

No files matched your search

+21 -21
View File
@@ -719,32 +719,32 @@ CPRunContinuesResponse = -1002;
*/
- (void)beginSheet:(CPWindow)aSheet modalForWindow:(CPWindow)aWindow modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
{
var styleMask = [aSheet styleMask];
if (!(styleMask & CPDocModalWindowMask))
{
[CPException raise:CPInternalInconsistencyException reason:@"Currently only CPDocModalWindowMask style mask is supported for attached sheets"];
return;
}
var styleMask = [aSheet styleMask];
if (!(styleMask & CPDocModalWindowMask))
{
[CPException raise:CPInternalInconsistencyException reason:@"Currently only CPDocModalWindowMask style mask is supported for attached sheets"];
return;
}
[aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo];
}
- (void)endSheet:(CPWindow)sheet returnCode:(int)returnCode
{
var count = [_windows count];
while (--count >= 0)
{
var aWindow = [_windows objectAtIndex:count];
var context = aWindow._sheetContext;
if (context != nil && context["sheet"] === sheet)
{
context["returnCode"] = returnCode;
[aWindow _detachSheetWindow];
return;
}
}
var count = [_windows count];
while (--count >= 0)
{
var aWindow = [_windows objectAtIndex:count];
var context = aWindow._sheetContext;
if (context != nil && context["sheet"] === sheet)
{
context["returnCode"] = returnCode;
[aWindow _detachSheetWindow];
return;
}
}
}
- (void)endSheet:(CPWindow)sheet
+64 -65
View File
@@ -310,7 +310,7 @@ var CPWindowSaveImage = nil,
BOOL _isFullPlatformWindow;
_CPWindowFullPlatformWindowSession _fullPlatformWindowSession;
CPDictionary _sheetContext;
CPDictionary _sheetContext;
}
/*
@@ -443,7 +443,7 @@ CPTexturedBackgroundWindowMask
return _CPBorderlessWindowView;
else if (aStyleMask & CPDocModalWindowMask)
return _CPDocModalWindowView;
return _CPDocModalWindowView;
return _CPStandardWindowView;
}
@@ -1729,11 +1729,11 @@ CPTexturedBackgroundWindowMask
- (void)_setFrame:(CGRect)aFrame delegate:(id)delegate duration:(int)duration curve:(CPAnimationCurve)curve
{
var animation = [[_CPWindowFrameAnimation alloc] initWithWindow:self targetFrame:aFrame];
[animation setDelegate:delegate];
[animation setAnimationCurve:curve];
[animation setDuration:duration];
[animation startAnimation];
var animation = [[_CPWindowFrameAnimation alloc] initWithWindow:self targetFrame:aFrame];
[animation setDelegate:delegate];
[animation setAnimationCurve:curve];
[animation setDuration:duration];
[animation startAnimation];
}
/* @ignore */
@@ -1744,60 +1744,60 @@ CPTexturedBackgroundWindowMask
var contentRect = [[self contentView] frame],
sheetFrame = CGRectMakeCopy([attachedSheet frame]);
sheetFrame.origin.y = CGRectGetMinY(_frame) + CGRectGetMinY(contentRect);
sheetFrame.origin.x = CGRectGetMinX(_frame) + FLOOR((CGRectGetWidth(_frame) - CGRectGetWidth(sheetFrame)) / 2.0);
sheetFrame.origin.y = CGRectGetMinY(_frame) + CGRectGetMinY(contentRect);
sheetFrame.origin.x = CGRectGetMinX(_frame) + FLOOR((CGRectGetWidth(_frame) - CGRectGetWidth(sheetFrame)) / 2.0);
[attachedSheet setFrameOrigin:sheetFrame.origin];
[attachedSheet setFrameOrigin:sheetFrame.origin];
}
/* @ignore */
- (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
{
var sheetFrame = [aSheet frame];
var sheetFrame = [aSheet frame];
// setup contexts
_sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector, "contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1, "opened": NO};
[self _attachSheetWindow:aSheet];
_sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector, "contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1, "opened": NO};
[self _attachSheetWindow:aSheet];
}
/* @ignore */
- (void)_attachSheetWindow:(CPWindow)aSheet
{
var sheetFrame = [aSheet frame],
frame = [self frame],
sheetContent = [aSheet contentView];
frame = [self frame],
sheetContent = [aSheet contentView];
// Configure sheet.
// if ([aSheet styleMask] & CPHUDBackgroundWindowMask)
// [aSheet setMovableByWindowBackground:NO];
// [aSheet setMovableByWindowBackground:NO];
_sheetContext["autoresizingMask"] = [sheetContent autoresizingMask];
_sheetContext["autoresizingMask"] = [sheetContent autoresizingMask];
[sheetContent setAutoresizingMask:CPViewMinYMargin];
[sheetContent setAutoresizesSubviews:NO];
aSheet._isSheet = YES;
aSheet._parentView = self;
// calculate start/end frames
var originx = frame.origin.x + FLOOR((frame.size.width - sheetFrame.size.width)/2);
var originy = frame.origin.y + [[self contentView] frame].origin.y;
var startFrame = CGRectMake(originx, originy , sheetFrame.size.width, 0);
var endFrame = CGRectMake(originx, originy ,sheetFrame.size.width,sheetFrame.size.height);
var originx = frame.origin.x + FLOOR((frame.size.width - sheetFrame.size.width)/2);
var originy = frame.origin.y + [[self contentView] frame].origin.y;
var startFrame = CGRectMake(originx, originy, sheetFrame.size.width, 0);
var endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height);
// Notify the world we will open the sheet
[[CPNotificationCenter defaultCenter] postNotificationName:@"CPWindowWillBeginSheetNotification" object:self];
// Start modal
[CPApp runModalForWindow:aSheet];
[CPApp runModalForWindow:aSheet];
// Order front and animate the sheet
// aSheet._isAnimating = YES;
// aSheet._isAnimating = YES;
[aSheet orderFront:self];
[aSheet setFrame:startFrame];
_sheetContext["opened"] = YES;
[aSheet _setFrame:endFrame delegate:self duration:0.3 curve:CPAnimationEaseOut];
// Should run the main loop here until _isAnimating = FALSE
// Should run the main loop here until _isAnimating = FALSE
[aSheet becomeKeyWindow];
}
@@ -1812,61 +1812,60 @@ CPTexturedBackgroundWindowMask
endFrame.size.height = 0;
// Set the new frame in case the sheet have been resized
_sheetContext["frame"] = startFrame;
_sheetContext["frame"] = startFrame;
// Autoresizing
var sheetContent = [sheet contentView];
var sheetContent = [sheet contentView];
[sheetContent setAutoresizingMask:CPViewMinYMargin];
[sheetContent setAutoresizesSubviews:NO];
_sheetContext["opened"] = NO;
// Start animation with delegate
_sheetContext["opened"] = NO;
[sheet _setFrame:endFrame delegate:self duration:0.2 curve:CPAnimationLinear];
[sheet _setFrame:endFrame delegate:self duration:0.2 curve:CPAnimationLinear];
}
/* @ignore */
- (void)animationDidEnd:(id)anim
{
var sheet = _sheetContext["sheet"];
if (anim._window != sheet)
return;
var sheet = _sheetContext["sheet"];
if (anim._window != sheet)
return;
// Retore autoresizing
var sheetContent = [sheet contentView];
[sheetContent setAutoresizingMask:_sheetContext["autoresizingMask"]];
[sheetContent setAutoresizesSubviews:YES];
var sheetContent = [sheet contentView];
[sheetContent setAutoresizingMask:_sheetContext["autoresizingMask"]];
[sheetContent setAutoresizesSubviews:YES];
// If we are opened return now
if (_sheetContext["opened"] == YES)
return;
// If we are opened return now
if (_sheetContext["opened"] === YES)
return;
// Stop modal
[CPApp stopModal];
[CPApp stopModal];
// Notify the world we closed the sheet
[[CPNotificationCenter defaultCenter] postNotificationName:@"CPWindowDidEndSheetNotification" object:self];
[[CPNotificationCenter defaultCenter] postNotificationName:@"CPWindowDidEndSheetNotification" object:self];
// check first if front ?
[sheet orderOut:self];
[sheet orderOut:self];
// Set the sheet frame to its last open state.
var lastFrame = _sheetContext["frame"];
[sheet setFrame:lastFrame];
// Send didEndSelector
var delegate = _sheetContext["modalDelegate"];
var endSelector = _sheetContext["endSelector"];
if(delegate != nil && endSelector != nil)
objj_msgSend(_sheetContext["modalDelegate"],
_sheetContext["endSelector"],
sheet,
_sheetContext["returnCode"],
_sheetContext["contextInfo"]);
var lastFrame = _sheetContext["frame"];
[sheet setFrame:lastFrame];
// Send didEndSelector
var delegate = _sheetContext["modalDelegate"];
var endSelector = _sheetContext["endSelector"];
if (delegate != nil && endSelector != nil)
objj_msgSend(_sheetContext["modalDelegate"],
_sheetContext["endSelector"],
sheet,
_sheetContext["returnCode"],
_sheetContext["contextInfo"]);
// reset contexts
_sheetContext = nil;
sheet._parentView = nil;
_sheetContext = nil;
sheet._parentView = nil;
}
/*!
@@ -1874,9 +1873,9 @@ CPTexturedBackgroundWindowMask
*/
- (CPWindow)attachedSheet
{
if (_sheetContext == nil)
return nil;
if (_sheetContext === nil)
return nil;
return _sheetContext["sheet"];
}
+4 -4
View File
@@ -5,7 +5,7 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
@implementation _CPDocModalWindowView : _CPWindowView
{
CPView _bodyView;
CPView _bodyView;
}
+ (CPColor)bodyBackgroundColor
@@ -22,9 +22,9 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
if (self)
{
var theClass = [self class],
var theClass = [self class],
bounds = [self bounds];
_bodyView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), CGRectGetHeight(bounds))];
[_bodyView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
@@ -34,7 +34,7 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
[self addSubview:_bodyView];
}
return self;
return self;
}
- (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
@@ -0,0 +1,84 @@
/*
* AppController.j
* AttachedSheet
*
* Created by Cacaodev on August 1, 2009.
* Copyright 2009, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
{
CPWindow window;
CPWindow sheet;
CPTextField textField;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
window = [[CPWindow alloc] initWithContentRect:CGRectMake(100,100,500,300) styleMask:CPResizableWindowMask],
contentView = [window contentView];
sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(0,0,300,100) styleMask:CPDocModalWindowMask|CPResizableWindowMask];
// [sheet setMinSize:CGSizeMake(300,100)];
var sheetContent = [sheet contentView];
textField = [[CPTextField alloc] initWithFrame:CGRectMake(10,30,280,30)];
[textField setEditable:YES];
[textField setBezeled:YES];
[textField setAutoresizingMask:CPViewMinYMargin|CPViewWidthSizable];
var okButton = [[CPButton alloc] initWithFrame:CGRectMake(230,70,50,24)];
[okButton setTitle:"OK"];
[okButton setTarget:self];
[okButton setTag:1];
[okButton setAction:@selector(closeSheet:)];
[okButton setAutoresizingMask:CPViewMinXMargin|CPViewMinYMargin];
var cancelButton = [[CPButton alloc] initWithFrame:CGRectMake(120,70,100,24)];
[cancelButton setTitle:"Cancel"];
[cancelButton setTarget:self];
[cancelButton setTag:0];
[cancelButton setAction:@selector(closeSheet:)];
[cancelButton setAutoresizingMask:CPViewMinXMargin|CPViewMinYMargin];
[sheetContent addSubview:textField];
[sheetContent addSubview:okButton];
[sheetContent addSubview:cancelButton];
var displayButton = [[CPButton alloc] initWithFrame:CGRectMake(200,150,100,24)];
[displayButton setTitle:"Display Sheet"];
[displayButton setTarget:self];
[displayButton setAction:@selector(displaySheet:)];
[contentView addSubview:displayButton];
[window orderFront:self]
}
- (void)displaySheet:(id)sender
{
[textField setStringValue:""];
[sheet makeFirstResponder:textField];
[CPApp beginSheet:sheet modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil];
}
- (void)closeSheet:(id)sender
{
[CPApp endSheet:sheet returnCode:[sender tag]];
}
- (void)didEndSheet:(CPWindow)sheet returnCode:(int)returnCode contextInfo:(id)contextInfo
{
var str = [textField stringValue];
[sheet orderOut:self];
if (returnCode == CPOKButton && [str length] > 0)
{
[window setTitle:str];
}
}
@end
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>FullOfSheet</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
+25
View File
@@ -0,0 +1,25 @@
require 'objective-j'
require 'objective-j/bundletask'
if !ENV['CONFIG']
ENV['CONFIG'] = 'Debug'
end
ObjectiveJ::BundleTask.new(:SplitView) do |t|
t.name = 'SplitView'
t.identifier = 'com.yourcompany.SplitView'
t.version = '1.0'
t.author = 'Your Company'
t.email = 'feedback @nospam@ yourcompany.com'
t.summary = 'SplitView'
t.sources = FileList['*.j']
t.resources = FileList['Resources/*']
t.index_file = 'index.html'
t.info_plist = 'Info.plist'
t.build_path = File.join('Build', ENV['CONFIG'], 'SplitView')
t.flag = '-DDEBUG' if ENV['CONFIG'] == 'Debug'
t.flag = '-O' if ENV['CONFIG'] == 'Release'
end
task :default => [:SplitView]
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index-debug.html
Untitled
Created by You on July 30, 2009.
Copyright 2009, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>Untitled</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
<script type = "text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to enable runtime type checking:
objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
objj_typecheck_prints_backtrace = true;
</script>
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading Untitled...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</body>
</html>
+69
View File
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<!--
index.html
SplitView
Created by You on August 1, 2009.
Copyright 2009, Your Company All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>Attached Sheet</title>
<script type = "text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
<style type = "text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading <i>Attached Sheet</i> …</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* SplitView
*
* Created by You on August 1, 2009.
* Copyright 2009, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}