2007-01-01 21:11:21 +00:00
/ * Copyright ( c ) 2006 -2007 Christopher J . W . Lloyd
2009-11-14 21:23:09 +00:00
2009 Markus Hitter < mah @ jump - ing . de >
2006-12-22 04:41:44 +00:00
Permission is hereby granted , free of charge , to any person obtaining a copy of this software and associated documentation files ( the "Software" ) , to deal in the Software without restriction , including without limitation the rights to use , copy , modify , merge , publish , distribute , sublicense , and / or sell copies of the Software , and to permit persons to whom the Software is furnished to do so , subject to the following conditions :
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE . * /
2007-01-01 21:11:21 +00:00
# import < AppKit / NSAlert . h >
2007-04-29 13:45:20 +00:00
# import < AppKit / NSImage . h >
2009-06-05 03:16:46 +00:00
# import < AppKit / NSRaise . h >
2008-05-13 18:43:48 +00:00
# import < Foundation / NSDictionary . h >
# import < AppKit / NSStringDrawer . h >
# import < AppKit / NSButton . h >
# import < AppKit / NSScreen . h >
# import < AppKit / NSApplication . h >
# import < AppKit / NSPanel . h >
# import < AppKit / NSWindow - Private . h >
# import < AppKit / NSImageView . h >
# import < AppKit / NSTextField . h >
# import < AppKit / NSFont . h >
# import < AppKit / NSAttributedString . h >
2006-12-22 04:41:44 +00:00
2007-01-01 21:11:21 +00:00
@ implementation NSAlert
2006-12-22 04:41:44 +00:00
2008-05-13 18:43:48 +00:00
/ *
NSWarningAlertStyle - app icon
NSInformationalAlertStyle - app icon
NSCriticalAlertStyle - large yellow / ! \ triangle w / small app icon
* /
- init {
_style = NSWarningAlertStyle ;
_icon = [ [ NSImage imageNamed : @ "NSAlertPanelExclamation" ] retain ] ;
2012-01-18 17:55:13 +00:00
_messageText = [ NSLocalizedStringFromTableInBundle ( @ "Alert" , nil , [ NSBundle bundleForClass : [ NSAlert class ] ] , @ "Default message text for NSAlert" ) copy ] ;
2008-05-13 18:43:48 +00:00
_informativeText = @ "" ;
_accessoryView = nil ;
_showsHelp = NO ;
_showsSuppressionButton = NO ;
_helpAnchor = nil ;
_buttons = [ NSMutableArray new ] ;
_window = [ [ NSPanel alloc ] initWithContentRect : NSMakeRect ( 0 , 0 , 10 , 10 ) styleMask : NSTitledWindowMask backing : NSBackingStoreBuffered defer : NO ] ;
2010-10-21 20:42:13 +00:00
_suppressionButton = [ [ NSButton alloc ] init ] ;
// [ _suppressionButton setButtonType : NSSwitchButton ] ;
2012-01-18 17:55:13 +00:00
[ _suppressionButton setTitle : NSLocalizedStringFromTableInBundle ( @ "Do not show this message again" , nil , [ NSBundle bundleForClass : [ NSAlert class ] ] , @ "Default NSAlert supression button title" ) ] ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
return self ;
}
- ( void ) dealloc {
[ _icon release ] ;
[ _messageText release ] ;
[ _informativeText release ] ;
[ _accessoryView release ] ;
[ _helpAnchor release ] ;
[ _buttons release ] ;
2010-10-21 20:42:13 +00:00
[ _suppressionButton release ] ;
2008-05-13 18:43:48 +00:00
[ _window release ] ;
[ super dealloc ] ;
}
2007-04-29 13:45:20 +00:00
+ ( NSAlert * ) alertWithError : ( NSError * ) error {
2008-05-13 18:43:48 +00:00
NSArray * titles = [ error localizedRecoveryOptions ] ;
NSString * defaultTitle = ( [ titles count ] > 0 ) ? [ titles objectAtIndex : 0 ] : nil ;
NSString * alternateTitle = ( [ titles count ] > 1 ) ? [ titles objectAtIndex : 1 ] : nil ;
NSString * otherTitle = ( [ titles count ] > 2 ) ? [ titles objectAtIndex : 2 ] : nil ;
NSAlert * result = [ [ [ self alloc ] init ] autorelease ] ;
[ result setMessageText : [ error localizedDescription ] ] ;
[ result setInformativeText : [ error localizedRecoverySuggestion ] ] ;
int i , count = [ titles count ] ;
for ( i = 0 ; i < count ; i + + )
[ result addButtonWithTitle : [ titles objectAtIndex : i ] ] ;
return result ;
2007-04-29 13:45:20 +00:00
}
+ ( NSAlert * ) alertWithMessageText : ( NSString * ) messageText defaultButton : ( NSString * ) defaultTitle alternateButton : ( NSString * ) alternateTitle otherButton : ( NSString * ) otherTitle informativeTextWithFormat : ( NSString * ) format , . . . {
2008-05-13 18:43:48 +00:00
va_list arguments ;
NSString * informativeText ;
va_start ( arguments , format ) ;
informativeText = [ [ [ NSString alloc ] initWithFormat : format arguments : arguments ] autorelease ] ;
NSAlert * result = [ [ [ self alloc ] init ] autorelease ] ;
[ result setMessageText : messageText ] ;
[ result setInformativeText : informativeText ] ;
if ( defaultTitle = = nil )
2012-01-18 17:55:13 +00:00
defaultTitle = NSLocalizedStringFromTableInBundle ( @ "OK" , nil , [ NSBundle bundleForClass : [ NSAlert class ] ] , @ "Default button title for NSAlert" ) ;
2008-05-13 18:43:48 +00:00
[ result addButtonWithTitle : defaultTitle ] ;
if ( alternateTitle ! = nil )
[ result addButtonWithTitle : alternateTitle ] ;
if ( otherTitle ! = nil )
[ result addButtonWithTitle : otherTitle ] ;
return result ;
2007-04-29 13:45:20 +00:00
}
2008-05-13 18:43:48 +00:00
2007-04-29 13:45:20 +00:00
- delegate {
return _delegate ;
}
- ( NSAlertStyle ) alertStyle {
return _style ;
}
- ( NSImage * ) icon {
return _icon ;
}
- ( NSString * ) messageText {
return _messageText ;
}
- ( NSString * ) informativeText {
return _informativeText ;
}
2008-05-13 18:43:48 +00:00
- ( NSView * ) accessoryView {
return _accessoryView ;
}
2007-04-29 13:45:20 +00:00
- ( BOOL ) showsHelp {
return _showsHelp ;
}
2008-05-13 18:43:48 +00:00
- ( BOOL ) showsSuppressionButton {
return _showsSuppressionButton ;
}
2007-04-29 13:45:20 +00:00
- ( NSString * ) helpAnchor {
return _helpAnchor ;
}
- ( NSArray * ) buttons {
return _buttons ;
}
2010-10-21 20:42:13 +00:00
- ( NSButton * ) suppressionButton {
return _suppressionButton ;
2008-05-13 18:43:48 +00:00
}
2007-04-29 13:45:20 +00:00
- window {
return _window ;
}
- ( void ) setDelegate : delegate {
_delegate = delegate ;
}
- ( void ) setAlertStyle : ( NSAlertStyle ) style {
_style = style ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
2007-04-29 13:45:20 +00:00
}
- ( void ) setIcon : ( NSImage * ) icon {
icon = [ icon copy ] ;
[ _icon release ] ;
_icon = icon ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
2007-04-29 13:45:20 +00:00
}
- ( void ) setMessageText : ( NSString * ) string {
string = [ string copy ] ;
[ _messageText release ] ;
_messageText = string ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
2007-04-29 13:45:20 +00:00
}
- ( void ) setInformativeText : ( NSString * ) string {
string = [ string copy ] ;
[ _informativeText release ] ;
_informativeText = string ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
}
- ( void ) setAccessoryView : ( NSView * ) value {
value = [ value retain ] ;
2012-03-23 06:00:46 +00:00
[ _accessoryView removeFromSuperview ] ;
2008-05-13 18:43:48 +00:00
[ _accessoryView release ] ;
_accessoryView = value ;
2012-03-23 06:00:46 +00:00
// We must add it as a subview here such that a makeFirstResponder : immediately after
// works properly by setting up the field editor
[ [ _window contentView ] addSubview : _accessoryView ] ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
2007-04-29 13:45:20 +00:00
}
- ( void ) setShowsHelp : ( BOOL ) flag {
_showsHelp = flag ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
}
- ( void ) setShowsSuppressionButton : ( BOOL ) value {
_showsSuppressionButton = value ;
_needsLayout = YES ;
2007-04-29 13:45:20 +00:00
}
- ( void ) setHelpAnchor : ( NSString * ) anchor {
anchor = [ anchor copy ] ;
[ _helpAnchor release ] ;
_helpAnchor = anchor ;
2008-05-13 18:43:48 +00:00
_needsLayout = YES ;
2007-04-29 13:45:20 +00:00
}
- ( NSButton * ) addButtonWithTitle : ( NSString * ) title {
2008-05-13 18:43:48 +00:00
NSButton * result = [ [ NSButton alloc ] init ] ;
[ result setTitle : title ] ;
[ result setTarget : self ] ;
[ result setAction : @ selector ( _alertButton : ) ] ;
[ result setTag : NSAlertFirstButtonReturn + [ _buttons count ] ] ;
[ _buttons addObject : result ] ;
_needsLayout = YES ;
return result ;
}
- ( void ) layout {
# define BOTTOM_MARGIN 16
# define TOP_MARGIN 16
# define LEFT_MARGIN 16
# define RIGHT_MARGIN 16
2009-11-14 21:23:09 +00:00
// A NSTextField adds a small margin around the text .
# define TEXTFIELD_MARGIN 2.
# define INTERTEXT_GAP 8.
2008-05-13 18:43:48 +00:00
# define BUTTON_MARGIN 8
# define INTERBUTTON_GAP 6
# define OTHER_GAP 20
# define ICON_MAIN _GAP 20
# define MAIN_BUTTON _GAP 20
2009-11-14 21:23:09 +00:00
NSSize screenSize = [ [ NSScreen mainScreen ] visibleFrame ] . size ;
NSSize textSize = NSZeroSize ;
NSStringDrawer * drawer = [ NSStringDrawer sharedStringDrawer ] ;
2008-05-13 18:43:48 +00:00
NSSize iconSize = ( _icon ! = nil ) ? [ _icon size ] : NSZeroSize ;
NSDictionary * messageAttributes = [ NSDictionary dictionaryWithObjectsAndKeys : [ NSFont boldSystemFontOfSize : 0 ] , NSFontAttributeName , nil ] ;
2009-11-14 21:23:09 +00:00
NSSize messageSize = NSZeroSize ;
2008-05-13 18:43:48 +00:00
NSDictionary * informativeAttributes = [ NSDictionary dictionaryWithObjectsAndKeys : [ NSFont systemFontOfSize : 0 ] , NSFontAttributeName , nil ] ;
2009-11-14 21:23:09 +00:00
NSSize informativeSize = NSZeroSize ;
2018-09-09 19:47:18 +00:00
CGFloat messageInformativeGap = 0. ;
2008-05-13 18:43:48 +00:00
NSDictionary * suppressionAttributes = [ NSDictionary dictionaryWithObjectsAndKeys : [ NSFont systemFontOfSize : 0 ] , NSFontAttributeName , nil ] ;
2009-11-14 21:23:09 +00:00
NSSize supressionSize = NSZeroSize ;
2018-09-09 19:47:18 +00:00
CGFloat informativeSuppressionGap = 0. ;
2008-05-13 18:43:48 +00:00
NSSize accessorySize = ( _accessoryView ! = nil ) ? [ _accessoryView frame ] . size : NSZeroSize ;
2018-09-09 19:47:18 +00:00
CGFloat suppressionAccessoryGap = 0. ;
2008-05-13 18:43:48 +00:00
NSSize mainSize = NSZeroSize ;
NSSize panelSize = NSZeroSize ;
int i , count = [ _buttons count ] ;
2009-11-14 21:23:09 +00:00
NSSize okCancelButtonSize = NSMakeSize ( 40 , 24 ) ;
NSSize otherButtonSize = okCancelButtonSize ;
NSSize allButtonsSize = NSZeroSize ;
// Size the buttons .
2008-05-13 18:43:48 +00:00
for ( i = 0 ; i < count && i < 2 ; i + + ) {
NSButton * check = [ _buttons objectAtIndex : i ] ;
NSAttributedString * title = [ check attributedTitle ] ;
2009-11-14 21:23:09 +00:00
NSSize size = [ drawer sizeOfAttributedString : title inSize : NSZeroSize ] ;
okCancelButtonSize . width = MAX ( size . width + BUTTON_MARGIN * 2 , okCancelButtonSize . width ) ;
okCancelButtonSize . height = MAX ( size . height , okCancelButtonSize . height ) ;
2008-05-13 18:43:48 +00:00
}
2009-11-14 21:23:09 +00:00
2008-05-13 18:43:48 +00:00
for ( i = 0 ; i < count && i < 2 ; i + + )
2009-11-14 21:23:09 +00:00
[ [ _buttons objectAtIndex : i ] setFrameSize : okCancelButtonSize ] ;
2008-05-13 18:43:48 +00:00
for ( i = 2 ; i < count ; i + + ) {
NSButton * check = [ _buttons objectAtIndex : i ] ;
NSAttributedString * title = [ check attributedTitle ] ;
2009-11-14 21:23:09 +00:00
NSSize size = [ drawer sizeOfAttributedString : title inSize : NSZeroSize ] ;
otherButtonSize . width = MAX ( size . width + BUTTON_MARGIN * 2 , otherButtonSize . width ) ;
otherButtonSize . height = MAX ( size . height , otherButtonSize . height ) ;
2008-05-13 18:43:48 +00:00
}
2009-11-14 21:23:09 +00:00
for ( i = 2 ; i < count ; i + + )
[ [ _buttons objectAtIndex : i ] setFrameSize : otherButtonSize ] ;
for ( i = 0 ; i < count ; i + + ) {
NSButton * button = [ _buttons objectAtIndex : i ] ;
allButtonsSize . width + = [ button frame ] . size . width ;
allButtonsSize . height = MAX ( allButtonsSize . height , [ button frame ] . size . height ) ;
allButtonsSize . width + = INTERBUTTON_GAP ;
if ( i = = 1 )
allButtonsSize . width + = OTHER_GAP ;
}
// Size the main reasonable and at least wide enough to make all buttons fit .
mainSize . width = MAX ( screenSize . width / 3. , allButtonsSize . width - iconSize . width - ICON_MAIN _GAP ) ;
mainSize . width = MAX ( mainSize . width , accessorySize . width ) ;
// Size the texts .
textSize = NSMakeSize ( mainSize . width - TEXTFIELD_MARGIN * 2 , NSStringDrawerLargeDimension ) ;
if ( _messageText ! = nil ) {
messageSize = [ drawer sizeOfString : _messageText withAttributes : messageAttributes inSize : textSize ] ;
messageSize . width + = TEXTFIELD_MARGIN * 2 ;
messageSize . height + = TEXTFIELD_MARGIN * 2 ;
}
if ( _informativeText ! = nil ) {
informativeSize = [ drawer sizeOfString : _informativeText withAttributes : informativeAttributes inSize : textSize ] ;
informativeSize . width + = TEXTFIELD_MARGIN * 2 ;
informativeSize . height + = TEXTFIELD_MARGIN * 2 ;
}
if ( _messageText ! = nil && _informativeText ! = nil )
messageInformativeGap = INTERTEXT_GAP ;
if ( _showsSuppressionButton )
2010-10-21 20:42:13 +00:00
supressionSize = [ drawer sizeOfString : [ _suppressionButton title ] withAttributes : suppressionAttributes inSize : textSize ] ;
2009-11-14 21:23:09 +00:00
if ( _informativeText ! = nil && _showsSuppressionButton )
informativeSuppressionGap = INTERTEXT_GAP ;
if ( _showsSuppressionButton && _accessoryView ! = nil )
suppressionAccessoryGap = INTERTEXT_GAP ;
// Now we can size the heights as well .
mainSize . height = messageSize . height + informativeSize . height + messageInformativeGap + supressionSize . height + informativeSuppressionGap + accessorySize . height + suppressionAccessoryGap ;
panelSize . width = LEFT_MARGIN + mainSize . width + iconSize . width + ICON_MAIN _GAP + RIGHT_MARGIN ;
panelSize . height = TOP_MARGIN + MAX ( mainSize . height , iconSize . height ) + MAIN_BUTTON _GAP + allButtonsSize . height + BOTTOM_MARGIN ;
2008-05-13 18:43:48 +00:00
if ( _icon ! = nil ) {
NSRect frame ;
NSImageView * imageView ;
frame . origin . x = LEFT_MARGIN ;
frame . origin . y = panelSize . height - TOP_MARGIN - iconSize . height ;
frame . size = iconSize ;
imageView = [ [ [ NSImageView alloc ] initWithFrame : frame ] autorelease ] ;
[ imageView setImage : _icon ] ;
[ [ _window contentView ] addSubview : imageView ] ;
}
if ( _messageText ! = nil ) {
NSRect frame ;
NSTextField * textField ;
frame . origin . x = LEFT_MARGIN + iconSize . width + ICON_MAIN _GAP ;
frame . origin . y = panelSize . height - TOP_MARGIN - messageSize . height ;
frame . size = messageSize ;
textField = [ [ [ NSTextField alloc ] initWithFrame : frame ] autorelease ] ;
[ textField setAttributedStringValue : [ [ [ NSAttributedString alloc ] initWithString : _messageText attributes : messageAttributes ] autorelease ] ] ;
2009-06-26 02:18:45 +00:00
[ textField setEditable : NO ] ;
2008-05-13 18:43:48 +00:00
[ textField setSelectable : YES ] ;
[ textField setBordered : NO ] ;
[ [ _window contentView ] addSubview : textField ] ;
}
if ( _informativeText ! = nil ) {
NSRect frame ;
NSTextField * textField ;
frame . origin . x = LEFT_MARGIN + iconSize . width + ICON_MAIN _GAP ;
2009-11-14 21:23:09 +00:00
frame . origin . y = panelSize . height - TOP_MARGIN - messageSize . height - messageInformativeGap - informativeSize . height ;
2008-05-13 18:43:48 +00:00
frame . size = informativeSize ;
textField = [ [ [ NSTextField alloc ] initWithFrame : frame ] autorelease ] ;
[ textField setStringValue : [ [ [ NSAttributedString alloc ] initWithString : _informativeText attributes : informativeAttributes ] autorelease ] ] ;
2009-06-26 02:18:45 +00:00
[ textField setEditable : NO ] ;
2008-05-13 18:43:48 +00:00
[ textField setSelectable : YES ] ;
[ textField setBordered : NO ] ;
[ [ _window contentView ] addSubview : textField ] ;
}
if ( _showsSuppressionButton ) {
NSRect frame ;
frame . origin . x = LEFT_MARGIN + iconSize . width + ICON_MAIN _GAP ;
2009-11-14 21:23:09 +00:00
frame . origin . y = panelSize . height - TOP_MARGIN - messageSize . height - messageInformativeGap - informativeSize . height - informativeSuppressionGap - frame . size . height ;
2008-05-13 18:43:48 +00:00
frame . size = supressionSize ;
2010-10-21 20:42:13 +00:00
[ _suppressionButton setFrame : frame ] ;
[ [ _window contentView ] addSubview : _suppressionButton ] ;
2008-05-13 18:43:48 +00:00
}
if ( _accessoryView ! = nil ) {
NSRect frame = [ _accessoryView frame ] ;
frame . origin . x = LEFT_MARGIN + iconSize . width + ICON_MAIN _GAP ;
2009-11-14 21:23:09 +00:00
frame . origin . y = panelSize . height - TOP_MARGIN - messageSize . height - messageInformativeGap - informativeSize . height - informativeSuppressionGap - supressionSize . height - suppressionAccessoryGap - frame . size . height ;
2008-05-13 18:43:48 +00:00
[ _accessoryView setFrame : frame ] ;
}
NSPoint origin = { panelSize . width - RIGHT_MARGIN , BOTTOM_MARGIN } ;
for ( i = 0 ; i < count ; i + + ) {
NSButton * button = [ _buttons objectAtIndex : i ] ;
NSSize bSize = [ button frame ] . size ;
origin . x - = bSize . width ;
[ button setFrameOrigin : origin ] ;
origin . x - = INTERBUTTON_GAP ;
if ( i = = 1 )
origin . x - = OTHER_GAP ;
[ [ _window contentView ] addSubview : button ] ;
}
NSRect contentRect = { { 0 , 0 } , panelSize } ;
NSRect frame = [ _window frameRectForContentRect : contentRect ] ;
2011-11-28 20:22:47 +00:00
// This stops the platform window from trying to impose a different size on us
// Which for some reason it wants to do .
[ _window setMinSize : frame . size ] ;
[ _window setMaxSize : frame . size ] ;
2008-05-13 18:43:48 +00:00
[ _window setFrame : frame display : NO ] ;
_needsLayout = NO ;
}
- ( void ) layoutIfNeeded {
// This isn ' t an optimization per se , it is to prevent relayout after a manual layout
if ( _needsLayout ) {
if ( [ _buttons count ] = = 0 ) {
2012-01-18 17:55:13 +00:00
[ self addButtonWithTitle : NSLocalizedStringFromTableInBundle ( @ "OK" , nil , [ NSBundle bundleForClass : [ NSAlert class ] ] , @ "Default button title for NSAlert" ) ] ;
2008-05-13 18:43:48 +00:00
}
[ self layout ] ;
}
}
- ( void ) sheetDidEnd : ( NSWindow * ) sheet returnCode : ( int ) returnCode contextInfo : ( void * ) contextInfo {
typedef void (*alertDidEnd)(id,SEL,NSAlert *,int,void *) ;
2009-08-19 03:22:47 +00:00
if ( _sheetDidEnd ) {
alertDidEnd endFunction = ( alertDidEnd ) [ _sheetDelegate methodForSelector : _sheetDidEnd ] ;
2008-05-13 18:43:48 +00:00
2009-08-19 03:22:47 +00:00
endFunction ( _sheetDelegate , _sheetDidEnd , self , returnCode , contextInfo ) ;
}
2009-06-26 02:18:45 +00:00
[ self release ] ;
2007-04-29 13:45:20 +00:00
}
- ( void ) beginSheetModalForWindow : ( NSWindow * ) window modalDelegate : delegate didEndSelector : ( SEL ) selector contextInfo : ( void * ) info {
2010-01-08 01:48:11 +00:00
[ _window setStyleMask : NSDocModalWindowMask ] ;
2008-05-13 18:43:48 +00:00
[ self layoutIfNeeded ] ;
2009-06-26 02:18:45 +00:00
[ _window setDefaultButtonCell : [ [ _buttons objectAtIndex : 0 ] cell ] ] ;
2008-05-13 18:43:48 +00:00
_sheetDelegate = delegate ;
_sheetDidEnd = selector ;
2009-06-26 02:18:45 +00:00
[ self retain ] ;
2008-05-13 18:43:48 +00:00
[ NSApp beginSheet : _window modalForWindow : window modalDelegate : self didEndSelector : @ selector ( sheetDidEnd : returnCode : contextInfo : ) contextInfo : info ] ;
2007-04-29 13:45:20 +00:00
}
2008-05-13 18:43:48 +00:00
- ( NSInteger ) runModal {
2011-11-28 20:22:47 +00:00
[ _window setLevel : NSModalPanelWindowLevel ] ;
2010-01-08 01:48:11 +00:00
[ _window setStyleMask : NSTitledWindowMask ] ;
2008-05-13 18:43:48 +00:00
[ self layoutIfNeeded ] ;
2009-06-26 02:18:45 +00:00
[ _window setDefaultButtonCell : [ [ _buttons objectAtIndex : 0 ] cell ] ] ;
2008-05-13 18:43:48 +00:00
return [ NSApp runModalForWindow : _window ] ;
}
- ( void ) _alertButton : sender {
if ( [ _window isSheet ] )
[ NSApp endSheet : _window returnCode : [ sender tag ] ] ;
else
[ NSApp stopModalWithCode : [ sender tag ] ] ;
2010-10-21 20:42:13 +00:00
2010-09-17 18:46:17 +00:00
[ _window close ] ;
}
2007-04-29 13:45:20 +00:00
2006-12-22 04:41:44 +00:00
@ end