Several changes to support porting of an OPENSTEP application to GNUstep.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2689 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Ovidiu Predescu 1998-01-09 22:28:14 +00:00
parent 298d5644e0
commit 83942f9a80
26 changed files with 365 additions and 29 deletions

View file

@ -1,3 +1,49 @@
Fri Jan 9 12:25:41 1998 Ovidiu Predescu <ovidiu@net-community.com>
* Headers/gnustep/gui/NSImageView.h: New file.
* Source/NSImageView.m: New file.
* Headers/gnustep/gui/NSApplication.h
(NSApplicationWillTerminateNotification): New notification.
(NSApplicationMain): New function.
(NSOpenStepRootDirectory): Likewise.
* Model/GMAppKit.h: New categories for NSCStringText and NSPopUpButton.
* Model/GMAppKit.m: Likewise.
(-[NSImage createObjectForModelUnarchiver:]): Return a dummy image in
case the image requested does not exist. This prevents a crash later.
* Model/IBClasses.h: Define the NSWindowTemplate class, which is used
internally by the NeXT's IB. I simply remove it from the generated
model file since it has no equivalent.
* Model/IBClasses.m (NSWindowTemplate): Remove all the instances that
appear in the NIB file and encode the window it points to.
* Model/IMConnectors.m: When assigning an object to an instance
variable directly retain the object automatically so it doesn't get
released accidentally.
* Model/IMLoading.m: Search for model files in the Resources directory
of the app wrapper. Automatically append the gmodel extension if not
present.
* Source/NSApplication.m (finishLaunching): Load the main model file if
any. Define the NSOpenStepRootDirectory to be the value of
GNUSTEP_SYSTEM_ROOT.
* Model/GNUmakefile: Define the GNUSTEP_INSTALLATION_DIR to be the
system root. Define the header files that get installed (in the AppKit
directory).
* Source/externs.m: Define the NSApplicationWillTerminateNotification
notification.
* Source/libgnustep-gui.m: Changed the name of the GNUstepMain function
to NSApplicationMain. Implement the NSApplicationMain function to do
something useful ;-).
Mon Jan 5 15:15:34 1998 Ovidiu Predescu <ovidiu@net-community.com>
* Headers/gnustep/DPSClient/DPSOperators.h: Moved to the AppKit header
directory.
* Headers/gnustep/DPSClient/NSDPSContext.h: Likewise.
* Headers/gnustep/DPSClient/TypesandConstants.h: Removed.
* Headers/gnustep/AppKit/NSApplication.h (NSOpenStepRootDirectory):
New function.
Wed Dec 3 14:12:35 1997 Ovidiu Predescu <ovidiu@net-community.com>
Added the code to support the loading of model files (similar to nib

View file

@ -32,7 +32,7 @@
//
// Display Postscript System
//
#include <DPSClient/DPSOperators.h>
#include <AppKit/DPSOperators.h>
//
// GNUstep GUI Library functions
@ -103,6 +103,7 @@
#include <AppKit/NSHelpPanel.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSImageRep.h>
#include <AppKit/NSImageView.h>
#include <AppKit/NSMatrix.h>
#include <AppKit/NSMenu.h>
#include <AppKit/NSMenuItem.h>

View file

@ -314,6 +314,7 @@ extern NSString *NSApplicationDidUnhideNotification;
extern NSString *NSApplicationDidUpdateNotification;
extern NSString *NSApplicationWillBecomeActiveNotification;
extern NSString *NSApplicationWillFinishLaunchingNotification;
extern NSString* NSApplicationWillTerminateNotification;
extern NSString *NSApplicationWillHideNotification;
extern NSString *NSApplicationWillResignActiveNotification;
extern NSString *NSApplicationWillUnhideNotification;
@ -335,4 +336,9 @@ BOOL NSPerformService(NSString *item, NSPasteboard *pboard);
//
void NSUpdateDynamicServices(void);
int NSApplicationMain(int argc, const char **argv);
NSString *NSOpenStepRootDirectory(void);
#endif // _GNUstep_H_NSApplication

View file

@ -29,9 +29,8 @@
#ifndef _GNUstep_H_NSDPSContext
#define _GNUstep_H_NSDPSContext
#include <DPSClient/TypesandConstants.h>
#include <DPSClient/DPSOperators.h>
#include <Foundation/NSObject.h>
#include <AppKit/DPSOperators.h>
@class NSData;
@class NSMutableData;

View file

@ -29,7 +29,7 @@
#ifndef _GNUstep_H_NSFontPanel
#define _GNUstep_H_NSFontPanel
#include <DPSClient/TypesandConstants.h>
#include <AppKit/NSDPSContext.h>
#include <AppKit/NSPanel.h>
@class NSFont;

View file

@ -29,7 +29,7 @@
#ifndef _GNUstep_H_NSImage
#define _GNUstep_H_NSImage
#include <DPSClient/TypesandConstants.h>
#include <AppKit/NSDPSContext.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSCoder.h>
#include <AppKit/NSBitmapImageRep.h>

View file

@ -0,0 +1,75 @@
/*
NSImageView.h
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: January 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; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _GNUstep_H_NSImageView
#define _GNUstep_H_NSImageView
#include <AppKit/NSControl.h>
typedef enum {
NSScaleProportionally = 0, // Fit propoRtionally
NSScaleToFit, // Forced fit (distort if necessary)
NSScaleNone // Don't scale (clip)
} NSImageScaling;
typedef enum {
NSImageAlignCenter = 0,
NSImageAlignTop,
NSImageAlignTopLeft,
NSImageAlignTopRight,
NSImageAlignLeft,
NSImageAlignBottom,
NSImageAlignBottomLeft,
NSImageAlignBottomRight,
NSImageAlignRight
} NSImageAlignment;
typedef enum {
NSImageFrameNone = 0,
NSImageFramePhoto,
NSImageFrameGrayBezel,
NSImageFrameGroove,
NSImageFrameButton
} NSImageFrameStyle;
@interface NSImageView : NSControl
{
}
- (NSImage *)image;
- (void)setImage:(NSImage *)image;
- (NSImageAlignment)imageAlignment;
- (void)setImageAlignment:(NSImageAlignment)align;
- (NSImageScaling)imageScaling;
- (void)setImageScaling:(NSImageScaling)scaling;
- (NSImageFrameStyle)imageFrameStyle;
- (void)setImageFrameStyle:(NSImageFrameStyle)style;
- (void)setEditable:(BOOL)flag;
- (BOOL)isEditable;
@end
#endif /* _GNUstep_H_NSImageView */

View file

@ -32,7 +32,7 @@
#ifndef _GNUstep_H_NSView
#define _GNUstep_H_NSView
#include <DPSClient/TypesandConstants.h>
#include <AppKit/NSDPSContext.h>
#include <AppKit/NSResponder.h>
@class NSString;

View file

@ -29,7 +29,7 @@
#ifndef _GNUstep_H_NSWindow
#define _GNUstep_H_NSWindow
#include <DPSClient/TypesandConstants.h>
#include <AppKit/NSDPSContext.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSResponder.h>
#include <AppKit/NSEvent.h>

View file

@ -44,6 +44,9 @@
@interface NSControl (GMArchiverMethods) <ModelCoding>
@end
@interface NSCStringText (GMArchiverMethods) <ModelCoding>
@end
@interface NSFont (GMArchiverMethods) <ModelCoding>
@end
@ -56,6 +59,9 @@
@interface NSMenu (GMArchiverMethods) <ModelCoding>
@end
@interface NSPopUpButton (GMArchiverMethods) <ModelCoding>
@end
@interface NSResponder (GMArchiverMethods) <ModelCoding>
@end

View file

@ -345,6 +345,26 @@ void __dummy_GMAppKit_functionForLinking() {}
@end /* NSControl (GMArchiverMethods) */
@implementation NSCStringText (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [super initWithModelUnarchiver:unarchiver];
}
- (Class)classForModelArchiver
{
return [NSCStringText class];
}
@end /* NSCStringText (GMArchiverMethods) */
@implementation NSFont (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
@ -382,7 +402,11 @@ void __dummy_GMAppKit_functionForLinking() {}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [NSImage imageNamed:[unarchiver decodeStringWithName:@"name"]];
id image = [NSImage imageNamed:[unarchiver decodeStringWithName:@"name"]];
if (!image)
image = [NSImage imageNamed:@"NSRadioButton"];
return image;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
@ -499,6 +523,27 @@ void __dummy_GMAppKit_functionForLinking() {}
@end /* NSMenu (GMArchiverMethods) */
@implementation NSPopUpButton (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
// [super encodeWithModelArchiver:archiver];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
// return [super initWithModelUnarchiver:unarchiver];
return self;
}
- (Class)classForModelArchiver
{
return [NSPopUpButton class];
}
@end /* NSPopUpButton (GMArchiverMethods) */
@implementation NSResponder (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver

View file

@ -22,6 +22,8 @@
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
LIBRARY_NAME = libgmodel
@ -33,6 +35,9 @@ endif
APP_NAME = test
libgmodel_OBJC_FILES = IMCustomObject.m IMConnectors.m IMLoading.m GMAppKit.m
libgmodel_HEADER_FILES_DIR = .
libgmodel_HEADER_FILES_INSTALL_DIR = /gnustep/gui/AppKit
libgmodel_HEADER_FILES = IMConnectors.h IMCustomObject.h IMLoading.h GMAppKit.h
test_OBJC_FILES = test.m Controller.m

View file

@ -56,4 +56,23 @@
@interface NSIBControlConnector : NSIBConnector
@end
/* Classes used internally by NeXT's AppKit we don't want to appear in the
model file */
@interface NSWindowTemplate : NSObject
{
NSRect windowRect;
int windowStyleMask;
int windowBacking;
id windowTitle;
id viewClass;
id windowClass;
id windowView;
id realObject;
id extension;
NSSize minSize;
BOOL _wtFlags; /* Don't know the type of this ivar */
NSRect screenRect;
}
@end
#endif /* _GNUstep_H_IBClasses */

View file

@ -127,3 +127,25 @@
return [IMControlConnector class];
}
@end /* NSIBControlConnector */
@implementation NSWindowTemplate (GMArchiverMethods)
#ifdef DEBUG
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
NSLog (@"%@: %@", NSStringFromClass (isa), NSStringFromSelector (_cmd));
[super encodeWithModelArchiver:archiver];
}
#endif
- (id)replacementObjectForModelArchiver:(GMArchiver*)archiver
{
#ifdef DEBUG
NSLog (@"realObject = %@", realObject);
#endif
return realObject;
}
@end

View file

@ -54,7 +54,7 @@ object_set_instance_variable (id anObject,
if (ivar.ivar_name && !strcmp (ivar.ivar_name, variableName)) {
/* We found it! */
*((id*)(((char*)anObject) + ivar.ivar_offset)) = value;
*((void**)(((char*)anObject) + ivar.ivar_offset)) = value;
break;
}
}
@ -97,7 +97,7 @@ object_set_instance_variable (id anObject,
[_source setTarget:_destination];
}
else
object_set_instance_variable (_source, "target", _destination);
object_set_instance_variable (_source, "target", [_destination retain]);
if ([_source respondsToSelector:@selector(setAction:)]) {
// NSLog (@"%@: setting action to %@",
@ -124,7 +124,7 @@ object_set_instance_variable (id anObject,
if (setSelector && [_source respondsToSelector:setSelector])
[_source performSelector:setSelector withObject:_destination];
else
object_set_instance_variable(_source, [label cString], _destination);
object_set_instance_variable(_source, [label cString], [_destination retain]);
}
@end /* IMOutletConnector */

View file

@ -25,6 +25,7 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSFileManager.h>
#include <extensions/GMArchiver.h>
#include "IMLoading.h"
#include "IMCustomObject.h"
@ -58,10 +59,21 @@ BOOL _fileOwnerDecoded = NO;
+ (BOOL)loadIMFile:(NSString*)path owner:(id)owner
{
GMUnarchiver* unarchiver = [GMUnarchiver unarchiverWithContentsOfFile:path];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* resourcePath = [mainBundle resourcePath];
GMUnarchiver* unarchiver;
id previousNibOwner = _nibOwner;
GMModel* decoded;
if (![path hasSuffix:@".gmodel"])
path = [path stringByAppendingPathExtension:@"gmodel"];
path = [resourcePath stringByAppendingPathComponent:path];
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
return NO;
NSLog (@"loading model file %@...", path);
unarchiver = [GMUnarchiver unarchiverWithContentsOfFile:path];
if (!unarchiver)
return NO;

View file

@ -70,6 +70,7 @@ NSFormCell.m \
NSHelpPanel.m \
NSImage.m \
NSImageRep.m \
NSImageView.m \
NSMatrix.m \
NSMenu.m \
NSMenuItem.m \
@ -149,6 +150,7 @@ AppKit/NSGraphics.h \
AppKit/NSHelpPanel.h \
AppKit/NSImage.h \
AppKit/NSImageRep.h \
AppKit/NSImageView.h \
AppKit/NSMatrix.h \
AppKit/NSMenu.h \
AppKit/NSMenuItem.h \
@ -184,9 +186,8 @@ AppKit/NSWorkspace.h \
AppKit/TrackingRectangle.h \
AppKit/nsimage-tiff.h \
AppKit/PSMatrix.h \
DPSClient/NSDPSContext.h \
DPSClient/DPSOperators.h \
DPSClient/TypesandConstants.h
AppKit/NSDPSContext.h \
AppKit/DPSOperators.h
-include GNUmakefile.preamble

View file

@ -77,5 +77,3 @@ before-all:: header-links
header-links:
-rm -rf ../Headers/AppKit
$(LN_S) ../Headers/gnustep/gui ../Headers/AppKit
-rm -rf ../Headers/DPSClient
$(LN_S) ../Headers/gnustep/dps ../Headers/DPSClient

View file

@ -63,8 +63,7 @@ ADDITIONAL_LIB_DIRS =
# Additional directories to be created during installation
ADDITIONAL_INSTALL_DIRS = $(GNUSTEP_HEADERS)/gnustep \
$(GNUSTEP_HEADERS)/gnustep/gui \
$(GNUSTEP_HEADERS)/gnustep/gui/AppKit \
$(GNUSTEP_HEADERS)/gnustep/gui/DPSClient
$(GNUSTEP_HEADERS)/gnustep/gui/AppKit
# What are the libraries this library depends upon. This is needed for some
# systems where building a shared library requires to pass to the linker

View file

@ -30,16 +30,19 @@
#include <stdio.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSTimer.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSFileManager.h>
#ifndef LIB_FOUNDATION_LIBRARY
# include <Foundation/NSConnection.h>
#endif
#include <DPSClient/NSDPSContext.h>
#include <AppKit/NSDPSContext.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSPopUpButton.h>
#include <AppKit/NSPanel.h>
@ -49,6 +52,8 @@
#include <AppKit/NSMenuItem.h>
#include <AppKit/NSCursor.h>
#include <AppKit/IMLoading.h>
//
// Class variables
//
@ -138,6 +143,21 @@ static id NSApp;
- (void)finishLaunching
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* resourcePath = [mainBundle resourcePath];
NSString* infoFilePath
= [resourcePath stringByAppendingPathComponent:@"Info-gnustep.plist"];
NSDictionary* infoDict = [[NSString stringWithContentsOfFile:infoFilePath]
propertyList];
NSString* mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
if (mainModelFile) {
if (![GMModel loadIMFile:mainModelFile
owner:[NSApplication sharedApplication]])
NSLog (@"Cannot load the main model file '%@", mainModelFile);
else
NSLog (@"Model loading ready!");
}
// notify that we will finish the launching
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
@ -1120,3 +1140,16 @@ static id NSApp;
{}
@end
/* Some utilities */
NSString *NSOpenStepRootDirectory(void)
{
NSString* root = [[[NSProcessInfo processInfo] environment]
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
if (!root)
root = @"/";
return root;
}

View file

@ -32,7 +32,7 @@
#include <Foundation/NSLock.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <gnustep/dps/NSDPSContext.h>
#include <AppKit/NSDPSContext.h>
#define ASSIGN(a, b) \
[b retain]; \

View file

@ -39,7 +39,7 @@
#include <AppKit/NSEvent.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSWindow.h>
#include <DPSClient/NSDPSContext.h>
#include <AppKit/NSDPSContext.h>
@implementation NSEvent

56
Source/NSImageView.m Normal file
View file

@ -0,0 +1,56 @@
/*
NSImageView.m
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: January 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; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <AppKit/NSImageView.h>
@implementation NSImageView
- (void)setImage:(NSImage *)image
{
}
- (void)setImageAlignment:(NSImageAlignment)align
{
}
- (void)setImageScaling:(NSImageScaling)scaling
{
}
- (void)setImageFrameStyle:(NSImageFrameStyle)style
{
}
- (void)setEditable:(BOOL)flag
{
}
- (NSImage *)image { return nil; }
- (NSImageAlignment)imageAlignment { return 0; }
- (NSImageScaling)imageScaling { return 0; }
- (NSImageFrameStyle)imageFrameStyle { return 0; }
- (BOOL)isEditable { return 0; }
@end

View file

@ -87,6 +87,7 @@ NSString *NSApplicationWillBecomeActiveNotification
= @"ApplicationWillBecomeActive";
NSString *NSApplicationWillFinishLaunchingNotification
= @"ApplicationWillFinishLaunching";
NSString *NSApplicationWillTerminateNotification = @"ApplicationWillTerminate";
NSString *NSApplicationWillHideNotification = @"ApplicationWillHide";
NSString *NSApplicationWillResignActiveNotification
= @"ApplicationWillResignActive";

View file

@ -30,7 +30,7 @@
;
LIBRARY libgnustep-gui
EXPORTS
GNUstepMain
NSApplicationMain
__objc_class_name_NSActionCell
__objc_category_name_NSApplication_GNUstepBackend
__objc_class_name_NSApplication

View file

@ -26,19 +26,31 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSFontManager.h>
#include <AppKit/NSFont.h>
char **NSArgv = NULL;
//
// The main entry point for X Windows
//
int
GNUstepMain(int argc, char **argv)
int NSApplicationMain(int argc, const char **argv)
{
extern char** environ;
#if LIB_FOUNDATION_LIBRARY
[NSProcessInfo initializeWithArguments:(char**)argv
count:argc
environment:environ];
#endif
[NSAutoreleasePool new];
#ifndef NX_CURRENT_COMPILER_RELEASE
initialize_gnustep_backend();
#endif
[[NSApplication sharedApplication] run];
return 0;
}