2013-03-15 13:11:33 +00:00
|
|
|
@implementation CocoaHorizontalSlider : NSSlider
|
|
|
|
|
2013-03-21 12:59:01 +00:00
|
|
|
-(id) initWith:(phoenix::HorizontalSlider&)horizontalSliderReference {
|
2013-03-15 13:11:33 +00:00
|
|
|
if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) {
|
|
|
|
horizontalSlider = &horizontalSliderReference;
|
|
|
|
|
|
|
|
[self setTarget:self];
|
|
|
|
[self setAction:@selector(activate:)];
|
|
|
|
[self setMinValue:0];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2013-03-21 12:59:01 +00:00
|
|
|
-(IBAction) activate:(id)sender {
|
2013-03-15 13:11:33 +00:00
|
|
|
horizontalSlider->state.position = [self doubleValue];
|
|
|
|
if(horizontalSlider->onChange) horizontalSlider->onChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
namespace phoenix {
|
|
|
|
|
|
|
|
Size pHorizontalSlider::minimumSize() {
|
2013-04-09 13:31:46 +00:00
|
|
|
return {48, 20};
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned pHorizontalSlider::position() {
|
|
|
|
@autoreleasepool {
|
|
|
|
return [cocoaView doubleValue];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
void pHorizontalSlider::setGeometry(Geometry geometry) {
|
2013-04-09 13:31:46 +00:00
|
|
|
pWidget::setGeometry({
|
|
|
|
geometry.x - 2, geometry.y,
|
|
|
|
geometry.width + 4, geometry.height
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
void pHorizontalSlider::setLength(unsigned length) {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setMaxValue:length];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHorizontalSlider::setPosition(unsigned position) {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setDoubleValue:position];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHorizontalSlider::constructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
cocoaView = cocoaHorizontalSlider = [[CocoaHorizontalSlider alloc] initWith:horizontalSlider];
|
|
|
|
|
|
|
|
setLength(horizontalSlider.state.length);
|
|
|
|
setPosition(horizontalSlider.state.position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pHorizontalSlider::destructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|