2015-08-16 19:56:39 -05:00
|
|
|
// 7 april 2015
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file assumes that you have imported <Cocoa/Cocoa.h> and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Mac OS X.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LIBUI_UI_DARWIN_H__
|
|
|
|
#define __LIBUI_UI_DARWIN_H__
|
|
|
|
|
2015-11-16 09:55:44 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-08-16 22:16:42 -05:00
|
|
|
typedef struct uiDarwinControl uiDarwinControl;
|
|
|
|
struct uiDarwinControl {
|
|
|
|
uiControl c;
|
2015-08-17 18:19:02 -05:00
|
|
|
void (*Relayout)(uiDarwinControl *);
|
2015-08-16 22:16:42 -05:00
|
|
|
};
|
2016-04-24 13:15:56 -05:00
|
|
|
#define uiDarwinControl(this) ((uiDarwinControl *) (this))
|
2015-08-17 18:11:35 -05:00
|
|
|
// TODO document
|
2015-08-18 18:57:16 -05:00
|
|
|
_UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
|
2015-08-16 22:16:42 -05:00
|
|
|
|
2015-08-16 19:56:39 -05:00
|
|
|
// TODO document
|
2016-04-24 13:15:56 -05:00
|
|
|
#define uiDarwinDefineControlWithOnDestroy(type, handlefield, onDestroy) \
|
2015-08-16 19:56:39 -05:00
|
|
|
static void _ ## type ## CommitDestroy(uiControl *c) \
|
|
|
|
{ \
|
|
|
|
type *this = type(c); \
|
|
|
|
onDestroy; \
|
|
|
|
[this->handlefield release]; \
|
|
|
|
} \
|
|
|
|
static uintptr_t _ ## type ## Handle(uiControl *c) \
|
|
|
|
{ \
|
2015-08-16 22:16:42 -05:00
|
|
|
return (uintptr_t) (type(c)->handlefield); \
|
2015-08-16 21:19:15 -05:00
|
|
|
} \
|
|
|
|
static void _ ## type ## ContainerUpdateState(uiControl *c) \
|
|
|
|
{ \
|
|
|
|
/* do nothing */ \
|
2015-08-17 18:11:35 -05:00
|
|
|
} \
|
2015-08-17 18:19:02 -05:00
|
|
|
static void _ ## type ## Relayout(uiDarwinControl *c) \
|
2015-08-17 18:11:35 -05:00
|
|
|
{ \
|
2015-08-18 18:57:16 -05:00
|
|
|
/* do nothing */ \
|
2015-08-16 19:56:39 -05:00
|
|
|
}
|
|
|
|
|
2016-04-24 13:15:56 -05:00
|
|
|
#define uiDarwinDefineControl(type, handlefield) \
|
|
|
|
uiDarwinDefineControlWithOnDestroy(type, handlefield, (void) this;)
|
2015-08-16 19:56:39 -05:00
|
|
|
|
2016-04-24 14:46:29 -05:00
|
|
|
// TODO document
|
|
|
|
#define uiNewControl(type) uiDarwinNewControl(sizeof (type), type ## Signature, #type)
|
2016-04-24 16:38:48 -05:00
|
|
|
_UI_EXTERN uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typenamestr);
|
2016-04-24 14:46:29 -05:00
|
|
|
|
2015-08-16 19:56:39 -05:00
|
|
|
#define uiDarwinFinishNewControl(variable, type) \
|
2015-08-16 22:08:00 -05:00
|
|
|
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
|
|
|
uiControl(variable)->Handle = _ ## type ## Handle; \
|
|
|
|
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
2015-08-17 18:11:35 -05:00
|
|
|
uiDarwinControl(variable)->Relayout = _ ## type ## Relayout; \
|
2015-08-16 19:56:39 -05:00
|
|
|
uiDarwinFinishControl(uiControl(variable));
|
|
|
|
|
|
|
|
// This is a function used to set up a control.
|
|
|
|
// Don't call it directly; use uiDarwinFinishNewControl() instead.
|
|
|
|
_UI_EXTERN void uiDarwinFinishControl(uiControl *c);
|
|
|
|
|
|
|
|
// Use this function as a shorthand for setting control fonts.
|
|
|
|
_UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size);
|
|
|
|
|
|
|
|
// You can use this function from within your control implementations to return text strings that can be freed with uiFreeText().
|
|
|
|
_UI_EXTERN char *uiDarwinNSStringToText(NSString *);
|
|
|
|
|
2015-11-16 09:55:44 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-16 19:56:39 -05:00
|
|
|
#endif
|