Additional work for Win32 operation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1968 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1996-12-05 13:07:59 +00:00
parent 50604fcf31
commit b861dad5d5
8 changed files with 170 additions and 177 deletions

View file

@ -1,3 +1,18 @@
Thu Dec 05 09:56:25 1996 Scott Christley <scottc@net-community.com>
* Headers/gnustep/gui/NSMenu.h: Newer release of OpenStep
specification indicates NSMenu subclasses from NSObject.
* Headers/gnustep/gui/NSFontManager.h (-enumerateFontsAndFamilies):
New method that backend must implement.
(-enumerateFamilies): Delete old method.
* Source/NSColor.m: Reverse usage of global variables for common
colors as it causes havoc with archiving.
* Source/NSFont.m: Encode additional instance variables.
* Source/NSFontManager.m: Rename global variables.
(-enumerateFamilies): Replaced by -enumerateFontsAndFamilies.
* Source/NSMenu.m: Encode additional instance variables.
* Source/NSWindow.m: Likewise.
Fri Oct 18 12:56:14 1996 GNUstep Development <gnustep@duncan.ocbi.com>
* SUPPORT: New file.

View file

@ -54,11 +54,6 @@
+ (void)setFontPanelFactory:(Class)classId;
+ (NSFontManager *)sharedFontManager;
//
// Initialization
//
- (void)enumerateFamilies;
//
// Converting Fonts
//
@ -117,4 +112,13 @@
@end
@interface NSFontManager (GNUstepBackend)
//
// Have the backend determine the fonts and families available
//
- (void)enumerateFontsAndFamilies;
@end
#endif // _GNUstep_H_NSFontManager

View file

@ -37,10 +37,11 @@
#include <Foundation/NSCoder.h>
#include <Foundation/NSZone.h>
@interface NSMenu : NSWindow <NSCoding>
@interface NSMenu : NSObject <NSCoding>
{
// Attributes
NSString *window_title;
NSMutableArray *menu_items;
NSMenu *super_menu;
BOOL autoenables_items;

View file

@ -31,23 +31,7 @@
#include <gnustep/gui/NSView.h>
// Class variables
BOOL gnustep_gui_ignores_alpha = YES;
// Common colors
NSColor *gnustep_gui_black = nil;
NSColor *gnustep_gui_blue = nil;
NSColor *gnustep_gui_brown = nil;
NSColor *gnustep_gui_clear = nil;
NSColor *gnustep_gui_cyan = nil;
NSColor *gnustep_gui_dark_gray = nil;
NSColor *gnustep_gui_gray = nil;
NSColor *gnustep_gui_green = nil;
NSColor *gnustep_gui_light_gray = nil;
NSColor *gnustep_gui_magenta = nil;
NSColor *gnustep_gui_orange = nil;
NSColor *gnustep_gui_purple = nil;
NSColor *gnustep_gui_red = nil;
NSColor *gnustep_gui_white = nil;
NSColor *gnustep_gui_yellow = nil;
static BOOL gnustep_gui_ignores_alpha = YES;
// Global strings
NSString *NSCalibratedWhiteColorSpace = @"NSCalibratedWhiteColorSpace";
@ -218,63 +202,43 @@ const float NSWhite = 1;
//
+ (NSColor *)blackColor
{
if (!gnustep_gui_black)
{
gnustep_gui_black = [self colorWithCalibratedWhite: NSBlack alpha: 1.0];
[gnustep_gui_black retain];
}
return gnustep_gui_black;
return [self colorWithCalibratedWhite: NSBlack alpha: 1.0];
}
+ (NSColor *)blueColor
{
if (!gnustep_gui_blue)
{
gnustep_gui_blue = [self colorWithCalibratedRed:0
green:0
blue:1.0
alpha:1.0];
[gnustep_gui_blue retain];
}
return gnustep_gui_blue;
return [self colorWithCalibratedRed:0
green:0
blue:1.0
alpha:1.0];
}
+ (NSColor *)brownColor
{
if (!gnustep_gui_brown)
{
gnustep_gui_brown = [self colorWithCalibratedRed:0.6
green:0.4
blue:0.2
alpha:1.0];
[gnustep_gui_brown retain];
}
return gnustep_gui_brown;
return [self colorWithCalibratedRed:0.6
green:0.4
blue:0.2
alpha:1.0];
}
+ (NSColor *)clearColor
{
if (!gnustep_gui_clear)
{
gnustep_gui_clear = [self colorWithCalibratedWhite: NSBlack alpha: 1.0];
[gnustep_gui_clear retain];
[gnustep_gui_clear setClear:YES];
}
return gnustep_gui_clear;
NSColor *c;
c = [self colorWithCalibratedRed:0
green:1.0
blue:1.0
alpha:1.0];
[c setClear:YES];
return c;
}
+ (NSColor *)cyanColor
{
// Why does OpenStep say RGB color space instead of CMYK?
if (!gnustep_gui_cyan)
{
gnustep_gui_cyan = [self colorWithCalibratedRed:0
green:1.0
blue:1.0
alpha:1.0];
[gnustep_gui_cyan retain];
}
return gnustep_gui_cyan;
return [self colorWithCalibratedRed:0
green:1.0
blue:1.0
alpha:1.0];
#if 0
return [self colorWithCalibratedCyan: 1.0
magenta:0
@ -286,62 +250,34 @@ const float NSWhite = 1;
+ (NSColor *)darkGrayColor
{
if (!gnustep_gui_dark_gray)
{
gnustep_gui_dark_gray = [self colorWithCalibratedWhite: NSDarkGray
alpha: 1.0];
[gnustep_gui_dark_gray retain];
}
return gnustep_gui_dark_gray;
return [self colorWithCalibratedWhite: NSDarkGray alpha: 1.0];
}
+ (NSColor *)grayColor
{
if (!gnustep_gui_gray)
{
gnustep_gui_gray = [self colorWithCalibratedWhite: NSGray
alpha: 1.0];
[gnustep_gui_gray retain];
}
return gnustep_gui_gray;
return [self colorWithCalibratedWhite: NSGray alpha: 1.0];
}
+ (NSColor *)greenColor
{
if (!gnustep_gui_green)
{
gnustep_gui_green = [self colorWithCalibratedRed:0
green:1.0
blue:0
alpha:1.0];
[gnustep_gui_green retain];
}
return gnustep_gui_green;
return [self colorWithCalibratedRed:0
green:1.0
blue:0
alpha:1.0];
}
+ (NSColor *)lightGrayColor
{
if (!gnustep_gui_light_gray)
{
gnustep_gui_light_gray = [self colorWithCalibratedWhite: NSLightGray
alpha: 1.0];
[gnustep_gui_light_gray retain];
}
return gnustep_gui_light_gray;
return [self colorWithCalibratedWhite: NSLightGray alpha: 1];
}
+ (NSColor *)magentaColor
{
// Why does OpenStep say RGB color space instead of CMYK?
if (!gnustep_gui_magenta)
{
gnustep_gui_magenta = [self colorWithCalibratedRed:1.0
green:0
blue:1.0
alpha:1.0];
[gnustep_gui_magenta retain];
}
return gnustep_gui_magenta;
return [self colorWithCalibratedRed:1.0
green:0
blue:1.0
alpha:1.0];
#if 0
return [self colorWithCalibratedCyan:0
magenta:1.0
@ -353,65 +289,40 @@ const float NSWhite = 1;
+ (NSColor *)orangeColor;
{
if (!gnustep_gui_orange)
{
gnustep_gui_orange = [self colorWithCalibratedRed:1.0
green:0.5
blue:0
alpha:1.0];
[gnustep_gui_orange retain];
}
return gnustep_gui_orange;
return [self colorWithCalibratedRed:1.0
green:0.5
blue:0
alpha:1.0];
}
+ (NSColor *)purpleColor;
{
if (!gnustep_gui_purple)
{
gnustep_gui_purple = [self colorWithCalibratedRed:0.5
green:0
blue:0.5
alpha:1.0];
[gnustep_gui_purple retain];
}
return gnustep_gui_purple;
return [self colorWithCalibratedRed:0.5
green:0
blue:0.5
alpha:1.0];
}
+ (NSColor *)redColor;
{
if (!gnustep_gui_red)
{
gnustep_gui_red = [self colorWithCalibratedRed:1.0
green:0
blue:0
alpha:1.0];
[gnustep_gui_red retain];
}
return gnustep_gui_red;
return [self colorWithCalibratedRed:1.0
green:0
blue:0
alpha:1.0];
}
+ (NSColor *)whiteColor;
{
if (!gnustep_gui_white)
{
gnustep_gui_white = [self colorWithCalibratedWhite: NSWhite alpha: 1.0];
[gnustep_gui_white retain];
}
return gnustep_gui_white;
return [self colorWithCalibratedWhite: NSWhite alpha: 1.0];
}
+ (NSColor *)yellowColor
{
// Why does OpenStep say RGB color space instead of CMYK?
if (!gnustep_gui_yellow)
{
gnustep_gui_yellow = [self colorWithCalibratedRed:1.0
green:1.0
blue:0
alpha:1.0];
[gnustep_gui_yellow retain];
}
return gnustep_gui_yellow;
return [self colorWithCalibratedRed:1.0
green:1.0
blue:0
alpha:1.0];
#if 0
return [self colorWithCalibratedCyan:0
magenta:0
@ -711,7 +622,8 @@ const float NSWhite = 1;
s = [NSString stringWithCString: object_get_class_name(self)];
// Version 2
if ([aDecoder versionForClassName: s] > 1)
// +++ Coding cannot return class version yet
// if ([aDecoder versionForClassName: s] > 1)
{
colorspace_name = [aDecoder decodeObject];
catalog_name = [aDecoder decodeObject];

View file

@ -65,7 +65,7 @@ NSString *NSAFMXHeight = @"AFMXHeight";
NSDebugLog(@"Initialize NSFont class\n");
// Initial version
[self setVersion:1];
[self setVersion:2];
}
}
@ -267,6 +267,10 @@ NSString *NSAFMXHeight = @"AFMXHeight";
[aCoder encodeObject: font_name];
[aCoder encodeValueOfObjCType: "f" at: &point_size];
[aCoder encodeValueOfObjCType: @encode(NSFontTraitMask) at: &font_traits];
// Version 2
//[aCoder encodeObject: type_face];
[aCoder encodeValueOfObjCType: @encode(int) at: &font_weight];
}
- initWithCoder:aDecoder
@ -278,6 +282,10 @@ NSString *NSAFMXHeight = @"AFMXHeight";
[aDecoder decodeValueOfObjCType: "f" at: &point_size];
[aDecoder decodeValueOfObjCType: @encode(NSFontTraitMask) at: &font_traits];
// Version 2
//type_face = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(int) at: &font_weight];
return self;
}

View file

@ -33,10 +33,10 @@
//
// Class variables
//
NSFontManager *MB_THE_FONT_MANAGER;
NSFontPanel *MB_THE_FONT_PANEL;
id MB_THE_FONT_MANAGER_FACTORY;
id MB_THE_FONT_PANEL_FACTORY;
NSFontManager *GNUSTEP_GUI_FONT_MANAGER;
NSFontPanel *GNUSTEP_GUI_FONT_PANEL;
id GNUSTEP_GUI_FONT_MANAGER_FACTORY;
id GNUSTEP_GUI_FONT_PANEL_FACTORY;
@implementation NSFontManager
@ -63,20 +63,22 @@ id MB_THE_FONT_PANEL_FACTORY;
//
+ (void)setFontManagerFactory:(Class)classId
{
MB_THE_FONT_MANAGER_FACTORY = classId;
GNUSTEP_GUI_FONT_MANAGER_FACTORY = classId;
}
+ (void)setFontPanelFactory:(Class)classId
{
MB_THE_FONT_PANEL_FACTORY = classId;
GNUSTEP_GUI_FONT_PANEL_FACTORY = classId;
}
+ (NSFontManager *)sharedFontManager
{
if (!MB_THE_FONT_MANAGER)
MB_THE_FONT_MANAGER = [[NSFontManager alloc] init];
[MB_THE_FONT_MANAGER enumerateFamilies];
return MB_THE_FONT_MANAGER;
if (!GNUSTEP_GUI_FONT_MANAGER)
{
GNUSTEP_GUI_FONT_MANAGER = [[NSFontManager alloc] init];
[GNUSTEP_GUI_FONT_MANAGER enumerateFontsAndFamilies];
}
return GNUSTEP_GUI_FONT_MANAGER;
}
//
@ -89,21 +91,13 @@ id MB_THE_FONT_PANEL_FACTORY;
// Allocate the font list
font_list = [NSMutableArray array];
// Allocate the family list
family_list = [NSMutableArray array];
family_metrics = [NSMutableArray array];
return self;
}
- (void)enumerateFamilies
{
if (!family_list)
{
// Allocate the family list
family_list = [NSMutableArray array];
family_metrics = [NSMutableArray array];
// Enumerate the available font families
}
}
//
// Converting Fonts
//
@ -281,9 +275,9 @@ id MB_THE_FONT_PANEL_FACTORY;
- (NSFontPanel *)fontPanel:(BOOL)create
{
if ((!MB_THE_FONT_PANEL) && (create))
MB_THE_FONT_PANEL = [[NSFontPanel alloc] init];
return MB_THE_FONT_PANEL;
if ((!GNUSTEP_GUI_FONT_PANEL) && (create))
GNUSTEP_GUI_FONT_PANEL = [[NSFontPanel alloc] init];
return GNUSTEP_GUI_FONT_PANEL;
}
- (BOOL)isEnabled
@ -361,3 +355,11 @@ id MB_THE_FONT_PANEL_FACTORY;
}
@end
@implementation NSFontManager (GNUstepBackend)
- (void)enumerateFontsAndFamilies
{
}
@end

View file

@ -44,7 +44,7 @@ NSZone *gnustep_gui_nsmenu_zone = NULL;
if (self == [NSMenu class])
{
// Initial version
[self setVersion:1];
[self setVersion:2];
}
}
@ -78,21 +78,22 @@ NSZone *gnustep_gui_nsmenu_zone = NULL;
NSApplication *theApp = [NSApplication sharedApplication];
// Init our superclass but skip any of its backend implementation
[super cleanInit];
[super init];
window_title = aTitle;
menu_items = [NSMutableArray array];
super_menu = nil;
autoenables_items = NO;
// [self setContentView:[[NSView alloc] initWithFrame:frame]];
menu_matrix = [[NSMatrix alloc] initWithFrame: NSZeroRect];
[menu_matrix setCellClass: [NSMenuCell class]];
[menu_matrix setIntercellSpacing: NSZeroSize];
[self setContentView: menu_matrix];
// [self setContentView: menu_matrix];
is_torn_off = NO;
// Register ourselves with the Application object
[theApp addWindowsItem:self title:window_title filename:NO];
// [theApp addWindowsItem:self title:window_title filename:NO];
return self;
}
@ -249,6 +250,13 @@ NSZone *gnustep_gui_nsmenu_zone = NULL;
[super encodeWithCoder:aCoder];
[aCoder encodeObject: menu_items];
// Version 2
[aCoder encodeObject: window_title];
[aCoder encodeObjectReference: super_menu withName: @"SuperMenu"];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &autoenables_items];
[aCoder encodeObject: menu_matrix];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_torn_off];
}
- initWithCoder:aDecoder
@ -257,6 +265,13 @@ NSZone *gnustep_gui_nsmenu_zone = NULL;
menu_items = [aDecoder decodeObject];
// Version 2
window_title = [aDecoder decodeObject];
[aDecoder decodeObjectAt: &super_menu withName: NULL];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &autoenables_items];
menu_matrix = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_torn_off];
return self;
}

View file

@ -67,7 +67,7 @@ NSString *NSWindowWillMoveNotification = @"WindowWillMove";
NSDebugLog(@"Initialize NSWindow class\n");
// Initial version
[self setVersion:1];
[self setVersion:2];
}
}
@ -1343,6 +1343,24 @@ NSString *NSWindowWillMoveNotification = @"WindowWillMove";
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_miniaturized];
[aCoder encodeValueOfObjCType:"I" at: &style_mask];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &menu_exclude];
// Version 2
[aCoder encodeSize:minimum_size];
[aCoder encodeSize:maximum_size];
[aCoder encodeObject:miniaturized_image];
[aCoder encodeValueOfObjCType:@encode(NSBackingStoreType) at: &backing_type];
[aCoder encodeValueOfObjCType:@encode(int) at: &window_level];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_one_shot];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_autodisplay];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &optimize_drawing];
[aCoder encodeValueOfObjCType:@encode(NSWindowDepth) at: &depth_limit];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &dynamic_depth_limit];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &cursor_rects_enabled];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_released_when_closed];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &disable_flush_window];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate];
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved];
NSDebugLog(@"NSWindow: finish encoding\n");
}
@ -1372,6 +1390,24 @@ NSString *NSWindowWillMoveNotification = @"WindowWillMove";
[aDecoder decodeValueOfObjCType:"I" at: &style_mask];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &menu_exclude];
// Version 2
minimum_size = [aDecoder decodeSize];
maximum_size = [aDecoder decodeSize];
miniaturized_image = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType:@encode(NSBackingStoreType)
at: &backing_type];
[aDecoder decodeValueOfObjCType:@encode(int) at: &window_level];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_one_shot];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_autodisplay];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &optimize_drawing];
[aDecoder decodeValueOfObjCType:@encode(NSWindowDepth) at: &depth_limit];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &dynamic_depth_limit];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &cursor_rects_enabled];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_released_when_closed];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &disable_flush_window];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved];
// Register ourselves with the Application object
// +++ we shouldn't do this because coding may not be done?
// better to do it in the awakeFromCoder method