2015-12-30 06:41:46 +00:00
|
|
|
#if defined(Hiro_HorizontalSlider)
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
@implementation CocoaHorizontalSlider : NSSlider
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
-(id) initWith:(hiro::mHorizontalSlider&)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];
|
2015-12-30 06:41:46 +00:00
|
|
|
horizontalSlider->doChange();
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
namespace hiro {
|
|
|
|
|
|
|
|
auto pHorizontalSlider::construct() -> void {
|
|
|
|
@autoreleasepool {
|
|
|
|
cocoaView = cocoaHorizontalSlider = [[CocoaHorizontalSlider alloc] initWith:self()];
|
|
|
|
pWidget::construct();
|
|
|
|
|
|
|
|
setLength(state().length);
|
|
|
|
setPosition(state().position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pHorizontalSlider::destruct() -> void {
|
|
|
|
@autoreleasepool {
|
2016-01-07 08:14:33 +00:00
|
|
|
[cocoaView removeFromSuperview];
|
2015-12-30 06:41:46 +00:00
|
|
|
[cocoaView release];
|
|
|
|
}
|
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pHorizontalSlider::minimumSize() const -> Size {
|
2013-04-09 13:31:46 +00:00
|
|
|
return {48, 20};
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pHorizontalSlider::setGeometry(Geometry geometry) -> void {
|
2013-04-09 13:31:46 +00:00
|
|
|
pWidget::setGeometry({
|
2015-12-30 06:41:46 +00:00
|
|
|
geometry.x() - 2, geometry.y(),
|
|
|
|
geometry.width() + 4, geometry.height()
|
2013-04-09 13:31:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pHorizontalSlider::setLength(uint length) -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setMaxValue:length];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
auto pHorizontalSlider::setPosition(uint position) -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setDoubleValue:position];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-30 06:41:46 +00:00
|
|
|
#endif
|