| 1 |
@implementation CocoaHorizontalSlider : NSSlider |
| 2 |
|
| 3 |
-(id) initWith:(phoenix::HorizontalSlider&)horizontalSliderReference { |
| 4 |
if(self = [super initWithFrame:NSMakeRect(0, 0, 1, 0)]) { |
| 5 |
horizontalSlider = &horizontalSliderReference; |
| 6 |
|
| 7 |
[self setTarget:self]; |
| 8 |
[self setAction:@selector(activate:)]; |
| 9 |
[self setMinValue:0]; |
| 10 |
} |
| 11 |
return self; |
| 12 |
} |
| 13 |
|
| 14 |
-(IBAction) activate:(id)sender { |
| 15 |
horizontalSlider->state.position = [self doubleValue]; |
| 16 |
if(horizontalSlider->onChange) horizontalSlider->onChange(); |
| 17 |
} |
| 18 |
|
| 19 |
@end |
| 20 |
|
| 21 |
namespace phoenix { |
| 22 |
|
| 23 |
Size pHorizontalSlider::minimumSize() { |
| 24 |
return {48, 20}; |
| 25 |
} |
| 26 |
|
| 27 |
void pHorizontalSlider::setGeometry(Geometry geometry) { |
| 28 |
pWidget::setGeometry({ |
| 29 |
geometry.x - 2, geometry.y, |
| 30 |
geometry.width + 4, geometry.height |
| 31 |
}); |
| 32 |
} |
| 33 |
|
| 34 |
void pHorizontalSlider::setLength(unsigned length) { |
| 35 |
@autoreleasepool { |
| 36 |
[cocoaView setMaxValue:length]; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
void pHorizontalSlider::setPosition(unsigned position) { |
| 41 |
@autoreleasepool { |
| 42 |
[cocoaView setDoubleValue:position]; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
void pHorizontalSlider::constructor() { |
| 47 |
@autoreleasepool { |
| 48 |
cocoaView = cocoaHorizontalSlider = [[CocoaHorizontalSlider alloc] initWith:horizontalSlider]; |
| 49 |
|
| 50 |
setLength(horizontalSlider.state.length); |
| 51 |
setPosition(horizontalSlider.state.position); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
void pHorizontalSlider::destructor() { |
| 56 |
@autoreleasepool { |
| 57 |
[cocoaView release]; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
} |