Fixed the uiRadioButtons buttons not showing up.

This commit is contained in:
Pietro Gagliardi 2015-08-22 16:09:21 -04:00
parent 2d9022ab13
commit cec464a998
1 changed files with 13 additions and 5 deletions

View File

@ -28,11 +28,22 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
uiRadioButtons *uiNewRadioButtons(void) uiRadioButtons *uiNewRadioButtons(void)
{ {
uiRadioButtons *r; uiRadioButtons *r;
NSButtonCell *cell;
r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType()); r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType());
r->matrix = [[NSMatrix alloc] initWithFrame:NSZeroRect]; // we have to set up the NSMatrix this way (prototype first)
[r->matrix setMode:NSRadioModeMatrix]; // otherwise we won't be able to change its properties (such as the button type)
cell = [NSButtonCell new];
[cell setButtonType:NSRadioButton];
// works on NSCells too (same selector)
uiDarwinSetControlFont((NSControl *) cell, NSRegularControlSize);
r->matrix = [[NSMatrix alloc] initWithFrame:NSZeroRect
mode:NSRadioModeMatrix
prototype:cell
numberOfRows:0
numberOfColumns:0];
// TODO should we allow an initial state of no selection, but not allow the user to select nothing? // TODO should we allow an initial state of no selection, but not allow the user to select nothing?
[r->matrix setAllowsEmptySelection:NO]; [r->matrix setAllowsEmptySelection:NO];
[r->matrix setIntercellSpacing:NSMakeSize(4, 2)]; [r->matrix setIntercellSpacing:NSMakeSize(4, 2)];
@ -40,9 +51,6 @@ uiRadioButtons *uiNewRadioButtons(void)
[r->matrix setDrawsBackground:NO]; [r->matrix setDrawsBackground:NO];
[r->matrix setDrawsCellBackground:NO]; [r->matrix setDrawsCellBackground:NO];
[r->matrix setAutosizesCells:YES]; [r->matrix setAutosizesCells:YES];
[[r->matrix prototype] setButtonType:NSRadioButton];
// works on NSCells too (same selector)
uiDarwinSetControlFont((NSControl *) [r->matrix prototype], NSRegularControlSize);
uiDarwinFinishNewControl(r, uiRadioButtons); uiDarwinFinishNewControl(r, uiRadioButtons);