2013-03-15 13:11:33 +00:00
|
|
|
@implementation CocoaVerticalSlider : NSSlider
|
|
|
|
|
2013-03-21 12:59:01 +00:00
|
|
|
-(id) initWith:(phoenix::VerticalSlider&)verticalSliderReference {
|
2013-03-15 13:11:33 +00:00
|
|
|
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 1)]) {
|
|
|
|
verticalSlider = &verticalSliderReference;
|
|
|
|
|
|
|
|
[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
|
|
|
verticalSlider->state.position = [self doubleValue];
|
|
|
|
if(verticalSlider->onChange) verticalSlider->onChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
namespace phoenix {
|
|
|
|
|
|
|
|
Size pVerticalSlider::minimumSize() {
|
2013-04-09 13:31:46 +00:00
|
|
|
return {20, 48};
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned pVerticalSlider::position() {
|
|
|
|
@autoreleasepool {
|
|
|
|
return [cocoaView doubleValue];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void pVerticalSlider::setGeometry(const Geometry& geometry) {
|
2013-04-09 13:31:46 +00:00
|
|
|
pWidget::setGeometry({
|
|
|
|
geometry.x, geometry.y - 2,
|
|
|
|
geometry.width, geometry.height + 4
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
void pVerticalSlider::setLength(unsigned length) {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setMaxValue:length];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pVerticalSlider::setPosition(unsigned position) {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setDoubleValue:position];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pVerticalSlider::constructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
cocoaView = cocoaVerticalSlider = [[CocoaVerticalSlider alloc] initWith:verticalSlider];
|
|
|
|
|
|
|
|
setLength(verticalSlider.state.length);
|
|
|
|
setPosition(verticalSlider.state.position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pVerticalSlider::destructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|