1 | #ifndef aw_root_hxx_included |
---|
2 | #define aw_root_hxx_included |
---|
3 | |
---|
4 | #ifndef _STDIO_H |
---|
5 | #include <stdio.h> |
---|
6 | #endif |
---|
7 | |
---|
8 | #define AW_ROOT_DEFAULT (aw_main_root_default) |
---|
9 | class AW_root; |
---|
10 | class AW_window; |
---|
11 | typedef long AW_CL; // generic client data type (void *) |
---|
12 | |
---|
13 | typedef void (*AW_RCB)(AW_root*,AW_CL,AW_CL); |
---|
14 | typedef void (*AW_RCB0)(AW_root*); |
---|
15 | typedef void (*AW_RCB1)(AW_root*,AW_CL); |
---|
16 | typedef void (*AW_RCB2)(AW_root*,AW_CL,AW_CL); |
---|
17 | typedef AW_window *(*AW_PPP)(AW_root*,AW_CL,AW_CL); |
---|
18 | |
---|
19 | typedef const char *AWAR; |
---|
20 | typedef long AW_bitset; |
---|
21 | typedef double AW_pos; |
---|
22 | typedef float AW_grey_level; // <0 dont fill 0.0 white 1.0 black |
---|
23 | typedef void *AW_default; // should be GBDATA * |
---|
24 | typedef AW_bitset AW_active; // bits to activate/inactivate buttons |
---|
25 | typedef int AW_font; |
---|
26 | |
---|
27 | typedef const char *GB_ERROR; |
---|
28 | typedef struct gbs_hash_struct GB_HASH; |
---|
29 | |
---|
30 | #ifdef HAVE_BOOL |
---|
31 | typedef bool AW_BOOL; |
---|
32 | const bool AW_FALSE = false; |
---|
33 | const bool AW_TRUE = true; |
---|
34 | #else |
---|
35 | typedef enum { AW_FALSE=0, AW_TRUE } AW_BOOL; |
---|
36 | #endif |
---|
37 | |
---|
38 | extern AW_default aw_main_root_default; |
---|
39 | |
---|
40 | #define AWUSE(variable) variable=variable |
---|
41 | |
---|
42 | typedef enum { |
---|
43 | AW_NONE = 0, |
---|
44 | AW_BIT = 1, |
---|
45 | AW_BYTE = 2, |
---|
46 | AW_INT = 3, |
---|
47 | AW_FLOAT = 4, |
---|
48 | AW_BITS = 6, |
---|
49 | AW_BYTES = 8, |
---|
50 | AW_INTS = 9, |
---|
51 | AW_FLOATS = 10, |
---|
52 | AW_STRING = 12, |
---|
53 | AW_SYTRING_SHORT = 13, |
---|
54 | AW_DB = 15, |
---|
55 | AW_TYPE_MAX = 16 |
---|
56 | } AW_VARIABLE_TYPE; // identical to GBDATA types |
---|
57 | |
---|
58 | typedef struct { |
---|
59 | int t, b, l, r; |
---|
60 | } AW_rectangle; |
---|
61 | |
---|
62 | typedef struct { |
---|
63 | AW_pos t, b, l, r; |
---|
64 | } AW_world; |
---|
65 | |
---|
66 | typedef char *AW_error; |
---|
67 | |
---|
68 | int aw_message( const char *msg, const char *buttons ); |
---|
69 | void aw_set_local_message(); // no message window, AWAR tmp/Message instead |
---|
70 | // interactive message: buttons = "OK,CANCEL,...." |
---|
71 | void aw_message(const char *msg); |
---|
72 | extern char AW_ERROR_BUFFER[1024]; |
---|
73 | void aw_message(); // prints AW_ERROR_BUFFER; |
---|
74 | void aw_macro_message(const char *temp,...);// gives control to the user |
---|
75 | char *aw_input(const char *title, const char *awar_value, const char *default_input=0); |
---|
76 | // Reads a string from the user |
---|
77 | void AW_ERROR(const char *templat, ...); |
---|
78 | |
---|
79 | void aw_initstatus( void ); // call this function only once as early as possible |
---|
80 | void aw_openstatus( const char *title ); // show status |
---|
81 | void aw_closestatus( void ); // hide status |
---|
82 | |
---|
83 | int aw_status( const char *text ); // return 1 if exit button is pressed + set statustext |
---|
84 | |
---|
85 | #ifdef __cplusplus |
---|
86 | extern "C" { |
---|
87 | #endif |
---|
88 | |
---|
89 | int aw_status( double gauge ); // return 1 if exit button is pressed + set statusslider |
---|
90 | |
---|
91 | #ifdef __cplusplus |
---|
92 | } |
---|
93 | #endif |
---|
94 | |
---|
95 | int aw_status( void ); // return 1 if exit button is pressed |
---|
96 | |
---|
97 | void aw_error( const char *text, const char *text2 ); // internal error: asks for core |
---|
98 | |
---|
99 | class AW_root_Motif; |
---|
100 | class AW_awar; |
---|
101 | struct AW_var_callback; |
---|
102 | struct AW_xfig_vectorfont; |
---|
103 | |
---|
104 | typedef enum { |
---|
105 | NO_EVENT = 0, |
---|
106 | KEY_PRESSED = 2, |
---|
107 | KEY_RELEASED = 3 |
---|
108 | } AW_ProcessEventType; |
---|
109 | |
---|
110 | class AW_root { |
---|
111 | private: |
---|
112 | protected: |
---|
113 | public: |
---|
114 | static AW_root *THIS; |
---|
115 | AW_root_Motif *prvt; // Do not use !!! |
---|
116 | AW_BOOL value_changed; |
---|
117 | long changer_of_variable; |
---|
118 | |
---|
119 | int y_correction_for_input_labels; |
---|
120 | |
---|
121 | AW_active global_mask; |
---|
122 | |
---|
123 | GB_HASH *hash_table_for_variables; |
---|
124 | |
---|
125 | AW_BOOL variable_set_by_toggle_field; |
---|
126 | |
---|
127 | int number_of_toggle_fields; |
---|
128 | int number_of_option_menues; |
---|
129 | |
---|
130 | void *get_aw_var_struct(char *awar); |
---|
131 | void *get_aw_var_struct_no_error(char *awar); |
---|
132 | |
---|
133 | AW_BOOL disable_callbacks; |
---|
134 | struct AW_var_callback *focus_callback_list; |
---|
135 | |
---|
136 | int active_windows; |
---|
137 | void window_show(); // a window is set to screen |
---|
138 | void window_hide(); |
---|
139 | /********************* the read only public section ***********************/ |
---|
140 | AW_default application_database; |
---|
141 | short font_width; |
---|
142 | short font_height; |
---|
143 | short font_ascent; |
---|
144 | GB_HASH *hash_for_windows; |
---|
145 | |
---|
146 | /* PJ - vectorfont stuff */ |
---|
147 | float vectorfont_userscale; // user scaling |
---|
148 | char *vectorfont_name; // name of font |
---|
149 | int vectorfont_zoomtext; // zoomtext calls: 0 = Xfont, 1 = vectorfont |
---|
150 | struct AW_xfig_vectorfont *vectorfont_lines; // graphic data of the font |
---|
151 | |
---|
152 | /************************* the real public section *************************/ |
---|
153 | |
---|
154 | AW_root(); |
---|
155 | ~AW_root(); |
---|
156 | enum { AW_MONO_COLOR, AW_RGB_COLOR } color_mode; |
---|
157 | |
---|
158 | void init_variables( AW_default database ); |
---|
159 | void init( const char *programmname , AW_BOOL no_exit = AW_FALSE); |
---|
160 | void main_loop(void); |
---|
161 | void process_events(void); |
---|
162 | AW_ProcessEventType peek_key_event(AW_window *); |
---|
163 | |
---|
164 | void add_timed_callback( int ms, void (*f)(class AW_root*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
---|
165 | void set_focus_callback( void (*f)(class AW_root*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); /* any focus callback in any window */ |
---|
166 | |
---|
167 | class AW_awar *awar(const char *awar); |
---|
168 | class AW_awar *awar_no_error(const char *awar); |
---|
169 | |
---|
170 | AW_awar *awar_string( const char *var_name, const char *default_value = "", AW_default default_file = AW_ROOT_DEFAULT); |
---|
171 | AW_awar *awar_int( const char *var_name, long default_value = 0 , AW_default default_file = AW_ROOT_DEFAULT); |
---|
172 | AW_awar *awar_float( const char *var_name, float default_value = 0.0, AW_default default_file = AW_ROOT_DEFAULT ); |
---|
173 | |
---|
174 | AW_default open_default(const char *default_name); |
---|
175 | AW_error *save_default( const char *awar_name ); |
---|
176 | AW_error *save_default(AW_default aw_default,const char *file_name); |
---|
177 | AW_default get_default(const char *varname); |
---|
178 | AW_default get_gbdata(const char *varname); |
---|
179 | |
---|
180 | // ************** Set and clear sensitivity of buttons and menus ********* |
---|
181 | void set_sensitive(AW_active mask); |
---|
182 | void set_sensitive( const char *id ); |
---|
183 | void set_insensitive( const char *id ); |
---|
184 | |
---|
185 | |
---|
186 | GB_ERROR start_macro_recording(const char *file,const char *application_id, const char *stop_action_name); |
---|
187 | GB_ERROR stop_macro_recording(); |
---|
188 | GB_ERROR execute_macro(const char *file); |
---|
189 | void stop_execute_macro(); // Starts macro window main loop, delayed return |
---|
190 | GB_ERROR enable_execute_macro(FILE *mfile,const char *mname); // leave macro window main loop, returns stop_execute_macro |
---|
191 | GB_ERROR check_for_remote_command(AW_default gb_main,const char *rm_base); |
---|
192 | |
---|
193 | /************************************************************************* |
---|
194 | Fonts |
---|
195 | *************************************************************************/ |
---|
196 | const char *font_2_ascii(AW_font font_nr); // converts fontnr to string |
---|
197 | // returns 0 if font is not available |
---|
198 | int font_2_xfig(AW_font font_nr); // converts fontnr to xfigid |
---|
199 | // negative values indicate monospaced f. |
---|
200 | |
---|
201 | }; |
---|
202 | |
---|
203 | |
---|
204 | /************************************************************************* |
---|
205 | AWARS |
---|
206 | *************************************************************************/ |
---|
207 | struct AW_var_callback; |
---|
208 | struct AW_var_target; |
---|
209 | |
---|
210 | class AW_awar { |
---|
211 | struct { |
---|
212 | struct { |
---|
213 | float min; |
---|
214 | float max; |
---|
215 | } f; |
---|
216 | const char *srt; |
---|
217 | } pp; |
---|
218 | struct AW_var_callback *callback_list; |
---|
219 | struct AW_var_target *target_list; |
---|
220 | |
---|
221 | public: |
---|
222 | // read only |
---|
223 | class AW_root *root; |
---|
224 | #ifdef GB_INCLUDED |
---|
225 | |
---|
226 | friend void AW_var_gbdata_callback_delete_intern(GBDATA *gbd, int *cl); |
---|
227 | |
---|
228 | GBDATA *gb_var; |
---|
229 | GBDATA *gb_origin; |
---|
230 | #else |
---|
231 | void *gb_var; |
---|
232 | void *gb_origin; |
---|
233 | #endif |
---|
234 | // read only |
---|
235 | void run_callbacks(); |
---|
236 | void update_target(AW_var_target*pntr); |
---|
237 | void update_targets(); |
---|
238 | AW_VARIABLE_TYPE variable_type; |
---|
239 | |
---|
240 | |
---|
241 | AW_awar( AW_VARIABLE_TYPE var_type, const char *var_name, const char *var_value, double var_double_value, AW_default default_file, AW_root *root ); |
---|
242 | |
---|
243 | char *awar_name; // name of the awar |
---|
244 | |
---|
245 | AW_awar *add_callback(void (*f)(AW_root*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
---|
246 | AW_awar *add_callback(void (*f)(AW_root*,AW_CL), AW_CL cd1); |
---|
247 | AW_awar *add_callback(void (*f)(AW_root*)); |
---|
248 | |
---|
249 | AW_awar *remove_callback( void (*f)(AW_root*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2 ); // remove a callback, please set unused AW_CL to (AW_CL)0 |
---|
250 | |
---|
251 | AW_awar *add_target_var( char **ppchr); |
---|
252 | AW_awar *add_target_var( long *pint); |
---|
253 | AW_awar *add_target_var( float *pfloat); |
---|
254 | void update(); // awar has changed |
---|
255 | |
---|
256 | AW_awar *set_minmax(float min, float max); |
---|
257 | AW_awar *set_srt(const char *srt); |
---|
258 | |
---|
259 | AW_awar *map(const char *awarn) { return this->map(root->awar(awarn)); } |
---|
260 | AW_awar *map(AW_default dest); /* map to new address */ |
---|
261 | AW_awar *map(AW_awar *dest); /* map to new address */ |
---|
262 | AW_awar *unmap(); /* map to original address */ |
---|
263 | |
---|
264 | void get(char **p_string); /* delete existing targets !!!*/ |
---|
265 | void get(long *p_int); |
---|
266 | void get(double *p_double); |
---|
267 | void get(float *p_float); |
---|
268 | AW_VARIABLE_TYPE get_type(); |
---|
269 | char *read_string(); |
---|
270 | char *read_as_string(); |
---|
271 | double read_float(); |
---|
272 | long read_int(); |
---|
273 | |
---|
274 | GB_ERROR write_string(const char *aw_string); |
---|
275 | GB_ERROR write_as_string(const char *aw_string); |
---|
276 | GB_ERROR write_int(long aw_int); |
---|
277 | GB_ERROR write_float(double aw_double); |
---|
278 | GB_ERROR write_as(char *aw_value) { return write_as_string(aw_value);}; |
---|
279 | GB_ERROR toggle_toggle(); /* switches between 1/0 */ |
---|
280 | void touch(void); |
---|
281 | }; |
---|
282 | |
---|
283 | |
---|
284 | |
---|
285 | #endif |
---|