Added NSStepper in the controls' palette.

Added an attributes inspector for NSStepper.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@10741 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2001-08-20 11:09:20 +00:00
parent f36b66a949
commit d80513ff6a
5 changed files with 220 additions and 2 deletions

View file

@ -27,8 +27,10 @@ PALETTE_NAME = 2Controls
2Controls_PALETTE_ICON = ControlsPalette
2Controls_OBJC_FILES = main.m inspectors.m
2Controls_PRINCIPAL_CLASS = ControlsPalette
2Controls_RESOURCE_FILES = ControlsPalette.tiff \
GormSliderInspector.gorm
GormSliderInspector.gorm \
GormStepperInspector.gorm
-include GNUmakefile.preamble

View file

@ -0,0 +1,70 @@
{
GormStepperAttributesInspector = {
Actions = (
"ok:",
"revert:"
);
Outlets = (
autorepeatButton,
incrementValueField,
maximumValueField,
minimumValueField,
valueField,
valueWrapsButton,
window
);
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;
};
}

Binary file not shown.

View file

@ -122,3 +122,144 @@
}
@end
@implementation NSStepper (IBInspectorClassNames)
- (NSString*) inspectorClassName
{
return @"GormStepperAttributesInspector";
}
- (NSString*) sizeInspectorClassName
{
return nil;
}
@end
@interface GormStepperAttributesInspector : IBInspector
{
NSTextField *valueField;
NSTextField *minimumValueField;
NSTextField *maximumValueField;
NSTextField *incrementValueField;
NSButton *autorepeatButton;
NSButton *valueWrapsButton;
}
@end
@implementation GormStepperAttributesInspector
- (void) _setValuesFromControl: control
{
if (control == valueField)
{
[object setDoubleValue:[control doubleValue]];
[object setNeedsDisplay: YES];
}
else if (control == minimumValueField)
{
[object setMinValue:[control doubleValue]];
[object setNeedsDisplay: YES];
}
else if (control == maximumValueField)
{
[object setMaxValue:[control doubleValue]];
[object setNeedsDisplay: YES];
}
else if (control == incrementValueField)
{
[object setIncrement:[control doubleValue]];
[object setNeedsDisplay: YES];
}
else if (control == autorepeatButton)
{
switch ([control state])
{
case 0:
[object setAutorepeat: NO];
break;
case 1:
[object setAutorepeat: YES];
break;
}
}
else if (control == valueWrapsButton)
{
switch ([control state])
{
case 0:
[object setValueWraps: NO];
break;
case 1:
[object setValueWraps: YES];
break;
}
}
}
- (void) _getValuesFromObject: anObject
{
if (anObject != object)
return;
[valueField setDoubleValue: [anObject doubleValue]];
[minimumValueField setDoubleValue: [anObject minValue]];
[maximumValueField setDoubleValue: [anObject maxValue]];
if ([object autorepeat])
[autorepeatButton setState: 1];
else
[autorepeatButton setState: 0];
if ([object valueWraps])
[valueWrapsButton setState: 1];
else
[valueWrapsButton setState: 0];
}
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
{
id notifier = [aNotification object];
[self _setValuesFromControl: notifier];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(window);
[super dealloc];
}
- (id) init
{
if ([super init] == nil)
return nil;
if ([NSBundle loadNibNamed: @"GormStepperInspector" owner: self] == NO)
{
NSLog(@"Could not gorm GormStepperAttributesInspector");
return nil;
}
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(controlTextDidEndEditing:)
name: NSControlTextDidEndEditingNotification
object: nil];
return self;
}
- (void) ok: (id)sender
{
[self _setValuesFromControl: valueField];
[self _setValuesFromControl: minimumValueField];
[self _setValuesFromControl: maximumValueField];
[self _setValuesFromControl: incrementValueField];
[self _setValuesFromControl: autorepeatButton];
[self _setValuesFromControl: valueWrapsButton];
}
- (void) setObject: (id)anObject
{
[super setObject: anObject];
[self _getValuesFromObject: anObject];
}
@end

View file

@ -152,6 +152,11 @@
[contents addSubview: v];
RELEASE(v);
// Stepper
v = [[NSStepper alloc] initWithFrame: NSMakeRect(172, 56, 40, 23)];
[contents addSubview: v];
RELEASE(v);
// TODO: Add CustomView as soon as I figure out how it works.
}
@end
@end