mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
* GNUAlertPanel rename to GSAlertPanel (to maintain a common naming style
along the NS* lines within the AppKit public API). Move code to NSPanel as it is conceptually a private panel class for the sake of the public NS* panel functions. * GNUServicesManager.m/.h rename to GSServicesManager (to maintain a common naming style along the NS* lines within the AppKit public API). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3429 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
81abcf1f75
commit
b17663409e
7 changed files with 518 additions and 527 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
<<<<<<< ChangeLog
|
||||
Thu Dec 10 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
|
||||
* GNUAlertPanel rename to GSAlertPanel (to maintain a common naming style
|
||||
along the NS* lines within the AppKit public API). Move code to NSPanel
|
||||
as it is conceptually a private panel class for the sake of the public
|
||||
NS* panel functions.
|
||||
* GNUServicesManager.m/.h rename to GSServicesManager (to maintain a
|
||||
common naming style along the NS* lines within the AppKit public API).
|
||||
Thu Dec 10 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
|
||||
* GNUAlertPanel rename to GSAlertPanel (to maintain a common naming style
|
||||
along the NS* lines within the AppKit public API). Move code to NSPanel
|
||||
as it is conceptually a private panel class for the sake of the public
|
||||
NS* panel functions.
|
||||
* GNUServicesManager.m/.h rename to GSServicesManager (to maintain a
|
||||
common naming style along the NS* lines within the AppKit public API).
|
||||
|
||||
Thu Dec 10 15:03:05 1998 Adam Fedor <fedor@ultra.doc.com>
|
||||
|
||||
* Headers/gnustep/gui/GSContext.h: New backend initialization.
|
||||
|
@ -31,7 +49,7 @@ Thu Dec 10 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
|||
runModalSession: dump all events not for modal window (fixes modal panel
|
||||
button display bug), arrangeInFront: preliminary implemenation.
|
||||
* NSCell.m: Polish.
|
||||
* NSWindow.m: center remove display invocation per 4.2 docs.
|
||||
* NSWindow.m: center method remove display invocation per 4.2 docs.
|
||||
|
||||
Wed Dec 9 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
GNUServicesManager.h
|
||||
GSServicesManager.h
|
||||
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
|||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_GNUServicesManager
|
||||
#define _GNUstep_H_GNUServicesManager
|
||||
#ifndef _GNUstep_H_GSServicesManager
|
||||
#define _GNUstep_H_GSServicesManager
|
||||
|
||||
@class NSApplication;
|
||||
@class NSArray;
|
||||
|
@ -37,7 +37,7 @@
|
|||
@class NSString;
|
||||
@class NSTimer;
|
||||
|
||||
@interface GNUServicesManager : NSObject
|
||||
@interface GSServicesManager : NSObject
|
||||
{
|
||||
NSApplication *application;
|
||||
NSMenu *servicesMenu;
|
||||
|
@ -54,8 +54,8 @@
|
|||
NSMutableDictionary *allServices;
|
||||
NSTimer *timer;
|
||||
}
|
||||
+ (GNUServicesManager*) newWithApplication: (NSApplication*)app;
|
||||
+ (GNUServicesManager*) manager;
|
||||
+ (GSServicesManager*) newWithApplication: (NSApplication*)app;
|
||||
+ (GSServicesManager*) manager;
|
||||
- (void) checkServices;
|
||||
- (void) doService: (NSCell*)item;
|
||||
- (BOOL) hasRegisteredTypes: (NSDictionary*)service;
|
|
@ -1,503 +0,0 @@
|
|||
/*
|
||||
GNUAlertPanel.m
|
||||
|
||||
GNUAlertPanel window class
|
||||
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Date: 1998
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSPanel.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSTextField.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSBox.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSScreen.h>
|
||||
#include <AppKit/IMLoading.h>
|
||||
#include <extensions/GMArchiver.h>
|
||||
|
||||
#define PANX 362.0
|
||||
#define PANY 191.0
|
||||
|
||||
@class GNUAlertPanel;
|
||||
|
||||
static GNUAlertPanel *standardAlertPanel = nil;
|
||||
static GNUAlertPanel *reusableAlertPanel = nil;
|
||||
|
||||
@interface GNUAlertPanel : NSPanel
|
||||
{
|
||||
NSButton *defButton;
|
||||
NSButton *altButton;
|
||||
NSButton *othButton;
|
||||
NSButton *icoButton;
|
||||
NSTextField *messageField;
|
||||
NSTextField *titleField;
|
||||
int result;
|
||||
BOOL active;
|
||||
}
|
||||
- (void) buttonAction: (id)sender;
|
||||
- (int) result;
|
||||
- (int) runModal;
|
||||
- (void) setTitle: (NSString*)title
|
||||
message: (NSString*)message
|
||||
def: (NSString*)defaultButton
|
||||
alt: (NSString*)alternateButton
|
||||
other: (NSString*)otherButton;
|
||||
@end
|
||||
|
||||
@implementation GNUAlertPanel
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [GNUAlertPanel class])
|
||||
[self setVersion:1];
|
||||
}
|
||||
|
||||
- (void) buttonAction: (id)sender
|
||||
{
|
||||
if (active == NO)
|
||||
{
|
||||
NSLog(@"alert panel buttonAction: when not in modal loop\n");
|
||||
return;
|
||||
}
|
||||
else if (sender == defButton)
|
||||
{
|
||||
result = NSAlertDefaultReturn;
|
||||
}
|
||||
else if (sender == altButton)
|
||||
{
|
||||
result = NSAlertAlternateReturn;
|
||||
}
|
||||
else if (sender == othButton)
|
||||
{
|
||||
result = NSAlertOtherReturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"alert panel buttonAction: from unknown sender - x%x\n",
|
||||
(unsigned)sender);
|
||||
}
|
||||
active = NO;
|
||||
[self orderOut: self];
|
||||
[[NSApplication sharedApplication] stopModal];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[defButton release];
|
||||
[altButton release];
|
||||
[othButton release];
|
||||
[icoButton release];
|
||||
[messageField release];
|
||||
[titleField release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) encodeWithModelArchiver: (GMArchiver *)archiver
|
||||
{
|
||||
if (standardAlertPanel)
|
||||
[archiver encodeObject: standardAlertPanel withName: @"AlertPanel"];
|
||||
}
|
||||
|
||||
- (id) initWithContentRect: (NSRect)r
|
||||
styleMask: (unsigned)m
|
||||
backing: (NSBackingStoreType)b
|
||||
defer: (BOOL)d
|
||||
screen: (NSScreen*)s
|
||||
{
|
||||
self = [super initWithContentRect: r
|
||||
styleMask: m
|
||||
backing: b
|
||||
defer: d
|
||||
screen: s];
|
||||
if (self)
|
||||
{
|
||||
NSView *content;
|
||||
unsigned bs = 10.0; /* Inter-button space */
|
||||
unsigned bh = 24.0; /* Button height. */
|
||||
unsigned bw = 72.0; /* Button width. */
|
||||
NSRect rect;
|
||||
NSBox *box;
|
||||
|
||||
[self setMaxSize: r.size];
|
||||
[self setMinSize: r.size];
|
||||
[self setTitle: @" "];
|
||||
|
||||
content = [self contentView];
|
||||
|
||||
rect.size.height = 2.0;
|
||||
rect.size.width = 362.0;
|
||||
rect.origin.y = 95.0;
|
||||
rect.origin.x = 0.0;
|
||||
box = [[NSBox alloc] initWithFrame: rect];
|
||||
[box setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||
[box setTitlePosition: NSNoTitle];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[content addSubview: box];
|
||||
[box release];
|
||||
|
||||
rect.size.height = bh;
|
||||
rect.size.width = bw;
|
||||
rect.origin.y = bs;
|
||||
rect.origin.x = 280.0;
|
||||
defButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[defButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
|
||||
[defButton setButtonType: NSMomentaryPushButton];
|
||||
[defButton setTitle: @"Default"];
|
||||
[defButton setTarget: self];
|
||||
[defButton setAction: @selector(buttonAction:)];
|
||||
[defButton setFont: [NSFont systemFontOfSize: 12.0]];
|
||||
[defButton setKeyEquivalent: @"\r"];
|
||||
[defButton setImagePosition: NSImageRight];
|
||||
[defButton setImage: [NSImage imageNamed: @"common_ret"]];
|
||||
|
||||
rect.origin.x = 199.0;
|
||||
altButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[altButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
|
||||
[altButton setButtonType: NSMomentaryPushButton];
|
||||
[altButton setTitle: @"Alternative"];
|
||||
[altButton setTarget: self];
|
||||
[altButton setAction: @selector(buttonAction:)];
|
||||
[altButton setFont: [NSFont systemFontOfSize: 12.0]];
|
||||
|
||||
rect.origin.x = 120.0;
|
||||
othButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[othButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
|
||||
[othButton setButtonType: NSMomentaryPushButton];
|
||||
[othButton setTitle: @"Other"];
|
||||
[othButton setTarget: self];
|
||||
[othButton setAction: @selector(buttonAction:)];
|
||||
[othButton setFont: [NSFont systemFontOfSize: 12.0]];
|
||||
|
||||
rect.size.height = 48.0;
|
||||
rect.size.width = 48.0;
|
||||
rect.origin.y = 105.0;
|
||||
rect.origin.x = 8.0;
|
||||
icoButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[icoButton setAutoresizingMask: NSViewMaxXMargin | NSViewMinYMargin];
|
||||
[icoButton setBordered: NO];
|
||||
[icoButton setEnabled: NO];
|
||||
[icoButton setImagePosition: NSImageOnly];
|
||||
[icoButton setImage:
|
||||
[[NSApplication sharedApplication] applicationIconImage]];
|
||||
|
||||
rect.size.height = 36.0;
|
||||
rect.size.width = 344.0;
|
||||
rect.origin.y = 46.0;
|
||||
rect.origin.x = 8.0;
|
||||
messageField = [[NSTextField alloc] initWithFrame: rect];
|
||||
[messageField setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable | NSViewMaxYMargin];
|
||||
[messageField setEditable: NO];
|
||||
[messageField setSelectable: NO];
|
||||
[messageField setBordered: NO];
|
||||
[messageField setDrawsBackground: NO];
|
||||
[messageField setStringValue: @""];
|
||||
[messageField setFont: [NSFont systemFontOfSize: 14.0]];
|
||||
|
||||
rect.size.height = 21.0;
|
||||
rect.size.width = 289.0;
|
||||
rect.origin.y = 121.0;
|
||||
rect.origin.x = 64.0;
|
||||
titleField = [[NSTextField alloc] initWithFrame: rect];
|
||||
[titleField setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||
[titleField setEditable: NO];
|
||||
[titleField setSelectable: NO];
|
||||
[titleField setBordered: NO];
|
||||
[titleField setDrawsBackground: NO];
|
||||
[titleField setStringValue: @""];
|
||||
[titleField setFont: [NSFont systemFontOfSize: 18.0]];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver
|
||||
{
|
||||
if (!standardAlertPanel)
|
||||
standardAlertPanel = [unarchiver decodeObjectWithName: @"AlertPanel"];
|
||||
[self release];
|
||||
return standardAlertPanel;
|
||||
}
|
||||
|
||||
- (int) result
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
- (int) runModal
|
||||
{
|
||||
NSApplication *app;
|
||||
|
||||
app = [NSApplication sharedApplication];
|
||||
active = YES;
|
||||
[app runModalForWindow: self];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) setTitle: (NSString*)title
|
||||
message: (NSString*)message
|
||||
def: (NSString*)defaultButton
|
||||
alt: (NSString*)alternateButton
|
||||
other: (NSString*)otherButton
|
||||
{
|
||||
NSView *content = [self contentView];
|
||||
|
||||
if (defaultButton)
|
||||
{
|
||||
[defButton setTitle: defaultButton];
|
||||
if ([defButton superview] == nil)
|
||||
{
|
||||
[content addSubview: defButton];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([defButton superview] != nil)
|
||||
{
|
||||
[defButton removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
if (alternateButton)
|
||||
{
|
||||
[altButton setTitle: alternateButton];
|
||||
if ([altButton superview] == nil)
|
||||
{
|
||||
[content addSubview: altButton];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([altButton superview] != nil)
|
||||
{
|
||||
[altButton removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
if (otherButton)
|
||||
{
|
||||
[othButton setTitle: otherButton];
|
||||
if ([othButton superview] == nil)
|
||||
{
|
||||
[content addSubview: othButton];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([othButton superview] != nil)
|
||||
{
|
||||
[othButton removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
if (message)
|
||||
{
|
||||
[messageField setStringValue: message];
|
||||
if ([messageField superview] == nil)
|
||||
{
|
||||
[content addSubview: messageField];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([messageField superview] != nil)
|
||||
{
|
||||
[messageField removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
if (title)
|
||||
{
|
||||
[titleField setStringValue: title];
|
||||
if ([titleField superview] == nil)
|
||||
{
|
||||
[content addSubview: titleField];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([titleField superview] != nil)
|
||||
{
|
||||
[titleField removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
result = NSAlertErrorReturn; /* If no button was pressed */
|
||||
[content display];
|
||||
|
||||
// [self notImplemented: _cmd];
|
||||
}
|
||||
@end
|
||||
|
||||
id
|
||||
NSGetAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
NSString *message;
|
||||
GNUAlertPanel *panel;
|
||||
|
||||
va_start (ap, otherButton);
|
||||
message = [NSString stringWithFormat: msg arguments: ap];
|
||||
va_end (ap);
|
||||
|
||||
if (title == nil)
|
||||
title = @"Alert";
|
||||
|
||||
if (standardAlertPanel == nil)
|
||||
{
|
||||
#if 0
|
||||
if (![GMModel loadIMFile: @"AlertPanel" owner: [GNUAlertPanel alloc]])
|
||||
{
|
||||
NSLog(@"cannot open alert panel model file\n");
|
||||
return nil;
|
||||
}
|
||||
#else
|
||||
|
||||
panel = [GNUAlertPanel alloc];
|
||||
panel = [panel initWithContentRect:NSMakeRect(0,0,PANX,PANY)
|
||||
styleMask: NSTitledWindowMask
|
||||
backing: NSBackingStoreRetained
|
||||
defer: YES
|
||||
screen: nil];
|
||||
[panel center];
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
panel = standardAlertPanel;
|
||||
standardAlertPanel = nil;
|
||||
}
|
||||
[panel setTitle: title
|
||||
message: message
|
||||
def: defaultButton
|
||||
alt: alternateButton
|
||||
other: otherButton];
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
id
|
||||
NSGetCriticalAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
NSPanel *panel;
|
||||
|
||||
if (title == nil)
|
||||
title = @"Warning";
|
||||
va_start (ap, otherButton);
|
||||
panel = NSGetAlertPanel(title, msg, defaultButton,
|
||||
alternateButton, otherButton, ap);
|
||||
va_end (ap);
|
||||
|
||||
return [panel retain];
|
||||
}
|
||||
|
||||
id
|
||||
NSGetInformationalAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
NSPanel *panel;
|
||||
|
||||
if (title == nil)
|
||||
title = @"Information";
|
||||
va_start (ap, otherButton);
|
||||
panel = NSGetAlertPanel(title, msg, defaultButton,
|
||||
alternateButton, otherButton, ap);
|
||||
va_end (ap);
|
||||
|
||||
return [panel retain];
|
||||
}
|
||||
|
||||
void
|
||||
NSReleaseAlertPanel(id alertPanel)
|
||||
{
|
||||
[alertPanel release];
|
||||
}
|
||||
|
||||
int
|
||||
NSRunAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
GNUAlertPanel *panel;
|
||||
NSString *message;
|
||||
int result;
|
||||
|
||||
if (title == nil)
|
||||
title = @"Alert";
|
||||
if (defaultButton == nil)
|
||||
defaultButton = @"OK";
|
||||
|
||||
va_start (ap, otherButton);
|
||||
message = [NSString stringWithFormat: msg arguments: ap];
|
||||
va_end (ap);
|
||||
|
||||
if (reusableAlertPanel)
|
||||
{
|
||||
panel = reusableAlertPanel;
|
||||
reusableAlertPanel = nil;
|
||||
[panel setTitle: title
|
||||
message: message
|
||||
def: defaultButton
|
||||
alt: alternateButton
|
||||
other: otherButton];
|
||||
}
|
||||
else
|
||||
{
|
||||
panel = NSGetAlertPanel(title, message, defaultButton,
|
||||
alternateButton, otherButton, ap);
|
||||
}
|
||||
|
||||
result = [panel runModal];
|
||||
|
||||
if (reusableAlertPanel == nil)
|
||||
reusableAlertPanel = panel;
|
||||
else
|
||||
NSReleaseAlertPanel(panel);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -106,8 +106,7 @@ NSView.m \
|
|||
NSWindow.m \
|
||||
NSWorkspace.m \
|
||||
GSTrackingRect.m \
|
||||
GNUAlertPanel.m \
|
||||
GNUServicesManager.m \
|
||||
GSServicesManager.m \
|
||||
PSMatrix.m \
|
||||
tiff.m \
|
||||
externs.m
|
||||
|
@ -202,7 +201,7 @@ AppKit/NSWorkspace.h \
|
|||
AppKit/GSTrackingRect.h \
|
||||
AppKit/PSMatrix.h \
|
||||
AppKit/nsimage-tiff.h \
|
||||
AppKit/GNUServicesManager.h \
|
||||
AppKit/GSServicesManager.h \
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
GNUServicesManager.m
|
||||
GSServicesManager.m
|
||||
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
#include <AppKit/NSCell.h>
|
||||
#include <AppKit/NSWorkspace.h>
|
||||
|
||||
#include <AppKit/GNUServicesManager.h>
|
||||
#include <AppKit/GSServicesManager.h>
|
||||
|
||||
#define stringify_it(X) #X
|
||||
#define prog_path(X,Y) \
|
||||
|
@ -222,9 +222,9 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
|||
|
||||
|
||||
|
||||
@implementation GNUServicesManager
|
||||
@implementation GSServicesManager
|
||||
|
||||
static GNUServicesManager *manager = nil;
|
||||
static GSServicesManager *manager = nil;
|
||||
static NSString *servicesName = @".GNUstepServices";
|
||||
static NSString *disabledName = @".GNUstepDisabled";
|
||||
|
||||
|
@ -234,7 +234,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
* provider with the applications name so we can handle incoming
|
||||
* service requests.
|
||||
*/
|
||||
+ (GNUServicesManager*) newWithApplication: (NSApplication*)app
|
||||
+ (GSServicesManager*) newWithApplication: (NSApplication*)app
|
||||
{
|
||||
NSDictionary *env;
|
||||
NSString *str;
|
||||
|
@ -247,7 +247,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
return manager;
|
||||
}
|
||||
|
||||
manager = [GNUServicesManager alloc];
|
||||
manager = [GSServicesManager alloc];
|
||||
|
||||
env = [[NSProcessInfo processInfo] environment];
|
||||
str = [env objectForKey: @"GNUSTEP_USER_ROOT"];
|
||||
|
@ -279,7 +279,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
return manager;
|
||||
}
|
||||
|
||||
+ (GNUServicesManager*) manager
|
||||
+ (GSServicesManager*) manager
|
||||
{
|
||||
if (manager == nil)
|
||||
{
|
||||
|
@ -962,7 +962,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
}
|
||||
}
|
||||
|
||||
@end /* GNUServicesManager */
|
||||
@end /* GSServicesManager */
|
||||
|
||||
|
||||
BOOL
|
||||
|
@ -1081,13 +1081,13 @@ int
|
|||
NSSetShowsServicesMenuItem(NSString *name, BOOL enabled)
|
||||
{
|
||||
|
||||
return [[GNUServicesManager manager] setShowsServicesMenuItem: name
|
||||
return [[GSServicesManager manager] setShowsServicesMenuItem: name
|
||||
to: enabled];
|
||||
}
|
||||
|
||||
BOOL
|
||||
NSShowsServicesMenuItem(NSString * name)
|
||||
{
|
||||
return [[GNUServicesManager manager] showsServicesMenuItem: name];
|
||||
return [[GSServicesManager manager] showsServicesMenuItem: name];
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSMenuItem.h>
|
||||
#include <AppKit/NSCursor.h>
|
||||
#include <AppKit/GNUServicesManager.h>
|
||||
#include <AppKit/GSServicesManager.h>
|
||||
#include <AppKit/IMLoading.h>
|
||||
|
||||
|
||||
|
@ -120,7 +120,7 @@ static NSString *NSAbortModalException = @"NSAbortModalException";
|
|||
|
||||
NSDebugLog(@"Begin of NSApplication -init\n");
|
||||
|
||||
listener = [GNUServicesManager newWithApplication: self];
|
||||
listener = [GSServicesManager newWithApplication: self];
|
||||
window_list = [NSMutableArray new]; // allocate window list
|
||||
window_count = 1;
|
||||
|
||||
|
|
481
Source/NSPanel.m
481
Source/NSPanel.m
|
@ -1,13 +1,18 @@
|
|||
/*
|
||||
NSPanel.m
|
||||
|
||||
Panel window class
|
||||
Panel window class and related functions
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
NSPanel implementation
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
|
||||
GSAlertPanel and alert panel functions implementation
|
||||
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Date: 1998
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
@ -27,11 +32,29 @@
|
|||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
|
||||
#include <AppKit/NSPanel.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSTextField.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSBox.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSScreen.h>
|
||||
#include <AppKit/IMLoading.h>
|
||||
|
||||
#include <extensions/GMArchiver.h>
|
||||
|
||||
|
||||
|
||||
@implementation NSPanel
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NSPanel
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
@implementation NSPanel
|
||||
|
||||
//
|
||||
// Class methods
|
||||
|
@ -84,4 +107,458 @@ int style = NSTitledWindowMask | NSClosableWindowMask;
|
|||
return self;
|
||||
}
|
||||
|
||||
@end /* NSPanel */
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// GSAlertPanel
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#define PANX 362.0
|
||||
#define PANY 191.0
|
||||
|
||||
@class GSAlertPanel;
|
||||
|
||||
static GSAlertPanel *standardAlertPanel = nil;
|
||||
static GSAlertPanel *reusableAlertPanel = nil;
|
||||
|
||||
@interface GSAlertPanel : NSPanel
|
||||
{
|
||||
NSButton *defButton;
|
||||
NSButton *altButton;
|
||||
NSButton *othButton;
|
||||
NSButton *icoButton;
|
||||
NSTextField *messageField;
|
||||
NSTextField *titleField;
|
||||
int result;
|
||||
BOOL active;
|
||||
}
|
||||
- (void) buttonAction: (id)sender;
|
||||
- (int) result;
|
||||
- (int) runModal;
|
||||
- (void) setTitle: (NSString*)title
|
||||
message: (NSString*)message
|
||||
def: (NSString*)defaultButton
|
||||
alt: (NSString*)alternateButton
|
||||
other: (NSString*)otherButton;
|
||||
@end
|
||||
|
||||
@implementation GSAlertPanel
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [GSAlertPanel class])
|
||||
[self setVersion:1];
|
||||
}
|
||||
|
||||
- (void) buttonAction: (id)sender
|
||||
{
|
||||
if (active == NO)
|
||||
{
|
||||
NSLog(@"alert panel buttonAction: when not in modal loop\n");
|
||||
return;
|
||||
}
|
||||
else if (sender == defButton)
|
||||
{
|
||||
result = NSAlertDefaultReturn;
|
||||
}
|
||||
else if (sender == altButton)
|
||||
{
|
||||
result = NSAlertAlternateReturn;
|
||||
}
|
||||
else if (sender == othButton)
|
||||
{
|
||||
result = NSAlertOtherReturn;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"alert panel buttonAction: from unknown sender - x%x\n",
|
||||
(unsigned)sender);
|
||||
}
|
||||
active = NO;
|
||||
[self orderOut: self];
|
||||
[[NSApplication sharedApplication] stopModal];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[defButton release];
|
||||
[altButton release];
|
||||
[othButton release];
|
||||
[icoButton release];
|
||||
[messageField release];
|
||||
[titleField release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) encodeWithModelArchiver: (GMArchiver *)archiver
|
||||
{
|
||||
if (standardAlertPanel)
|
||||
[archiver encodeObject: standardAlertPanel withName: @"AlertPanel"];
|
||||
}
|
||||
|
||||
- (id) initWithContentRect: (NSRect)r
|
||||
styleMask: (unsigned)m
|
||||
backing: (NSBackingStoreType)b
|
||||
defer: (BOOL)d
|
||||
screen: (NSScreen*)s
|
||||
{
|
||||
self = [super initWithContentRect: r
|
||||
styleMask: m
|
||||
backing: b
|
||||
defer: d
|
||||
screen: s];
|
||||
if (self)
|
||||
{
|
||||
NSView *content;
|
||||
unsigned bs = 10.0; /* Inter-button space */
|
||||
unsigned bh = 24.0; /* Button height. */
|
||||
unsigned bw = 72.0; /* Button width. */
|
||||
NSRect rect;
|
||||
NSBox *box;
|
||||
|
||||
[self setMaxSize: r.size];
|
||||
[self setMinSize: r.size];
|
||||
[self setTitle: @" "];
|
||||
|
||||
content = [self contentView];
|
||||
|
||||
rect.size.height = 2.0;
|
||||
rect.size.width = 362.0;
|
||||
rect.origin.y = 95.0;
|
||||
rect.origin.x = 0.0;
|
||||
box = [[NSBox alloc] initWithFrame: rect];
|
||||
[box setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||
[box setTitlePosition: NSNoTitle];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[content addSubview: box];
|
||||
[box release];
|
||||
|
||||
rect.size.height = bh;
|
||||
rect.size.width = bw;
|
||||
rect.origin.y = bs;
|
||||
rect.origin.x = 280.0;
|
||||
defButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[defButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
|
||||
[defButton setButtonType: NSMomentaryPushButton];
|
||||
[defButton setTitle: @"Default"];
|
||||
[defButton setTarget: self];
|
||||
[defButton setAction: @selector(buttonAction:)];
|
||||
[defButton setFont: [NSFont systemFontOfSize: 12.0]];
|
||||
[defButton setKeyEquivalent: @"\r"];
|
||||
[defButton setImagePosition: NSImageRight];
|
||||
[defButton setImage: [NSImage imageNamed: @"common_ret"]];
|
||||
|
||||
rect.origin.x = 199.0;
|
||||
altButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[altButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
|
||||
[altButton setButtonType: NSMomentaryPushButton];
|
||||
[altButton setTitle: @"Alternative"];
|
||||
[altButton setTarget: self];
|
||||
[altButton setAction: @selector(buttonAction:)];
|
||||
[altButton setFont: [NSFont systemFontOfSize: 12.0]];
|
||||
|
||||
rect.origin.x = 120.0;
|
||||
othButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[othButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
|
||||
[othButton setButtonType: NSMomentaryPushButton];
|
||||
[othButton setTitle: @"Other"];
|
||||
[othButton setTarget: self];
|
||||
[othButton setAction: @selector(buttonAction:)];
|
||||
[othButton setFont: [NSFont systemFontOfSize: 12.0]];
|
||||
|
||||
rect.size.height = 48.0;
|
||||
rect.size.width = 48.0;
|
||||
rect.origin.y = 105.0;
|
||||
rect.origin.x = 8.0;
|
||||
icoButton = [[NSButton alloc] initWithFrame: rect];
|
||||
[icoButton setAutoresizingMask: NSViewMaxXMargin | NSViewMinYMargin];
|
||||
[icoButton setBordered: NO];
|
||||
[icoButton setEnabled: NO];
|
||||
[icoButton setImagePosition: NSImageOnly];
|
||||
[icoButton setImage:
|
||||
[[NSApplication sharedApplication] applicationIconImage]];
|
||||
|
||||
rect.size.height = 36.0;
|
||||
rect.size.width = 344.0;
|
||||
rect.origin.y = 46.0;
|
||||
rect.origin.x = 8.0;
|
||||
messageField = [[NSTextField alloc] initWithFrame: rect];
|
||||
[messageField setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable | NSViewMaxYMargin];
|
||||
[messageField setEditable: NO];
|
||||
[messageField setSelectable: NO];
|
||||
[messageField setBordered: NO];
|
||||
[messageField setDrawsBackground: NO];
|
||||
[messageField setStringValue: @""];
|
||||
[messageField setFont: [NSFont systemFontOfSize: 14.0]];
|
||||
|
||||
rect.size.height = 21.0;
|
||||
rect.size.width = 289.0;
|
||||
rect.origin.y = 121.0;
|
||||
rect.origin.x = 64.0;
|
||||
titleField = [[NSTextField alloc] initWithFrame: rect];
|
||||
[titleField setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||
[titleField setEditable: NO];
|
||||
[titleField setSelectable: NO];
|
||||
[titleField setBordered: NO];
|
||||
[titleField setDrawsBackground: NO];
|
||||
[titleField setStringValue: @""];
|
||||
[titleField setFont: [NSFont systemFontOfSize: 18.0]];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver
|
||||
{
|
||||
if (!standardAlertPanel)
|
||||
standardAlertPanel = [unarchiver decodeObjectWithName: @"AlertPanel"];
|
||||
[self release];
|
||||
return standardAlertPanel;
|
||||
}
|
||||
|
||||
- (int) result
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
- (int) runModal
|
||||
{
|
||||
NSApplication *app;
|
||||
|
||||
app = [NSApplication sharedApplication];
|
||||
active = YES;
|
||||
[app runModalForWindow: self];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) setTitle: (NSString*)title
|
||||
message: (NSString*)message
|
||||
def: (NSString*)defaultButton
|
||||
alt: (NSString*)alternateButton
|
||||
other: (NSString*)otherButton
|
||||
{
|
||||
NSView *content = [self contentView];
|
||||
|
||||
if (defaultButton)
|
||||
{
|
||||
[defButton setTitle: defaultButton];
|
||||
if ([defButton superview] == nil)
|
||||
[content addSubview: defButton];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([defButton superview] != nil)
|
||||
[defButton removeFromSuperview];
|
||||
}
|
||||
|
||||
if (alternateButton)
|
||||
{
|
||||
[altButton setTitle: alternateButton];
|
||||
if ([altButton superview] == nil)
|
||||
[content addSubview: altButton];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([altButton superview] != nil)
|
||||
[altButton removeFromSuperview];
|
||||
}
|
||||
|
||||
if (otherButton)
|
||||
{
|
||||
[othButton setTitle: otherButton];
|
||||
if ([othButton superview] == nil)
|
||||
[content addSubview: othButton];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([othButton superview] != nil)
|
||||
[othButton removeFromSuperview];
|
||||
}
|
||||
|
||||
if (message)
|
||||
{
|
||||
[messageField setStringValue: message];
|
||||
if ([messageField superview] == nil)
|
||||
[content addSubview: messageField];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([messageField superview] != nil)
|
||||
[messageField removeFromSuperview];
|
||||
}
|
||||
|
||||
if (title)
|
||||
{
|
||||
[titleField setStringValue: title];
|
||||
if ([titleField superview] == nil)
|
||||
[content addSubview: titleField];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([titleField superview] != nil)
|
||||
[titleField removeFromSuperview];
|
||||
}
|
||||
|
||||
result = NSAlertErrorReturn; /* If no button was pressed */
|
||||
[content display];
|
||||
}
|
||||
|
||||
@end /* GSAlertPanel */
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Alert panel functions
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
id
|
||||
NSGetAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
NSString *message;
|
||||
GSAlertPanel *panel;
|
||||
|
||||
va_start (ap, otherButton);
|
||||
message = [NSString stringWithFormat: msg arguments: ap];
|
||||
va_end (ap);
|
||||
|
||||
if (title == nil)
|
||||
title = @"Alert";
|
||||
|
||||
if (standardAlertPanel == nil)
|
||||
{
|
||||
#if 0
|
||||
if (![GMModel loadIMFile: @"AlertPanel" owner: [GSAlertPanel alloc]])
|
||||
{
|
||||
NSLog(@"cannot open alert panel model file\n");
|
||||
return nil;
|
||||
}
|
||||
#else
|
||||
|
||||
panel = [GSAlertPanel alloc];
|
||||
panel = [panel initWithContentRect:NSMakeRect(0,0,PANX,PANY)
|
||||
styleMask: NSTitledWindowMask
|
||||
backing: NSBackingStoreRetained
|
||||
defer: YES
|
||||
screen: nil];
|
||||
[panel center];
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
panel = standardAlertPanel;
|
||||
standardAlertPanel = nil;
|
||||
}
|
||||
[panel setTitle: title
|
||||
message: message
|
||||
def: defaultButton
|
||||
alt: alternateButton
|
||||
other: otherButton];
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
id
|
||||
NSGetCriticalAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
NSPanel *panel;
|
||||
|
||||
if (title == nil)
|
||||
title = @"Warning";
|
||||
va_start (ap, otherButton);
|
||||
panel = NSGetAlertPanel(title, msg, defaultButton,
|
||||
alternateButton, otherButton, ap);
|
||||
va_end (ap);
|
||||
|
||||
return [panel retain];
|
||||
}
|
||||
|
||||
id
|
||||
NSGetInformationalAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
NSPanel *panel;
|
||||
|
||||
if (title == nil)
|
||||
title = @"Information";
|
||||
va_start (ap, otherButton);
|
||||
panel = NSGetAlertPanel(title, msg, defaultButton,
|
||||
alternateButton, otherButton, ap);
|
||||
va_end (ap);
|
||||
|
||||
return [panel retain];
|
||||
}
|
||||
|
||||
void
|
||||
NSReleaseAlertPanel(id alertPanel)
|
||||
{
|
||||
[alertPanel release];
|
||||
}
|
||||
|
||||
int
|
||||
NSRunAlertPanel(NSString *title,
|
||||
NSString *msg,
|
||||
NSString *defaultButton,
|
||||
NSString *alternateButton,
|
||||
NSString *otherButton, ...)
|
||||
{
|
||||
va_list ap;
|
||||
GSAlertPanel *panel;
|
||||
NSString *message;
|
||||
int result;
|
||||
|
||||
if (title == nil)
|
||||
title = @"Alert";
|
||||
if (defaultButton == nil)
|
||||
defaultButton = @"OK";
|
||||
|
||||
va_start (ap, otherButton);
|
||||
message = [NSString stringWithFormat: msg arguments: ap];
|
||||
va_end (ap);
|
||||
|
||||
if (reusableAlertPanel)
|
||||
{
|
||||
panel = reusableAlertPanel;
|
||||
reusableAlertPanel = nil;
|
||||
[panel setTitle: title
|
||||
message: message
|
||||
def: defaultButton
|
||||
alt: alternateButton
|
||||
other: otherButton];
|
||||
}
|
||||
else
|
||||
{
|
||||
panel = NSGetAlertPanel(title, message, defaultButton,
|
||||
alternateButton, otherButton, ap);
|
||||
}
|
||||
|
||||
result = [panel runModal];
|
||||
|
||||
if (reusableAlertPanel == nil)
|
||||
reusableAlertPanel = panel;
|
||||
else
|
||||
NSReleaseAlertPanel(panel);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue