| 1 | #ifndef AW_WINDOW_HXX |
|---|
| 2 | #define AW_WINDOW_HXX |
|---|
| 3 | |
|---|
| 4 | #ifndef AW_ROOT_HXX |
|---|
| 5 | #include <aw_root.hxx> |
|---|
| 6 | #endif |
|---|
| 7 | #ifndef AW_DEVICE_HXX |
|---|
| 8 | #include <aw_device.hxx> |
|---|
| 9 | #endif |
|---|
| 10 | #ifndef AW_KEYSYM_HXX |
|---|
| 11 | #include <aw_keysym.hxx> |
|---|
| 12 | #endif |
|---|
| 13 | |
|---|
| 14 | class AW_window; |
|---|
| 15 | typedef struct _WidgetRec *Widget; |
|---|
| 16 | |
|---|
| 17 | typedef void (*AW_CB)(AW_window*,AW_CL,AW_CL); |
|---|
| 18 | typedef void (*AW_CB0)(AW_window*); |
|---|
| 19 | typedef void (*AW_CB1)(AW_window*,AW_CL); |
|---|
| 20 | typedef void (*AW_CB2)(AW_window*,AW_CL,AW_CL); |
|---|
| 21 | typedef AW_window *(*AW_Window_Creator)(AW_root*,AW_CL); |
|---|
| 22 | |
|---|
| 23 | //-------------------------------------------------------------------------------- |
|---|
| 24 | |
|---|
| 25 | #define AW_POPUP ((AW_CB)(-1)) |
|---|
| 26 | // AW_POPDOWN is defined later in this section |
|---|
| 27 | |
|---|
| 28 | #define AW_MESSAGE_TIME 2000 |
|---|
| 29 | #define AW_HEADER_MAIN extern "C" { int XtAppInitialize(); } void aw_never_called_main(void) { XtAppInitialize(); } |
|---|
| 30 | |
|---|
| 31 | //======= Used in Tune background function ================================= |
|---|
| 32 | #define TUNE_BUTTON 8 |
|---|
| 33 | #define TUNE_INPUT (-TUNE_BUTTON) |
|---|
| 34 | #define TUNE_SUBMENU 0 |
|---|
| 35 | #define TUNE_MENUTOPIC (-12) |
|---|
| 36 | #define TUNE_BRIGHT (256+30) |
|---|
| 37 | #define TUNE_DARK (-TUNE_BRIGHT) |
|---|
| 38 | // ========================================================================== |
|---|
| 39 | |
|---|
| 40 | #ifndef AW_AT_HXX |
|---|
| 41 | class AW_at; |
|---|
| 42 | #endif |
|---|
| 43 | |
|---|
| 44 | class AW_at_size { |
|---|
| 45 | |
|---|
| 46 | int to_offset_x; // here we use offsets (not positions like in AW_at) |
|---|
| 47 | int to_offset_y; |
|---|
| 48 | bool to_position_exists; |
|---|
| 49 | |
|---|
| 50 | bool attach_x; // attach right side to right form |
|---|
| 51 | bool attach_y; |
|---|
| 52 | bool attach_lx; // attach left side to right form |
|---|
| 53 | bool attach_ly; |
|---|
| 54 | bool attach_any; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | public: |
|---|
| 58 | void store(const AW_at *at); |
|---|
| 59 | void restore(AW_at *at) const; |
|---|
| 60 | }; |
|---|
| 61 | |
|---|
| 62 | class AW_at_maxsize { |
|---|
| 63 | int maxx; |
|---|
| 64 | int maxy; |
|---|
| 65 | |
|---|
| 66 | public: |
|---|
| 67 | void store(const AW_at *at); |
|---|
| 68 | void restore(AW_at *at) const; |
|---|
| 69 | }; |
|---|
| 70 | |
|---|
| 71 | typedef enum { |
|---|
| 72 | AW_Keyboard_Press = 1, |
|---|
| 73 | AW_Keyboard_Release = 2, |
|---|
| 74 | AW_Mouse_Press = 3, |
|---|
| 75 | AW_Mouse_Release = 4, |
|---|
| 76 | AW_Mouse_Drag = 5 |
|---|
| 77 | } AW_event_type; |
|---|
| 78 | |
|---|
| 79 | typedef const char *AW_label; // label for buttons menues etc |
|---|
| 80 | // "fsdf" simple label // no '/' symbol !!! |
|---|
| 81 | // "awarname/asdf" // awar name (any '/' in string) |
|---|
| 82 | // "#file.bitmap" // bitmap in $ARBHOME/lib/pixmaps/file.bitmap |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | struct AW_event { |
|---|
| 86 | AW_event_type type; /* AW_Keyboard or AW_Mouse */ |
|---|
| 87 | unsigned long time; /* time in msec, when event occured */ |
|---|
| 88 | //***** button fields |
|---|
| 89 | unsigned int button; /* which mouse button was pressed 1,2,3 */ |
|---|
| 90 | int x,y; /* pointer x,y coordinates in the event window */ |
|---|
| 91 | //****** key fields |
|---|
| 92 | AW_key_mod keymodifier; /* control alt meta .... */ |
|---|
| 93 | AW_key_code keycode; /* which key type was pressed */ |
|---|
| 94 | char character; /* the c character */ |
|---|
| 95 | }; |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | void AW_POPDOWN(AW_window *); |
|---|
| 99 | void AW_POPUP_HELP(AW_window *,AW_CL /*char */ helpfile); |
|---|
| 100 | void AW_help_entry_pressed(AW_window *); |
|---|
| 101 | void AW_clock_cursor(AW_root *); |
|---|
| 102 | void AW_normal_cursor(AW_root *); |
|---|
| 103 | |
|---|
| 104 | /*************************************************************************/ |
|---|
| 105 | class AW_cb_struct { |
|---|
| 106 | AW_CL cd1; |
|---|
| 107 | AW_CL cd2; |
|---|
| 108 | AW_cb_struct *next; |
|---|
| 109 | |
|---|
| 110 | public: |
|---|
| 111 | // ************ This is not the public section ************* |
|---|
| 112 | AW_window *pop_up_window; |
|---|
| 113 | AW_CB f; |
|---|
| 114 | AW_window *aw; |
|---|
| 115 | const char *help_text; |
|---|
| 116 | char *id; |
|---|
| 117 | |
|---|
| 118 | // ************ The real public section ************* |
|---|
| 119 | AW_cb_struct(AW_window *awi, |
|---|
| 120 | AW_CB g, |
|---|
| 121 | AW_CL cd1i = 0, |
|---|
| 122 | AW_CL cd2i = 0, |
|---|
| 123 | const char *help_texti = 0, |
|---|
| 124 | AW_cb_struct *next = 0); |
|---|
| 125 | |
|---|
| 126 | void run_callback(void); // runs the whole list |
|---|
| 127 | bool contains(AW_CB g); // test if contained in list |
|---|
| 128 | bool is_equal(const AW_cb_struct& other) const; |
|---|
| 129 | |
|---|
| 130 | #if defined(DEBUG) |
|---|
| 131 | AW_CL get_cd1() const { return cd1; } |
|---|
| 132 | AW_CL get_cd2() const { return cd2; } |
|---|
| 133 | #endif // DEBUG |
|---|
| 134 | }; |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | enum { |
|---|
| 138 | AWM_DISABLED = 0, // disabled items (used for dynamically dis-/enabled items) |
|---|
| 139 | AWM_BASIC = 1, |
|---|
| 140 | AWM_EXP = 2, |
|---|
| 141 | AWM_ALL = AWM_BASIC|AWM_EXP |
|---|
| 142 | }; |
|---|
| 143 | |
|---|
| 144 | enum { |
|---|
| 145 | AWM_MASK_UNKNOWN = AWM_DISABLED, |
|---|
| 146 | AWM_MASK_DEFAULT = AWM_BASIC, |
|---|
| 147 | AWM_MASK_EXPERT = AWM_ALL |
|---|
| 148 | }; |
|---|
| 149 | |
|---|
| 150 | typedef char *AW_pixmap; |
|---|
| 151 | |
|---|
| 152 | class AW_window_Motif; |
|---|
| 153 | struct AW_select_table_struct; |
|---|
| 154 | |
|---|
| 155 | class AW_selection_list { |
|---|
| 156 | AW_select_table_struct *loop_pntr; |
|---|
| 157 | public: |
|---|
| 158 | AW_selection_list( const char *variable_namei, int variable_typei, Widget select_list_widgeti ); |
|---|
| 159 | |
|---|
| 160 | char *variable_name; |
|---|
| 161 | AW_VARIABLE_TYPE variable_type; |
|---|
| 162 | Widget select_list_widget; |
|---|
| 163 | bool value_equal_display; // set true to fix load/save of some selection lists |
|---|
| 164 | |
|---|
| 165 | AW_select_table_struct *list_table; |
|---|
| 166 | AW_select_table_struct *last_of_list_table; |
|---|
| 167 | AW_select_table_struct *default_select; |
|---|
| 168 | AW_selection_list *next; |
|---|
| 169 | |
|---|
| 170 | // ******************** real public *************** |
|---|
| 171 | void selectAll(); |
|---|
| 172 | void deselectAll(); |
|---|
| 173 | const char *first_selected(); |
|---|
| 174 | const char *first_element(); |
|---|
| 175 | const char *next_element(); |
|---|
| 176 | }; |
|---|
| 177 | |
|---|
| 178 | struct AW_option_menu_struct; |
|---|
| 179 | struct aw_toggle_data; |
|---|
| 180 | |
|---|
| 181 | class AW_window { |
|---|
| 182 | private: |
|---|
| 183 | void all_menus_created(); |
|---|
| 184 | void create_toggle(const char *var_name, aw_toggle_data *tdata); |
|---|
| 185 | |
|---|
| 186 | protected: |
|---|
| 187 | AW_root *root; |
|---|
| 188 | |
|---|
| 189 | void check_at_pos( void ); |
|---|
| 190 | void create_devices(void); |
|---|
| 191 | void set_background(const char *colorname, Widget w); |
|---|
| 192 | |
|---|
| 193 | void wm_activate(); // un-minimize window and give it the focus (use show_and_activate()) |
|---|
| 194 | |
|---|
| 195 | public: |
|---|
| 196 | |
|---|
| 197 | // ************ This is not the public section ************* |
|---|
| 198 | |
|---|
| 199 | AW_window_Motif *p_w; // Do not use !!! |
|---|
| 200 | AW_at *_at; |
|---|
| 201 | AW_cb_struct *_callback; |
|---|
| 202 | AW_cb_struct *_d_callback; |
|---|
| 203 | |
|---|
| 204 | AW_window(); |
|---|
| 205 | virtual ~AW_window(); |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | AW_event event; |
|---|
| 209 | unsigned long click_time; |
|---|
| 210 | long color_table_size; |
|---|
| 211 | unsigned long *color_table; |
|---|
| 212 | |
|---|
| 213 | int recalc_size_at_show; |
|---|
| 214 | // 0 = do not resize |
|---|
| 215 | // 1 = do resize to default size |
|---|
| 216 | // 2 = do resize to user size (or default size if that is bigger) |
|---|
| 217 | |
|---|
| 218 | int number_of_timed_title_changes; |
|---|
| 219 | |
|---|
| 220 | void /*AW_xfig*/ *xfig_data; |
|---|
| 221 | |
|---|
| 222 | void create_window_variables( void ); |
|---|
| 223 | void show_grabbed(void); |
|---|
| 224 | void set_window_title_intern( char *title ); |
|---|
| 225 | |
|---|
| 226 | int calculate_string_width( int columns ); |
|---|
| 227 | int calculate_string_height( int columns, int offset ); |
|---|
| 228 | char *align_string( const char *string, int columns ); |
|---|
| 229 | |
|---|
| 230 | void update_label( int *widget, const char *var_value ); |
|---|
| 231 | void update_toggle( int *widget, const char *var_value, AW_CL cd ); |
|---|
| 232 | void update_input_field( int *widget, const char *var_value ); |
|---|
| 233 | void update_text_field( int *widget, const char *var_value ); |
|---|
| 234 | |
|---|
| 235 | void create_invisible( int columns ); |
|---|
| 236 | // void update_option_menu( int option_menu_number ); |
|---|
| 237 | void *_create_option_entry(AW_VARIABLE_TYPE type, const char *name, const char *mnemonic,const char *name_of_color ); |
|---|
| 238 | void update_toggle_field( int toggle_field_number ); |
|---|
| 239 | void update_selection_list_intern( AW_selection_list *selection_list ); |
|---|
| 240 | void _set_activate_callback(void *widget); |
|---|
| 241 | void unset_at_commands( void ); |
|---|
| 242 | void increment_at_commands( int width, int height ); |
|---|
| 243 | |
|---|
| 244 | |
|---|
| 245 | AW_color alloc_named_data_color(int colnum, char *colorname); |
|---|
| 246 | const char *GC_to_RGB(AW_device *device, int gc, int& red, int& green, int& blue); // returns colors in result-parameters or error message in return value |
|---|
| 247 | // Converts GC to RGB float values to the range (0 - 1.0) |
|---|
| 248 | const char *GC_to_RGB_float(AW_device *device, int gc, float& red, float& green, float& blue); |
|---|
| 249 | void _get_area_size(AW_area area, AW_rectangle *square); |
|---|
| 250 | int label_widget(void *wgt, AW_label str, char *mnemonic=0, int width =0, int alignment =0); |
|---|
| 251 | |
|---|
| 252 | // ------------------------------ |
|---|
| 253 | // The read only section |
|---|
| 254 | // ------------------------------ |
|---|
| 255 | |
|---|
| 256 | char *window_name; // window title |
|---|
| 257 | char *window_defaults_name; |
|---|
| 258 | bool window_is_shown; |
|---|
| 259 | |
|---|
| 260 | int left_indent_of_horizontal_scrollbar; |
|---|
| 261 | int top_indent_of_vertical_scrollbar; |
|---|
| 262 | int bottom_indent_of_vertical_scrollbar; |
|---|
| 263 | int slider_pos_vertical; |
|---|
| 264 | int slider_pos_horizontal; |
|---|
| 265 | int main_drag_gc; |
|---|
| 266 | |
|---|
| 267 | AW_rectangle *picture; // the result of tell scrolled |
|---|
| 268 | // picture size |
|---|
| 269 | |
|---|
| 270 | // -------------------------------- |
|---|
| 271 | // The real public section |
|---|
| 272 | // -------------------------------- |
|---|
| 273 | |
|---|
| 274 | AW_root *get_root(void) { return root; } |
|---|
| 275 | |
|---|
| 276 | //******************* Global layout functions ********************** |
|---|
| 277 | |
|---|
| 278 | void show(); // show newly created window or unhide hidden window (aka closed window) |
|---|
| 279 | void hide(); // hide (dont destroy) a window (<->show) |
|---|
| 280 | |
|---|
| 281 | void activate() { show(); wm_activate(); } // make_visible, pop window to front and give it the focus |
|---|
| 282 | |
|---|
| 283 | bool is_shown(); // is window visible (== true) or hidden (== false). ? |
|---|
| 284 | |
|---|
| 285 | void hide_or_notify(const char *error) { |
|---|
| 286 | if (error) aw_message(error); |
|---|
| 287 | else hide(); |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | void message( char *title, int ms ); // Set for ms milliseconds the title of the window |
|---|
| 291 | void set_window_title( const char *title ); // Set the window title forever |
|---|
| 292 | |
|---|
| 293 | const char *get_window_title( void ); // Get the window's title |
|---|
| 294 | const char *get_window_id() const { return window_defaults_name; } // Get the window's internal name |
|---|
| 295 | |
|---|
| 296 | const char *local_id(const char *id) const; |
|---|
| 297 | |
|---|
| 298 | void set_info_area_height(int height); |
|---|
| 299 | void set_bottom_area_height(int height); |
|---|
| 300 | |
|---|
| 301 | //******************* Input and Motion Events ********************** |
|---|
| 302 | |
|---|
| 303 | void set_popup_callback(void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 304 | void set_focus_callback(void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 305 | |
|---|
| 306 | void set_expose_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1=0, AW_CL cd2=0); |
|---|
| 307 | void set_resize_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1=0, AW_CL cd2=0); |
|---|
| 308 | void set_input_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1=0, AW_CL cd2=0); |
|---|
| 309 | void set_motion_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1=0, AW_CL cd2=0); |
|---|
| 310 | void set_double_click_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1=0, AW_CL cd2=0); |
|---|
| 311 | |
|---|
| 312 | bool is_expose_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 313 | bool is_resize_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 314 | bool is_input_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 315 | bool is_motion_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 316 | bool is_double_click_callback(AW_area area, void (*f)(AW_window*,AW_CL,AW_CL)); |
|---|
| 317 | |
|---|
| 318 | void get_event(AW_event *eventi); // In an event callback get the events info |
|---|
| 319 | |
|---|
| 320 | void force_expose(); // forces the window to expose instantly |
|---|
| 321 | |
|---|
| 322 | //******************* Get the devices ********************** |
|---|
| 323 | AW_device *get_device (AW_area area); |
|---|
| 324 | AW_device *get_click_device(AW_area area, int mousex,int mousey, AW_pos max_distance_linei, |
|---|
| 325 | AW_pos max_distance_texti, AW_pos radi); |
|---|
| 326 | AW_device *get_size_device (AW_area area); |
|---|
| 327 | AW_device *get_print_device (AW_area area); |
|---|
| 328 | |
|---|
| 329 | // ************** Create the menu buttons ********* |
|---|
| 330 | void create_menu(AW_label name, const char *mnemonic, const char *help_text = 0, AW_active mask = AWM_ALL); |
|---|
| 331 | void insert_sub_menu(AW_label name, const char *mnemonic, const char *help_text = 0, AW_active mask = AWM_ALL); |
|---|
| 332 | void insert_menu_topic(const char *id, AW_label name, const char *mnemonic, const char *help_text, AW_active mask, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 333 | void close_sub_menu(void); |
|---|
| 334 | |
|---|
| 335 | void insert_separator(void); |
|---|
| 336 | void insert_help_topic(AW_label name, const char *mnemonic, const char *help_text, AW_active mask, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 337 | void insert_separator_help(void); |
|---|
| 338 | // ************** Create modes on the left side ****************** |
|---|
| 339 | int create_mode(const char *pixmap, const char *help_text, AW_active mask, void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 340 | void select_mode(int mode); |
|---|
| 341 | |
|---|
| 342 | |
|---|
| 343 | // ************** Control the size of the main drawing area + scrollbars ********* |
|---|
| 344 | void tell_scrolled_picture_size(AW_rectangle rectangle); |
|---|
| 345 | void tell_scrolled_picture_size(AW_world rectangle); |
|---|
| 346 | AW_pos get_scrolled_picture_width(); |
|---|
| 347 | AW_pos get_scrolled_picture_height(); |
|---|
| 348 | void reset_scrolled_picture_size(); |
|---|
| 349 | |
|---|
| 350 | void calculate_scrollbars(void); |
|---|
| 351 | void set_vertical_scrollbar_position(int position); |
|---|
| 352 | void set_horizontal_scrollbar_position(int position); |
|---|
| 353 | void set_vertical_change_callback(void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 354 | void set_horizontal_change_callback(void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2); |
|---|
| 355 | void set_horizontal_scrollbar_left_indent(int indent); |
|---|
| 356 | void set_vertical_scrollbar_top_indent(int indent); |
|---|
| 357 | void set_vertical_scrollbar_bottom_indent(int indent); |
|---|
| 358 | |
|---|
| 359 | |
|---|
| 360 | // ************** Control window size ********* |
|---|
| 361 | void set_window_size( int width, int height ); |
|---|
| 362 | void get_window_size( int& width, int& height ); |
|---|
| 363 | void window_fit(void); // Recalculate the size of a window with buttons |
|---|
| 364 | void align(void); // Position dialog in the center the screen |
|---|
| 365 | |
|---|
| 366 | // ************** ******************************************************************** ********* |
|---|
| 367 | // ************** Create buttons: First set modify flags and finally create the button ********* |
|---|
| 368 | // ************** ******************************************************************** ********* |
|---|
| 369 | |
|---|
| 370 | // *** global modifier: **** |
|---|
| 371 | void load_xfig(const char *file, bool resize=true); // Loads the background graphic |
|---|
| 372 | void draw_line(int x1, int y1, int x2, int y2, int width, bool resize); // draws a line on the background |
|---|
| 373 | |
|---|
| 374 | void label_length( int length ); // Justifies all following labels |
|---|
| 375 | void button_length( int length ); // Sets the width of all following buttons (in chars) |
|---|
| 376 | void button_height( int height ); // Sets the height of all following buttons (in lines) |
|---|
| 377 | int get_button_length() const; // returns the current width of buttons |
|---|
| 378 | int get_button_height() const; // returns the current height of buttons |
|---|
| 379 | void highlight( void ); // Creates a frame around the button |
|---|
| 380 | void auto_increment( int dx, int dy ); // enable automatic placement of buttons |
|---|
| 381 | // dx is the horizontal distance between the left |
|---|
| 382 | // borders of two buttons |
|---|
| 383 | void auto_space( int xspace, int yspace ); // enable automatic placement of buttons |
|---|
| 384 | // xspace is the horizontal space between 2 buttons |
|---|
| 385 | |
|---|
| 386 | void auto_off( void ); // disable auto_xxxxx |
|---|
| 387 | void shadow_width (int shadow_thickness); // set the shadow_thickness of buttons |
|---|
| 388 | |
|---|
| 389 | void TuneBackground(Widget w,int modStrength); |
|---|
| 390 | void TuneOrSetBackground(Widget w, const char *color, int modStrength); |
|---|
| 391 | |
|---|
| 392 | // *** local modifiers: ******** |
|---|
| 393 | void at( int x, int y ); // abs pos of a button (>10,10) |
|---|
| 394 | void at_x( int x ); // abs x pos |
|---|
| 395 | void at_y( int y ); // abs y pos |
|---|
| 396 | void at_shift( int x, int y ); // rel pos of a button |
|---|
| 397 | void at_newline( void ); // in auto_space mode only: newline |
|---|
| 398 | |
|---|
| 399 | void at( const char *id ); /* place the button at the position set in the .fig |
|---|
| 400 | * file (loaded with load_xfig) by the string $id */ |
|---|
| 401 | bool at_ifdef(const char *id); // check whether 'id' is an element if the .fig file |
|---|
| 402 | |
|---|
| 403 | void label( const char *label ); // Create a label before the button |
|---|
| 404 | |
|---|
| 405 | void get_at_position(int *x, int *y); |
|---|
| 406 | int get_at_xposition(); |
|---|
| 407 | int get_at_yposition(); |
|---|
| 408 | |
|---|
| 409 | void dump_at_position(const char *debug_label) const; // for debugging (uses printf) |
|---|
| 410 | |
|---|
| 411 | void at_attach(bool attach_x, bool attach_y); // attach to X, Y or both |
|---|
| 412 | void at_set_to(bool attach_x, bool attach_y, int xoff, int yoff); // set "to:XY:id" manually |
|---|
| 413 | void at_unset_to(); // unset "to:id" manually |
|---|
| 414 | void at_set_min_size(int xmin, int ymin); // define minimum window size |
|---|
| 415 | |
|---|
| 416 | void store_at_size_and_attach( AW_at_size *at_size ); // get size of at-element |
|---|
| 417 | void restore_at_size_and_attach( const AW_at_size *at_size ); // set size of a at-element |
|---|
| 418 | |
|---|
| 419 | void sens_mask( AW_active mask ); // Set the sensitivity mask used for following widgets (Note: reset by next at()-command) |
|---|
| 420 | void help_text(const char *id ); // Set the help text of a button |
|---|
| 421 | void callback( void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2 ); // normal callbacks |
|---|
| 422 | void callback( void (*f)(AW_window*,AW_CL), AW_CL cd1); |
|---|
| 423 | void callback( void (*f)(AW_window*)); |
|---|
| 424 | void callback( AW_cb_struct * /*owner*/awcbs); // Calls f with |
|---|
| 425 | // aww in awcbs |
|---|
| 426 | void d_callback( void (*f)(AW_window*,AW_CL,AW_CL), AW_CL cd1, AW_CL cd2 ); // double click callbacks |
|---|
| 427 | void d_callback( void (*f)(AW_window*,AW_CL), AW_CL cd1); // selection lists only !! |
|---|
| 428 | void d_callback( void (*f)(AW_window*)); |
|---|
| 429 | void d_callback( AW_cb_struct * /*owner*/awcbs); // Calls f with |
|---|
| 430 | // *** create the buttons ******** |
|---|
| 431 | |
|---|
| 432 | // void create_button( const char *macro_name, AW_label label,const char *mnemonic = 0); // simple button; shadow only when callback |
|---|
| 433 | void create_button( const char *macro_name, AW_label label,const char *mnemonic = 0, const char *color = 0); // simple button; shadow only when callback |
|---|
| 434 | void create_autosize_button( const char *macro_name, AW_label label,const char *mnemonic = 0, unsigned xtraSpace = 1); // as above, but ignores button_length |
|---|
| 435 | Widget get_last_widget() const; |
|---|
| 436 | |
|---|
| 437 | void create_toggle( const char *awar_name); // int 0/1 string yes/no float undef |
|---|
| 438 | void create_inverse_toggle( const char *awar_name); // like create_toggle, but displays inverted toggle value |
|---|
| 439 | |
|---|
| 440 | void create_toggle( const char *awar_name, const char *nobitmap,const char *yesbitmap, int buttonWidth = 0); |
|---|
| 441 | void create_text_toggle(const char *var_name, const char *noText, const char *yesText, int buttonWidth = 0); |
|---|
| 442 | |
|---|
| 443 | void create_input_field( const char *awar_name, int columns = 0 ); // One line textfield |
|---|
| 444 | void create_text_field( const char *awar_name, int columns = 20, int rows = 4 ); // Multi line textfield |
|---|
| 445 | // with scrollbars |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | // ***** option_menu is a menu where only one selection is visible at a time |
|---|
| 449 | AW_option_menu_struct *create_option_menu( const char *awar_name, AW_label label=0,const char *mnemonic=0 ); |
|---|
| 450 | void clear_option_menu( AW_option_menu_struct *oms); // used to redefine available options |
|---|
| 451 | |
|---|
| 452 | private: |
|---|
| 453 | void insert_option_internal( AW_label choice_label, const char *mnemonic,const char *var_value, const char *name_of_color, bool default_option); |
|---|
| 454 | void insert_option_internal( AW_label choice_label, const char *mnemonic,int var_value, const char *name_of_color, bool default_option); |
|---|
| 455 | void insert_option_internal( AW_label choice_label, const char *mnemonic,float var_value, const char *name_of_color, bool default_option); |
|---|
| 456 | |
|---|
| 457 | void insert_toggle_internal( AW_label toggle_label, const char *mnemonic, const char *var_value, bool default_toggle); |
|---|
| 458 | void insert_toggle_internal( AW_label toggle_label, const char *mnemonic, int var_value, bool default_toggle); |
|---|
| 459 | void insert_toggle_internal( AW_label toggle_label, const char *mnemonic, float var_value, bool default_toggle); |
|---|
| 460 | public: |
|---|
| 461 | |
|---|
| 462 | // for string |
|---|
| 463 | void insert_option ( AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color = 0); // for string |
|---|
| 464 | void insert_default_option ( AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color = 0 ); |
|---|
| 465 | // for int |
|---|
| 466 | void insert_option ( AW_label choice_label, const char *mnemonic, int var_value, const char *name_of_color = 0 ); // for int |
|---|
| 467 | void insert_default_option ( AW_label choice_label, const char *mnemonic, int var_value, const char *name_of_color = 0 ); |
|---|
| 468 | // for float |
|---|
| 469 | void insert_option ( AW_label choice_label, const char *mnemonic, float var_value, const char *name_of_color = 0 ); // for float |
|---|
| 470 | void insert_default_option ( AW_label choice_label, const char *mnemonic, float var_value, const char *name_of_color = 0 ); |
|---|
| 471 | |
|---|
| 472 | void update_option_menu( void ); |
|---|
| 473 | void update_option_menu( AW_option_menu_struct *); // dont use this |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | // ***** toggle_field is a static menu (all items are visible and only one is selected) |
|---|
| 477 | void create_toggle_field( const char *awar_name, AW_label label, const char *mnemonic ); |
|---|
| 478 | void create_toggle_field( const char *awar_name, int orientation = 0 );// 1 = horizontal |
|---|
| 479 | // for string |
|---|
| 480 | void insert_toggle( AW_label toggle_label, const char *mnemonic, const char *var_value ); |
|---|
| 481 | void insert_default_toggle( AW_label toggle_label, const char *mnemonic, const char *var_value ); |
|---|
| 482 | // for int |
|---|
| 483 | void insert_toggle( AW_label toggle_label, const char *mnemonic, int var_value ); |
|---|
| 484 | void insert_default_toggle( AW_label toggle_label, const char *mnemonic, int var_value ); |
|---|
| 485 | // for float |
|---|
| 486 | void insert_toggle( AW_label toggle_label, const char *mnemonic, float var_value ); |
|---|
| 487 | void insert_default_toggle( AW_label toggle_label, const char *mnemonic, float var_value ); |
|---|
| 488 | void update_toggle_field( void ); |
|---|
| 489 | |
|---|
| 490 | // ***** selection list is a redefinable scrolled list of items |
|---|
| 491 | |
|---|
| 492 | AW_selection_list *create_selection_list( const char *awar_name, const char *label = 0, const char *mnemonic = 0, int columns = 4, int rows = 4 ); |
|---|
| 493 | // to make a copy of the selection list |
|---|
| 494 | AW_selection_list *copySelectionList(AW_selection_list *sourceList, AW_selection_list *destinationList); |
|---|
| 495 | // for string |
|---|
| 496 | void insert_selection( AW_selection_list *selection_list, const char *displayed, const char *value ); |
|---|
| 497 | void insert_default_selection( AW_selection_list * selection_list, const char *displayed, const char *value ); |
|---|
| 498 | // for int |
|---|
| 499 | void insert_selection( AW_selection_list * selection_list, const char *displayed, long value ); |
|---|
| 500 | void insert_default_selection( AW_selection_list * selection_list, const char *displayed, long value ); |
|---|
| 501 | // for float |
|---|
| 502 | void insert_selection( AW_selection_list * selection_list, const char *displayed, float value ); |
|---|
| 503 | void insert_default_selection( AW_selection_list * selection_list, const char *displayed, float value ); |
|---|
| 504 | // for pointers (only allowed if selection list uses a tmp-awars) |
|---|
| 505 | void insert_selection( AW_selection_list * selection_list, const char *displayed, void *pointer ); |
|---|
| 506 | void insert_default_selection( AW_selection_list * selection_list, const char *displayed, void *pointer ); |
|---|
| 507 | |
|---|
| 508 | void delete_selection_from_list( AW_selection_list * selection_list, const char *displayed_string ); |
|---|
| 509 | void conc_list( AW_selection_list * from_list_id, AW_selection_list * to_list_id); |
|---|
| 510 | |
|---|
| 511 | // --- selection list iterator: |
|---|
| 512 | void init_list_entry_iterator(AW_selection_list *selection_list); |
|---|
| 513 | void iterate_list_entry(int offset); |
|---|
| 514 | // --- the following functions work on the currently iterated element: |
|---|
| 515 | const char *get_list_entry_char_value(); |
|---|
| 516 | const char *get_list_entry_displayed(); |
|---|
| 517 | void set_list_entry_char_value(const char *new_char_value); |
|---|
| 518 | void set_list_entry_displayed(const char *new_displayed); |
|---|
| 519 | // --------------------------------------------------------- |
|---|
| 520 | |
|---|
| 521 | void clear_selection_list( AW_selection_list * selection_list ); |
|---|
| 522 | void update_selection_list( AW_selection_list * selection_list ); |
|---|
| 523 | |
|---|
| 524 | int get_no_of_entries( AW_selection_list * selection_list ); |
|---|
| 525 | int get_index_of_element(AW_selection_list *selection_list, const char *selected_element); |
|---|
| 526 | char *get_element_of_index(AW_selection_list *selection_list, int index); |
|---|
| 527 | |
|---|
| 528 | int get_index_of_current_element(AW_selection_list *selection_list, const char *awar_name); |
|---|
| 529 | void select_index(AW_selection_list *selection_list, const char *awar_name, int wanted_index); |
|---|
| 530 | void move_selection(AW_selection_list *selection_list, const char *awar_name, int offset); |
|---|
| 531 | |
|---|
| 532 | |
|---|
| 533 | char *get_selection_list_contents(AW_selection_list * selection_list, long nr_of_lines = -1); |
|---|
| 534 | void sort_selection_list(AW_selection_list * selection_list, int backward, int case_sensitive); |
|---|
| 535 | GB_ERROR save_selection_list(AW_selection_list * selection_list, const char *filename,long number_of_lines = 0); |
|---|
| 536 | void set_selection_list_suffix(AW_selection_list * selection_list, const char *suffix); |
|---|
| 537 | GB_ERROR load_selection_list(AW_selection_list * selection_list, const char *filename); |
|---|
| 538 | GB_HASH *selection_list_to_hash(AW_selection_list *sel_list, bool case_sens); |
|---|
| 539 | |
|---|
| 540 | AW_selection_list *create_multi_selection_list(const char *label = 0, const char *mnemonic = 0, int columns = 4, int rows = 4); |
|---|
| 541 | // all works, but its not connected to an AWAR may be converted to AW_mselection_list_helper |
|---|
| 542 | }; |
|---|
| 543 | |
|---|
| 544 | |
|---|
| 545 | class AW_window_menu_modes : public AW_window { |
|---|
| 546 | private: |
|---|
| 547 | void *AW_window_menu_modes_private; // Do not use !!! |
|---|
| 548 | public: |
|---|
| 549 | AW_window_menu_modes(void); |
|---|
| 550 | ~AW_window_menu_modes(void); |
|---|
| 551 | void init(AW_root *root, const char *wid, const char *windowname, int width, int height); |
|---|
| 552 | }; |
|---|
| 553 | |
|---|
| 554 | class AW_window_menu : public AW_window { |
|---|
| 555 | private: |
|---|
| 556 | public: |
|---|
| 557 | AW_window_menu(void); |
|---|
| 558 | ~AW_window_menu(void); |
|---|
| 559 | void init(AW_root *root, const char *wid, const char *windowname, int width, int height); |
|---|
| 560 | }; |
|---|
| 561 | |
|---|
| 562 | class AW_window_simple_menu : public AW_window { |
|---|
| 563 | private: |
|---|
| 564 | public: |
|---|
| 565 | AW_window_simple_menu(void); |
|---|
| 566 | ~AW_window_simple_menu(void); |
|---|
| 567 | void init(AW_root *root, const char *wid, const char *windowname); |
|---|
| 568 | }; |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | class AW_window_simple : public AW_window { |
|---|
| 572 | private: |
|---|
| 573 | public: |
|---|
| 574 | AW_window_simple(void); |
|---|
| 575 | ~AW_window_simple(void); |
|---|
| 576 | void init(AW_root *root, const char *wid, const char *windowname); |
|---|
| 577 | }; |
|---|
| 578 | |
|---|
| 579 | |
|---|
| 580 | class AW_window_message : public AW_window { |
|---|
| 581 | private: |
|---|
| 582 | public: |
|---|
| 583 | AW_window_message(void); |
|---|
| 584 | ~AW_window_message(void); |
|---|
| 585 | void init(AW_root *root, const char *windowname, bool allow_close); |
|---|
| 586 | }; |
|---|
| 587 | |
|---|
| 588 | |
|---|
| 589 | typedef void* AW_gc_manager; |
|---|
| 590 | |
|---|
| 591 | class AW_detach_information { |
|---|
| 592 | Awar_Callback_Info *cb_info; |
|---|
| 593 | Widget detach_button; |
|---|
| 594 | public: |
|---|
| 595 | AW_detach_information(Awar_Callback_Info *cb_info_) |
|---|
| 596 | : cb_info(cb_info_) , detach_button(0) { } |
|---|
| 597 | |
|---|
| 598 | Awar_Callback_Info *get_cb_info() { return cb_info; } |
|---|
| 599 | Widget get_detach_button() { aw_assert(detach_button); return detach_button; } |
|---|
| 600 | void set_detach_button(Widget w) { detach_button = w; } |
|---|
| 601 | }; |
|---|
| 602 | |
|---|
| 603 | #else |
|---|
| 604 | #error aw_window.hxx included twice |
|---|
| 605 | #endif |
|---|