Added uiOnShouldQuit() and its common code.
This commit is contained in:
parent
3d714e03c1
commit
c395cdd2fd
|
@ -25,6 +25,7 @@ baseHFILES = \
|
||||||
baseCFILES = \
|
baseCFILES = \
|
||||||
box.c \
|
box.c \
|
||||||
ptrarray.c \
|
ptrarray.c \
|
||||||
|
shouldquit.c \
|
||||||
$(osCFILES)
|
$(osCFILES)
|
||||||
|
|
||||||
baseMFILES = $(osMFILES)
|
baseMFILES = $(osMFILES)
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// 9 may 2015
|
||||||
|
#include "ui.h"
|
||||||
|
#include "uipriv.h"
|
||||||
|
|
||||||
|
static int defaultOnShouldQuit(void *data)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int (*onShouldQuit)(void *) = defaultOnShouldQuit;
|
||||||
|
static void *onShouldQuitData;
|
||||||
|
|
||||||
|
void uiOnShouldQuit(int (*f)(void *), void *data)
|
||||||
|
{
|
||||||
|
onShouldQuit = f;
|
||||||
|
onShouldQuitData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
int shouldQuit(void)
|
||||||
|
{
|
||||||
|
return (*onShouldQuit)(onShouldQuitData);
|
||||||
|
}
|
2
ui.idl
2
ui.idl
|
@ -24,6 +24,8 @@ func FreeInitError(err *const char);
|
||||||
func Main(void);
|
func Main(void);
|
||||||
func Quit(void);
|
func Quit(void);
|
||||||
|
|
||||||
|
func OnShouldQuit(f *func(data *void) int, data *void);
|
||||||
|
|
||||||
func FreeText(text *char);
|
func FreeText(text *char);
|
||||||
|
|
||||||
raw "typedef struct uiSizingSys uiSizingSys;";
|
raw "typedef struct uiSizingSys uiSizingSys;";
|
||||||
|
|
3
uipriv.h
3
uipriv.h
|
@ -27,3 +27,6 @@ void ptrArrayAppend(struct ptrArray *, void *);
|
||||||
void ptrArrayInsertBefore(struct ptrArray *, uintmax_t, void *);
|
void ptrArrayInsertBefore(struct ptrArray *, uintmax_t, void *);
|
||||||
void ptrArrayDelete(struct ptrArray *, uintmax_t);
|
void ptrArrayDelete(struct ptrArray *, uintmax_t);
|
||||||
#define ptrArrayIndex(p, T, i) ((T) ((p)->ptrs[(i)]))
|
#define ptrArrayIndex(p, T, i) ((T) ((p)->ptrs[(i)]))
|
||||||
|
|
||||||
|
// shouldquit.c
|
||||||
|
int shouldQuit(void);
|
||||||
|
|
Loading…
Reference in New Issue