~ubuntu-branches/ubuntu/hardy/orbital-eunuchs-sniper/hardy

« back to all changes in this revision

Viewing changes to src/ui.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-05-29 09:32:48 UTC
  • mfrom: (1.1.1 upstream) (2.1.2 gutsy)
  • Revision ID: james.westby@ubuntu.com-20070529093248-laj1bsm2dffohdf9
Tags: 1.30+svn20070601-1
Fix broken "upstream" rule to generate correctly versioned orig.tar.gz
to avoid native package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef OESUI_H_
 
2
#define OESUI_H_
 
3
 
 
4
#include "sexpr/sexp.h"
 
5
 
 
6
sexp_t *assoc_sexp(sexp_t*, const char *);
 
7
 
 
8
 
 
9
/* UI events */
 
10
enum {
 
11
  OESUI_UPDATE,   /* Synchronize memory spaces. */
 
12
  OESUI_REFRESH,  /* Redraw widgets */
 
13
  OESUI_MHORIZ,   /* Motion (relative) horizontal */
 
14
  OESUI_MVERT,    /* Motion (relative) vertical */
 
15
  OESUI_WHORIZ,   /* Warp (absolute) horizontal */
 
16
  OESUI_WVERT,    /* Warp (absolute) vertical */
 
17
  OESUI_OPEN,     /* First painting */
 
18
  OESUI_CLOSE,    /* closing */
 
19
  OESUI_CLICK,    /* Pointer click */
 
20
  OESUI_KEY,      /* Keypress */
 
21
  OESUI_UNKEY,    /* Keyrelease */
 
22
};
 
23
 
 
24
 
 
25
/* Property value types. */
 
26
enum {
 
27
  OESATOM_NULL,
 
28
  OESATOM_INT,
 
29
  OESATOM_FLOAT,
 
30
  OESATOM_STRING,
 
31
  OESATOM_SYMBOL,
 
32
  OESATOM_PAIR,
 
33
  OESATOM_PTR,
 
34
};
 
35
 
 
36
 
 
37
enum {
 
38
  MAGIC_HEAPED = 0x569A2937,
 
39
};
 
40
 
 
41
 
 
42
typedef struct llist_t {
 
43
  int magic;
 
44
  void *data;
 
45
  struct llist_t *next;
 
46
} llist_t;
 
47
 
 
48
 
 
49
typedef union oesui_atom_t {
 
50
  int i;
 
51
  float f;
 
52
  char *s;
 
53
  const char *sym;
 
54
  void *p;
 
55
} oesui_atom_t;
 
56
 
 
57
typedef struct oesui_propnode_t {
 
58
  int magic;
 
59
  int hash;
 
60
  char *key;
 
61
  int valtype;
 
62
  oesui_atom_t val;
 
63
} oesui_propnode_t;
 
64
 
 
65
typedef struct oesui_props_t {
 
66
  int magic;
 
67
  llist_t *list, *tail;
 
68
} oesui_props_t;
 
69
 
 
70
typedef struct oesui_widget_t {
 
71
  int magic;
 
72
  oesui_props_t *props;
 
73
} oesui_widget_t;
 
74
 
 
75
 
 
76
typedef struct oesui_signal_t {
 
77
  int magic;
 
78
  int len;
 
79
  oesui_atom_t msg[];
 
80
} oesui_signal_t;
 
81
 
 
82
#define UISIG_ARG(sig, n) ((sig)->msg[n])
 
83
#define UISIG_NAME(sig) (UISIG_ARG(sig, 0).s)
 
84
 
 
85
 
 
86
typedef struct oesui_t {
 
87
  int magic;
 
88
  SDL_Surface *screen;
 
89
  oesui_widget_t *toplevel;
 
90
  oesui_widget_t *signals;  /* signals for widgets. */
 
91
  int x, y, w, h;  /* draw boundaries? */
 
92
  int px, py, pz;  /* pointer position */
 
93
  int (*sighandler)(struct oesui_t *, oesui_signal_t *);
 
94
  int retcode;   /* communications/synchronization hack. */
 
95
} oesui_t;
 
96
 
 
97
 
 
98
typedef struct assetcache_t {
 
99
  int magic;
 
100
  int len;
 
101
  int alloc;
 
102
  oesui_propnode_t *cache;  /* array of pairs. */
 
103
} assetcache_t;
 
104
 
 
105
 
 
106
oesui_widget_t * sexp_to_widget (oesui_t *, sexp_t *);
 
107
llist_t * sexp_to_widgetlist (oesui_t *, sexp_t *);
 
108
 
 
109
 
 
110
oesui_propnode_t *oesui_propnode_init (oesui_propnode_t *, const char *key);
 
111
void oesui_propnode_delete (oesui_propnode_t *);
 
112
 
 
113
oesui_props_t * oeui_props_init (oesui_props_t *);
 
114
oesui_props_t * oeui_props_delete (oesui_props_t *);
 
115
oesui_propnode_t * oeui_props_get (oesui_props_t *);
 
116
oesui_props_t * oesui_props_set_int (oesui_props_t *, const char *key, int val);
 
117
oesui_props_t * oesui_props_set_float (oesui_props_t *, const char *key, float val);
 
118
oesui_props_t * oesui_props_set_string (oesui_props_t *, const char *key, const char * val);
 
119
oesui_props_t * oesui_props_set_ptr (oesui_props_t *, const char *key, void * val);
 
120
int oeui_props_get_int (oesui_props_t *, const char *key);
 
121
float oeui_props_get_float (oesui_props_t *, const char *key);
 
122
const char * oeui_props_get_string (oesui_props_t *, const char *key);
 
123
void * oeui_props_get_ptr (oesui_props_t *, const char *key);
 
124
 
 
125
oesui_t * oesui_init (oesui_t *);
 
126
oesui_t * oesui_init_surface (oesui_t *, SDL_Surface *sdlscreen);
 
127
void oesui_delete (oesui_t *);
 
128
int oesui_load (oesui_t *, const char *fname);
 
129
int oesui_event (oesui_t *, int evtype, int parm);
 
130
int oesui_open (oesui_t *, const char *tlname);
 
131
int oesui_loop (oesui_t *);  /* main gui loop */
 
132
int oesui_sighandle (oesui_t *, int (*sighandle)(oesui_t *, oesui_signal_t *));
 
133
 
 
134
#endif /* OESUI_H_ */
 
135