2005-08-06 17:59:08 +00:00
|
|
|
/*
|
|
|
|
main.m
|
1999-12-16 21:41:21 +00:00
|
|
|
|
2005-08-06 17:59:08 +00:00
|
|
|
Copyright (C) 1999-2005 Free Software Foundation, Inc.
|
1999-12-16 21:41:21 +00:00
|
|
|
|
|
|
|
Author: Richard frith-Macdonald (richard@brainstorm.co.uk>
|
|
|
|
Date: 1999
|
|
|
|
|
|
|
|
This file is part of GNUstep.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-11-05 23:44:36 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-12-16 21:41:21 +00:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-05-26 03:37:38 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
1999-12-16 21:41:21 +00:00
|
|
|
*/
|
2005-08-06 17:59:08 +00:00
|
|
|
|
2004-12-31 13:21:30 +00:00
|
|
|
#include <InterfaceBuilder/IBApplicationAdditions.h>
|
2005-08-06 17:59:08 +00:00
|
|
|
#include <InterfaceBuilder/IBInspector.h>
|
|
|
|
#include <InterfaceBuilder/IBPalette.h>
|
|
|
|
|
2005-03-31 03:01:36 +00:00
|
|
|
#include <GormCore/GormDocument.h>
|
|
|
|
#include <GormCore/NSColorWell+GormExtensions.h>
|
2010-01-06 06:05:08 +00:00
|
|
|
#include <GormCore/GormNSPanel.h>
|
|
|
|
#include <GormCore/GormNSWindow.h>
|
2005-08-06 17:59:08 +00:00
|
|
|
|
|
|
|
#include "GormWindowSizeInspector.h"
|
2006-09-13 03:12:59 +00:00
|
|
|
#include "WindowsPalette.h"
|
1999-12-16 21:41:21 +00:00
|
|
|
|
|
|
|
@interface GormWindowMaker : NSObject <NSCoding>
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation GormWindowMaker
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
{
|
|
|
|
}
|
2003-01-16 04:09:07 +00:00
|
|
|
|
1999-12-16 21:41:21 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
{
|
2005-08-06 17:59:08 +00:00
|
|
|
id w;
|
|
|
|
unsigned style = ( NSTitledWindowMask | NSClosableWindowMask
|
|
|
|
| NSResizableWindowMask | NSMiniaturizableWindowMask);
|
2002-11-24 03:45:11 +00:00
|
|
|
NSRect screenRect = [[NSScreen mainScreen] frame];
|
2005-08-06 17:59:08 +00:00
|
|
|
float x = (screenRect.size.width - 500)/2;
|
|
|
|
float y = (screenRect.size.height - 300)/2;
|
2002-11-24 03:45:11 +00:00
|
|
|
NSRect windowRect = NSMakeRect(x,y,500,300);
|
1999-12-16 21:41:21 +00:00
|
|
|
|
2002-11-24 03:45:11 +00:00
|
|
|
w = [[GormNSWindow alloc] initWithContentRect: windowRect
|
2002-02-18 12:37:26 +00:00
|
|
|
styleMask: style
|
|
|
|
backing: NSBackingStoreRetained
|
|
|
|
defer: NO];
|
2005-08-06 17:59:08 +00:00
|
|
|
|
2002-11-24 03:45:11 +00:00
|
|
|
[w setFrame: windowRect display: YES];
|
1999-12-16 21:41:21 +00:00
|
|
|
[w setTitle: @"Window"];
|
2002-11-24 03:45:11 +00:00
|
|
|
[w orderFront: self];
|
1999-12-16 21:41:21 +00:00
|
|
|
RELEASE(self);
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface GormPanelMaker : NSObject <NSCoding>
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation GormPanelMaker
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
{
|
|
|
|
}
|
2001-06-18 23:04:20 +00:00
|
|
|
|
1999-12-16 21:41:21 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
{
|
|
|
|
id w;
|
2003-01-05 06:03:14 +00:00
|
|
|
unsigned style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
|
2002-11-24 03:45:11 +00:00
|
|
|
NSRect screenRect = [[NSScreen mainScreen] frame];
|
|
|
|
float
|
|
|
|
x = (screenRect.size.width - 500)/2,
|
|
|
|
y = (screenRect.size.height - 300)/2;
|
|
|
|
NSRect windowRect = NSMakeRect(x,y,500,300);
|
|
|
|
|
2003-01-05 06:03:14 +00:00
|
|
|
w = [[GormNSPanel alloc] initWithContentRect: windowRect
|
|
|
|
styleMask: style
|
|
|
|
backing: NSBackingStoreRetained
|
|
|
|
defer: NO];
|
2002-11-24 03:45:11 +00:00
|
|
|
[w setFrame: windowRect display: YES];
|
1999-12-16 21:41:21 +00:00
|
|
|
[w setTitle: @"Panel"];
|
2002-11-24 03:45:11 +00:00
|
|
|
[w orderFront: self];
|
1999-12-16 21:41:21 +00:00
|
|
|
RELEASE(self);
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation WindowsPalette
|
|
|
|
- (void) finishInstantiate
|
|
|
|
{
|
|
|
|
NSView *contents;
|
|
|
|
id w;
|
|
|
|
id v;
|
|
|
|
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
|
|
|
NSString *path = [bundle pathForImageResource: @"WindowDrag"];
|
|
|
|
NSImage *dragImage = [[NSImage alloc] initWithContentsOfFile: path];
|
2006-09-13 03:12:59 +00:00
|
|
|
NSString *drawerPath = [bundle pathForImageResource: @"Drawer"];
|
|
|
|
NSImage *drawerImage = [[NSImage alloc] initWithContentsOfFile: drawerPath];
|
|
|
|
NSFont *systemFont = [NSFont boldSystemFontOfSize: [NSFont systemFontSize]];
|
2004-07-12 04:16:09 +00:00
|
|
|
RELEASE(originalWindow);
|
2006-09-13 03:12:59 +00:00
|
|
|
originalWindow = [[NSWindow alloc] initWithContentRect:
|
|
|
|
NSMakeRect(0, 0, 272, 192)
|
|
|
|
styleMask: NSBorderlessWindowMask
|
|
|
|
backing: NSBackingStoreRetained
|
|
|
|
defer: NO];
|
2019-12-22 23:46:59 +00:00
|
|
|
[originalWindow setTitle: @"Windows"];
|
2004-07-12 04:16:09 +00:00
|
|
|
contents = [originalWindow contentView];
|
1999-12-16 21:41:21 +00:00
|
|
|
|
2005-06-17 11:52:30 +00:00
|
|
|
w = [[GormWindowMaker alloc] init];
|
2006-09-13 03:12:59 +00:00
|
|
|
v = [[NSButton alloc] initWithFrame: NSMakeRect(35, 100, 80, 64)];
|
|
|
|
[v setFont: systemFont];
|
1999-12-16 21:41:21 +00:00
|
|
|
[v setBordered: NO];
|
|
|
|
[v setImage: dragImage];
|
|
|
|
[v setImagePosition: NSImageOverlaps];
|
|
|
|
[v setTitle: @"Window"];
|
|
|
|
[contents addSubview: v];
|
|
|
|
[self associateObject: w
|
2005-08-06 17:59:08 +00:00
|
|
|
type: IBWindowPboardType
|
|
|
|
with: v];
|
1999-12-16 21:41:21 +00:00
|
|
|
RELEASE(v);
|
|
|
|
RELEASE(w);
|
|
|
|
|
2005-06-17 11:52:30 +00:00
|
|
|
w = [[GormPanelMaker alloc] init];
|
2006-09-13 03:12:59 +00:00
|
|
|
v = [[NSButton alloc] initWithFrame: NSMakeRect(155, 100, 80, 64)];
|
|
|
|
[v setFont: systemFont];
|
1999-12-16 21:41:21 +00:00
|
|
|
[v setBordered: NO];
|
|
|
|
[v setImage: dragImage];
|
|
|
|
[v setImagePosition: NSImageOverlaps];
|
|
|
|
[v setTitle: @"Panel"];
|
|
|
|
[contents addSubview: v];
|
|
|
|
[self associateObject: w
|
2005-08-06 17:59:08 +00:00
|
|
|
type: IBWindowPboardType
|
|
|
|
with: v];
|
1999-12-16 21:41:21 +00:00
|
|
|
RELEASE(v);
|
|
|
|
RELEASE(w);
|
|
|
|
|
2006-09-13 03:12:59 +00:00
|
|
|
w = [[NSDrawer alloc] init];
|
|
|
|
v = [[NSButton alloc] initWithFrame: NSMakeRect(95, 30, 80, 64)];
|
|
|
|
[v setFont: systemFont];
|
|
|
|
[v setBordered: NO];
|
|
|
|
[v setImage: drawerImage];
|
|
|
|
[v setImagePosition: NSImageOverlaps];
|
|
|
|
[v setTitle: @"Drawer"];
|
|
|
|
[contents addSubview: v];
|
|
|
|
[self associateObject: w
|
|
|
|
type: IBObjectPboardType
|
|
|
|
with: v];
|
|
|
|
RELEASE(v);
|
|
|
|
RELEASE(w);
|
|
|
|
|
1999-12-16 21:41:21 +00:00
|
|
|
RELEASE(dragImage);
|
2006-09-13 03:12:59 +00:00
|
|
|
RELEASE(drawerImage);
|
1999-12-16 21:41:21 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2002-02-18 12:37:26 +00:00
|
|
|
@implementation NSWindow (GormPrivate)
|
|
|
|
+ (id) allocSubstitute
|
|
|
|
{
|
|
|
|
return [GormNSWindow alloc];
|
|
|
|
}
|
|
|
|
@end
|
2002-11-13 16:10:22 +00:00
|
|
|
|
2005-07-31 23:07:30 +00:00
|
|
|
@implementation NSPanel (GormPrivate)
|
|
|
|
+ (id) allocSubstitute
|
|
|
|
{
|
|
|
|
return [GormNSPanel alloc];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|