mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 14:50:38 +00:00
Implemented coding for NSPanel. For GSAlertPanel reoranised the
initXXX code. Moved the GModel methods into a separate category, removing [createObjectForModelUnarchiver:] as this was (incorrectly) duplication code from the super class. Implemented NSBeginAlertSheet(), NSBeginCriticalAlertSheet() and NSBeginInformationalAlertSheet(). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11000 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ccf62d14f7
commit
bce2688968
1 changed files with 235 additions and 182 deletions
417
Source/NSPanel.m
417
Source/NSPanel.m
|
@ -149,7 +149,7 @@ static NSString *defaultTitle = @" ";
|
||||||
|
|
||||||
- (void) setWorksWhenModal: (BOOL)flag
|
- (void) setWorksWhenModal: (BOOL)flag
|
||||||
{
|
{
|
||||||
_worksWhenModal = flag;
|
_worksWhenModal = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) becomesKeyOnlyIfNeeded
|
- (BOOL) becomesKeyOnlyIfNeeded
|
||||||
|
@ -159,7 +159,7 @@ static NSString *defaultTitle = @" ";
|
||||||
|
|
||||||
- (void) setBecomesKeyOnlyIfNeeded: (BOOL)flag
|
- (void) setBecomesKeyOnlyIfNeeded: (BOOL)flag
|
||||||
{
|
{
|
||||||
_becomesKeyOnlyIfNeeded = flag;
|
_becomesKeyOnlyIfNeeded = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -167,12 +167,28 @@ static NSString *defaultTitle = @" ";
|
||||||
*/
|
*/
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
|
BOOL flag;
|
||||||
|
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
flag = _becomesKeyOnlyIfNeeded;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _isFloatingPanel;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
flag = _worksWhenModal;
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
|
BOOL flag;
|
||||||
|
|
||||||
[super initWithCoder: aDecoder];
|
[super initWithCoder: aDecoder];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
[self setBecomesKeyOnlyIfNeeded: flag];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
[self setFloatingPanel: flag];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||||
|
[self setWorksWhenModal: flag];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +304,6 @@ static NSString *defaultTitle = @" ";
|
||||||
static GSAlertPanel *standardAlertPanel = nil;
|
static GSAlertPanel *standardAlertPanel = nil;
|
||||||
static GSAlertPanel *informationalAlertPanel = nil;
|
static GSAlertPanel *informationalAlertPanel = nil;
|
||||||
static GSAlertPanel *criticalAlertPanel = nil;
|
static GSAlertPanel *criticalAlertPanel = nil;
|
||||||
static GSAlertPanel *gmodelAlertPanel = nil;
|
|
||||||
|
|
||||||
@interface GSAlertPanel: NSPanel
|
@interface GSAlertPanel: NSPanel
|
||||||
{
|
{
|
||||||
|
@ -301,15 +316,9 @@ static GSAlertPanel *gmodelAlertPanel = nil;
|
||||||
NSScrollView *scroll;
|
NSScrollView *scroll;
|
||||||
int result;
|
int result;
|
||||||
BOOL isGreen; // we were unarchived and not resized.
|
BOOL isGreen; // we were unarchived and not resized.
|
||||||
//PJB: I removed the active flag. Please see the isActivePanel method below.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithContentRect: (NSRect)r
|
- (id) _initWithoutGModel;
|
||||||
styleMask: (unsigned)m
|
|
||||||
backing: (NSBackingStoreType)b
|
|
||||||
defer: (BOOL)d
|
|
||||||
screen: (NSScreen*)s;
|
|
||||||
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver;
|
|
||||||
- (int) runModal;
|
- (int) runModal;
|
||||||
- (void) setTitle: (NSString*)title
|
- (void) setTitle: (NSString*)title
|
||||||
message: (NSString*)message
|
message: (NSString*)message
|
||||||
|
@ -358,16 +367,16 @@ static const float ButtonMinWidth = 72.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id) createObjectForModelUnarchiver: (GMUnarchiver*)unarchiver
|
- (id) init
|
||||||
{
|
{
|
||||||
unsigned backingType = [unarchiver decodeUnsignedIntWithName:
|
/*
|
||||||
@"backingType"];
|
if (![NSBundle loadNibNamed: @"AlertPanel" owner: self])
|
||||||
unsigned styleMask = [unarchiver decodeUnsignedIntWithName: @"styleMask"];
|
{
|
||||||
NSRect aRect = [unarchiver decodeRectWithName: @"frame"];
|
NSLog(@"cannot open alert panel model file\n");
|
||||||
NSPanel* panel = AUTORELEASE([[GSAlertPanel allocWithZone:
|
return nil;
|
||||||
[unarchiver objectZone]] initWithContentRect: aRect
|
}
|
||||||
styleMask: styleMask backing: backingType defer: YES]);
|
*/
|
||||||
return panel;
|
return [self _initWithoutGModel];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
@ -394,18 +403,6 @@ static const float ButtonMinWidth = 72.0;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) encodeWithModelArchiver: (GMArchiver*)archiver
|
|
||||||
{
|
|
||||||
[super encodeWithModelArchiver: archiver];
|
|
||||||
[archiver encodeSize: [self frame].size withName: @"OriginalSize"];
|
|
||||||
[archiver encodeObject: defButton withName: @"DefaultButton"];
|
|
||||||
[archiver encodeObject: altButton withName: @"AlternateButton"];
|
|
||||||
[archiver encodeObject: othButton withName: @"OtherButton"];
|
|
||||||
[archiver encodeObject: icoButton withName: @"IconButton"];
|
|
||||||
[archiver encodeObject: messageField withName: @"MessageField"];
|
|
||||||
[archiver encodeObject: titleField withName: @"TitleField"];
|
|
||||||
}
|
|
||||||
|
|
||||||
static NSScrollView*
|
static NSScrollView*
|
||||||
makeScrollViewWithRect(NSRect rect)
|
makeScrollViewWithRect(NSRect rect)
|
||||||
{
|
{
|
||||||
|
@ -422,7 +419,6 @@ makeScrollViewWithRect(NSRect rect)
|
||||||
return scroll;
|
return scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSButton*) _makeButtonWithRect: (NSRect)rect
|
- (NSButton*) _makeButtonWithRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
NSButton *button = [[NSButton alloc] initWithFrame: rect];
|
NSButton *button = [[NSButton alloc] initWithFrame: rect];
|
||||||
|
@ -463,134 +459,108 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithContentRect: (NSRect)r
|
- (id) _initWithoutGModel
|
||||||
styleMask: (unsigned)m
|
|
||||||
backing: (NSBackingStoreType)b
|
|
||||||
defer: (BOOL)d
|
|
||||||
screen: (NSScreen*)s
|
|
||||||
{
|
{
|
||||||
self = [super initWithContentRect: r
|
NSRect rect;
|
||||||
styleMask: m
|
NSImage *image;
|
||||||
backing: b
|
NSBox *box;
|
||||||
defer: d
|
NSView *content;
|
||||||
screen: s];
|
NSRect r = NSMakeRect(0.0, 0.0, WinMinWidth, WinMinHeight);
|
||||||
if (self != nil)
|
|
||||||
{
|
|
||||||
NSRect rect;
|
|
||||||
NSImage *image;
|
|
||||||
NSBox *box;
|
|
||||||
NSView *content = [self contentView];
|
|
||||||
|
|
||||||
[self setTitle: @" "];
|
self = [self initWithContentRect: r
|
||||||
|
styleMask: NSTitledWindowMask
|
||||||
|
backing: NSBackingStoreRetained
|
||||||
|
defer: YES
|
||||||
|
screen: nil];
|
||||||
|
|
||||||
// we're an ATTENTION panel, therefore:
|
if (self == nil)
|
||||||
[self setHidesOnDeactivate: NO];
|
return nil;
|
||||||
[self setBecomesKeyOnlyIfNeeded: NO];
|
|
||||||
|
|
||||||
// First, the subviews that will be positioned automatically.
|
[self setTitle: @" "];
|
||||||
rect.size.height = IconSide;
|
content = [self contentView];
|
||||||
rect.size.width = IconSide;
|
|
||||||
rect.origin.y = r.origin.y + r.size.height + IconBottom;
|
// we're an ATTENTION panel, therefore:
|
||||||
rect.origin.x = IconLeft;
|
[self setHidesOnDeactivate: NO];
|
||||||
icoButton = [[NSButton alloc] initWithFrame: rect];
|
[self setBecomesKeyOnlyIfNeeded: NO];
|
||||||
[icoButton setAutoresizingMask: NSViewMaxXMargin|NSViewMinYMargin];
|
|
||||||
[icoButton setBordered: NO];
|
// First, the subviews that will be positioned automatically.
|
||||||
[icoButton setEnabled: NO];
|
rect.size.height = IconSide;
|
||||||
[icoButton setImagePosition: NSImageOnly];
|
rect.size.width = IconSide;
|
||||||
image = [[NSApplication sharedApplication] applicationIconImage];
|
rect.origin.y = r.origin.y + r.size.height + IconBottom;
|
||||||
[icoButton setImage: image];
|
rect.origin.x = IconLeft;
|
||||||
[content addSubview: icoButton];
|
icoButton = [[NSButton alloc] initWithFrame: rect];
|
||||||
|
[icoButton setAutoresizingMask: NSViewMaxXMargin|NSViewMinYMargin];
|
||||||
|
[icoButton setBordered: NO];
|
||||||
|
[icoButton setEnabled: NO];
|
||||||
|
[icoButton setImagePosition: NSImageOnly];
|
||||||
|
image = [[NSApplication sharedApplication] applicationIconImage];
|
||||||
|
[icoButton setImage: image];
|
||||||
|
[content addSubview: icoButton];
|
||||||
|
|
||||||
|
rect.size.height = 20.0; // will be sized to fit anyway.
|
||||||
|
rect.size.width = 80.0; // will be sized to fit anyway.
|
||||||
|
rect.origin.y = r.origin.y + r.size.height + IconBottom;
|
||||||
|
rect.origin.x = TitleLeft;
|
||||||
|
titleField = [[NSTextField alloc] initWithFrame: rect];
|
||||||
|
[titleField setAutoresizingMask: NSViewMinYMargin];
|
||||||
|
[titleField setEditable: NO];
|
||||||
|
[titleField setSelectable: YES];
|
||||||
|
[titleField setBezeled: NO];
|
||||||
|
[titleField setDrawsBackground: NO];
|
||||||
|
[titleField setStringValue: @""];
|
||||||
|
[titleField setFont: [NSFont systemFontOfSize: 18.0]];
|
||||||
|
|
||||||
|
rect.size.height = LineHeight;
|
||||||
|
rect.size.width = r.size.width;
|
||||||
|
rect.origin.y = r.origin.y + r.size.height + LineBottom;
|
||||||
|
rect.origin.x = LineLeft;
|
||||||
|
box = [[NSBox alloc] initWithFrame: rect];
|
||||||
|
[box setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||||
|
[box setTitlePosition: NSNoTitle];
|
||||||
|
[box setBorderType: NSGrooveBorder];
|
||||||
|
[content addSubview: box];
|
||||||
|
RELEASE(box);
|
||||||
|
|
||||||
|
// Then, make the subviews that'll be sized by sizePanelToFit;
|
||||||
|
rect.size.height = 20.0;
|
||||||
|
rect.size.width = 80.0;
|
||||||
|
rect.origin.y = 0.0;
|
||||||
|
rect.origin.x = 0.0;
|
||||||
|
|
||||||
|
messageField = [[NSTextField alloc] initWithFrame: rect];
|
||||||
|
[messageField setEditable: NO];
|
||||||
|
[messageField setSelectable: YES];
|
||||||
|
/*
|
||||||
|
PJB:
|
||||||
|
How do you want the user to report an error message if it is
|
||||||
|
not selectable? Any text visible on the screen should always
|
||||||
|
be selectable for a copy-and-paste. Hence, setSelectable: YES.
|
||||||
|
*/
|
||||||
|
[messageField setBezeled: NO];
|
||||||
|
[messageField setDrawsBackground: YES];
|
||||||
|
[messageField setBackgroundColor: [NSColor lightGrayColor]];
|
||||||
|
[messageField setAlignment: NSCenterTextAlignment];
|
||||||
|
[messageField setStringValue: @""];
|
||||||
|
[messageField setFont: MessageFont];
|
||||||
|
|
||||||
|
defButton = [self _makeButtonWithRect: rect];
|
||||||
|
[defButton setKeyEquivalent: @"\r"];
|
||||||
|
[defButton setImagePosition: NSImageRight];
|
||||||
|
[defButton setImage: [NSImage imageNamed: @"common_ret"]];
|
||||||
|
[defButton setAlternateImage: [NSImage imageNamed: @"common_retH"]];
|
||||||
|
|
||||||
|
altButton = [self _makeButtonWithRect: rect];
|
||||||
|
othButton = [self _makeButtonWithRect: rect];
|
||||||
|
|
||||||
|
rect.size.height = 80.0;
|
||||||
|
scroll = makeScrollViewWithRect(rect);
|
||||||
|
|
||||||
|
result = NSAlertErrorReturn;
|
||||||
|
isGreen = YES;
|
||||||
|
|
||||||
|
|
||||||
rect.size.height = 20.0; // will be sized to fit anyway.
|
|
||||||
rect.size.width = 80.0; // will be sized to fit anyway.
|
|
||||||
rect.origin.y = r.origin.y + r.size.height + IconBottom;
|
|
||||||
rect.origin.x = TitleLeft;
|
|
||||||
titleField = [[NSTextField alloc] initWithFrame: rect];
|
|
||||||
[titleField setAutoresizingMask: NSViewMinYMargin];
|
|
||||||
[titleField setEditable: NO];
|
|
||||||
[titleField setSelectable: YES];
|
|
||||||
[titleField setBezeled: NO];
|
|
||||||
[titleField setDrawsBackground: NO];
|
|
||||||
[titleField setStringValue: @""];
|
|
||||||
[titleField setFont: [NSFont systemFontOfSize: 18.0]];
|
|
||||||
|
|
||||||
rect.size.height = LineHeight;
|
|
||||||
rect.size.width = r.size.width;
|
|
||||||
rect.origin.y = r.origin.y + r.size.height + LineBottom;
|
|
||||||
rect.origin.x = LineLeft;
|
|
||||||
box = [[NSBox alloc] initWithFrame: rect];
|
|
||||||
[box setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
|
||||||
[box setTitlePosition: NSNoTitle];
|
|
||||||
[box setBorderType: NSGrooveBorder];
|
|
||||||
[content addSubview: box];
|
|
||||||
RELEASE(box);
|
|
||||||
|
|
||||||
// Then, make the subviews that'll be sized by sizePanelToFit;
|
|
||||||
|
|
||||||
rect.size.height = 20.0;
|
|
||||||
rect.size.width = 80.0;
|
|
||||||
rect.origin.y = 0.0;
|
|
||||||
rect.origin.x = 0.0;
|
|
||||||
|
|
||||||
messageField = [[NSTextField alloc] initWithFrame: rect];
|
|
||||||
[messageField setEditable: NO];
|
|
||||||
[messageField setSelectable: YES];
|
|
||||||
/*
|
|
||||||
PJB:
|
|
||||||
How do you want the user to report an error message if it is
|
|
||||||
not selectable? Any text visible on the screen should always
|
|
||||||
be selectable for a copy-and-paste. Hence, setSelectable: YES.
|
|
||||||
*/
|
|
||||||
[messageField setBezeled: NO];
|
|
||||||
[messageField setDrawsBackground: YES];
|
|
||||||
[messageField setBackgroundColor: [NSColor lightGrayColor]];
|
|
||||||
[messageField setAlignment: NSCenterTextAlignment];
|
|
||||||
[messageField setStringValue: @""];
|
|
||||||
[messageField setFont: MessageFont];
|
|
||||||
|
|
||||||
defButton = [self _makeButtonWithRect: rect];
|
|
||||||
[defButton setKeyEquivalent: @"\r"];
|
|
||||||
[defButton setImagePosition: NSImageRight];
|
|
||||||
[defButton setImage: [NSImage imageNamed: @"common_ret"]];
|
|
||||||
[defButton setAlternateImage: [NSImage imageNamed: @"common_retH"]];
|
|
||||||
|
|
||||||
altButton = [self _makeButtonWithRect: rect];
|
|
||||||
othButton = [self _makeButtonWithRect: rect];
|
|
||||||
|
|
||||||
rect.size.height = 80.0;
|
|
||||||
scroll = makeScrollViewWithRect(rect);
|
|
||||||
|
|
||||||
result = NSAlertErrorReturn;
|
|
||||||
isGreen = YES;
|
|
||||||
}
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver
|
|
||||||
{
|
|
||||||
self = [super initWithModelUnarchiver: unarchiver];
|
|
||||||
if (self != nil)
|
|
||||||
{
|
|
||||||
// TODO: Remove the following line when NSPanel archiver method will be implemented.
|
|
||||||
[self setBecomesKeyOnlyIfNeeded: NO];
|
|
||||||
|
|
||||||
(void)[unarchiver decodeSizeWithName: @"OriginalSize"];
|
|
||||||
defButton = RETAIN([unarchiver decodeObjectWithName: @"DefaultButton"]);
|
|
||||||
altButton = RETAIN([unarchiver decodeObjectWithName: @"AlternateButton"]);
|
|
||||||
othButton = RETAIN([unarchiver decodeObjectWithName: @"OtherButton"]);
|
|
||||||
icoButton = RETAIN([unarchiver decodeObjectWithName: @"IconButton"]);
|
|
||||||
messageField = RETAIN([unarchiver decodeObjectWithName: @"MessageField"]);
|
|
||||||
titleField = RETAIN([unarchiver decodeObjectWithName: @"TitleField"]);
|
|
||||||
scroll = makeScrollViewWithRect(NSMakeRect(0.0, 0.0, 80.0, 80.0));
|
|
||||||
result = NSAlertErrorReturn;
|
|
||||||
isGreen = YES;
|
|
||||||
}
|
|
||||||
gmodelAlertPanel = self;
|
|
||||||
return gmodelAlertPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) sizePanelToFit
|
- (void) sizePanelToFit
|
||||||
{
|
{
|
||||||
NSRect bounds;
|
NSRect bounds;
|
||||||
|
@ -853,7 +823,7 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
NSLog(@"alert panel buttonAction: from unknown sender - x%x\n",
|
NSLog(@"alert panel buttonAction: from unknown sender - x%x\n",
|
||||||
(unsigned)sender);
|
(unsigned)sender);
|
||||||
}
|
}
|
||||||
[[NSApplication sharedApplication] stopModal];
|
[NSApp stopModalWithCode: result];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) result
|
- (int) result
|
||||||
|
@ -863,7 +833,7 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
|
|
||||||
- (BOOL) isActivePanel
|
- (BOOL) isActivePanel
|
||||||
{
|
{
|
||||||
return [[NSApplication sharedApplication]modalWindow] == self;
|
return [NSApp modalWindow] == self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) runModal
|
- (int) runModal
|
||||||
|
@ -872,6 +842,7 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
{
|
{
|
||||||
[self sizePanelToFit];
|
[self sizePanelToFit];
|
||||||
}
|
}
|
||||||
|
|
||||||
[NSApp runModalForWindow: self];
|
[NSApp runModalForWindow: self];
|
||||||
[self orderOut: self];
|
[self orderOut: self];
|
||||||
return result;
|
return result;
|
||||||
|
@ -886,10 +857,13 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
NSView *content = [self contentView];
|
NSView *content = [self contentView];
|
||||||
|
|
||||||
setControl(content, titleField, title);
|
setControl(content, titleField, title);
|
||||||
// TODO: Remove the following line once NSView is corrected.
|
if (useControl(scroll))
|
||||||
[scroll setDocumentView: nil];
|
{
|
||||||
[scroll removeFromSuperview];
|
// TODO: Remove the following line once NSView is corrected.
|
||||||
[messageField removeFromSuperview];
|
[scroll setDocumentView: nil];
|
||||||
|
[scroll removeFromSuperview];
|
||||||
|
[messageField removeFromSuperview];
|
||||||
|
}
|
||||||
setControl(content, messageField, message);
|
setControl(content, messageField, message);
|
||||||
setControl(content, defButton, defaultButton);
|
setControl(content, defButton, defaultButton);
|
||||||
setControl(content, altButton, alternateButton);
|
setControl(content, altButton, alternateButton);
|
||||||
|
@ -961,6 +935,42 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
|
|
||||||
@end /* GSAlertPanel */
|
@end /* GSAlertPanel */
|
||||||
|
|
||||||
|
@implementation GSAlertPanel (GMArchiverMethods)
|
||||||
|
|
||||||
|
// Reuse createObjectForModelUnarchiver: from super class
|
||||||
|
|
||||||
|
- (void) encodeWithModelArchiver: (GMArchiver*)archiver
|
||||||
|
{
|
||||||
|
[super encodeWithModelArchiver: archiver];
|
||||||
|
[archiver encodeSize: [self frame].size withName: @"OriginalSize"];
|
||||||
|
[archiver encodeObject: defButton withName: @"DefaultButton"];
|
||||||
|
[archiver encodeObject: altButton withName: @"AlternateButton"];
|
||||||
|
[archiver encodeObject: othButton withName: @"OtherButton"];
|
||||||
|
[archiver encodeObject: icoButton withName: @"IconButton"];
|
||||||
|
[archiver encodeObject: messageField withName: @"MessageField"];
|
||||||
|
[archiver encodeObject: titleField withName: @"TitleField"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver
|
||||||
|
{
|
||||||
|
self = [super initWithModelUnarchiver: unarchiver];
|
||||||
|
if (self != nil)
|
||||||
|
{
|
||||||
|
(void)[unarchiver decodeSizeWithName: @"OriginalSize"];
|
||||||
|
defButton = RETAIN([unarchiver decodeObjectWithName: @"DefaultButton"]);
|
||||||
|
altButton = RETAIN([unarchiver decodeObjectWithName: @"AlternateButton"]);
|
||||||
|
othButton = RETAIN([unarchiver decodeObjectWithName: @"OtherButton"]);
|
||||||
|
icoButton = RETAIN([unarchiver decodeObjectWithName: @"IconButton"]);
|
||||||
|
messageField = RETAIN([unarchiver decodeObjectWithName: @"MessageField"]);
|
||||||
|
titleField = RETAIN([unarchiver decodeObjectWithName: @"TitleField"]);
|
||||||
|
scroll = makeScrollViewWithRect(NSMakeRect(0.0, 0.0, 80.0, 80.0));
|
||||||
|
result = NSAlertErrorReturn;
|
||||||
|
isGreen = YES;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end /* GSAlertPanel GMArchiverMethods */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These functions may be called "recursively". For example, from a
|
These functions may be called "recursively". For example, from a
|
||||||
|
@ -970,7 +980,7 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
with, but which will be kept for future use.
|
with, but which will be kept for future use.
|
||||||
|
|
||||||
+---------+---------+---------+---------+---------+
|
+---------+---------+---------+---------+---------+
|
||||||
| std != 0 | std act | pan =std | pan=new | std=new |
|
| std !=0 | std act | pan=std | pan=new | std=new |
|
||||||
+---------+---------+---------+---------+---------+
|
+---------+---------+---------+---------+---------+
|
||||||
a: | F | N/A | | X | X |
|
a: | F | N/A | | X | X |
|
||||||
+---------+---------+---------+---------+---------+
|
+---------+---------+---------+---------+---------+
|
||||||
|
@ -981,28 +991,10 @@ setControl(NSView* content, id control, NSString *title)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define NEW_PANEL [[GSAlertPanel alloc] \
|
|
||||||
initWithContentRect: NSMakeRect(0.0, 0.0, WinMinWidth, WinMinHeight) \
|
|
||||||
styleMask: NSTitledWindowMask \
|
|
||||||
backing: NSBackingStoreRetained \
|
|
||||||
defer: YES \
|
|
||||||
screen: nil]
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (![GMModel loadIMFile: @"AlertPanel" owner: [GSAlertPanel alloc]])
|
|
||||||
{
|
|
||||||
NSLog(@"cannot open alert panel model file\n");
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: Check if this discrepancy is wanted and needed.
|
TODO: Check if this discrepancy is wanted and needed.
|
||||||
If not, we could merge these parameters, even
|
If not, we could merge these parameters, even
|
||||||
for the alert panel, setting its window title to "Alert".
|
for the alert panel, setting its window title to "Alert".
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static GSAlertPanel*
|
static GSAlertPanel*
|
||||||
|
@ -1021,7 +1013,7 @@ getSomePanel(
|
||||||
{
|
{
|
||||||
if ([*instance isActivePanel])
|
if ([*instance isActivePanel])
|
||||||
{ // c:
|
{ // c:
|
||||||
panel = NEW_PANEL;
|
panel = [[GSAlertPanel alloc] init];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // b:
|
{ // b:
|
||||||
|
@ -1030,7 +1022,7 @@ getSomePanel(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // a:
|
{ // a:
|
||||||
panel = NEW_PANEL;
|
panel = [[GSAlertPanel alloc] init];
|
||||||
*instance = panel;
|
*instance = panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1266,7 +1258,30 @@ void NSBeginAlertSheet(NSString *title,
|
||||||
void *contextInfo,
|
void *contextInfo,
|
||||||
NSString *msg, ...)
|
NSString *msg, ...)
|
||||||
{
|
{
|
||||||
// TODO
|
va_list ap;
|
||||||
|
NSString *message;
|
||||||
|
GSAlertPanel *panel;
|
||||||
|
|
||||||
|
va_start(ap, msg);
|
||||||
|
message = [NSString stringWithFormat: msg arguments: ap];
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (defaultButton == nil)
|
||||||
|
{
|
||||||
|
defaultButton = @"OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
panel = getSomePanel(&standardAlertPanel, defaultTitle, title, message,
|
||||||
|
defaultButton, alternateButton, otherButton);
|
||||||
|
|
||||||
|
// FIXME: We should also change the button action to call endSheet:
|
||||||
|
[NSApp beginSheet: panel
|
||||||
|
modalForWindow: docWindow
|
||||||
|
modalDelegate: modalDelegate
|
||||||
|
didEndSelector: didEndSelector
|
||||||
|
contextInfo: contextInfo];
|
||||||
|
[panel close];
|
||||||
|
NSReleaseAlertPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSBeginCriticalAlertSheet(NSString *title,
|
void NSBeginCriticalAlertSheet(NSString *title,
|
||||||
|
@ -1280,7 +1295,25 @@ void NSBeginCriticalAlertSheet(NSString *title,
|
||||||
void *contextInfo,
|
void *contextInfo,
|
||||||
NSString *msg, ...)
|
NSString *msg, ...)
|
||||||
{
|
{
|
||||||
// TODO
|
va_list ap;
|
||||||
|
NSString *message;
|
||||||
|
GSAlertPanel *panel;
|
||||||
|
|
||||||
|
va_start(ap, msg);
|
||||||
|
message = [NSString stringWithFormat: msg arguments: ap];
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
panel = getSomePanel(&criticalAlertPanel, @"Critical", title, message,
|
||||||
|
defaultButton, alternateButton, otherButton);
|
||||||
|
|
||||||
|
// FIXME: We should also change the button action to call endSheet:
|
||||||
|
[NSApp beginSheet: panel
|
||||||
|
modalForWindow: docWindow
|
||||||
|
modalDelegate: modalDelegate
|
||||||
|
didEndSelector: didEndSelector
|
||||||
|
contextInfo: contextInfo];
|
||||||
|
[panel close];
|
||||||
|
NSReleaseAlertPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSBeginInformationalAlertSheet(NSString *title,
|
void NSBeginInformationalAlertSheet(NSString *title,
|
||||||
|
@ -1294,6 +1327,26 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
||||||
void *contextInfo,
|
void *contextInfo,
|
||||||
NSString *msg, ...)
|
NSString *msg, ...)
|
||||||
{
|
{
|
||||||
// TODO
|
va_list ap;
|
||||||
|
NSString *message;
|
||||||
|
GSAlertPanel *panel;
|
||||||
|
|
||||||
|
va_start(ap, msg);
|
||||||
|
message = [NSString stringWithFormat: msg arguments: ap];
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
panel = getSomePanel(&informationalAlertPanel,
|
||||||
|
@"Information",
|
||||||
|
title, message,
|
||||||
|
defaultButton, alternateButton, otherButton);
|
||||||
|
|
||||||
|
// FIXME: We should also change the button action to call endSheet:
|
||||||
|
[NSApp beginSheet: panel
|
||||||
|
modalForWindow: docWindow
|
||||||
|
modalDelegate: modalDelegate
|
||||||
|
didEndSelector: didEndSelector
|
||||||
|
contextInfo: contextInfo];
|
||||||
|
[panel close];
|
||||||
|
NSReleaseAlertPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue