2013-03-15 13:11:33 +00:00
|
|
|
namespace phoenix {
|
|
|
|
|
|
|
|
bool pWidget::enabled() {
|
|
|
|
@autoreleasepool {
|
|
|
|
return [cocoaView respondsToSelector:@selector(enabled)] && [cocoaView enabled];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool pWidget::focused() {
|
|
|
|
@autoreleasepool {
|
|
|
|
return cocoaView == [[cocoaView window] firstResponder];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Size pWidget::minimumSize() {
|
|
|
|
return {0, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
void pWidget::setEnabled(bool enabled) {
|
2013-11-28 10:29:01 +00:00
|
|
|
if(!widget.parent()) enabled = false;
|
2013-03-15 13:11:33 +00:00
|
|
|
if(widget.state.abstract) enabled = false;
|
2013-11-28 10:29:01 +00:00
|
|
|
if(!widget.enabledToAll()) enabled = false;
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
@autoreleasepool {
|
|
|
|
if([cocoaView respondsToSelector:@selector(setEnabled:)]) {
|
|
|
|
[cocoaView setEnabled:enabled];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pWidget::setFocused() {
|
|
|
|
@autoreleasepool {
|
|
|
|
[[cocoaView window] makeFirstResponder:cocoaView];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
void pWidget::setFont(string font) {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
if([cocoaView respondsToSelector:@selector(setFont:)]) {
|
|
|
|
[cocoaView setFont:pFont::cocoaFont(font)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
void pWidget::setGeometry(Geometry geometry) {
|
2013-03-15 13:11:33 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
CGFloat windowHeight = [[cocoaView superview] frame].size.height;
|
|
|
|
[cocoaView setFrame:NSMakeRect(geometry.x, windowHeight - geometry.y - geometry.height, geometry.width, geometry.height)];
|
|
|
|
[[cocoaView superview] setNeedsDisplay:YES];
|
|
|
|
}
|
2013-11-28 10:29:01 +00:00
|
|
|
if(widget.onSize) widget.onSize();
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pWidget::setVisible(bool visible) {
|
2013-11-28 10:29:01 +00:00
|
|
|
if(!widget.parent()) visible = false;
|
2013-03-15 13:11:33 +00:00
|
|
|
if(widget.state.abstract) visible = false;
|
2013-11-28 10:29:01 +00:00
|
|
|
if(!widget.visibleToAll()) visible = false;
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView setHidden:!visible];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pWidget::constructor() {
|
|
|
|
if(!widget.state.abstract) return;
|
|
|
|
|
|
|
|
@autoreleasepool {
|
|
|
|
cocoaView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
|
|
|
[cocoaView setHidden:true];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pWidget::destructor() {
|
|
|
|
@autoreleasepool {
|
|
|
|
[cocoaView release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|