65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
/****** elements.h, defines various UI elements
|
|
|
|
******/
|
|
#ifndef ELEMENTS_H
|
|
#define ELEMENTS_H
|
|
|
|
#define STATE_NORMAL 0
|
|
#define STATE_PRESSED 1
|
|
#define STATE_HELD 2
|
|
#define STATE_DRAG 3
|
|
#define STATE_FOCUS 4
|
|
|
|
struct Element {
|
|
int x;
|
|
int y;
|
|
int state;
|
|
int type;
|
|
struct Element *next;
|
|
void *data;
|
|
void (*callback)();
|
|
void *user;
|
|
};
|
|
|
|
struct Element *newElement(int type);
|
|
|
|
/* element type structs and such */
|
|
#define TYPE_TEXT 0
|
|
#define TYPE_BUTTON 1
|
|
#define TYPE_TEXT_INPUT 2
|
|
#define TYPE_IMAGE 3
|
|
|
|
struct ButtonElement {
|
|
int length;
|
|
char *string;
|
|
};
|
|
|
|
struct TextElement {
|
|
int length;
|
|
char *string;
|
|
};
|
|
|
|
struct TextInputElement {
|
|
int size;
|
|
int cursor;
|
|
int length;
|
|
char *string;
|
|
};
|
|
|
|
struct ImageElement {
|
|
int width;
|
|
int height;
|
|
void *image;
|
|
};
|
|
|
|
int setElementText(struct Element *element, const char *string);
|
|
int setElementPosition(struct Element *element, int x, int y);
|
|
int setElementCallback(struct Element *element, void(*callback));
|
|
int setElementSize(struct Element *element, int size);
|
|
int setElementImage(struct Element *element, void *image, int width, int height);
|
|
|
|
const char *getElementText(struct Element *element);
|
|
int handleInputElement(struct Element *element, char ch);
|
|
|
|
#endif
|