Laid the foundation for the rewritten Mac OS X controls.
This commit is contained in:
parent
cb05779d0a
commit
3f2a0f8dfa
|
@ -12,13 +12,22 @@ struct singleView {
|
|||
BOOL containerHid;
|
||||
BOOL userDisabled;
|
||||
BOOL containerDisabled;
|
||||
void (*onDestroy)(void *);
|
||||
void *onDestroyData;
|
||||
};
|
||||
|
||||
static void singleDestroy(uiControl *c)
|
||||
{
|
||||
singleView *s = (singleView *) (c->Internal);
|
||||
|
||||
[s->immediate retain]; // to keep alive when removing
|
||||
if (s->parent != NULL) {
|
||||
[s->immediate removeFromSuperview];
|
||||
s->parent = NULL;
|
||||
}
|
||||
[destroyedControlsView addSubview:s->immediate];
|
||||
(*(s->onDestroy))(s->onDestroyData);
|
||||
[s->immediate release];
|
||||
}
|
||||
|
||||
static uintptr_t singleHandle(uiControl *c)
|
||||
|
@ -28,6 +37,7 @@ static uintptr_t singleHandle(uiControl *c)
|
|||
return (uintptr_t) (s->view);
|
||||
}
|
||||
|
||||
// TODO figure out retain/release for this
|
||||
static void singleSetParent(uiControl *c, uiParent *parent)
|
||||
{
|
||||
singleView *s = (singleView *) (c->Internal);
|
||||
|
@ -176,7 +186,7 @@ static void singleContainerDisable(uiControl *c)
|
|||
disable(s);
|
||||
}
|
||||
|
||||
void uiDarwinNewControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder)
|
||||
void uiDarwinNewControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData)
|
||||
{
|
||||
singleView *s;
|
||||
|
||||
|
@ -198,6 +208,9 @@ void uiDarwinNewControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrol
|
|||
s->immediate = (NSView *) (s->scrollView);
|
||||
}
|
||||
|
||||
s->onDestroy = onDestroy;
|
||||
s->onDestroyData = onDestroyData;
|
||||
|
||||
// and keep a reference to s->immediate for when we remove the control from its parent
|
||||
[s->immediate retain];
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ This file assumes that you have imported <Cocoa/Cocoa.h> and "ui.h" beforehand.
|
|||
// uiDarwinNewControl() initializes the given uiControl with the given Cocoa control inside.
|
||||
// The second parameter should come from [RealControlType class].
|
||||
// The two scrollView parameters allow placing scrollbars on the new control.
|
||||
// The two onDestroy parameters define a function and its parameter to call when the widget is destroyed.
|
||||
// Your control must call uiDarwinControlFreeWhenAppropriate() on the returned uiControl in its -[viewDidMoveToSuperview] method.
|
||||
// If it returns a value other than NO, then the uiControl has been freed and you should set references to it to NULL.
|
||||
extern void uiDarwinNewControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder);
|
||||
extern BOOL uiDarwinControlFreeWhenAppropriate(uiControl *c, NSView *newSuperview);
|
||||
extern BOOL uiDarwinControlFreeWhenAppropriate(uiControl *c, NSView *newSuperview, void (*onDestroy)(void *), void *onDestroyData);
|
||||
|
||||
// You can use this function from within your control implementations to return text strings that can be freed with uiTextFree().
|
||||
extern char *uiDarwinNSStringToText(NSString *);
|
||||
|
|
Loading…
Reference in New Issue