| 1 | #ifndef AW_WINDOW_XM_HXX |
|---|
| 2 | #define AW_WINDOW_XM_HXX |
|---|
| 3 | |
|---|
| 4 | #ifndef AW_DEVICE_HXX |
|---|
| 5 | #include <aw_device.hxx> |
|---|
| 6 | #endif |
|---|
| 7 | #ifndef AW_KEYSYM_HXX |
|---|
| 8 | #include <aw_keysym.hxx> |
|---|
| 9 | #endif |
|---|
| 10 | |
|---|
| 11 | // Makrodefinitionen |
|---|
| 12 | #define p_r prvt |
|---|
| 13 | #define p_global (root->prvt) |
|---|
| 14 | #define p_aww(aww) (aww->p_w) |
|---|
| 15 | |
|---|
| 16 | bool AW_remove_button_from_sens_list(AW_root *aw_root, Widget w); |
|---|
| 17 | |
|---|
| 18 | #define MAP_ARAM(ar) p_w->areas[ar] |
|---|
| 19 | |
|---|
| 20 | #define INFO_WIDGET p_w->areas[AW_INFO_AREA]->area |
|---|
| 21 | #define INFO_FORM p_w->areas[AW_INFO_AREA]->form |
|---|
| 22 | #define MIDDLE_WIDGET p_w->areas[AW_MIDDLE_AREA]->area |
|---|
| 23 | #define BOTTOM_WIDGET p_w->areas[AW_BOTTOM_AREA]->area |
|---|
| 24 | |
|---|
| 25 | #define AW_SCROLL_MAX 100 |
|---|
| 26 | #define AW_MAX_MENU_DEEP 10 |
|---|
| 27 | |
|---|
| 28 | #define RES_CONVERT( res_name, res_value) \ |
|---|
| 29 | XtVaTypedArg, (res_name), XmRString, (res_value), strlen(res_value) + 1 |
|---|
| 30 | |
|---|
| 31 | #define AW_MOTIF_LABEL |
|---|
| 32 | |
|---|
| 33 | #define RES_LABEL_CONVERT(str) \ |
|---|
| 34 | XmNlabelType, (str[0]=='#')?XmPIXMAP:XmSTRING,\ |
|---|
| 35 | XtVaTypedArg, (str[0]=='#')?XmNlabelPixmap:XmNlabelString, \ |
|---|
| 36 | XmRString, \ |
|---|
| 37 | aw_str_2_label(str,this), \ |
|---|
| 38 | strlen(aw_str_2_label(str,this))+1 |
|---|
| 39 | |
|---|
| 40 | #define RES_LABEL_CONVERT2(str,aww) \ |
|---|
| 41 | XmNlabelType, (str[0]=='#')?XmPIXMAP:XmSTRING,\ |
|---|
| 42 | XtVaTypedArg, (str[0]=='#')?XmNlabelPixmap:XmNlabelString, \ |
|---|
| 43 | XmRString, \ |
|---|
| 44 | aw_str_2_label(str,aww), \ |
|---|
| 45 | strlen(aw_str_2_label(str,aww))+1 |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | #define AW_JUSTIFY_LABEL(widget,corr) \ |
|---|
| 49 | switch(corr){\ |
|---|
| 50 | case 1: XtVaSetValues( widget,XmNalignment,XmALIGNMENT_CENTER,NULL);break;\ |
|---|
| 51 | case 2: XtVaSetValues( widget,XmNalignment,XmALIGNMENT_END,NULL);break;\ |
|---|
| 52 | default: break;\ |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | /*************************************************************************/ |
|---|
| 57 | struct AW_timer_cb_struct { |
|---|
| 58 | AW_timer_cb_struct(AW_root *ari, void (*g)(AW_root*,AW_CL ,AW_CL), AW_CL cd1i, AW_CL cd2i); |
|---|
| 59 | ~AW_timer_cb_struct(void); |
|---|
| 60 | AW_root *ar; |
|---|
| 61 | void (*f)(AW_root*,AW_CL ,AW_CL); |
|---|
| 62 | AW_CL cd1; |
|---|
| 63 | AW_CL cd2; |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | /************************************************************************/ |
|---|
| 69 | struct AW_buttons_struct { |
|---|
| 70 | AW_buttons_struct(AW_active maski, Widget w, AW_buttons_struct *next); |
|---|
| 71 | ~AW_buttons_struct(); |
|---|
| 72 | |
|---|
| 73 | AW_active mask; |
|---|
| 74 | Widget button; |
|---|
| 75 | AW_buttons_struct *next; |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | /************************************************************************/ |
|---|
| 80 | struct AW_config_struct { |
|---|
| 81 | AW_config_struct( const char *idi, AW_active maski, Widget w, const char *variable_namei, const char *variable_valuei, AW_config_struct *nexti ); |
|---|
| 82 | |
|---|
| 83 | const char *id; |
|---|
| 84 | AW_active mask; |
|---|
| 85 | Widget widget; |
|---|
| 86 | const char *variable_name; |
|---|
| 87 | const char *variable_value; |
|---|
| 88 | AW_config_struct *next; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | struct AW_option_struct { |
|---|
| 93 | AW_option_struct( const char *variable_valuei, Widget choice_widgeti ); |
|---|
| 94 | AW_option_struct( int variable_valuei, Widget choice_widgeti ); |
|---|
| 95 | AW_option_struct( float variable_valuei, Widget choice_widgeti ); |
|---|
| 96 | ~AW_option_struct(); |
|---|
| 97 | |
|---|
| 98 | char *variable_value; |
|---|
| 99 | int variable_int_value; |
|---|
| 100 | float variable_float_value; |
|---|
| 101 | Widget choice_widget; |
|---|
| 102 | AW_option_struct *next; |
|---|
| 103 | }; |
|---|
| 104 | |
|---|
| 105 | struct AW_option_menu_struct { |
|---|
| 106 | AW_option_menu_struct( int numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, Widget menu_widgeti, AW_pos xi, AW_pos yi, int correct); |
|---|
| 107 | |
|---|
| 108 | int option_menu_number; |
|---|
| 109 | char *variable_name; |
|---|
| 110 | AW_VARIABLE_TYPE variable_type; |
|---|
| 111 | Widget label_widget; |
|---|
| 112 | Widget menu_widget; |
|---|
| 113 | AW_option_struct *first_choice; |
|---|
| 114 | AW_option_struct *last_choice; |
|---|
| 115 | AW_option_struct *default_choice; |
|---|
| 116 | AW_pos x; |
|---|
| 117 | AW_pos y; |
|---|
| 118 | int correct_for_at_center_intern; // needed for centered and right justified menus (former member of AW_at) |
|---|
| 119 | |
|---|
| 120 | AW_option_menu_struct *next; |
|---|
| 121 | }; |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | struct AW_toggle_struct { |
|---|
| 125 | |
|---|
| 126 | AW_toggle_struct( const char *variable_valuei, Widget choice_widgeti ); |
|---|
| 127 | AW_toggle_struct( int variable_valuei, Widget choice_widgeti ); |
|---|
| 128 | AW_toggle_struct( float variable_valuei, Widget choice_widgeti ); |
|---|
| 129 | |
|---|
| 130 | char *variable_value; |
|---|
| 131 | int variable_int_value; |
|---|
| 132 | float variable_float_value; |
|---|
| 133 | Widget toggle_widget; |
|---|
| 134 | |
|---|
| 135 | AW_toggle_struct *next; |
|---|
| 136 | |
|---|
| 137 | }; |
|---|
| 138 | |
|---|
| 139 | struct AW_toggle_field_struct { |
|---|
| 140 | |
|---|
| 141 | AW_toggle_field_struct( int toggle_field_numberi, const char *variable_namei, AW_VARIABLE_TYPE variable_typei, Widget label_widgeti, int correct); |
|---|
| 142 | |
|---|
| 143 | int toggle_field_number; |
|---|
| 144 | char *variable_name; |
|---|
| 145 | AW_VARIABLE_TYPE variable_type; |
|---|
| 146 | Widget label_widget; |
|---|
| 147 | AW_toggle_struct *first_toggle; |
|---|
| 148 | AW_toggle_struct *last_toggle; |
|---|
| 149 | AW_toggle_struct *default_toggle; |
|---|
| 150 | int correct_for_at_center_intern; // needed for centered and right justified toggle fields (former member of AW_at) |
|---|
| 151 | |
|---|
| 152 | AW_toggle_field_struct *next; |
|---|
| 153 | |
|---|
| 154 | }; |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | struct AW_select_table_struct { |
|---|
| 158 | |
|---|
| 159 | AW_select_table_struct( const char *displayedi, const char *value ); |
|---|
| 160 | AW_select_table_struct( const char *displayedi, long value ); |
|---|
| 161 | AW_select_table_struct( const char *displayedi, float value ); |
|---|
| 162 | AW_select_table_struct( const char *displayedi, void *pointer ); |
|---|
| 163 | |
|---|
| 164 | ~AW_select_table_struct( void ); |
|---|
| 165 | |
|---|
| 166 | static char *copy_string(const char *str); |
|---|
| 167 | |
|---|
| 168 | char *displayed; |
|---|
| 169 | |
|---|
| 170 | #if defined(DEVEL_RALF) |
|---|
| 171 | #warning make the following variables a union |
|---|
| 172 | #endif // DEVEL_RALF |
|---|
| 173 | char *char_value; |
|---|
| 174 | long int_value; |
|---|
| 175 | float float_value; |
|---|
| 176 | void *pointer_value; |
|---|
| 177 | |
|---|
| 178 | int is_selected; // internal use only |
|---|
| 179 | |
|---|
| 180 | AW_select_table_struct *next; |
|---|
| 181 | }; |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | /***************************************************************************************************** |
|---|
| 186 | area management: devices callbacks |
|---|
| 187 | *****************************************************************************************************/ |
|---|
| 188 | |
|---|
| 189 | class AW_common; |
|---|
| 190 | class AW_device_Xm; |
|---|
| 191 | class AW_device_click; |
|---|
| 192 | class AW_device_size; |
|---|
| 193 | class AW_device_print; |
|---|
| 194 | class AW_cb_struct; |
|---|
| 195 | |
|---|
| 196 | class AW_area_management { |
|---|
| 197 | friend class AW_window; |
|---|
| 198 | friend class AW_window_simple; |
|---|
| 199 | friend class AW_window_simple_menu; |
|---|
| 200 | friend class AW_window_menu; |
|---|
| 201 | friend class AW_window_menu_modes; |
|---|
| 202 | friend class AW_window_message; |
|---|
| 203 | |
|---|
| 204 | public: |
|---|
| 205 | Widget form; // for resizing |
|---|
| 206 | Widget area; // for displaying additional information |
|---|
| 207 | AW_common *common; |
|---|
| 208 | AW_device_Xm *device; |
|---|
| 209 | AW_device_click *click_device; |
|---|
| 210 | AW_device_size *size_device; |
|---|
| 211 | AW_device_print *print_device; |
|---|
| 212 | |
|---|
| 213 | AW_cb_struct *expose_cb; |
|---|
| 214 | AW_cb_struct *resize_cb; |
|---|
| 215 | int do_resize_if_expose; |
|---|
| 216 | AW_cb_struct *double_click_cb; |
|---|
| 217 | long click_time; |
|---|
| 218 | |
|---|
| 219 | void create_devices(AW_window *aww, AW_area ar); |
|---|
| 220 | |
|---|
| 221 | void set_expose_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 222 | void set_resize_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 223 | void set_input_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 224 | void set_double_click_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 225 | void set_motion_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 226 | |
|---|
| 227 | bool is_expose_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 228 | bool is_resize_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 229 | bool is_input_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 230 | bool is_double_click_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 231 | bool is_motion_callback(AW_window *aww, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 232 | |
|---|
| 233 | AW_area_management(AW_root *awr,Widget form,Widget widget); |
|---|
| 234 | }; |
|---|
| 235 | /************************************************************************/ |
|---|
| 236 | |
|---|
| 237 | class AW_selection_list; |
|---|
| 238 | |
|---|
| 239 | class AW_root_Motif { |
|---|
| 240 | Widget last_widget; // last created (sensitive) widget |
|---|
| 241 | public: |
|---|
| 242 | Display *display; |
|---|
| 243 | XtAppContext context; |
|---|
| 244 | Widget toplevel_widget; |
|---|
| 245 | Widget main_widget; |
|---|
| 246 | class AW_window *main_aww; |
|---|
| 247 | Widget message_shell; |
|---|
| 248 | |
|---|
| 249 | Pixel foreground; |
|---|
| 250 | Pixel background; |
|---|
| 251 | |
|---|
| 252 | XmFontList fontlist; |
|---|
| 253 | |
|---|
| 254 | AW_buttons_struct *button_list; |
|---|
| 255 | |
|---|
| 256 | AW_config_struct *config_list; |
|---|
| 257 | AW_config_struct *last_config; |
|---|
| 258 | |
|---|
| 259 | AW_option_menu_struct *option_menu_list; |
|---|
| 260 | AW_option_menu_struct *last_option_menu; |
|---|
| 261 | AW_option_menu_struct *current_option_menu; |
|---|
| 262 | |
|---|
| 263 | AW_toggle_field_struct *toggle_field_list; |
|---|
| 264 | AW_toggle_field_struct *last_toggle_field; |
|---|
| 265 | |
|---|
| 266 | AW_selection_list *selection_list; |
|---|
| 267 | AW_selection_list *last_selection_list; |
|---|
| 268 | |
|---|
| 269 | int screen_depth; |
|---|
| 270 | unsigned long *color_table; |
|---|
| 271 | Colormap colormap; |
|---|
| 272 | |
|---|
| 273 | int help_active; |
|---|
| 274 | Cursor clock_cursor; |
|---|
| 275 | Cursor question_cursor; |
|---|
| 276 | Display *old_cursor_display; |
|---|
| 277 | Window old_cursor_window; |
|---|
| 278 | bool no_exit; |
|---|
| 279 | |
|---|
| 280 | char *recording_macro_path; |
|---|
| 281 | FILE *recording_macro_file; |
|---|
| 282 | char *application_name_for_macros; |
|---|
| 283 | char *stop_action_name; |
|---|
| 284 | FILE *executing_macro_file; |
|---|
| 285 | GB_HASH *action_hash; |
|---|
| 286 | |
|---|
| 287 | AW_root_Motif() {}; |
|---|
| 288 | ~AW_root_Motif() {}; |
|---|
| 289 | |
|---|
| 290 | Widget get_last_widget() const { return last_widget; } |
|---|
| 291 | void set_last_widget(Widget w) { last_widget = w; } |
|---|
| 292 | |
|---|
| 293 | void set_cursor(Display *d, Window w, Cursor c); |
|---|
| 294 | void normal_cursor(void); |
|---|
| 295 | }; |
|---|
| 296 | |
|---|
| 297 | /**********************************************************************/ |
|---|
| 298 | const int AW_NUMBER_OF_F_KEYS = 20; |
|---|
| 299 | |
|---|
| 300 | class AW_window_Motif { |
|---|
| 301 | public: |
|---|
| 302 | |
|---|
| 303 | Widget shell; // for show, hide |
|---|
| 304 | Widget scroll_bar_vertical; // for scrolling the |
|---|
| 305 | Widget scroll_bar_horizontal; // draw area |
|---|
| 306 | Widget menu_bar[AW_MAX_MENU_DEEP]; // for inserting topics to menu bar |
|---|
| 307 | int menu_deep; |
|---|
| 308 | Widget help_pull_down; // for inserting subtopics to the help pull_down |
|---|
| 309 | Widget mode_area; // for inserting buttons to the mode area |
|---|
| 310 | short number_of_modes; // holds number of mode buttons in window |
|---|
| 311 | |
|---|
| 312 | // ********** local modifiers ********** |
|---|
| 313 | |
|---|
| 314 | AW_cb_struct **modes_f_callbacks; |
|---|
| 315 | Widget *modes_widgets; |
|---|
| 316 | int selected_mode; |
|---|
| 317 | AW_cb_struct *popup_cb; |
|---|
| 318 | Widget frame; |
|---|
| 319 | |
|---|
| 320 | Widget toggle_field; |
|---|
| 321 | Widget toggle_label; |
|---|
| 322 | char *toggle_field_var_name; |
|---|
| 323 | AW_VARIABLE_TYPE toggle_field_var_type; |
|---|
| 324 | AW_key_mod keymodifier; |
|---|
| 325 | |
|---|
| 326 | AW_area_management *areas[AW_MAX_AREA]; |
|---|
| 327 | int WM_top_offset; // WM top area |
|---|
| 328 | int WM_left_offset; |
|---|
| 329 | |
|---|
| 330 | AW_window_Motif(); |
|---|
| 331 | ~AW_window_Motif() {}; |
|---|
| 332 | }; |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | void aw_root_init_font(Display *tool_d); |
|---|
| 336 | const char *aw_str_2_label(const char *str,AW_window *aww); |
|---|
| 337 | void AW_label_in_awar_list(AW_window *aww,Widget widget,const char *str); |
|---|
| 338 | void AW_server_callback(Widget wgt, XtPointer aw_cb_struct, XtPointer call_data); |
|---|
| 339 | void aw_message_timer_listen_event(AW_root *awr, AW_CL cl1, AW_CL cl2); |
|---|
| 340 | void message_cb( AW_window *aw, AW_CL cd1 ); |
|---|
| 341 | // void macro_message_cb( AW_window *aw, AW_CL cd1 ); |
|---|
| 342 | void input_cb( AW_window *aw, AW_CL cd1 ); |
|---|
| 343 | void input_history_cb( AW_window *aw, AW_CL cl_mode); // internal |
|---|
| 344 | |
|---|
| 345 | Widget aw_create_shell(AW_window *aww, bool allow_resize, bool allow_close, int width, int height, int posx, int posy); |
|---|
| 346 | void aw_realize_widget(AW_window *aww); |
|---|
| 347 | void aw_create_help_entry(AW_window *aww); |
|---|
| 348 | |
|---|
| 349 | #else |
|---|
| 350 | #error aw_window_Xm.hxx included twice |
|---|
| 351 | #endif |
|---|