diff --git a/AppKit/AppKit.j b/AppKit/AppKit.j index 9f9db4730..3a2a3f421 100644 --- a/AppKit/AppKit.j +++ b/AppKit/AppKit.j @@ -50,6 +50,7 @@ @import "CPImageView.j" @import "CPMenu.j" @import "CPMenuItem.j" +@import "CPOpenPanel.j" @import "CPPanel.j" @import "CPPasteboard.j" @import "CPPopUpButton.j" diff --git a/AppKit/CPColor.j b/AppKit/CPColor.j index 9bd934b90..d4188c92e 100644 --- a/AppKit/CPColor.j +++ b/AppKit/CPColor.j @@ -623,6 +623,15 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image @end +@implementation CPColor (Debugging) + ++ (CPColor)randomColor +{ + return [CPColor colorWithRed:RAND() green:RAND() blue:RAND() alpha:1.0]; +} + +@end + var CPColorComponentsKey = @"CPColorComponentsKey", CPColorPatternImageKey = @"CPColorPatternImageKey"; diff --git a/AppKit/CPOpenPanel.j b/AppKit/CPOpenPanel.j new file mode 100644 index 000000000..d54026c5c --- /dev/null +++ b/AppKit/CPOpenPanel.j @@ -0,0 +1,63 @@ + +@import +#include "Platform/Platform.h" + +var SharedOpenPanel = nil; + +@implementation CPOpenPanel : CPPanel +{ + CPArray _files; + BOOL _canChooseFiles @accessors(property=canChooseFiles); + BOOL _canChooseDirectories @accessors(property=canChooseDirectories); + BOOL _allowsMultipleSelection @accessors(property=allowsMultipleSelection); +} + ++ (id)openPanel +{ + if (!SharedOpenPanel) + SharedOpenPanel = [[CPOpenPanel alloc] init]; + + return SharedOpenPanel; +} + +- (id)init +{ + if (self = [super init]) + { + _files = []; + _canChooseFiles = YES; + } + + return self; +} + +- (void)filenames +{ + return _files; +} + +- (unsigned)runModalForDirectory:(CPString)absoluteDirectoryPath file:(CPString)filename types:(CPArray)fileTypes +{ +#if PLATFORM(DOM) + console.log("0 "+Titanium); + console.log("1 "+window.Titanium); + if (window.Titanium) + { + _files = Titanium.Desktop.openFiles({ + path:absoluteDirectoryPath, + types:fileTypes, + multiple:_allowsMultipleSelection, + filename:filename, + directories:_canChooseDirectories, + files:_canChooseFiles + }); + } +#endif +} + +- (unsigned)runModalForTypes:(CPArray)fileTypes +{alert("HERE"); + [self runModalForDirectory:"/" file:nil types:fileTypes]; +} + +@end