1 /*  GNU Robbo
2  *  Copyright (C) 2002-2010 The GNU Robbo Team (see AUTHORS).
3  *
4  *  GNU Robbo is free software - you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2, or (at your option)
7  *  any later version.
8  *
9  *  GNU Robbo is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the impled warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with GNU CC; see the file COPYING. If not, write to the
16  *  Free Software Foundation, 59 Temple Place - Suite 330,
17  *  Boston, MA 02111-1307, USA.
18  *
19  */
20 
21 /* Defines */
22 /*
23 #define DEBUG_ROB_HOTSPOTS
24 */
25 
26 /* Miscellaneous defines */
27 #define ROB_UNDEFINED -1
28 #define ROB_INHERITED -2
29 
30 /* System objects */
31 #define ROB_LYR_ROOT 0
32 #define ROB_LYR_CANVAS 1
33 #define ROB_REC_POINTER 98
34 #define ROB_LYR_POINTER 99
35 
36 /* Hit points */
37 #define ROB_HIT_POINT_TOP_LEFT 0
38 #define ROB_HIT_POINT_CENTRE 1
39 
40 /* Object drag points */
41 #define ROB_DRAG_POINT_ANYWHERE 0
42 #define ROB_DRAG_POINT_MIDDLE 1
43 
44 /* Object drag types */
45 #define ROB_DRAG_ANYWHERE 1
46 #define ROB_DRAG_RESTRICT_TO_PARENT 2
47 #define ROB_DRAG_RESTRICT_TO_PARENT_ORIGIN 3
48 
49 /* ZOrder positions */
50 #define ROB_ZORDER_ABOVE_ALL 0
51 #define ROB_ZORDER_ABOVE 1
52 #define ROB_ZORDER_BELOW 2
53 
54 /* Pointer modes */
55 #define ROB_POINTER_MODE_OFF 0
56 #define ROB_POINTER_MODE_PHYSICAL 1
57 #define ROB_POINTER_MODE_SIMULATED 2
58 
59 /* Events */
60 #define ROB_EVENT_SEND_PRE_RENDER
61 
62 #define ROB_EVENT_OVER 10
63 #define ROB_EVENT_OUT 11
64 #define ROB_EVENT_PRESS 12
65 #define ROB_EVENT_CLICK 13
66 #define ROB_EVENT_RELEASE 14
67 #define ROB_EVENT_DRAG 15
68 #define ROB_EVENT_SELECT 38
69 
70 /* Error codes */
71 #define ROB_ERROR_NONE 0
72 #define ROB_ERROR_TOO_MANY_OBJECTS 100
73 #define ROB_ERROR_INVALID_OBJECT 200
74 #define ROB_ERROR_INVALID_OBJECT_ID 300
75 #define ROB_ERROR_INVALID_TARGET_OBJECT 400
76 #define ROB_ERROR_CANNOT_SET_SURFACE_ALPHA 500
77 #define ROB_ERROR_CANNOT_FILL_SURFACE 600
78 #define ROB_ERROR_CANNOT_BLIT_SURFACE 700
79 #define ROB_ERROR_INVALID_EVENT 800
80 
81 
82 /* Variables */
83 typedef struct robobject {
84 	int id;
85 	int pid;			/* Once object is loaded, use *pob instead; the engine does not use this after loading */
86 	int visible;		/* -2 (inherited), 0 or 1: Invisible objects are not manipulatable */
87 	int enabled;		/* -2 (inherited), 0 or 1: Disabled objects are not manipulatable */
88 	int alpha;			/* -2 (inherited) or 0 (transparent) to 255 (opaque) */
89 	int alpha_over;
90 	int alpha_press;
91 	int bgcolour;
92 	int bgcolour_over;
93 	int bgcolour_press;
94 	int x;				/* Object coordinates and dimensions */
95 	int y;
96 	int w;
97 	int h;
98 	SDL_Surface *img_surface;
99 	int img_x;			/* Image region */
100 	int img_y;
101 	int img_w;
102 	int img_h;
103 	SDL_Surface *img_over_surface;
104 	int img_over_x;		/* Image over region */
105 	int img_over_y;
106 	int img_over_w;
107 	int img_over_h;
108 	SDL_Surface *img_press_surface;
109 	int img_press_x;	/* Image press region */
110 	int img_press_y;
111 	int img_press_w;
112 	int img_press_h;
113 	int draggable;
114 	int drag_point;
115 	int drag_granularity;
116 	/* The properties below are set by the system when the object is created */
117 	int zorder;
118 	void *pob;			/* Parent object pointer */
119 } ROB_Object;
120 
121 ROB_Object *rob_lyr_pointer;
122 
123 typedef struct robevent {
124 	ROB_Object *rob_object;
125 	int klasse;
126 } ROB_Event;
127 
128 typedef struct robopenv {
129 	int systempointer;								/* True or false */
130 	int pointer;									/* True or false */
131 	int pointer_mode;								/* Pointer mode */
132 	int pointer_move_unit_low;						/* Unit pointer should move unaccelerated */
133 	int pointer_move_unit_high;						/* Unit pointer should move accelerated */
134 	int pointer_move_unit_threshold;				/* Number of units marking the low/high threshold */
135 	void (*event_processor)(ROB_Event *rob_event);	/* The function that receives events */
136 } ROB_OpEnv;
137 
138 /* Function prototypes */
139 void ROB_Init(ROB_OpEnv *op_env);
140 ROB_Object *ROB_GetObject(int id);
141 int ROB_CreateObject(ROB_Object *rob_object);
142 int ROB_SetObjectDefaults(ROB_Object *rob_object);
143 char *ROB_GetError(void);
144 int ROB_Quit(void);
145 int ROB_FreeAllChildObjects(ROB_Object *pob, int free_pob);
146 int ROB_FreeAllDescendantObjects(ROB_Object *ancestor, int free_ancestor);
147 int ROB_FreeObject(ROB_Object *rob_object, int free_images_only);
148 int ROB_RenderObjects(void);
149 void ROB_GenerateEvents(int *actionid);
150 int ROB_ShowEvent(ROB_Event *rob_event, const char *func);
151 int ROB_SetOpEnvSystemPointer(int systempointer);
152 int ROB_SetOpEnvPointer(int pointer, int pointer_mode);
153 int ROB_SetOpEnvEventProcessor(void (*event_processor)(ROB_Event *rob_event));
154 
155 
156 
157 
158 
159 
160 
161