File: cpins.h

package info (click to toggle)
searchandrescue 0.8.2-10
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,656 kB
  • ctags: 6,111
  • sloc: ansic: 89,072; cpp: 7,691; sh: 90; makefile: 80
file content (115 lines) | stat: -rw-r--r-- 3,371 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
		     Control Panel Instrument
 */

#ifndef CPINS_H
#define CPINS_H

#include <sys/types.h>
#include <GL/gl.h>
#include "v3dtex.h"
#include "cpvalues.h"


/*
 *	Default (this) instrument type:
 */
#define CPINS_TYPE_INS		1


/*
 *	Control Panel Instrument structure:
 *
 *	This is the base structure for all instruments.
 */
typedef struct _CPIns CPIns;
struct _CPIns {

	int	type;		/* One of CPINS_TYPE_. */

	void	*cp;		/* Pointer back to control panel. */

	char	*name;		/* Arbitary name of instrument. */

	/* Position and size (coefficient) relative to the control
	 * panel's upper left corner.
	 */
	float	x, y,
		width, height;

	/* Texture resolution, the size to set the GL back buffer when
	 * drawing for the texture tex.  This will also be the size of
	 * the texture tex.
	 */
	int res_width, res_height;	/* In pixels. */

	/* Texture that will be used when drawing the instrument, this
	 * texture should be created in the "values_changed" function
	 * using the GL back buffer.  The size of this texture is
	 * determined by res_width and res_height, this will also be
	 * the size of the GL back buffer when drawing for this texture.
	 */
	v3d_texture_ref_struct  *tex;

	/* Last time instrument was updated and the update interval. */
	time_t	update_next,		/* In milliseconds. */
		update_int;

	/* Background and foreground textures. */
	v3d_texture_ref_struct	*tex_bg,
				*tex_fg;

	CPColor	color_bg[CP_COLOR_STATES],
		color_fg[CP_COLOR_STATES],
		color_text[CP_COLOR_STATES];

	/* Functions. */
	/* "values_changed" function (CPIns *ins, ControlPanelValues *v, void *data). */
	void *values_changed_func_data;
	void (*values_changed_func)(CPIns *, ControlPanelValues *, void *);

	/* "manage" function (CPIns *ins, ControlPanelValues *v, void *data). */
	void *manage_func_data;
	void (*manage_func)(CPIns *, ControlPanelValues *, void *);

	/* "reset_timmers" function (CPIns *ins, time_t t, void *data). */
	void *reset_timmers_func_data;
	void (*reset_timmers_func)(CPIns *, time_t, void *);

	/* "delete" function (CPIns *ins, void *data). */
	void *delete_func_data;
	void (*delete_func)(CPIns *, void *);
};
#define CPINS(p)	((CPIns *)(p))
#define CPINS_TYPE(p)	(((p) != NULL) ? (*(int *)(p)) : -1)
#define CPINS_NAME(p)	(((p) != NULL) ? CPINS(p)->name : NULL)
#define CPINS_IS_INS(p)	(CPINS_TYPE(p) == CPINS_TYPE_INS)


extern void CPInsSetName(CPIns *ins, const char *name);
extern void CPInsSetPosition(CPIns *ins, float x, float y);
extern void CPInsSetSize(CPIns *ins, float width, float height);
extern void CPInsSetTextureBG(CPIns *ins, const char *path);
extern void CPInsSetTextureFG(CPIns *ins, const char *path);
extern void CPInsSetResolution(
	CPIns *ins,
	int res_width, int res_height	/* In pixels. */
);
extern void CPInsSetUpdateInt(CPIns *ins, time_t update_int);
extern void CPInsSetFunction(
	CPIns *ins, const char *func_name,
	void *func, void *data
);

extern void CPInsResetTimmers(CPIns *ins, time_t t);
extern void CPInsChangeValues(CPIns *ins, ControlPanelValues *v);
extern void CPInsDraw(CPIns *ins);
extern void CPInsDrawFullScreen(CPIns *ins, const CPRectangle *rect);
extern void CPInsManage(CPIns *ins, ControlPanelValues *v);
extern void CPInsRealizeTexture(CPIns *ins);

extern CPIns *CPInsNew(size_t s, void *cp, int type, const char *name);
extern void CPInsDelete(CPIns *ins);


#endif	/* CPINS_H */