Gutted the existing header files, started trimming things that remain in the backups, and renamed _UI_EXTERN and _UI_ENUM and the include guards and libui_EXPORTS to start with uipriv instead.

This commit is contained in:
Pietro Gagliardi 2019-04-08 20:55:06 -04:00
parent 12d52be921
commit c9643ea5a6
9 changed files with 348 additions and 2454 deletions

View File

@ -158,9 +158,9 @@ libui_libui = library('ui', libui_sources,
name_prefix: 'lib', # always call it libui, even in Windows DLLs name_prefix: 'lib', # always call it libui, even in Windows DLLs
install: true, install: true,
gnu_symbol_visibility: 'hidden', gnu_symbol_visibility: 'hidden',
c_args: ['-Dlibui_EXPORTS'], c_args: ['-DuiprivBuildingLibui'],
cpp_args: ['-Dlibui_EXPORTS'], cpp_args: ['-DuiprivBuildingLibui'],
objc_args: ['-Dlibui_EXPORTS'], objc_args: ['-DuiprivBuildingLibui'],
link_args: libui_libui_link_args, link_args: libui_libui_link_args,
soversion: libui_soversion, soversion: libui_soversion,
darwin_versions: []) # TODO darwin_versions: []) # TODO

1448
ui.h

File diff suppressed because it is too large Load Diff

View File

@ -4,219 +4,13 @@
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. 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__ #ifndef uiprivIncludeGuard_ui_darwin_h
#define __LIBUI_UI_DARWIN_H__ #define uiprivIncludeGuard_ui_darwin_h
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct uiDarwinControl uiDarwinControl;
struct uiDarwinControl {
uiControl c;
uiControl *parent;
BOOL enabled;
BOOL visible;
void (*SyncEnableState)(uiDarwinControl *, int);
void (*SetSuperview)(uiDarwinControl *, NSView *);
BOOL (*HugsTrailingEdge)(uiDarwinControl *);
BOOL (*HugsBottom)(uiDarwinControl *);
void (*ChildEdgeHuggingChanged)(uiDarwinControl *);
NSLayoutPriority (*HuggingPriority)(uiDarwinControl *, NSLayoutConstraintOrientation);
void (*SetHuggingPriority)(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation);
void (*ChildVisibilityChanged)(uiDarwinControl *);
};
#define uiDarwinControl(this) ((uiDarwinControl *) (this))
// TODO document
_UI_EXTERN void uiDarwinControlSyncEnableState(uiDarwinControl *, int);
_UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
_UI_EXTERN BOOL uiDarwinControlHugsTrailingEdge(uiDarwinControl *);
_UI_EXTERN BOOL uiDarwinControlHugsBottom(uiDarwinControl *);
_UI_EXTERN void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *);
_UI_EXTERN NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation);
_UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation);
_UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *);
#define uiDarwinControlDefaultDestroy(type, handlefield) \
static void type ## Destroy(uiControl *c) \
{ \
[type(c)->handlefield release]; \
uiFreeControl(c); \
}
#define uiDarwinControlDefaultHandle(type, handlefield) \
static uintptr_t type ## Handle(uiControl *c) \
{ \
return (uintptr_t) (type(c)->handlefield); \
}
#define uiDarwinControlDefaultParent(type, handlefield) \
static uiControl *type ## Parent(uiControl *c) \
{ \
return uiDarwinControl(c)->parent; \
}
#define uiDarwinControlDefaultSetParent(type, handlefield) \
static void type ## SetParent(uiControl *c, uiControl *parent) \
{ \
uiControlVerifySetParent(c, parent); \
uiDarwinControl(c)->parent = parent; \
}
#define uiDarwinControlDefaultToplevel(type, handlefield) \
static int type ## Toplevel(uiControl *c) \
{ \
return 0; \
}
#define uiDarwinControlDefaultVisible(type, handlefield) \
static int type ## Visible(uiControl *c) \
{ \
return uiDarwinControl(c)->visible; \
}
#define uiDarwinControlDefaultShow(type, handlefield) \
static void type ## Show(uiControl *c) \
{ \
uiDarwinControl(c)->visible = YES; \
[type(c)->handlefield setHidden:NO]; \
uiDarwinNotifyVisibilityChanged(uiDarwinControl(c)); \
}
#define uiDarwinControlDefaultHide(type, handlefield) \
static void type ## Hide(uiControl *c) \
{ \
uiDarwinControl(c)->visible = NO; \
[type(c)->handlefield setHidden:YES]; \
uiDarwinNotifyVisibilityChanged(uiDarwinControl(c)); \
}
#define uiDarwinControlDefaultEnabled(type, handlefield) \
static int type ## Enabled(uiControl *c) \
{ \
return uiDarwinControl(c)->enabled; \
}
#define uiDarwinControlDefaultEnable(type, handlefield) \
static void type ## Enable(uiControl *c) \
{ \
uiDarwinControl(c)->enabled = YES; \
uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(c)); \
}
#define uiDarwinControlDefaultDisable(type, handlefield) \
static void type ## Disable(uiControl *c) \
{ \
uiDarwinControl(c)->enabled = NO; \
uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(c)); \
}
#define uiDarwinControlDefaultSyncEnableState(type, handlefield) \
static void type ## SyncEnableState(uiDarwinControl *c, int enabled) \
{ \
if (uiDarwinShouldStopSyncEnableState(c, enabled)) \
return; \
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
[((id) (type(c)->handlefield)) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
}
#define uiDarwinControlDefaultSetSuperview(type, handlefield) \
static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \
{ \
[type(c)->handlefield setTranslatesAutoresizingMaskIntoConstraints:NO]; \
if (superview == nil) \
[type(c)->handlefield removeFromSuperview]; \
else \
[superview addSubview:type(c)->handlefield]; \
}
#define uiDarwinControlDefaultHugsTrailingEdge(type, handlefield) \
static BOOL type ## HugsTrailingEdge(uiDarwinControl *c) \
{ \
return YES; /* always hug by default */ \
}
#define uiDarwinControlDefaultHugsBottom(type, handlefield) \
static BOOL type ## HugsBottom(uiDarwinControl *c) \
{ \
return YES; /* always hug by default */ \
}
#define uiDarwinControlDefaultChildEdgeHuggingChanged(type, handlefield) \
static void type ## ChildEdgeHuggingChanged(uiDarwinControl *c) \
{ \
/* do nothing */ \
}
#define uiDarwinControlDefaultHuggingPriority(type, handlefield) \
static NSLayoutPriority type ## HuggingPriority(uiDarwinControl *c, NSLayoutConstraintOrientation orientation) \
{ \
return [type(c)->handlefield contentHuggingPriorityForOrientation:orientation]; \
}
#define uiDarwinControlDefaultSetHuggingPriority(type, handlefield) \
static void type ## SetHuggingPriority(uiDarwinControl *c, NSLayoutPriority priority, NSLayoutConstraintOrientation orientation) \
{ \
[type(c)->handlefield setContentHuggingPriority:priority forOrientation:orientation]; \
}
#define uiDarwinControlDefaultChildVisibilityChanged(type, handlefield) \
static void type ## ChildVisibilityChanged(uiDarwinControl *c) \
{ \
/* do nothing */ \
}
#define uiDarwinControlAllDefaultsExceptDestroy(type, handlefield) \
uiDarwinControlDefaultHandle(type, handlefield) \
uiDarwinControlDefaultParent(type, handlefield) \
uiDarwinControlDefaultSetParent(type, handlefield) \
uiDarwinControlDefaultToplevel(type, handlefield) \
uiDarwinControlDefaultVisible(type, handlefield) \
uiDarwinControlDefaultShow(type, handlefield) \
uiDarwinControlDefaultHide(type, handlefield) \
uiDarwinControlDefaultEnabled(type, handlefield) \
uiDarwinControlDefaultEnable(type, handlefield) \
uiDarwinControlDefaultDisable(type, handlefield) \
uiDarwinControlDefaultSyncEnableState(type, handlefield) \
uiDarwinControlDefaultSetSuperview(type, handlefield) \
uiDarwinControlDefaultHugsTrailingEdge(type, handlefield) \
uiDarwinControlDefaultHugsBottom(type, handlefield) \
uiDarwinControlDefaultChildEdgeHuggingChanged(type, handlefield) \
uiDarwinControlDefaultHuggingPriority(type, handlefield) \
uiDarwinControlDefaultSetHuggingPriority(type, handlefield) \
uiDarwinControlDefaultChildVisibilityChanged(type, handlefield)
#define uiDarwinControlAllDefaults(type, handlefield) \
uiDarwinControlDefaultDestroy(type, handlefield) \
uiDarwinControlAllDefaultsExceptDestroy(type, handlefield)
// TODO document
#define uiDarwinNewControl(type, var) \
var = type(uiDarwinAllocControl(sizeof (type), type ## Signature, #type)); \
uiControl(var)->Destroy = type ## Destroy; \
uiControl(var)->Handle = type ## Handle; \
uiControl(var)->Parent = type ## Parent; \
uiControl(var)->SetParent = type ## SetParent; \
uiControl(var)->Toplevel = type ## Toplevel; \
uiControl(var)->Visible = type ## Visible; \
uiControl(var)->Show = type ## Show; \
uiControl(var)->Hide = type ## Hide; \
uiControl(var)->Enabled = type ## Enabled; \
uiControl(var)->Enable = type ## Enable; \
uiControl(var)->Disable = type ## Disable; \
uiDarwinControl(var)->SyncEnableState = type ## SyncEnableState; \
uiDarwinControl(var)->SetSuperview = type ## SetSuperview; \
uiDarwinControl(var)->HugsTrailingEdge = type ## HugsTrailingEdge; \
uiDarwinControl(var)->HugsBottom = type ## HugsBottom; \
uiDarwinControl(var)->ChildEdgeHuggingChanged = type ## ChildEdgeHuggingChanged; \
uiDarwinControl(var)->HuggingPriority = type ## HuggingPriority; \
uiDarwinControl(var)->SetHuggingPriority = type ## SetHuggingPriority; \
uiDarwinControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \
uiDarwinControl(var)->visible = YES; \
uiDarwinControl(var)->enabled = YES;
// TODO document
_UI_EXTERN uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// 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 *);
// TODO document
_UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL);
// TODO document
_UI_EXTERN void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *);
_UI_EXTERN void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c);
// TODO document
// TODO document that values should not be cached
_UI_EXTERN CGFloat uiDarwinMarginAmount(void *reserved);
_UI_EXTERN CGFloat uiDarwinPaddingAmount(void *reserved);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

130
ui_unix.h
View File

@ -4,139 +4,13 @@
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). 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__ #ifndef uiprivIncludeGuard_ui_unix_h
#define __LIBUI_UI_UNIX_H__ #define uiprivIncludeGuard_ui_unix_h
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct uiUnixControl uiUnixControl;
struct uiUnixControl {
uiControl c;
uiControl *parent;
gboolean addedBefore;
gboolean explicitlyHidden;
void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean);
};
#define uiUnixControl(this) ((uiUnixControl *) (this))
// TODO document
_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean);
#define uiUnixControlDefaultDestroy(type) \
static void type ## Destroy(uiControl *c) \
{ \
/* TODO is this safe on floating refs? */ \
g_object_unref(type(c)->widget); \
uiFreeControl(c); \
}
#define uiUnixControlDefaultHandle(type) \
static uintptr_t type ## Handle(uiControl *c) \
{ \
return (uintptr_t) (type(c)->widget); \
}
#define uiUnixControlDefaultParent(type) \
static uiControl *type ## Parent(uiControl *c) \
{ \
return uiUnixControl(c)->parent; \
}
#define uiUnixControlDefaultSetParent(type) \
static void type ## SetParent(uiControl *c, uiControl *parent) \
{ \
uiControlVerifySetParent(c, parent); \
uiUnixControl(c)->parent = parent; \
}
#define uiUnixControlDefaultToplevel(type) \
static int type ## Toplevel(uiControl *c) \
{ \
return 0; \
}
#define uiUnixControlDefaultVisible(type) \
static int type ## Visible(uiControl *c) \
{ \
return gtk_widget_get_visible(type(c)->widget); \
}
#define uiUnixControlDefaultShow(type) \
static void type ## Show(uiControl *c) \
{ \
/*TODO part of massive hack about hidden before*/uiUnixControl(c)->explicitlyHidden=FALSE; \
gtk_widget_show(type(c)->widget); \
}
#define uiUnixControlDefaultHide(type) \
static void type ## Hide(uiControl *c) \
{ \
/*TODO part of massive hack about hidden before*/uiUnixControl(c)->explicitlyHidden=TRUE; \
gtk_widget_hide(type(c)->widget); \
}
#define uiUnixControlDefaultEnabled(type) \
static int type ## Enabled(uiControl *c) \
{ \
return gtk_widget_get_sensitive(type(c)->widget); \
}
#define uiUnixControlDefaultEnable(type) \
static void type ## Enable(uiControl *c) \
{ \
gtk_widget_set_sensitive(type(c)->widget, TRUE); \
}
#define uiUnixControlDefaultDisable(type) \
static void type ## Disable(uiControl *c) \
{ \
gtk_widget_set_sensitive(type(c)->widget, FALSE); \
}
// TODO this whole addedBefore stuff is a MASSIVE HACK.
#define uiUnixControlDefaultSetContainer(type) \
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
{ \
if (!uiUnixControl(c)->addedBefore) { \
g_object_ref_sink(type(c)->widget); /* our own reference, which we release in Destroy() */ \
/* massive hack notes: without any of this, nothing gets shown when we show a window; without the if, all things get shown even if some were explicitly hidden (TODO why don't we just show everything except windows on create? */ \
/*TODO*/if(!uiUnixControl(c)->explicitlyHidden) gtk_widget_show(type(c)->widget); \
uiUnixControl(c)->addedBefore = TRUE; \
} \
if (remove) \
gtk_container_remove(container, type(c)->widget); \
else \
gtk_container_add(container, type(c)->widget); \
}
#define uiUnixControlAllDefaultsExceptDestroy(type) \
uiUnixControlDefaultHandle(type) \
uiUnixControlDefaultParent(type) \
uiUnixControlDefaultSetParent(type) \
uiUnixControlDefaultToplevel(type) \
uiUnixControlDefaultVisible(type) \
uiUnixControlDefaultShow(type) \
uiUnixControlDefaultHide(type) \
uiUnixControlDefaultEnabled(type) \
uiUnixControlDefaultEnable(type) \
uiUnixControlDefaultDisable(type) \
uiUnixControlDefaultSetContainer(type)
#define uiUnixControlAllDefaults(type) \
uiUnixControlDefaultDestroy(type) \
uiUnixControlAllDefaultsExceptDestroy(type)
// TODO document
#define uiUnixNewControl(type, var) \
var = type(uiUnixAllocControl(sizeof (type), type ## Signature, #type)); \
uiControl(var)->Destroy = type ## Destroy; \
uiControl(var)->Handle = type ## Handle; \
uiControl(var)->Parent = type ## Parent; \
uiControl(var)->SetParent = type ## SetParent; \
uiControl(var)->Toplevel = type ## Toplevel; \
uiControl(var)->Visible = type ## Visible; \
uiControl(var)->Show = type ## Show; \
uiControl(var)->Hide = type ## Hide; \
uiControl(var)->Enabled = type ## Enabled; \
uiControl(var)->Enable = type ## Enable; \
uiControl(var)->Disable = type ## Disable; \
uiUnixControl(var)->SetContainer = type ## SetContainer;
// TODO document
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText().
_UI_EXTERN char *uiUnixStrdupText(const char *);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -4,262 +4,13 @@
This file assumes that you have included <windows.h> and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls in Windows. This file assumes that you have included <windows.h> and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls in Windows.
*/ */
#ifndef __LIBUI_UI_WINDOWS_H__ #ifndef uiprivIncludeGuard_ui_windows_h
#define __LIBUI_UI_WINDOWS_H__ #define uiprivIncludeGuard_ui_windows_h
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef struct uiWindowsSizing uiWindowsSizing;
typedef struct uiWindowsControl uiWindowsControl;
struct uiWindowsControl {
uiControl c;
uiControl *parent;
// TODO this should be int on both os x and windows
BOOL enabled;
BOOL visible;
void (*SyncEnableState)(uiWindowsControl *, int);
void (*SetParentHWND)(uiWindowsControl *, HWND);
void (*MinimumSize)(uiWindowsControl *, int *, int *);
void (*MinimumSizeChanged)(uiWindowsControl *);
void (*LayoutRect)(uiWindowsControl *c, RECT *r);
void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *);
void (*ChildVisibilityChanged)(uiWindowsControl *);
};
#define uiWindowsControl(this) ((uiWindowsControl *) (this))
// TODO document
_UI_EXTERN void uiWindowsControlSyncEnableState(uiWindowsControl *, int);
_UI_EXTERN void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND);
_UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *);
_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *);
_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *);
_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *);
_UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
// TODO document
#define uiWindowsControlDefaultDestroy(type) \
static void type ## Destroy(uiControl *c) \
{ \
uiWindowsEnsureDestroyWindow(type(c)->hwnd); \
uiFreeControl(c); \
}
#define uiWindowsControlDefaultHandle(type) \
static uintptr_t type ## Handle(uiControl *c) \
{ \
return (uintptr_t) (type(c)->hwnd); \
}
#define uiWindowsControlDefaultParent(type) \
static uiControl *type ## Parent(uiControl *c) \
{ \
return uiWindowsControl(c)->parent; \
}
#define uiWindowsControlDefaultSetParent(type) \
static void type ## SetParent(uiControl *c, uiControl *parent) \
{ \
uiControlVerifySetParent(c, parent); \
uiWindowsControl(c)->parent = parent; \
}
#define uiWindowsControlDefaultToplevel(type) \
static int type ## Toplevel(uiControl *c) \
{ \
return 0; \
}
#define uiWindowsControlDefaultVisible(type) \
static int type ## Visible(uiControl *c) \
{ \
return uiWindowsControl(c)->visible; \
}
#define uiWindowsControlDefaultShow(type) \
static void type ## Show(uiControl *c) \
{ \
uiWindowsControl(c)->visible = 1; \
ShowWindow(type(c)->hwnd, SW_SHOW); \
uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \
}
#define uiWindowsControlDefaultHide(type) \
static void type ## Hide(uiControl *c) \
{ \
uiWindowsControl(c)->visible = 0; \
ShowWindow(type(c)->hwnd, SW_HIDE); \
uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \
}
#define uiWindowsControlDefaultEnabled(type) \
static int type ## Enabled(uiControl *c) \
{ \
return uiWindowsControl(c)->enabled; \
}
#define uiWindowsControlDefaultEnable(type) \
static void type ## Enable(uiControl *c) \
{ \
uiWindowsControl(c)->enabled = 1; \
uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \
}
#define uiWindowsControlDefaultDisable(type) \
static void type ## Disable(uiControl *c) \
{ \
uiWindowsControl(c)->enabled = 0; \
uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \
}
#define uiWindowsControlDefaultSyncEnableState(type) \
static void type ## SyncEnableState(uiWindowsControl *c, int enabled) \
{ \
if (uiWindowsShouldStopSyncEnableState(c, enabled)) \
return; \
EnableWindow(type(c)->hwnd, enabled); \
}
#define uiWindowsControlDefaultSetParentHWND(type) \
static void type ## SetParentHWND(uiWindowsControl *c, HWND parent) \
{ \
uiWindowsEnsureSetParentHWND(type(c)->hwnd, parent); \
}
// note that there is no uiWindowsControlDefaultMinimumSize(); you MUST define this yourself!
#define uiWindowsControlDefaultMinimumSizeChanged(type) \
static void type ## MinimumSizeChanged(uiWindowsControl *c) \
{ \
if (uiWindowsControlTooSmall(c)) { \
uiWindowsControlContinueMinimumSizeChanged(c); \
return; \
} \
/* otherwise do nothing; we have no children */ \
}
#define uiWindowsControlDefaultLayoutRect(type) \
static void type ## LayoutRect(uiWindowsControl *c, RECT *r) \
{ \
/* use the window rect as we include the non-client area in the sizes */ \
uiWindowsEnsureGetWindowRect(type(c)->hwnd, r); \
}
#define uiWindowsControlDefaultAssignControlIDZOrder(type) \
static void type ## AssignControlIDZOrder(uiWindowsControl *c, LONG_PTR *controlID, HWND *insertAfter) \
{ \
uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, controlID, insertAfter); \
}
#define uiWindowsControlDefaultChildVisibilityChanged(type) \
static void type ## ChildVisibilityChanged(uiWindowsControl *c) \
{ \
/* do nothing */ \
}
#define uiWindowsControlAllDefaultsExceptDestroy(type) \
uiWindowsControlDefaultHandle(type) \
uiWindowsControlDefaultParent(type) \
uiWindowsControlDefaultSetParent(type) \
uiWindowsControlDefaultToplevel(type) \
uiWindowsControlDefaultVisible(type) \
uiWindowsControlDefaultShow(type) \
uiWindowsControlDefaultHide(type) \
uiWindowsControlDefaultEnabled(type) \
uiWindowsControlDefaultEnable(type) \
uiWindowsControlDefaultDisable(type) \
uiWindowsControlDefaultSyncEnableState(type) \
uiWindowsControlDefaultSetParentHWND(type) \
uiWindowsControlDefaultMinimumSizeChanged(type) \
uiWindowsControlDefaultLayoutRect(type) \
uiWindowsControlDefaultAssignControlIDZOrder(type) \
uiWindowsControlDefaultChildVisibilityChanged(type)
#define uiWindowsControlAllDefaults(type) \
uiWindowsControlDefaultDestroy(type) \
uiWindowsControlAllDefaultsExceptDestroy(type)
// TODO document
#define uiWindowsNewControl(type, var) \
var = type(uiWindowsAllocControl(sizeof (type), type ## Signature, #type)); \
uiControl(var)->Destroy = type ## Destroy; \
uiControl(var)->Handle = type ## Handle; \
uiControl(var)->Parent = type ## Parent; \
uiControl(var)->SetParent = type ## SetParent; \
uiControl(var)->Toplevel = type ## Toplevel; \
uiControl(var)->Visible = type ## Visible; \
uiControl(var)->Show = type ## Show; \
uiControl(var)->Hide = type ## Hide; \
uiControl(var)->Enabled = type ## Enabled; \
uiControl(var)->Enable = type ## Enable; \
uiControl(var)->Disable = type ## Disable; \
uiWindowsControl(var)->SyncEnableState = type ## SyncEnableState; \
uiWindowsControl(var)->SetParentHWND = type ## SetParentHWND; \
uiWindowsControl(var)->MinimumSize = type ## MinimumSize; \
uiWindowsControl(var)->MinimumSizeChanged = type ## MinimumSizeChanged; \
uiWindowsControl(var)->LayoutRect = type ## LayoutRect; \
uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZOrder; \
uiWindowsControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \
uiWindowsControl(var)->visible = 1; \
uiWindowsControl(var)->enabled = 1;
// TODO document
_UI_EXTERN uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// TODO document
_UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont);
// TODO document
_UI_EXTERN void uiWindowsEnsureDestroyWindow(HWND hwnd);
// TODO document
// TODO document that this should only be used in SetParentHWND() implementations
_UI_EXTERN void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent);
// TODO document
_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter);
// TODO document
_UI_EXTERN void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r);
_UI_EXTERN void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r);
// TODO document
_UI_EXTERN char *uiWindowsWindowText(HWND hwnd);
_UI_EXTERN void uiWindowsSetWindowText(HWND hwnd, const char *text);
// TODO document
_UI_EXTERN int uiWindowsWindowTextWidth(HWND hwnd);
// TODO document
// TODO point out this should only be used in a resize cycle
_UI_EXTERN void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, int height);
// TODO document
_UI_EXTERN void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c);
_UI_EXTERN void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd);
// TODO document
_UI_EXTERN void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c);
_UI_EXTERN void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd);
// TODO document
_UI_EXTERN void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c);
_UI_EXTERN void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd);
// TODO document
_UI_EXTERN void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd);
_UI_EXTERN void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd);
// TODO document
typedef struct uiWindowsSizing uiWindowsSizing;
struct uiWindowsSizing {
int BaseX;
int BaseY;
LONG InternalLeading;
};
_UI_EXTERN void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing);
_UI_EXTERN void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y);
_UI_EXTERN void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y);
// TODO document
_UI_EXTERN HWND uiWindowsMakeContainer(uiWindowsControl *c, void (*onResize)(uiWindowsControl *));
// TODO document
_UI_EXTERN BOOL uiWindowsControlTooSmall(uiWindowsControl *c);
_UI_EXTERN void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c);
// TODO document
_UI_EXTERN void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *);
// TODO document
_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled);
// TODO document
_UI_EXTERN void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

590
zOLD_ui.h

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,3 @@
// 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__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct uiDarwinControl uiDarwinControl; typedef struct uiDarwinControl uiDarwinControl;
struct uiDarwinControl { struct uiDarwinControl {
uiControl c; uiControl c;
@ -28,14 +15,14 @@ struct uiDarwinControl {
}; };
#define uiDarwinControl(this) ((uiDarwinControl *) (this)) #define uiDarwinControl(this) ((uiDarwinControl *) (this))
// TODO document // TODO document
_UI_EXTERN void uiDarwinControlSyncEnableState(uiDarwinControl *, int); uiprivExtern void uiDarwinControlSyncEnableState(uiDarwinControl *, int);
_UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); uiprivExtern void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
_UI_EXTERN BOOL uiDarwinControlHugsTrailingEdge(uiDarwinControl *); uiprivExtern BOOL uiDarwinControlHugsTrailingEdge(uiDarwinControl *);
_UI_EXTERN BOOL uiDarwinControlHugsBottom(uiDarwinControl *); uiprivExtern BOOL uiDarwinControlHugsBottom(uiDarwinControl *);
_UI_EXTERN void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *); uiprivExtern void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *);
_UI_EXTERN NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation); uiprivExtern NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation);
_UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation); uiprivExtern void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation);
_UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *); uiprivExtern void uiDarwinControlChildVisibilityChanged(uiDarwinControl *);
#define uiDarwinControlDefaultDestroy(type, handlefield) \ #define uiDarwinControlDefaultDestroy(type, handlefield) \
static void type ## Destroy(uiControl *c) \ static void type ## Destroy(uiControl *c) \
@ -197,28 +184,22 @@ _UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *);
uiDarwinControl(var)->visible = YES; \ uiDarwinControl(var)->visible = YES; \
uiDarwinControl(var)->enabled = YES; uiDarwinControl(var)->enabled = YES;
// TODO document // TODO document
_UI_EXTERN uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr); uiprivExtern uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// Use this function as a shorthand for setting control fonts. // Use this function as a shorthand for setting control fonts.
_UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size); uiprivExtern 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(). // 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 *); uiprivExtern char *uiDarwinNSStringToText(NSString *);
// TODO document // TODO document
_UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL); uiprivExtern BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL);
// TODO document // TODO document
_UI_EXTERN void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *); uiprivExtern void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *);
_UI_EXTERN void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c); uiprivExtern void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c);
// TODO document // TODO document
// TODO document that values should not be cached // TODO document that values should not be cached
_UI_EXTERN CGFloat uiDarwinMarginAmount(void *reserved); uiprivExtern CGFloat uiDarwinMarginAmount(void *reserved);
_UI_EXTERN CGFloat uiDarwinPaddingAmount(void *reserved); uiprivExtern CGFloat uiDarwinPaddingAmount(void *reserved);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,16 +1,3 @@
// 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__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct uiUnixControl uiUnixControl; typedef struct uiUnixControl uiUnixControl;
struct uiUnixControl { struct uiUnixControl {
uiControl c; uiControl c;
@ -21,7 +8,7 @@ struct uiUnixControl {
}; };
#define uiUnixControl(this) ((uiUnixControl *) (this)) #define uiUnixControl(this) ((uiUnixControl *) (this))
// TODO document // TODO document
_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean); uiprivExtern void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean);
#define uiUnixControlDefaultDestroy(type) \ #define uiUnixControlDefaultDestroy(type) \
static void type ## Destroy(uiControl *c) \ static void type ## Destroy(uiControl *c) \
@ -132,13 +119,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
uiControl(var)->Disable = type ## Disable; \ uiControl(var)->Disable = type ## Disable; \
uiUnixControl(var)->SetContainer = type ## SetContainer; uiUnixControl(var)->SetContainer = type ## SetContainer;
// TODO document // TODO document
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr); uiprivExtern uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). // uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText().
_UI_EXTERN char *uiUnixStrdupText(const char *); uiprivExtern char *uiUnixStrdupText(const char *);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,16 +1,3 @@
// 21 april 2016
/*
This file assumes that you have included <windows.h> and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls in Windows.
*/
#ifndef __LIBUI_UI_WINDOWS_H__
#define __LIBUI_UI_WINDOWS_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct uiWindowsSizing uiWindowsSizing; typedef struct uiWindowsSizing uiWindowsSizing;
typedef struct uiWindowsControl uiWindowsControl; typedef struct uiWindowsControl uiWindowsControl;
@ -30,13 +17,13 @@ struct uiWindowsControl {
}; };
#define uiWindowsControl(this) ((uiWindowsControl *) (this)) #define uiWindowsControl(this) ((uiWindowsControl *) (this))
// TODO document // TODO document
_UI_EXTERN void uiWindowsControlSyncEnableState(uiWindowsControl *, int); uiprivExtern void uiWindowsControlSyncEnableState(uiWindowsControl *, int);
_UI_EXTERN void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND); uiprivExtern void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND);
_UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *); uiprivExtern void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *);
_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *); uiprivExtern void uiWindowsControlMinimumSizeChanged(uiWindowsControl *);
_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *); uiprivExtern void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *);
_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *); uiprivExtern void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *);
_UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); uiprivExtern void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
// TODO document // TODO document
#define uiWindowsControlDefaultDestroy(type) \ #define uiWindowsControlDefaultDestroy(type) \
@ -187,51 +174,51 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
uiWindowsControl(var)->visible = 1; \ uiWindowsControl(var)->visible = 1; \
uiWindowsControl(var)->enabled = 1; uiWindowsControl(var)->enabled = 1;
// TODO document // TODO document
_UI_EXTERN uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr); uiprivExtern uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// TODO document // TODO document
_UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont); uiprivExtern HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont);
// TODO document // TODO document
_UI_EXTERN void uiWindowsEnsureDestroyWindow(HWND hwnd); uiprivExtern void uiWindowsEnsureDestroyWindow(HWND hwnd);
// TODO document // TODO document
// TODO document that this should only be used in SetParentHWND() implementations // TODO document that this should only be used in SetParentHWND() implementations
_UI_EXTERN void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent); uiprivExtern void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent);
// TODO document // TODO document
_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter); uiprivExtern void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter);
// TODO document // TODO document
_UI_EXTERN void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r); uiprivExtern void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r);
_UI_EXTERN void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r); uiprivExtern void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r);
// TODO document // TODO document
_UI_EXTERN char *uiWindowsWindowText(HWND hwnd); uiprivExtern char *uiWindowsWindowText(HWND hwnd);
_UI_EXTERN void uiWindowsSetWindowText(HWND hwnd, const char *text); uiprivExtern void uiWindowsSetWindowText(HWND hwnd, const char *text);
// TODO document // TODO document
_UI_EXTERN int uiWindowsWindowTextWidth(HWND hwnd); uiprivExtern int uiWindowsWindowTextWidth(HWND hwnd);
// TODO document // TODO document
// TODO point out this should only be used in a resize cycle // TODO point out this should only be used in a resize cycle
_UI_EXTERN void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, int height); uiprivExtern void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, int height);
// TODO document // TODO document
_UI_EXTERN void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); uiprivExtern void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c);
_UI_EXTERN void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd); uiprivExtern void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd);
// TODO document // TODO document
_UI_EXTERN void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c); uiprivExtern void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c);
_UI_EXTERN void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd); uiprivExtern void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd);
// TODO document // TODO document
_UI_EXTERN void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); uiprivExtern void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c);
_UI_EXTERN void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd); uiprivExtern void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd);
// TODO document // TODO document
_UI_EXTERN void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd); uiprivExtern void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd);
_UI_EXTERN void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd); uiprivExtern void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd);
// TODO document // TODO document
typedef struct uiWindowsSizing uiWindowsSizing; typedef struct uiWindowsSizing uiWindowsSizing;
@ -240,28 +227,22 @@ struct uiWindowsSizing {
int BaseY; int BaseY;
LONG InternalLeading; LONG InternalLeading;
}; };
_UI_EXTERN void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing); uiprivExtern void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing);
_UI_EXTERN void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y); uiprivExtern void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y);
_UI_EXTERN void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y); uiprivExtern void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y);
// TODO document // TODO document
_UI_EXTERN HWND uiWindowsMakeContainer(uiWindowsControl *c, void (*onResize)(uiWindowsControl *)); uiprivExtern HWND uiWindowsMakeContainer(uiWindowsControl *c, void (*onResize)(uiWindowsControl *));
// TODO document // TODO document
_UI_EXTERN BOOL uiWindowsControlTooSmall(uiWindowsControl *c); uiprivExtern BOOL uiWindowsControlTooSmall(uiWindowsControl *c);
_UI_EXTERN void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c); uiprivExtern void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c);
// TODO document // TODO document
_UI_EXTERN void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *); uiprivExtern void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *);
// TODO document // TODO document
_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled); uiprivExtern BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled);
// TODO document // TODO document
_UI_EXTERN void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c); uiprivExtern void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c);
#ifdef __cplusplus
}
#endif
#endif