109 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
			
		
		
	
	
			109 lines
		
	
	
		
			2.6 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 ElementList {
 | 
						|
  struct Element *first;
 | 
						|
  struct Element *last;
 | 
						|
  void *user;
 | 
						|
  void (*hook_newElement)();
 | 
						|
  void (*hook_addElement)();
 | 
						|
};
 | 
						|
 | 
						|
struct Element {
 | 
						|
  int x;
 | 
						|
  int y;
 | 
						|
  int state;
 | 
						|
  int type;
 | 
						|
  int child_count;
 | 
						|
  int gid;
 | 
						|
  int id;
 | 
						|
  struct Element *next;
 | 
						|
  struct Element **children;
 | 
						|
  void *data;
 | 
						|
  void (*callback)();
 | 
						|
  void *user;
 | 
						|
  void *parent;
 | 
						|
  void *sibling;
 | 
						|
};
 | 
						|
 | 
						|
struct Element *newElement(int type);
 | 
						|
void freeElement(struct Element *element);
 | 
						|
 | 
						|
#define HOOK_ADD 1
 | 
						|
 | 
						|
struct ElementList *newElementList();
 | 
						|
void freeElementList(struct ElementList *list);
 | 
						|
void addElementToList(struct ElementList *list, struct Element *element);
 | 
						|
void removeElementFromList(struct ElementList *list, struct Element *element);
 | 
						|
void deleteElementsFromList(struct ElementList *list);
 | 
						|
void setElementListUser(struct ElementList *list, void *user);
 | 
						|
void hookElementList(struct ElementList *list, int callback_id, void(*callback));
 | 
						|
 | 
						|
/* element type structs and such */
 | 
						|
#define TYPE_TEXT 0
 | 
						|
#define TYPE_BUTTON 1
 | 
						|
#define TYPE_TEXT_INPUT 2
 | 
						|
#define TYPE_IMAGE 3
 | 
						|
#define TYPE_SPINNER 4
 | 
						|
 | 
						|
struct ButtonElement {
 | 
						|
  int length;
 | 
						|
  char *string;
 | 
						|
};
 | 
						|
 | 
						|
struct SpinnerElement {
 | 
						|
  int size;
 | 
						|
  int cursor;
 | 
						|
  int length;
 | 
						|
  char *string;
 | 
						|
  int value;
 | 
						|
};
 | 
						|
 | 
						|
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);
 | 
						|
int setElementValue(struct Element *element, int value);
 | 
						|
int setElementUser(struct Element *element, void *user);
 | 
						|
int setElementId(struct Element *element, int id);
 | 
						|
int setElementGid(struct Element *element, int gid);
 | 
						|
int setElementSibling(struct Element *element, struct Element *sibling);
 | 
						|
int setElementParent(struct Element *element, struct Element *parent);
 | 
						|
int addElementChild(struct Element *element, struct Element *child);
 | 
						|
int removeElementChild(struct Element *element, struct Element *child);
 | 
						|
 | 
						|
const char *getElementText(struct Element *element);
 | 
						|
int getElementValue(struct Element *element);
 | 
						|
int handleInputElement(struct Element *element, int ch);
 | 
						|
int handleMouseButton(struct Element *element, int button);
 | 
						|
 | 
						|
#endif
 |