1 /* 2 * This file is part of XForms. 3 * 4 * XForms is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as 6 * published by the Free Software Foundation; either version 2.1, or 7 * (at your option) any later version. 8 * 9 * XForms is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with XForms. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 19 /** 20 * \file fd_main.h 21 * 22 * This file is the header file used in the Form Designer 23 */ 24 25 #ifndef FD_MAIN_H_ 26 #define FD_MAIN_H_ 27 28 #include <stdio.h> 29 #include "include/forms.h" 30 #include "flinternal.h" 31 32 #ifndef FALSE 33 #define FALSE 0 34 #define TRUE ( ! FALSE ) 35 #endif 36 37 /* since MAGIC4 all coordinates are relative to the top-left */ 38 39 #define MAGIC2 12321 40 #define MAGIC3 12322 41 #define MAGIC4 13000 42 #define MAGIC5 14000 /* since XForms 1.0.92 */ 43 #define MAGIC6 15000 /* since XForms 1.0.94pre4 */ 44 45 46 /* general limits */ 47 48 #define MAX_CLASS_NAME_LEN 64 /* FL_BUTTON etc. */ 49 #define MAX_TYPE_NAME_LEN 64 /* FL_RADIO_BUTTON etc */ 50 #define MAX_VAR_LEN 128 /* max. length of a variable/function */ 51 52 /* various options of the program */ 53 54 typedef struct { 55 int language; 56 int emit_code; /* if emit UI code */ 57 int emit_main; 58 int emit_cb; 59 int lax; 60 int altformat; 61 int conv_only; 62 int show_pallete; 63 int compensate; /* if emit font size compensation code */ 64 int unit; 65 char * output_dir; 66 } FD_Opt; 67 68 enum { 69 FD_C = 1, 70 FD_ADA95, 71 FD_PERL, 72 FD_PASCAL, 73 FD_PYTHON, 74 FD_FORTRAN, 75 FD_PS, 76 FD_SCM, 77 FD_EXP 78 }; 79 80 /* We use different file selector for different tasks */ 81 82 enum { 83 SAVE_FSELECTOR, 84 LOAD_FSELECTOR, 85 XPM_FSELECTOR 86 }; 87 88 #define MAX_CONVERTOR ( FD_EXP + 1 ) 89 90 /* Structure that will hole all forms created */ 91 92 typedef struct { 93 FL_FORM * form; /* The form */ 94 char fname[ MAX_VAR_LEN ]; /* Its name */ 95 } FRM; 96 97 typedef struct { 98 const char * lang_name; 99 int ( * convert )( const char *, 100 FRM *, 101 int ); /* built-in convertor */ 102 const char * extern_convertor; /* the converter itself */ 103 const char * contact_info; /* who to contact in case of error */ 104 int need_c_code; /* if translator works on C or .fd file */ 105 void ( * init )( void ); /* additional initialization */ 106 } Conv; 107 108 extern Conv convertor[ ]; 109 extern FD_Opt fdopt; 110 111 #define ShiftIsDown( mask ) ( mask & ShiftMask ) 112 113 /******** in fd_main.c *********/ 114 115 extern long main_window; /* The identifier of the main window */ 116 extern FL_Coord winw, 117 winh; 118 extern int changed; /* Whether the file has changed. */ 119 extern char main_name[ ]; /* Main creation routine name */ 120 121 /******** in fd_rubber.c *********/ 122 123 /* Contains routines for drawing rubberband boxes. */ 124 125 void set_step_size( double ); /* sets the stepsize */ 126 127 double get_step_size( void ); /* returns the stepsize */ 128 129 /* Sets the bounding box in which the drawing occurs */ 130 131 void set_bounding_box( double, 132 double, 133 double, 134 double ); 135 136 /* returns the position of the mouse in world coordinates */ 137 138 void get_mouse_pos( double *, 139 double * ); 140 141 /* drag a box around until the user releases a mouse button */ 142 143 void move_box( double *, 144 double *, 145 double *, 146 double *, 147 int ); 148 149 /* scales a box until the user releases a left mouse button */ 150 151 void scale_box( double *, 152 double *, 153 double *, 154 double * ); 155 156 /******** in fd_select.c *********/ 157 158 /* Contains the routines that deal with the maintenance of the 159 current selection of objects */ 160 161 int is_selected( FL_OBJECT * ); /* Returns whether the object is 162 selected. */ 163 164 void addto_selection( FL_OBJECT * ); /* Adds an object to a 165 selection */ 166 167 void addgroupto_selection( FL_OBJECT * ); /* Adds a group of objects 168 to a selection */ 169 170 void deletefrom_selection( FL_OBJECT * ); /* Deletes an object from a 171 selection */ 172 173 void clear_selection( void ); /* Clears the current selection */ 174 175 void resize_selection( FL_Coord, 176 FL_Coord ); 177 178 void move_selection( FL_Coord, 179 FL_Coord ); 180 181 void deletegroupfrom_selection( FL_OBJECT * ); /* Deletes a group of objects 182 from a selection */ 183 184 void draw_selbox( void ); /* Draws the box around the selected objects */ 185 186 void handle_select( const XEvent * ); /* Change the selection when 187 user puhed mouse. */ 188 189 void handle_move( const XEvent * ); /* Moves or scales the 190 selection. */ 191 void select_all( void ); /* Selects all objectsin the form */ 192 193 void change_selection( void ); /* Changes the atributes of the 194 selection */ 195 196 void align_selection( int ); /* Aligns the objects in the 197 selection */ 198 void show_selection( void ); /* Makes the selection visible. */ 199 200 void hide_selection( void ); /* Makes the selection invisible. */ 201 202 void raise_selection( void ); /* Raises the selection */ 203 204 void lower_selection( void ); /* Lower the selection */ 205 206 void cut_selection( void ); /* Deletes all objects in the 207 selection */ 208 void paste_selection( void ); /* Puts elements from buffer into 209 form */ 210 void copy_selection( void ); /* Copies objects in selection to 211 buffer */ 212 FL_OBJECT **dup_selection( void ); 213 214 void set_selection( FL_OBJECT ** ); 215 216 void free_dupped_selection( FL_OBJECT ** ); 217 218 void next_selection( void ); 219 220 void prev_selection( void ); 221 222 void group_selection( void ); /* Turns objects in the selection 223 into a group. */ 224 225 void flatten_selection( void ); /* Removes begin and end groups from 226 the selection. */ 227 228 /******** in fd_attribs.c **********/ 229 230 /* Contains routines to set and change attributes of objects. */ 231 232 int change_object( FL_OBJECT *, /* changes the settings for object */ 233 int ); 234 235 void change_type( FL_OBJECT *, /* Changes the type of a particular object. */ 236 int); 237 238 void set_label( FL_OBJECT *, /* Sets the object label (interpreting \n's). */ 239 const char * ); 240 241 void set_shortcut( FL_OBJECT *, 242 const char * ); 243 char *get_label( const FL_OBJECT *, /* Returns object label */ 244 int); /* (turning NL's into \n's). */ 245 char *get_shortcut_string( const FL_OBJECT * ); 246 247 248 /******** in fl_file_fun.c ********/ 249 250 #define FF_READ_FAILURE -1 251 #define FF_AT_END_OF_FILE 0 252 #define FF_AT_START_OF_FORM 1 253 #define FF_AT_START_OF_OBJECT 2 254 255 256 int ff_get_fd_file( const char *, 257 int ); 258 char *ff_get_filename_copy( void ); 259 int ff_read( const char *, 260 ... ); 261 void ff_close( void ); 262 int ff_err( const char * ); 263 264 265 /******** in fl_file.c ********/ 266 267 /* Contains all routines that deal with saving and loading forms. */ 268 269 int read_form( void ); 270 void write_form( FILE *, 271 FL_FORM *, 272 char[ ] ); 273 274 /******** in fl_print.c ********/ 275 276 /* Contains all routines that deal with printing forms in C format. */ 277 278 void print_form( FILE *, 279 FL_FORM *, 280 const char * ); 281 void print_callbacks_and_globals( FILE *, 282 FL_FORM *, 283 int ); 284 285 /* For making the header file */ 286 287 void print_header( FILE *, 288 FL_FORM *, 289 const char * ); 290 void output_main( FILE *, 291 FRM *, 292 int ); 293 void output_callbacks( FILE *, 294 FRM *, 295 int ); 296 297 /******** in fd_forms.c *********/ 298 299 /* Contains the routines that maintain the collection of forms. */ 300 301 extern FL_FORM *cur_form; 302 303 const char * get_form_name( FL_FORM * form ); 304 305 /* The current form under construction */ 306 307 void redraw_the_form( int ); 308 309 /* Redraws the current form. The argument indicates whether the background 310 should be redrawn. */ 311 312 void reshape_form_background( FL_Coord, 313 FL_Coord ); 314 315 /* loads the forms from a file */ 316 317 int load_forms( int, 318 const char * ); 319 320 int save_forms( const char * ); 321 322 /* saves the forms to a file, returns whether actually saved */ 323 324 /******** fd_groups.c *********/ 325 326 /* Contains the routines that deal with groups. */ 327 328 /* Fills in the groups in the current form. */ 329 330 void fillin_groups( void ); 331 332 333 /******** fd_names.c **********/ 334 335 /* Routines that keep track of the object names */ 336 337 void get_object_name( const FL_OBJECT *, 338 char *, 339 char *, 340 char * ); 341 342 void set_object_name( FL_OBJECT *, 343 const char *, 344 const char *, 345 const char * ); 346 347 const char * get_object_c_name( FL_OBJECT * obj ); 348 349 /******** fd_objects.c *********/ 350 351 /* Contains the different object classes and types. */ 352 353 #define MAXCLASSES 60 /* Max. number of object classes handled */ 354 #define MAXTYPES 24 /* Max. number of types per class. */ 355 356 /* Maximal number of object classes. */ 357 358 /* The current class of object to be added */ 359 360 extern int cur_class; 361 362 /* Initializes all the classes and types. */ 363 364 void init_classes( void ); 365 366 /* adds an object to the current form */ 367 368 FL_OBJECT * add_an_object( int, 369 int, 370 FL_Coord, 371 FL_Coord, 372 FL_Coord, 373 FL_Coord ); 374 375 /* Returns a pointer to the name of the class */ 376 377 char *find_class_name( int ); 378 379 char * find_class_name( int ); 380 381 /* Returns the number of types in the class */ 382 383 int find_class_maxtype( int ); 384 385 /* Returns the default object in the class */ 386 387 FL_OBJECT * find_class_default( int, 388 int ); 389 390 /* Returns a pointer to the name of the type in the class */ 391 392 const char *find_type_name( int, 393 int ); 394 395 int find_type_value( int, 396 const char * ); 397 398 extern unsigned long fd_red, 399 fd_black, 400 fd_white, 401 fd_col; 402 403 extern int fd_magic; 404 extern int fd_border; 405 extern int fd_trackgeometry, 406 fd_buttonLabelSize, 407 fd_testborder; 408 409 void color( unsigned long ); 410 411 int getbutton( int ); 412 413 void fd_clear( int, 414 int, 415 int, 416 int ); 417 418 void rect( FL_Coord, 419 FL_Coord, 420 FL_Coord, 421 FL_Coord ); 422 423 void rectf( FL_Coord, 424 FL_Coord, 425 FL_Coord, 426 FL_Coord ); 427 428 int fl_qtest( void ); 429 430 /* attribute query routines */ 431 432 char * class_name( int ); 433 int class_val( const char * ); 434 435 char * gravity_name( int ); 436 int gravity_val( const char * ); 437 438 char * resize_name( int ); 439 int resize_val( const char * ); 440 441 char * style_name( int ); 442 int style_val( const char * ); 443 444 const char * align_name( int, 445 int ); 446 int align_val( const char * ); 447 448 char * lsize_name( int ); 449 int lsize_val( const char * ); 450 451 char * boxtype_name( int ); 452 int boxtype_val( const char * ); 453 454 extern char * loadedfile; 455 extern char *loadedfile_fullpath; 456 457 typedef struct { 458 int val; /* value */ 459 char * name; /* formal name */ 460 char * shown; /* name shown */ 461 char * hotkey; /* hotkeys */ 462 } VN_pair; 463 464 char * get_vn_name( VN_pair *, 465 int ); 466 int get_vn_val( VN_pair *, 467 const char * ); 468 469 extern VN_pair vn_btype[ ]; 470 extern VN_pair vn_gravity[ ]; 471 extern VN_pair vn_align[ ]; 472 extern VN_pair vn_resize[ ]; 473 474 extern int fd_align_fontsize, 475 fd_type_fontsize; 476 extern int fd_convert, 477 fd_show_palette; 478 479 const char * get_fd_name( const char * ); 480 481 extern int fd_bwidth; 482 483 char * unit_name( int ); 484 485 int unit_val( const char * ); 486 487 int convert_u( int ); 488 489 double get_conversion_factor( void ); 490 491 extern char xform_header[ ]; 492 extern char glcanvas_header[ ]; 493 494 void show_geometry( int, 495 int, 496 int, 497 int ); 498 499 void show_selmessage( FL_OBJECT *[ ], 500 int ); 501 502 enum { 503 FD_LEFT = 1, 504 FD_HCENTER = 2, 505 FD_RIGHT = 3, 506 FD_HEQUAL = 4, 507 FD_BOTTOM = 5, 508 FD_VCENTER = 6, 509 FD_TOP = 7, 510 FD_VEQUAL = 8 511 }; 512 513 enum { 514 HELP_VERSION, 515 HELP_GENERAL, 516 HELP_MOUSE, 517 HELP_KEYBOARD, 518 HELP_GROUP, 519 HELP_TEST, 520 HELP_SAVE 521 }; 522 523 extern FL_FORM * thetestform; 524 525 FL_OBJECT * fl_create_simu_canvas( int, 526 FL_Coord, 527 FL_Coord, 528 FL_Coord, 529 FL_Coord, 530 const char * ); 531 532 FL_OBJECT * fl_add_simu_canvas( int, 533 FL_Coord, 534 FL_Coord, 535 FL_Coord, 536 FL_Coord, 537 const char * ); 538 539 FL_OBJECT * fl_create_simu_glcanvas( int, 540 FL_Coord, 541 FL_Coord, 542 FL_Coord, 543 FL_Coord, 544 const char * ); 545 546 FL_OBJECT * fl_add_simu_glcanvas( int, 547 FL_Coord, 548 FL_Coord, 549 FL_Coord, 550 FL_Coord, 551 const char * ); 552 553 /* Object class specific info handler */ 554 555 void save_objclass_spec_info( FILE *, 556 FL_OBJECT * ); 557 558 int load_objclass_spec_info( FL_OBJECT *, 559 char *); 560 561 void emit_objclass_spec_info( FILE *, 562 FL_OBJECT * ); 563 564 void emit_objclass_spec_header( FILE *, 565 FL_OBJECT * ); 566 567 void emit_objclass_spec_global( FILE *, 568 FL_OBJECT * ); 569 570 void set_objclass_spec_attributes( FL_OBJECT *, 571 long ); 572 573 void obj_spec_reread( FL_OBJECT * obj ); 574 575 void obj_spec_apply( FL_OBJECT * obj ); 576 577 void obj_spec_restore( FL_OBJECT * obj ); 578 579 int has_class_spec_info( FL_OBJECT * ); 580 581 void modify_attrib_basic_color( FL_COLOR, 582 FL_COLOR ); 583 584 /* Control panel etc */ 585 586 #include "fd/ui_theforms.h" 587 #include "fd/ui_attrib.h" 588 589 extern FD_control *fd_control; 590 591 extern FD_attrib *fd_attrib; 592 593 extern FD_generic_attrib *fd_generic_attrib; 594 595 extern FD_test * fd_test; 596 597 extern FD_align * fd_align; 598 599 extern FD_resize * fd_resize; 600 601 extern FD_helpform * fd_help; 602 603 void loadforms_cb( FL_OBJECT *, 604 long ); 605 606 void saveforms_cb( FL_OBJECT *, 607 long ); 608 609 void saveforms_as_cb( FL_OBJECT *, 610 long ); 611 612 void mergeforms_cb( FL_OBJECT *, 613 long ); 614 615 void exit_cb( FL_OBJECT *, 616 long ); 617 618 void changegroupname_cb( FL_OBJECT *, 619 long ); 620 621 void mainname_cb( FL_OBJECT *, 622 long ); 623 624 void create_the_forms( void ); 625 626 void control_init( FD_control * ); 627 628 extern FL_FORM *thetestform; 629 630 int within_selection( double, 631 double ); 632 633 extern int no_selection; 634 635 int C_output( const char *, 636 FRM *, 637 int ); 638 639 extern int is_pasting; 640 641 void init_align( void ); 642 643 void cleanup_spec( FL_OBJECT * ); 644 645 /* fake stuff */ 646 647 #define FL_NTABFOLDER 50 648 649 FL_OBJECT *fl_add_ntabfolder( int, 650 FL_Coord, 651 FL_Coord, 652 FL_Coord, 653 FL_Coord, 654 const char *); 655 656 FL_OBJECT *fl_create_ntabfolder( int, 657 FL_Coord, 658 FL_Coord, 659 FL_Coord, 660 FL_Coord, 661 const char * ); 662 663 FL_OBJECT *fl_add_nformbrowser( int, 664 FL_Coord, 665 FL_Coord, 666 FL_Coord, 667 FL_Coord, 668 const char * ); 669 670 FL_OBJECT *fl_create_nformbrowser( int, 671 FL_Coord, 672 FL_Coord, 673 FL_Coord, 674 FL_Coord, 675 const char * ); 676 677 void make_backup( const char * ); 678 679 int is_var_boxtype( int cn ); 680 681 void set_testing_pixmap( FL_OBJECT * ); 682 683 void set_testing_bitmap( FL_OBJECT * ob ); 684 685 void set_snap_size( int, 686 int ); 687 688 int get_snap_size( void ); 689 690 void show_pallette( void ); 691 692 void hide_pallette( void ); 693 694 void reset_pallette_menu_status( void ); 695 696 void select_pallette_entry( int ); 697 698 void reset_pallette( void ); 699 700 typedef struct { 701 double min, 702 max, 703 xmin, 704 xmax, 705 ymin, 706 ymax; 707 double val, 708 xval, 709 yval; 710 double step, 711 sstep, 712 lstep, 713 xstep, 714 ystep; 715 double slsize; 716 double thetai, 717 thetaf; 718 double ldelta, 719 rdelta; 720 double dval, 721 dmin, 722 dmax, 723 dstep; 724 int prec; 725 int direction; 726 int mbuttons; 727 int int_val; 728 int align; 729 int dx, 730 dy; 731 int show_focus; 732 int h_pref, 733 v_pref; 734 int nlines; 735 int xmajor, 736 xminor; 737 int ymajor, 738 yminor; 739 int xscale, 740 yscale; 741 float xbase, 742 ybase; 743 int xgrid, 744 ygrid; 745 char ** content; 746 char ** shortcut; 747 char ** callback; 748 unsigned char * mode; 749 int new_menuapi; 750 int global_scope; 751 int showsymbol; 752 char * misc_char; 753 int grid_linestyle; 754 int no_title; 755 int mark_active; 756 int * mval; 757 int orient; 758 } SuperSPEC; 759 760 SuperSPEC * get_superspec( FL_OBJECT * ); 761 762 SuperSPEC * spec_to_superspec( FL_OBJECT * ); 763 764 void * superspec_to_spec( FL_OBJECT * ); 765 766 void copy_superspec( FL_OBJECT * dest, 767 FL_OBJECT * src ); 768 769 void free_superspec( FL_OBJECT * obj ); 770 771 #define ISBUTTON( cls ) ( ( cls ) == FL_BUTTON \ 772 || ( cls ) == FL_LIGHTBUTTON \ 773 || ( cls ) == FL_CHECKBUTTON \ 774 || ( cls ) == FL_ROUNDBUTTON \ 775 || ( cls ) == FL_ROUND3DBUTTON \ 776 || ( cls ) == FL_PIXMAPBUTTON \ 777 || ( cls ) == FL_BITMAPBUTTON \ 778 || ( cls ) == FL_SCROLLBUTTON \ 779 || ( cls ) == FL_LABELBUTTON ) 780 781 #define ISCHOICE( cls ) ( ( cls ) == FL_CHOICE \ 782 || ( cls ) == FL_MENU \ 783 || ( cls ) == FL_BROWSER ) 784 785 void select_object_by_class( int ); 786 787 char * append_fd_suffix( const char * ); 788 789 const char * get_placement( FL_FORM * ); 790 791 unsigned int 792 check_resize( unsigned int what, 793 int nw, 794 int se ); 795 796 void reset_dupinfo_cache( void ); 797 798 int is_duplicate_info( const char * ); 799 800 char * rel2abs( const char * rel_path ); 801 802 int is_valid_c_name( const char * str ); 803 804 void setup_how_return_menu( FL_OBJECT * ); 805 806 void reset_how_return_menu( FL_OBJECT *, 807 unsigned int ); 808 809 void handle_how_return_changes( FL_OBJECT *, 810 FL_OBJECT * ); 811 812 int get_how_return_val( const char * ); 813 814 const char * get_how_return_name( unsigned int, 815 int ); 816 817 const char * file_tail( const char * ); 818 819 void reset_object_list( void ); 820 821 822 void addform_cb( FL_OBJECT *, 823 long ); 824 825 void deleteform_cb( FL_OBJECT *, 826 long ); 827 828 void changename_cb( FL_OBJECT *, 829 long ); 830 831 void changesize_cb( FL_OBJECT *, 832 long ); 833 834 #endif /* FD_MAIN_H */ 835 836 837 /* 838 * Local variables: 839 * tab-width: 4 840 * indent-tabs-mode: nil 841 * End: 842 */ 843