Converted struct mapTable to uiprivMap first, since that typedef will be a dependency of later stuff. ALso I didn't realize whoever wrote that new menu code also completely rewrote map.m... Cleaned up style inconsistencies I found in both. Anyway I plan on getting rid of that menu code anyway, and I could just have something else for target-action instead of this depending on whatever happens with ARC...
This commit is contained in:
parent
5a113e1e0b
commit
b8316c61dd
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
// menu.m
|
// menu.m
|
||||||
@interface menuManager : NSObject {
|
@interface menuManager : NSObject {
|
||||||
struct mapTable *items;
|
uiprivMap *items;
|
||||||
BOOL hasQuit;
|
BOOL hasQuit;
|
||||||
BOOL hasPreferences;
|
BOOL hasPreferences;
|
||||||
BOOL hasAbout;
|
BOOL hasAbout;
|
||||||
|
@ -68,15 +68,6 @@ extern void singleChildConstraintsEstablish(struct singleChildConstraints *c, NS
|
||||||
extern void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv);
|
extern void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv);
|
||||||
extern void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int margined);
|
extern void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int margined);
|
||||||
|
|
||||||
// map.m
|
|
||||||
extern struct mapTable *newMap(void);
|
|
||||||
extern void mapDestroy(struct mapTable *m);
|
|
||||||
extern void *mapGet(struct mapTable *m, void *key);
|
|
||||||
extern void mapSet(struct mapTable *m, void *key, void *value);
|
|
||||||
extern void mapDelete(struct mapTable *m, void *key);
|
|
||||||
extern void mapWalk(struct mapTable *m, void (*f)(void *key, void *value));
|
|
||||||
extern void mapReset(struct mapTable *m);
|
|
||||||
|
|
||||||
// area.m
|
// area.m
|
||||||
extern int sendAreaEvents(NSEvent *);
|
extern int sendAreaEvents(NSEvent *);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct uiButton {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface buttonDelegateClass : NSObject {
|
@interface buttonDelegateClass : NSObject {
|
||||||
struct mapTable *buttons;
|
uiprivMap *buttons;
|
||||||
}
|
}
|
||||||
- (IBAction)onClicked:(id)sender;
|
- (IBAction)onClicked:(id)sender;
|
||||||
- (void)registerButton:(uiButton *)b;
|
- (void)registerButton:(uiButton *)b;
|
||||||
|
@ -22,13 +22,13 @@ struct uiButton {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->buttons = newMap();
|
self->buttons = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->buttons);
|
uiprivMapDestroy(self->buttons);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ struct uiButton {
|
||||||
{
|
{
|
||||||
uiButton *b;
|
uiButton *b;
|
||||||
|
|
||||||
b = (uiButton *) mapGet(self->buttons, sender);
|
b = (uiButton *) uiprivMapGet(self->buttons, sender);
|
||||||
(*(b->onClicked))(b, b->onClickedData);
|
(*(b->onClicked))(b, b->onClickedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerButton:(uiButton *)b
|
- (void)registerButton:(uiButton *)b
|
||||||
{
|
{
|
||||||
mapSet(self->buttons, b->button, b);
|
uiprivMapSet(self->buttons, b->button, b);
|
||||||
[b->button setTarget:self];
|
[b->button setTarget:self];
|
||||||
[b->button setAction:@selector(onClicked:)];
|
[b->button setAction:@selector(onClicked:)];
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ struct uiButton {
|
||||||
- (void)unregisterButton:(uiButton *)b
|
- (void)unregisterButton:(uiButton *)b
|
||||||
{
|
{
|
||||||
[b->button setTarget:nil];
|
[b->button setTarget:nil];
|
||||||
mapDelete(self->buttons, b->button);
|
uiprivMapDelete(self->buttons, b->button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct uiCheckbox {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface checkboxDelegateClass : NSObject {
|
@interface checkboxDelegateClass : NSObject {
|
||||||
struct mapTable *buttons;
|
uiprivMap *buttons;
|
||||||
}
|
}
|
||||||
- (IBAction)onToggled:(id)sender;
|
- (IBAction)onToggled:(id)sender;
|
||||||
- (void)registerCheckbox:(uiCheckbox *)c;
|
- (void)registerCheckbox:(uiCheckbox *)c;
|
||||||
|
@ -22,13 +22,13 @@ struct uiCheckbox {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->buttons = newMap();
|
self->buttons = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->buttons);
|
uiprivMapDestroy(self->buttons);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ struct uiCheckbox {
|
||||||
{
|
{
|
||||||
uiCheckbox *c;
|
uiCheckbox *c;
|
||||||
|
|
||||||
c = (uiCheckbox *) mapGet(self->buttons, sender);
|
c = (uiCheckbox *) uiprivMapGet(self->buttons, sender);
|
||||||
(*(c->onToggled))(c, c->onToggledData);
|
(*(c->onToggled))(c, c->onToggledData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerCheckbox:(uiCheckbox *)c
|
- (void)registerCheckbox:(uiCheckbox *)c
|
||||||
{
|
{
|
||||||
mapSet(self->buttons, c->button, c);
|
uiprivMapSet(self->buttons, c->button, c);
|
||||||
[c->button setTarget:self];
|
[c->button setTarget:self];
|
||||||
[c->button setAction:@selector(onToggled:)];
|
[c->button setAction:@selector(onToggled:)];
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ struct uiCheckbox {
|
||||||
- (void)unregisterCheckbox:(uiCheckbox *)c
|
- (void)unregisterCheckbox:(uiCheckbox *)c
|
||||||
{
|
{
|
||||||
[c->button setTarget:nil];
|
[c->button setTarget:nil];
|
||||||
mapDelete(self->buttons, c->button);
|
uiprivMapDelete(self->buttons, c->button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct uiCombobox {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface comboboxDelegateClass : NSObject {
|
@interface comboboxDelegateClass : NSObject {
|
||||||
struct mapTable *comboboxes;
|
uiprivMap *comboboxes;
|
||||||
}
|
}
|
||||||
- (IBAction)onSelected:(id)sender;
|
- (IBAction)onSelected:(id)sender;
|
||||||
- (void)registerCombobox:(uiCombobox *)c;
|
- (void)registerCombobox:(uiCombobox *)c;
|
||||||
|
@ -27,13 +27,13 @@ struct uiCombobox {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->comboboxes = newMap();
|
self->comboboxes = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->comboboxes);
|
uiprivMapDestroy(self->comboboxes);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ struct uiCombobox {
|
||||||
{
|
{
|
||||||
uiCombobox *c;
|
uiCombobox *c;
|
||||||
|
|
||||||
c = uiCombobox(mapGet(self->comboboxes, sender));
|
c = uiCombobox(uiprivMapGet(self->comboboxes, sender));
|
||||||
(*(c->onSelected))(c, c->onSelectedData);
|
(*(c->onSelected))(c, c->onSelectedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerCombobox:(uiCombobox *)c
|
- (void)registerCombobox:(uiCombobox *)c
|
||||||
{
|
{
|
||||||
mapSet(self->comboboxes, c->pb, c);
|
uiprivMapSet(self->comboboxes, c->pb, c);
|
||||||
[c->pb setTarget:self];
|
[c->pb setTarget:self];
|
||||||
[c->pb setAction:@selector(onSelected:)];
|
[c->pb setAction:@selector(onSelected:)];
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ struct uiCombobox {
|
||||||
- (void)unregisterCombobox:(uiCombobox *)c
|
- (void)unregisterCombobox:(uiCombobox *)c
|
||||||
{
|
{
|
||||||
[c->pb setTarget:nil];
|
[c->pb setTarget:nil];
|
||||||
mapDelete(self->comboboxes, c->pb);
|
uiprivMapDelete(self->comboboxes, c->pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct uiEditableCombobox {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface editableComboboxDelegateClass : NSObject<NSComboBoxDelegate> {
|
@interface editableComboboxDelegateClass : NSObject<NSComboBoxDelegate> {
|
||||||
struct mapTable *comboboxes;
|
uiprivMap *comboboxes;
|
||||||
}
|
}
|
||||||
- (void)controlTextDidChange:(NSNotification *)note;
|
- (void)controlTextDidChange:(NSNotification *)note;
|
||||||
- (void)comboBoxSelectionDidChange:(NSNotification *)note;
|
- (void)comboBoxSelectionDidChange:(NSNotification *)note;
|
||||||
|
@ -48,13 +48,13 @@ struct uiEditableCombobox {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->comboboxes = newMap();
|
self->comboboxes = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->comboboxes);
|
uiprivMapDestroy(self->comboboxes);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ struct uiEditableCombobox {
|
||||||
{
|
{
|
||||||
uiEditableCombobox *c;
|
uiEditableCombobox *c;
|
||||||
|
|
||||||
c = uiEditableCombobox(mapGet(self->comboboxes, [note object]));
|
// TODO normalize the cast styles in these calls
|
||||||
|
c = uiEditableCombobox(uiprivMapGet(self->comboboxes, [note object]));
|
||||||
(*(c->onChanged))(c, c->onChangedData);
|
(*(c->onChanged))(c, c->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,14 +80,14 @@ struct uiEditableCombobox {
|
||||||
|
|
||||||
- (void)registerCombobox:(uiEditableCombobox *)c
|
- (void)registerCombobox:(uiEditableCombobox *)c
|
||||||
{
|
{
|
||||||
mapSet(self->comboboxes, c->cb, c);
|
uiprivMapSet(self->comboboxes, c->cb, c);
|
||||||
[c->cb setDelegate:self];
|
[c->cb setDelegate:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unregisterCombobox:(uiEditableCombobox *)c
|
- (void)unregisterCombobox:(uiEditableCombobox *)c
|
||||||
{
|
{
|
||||||
[c->cb setDelegate:nil];
|
[c->cb setDelegate:nil];
|
||||||
mapDelete(self->comboboxes, c->cb);
|
uiprivMapDelete(self->comboboxes, c->cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -67,7 +67,7 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface entryDelegateClass : NSObject<NSTextFieldDelegate> {
|
@interface entryDelegateClass : NSObject<NSTextFieldDelegate> {
|
||||||
struct mapTable *entries;
|
uiprivMap *entries;
|
||||||
}
|
}
|
||||||
- (void)controlTextDidChange:(NSNotification *)note;
|
- (void)controlTextDidChange:(NSNotification *)note;
|
||||||
- (IBAction)onSearch:(id)sender;
|
- (IBAction)onSearch:(id)sender;
|
||||||
|
@ -81,13 +81,13 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->entries = newMap();
|
self->entries = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->entries);
|
uiprivMapDestroy(self->entries);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,13 +100,13 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
{
|
{
|
||||||
uiEntry *e;
|
uiEntry *e;
|
||||||
|
|
||||||
e = (uiEntry *) mapGet(self->entries, sender);
|
e = (uiEntry *) uiprivMapGet(self->entries, sender);
|
||||||
(*(e->onChanged))(e, e->onChangedData);
|
(*(e->onChanged))(e, e->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerEntry:(uiEntry *)e
|
- (void)registerEntry:(uiEntry *)e
|
||||||
{
|
{
|
||||||
mapSet(self->entries, e->textfield, e);
|
uiprivMapSet(self->entries, e->textfield, e);
|
||||||
if (isSearchField(e->textfield)) {
|
if (isSearchField(e->textfield)) {
|
||||||
[e->textfield setTarget:self];
|
[e->textfield setTarget:self];
|
||||||
[e->textfield setAction:@selector(onSearch:)];
|
[e->textfield setAction:@selector(onSearch:)];
|
||||||
|
@ -120,7 +120,7 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
[e->textfield setTarget:nil];
|
[e->textfield setTarget:nil];
|
||||||
else
|
else
|
||||||
[e->textfield setDelegate:nil];
|
[e->textfield setDelegate:nil];
|
||||||
mapDelete(self->entries, e->textfield);
|
uiprivMapDelete(self->entries, e->textfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
32
darwin/map.m
32
darwin/map.m
|
@ -4,22 +4,22 @@
|
||||||
// unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers
|
// unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers
|
||||||
// hence, this file
|
// hence, this file
|
||||||
// we could expose a NSMapTable directly, but let's treat all pointers as opaque and hide the implementation, just to be safe and prevent even more rewrites later
|
// we could expose a NSMapTable directly, but let's treat all pointers as opaque and hide the implementation, just to be safe and prevent even more rewrites later
|
||||||
struct mapTable {
|
struct uiprivMap {
|
||||||
NSMapTable *m;
|
NSMapTable *m;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mapTable *newMap(void)
|
uiprivMap *uiprivNewMap(void)
|
||||||
{
|
{
|
||||||
struct mapTable *m;
|
uiprivMap *m;
|
||||||
|
|
||||||
m = uiprivNew(struct mapTable);
|
m = uiprivNew(uiprivMap);
|
||||||
m->m = [[NSMapTable alloc] initWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
m->m = [[NSMapTable alloc] initWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||||
valueOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
valueOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||||
capacity:0];
|
capacity:0];
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapDestroy(struct mapTable *m)
|
void uiprivMapDestroy(uiprivMap *m)
|
||||||
{
|
{
|
||||||
if ([m->m count] != 0)
|
if ([m->m count] != 0)
|
||||||
uiprivImplBug("attempt to destroy map with items inside");
|
uiprivImplBug("attempt to destroy map with items inside");
|
||||||
|
@ -27,33 +27,35 @@ void mapDestroy(struct mapTable *m)
|
||||||
uiprivFree(m);
|
uiprivFree(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mapGet(struct mapTable *m, void *key)
|
void *uiprivMapGet(uiprivMap *m, void *key)
|
||||||
{
|
{
|
||||||
return NSMapGet(m->m, key);
|
return NSMapGet(m->m, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapSet(struct mapTable *m, void *key, void *value)
|
void uiprivMapSet(uiprivMap *m, void *key, void *value)
|
||||||
{
|
{
|
||||||
NSMapInsert(m->m, key, value);
|
NSMapInsert(m->m, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapDelete(struct mapTable *m, void *key)
|
void uiprivMapDelete(uiprivMap *m, void *key)
|
||||||
{
|
{
|
||||||
NSMapRemove(m->m, key);
|
NSMapRemove(m->m, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapWalk(struct mapTable *m, void (*f)(void *key, void *value))
|
void uiprivMapWalk(uiprivMap *m, void (*f)(void *key, void *value))
|
||||||
{
|
{
|
||||||
NSMapEnumerator e = NSEnumerateMapTable(m->m);
|
NSMapEnumerator e;
|
||||||
void *k = NULL;
|
void *k, *v;
|
||||||
void *v = NULL;
|
|
||||||
while (NSNextMapEnumeratorPair(&e, &k, &v)) {
|
e = NSEnumerateMapTable(m->m);
|
||||||
|
k = NULL;
|
||||||
|
v = NULL;
|
||||||
|
while (NSNextMapEnumeratorPair(&e, &k, &v))
|
||||||
f(k, v);
|
f(k, v);
|
||||||
}
|
|
||||||
NSEndMapTableEnumeration(&e);
|
NSEndMapTableEnumeration(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapReset(struct mapTable *m)
|
void uiprivMapReset(uiprivMap *m)
|
||||||
{
|
{
|
||||||
NSResetMapTable(m->m);
|
NSResetMapTable(m->m);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
self->items = newMap();
|
self->items = uiprivNewMap();
|
||||||
self->hasQuit = NO;
|
self->hasQuit = NO;
|
||||||
self->hasPreferences = NO;
|
self->hasPreferences = NO;
|
||||||
self->hasAbout = NO;
|
self->hasAbout = NO;
|
||||||
|
@ -51,9 +51,9 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapWalk(self->items, mapItemReleaser);
|
uiprivMapWalk(self->items, mapItemReleaser);
|
||||||
mapReset(self->items);
|
uiprivMapReset(self->items);
|
||||||
mapDestroy(self->items);
|
uiprivMapDestroy(self->items);
|
||||||
uninitMenus();
|
uninitMenus();
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
{
|
{
|
||||||
uiMenuItem *item;
|
uiMenuItem *item;
|
||||||
|
|
||||||
item = (uiMenuItem *) mapGet(self->items, sender);
|
item = (uiMenuItem *) uiprivMapGet(self->items, sender);
|
||||||
if (item->type == typeCheckbox)
|
if (item->type == typeCheckbox)
|
||||||
uiMenuItemSetChecked(item, !uiMenuItemChecked(item));
|
uiMenuItemSetChecked(item, !uiMenuItemChecked(item));
|
||||||
// use the key window as the source of the menu event; it's the active window
|
// use the key window as the source of the menu event; it's the active window
|
||||||
|
@ -94,7 +94,7 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
self->hasAbout = YES;
|
self->hasAbout = YES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mapSet(self->items, item, smi);
|
uiprivMapSet(self->items, item, smi);
|
||||||
}
|
}
|
||||||
|
|
||||||
// on OS X there are two ways to handle menu items being enabled or disabled: automatically and manually
|
// on OS X there are two ways to handle menu items being enabled or disabled: automatically and manually
|
||||||
|
@ -112,7 +112,7 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
if (item == self.aboutItem && !self->hasAbout)
|
if (item == self.aboutItem && !self->hasAbout)
|
||||||
return NO;
|
return NO;
|
||||||
// then poll the item's enabled/disabled state
|
// then poll the item's enabled/disabled state
|
||||||
smi = (uiMenuItem *) mapGet(self->items, item);
|
smi = (uiMenuItem *) uiprivMapGet(self->items, item);
|
||||||
return !smi->disabled;
|
return !smi->disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct uiSlider {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface sliderDelegateClass : NSObject {
|
@interface sliderDelegateClass : NSObject {
|
||||||
struct mapTable *sliders;
|
uiprivMap *sliders;
|
||||||
}
|
}
|
||||||
- (IBAction)onChanged:(id)sender;
|
- (IBAction)onChanged:(id)sender;
|
||||||
- (void)registerSlider:(uiSlider *)b;
|
- (void)registerSlider:(uiSlider *)b;
|
||||||
|
@ -42,13 +42,13 @@ struct uiSlider {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->sliders = newMap();
|
self->sliders = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->sliders);
|
uiprivMapDestroy(self->sliders);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@ struct uiSlider {
|
||||||
{
|
{
|
||||||
uiSlider *s;
|
uiSlider *s;
|
||||||
|
|
||||||
s = (uiSlider *) mapGet(self->sliders, sender);
|
s = (uiSlider *) uiprivMapGet(self->sliders, sender);
|
||||||
(*(s->onChanged))(s, s->onChangedData);
|
(*(s->onChanged))(s, s->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerSlider:(uiSlider *)s
|
- (void)registerSlider:(uiSlider *)s
|
||||||
{
|
{
|
||||||
mapSet(self->sliders, s->slider, s);
|
uiprivMapSet(self->sliders, s->slider, s);
|
||||||
[s->slider setTarget:self];
|
[s->slider setTarget:self];
|
||||||
[s->slider setAction:@selector(onChanged:)];
|
[s->slider setAction:@selector(onChanged:)];
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ struct uiSlider {
|
||||||
- (void)unregisterSlider:(uiSlider *)s
|
- (void)unregisterSlider:(uiSlider *)s
|
||||||
{
|
{
|
||||||
[s->slider setTarget:nil];
|
[s->slider setTarget:nil];
|
||||||
mapDelete(self->sliders, s->slider);
|
uiprivMapDelete(self->sliders, s->slider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -22,4 +22,14 @@
|
||||||
|
|
||||||
/*TODO remove this*/typedef struct uiImage uiImage;
|
/*TODO remove this*/typedef struct uiImage uiImage;
|
||||||
|
|
||||||
|
// map.m
|
||||||
|
typedef struct uiprivMap uiprivMap;
|
||||||
|
extern uiprivMap *uiprivNewMap(void);
|
||||||
|
extern void uiprivMapDestroy(uiprivMap *m);
|
||||||
|
extern void *uiprivMapGet(uiprivMap *m, void *key);
|
||||||
|
extern void uiprivMapSet(uiprivMap *m, void *key, void *value);
|
||||||
|
extern void uiprivMapDelete(uiprivMap *m, void *key);
|
||||||
|
extern void uiprivMapWalk(uiprivMap *m, void (*f)(void *key, void *value));
|
||||||
|
extern void uiprivMapReset(uiprivMap *m);
|
||||||
|
|
||||||
#import "OLD_uipriv_darwin.h"
|
#import "OLD_uipriv_darwin.h"
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct uiWindow {
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
|
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
|
||||||
struct mapTable *windows;
|
uiprivMap *windows;
|
||||||
}
|
}
|
||||||
- (BOOL)windowShouldClose:(id)sender;
|
- (BOOL)windowShouldClose:(id)sender;
|
||||||
- (void)windowDidResize:(NSNotification *)note;
|
- (void)windowDidResize:(NSNotification *)note;
|
||||||
|
@ -50,13 +50,13 @@ struct uiWindow {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->windows = newMap();
|
self->windows = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->windows);
|
uiprivMapDestroy(self->windows);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,21 +100,21 @@ struct uiWindow {
|
||||||
|
|
||||||
- (void)registerWindow:(uiWindow *)w
|
- (void)registerWindow:(uiWindow *)w
|
||||||
{
|
{
|
||||||
mapSet(self->windows, w->window, w);
|
uiprivMapSet(self->windows, w->window, w);
|
||||||
[w->window setDelegate:self];
|
[w->window setDelegate:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unregisterWindow:(uiWindow *)w
|
- (void)unregisterWindow:(uiWindow *)w
|
||||||
{
|
{
|
||||||
[w->window setDelegate:nil];
|
[w->window setDelegate:nil];
|
||||||
mapDelete(self->windows, w->window);
|
uiprivMapDelete(self->windows, w->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (uiWindow *)lookupWindow:(NSWindow *)w
|
- (uiWindow *)lookupWindow:(NSWindow *)w
|
||||||
{
|
{
|
||||||
uiWindow *v;
|
uiWindow *v;
|
||||||
|
|
||||||
v = uiWindow(mapGet(self->windows, w));
|
v = uiWindow(uiprivMapGet(self->windows, w));
|
||||||
// this CAN (and IS ALLOWED TO) return NULL, just in case we're called with some OS X-provided window as the key window
|
// this CAN (and IS ALLOWED TO) return NULL, just in case we're called with some OS X-provided window as the key window
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue