1999-12-16 21:41:21 +00:00
|
|
|
|
/* main.m
|
|
|
|
|
|
|
|
|
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(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
|
|
|
|
*/
|
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
|
#include <AppKit/AppKit.h>
|
2005-06-04 11:46:43 +00:00
|
|
|
|
#include <GNUstepGUI/GSNibTemplates.h>
|
2004-12-31 13:21:30 +00:00
|
|
|
|
#include <InterfaceBuilder/IBPalette.h>
|
|
|
|
|
#include <InterfaceBuilder/IBInspector.h>
|
|
|
|
|
#include <InterfaceBuilder/IBApplicationAdditions.h>
|
2005-03-31 03:01:36 +00:00
|
|
|
|
#include <GormCore/GormDocument.h>
|
|
|
|
|
#include <GormCore/NSColorWell+GormExtensions.h>
|
2002-02-18 12:37:26 +00:00
|
|
|
|
#include "GormNSWindow.h"
|
2003-01-05 06:03:14 +00:00
|
|
|
|
#include "GormNSPanel.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
|
|
|
|
|
{
|
|
|
|
|
id w;
|
|
|
|
|
unsigned style = NSTitledWindowMask | NSClosableWindowMask
|
|
|
|
|
| NSResizableWindowMask | NSMiniaturizableWindowMask;
|
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);
|
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];
|
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
|
|
|
|
|
|
|
|
|
|
@interface WindowsPalette: IBPalette
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
@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];
|
|
|
|
|
|
2004-07-12 04:16:09 +00:00
|
|
|
|
RELEASE(originalWindow);
|
|
|
|
|
originalWindow= [[NSWindow alloc] initWithContentRect:
|
|
|
|
|
NSMakeRect(0, 0, 272, 192)
|
1999-12-16 21:41:21 +00:00
|
|
|
|
styleMask: NSBorderlessWindowMask
|
|
|
|
|
backing: NSBackingStoreRetained
|
|
|
|
|
defer: NO];
|
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];
|
1999-12-16 21:41:21 +00:00
|
|
|
|
v = [[NSButton alloc] initWithFrame: NSMakeRect(35, 60, 80, 64)];
|
|
|
|
|
[v setBordered: NO];
|
|
|
|
|
[v setImage: dragImage];
|
|
|
|
|
[v setImagePosition: NSImageOverlaps];
|
|
|
|
|
[v setTitle: @"Window"];
|
|
|
|
|
[contents addSubview: v];
|
|
|
|
|
[self associateObject: w
|
|
|
|
|
type: IBWindowPboardType
|
|
|
|
|
with: v];
|
|
|
|
|
RELEASE(v);
|
|
|
|
|
RELEASE(w);
|
|
|
|
|
|
2005-06-17 11:52:30 +00:00
|
|
|
|
w = [[GormPanelMaker alloc] init];
|
1999-12-16 21:41:21 +00:00
|
|
|
|
v = [[NSButton alloc] initWithFrame: NSMakeRect(155, 60, 80, 64)];
|
|
|
|
|
[v setBordered: NO];
|
|
|
|
|
[v setImage: dragImage];
|
|
|
|
|
[v setImagePosition: NSImageOverlaps];
|
|
|
|
|
[v setTitle: @"Panel"];
|
|
|
|
|
[contents addSubview: v];
|
|
|
|
|
[self associateObject: w
|
|
|
|
|
type: IBWindowPboardType
|
|
|
|
|
with: v];
|
|
|
|
|
RELEASE(v);
|
|
|
|
|
RELEASE(w);
|
|
|
|
|
|
|
|
|
|
RELEASE(dragImage);
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
2005-07-31 23:07:30 +00:00
|
|
|
|
/*---------------------------------------------------------
|
|
|
|
|
// NSWindow inspector
|
|
|
|
|
---------------------------------------------------------*/
|
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
|
|
|
|
|
|
2003-09-28 23:31:35 +00:00
|
|
|
|
// the normal classes...
|
|
|
|
|
@implementation NSWindow (IBInspectorClassNames)
|
|
|
|
|
- (NSString*) inspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowAttributesInspector";
|
|
|
|
|
}
|
|
|
|
|
- (NSString*) sizeInspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowSizeInspector";
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSPanel (IBInspectorClassNames)
|
|
|
|
|
- (NSString*) inspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowAttributesInspector";
|
|
|
|
|
}
|
|
|
|
|
- (NSString*) sizeInspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowSizeInspector";
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// special subclasses...
|
2002-02-18 12:37:26 +00:00
|
|
|
|
@implementation GormNSWindow (IBInspectorClassNames)
|
1999-12-16 21:41:21 +00:00
|
|
|
|
- (NSString*) inspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowAttributesInspector";
|
|
|
|
|
}
|
2001-06-18 23:04:20 +00:00
|
|
|
|
- (NSString*) sizeInspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowSizeInspector";
|
|
|
|
|
}
|
1999-12-16 21:41:21 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2003-01-05 06:03:14 +00:00
|
|
|
|
@implementation GormNSPanel (IBInspectorClassNames)
|
2003-01-04 00:17:43 +00:00
|
|
|
|
- (NSString*) inspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowAttributesInspector";
|
|
|
|
|
}
|
|
|
|
|
- (NSString*) sizeInspectorClassName
|
|
|
|
|
{
|
|
|
|
|
return @"GormWindowSizeInspector";
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
1999-12-16 21:41:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface GormWindowAttributesInspector : IBInspector
|
2000-01-03 11:00:14 +00:00
|
|
|
|
{
|
2001-10-27 20:22:59 +00:00
|
|
|
|
id titleForm;
|
|
|
|
|
id backingMatrix;
|
|
|
|
|
id optionMatrix;
|
|
|
|
|
id controlMatrix;
|
2004-12-31 19:26:21 +00:00
|
|
|
|
id iconNameForm;
|
|
|
|
|
id clearButton;
|
2005-01-28 05:41:55 +00:00
|
|
|
|
id colorWell;
|
2000-01-03 11:00:14 +00:00
|
|
|
|
}
|
1999-12-16 21:41:21 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GormWindowAttributesInspector
|
2000-01-05 17:06:48 +00:00
|
|
|
|
|
2005-07-07 12:45:45 +00:00
|
|
|
|
/* delegate method for changing the Window title */
|
|
|
|
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self ok:[aNotification object]];
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-27 20:22:59 +00:00
|
|
|
|
- (void) _setValuesFromControl: control
|
|
|
|
|
{
|
|
|
|
|
if (control == titleForm)
|
|
|
|
|
{
|
|
|
|
|
[object setTitle: [[control cellAtIndex: 0] stringValue] ];
|
|
|
|
|
}
|
2004-12-31 19:26:21 +00:00
|
|
|
|
else if (control == iconNameForm)
|
|
|
|
|
{
|
|
|
|
|
NSString *string = [[control cellAtIndex: 0] stringValue];
|
|
|
|
|
NSImage *image;
|
|
|
|
|
|
|
|
|
|
if ([string length] > 0)
|
|
|
|
|
{
|
|
|
|
|
image = [NSImage imageNamed: string];
|
|
|
|
|
[object setMiniwindowImage: image];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// use the default, if the string is empty.
|
|
|
|
|
[object setMiniwindowImage: nil];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (control == clearButton)
|
|
|
|
|
{
|
|
|
|
|
[[iconNameForm cellAtIndex: 0] setStringValue: nil];
|
|
|
|
|
[object setMiniwindowImage: nil];
|
|
|
|
|
}
|
2001-10-27 20:22:59 +00:00
|
|
|
|
else if (control == backingMatrix)
|
|
|
|
|
{
|
|
|
|
|
[object setBackingType: [[control selectedCell] tag] ];
|
|
|
|
|
}
|
|
|
|
|
else if (control == controlMatrix)
|
|
|
|
|
{
|
|
|
|
|
unsigned int newStyleMask;
|
|
|
|
|
int rows,cols,i;
|
|
|
|
|
|
|
|
|
|
[control getNumberOfRows:&rows columns:&cols];
|
|
|
|
|
|
2004-08-23 19:03:20 +00:00
|
|
|
|
newStyleMask = [object _styleMask];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
for (i=0;i<rows;i++) {
|
|
|
|
|
if ([[control cellAtRow: i column: 0] state] == NSOnState)
|
|
|
|
|
newStyleMask |= [[control cellAtRow: i column: 0] tag];
|
|
|
|
|
else
|
|
|
|
|
newStyleMask &= ~[[control cellAtRow: i column: 0] tag];
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-23 19:03:20 +00:00
|
|
|
|
[object _setStyleMask: newStyleMask];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
[object display];
|
|
|
|
|
}
|
2005-01-28 05:41:55 +00:00
|
|
|
|
else if (control == colorWell)
|
|
|
|
|
{
|
|
|
|
|
[object setBackgroundColor: [colorWell color]];
|
|
|
|
|
}
|
2001-10-27 20:22:59 +00:00
|
|
|
|
else if (control == optionMatrix)
|
|
|
|
|
{
|
|
|
|
|
BOOL flag;
|
2004-12-31 19:26:21 +00:00
|
|
|
|
GormDocument *doc = (GormDocument*)[(id<IB>)NSApp activeDocument];
|
|
|
|
|
|
2001-10-27 20:22:59 +00:00
|
|
|
|
// Release When Closed
|
|
|
|
|
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO;
|
2004-07-21 01:49:07 +00:00
|
|
|
|
[object _setReleasedWhenClosed: flag];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
|
|
|
|
|
// Hide on deactivate
|
|
|
|
|
flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO;
|
|
|
|
|
[object setHidesOnDeactivate: flag];
|
|
|
|
|
|
2004-12-31 19:26:21 +00:00
|
|
|
|
// Visible at launch time. (not an object property. Stored in a Gorm dictionary)
|
2001-10-27 20:22:59 +00:00
|
|
|
|
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
|
2004-12-31 19:26:21 +00:00
|
|
|
|
[doc setObject: object isVisibleAtLaunch: flag];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
|
|
|
|
|
// Deferred
|
|
|
|
|
flag = ([[control cellAtRow: 3 column: 0] state] == NSOnState) ? YES : NO;
|
2004-12-31 19:26:21 +00:00
|
|
|
|
[doc setObject: object isDeferred: flag];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
|
|
|
|
|
// One shot
|
2003-01-05 06:03:14 +00:00
|
|
|
|
flag = ([[control cellAtRow: 4 column: 0] state] == NSOnState) ? YES : NO;
|
|
|
|
|
[object setOneShot: flag];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
|
|
|
|
|
// Dynamic depth limit
|
2003-01-05 06:03:14 +00:00
|
|
|
|
flag = ([[control cellAtRow: 5 column: 0] state] == NSOnState) ? YES : NO;
|
|
|
|
|
[object setDynamicDepthLimit: flag];
|
|
|
|
|
|
|
|
|
|
// wants to be color
|
|
|
|
|
// FIXME: probably means window depth > 2 bits per pixel but don't know
|
2004-12-31 19:26:21 +00:00
|
|
|
|
// exactly what NSWindow method to use to enforce that.
|
2003-01-05 06:03:14 +00:00
|
|
|
|
flag = ([[control cellAtRow: 6 column: 0] state] == NSOnState) ? YES : NO;
|
2001-10-27 20:22:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) _getValuesFromObject: anObject
|
|
|
|
|
{
|
2004-12-31 19:26:21 +00:00
|
|
|
|
GormDocument *doc = (GormDocument*)[(id<IB>)NSApp activeDocument];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
if (anObject != object)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
[[titleForm cellAtIndex: 0] setStringValue: [anObject title] ];
|
|
|
|
|
|
|
|
|
|
[backingMatrix selectCellWithTag: [anObject backingType] ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[controlMatrix deselectAllCells];
|
2004-08-23 19:03:20 +00:00
|
|
|
|
if ([anObject _styleMask] & NSMiniaturizableWindowMask)
|
2001-10-27 20:22:59 +00:00
|
|
|
|
[controlMatrix selectCellAtRow: 0 column: 0];
|
2004-08-23 19:03:20 +00:00
|
|
|
|
if ([anObject _styleMask] & NSClosableWindowMask)
|
2001-10-27 20:22:59 +00:00
|
|
|
|
[controlMatrix selectCellAtRow: 1 column: 0];
|
2004-08-23 19:03:20 +00:00
|
|
|
|
if ([anObject _styleMask] & NSResizableWindowMask)
|
2001-10-27 20:22:59 +00:00
|
|
|
|
[controlMatrix selectCellAtRow: 2 column: 0];
|
|
|
|
|
|
|
|
|
|
[optionMatrix deselectAllCells];
|
2004-07-21 01:49:07 +00:00
|
|
|
|
if ([anObject _isReleasedWhenClosed])
|
2001-10-27 20:22:59 +00:00
|
|
|
|
[optionMatrix selectCellAtRow: 0 column: 0];
|
|
|
|
|
if ([anObject hidesOnDeactivate])
|
|
|
|
|
[optionMatrix selectCellAtRow: 1 column: 0];
|
2003-01-16 04:09:07 +00:00
|
|
|
|
|
|
|
|
|
// visible at launch time.
|
2004-12-31 19:26:21 +00:00
|
|
|
|
if ([doc objectIsVisibleAtLaunch: anObject])
|
|
|
|
|
{
|
|
|
|
|
[optionMatrix selectCellAtRow: 2 column: 0];
|
|
|
|
|
}
|
2001-10-27 20:22:59 +00:00
|
|
|
|
|
2003-01-16 04:09:07 +00:00
|
|
|
|
// defer comes here.
|
2004-12-31 19:26:21 +00:00
|
|
|
|
if ([doc objectIsDeferred: anObject])
|
|
|
|
|
{
|
|
|
|
|
[optionMatrix selectCellAtRow: 3 column: 0];
|
|
|
|
|
}
|
2001-10-27 20:22:59 +00:00
|
|
|
|
|
|
|
|
|
if ([anObject isOneShot])
|
|
|
|
|
[optionMatrix selectCellAtRow: 4 column: 0];
|
|
|
|
|
|
|
|
|
|
if ([anObject hasDynamicDepthLimit])
|
|
|
|
|
[optionMatrix selectCellAtRow: 5 column: 0];
|
|
|
|
|
|
2004-12-31 19:26:21 +00:00
|
|
|
|
// icon name
|
|
|
|
|
[[iconNameForm cellAtIndex: 0] setStringValue: [[object miniwindowImage] name]];
|
2005-01-28 05:41:55 +00:00
|
|
|
|
|
|
|
|
|
// background color
|
|
|
|
|
[colorWell setColorWithoutAction: [object backgroundColor]];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-05 06:03:14 +00:00
|
|
|
|
- (void) _validate: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
id cell = [controlMatrix cellAtRow: 0 column: 0];
|
|
|
|
|
// Assumed to be the "miniaturize" cell.
|
|
|
|
|
// panels should not be allowed to miniaturize the app.
|
|
|
|
|
|
|
|
|
|
if([anObject isKindOfClass: [NSPanel class]])
|
|
|
|
|
{
|
|
|
|
|
[cell setEnabled: NO];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[cell setEnabled: YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-16 21:41:21 +00:00
|
|
|
|
- (id) init
|
|
|
|
|
{
|
2002-03-06 11:43:38 +00:00
|
|
|
|
if ([super init] == nil)
|
2001-10-27 20:22:59 +00:00
|
|
|
|
return nil;
|
|
|
|
|
|
2003-01-04 04:51:12 +00:00
|
|
|
|
if ([NSBundle loadNibNamed: @"GormNSWindowInspector" owner: self] == NO)
|
1999-12-16 21:41:21 +00:00
|
|
|
|
{
|
2003-01-04 04:51:12 +00:00
|
|
|
|
NSLog(@"Could not gorm GormNSWindowInspector");
|
2001-10-27 20:22:59 +00:00
|
|
|
|
return nil;
|
1999-12-16 21:41:21 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
2000-01-03 11:00:14 +00:00
|
|
|
|
|
|
|
|
|
- (void) ok: (id)sender
|
|
|
|
|
{
|
2005-01-28 05:41:55 +00:00
|
|
|
|
[super ok: sender];
|
|
|
|
|
[self _setValuesFromControl: sender];
|
2000-01-03 11:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setObject: (id)anObject
|
|
|
|
|
{
|
2003-01-05 06:03:14 +00:00
|
|
|
|
// Need to do something here to disable certain portions of
|
|
|
|
|
// the inspector if the object being edited is an NSPanel.
|
2000-01-03 11:00:14 +00:00
|
|
|
|
[super setObject: anObject];
|
2003-01-05 06:03:14 +00:00
|
|
|
|
// [self _validate: anObject];
|
2001-10-27 20:22:59 +00:00
|
|
|
|
[self _getValuesFromObject: anObject];
|
2000-01-03 11:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-16 21:41:21 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2001-06-18 23:04:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface GormWindowSizeInspector : IBInspector
|
|
|
|
|
{
|
|
|
|
|
NSForm *sizeForm;
|
|
|
|
|
NSForm *minForm;
|
2005-06-04 11:46:43 +00:00
|
|
|
|
NSForm *maxForm;
|
|
|
|
|
id top;
|
|
|
|
|
id bottom;
|
|
|
|
|
id left;
|
|
|
|
|
id right;
|
2001-06-18 23:04:20 +00:00
|
|
|
|
}
|
2005-06-04 11:46:43 +00:00
|
|
|
|
|
|
|
|
|
- (void) setAutoposition: (id)sender;
|
2001-06-18 23:04:20 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GormWindowSizeInspector
|
|
|
|
|
|
2005-07-07 12:45:45 +00:00
|
|
|
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
|
|
|
|
{
|
|
|
|
|
[self ok:[aNotification object]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-18 23:04:20 +00:00
|
|
|
|
- (void) _setValuesFromControl: control
|
|
|
|
|
{
|
|
|
|
|
if (control == sizeForm)
|
|
|
|
|
{
|
|
|
|
|
NSRect rect;
|
|
|
|
|
rect = NSMakeRect([[control cellAtIndex: 0] floatValue],
|
|
|
|
|
[[control cellAtIndex: 1] floatValue],
|
|
|
|
|
[[control cellAtIndex: 2] floatValue],
|
|
|
|
|
[[control cellAtIndex: 3] floatValue]);
|
|
|
|
|
[object setFrame: rect display: YES];
|
|
|
|
|
}
|
|
|
|
|
else if (control == minForm)
|
|
|
|
|
{
|
|
|
|
|
NSSize size;
|
|
|
|
|
size = NSMakeSize([[minForm cellAtIndex: 0] floatValue],
|
|
|
|
|
[[minForm cellAtIndex: 1] floatValue]);
|
|
|
|
|
[object setMinSize: size];
|
|
|
|
|
}
|
2005-06-04 11:46:43 +00:00
|
|
|
|
else if (control == maxForm)
|
|
|
|
|
{
|
|
|
|
|
NSSize size;
|
|
|
|
|
size = NSMakeSize([[maxForm cellAtIndex: 0] floatValue],
|
|
|
|
|
[[maxForm cellAtIndex: 1] floatValue]);
|
|
|
|
|
[object setMaxSize: size];
|
|
|
|
|
}
|
2001-06-18 23:04:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _getValuesFromObject: anObject
|
|
|
|
|
{
|
|
|
|
|
NSRect frame;
|
|
|
|
|
NSSize size;
|
2005-06-04 11:46:43 +00:00
|
|
|
|
unsigned int mask = [object autoPositionMask];
|
2001-06-18 23:04:20 +00:00
|
|
|
|
|
|
|
|
|
if (anObject != object)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
frame = [anObject frame];
|
|
|
|
|
[[sizeForm cellAtIndex: 0] setFloatValue: NSMinX(frame)];
|
|
|
|
|
[[sizeForm cellAtIndex: 1] setFloatValue: NSMinY(frame)];
|
|
|
|
|
[[sizeForm cellAtIndex: 2] setFloatValue: NSWidth(frame)];
|
|
|
|
|
[[sizeForm cellAtIndex: 3] setFloatValue: NSHeight(frame)];
|
|
|
|
|
|
|
|
|
|
size = [anObject minSize];
|
|
|
|
|
[[minForm cellAtIndex: 0] setFloatValue: size.width];
|
|
|
|
|
[[minForm cellAtIndex: 1] setFloatValue: size.height];
|
2005-06-04 11:46:43 +00:00
|
|
|
|
|
|
|
|
|
size = [anObject maxSize];
|
|
|
|
|
[[maxForm cellAtIndex: 0] setFloatValue: size.width];
|
|
|
|
|
[[maxForm cellAtIndex: 1] setFloatValue: size.height];
|
|
|
|
|
|
|
|
|
|
if (mask & GSWindowMaxYMargin)
|
|
|
|
|
[top setState: NSOnState];
|
|
|
|
|
else
|
|
|
|
|
[top setState: NSOffState];
|
|
|
|
|
|
|
|
|
|
if (mask & GSWindowMinYMargin)
|
|
|
|
|
[bottom setState: NSOnState];
|
|
|
|
|
else
|
|
|
|
|
[bottom setState: NSOffState];
|
|
|
|
|
|
|
|
|
|
if (mask & GSWindowMaxXMargin)
|
|
|
|
|
[right setState: NSOnState];
|
|
|
|
|
else
|
|
|
|
|
[right setState: NSOffState];
|
|
|
|
|
|
|
|
|
|
if (mask & GSWindowMinXMargin)
|
|
|
|
|
[left setState: NSOnState];
|
|
|
|
|
else
|
|
|
|
|
[left setState: NSOffState];
|
2001-06-18 23:04:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) windowChangeNotification: (NSNotification*)aNotification
|
|
|
|
|
{
|
|
|
|
|
id notifier = [aNotification object];
|
|
|
|
|
|
|
|
|
|
[self _getValuesFromObject: notifier];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
|
{
|
|
|
|
|
if ([super init] == nil)
|
|
|
|
|
return nil;
|
|
|
|
|
|
2003-01-04 04:51:12 +00:00
|
|
|
|
if ([NSBundle loadNibNamed: @"GormNSWindowSizeInspector" owner: self] == NO)
|
2001-06-18 23:04:20 +00:00
|
|
|
|
{
|
2003-01-04 04:51:12 +00:00
|
|
|
|
NSLog(@"Could not gorm GormNSWindowSizeInspector");
|
2001-06-18 23:04:20 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
|
addObserver: self
|
|
|
|
|
selector: @selector(windowChangeNotification:)
|
|
|
|
|
name: NSWindowDidMoveNotification
|
|
|
|
|
object: object];
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
|
addObserver: self
|
|
|
|
|
selector: @selector(windowChangeNotification:)
|
|
|
|
|
name: NSWindowDidResizeNotification
|
|
|
|
|
object: object];
|
2005-06-04 11:46:43 +00:00
|
|
|
|
|
|
|
|
|
// set up tags...
|
|
|
|
|
[top setTag: GSWindowMaxYMargin];
|
|
|
|
|
[bottom setTag: GSWindowMinYMargin];
|
|
|
|
|
[left setTag: GSWindowMinXMargin];
|
|
|
|
|
[right setTag: GSWindowMaxXMargin];
|
|
|
|
|
|
2001-06-18 23:04:20 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) ok: (id)sender
|
|
|
|
|
{
|
2005-01-28 05:41:55 +00:00
|
|
|
|
[super ok: sender];
|
2001-06-18 23:04:20 +00:00
|
|
|
|
[self _setValuesFromControl: sizeForm];
|
|
|
|
|
[self _setValuesFromControl: minForm];
|
2005-06-04 11:46:43 +00:00
|
|
|
|
[self _setValuesFromControl: maxForm];
|
2001-06-18 23:04:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setObject: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
[super setObject: anObject];
|
|
|
|
|
[self _getValuesFromObject: anObject];
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-04 11:46:43 +00:00
|
|
|
|
- (void) setAutoposition: (id)sender
|
|
|
|
|
{
|
|
|
|
|
unsigned mask = [sender tag];
|
|
|
|
|
|
|
|
|
|
[super ok: sender];
|
|
|
|
|
if ([sender state] == NSOnState)
|
|
|
|
|
{
|
|
|
|
|
mask = [object autoPositionMask] | mask;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mask = [object autoPositionMask] & ~mask;
|
|
|
|
|
}
|
|
|
|
|
[object setAutoPositionMask: mask];
|
|
|
|
|
}
|
2001-06-18 23:04:20 +00:00
|
|
|
|
@end
|