ref: 6ff9ef0c4bef23bfd91f33f0c2f5cab0b88c0307
dir: /nate.h/
#pragma lib "libnate.a" typedef struct Nelem Nelem; typedef struct Nelemfunctions Nelemfunctions; typedef struct Nlist Nlist; /* user functions ******************/ void nateinit(void); void nateredraw(void); int natemouseevent(Mouse); #define NAssign(T, A, B) ((T*)(nassign((Nelem**)A, B))) Nelem* nassign(Nelem**, Nelem*); /* end user functions *********************/ struct Nelem { char* type; Nelemfunctions* funcs; }; struct Nelemfunctions { Point (*calcsize)(Nelem*, Image*); void (*draw)(Nelem*, Image*, Rectangle); Nelem* (*checkhit)(Nelem*, Image*, Rectangle, Mouse); int (*hit)(Nelem*, Mouse); void (*free)(Nelem*); Nlist* (*getchildren)(Nelem*); }; /* nlist functions ******************/ typedef struct Nlistelem Nlistelem; struct Nlist { Nlistelem* first; }; struct Nlistelem { Nelem* item; Nlistelem* next; }; void linit(Nlist* list); int lhas(Nlist* list, Nelem* item); void ladd(Nlist* list, Nelem* item); void lins(Nlist* list, Nelem* item); void ldel(Nlist* list, Nelem* item); void linsert(Nlist* list, Nelem* before, Nelem* item); void lforeach(Nlist* list, void (*f)(Nelem*, int)); void lfreelist(Nlist* list); Nelem* lgetfirst(Nlist* list); Nelem* lsetfirst(Nlist* list, Nelem* item); /* helper functions ********************/ // calls on Nelem Point ncallcalcsize(Nelem*, Image*); void ncalldraw(Nelem*, Image*, Rectangle); Nelem* ncallcheckhit(Nelem*, Image*, Rectangle, Mouse); int ncallhit(Nelem*, Mouse); void ncallfree(Nelem*); Nlist* ncallgetchildren(Nelem*); /* root set management ***********************/ // register Nelem as root void nregister(Nelem*); // deregister Nelem as root (free for collection) void nderegister(Nelem*); // true if Nelem is root int nisroot(Nelem*); // register root element void nregroot(Nelem*); /* more syntactic sugar ***********************/ #define DECL_ACCESSOR(Type, Acc) Type* (*Acc)(void) #define DECL_ACCESSOR_OneParam(Type, Acc, T1) Type* (*Acc)(T1) #define DECL_ACCESSOR_TwoParams(Type, Acc, T1, T2) Type* (*Acc)(T1, T2) #define DECL_ACCESSOR_ThreeParams(Type, Acc, T1, T2, T3) Type* (*Acc)(T1, T2, T3)