diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index 9f04ec545..28b4a3cb6 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -39,17 +39,17 @@ @global @group CPAlertStyle */ -CPWarningAlertStyle = 0; +CPWarningAlertStyle = 0; /* @global @group CPAlertStyle */ -CPInformationalAlertStyle = 1; +CPInformationalAlertStyle = 1; /* @global @group CPAlertStyle */ -CPCriticalAlertStyle = 2; +CPCriticalAlertStyle = 2; var CPAlertWarningImage, @@ -58,7 +58,7 @@ var CPAlertWarningImage, /*! @ingroup appkit - + CPAlert is an alert panel that can be displayed modally to present the user with a message and one or more options. @@ -74,7 +74,7 @@ var CPAlertWarningImage, @delegate -(void)alertDidEnd:(CPAlert)theAlert returnCode:(int)returnCode; Called when the user dismisses the alert by clicking one of the buttons. @param theAlert the alert panel that the user dismissed - @param returnCode the index of the button that the user clicked (starting from 0, + @param returnCode the index of the button that the user clicked (starting from 0, representing the first button added to the alert which appears on the right, 1 representing the next button to the left and so on) */ @@ -100,15 +100,15 @@ var CPAlertWarningImage, if (self != CPAlert) return; - var bundle = [CPBundle bundleForClass:[self class]]; + var bundle = [CPBundle bundleForClass:[self class]]; - CPAlertWarningImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-warning.png"] + CPAlertWarningImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-warning.png"] size:CGSizeMake(32.0, 32.0)]; - - CPAlertInformationImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-information.png"] + + CPAlertInformationImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-information.png"] size:CGSizeMake(32.0, 32.0)]; - - CPAlertErrorImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-error.png"] + + CPAlertErrorImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-error.png"] size:CGSizeMake(32.0, 32.0)]; } @@ -125,7 +125,7 @@ var CPAlertWarningImage, [self setWindowStyle:nil]; } - + return self; } @@ -136,16 +136,16 @@ var CPAlertWarningImage, - (void)setWindowStyle:(int)styleMask { _windowStyle = styleMask; - + _alertPanel = [[CPPanel alloc] initWithContentRect:CGRectMake(0.0, 0.0, 400.0, 110.0) styleMask:styleMask ? styleMask | CPTitledWindowMask : CPTitledWindowMask]; [_alertPanel setFloatingPanel:YES]; [_alertPanel center]; var count = [_buttons count]; - for(var i=0; i < count; i++) + for (var i = 0; i < count; i++) { var button = _buttons[i]; - [button setTheme:(_windowStyle === CPHUDBackgroundWindowMask) ? [CPTheme themeNamed:"Aristo-HUD"] : [CPTheme defaultTheme]]; + [button setTheme:(_windowStyle === CPHUDBackgroundWindowMask) ? [CPTheme defaultHudTheme] : [CPTheme defaultTheme]]; [[_alertPanel contentView] addSubview:button]; } @@ -160,7 +160,6 @@ var CPAlertWarningImage, [_messageLabel setAlignment:CPJustifiedTextAlignment]; [_messageLabel setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable]; - _alertImageView = [[CPImageView alloc] initWithFrame:CGRectMake(15.0, 12.0, 32.0, 32.0)]; _informativeLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; @@ -294,12 +293,12 @@ var CPAlertWarningImage, [button setTarget:self]; [button setTag:_buttonCount]; [button setAction:@selector(_notifyDelegate:)]; - - [button setTheme:(_windowStyle === CPHUDBackgroundWindowMask) ? [CPTheme themeNamed:"Aristo-HUD"] : [CPTheme defaultTheme]]; + + [button setTheme:(_windowStyle === CPHUDBackgroundWindowMask) ? [CPTheme defaultHudTheme] : [CPTheme defaultTheme]]; [button setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; [[_alertPanel contentView] addSubview:button]; - + if (_buttonCount == 0) [button setKeyEquivalent:CPCarriageReturnCharacter]; else if ([title lowercaseString] === "cancel") @@ -319,7 +318,8 @@ var CPAlertWarningImage, count = [_buttons count], offsetX = CGRectGetWidth(bounds), offsetY = CGRectGetHeight(bounds) - 34.0; - for(var i=0; i < count; i++) + + for (var i = 0; i < count; i++) { var button = _buttons[i]; @@ -353,7 +353,7 @@ var CPAlertWarningImage, - (void)runModal { var theTitle; - + switch (_alertStyle) { case CPWarningAlertStyle: [_alertImageView setImage:CPAlertWarningImage]; @@ -366,9 +366,9 @@ var CPAlertWarningImage, theTitle = @"Error"; break; } - + [_alertPanel setTitle:_windowTitle ? _windowTitle : theTitle]; - + [CPApp runModalForWindow:_alertPanel]; } diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index a1d27c8e5..c0b91722c 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -24,8 +24,9 @@ @import @import -var CPThemesByName = { }, - CPThemeDefaultTheme = nil; +var CPThemesByName = { }, + CPThemeDefaultTheme = nil, + CPThemeDefaultHudTheme = nil; /*! @@ -48,6 +49,27 @@ var CPThemesByName = { }, return CPThemeDefaultTheme; } +/*! + Set the default HUD theme. If set to nil, the default described in defaultHudTheme + will be used. +*/ ++ (void)setDefaultHudTheme:(CPTheme)aTheme +{ + CPThemeDefaultHudTheme = aTheme; +} + +/*! + The default HUD theme is (sometimes) used for windows with the CPHUDBackgroundWindowMask + style mask. The default is theme with the name of the default theme with -HUD appended + at the end. +*/ ++ (CPTheme)defaultHudTheme +{ + if (!CPThemeDefaultHudTheme) + CPThemeDefaultHudTheme = [CPTheme themeNamed:[[self defaultTheme] name] + "-HUD"]; + return CPThemeDefaultHudTheme; +} + + (CPTheme)themeNamed:(CPString)aName { return CPThemesByName[aName]; @@ -474,15 +496,15 @@ CPThemeStateCircular = CPThemeState("circular"); @end -var cachedNumberOfOnes = [ 0 /*000000*/, 1 /*000001*/, 1 /*000010*/, 2 /*000011*/, 1 /*000100*/, 2 /*000101*/, 2 /*000110*/, - 3 /*000111*/, 1 /*001000*/, 2 /*001001*/, 2 /*001010*/, 3 /*001011*/, 2 /*001100*/, 3 /*001101*/, - 3 /*001110*/, 4 /*001111*/, 1 /*010000*/, 2 /*010001*/, 2 /*010010*/, 3 /*010011*/, 2 /*010100*/, - 3 /*010101*/, 3 /*010110*/, 4 /*010111*/, 2 /*011000*/, 3 /*011001*/, 3 /*011010*/, 4 /*011011*/, - 3 /*011100*/, 4 /*011101*/, 4 /*011110*/, 5 /*011111*/, 1 /*100000*/, 2 /*100001*/, 2 /*100010*/, - 3 /*100011*/, 2 /*100100*/, 3 /*100101*/, 3 /*100110*/, 4 /*100111*/, 2 /*101000*/, 3 /*101001*/, - 3 /*101010*/, 4 /*101011*/, 3 /*101100*/, 4 /*101101*/, 4 /*101110*/, 5 /*101111*/, 2 /*110000*/, - 3 /*110001*/, 3 /*110010*/, 4 /*110011*/, 3 /*110100*/, 4 /*110101*/, 4 /*110110*/, 5 /*110111*/, - 3 /*111000*/, 4 /*111001*/, 4 /*111010*/, 5 /*111011*/, 4 /*111100*/, 5 /*111101*/, 5 /*111110*/, +var cachedNumberOfOnes = [ 0 /*000000*/, 1 /*000001*/, 1 /*000010*/, 2 /*000011*/, 1 /*000100*/, 2 /*000101*/, 2 /*000110*/, + 3 /*000111*/, 1 /*001000*/, 2 /*001001*/, 2 /*001010*/, 3 /*001011*/, 2 /*001100*/, 3 /*001101*/, + 3 /*001110*/, 4 /*001111*/, 1 /*010000*/, 2 /*010001*/, 2 /*010010*/, 3 /*010011*/, 2 /*010100*/, + 3 /*010101*/, 3 /*010110*/, 4 /*010111*/, 2 /*011000*/, 3 /*011001*/, 3 /*011010*/, 4 /*011011*/, + 3 /*011100*/, 4 /*011101*/, 4 /*011110*/, 5 /*011111*/, 1 /*100000*/, 2 /*100001*/, 2 /*100010*/, + 3 /*100011*/, 2 /*100100*/, 3 /*100101*/, 3 /*100110*/, 4 /*100111*/, 2 /*101000*/, 3 /*101001*/, + 3 /*101010*/, 4 /*101011*/, 3 /*101100*/, 4 /*101101*/, 4 /*101110*/, 5 /*101111*/, 2 /*110000*/, + 3 /*110001*/, 3 /*110010*/, 4 /*110011*/, 3 /*110100*/, 4 /*110101*/, 4 /*110110*/, 5 /*110111*/, + 3 /*111000*/, 4 /*111001*/, 4 /*111010*/, 5 /*111011*/, 4 /*111100*/, 5 /*111101*/, 5 /*111110*/, 6 /*111111*/ ]; var numberOfOnes = function(aNumber)