The stepper and slider controls do not have a direct tag representation in gsmarkup, but using the control tag with the instanceOf attribute, the Renaissance library will create these controls. As the saying goes, an example is worth a thousand man pages:
Adjustments.gsmarkup
<?xml version="1.0"?>
<!DOCTYPE gsmarkup>
<gsmarkup>
<objects>
<window title="Image Adjustments" id="WindowAdjustments" delegate="#NSOwner">
<vbox>
<box title="Brightness"><hbox>
<control instanceOf="NSSlider" id="SliderBrightness" action="setBrightnessViaSlider:" height="28" width="256" />
<textField id="TextBrightness" action="setBrightnessViaText:">000</textField>
<control instanceOf="NSStepper" id="StepperBrightness" action="setBrightnessViaStepper:" height="28" width="18" />
</hbox></box>
</vbox>
</window>
</objects>
<connectors>
<outlet source="#NSOwner" target="#SliderBrightness" key="SliderBrightness" />
<outlet source="#NSOwner" target="#TextBrightness" key="TextBrightness" />
<outlet source="#NSOwner" target="#StepperBrightness" key="StepperBrightness" />
</connectors>
</gsmarkup>
Adjustments.h
#import <AppKit/AppKit.h>
#import <Renaissance/Renaissance.h>
@interface Adjustments : NSObject
{
IBOutlet NSSlider *SliderBrightness;
IBOutlet NSTextField *TextBrightness;
IBOutlet NSStepper *StepperBrightness;
}
- (id) init;
- (void) dealloc;
- (void) setAdjustmentsDefaults;
- (void) setBrightnessViaSlider: (id)sender;
- (void) setBrightnessViaText: (id)sender;
- (void) setBrightnessViaStepper: (id)sender;
@end
Adjustments.m
#import <Adjustments.h>
@implementation Adjustments
- (id)init
{
if ((self = [super init]))
{
[NSBundle loadGSMarkupNamed:@"Adjustments" owner:self];
[self setAdjustmentsDefaults];
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void) setAdjustmentsDefaults
{
[SliderBrightness setMaxValue: 255];
[SliderBrightness setMinValue: 0];
[SliderBrightness setIntValue: 227];
[TextBrightness setIntValue: [SliderBrightness intValue]];
[StepperBrightness setMaxValue: [SliderBrightness maxValue]];
[StepperBrightness setMinValue:[SliderBrightness minValue]];
[StepperBrightness setIncrement: 1];
[StepperBrightness setIntValue: [SliderBrightness intValue]];
}
- (void) setBrightnessViaSlider: (id)sender
{
[StepperBrightness setIntValue: [SliderBrightness intValue]];
[TextBrightness setIntValue: [SliderBrightness intValue]];
}
- (void) setBrightnessViaText: (id)sender
{
[StepperBrightness setIntValue: [TextBrightness intValue]];
[SliderBrightness setIntValue: [TextBrightness intValue]];
}
- (void) setBrightnessViaStepper: (id)sender
{
[SliderBrightness setIntValue: [StepperBrightness intValue]];
[TextBrightness setIntValue: [StepperBrightness intValue]];
}
@end
No comments:
Post a Comment