bsnes/hiro/cocoa/widget/radio-label.cpp
Tim Allen 47d4bd4d81 Update to v096r01 release.
byuu says:

Changelog:

- restructured the project and removed a whole bunch of old/dead
  directives from higan/GNUmakefile
- huge amounts of work on hiro/cocoa (compiles but ~70% of the
  functionality is commented out)
- fixed a masking error in my ARM CPU disassembler [Lioncash]
- SFC: decided to change board cic=(411,413) back to board
  region=(ntsc,pal) ... the former was too obtuse

If you rename Boolean (it's a problem with an include from ruby, not
from hiro) and disable all the ruby drivers, you can compile an
OS X binary, but obviously it's not going to do anything.

It's a boring WIP, I just wanted to push out the project structure
change now at the start of this WIP cycle.
2015-12-30 17:54:59 +11:00

82 lines
1.8 KiB
C++

#if defined(Hiro_RadioLabel)
@implementation CocoaRadioLabel : NSButton
-(id) initWith:(hiro::mRadioLabel&)radioLabelReference {
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
radioLabel = &radioLabelReference;
[self setTarget:self];
[self setAction:@selector(activate:)];
[self setButtonType:NSRadioButton];
}
return self;
}
-(IBAction) activate:(id)sender {
radioLabel->setChecked();
radioLabel->doActivate();
}
@end
namespace hiro {
auto pRadioLabel::construct() -> void {
@autoreleasepool {
cocoaView = cocoaRadioLabel = [[CocoaRadioLabel alloc] initWith:self()];
pWidget::construct();
if(state().checked) setChecked();
setText(state().text);
}
}
auto pRadioLabel::destruct() -> void {
@autoreleasepool {
[cocoaView release];
}
}
auto pRadioLabel::minimumSize() const -> Size {
Size size = pFont::size(self().font(true), state().text);
return {size.width() + 22, size.height()};
}
auto pRadioLabel::setChecked() -> void {
@autoreleasepool {
if(auto group = state().group) {
for(auto& weak : group->state.objects) {
if(auto object = weak.acquire()) {
if(auto self = object->self()) {
if(auto p = dynamic_cast<pRadioLabel*>(self)) {
auto state = this == p ? NSOnState : NSOffState;
[p->cocoaView setState:state];
}
}
}
}
}
}
}
auto pRadioLabel::setGeometry(Geometry geometry) -> void {
pWidget::setGeometry({
geometry.x() - 1, geometry.y(),
geometry.width() + 2, geometry.height()
});
}
auto pRadioLabel::setGroup(sGroup group) -> void {
}
auto pRadioLabel::setText(const string& text) -> void {
@autoreleasepool {
[cocoaView setTitle:[NSString stringWithUTF8String:text]];
}
}
}
#endif