More TODO resolution.

This commit is contained in:
Pietro Gagliardi 2015-08-17 12:57:45 -04:00
parent b15554cbd1
commit 478f5d2504
6 changed files with 22 additions and 10 deletions

View File

@ -3,10 +3,12 @@
#import "uipriv_darwin.h"
NSMutableArray *allocations;
NSMutableArray *delegates;
void initAlloc(void)
{
allocations = [NSMutableArray new];
delegates = [NSMutableArray new];
}
#define UINT8(p) ((uint8_t *) (p))
@ -21,6 +23,11 @@ void initAlloc(void)
void uninitAlloc(void)
{
if ([allocations count] == 0) {
NSInteger i;
for (i = 0; i < [delegates count]; i++)
[[delegates objectAtIndex:i] release];
[delegates release];
[allocations release];
return;
}

View File

@ -26,7 +26,6 @@ struct uiButton {
return self;
}
// TODO have this called
- (void)dealloc
{
if ([self->buttons count] != 0)
@ -103,8 +102,10 @@ uiButton *uiNewButton(const char *text)
[b->button setBezelStyle:NSRoundedBezelStyle];
uiDarwinSetControlFont(b->button, NSRegularControlSize);
if (buttonDelegate == nil)
if (buttonDelegate == nil) {
buttonDelegate = [buttonDelegateClass new];
[delegates addObject:buttonDelegate];
}
[buttonDelegate registerButton:b];
uiButtonOnClicked(b, defaultOnClicked, NULL);

View File

@ -3,13 +3,13 @@
struct uiCheckbox {
uiDarwinControl c;
NSButton *button; // TODO rename to checkbox?
NSButton *button;
void (*onToggled)(uiCheckbox *, void *);
void *onToggledData;
};
@interface checkboxDelegateClass : NSObject {
NSMapTable *buttons; // TODO rename to checkboxes?
NSMapTable *buttons;
}
- (IBAction)onToggled:(id)sender;
- (void)registerCheckbox:(uiCheckbox *)c;
@ -26,7 +26,6 @@ struct uiCheckbox {
return self;
}
// TODO have this called
- (void)dealloc
{
if ([self->buttons count] != 0)
@ -117,8 +116,10 @@ uiCheckbox *uiNewCheckbox(const char *text)
[c->button setBordered:NO];
uiDarwinSetControlFont(c->button, NSRegularControlSize);
if (checkboxDelegate == nil)
if (checkboxDelegate == nil) {
checkboxDelegate = [checkboxDelegateClass new];
[delegates addObject:checkboxDelegate];
}
[checkboxDelegate registerCheckbox:c];
uiCheckboxOnToggled(c, defaultOnToggled, NULL);

View File

@ -28,7 +28,6 @@ struct uiEntry {
return self;
}
// TODO have this called
- (void)dealloc
{
if ([self->entries count] != 0)
@ -131,8 +130,10 @@ uiEntry *uiNewEntry(void)
[e->textfield setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
finishNewTextField(e->textfield, YES);
if (entryDelegate == nil)
if (entryDelegate == nil) {
entryDelegate = [entryDelegateClass new];
[delegates addObject:entryDelegate];
}
[entryDelegate registerEntry:e];
uiEntryOnChanged(e, defaultOnChanged, NULL);

View File

@ -46,6 +46,7 @@ extern void finishNewTextField(NSTextField *, BOOL);
extern uiWindow *windowFromNSWindow(NSWindow *);
// alloc.m
extern NSMutableArray *delegates;
extern void initAlloc(void);
extern void uninitAlloc(void);

View File

@ -29,7 +29,6 @@ struct uiWindow {
return self;
}
// TODO have this called
- (void)dealloc
{
if ([self->windows count] != 0)
@ -191,8 +190,10 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
// the only thing that closes the window is us anyway
[w->window setReleasedWhenClosed:YES];
if (windowDelegate == nil)
if (windowDelegate == nil) {
windowDelegate = [windowDelegateClass new];
[delegates addObject:windowDelegate];
}
[windowDelegate registerWindow:w];
uiWindowOnClosing(w, defaultOnClosing, NULL);