mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
New window size inspector using gorm file
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@10204 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6bbf24ca8e
commit
042cc5c13e
6 changed files with 210 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2001-06-18 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* GormWindowEditor.m
|
||||
(-_validateFrame:forViewPtr:withEvent:update:update): Allow the frame
|
||||
to increase even if it's already too small.
|
||||
|
||||
* Palettes/1Windows/main.m: Implement GormWindowSizeInspector.
|
||||
* Palettes/1Windows/GormWindowSizeInspector.gorm: New file.
|
||||
* Palettes/1Windows/GormWindowSizeInspector.class: Likewise.
|
||||
|
||||
2001-06-15 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* GormWindowEditor.m (-_editTextView:withEvent:):
|
||||
|
|
|
@ -478,16 +478,22 @@ static BOOL done_editing;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSRect oldFrame = [view frame];
|
||||
/* Increase the cell size */
|
||||
cellSize = NSMakeSize((NSWidth(frame)+intercellSpace.width)/cols
|
||||
- intercellSpace.width,
|
||||
(NSHeight(frame)+intercellSpace.height)/rows
|
||||
- intercellSpace.height);
|
||||
/* Reasonable minimum size? - NSMatrix should do this? */
|
||||
if (cellSize.width < minSize.width)
|
||||
return NO;
|
||||
if (cellSize.height < minSize.height)
|
||||
return NO;
|
||||
/* Check if it is already too small and we're just making it bigger */
|
||||
if (NSWidth(frame) < NSWidth(oldFrame)
|
||||
&& NSHeight(frame) < NSHeight(oldFrame))
|
||||
{
|
||||
/* Reasonable minimum size? - NSMatrix should do this? */
|
||||
if (cellSize.width < minSize.width)
|
||||
return NO;
|
||||
if (cellSize.height < minSize.height)
|
||||
return NO;
|
||||
}
|
||||
if (update)
|
||||
[view setCellSize: cellSize];
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ PALETTE_NAME = 1Windows
|
|||
1Windows_PALETTE_ICON = WindowsPalette
|
||||
1Windows_OBJC_FILES = main.m
|
||||
1Windows_PRINCIPAL_CLASS = WindowsPalette
|
||||
1Windows_RESOURCE_FILES = WindowsPalette.tiff WindowDrag.tiff
|
||||
1Windows_RESOURCE_FILES = WindowsPalette.tiff WindowDrag.tiff \
|
||||
GormWindowSizeInspector.gorm
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
|
|
71
Palettes/1Windows/GormWindowSizeInspector.classes
Normal file
71
Palettes/1Windows/GormWindowSizeInspector.classes
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
GormWindowSizeInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
minForm,
|
||||
sizeForm,
|
||||
window
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
IBInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSApplication = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSButton = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSControl = {
|
||||
Actions = (
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:"
|
||||
);
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
NSMenu = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSMenuItem = {
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSResponder = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSSlider = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSTextField = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSControl;
|
||||
};
|
||||
NSView = {
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
BIN
Palettes/1Windows/GormWindowSizeInspector.gorm
Normal file
BIN
Palettes/1Windows/GormWindowSizeInspector.gorm
Normal file
Binary file not shown.
|
@ -59,8 +59,8 @@
|
|||
@implementation GormPanelMaker
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
id w;
|
||||
|
@ -133,6 +133,10 @@
|
|||
{
|
||||
return @"GormWindowAttributesInspector";
|
||||
}
|
||||
- (NSString*) sizeInspectorClassName
|
||||
{
|
||||
return @"GormWindowSizeInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
@ -247,3 +251,114 @@
|
|||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface GormWindowSizeInspector : IBInspector
|
||||
{
|
||||
NSForm *sizeForm;
|
||||
NSForm *minForm;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormWindowSizeInspector
|
||||
|
||||
- (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];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _getValuesFromObject: anObject
|
||||
{
|
||||
NSRect frame;
|
||||
NSSize size;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
id notifier = [aNotification object];
|
||||
[self _setValuesFromControl: notifier];
|
||||
}
|
||||
|
||||
- (void) windowChangeNotification: (NSNotification*)aNotification
|
||||
{
|
||||
id notifier = [aNotification object];
|
||||
|
||||
[self _getValuesFromObject: notifier];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(window);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([super init] == nil)
|
||||
return nil;
|
||||
|
||||
if ([NSBundle loadNibNamed: @"GormWindowSizeInspector" owner: self] == NO)
|
||||
{
|
||||
NSLog(@"Could not gorm GormWindowSizeInspector");
|
||||
return nil;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(windowChangeNotification:)
|
||||
name: NSWindowDidMoveNotification
|
||||
object: object];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(windowChangeNotification:)
|
||||
name: NSWindowDidResizeNotification
|
||||
object: object];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(controlTextDidEndEditing:)
|
||||
name: NSControlTextDidEndEditingNotification
|
||||
object: nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
[self _setValuesFromControl: sizeForm];
|
||||
[self _setValuesFromControl: minForm];
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[self _getValuesFromObject: anObject];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue