libui/ui_unix.h

66 lines
1.9 KiB
C
Raw Normal View History

2015-08-27 11:29:19 -05:00
// 7 april 2015
/*
This file assumes that you have included <gtk/gtk.h> and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X).
*/
#ifndef __LIBUI_UI_UNIX_H__
#define __LIBUI_UI_UNIX_H__
2015-11-16 09:55:44 -06:00
#ifdef __cplusplus
extern "C" {
#endif
2015-08-27 11:29:19 -05:00
typedef struct uiUnixControl uiUnixControl;
struct uiUnixControl {
uiControl c;
};
_UI_EXTERN uintmax_t uiUnixControlType(void);
#define uiUnixControl(this) ((uiUnixControl *) uiIsA((this), uiUnixControlType(), 1))
// TODO document
#define uiUnixDefineControlWithOnDestroy(type, typefn, onDestroy) \
static uintmax_t _ ## type ## Type = 0; \
uintmax_t typefn(void) \
{ \
if (_ ## type ## Type == 0) \
_ ## type ## Type = uiRegisterType(#type, uiUnixControlType(), sizeof (type)); \
return _ ## type ## Type; \
} \
static void _ ## type ## CommitDestroy(uiControl *c) \
{ \
type *this = type(c); \
onDestroy; \
g_object_unref(this->widget); \
} \
static uintptr_t _ ## type ## Handle(uiControl *c) \
{ \
return (uintptr_t) (type(c)->widget); \
} \
static void _ ## type ## ContainerUpdateState(uiControl *c) \
{ \
/* do nothing */ \
}
#define uiUnixDefineControl(type, typefn) \
uiUnixDefineControlWithOnDestroy(type, typefn, (void) this;)
#define uiUnixFinishNewControl(variable, type) \
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
uiControl(variable)->Handle = _ ## type ## Handle; \
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
uiUnixFinishControl(uiControl(variable));
// This is a function used to set up a control.
// Don't call it directly; use uiUnixFinishNewControl() instead.
_UI_EXTERN void uiUnixFinishControl(uiControl *c);
// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText().
2015-11-17 09:46:58 -06:00
_UI_EXTERN char *uiUnixStrdupText(const char *);
2015-08-27 11:29:19 -05:00
2015-11-16 09:55:44 -06:00
#ifdef __cplusplus
}
#endif
2015-08-27 11:29:19 -05:00
#endif