diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 933e03c90..b0542a14e 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -271,6 +271,7 @@ var CPWindowActionMessageKeys = [ BOOL _isAnimating; BOOL _hasShadow; BOOL _isMovableByWindowBackground; + BOOL _isMovable; unsigned _shadowStyle; BOOL _showsResizeIndicator; @@ -404,6 +405,7 @@ CPTexturedBackgroundWindowMask _registeredDraggedTypesArray = []; _isSheet = NO; _acceptsMouseMovedEvents = YES; + _isMovable = YES; // Set up our window number. _windowNumber = [CPApp._windows count]; @@ -1438,6 +1440,23 @@ CPTexturedBackgroundWindowMask return _isMovableByWindowBackground; } +/*! + Sets whether the window can be moved. + @param shouldBeMovable \c YES makes the window movable. +*/ +- (void)setMovable:(BOOL)shouldBeMovable +{ + _isMovable = shouldBeMovable; +} + +/*! + Returns \c YES if the window can be moved. +*/ +- (void)isMovable +{ + return _isMovable; +} + /*! Sets the window location to be the center of the screen */ diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 6a9f62894..ffeaad082 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -111,7 +111,7 @@ var _CPWindowViewResizeIndicatorImage = nil; return [self trackResizeWithEvent:anEvent]; } - if ([theWindow isMovableByWindowBackground]) + if ([theWindow isMovable] && [theWindow isMovableByWindowBackground]) [self trackMoveWithEvent:anEvent]; else @@ -174,6 +174,9 @@ var _CPWindowViewResizeIndicatorImage = nil; - (void)trackMoveWithEvent:(CPEvent)anEvent { + if (![[self window] isMovable]) + return; + var type = [anEvent type]; if (type === CPLeftMouseUp) diff --git a/Tests/Manual/CPWindowMovableTest/AppController.j b/Tests/Manual/CPWindowMovableTest/AppController.j new file mode 100644 index 000000000..2599b1e02 --- /dev/null +++ b/Tests/Manual/CPWindowMovableTest/AppController.j @@ -0,0 +1,63 @@ +/* + * AppController.j + * CPWindowMovableTest + * + * Created by You on October 28, 2011. + * Copyright 2011, Your Company All rights reserved. + */ + +@import + + +@implementation AppController : CPObject +{ + CPWindow aWindow; + CPCheckBox backgroundMovableCB; + CPCheckBox movableCB; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + + backgroundMovableCB = [CPCheckBox checkBoxWithTitle:@"Movable by background"]; + + [backgroundMovableCB setFrameOrigin:CPPointMake(10, 10)]; + [backgroundMovableCB setTarget:self]; + [backgroundMovableCB setAction:@selector(setMovableByBackground:)] + [contentView addSubview:backgroundMovableCB]; + + movableCB = [CPCheckBox checkBoxWithTitle:@"Movable"]; + + [movableCB setFrameOrigin:CPPointMake(200, 10)]; + [movableCB setTarget:self]; + [movableCB setAction:@selector(setMovable:)] + [contentView addSubview:movableCB]; + + [theWindow orderFront:self]; + + aWindow = [[CPWindow alloc] initWithContentRect:CPRectMake(0, 0, 200, 200) styleMask:CPTitledWindowMask]; + [aWindow setTitle:@"Move me!"]; + [aWindow center]; + [aWindow makeKeyAndOrderFront:self]; + + [backgroundMovableCB setState:[aWindow isMovableByWindowBackground]]; + [movableCB setState:[aWindow isMovable]]; + [backgroundMovableCB setEnabled:[aWindow isMovable]]; +} + +- (IBAction)setMovableByBackground:(id)aSender +{ + [aWindow setMovableByWindowBackground:[aSender state] === CPOnState]; +} + +- (IBAction)setMovable:(id)aSender +{ + [aWindow setMovable:[aSender state] === CPOnState]; + [backgroundMovableCB setEnabled:[aWindow isMovable]]; +} + + +@end diff --git a/Tests/Manual/CPWindowMovableTest/Info.plist b/Tests/Manual/CPWindowMovableTest/Info.plist new file mode 100644 index 000000000..a0ae7cc67 --- /dev/null +++ b/Tests/Manual/CPWindowMovableTest/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + CPWindowMovableTest + CPPrincipalClass + CPApplication + + diff --git a/Tests/Manual/CPWindowMovableTest/Jakefile b/Tests/Manual/CPWindowMovableTest/Jakefile new file mode 100644 index 000000000..8ca955d00 --- /dev/null +++ b/Tests/Manual/CPWindowMovableTest/Jakefile @@ -0,0 +1,93 @@ +/* + * Jakefile + * CPWindowMovableTest + * + * Created by You on October 28, 2011. + * Copyright 2011, Your Company All rights reserved. + */ + +var ENV = require("system").env, + FILE = require("file"), + JAKE = require("jake"), + task = JAKE.task, + FileList = JAKE.FileList, + app = require("cappuccino/jake").app, + configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", + OS = require("os"); + +app ("CPWindowMovableTest", function(task) +{ + task.setBuildIntermediatesPath(FILE.join("Build", "CPWindowMovableTest.build", configuration)); + task.setBuildPath(FILE.join("Build", configuration)); + + task.setProductName("CPWindowMovableTest"); + task.setIdentifier("com.yourcompany.CPWindowMovableTest"); + task.setVersion("1.0"); + task.setAuthor("Your Company"); + task.setEmail("feedback @nospam@ yourcompany.com"); + task.setSummary("CPWindowMovableTest"); + task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**"))); + task.setResources(new FileList("Resources/**")); + task.setIndexFilePath("index.html"); + task.setInfoPlistPath("Info.plist"); + + if (configuration === "Debug") + task.setCompilerFlags("-DDEBUG -g"); + else + task.setCompilerFlags("-O"); +}); + +task ("default", ["CPWindowMovableTest"], function() +{ + printResults(configuration); +}); + +task ("build", ["default"]); + +task ("debug", function() +{ + ENV["CONFIGURATION"] = "Debug"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("release", function() +{ + ENV["CONFIGURATION"] = "Release"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("run", ["debug"], function() +{ + OS.system(["open", FILE.join("Build", "Debug", "CPWindowMovableTest", "index.html")]); +}); + +task ("run-release", ["release"], function() +{ + OS.system(["open", FILE.join("Build", "Release", "CPWindowMovableTest", "index.html")]); +}); + +task ("deploy", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Deployment", "CPWindowMovableTest")); + OS.system(["press", "-f", FILE.join("Build", "Release", "CPWindowMovableTest"), FILE.join("Build", "Deployment", "CPWindowMovableTest")]); + printResults("Deployment") +}); + +task ("desktop", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Desktop", "CPWindowMovableTest")); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPWindowMovableTest"), FILE.join("Build", "Desktop", "CPWindowMovableTest", "CPWindowMovableTest.app")); + printResults("Desktop") +}); + +task ("run-desktop", ["desktop"], function() +{ + OS.system([FILE.join("Build", "Desktop", "CPWindowMovableTest", "CPWindowMovableTest.app", "Contents", "MacOS", "NativeHost"), "-i"]); +}); + +function printResults(configuration) +{ + print("----------------------------"); + print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPWindowMovableTest")); + print("----------------------------"); +} diff --git a/Tests/Manual/CPWindowMovableTest/Resources/spinner.gif b/Tests/Manual/CPWindowMovableTest/Resources/spinner.gif new file mode 100644 index 000000000..06dbc2bc2 Binary files /dev/null and b/Tests/Manual/CPWindowMovableTest/Resources/spinner.gif differ diff --git a/Tests/Manual/CPWindowMovableTest/index-debug.html b/Tests/Manual/CPWindowMovableTest/index-debug.html new file mode 100644 index 000000000..048300db6 --- /dev/null +++ b/Tests/Manual/CPWindowMovableTest/index-debug.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + CPWindowMovableTest + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + diff --git a/Tests/Manual/CPWindowMovableTest/index.html b/Tests/Manual/CPWindowMovableTest/index.html new file mode 100644 index 000000000..0fcbd5fd4 --- /dev/null +++ b/Tests/Manual/CPWindowMovableTest/index.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + CPWindowMovableTest + + + + + + + + + + + + +
+
+ + + +
+
+ + + + diff --git a/Tests/Manual/CPWindowMovableTest/main.j b/Tests/Manual/CPWindowMovableTest/main.j new file mode 100644 index 000000000..9c4c247e4 --- /dev/null +++ b/Tests/Manual/CPWindowMovableTest/main.j @@ -0,0 +1,18 @@ +/* + * AppController.j + * CPWindowMovableTest + * + * Created by You on October 28, 2011. + * Copyright 2011, Your Company All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +}