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) {
|
|
|
|
if(widget.state.abstract) enabled = false;
|
|
|
|
if(sizable.state.layout && sizable.state.layout->enabled() == false) enabled = false;
|
|
|
|
|
|
|
|
@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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pWidget::setVisible(bool visible) {
|
|
|
|
if(widget.state.abstract) visible = false;
|
|
|
|
if(sizable.state.layout && sizable.state.layout->visible() == false) visible = false;
|
|
|
|
|
|
|
|
@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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|