mirror of https://github.com/Airr/nim-cocoa.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
960 B
38 lines
960 B
#import <Cocoa/Cocoa.h>
|
|
#import "col.h"
|
|
|
|
@implementation CocoaSlider
|
|
{
|
|
|
|
}
|
|
@synthesize Value;
|
|
@synthesize sliderAction;
|
|
|
|
- (IBAction)onChanged:(id)sender{
|
|
self.Value = [sender intValue];
|
|
sliderAction(sender);
|
|
}
|
|
|
|
- (id) initWithFrame:(NSRect)rect callBack:(ACTION)callback {
|
|
self = [super initWithFrame: rect];
|
|
[self setMinValue:0];
|
|
[self setMaxValue:100];
|
|
[self setAllowsTickMarkValuesOnly:NO];
|
|
[self setNumberOfTickMarks:0];
|
|
[self setTickMarkPosition:1];
|
|
[self setTarget:self];
|
|
[self setContinuous: YES];
|
|
if (callback != NULL) {
|
|
[self setSliderAction: callback];
|
|
[self setAction: @selector(onChanged:)];
|
|
}
|
|
return self;
|
|
}
|
|
@end
|
|
|
|
id createSlider(id parent, int left, int top, int width, int height, ACTION callback) {
|
|
id widget = [[CocoaSlider alloc] initWithFrame:NSMakeRect(left, top, width, height) callBack:callback];
|
|
|
|
[[parent contentView] addSubview:widget];
|
|
return widget;
|
|
}
|
|
|