1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
|
/*
* This file is part of XForms.
*
* XForms is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1, or
* (at your option) any later version.
*
* XForms is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with XForms. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file fd_control.c
*
* This file is part of XForms package
* Copyright (c) 1996-2002 T.C. Zhao and Mark Overmars
* All rights reserved.
*
* Form designer Control panel handling
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "include/forms.h"
#include "fd_main.h"
#include "fd/ui_theforms.h"
#include "private/pmenu.h"
#include "private/pchoice.h"
/* All control panel menus, File Object Options etc. have this
* common structures
*/
typedef struct {
const char * entry; /* label */
const char * sc; /* shortcut */
void ( * callback )( FL_OBJECT *, /* callback functions */
long );
int n; /* func_cb parameter */
int * p; /* binary value */
} MenuEntry;
extern void exit_cb( FL_OBJECT *,
long );
extern void saveforms_cb( FL_OBJECT *,
long );
/**** FileMenu ******{*/
static MenuEntry fmenu[ ] =
{
{ " Open", "Oo#o", loadforms_cb, 0, 0 },
{ " Merge", "Mm#m", mergeforms_cb, 0, 0 },
{ " Save", "Ss#s", saveforms_cb, 0, 0 },
{ " Save As %l", "Aa#a", saveforms_as_cb, 0, 0 },
{ " Exit", "Ee#e", exit_cb, 0, 0 }
};
#define NFM ( sizeof fmenu / sizeof *fmenu )
/***************************************
***************************************/
void
filemenu_callback( FL_OBJECT * ob,
long data FL_UNUSED_ARG )
{
int n = fl_get_menu( ob ) - 1;
if ( n >= 0 && fmenu[ n ].callback )
fmenu[ n ].callback( 0, 0 );
}
/***************************************
* Exit the program
***************************************/
void
exit_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
if ( changed )
{
int rep;
fl_set_choices_shortcut( "Ss#s", "Ee#e", "Rr#r" );
rep = fl_show_choice( "WARNING", "", "Changes have not been saved.",
3, "Save", "Exit", "Return", 1 );
if ( ( rep == 1 && ! save_forms( NULL ) ) || rep == 3 )
return;
}
fl_finish( );
exit( 0 );
}
/***************************************
* Merge a set of forms with the current ones.
***************************************/
void
mergeforms_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
load_forms( FL_TRUE, NULL, 0 );
changed = 1;
loadedfile = 0;
}
/***************************************
* Save the current set of forms.
***************************************/
void
saveforms_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
changed = ! save_forms( loadedfile_fullpath );
}
/***************************************
***************************************/
void
saveforms_as_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
changed = ! save_forms( NULL );
}
/***************************************
* Load a new set of forms
***************************************/
void
loadforms_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
if ( changed
&& fl_show_question( "Forms have been changed!\n"
"Should I save them?", 1 )
&& ! save_forms( NULL ) )
return;
load_forms( FL_FALSE, NULL, 1 );
changed = 0;
}
/***** End of FileMenu *****/
/* Group Menu entry */
static MenuEntry gmenu[ ] =
{
{ "New group", "Nn#n", NULL, 7, 0 },
{ "Delete Group", "Dd#d", NULL, 8, 0 },
{ "Rename Group", "Rr#r", changegroupname_cb, 0, 0 }
};
#define NGM ( sizeof gmenu / sizeof *gmenu )
/***************************************
***************************************/
void
groupmenu_callback( FL_OBJECT * ob,
long data FL_UNUSED_ARG )
{
int n = fl_get_menu( ob ) - 1;
if ( n >= 0 )
{
if ( gmenu[ n ].callback )
gmenu[ n ].callback( 0, 0 );
else
func_cb( 0, gmenu[ n ].n );
}
}
/* object menu entry */
static MenuEntry obmenu[ ] =
{
{ "Object Attributes", "Oo#o", 0, 1, 0 },
{ "Lower Object", "Ll#l", 0, 2, 0 },
{ "Raise Object", "Rr#r", 0, 3, 0 },
{ "Show Object", "Ss#s", 0, 5, 0 },
{ "Hide Object", "Hh#h", 0, 6, 0 },
{ "Cut Object", "Cc#c", 0, 12, 0 },
{ "Paste Object", "Pp#p", 0, 10, 0 }
};
#define NOBM ( sizeof obmenu / sizeof *obmenu )
/***************************************
***************************************/
void
objectmenu_callback( FL_OBJECT * ob,
long data FL_UNUSED_ARG )
{
int n = fl_get_menu( ob ) - 1;
if ( n >= 0 )
func_cb( 0, obmenu[ n ].n );
}
/* form menu entry */
static MenuEntry fmmenu[ ] =
{
{ "New Form", "Nn#n", addform_cb, 0, 0 },
{ "Delete Form", "Dd#d", deleteform_cb, 0, 0 },
{ "Rename Form", "Rr#r", changename_cb, 0, 0 },
{ "Resize Form", "Ss#s", changesize_cb, 0, 0 }
};
#define NFMM ( sizeof fmmenu / sizeof *fmmenu )
/***************************************
***************************************/
void
formmenu_callback( FL_OBJECT * ob,
long data FL_UNUSED_ARG )
{
int n = fl_get_menu( ob ) - 1;
if ( n >= 0 && fmmenu[ n ].callback )
fmmenu[ n ].callback( 0, 0 );
}
/* Option menu */
static MenuEntry opmenu[ ] =
{
{ "Track Geometry", "Gg#g", 0, 0, &fd_trackgeometry },
{ "Show Pallette", "Pp#p", 0, 0, &fd_show_palette },
{ "Emit %s UI code", "Ee#e", 0, 0, &fdopt.emit_code },
{ "Emit Callback", "Cc#c", 0, 0, &fdopt.emit_cb },
{ "Emit Main", "Mm#m", 0, 0, &fdopt.emit_main },
{ "Alt Format", "Aa#a", 0, 0, &fdopt.altformat },
{ "FS Compensate ", "Ff#f", 0, 0, &fdopt.compensate }
};
#define NOPM ( sizeof opmenu / sizeof *opmenu )
/***************************************
***************************************/
void
optionmenu_callback( FL_OBJECT * ob,
long data FL_UNUSED_ARG )
{
int n = fl_get_menu( ob ) - 1;
char buf[ 32 ];
if ( n >= 0 )
{
*opmenu[ n ].p = ! *opmenu[ n ].p;
sprintf( buf, "%s%%%c", opmenu[ n ].entry,
*opmenu[ n ].p ? 'B' : 'b' );
fl_replace_menu_item( fd_control->optionmenu, n + 1, buf );
( fd_show_palette ? show_pallette : hide_pallette )( );
}
}
/***************************************
***************************************/
void
reset_pallette_menu_status(void)
{
fl_set_menu_item_mode( fd_control->optionmenu, 2, FL_PUP_BOX );
fd_show_palette = 0;
}
/***************************************
***************************************/
static void
deactivate_control( FL_FORM * form FL_UNUSED_ARG,
void * data FL_UNUSED_ARG )
{
fl_set_object_lcol( fd_control->title, FL_SLATEBLUE );
fl_set_object_lcol( fd_control->menubar_group, FL_INACTIVE );
fl_set_object_lcol( fd_control->shortcut_group, FL_INACTIVE );
fl_set_object_lcol( fd_control->fkey_group, FL_INACTIVE );
}
/***************************************
***************************************/
static void
activate_control( FL_FORM * form FL_UNUSED_ARG,
void * data FL_UNUSED_ARG )
{
fl_set_object_lcol( fd_control->title, FL_BLUE );
fl_set_object_lcol( fd_control->menubar_group, FL_BLACK );
fl_set_object_lcol( fd_control->shortcut_group, FL_BLACK );
fl_set_object_lcol( fd_control->fkey_group, FL_BLACK );
}
/***************************************
* Initialize the control panel by filling in the menu entries
***************************************/
void
control_init( FD_control * ui )
{
static int control_initialized;
MenuEntry *m,
*me;
char buf[ 32 ];
int i;
if ( control_initialized )
return;
control_initialized = 1;
#ifdef __sgi
fl_set_object_lsize( ui->filemenu, FL_SMALL_SIZE );
fl_set_object_lsize( ui->formmenu, FL_SMALL_SIZE );
fl_set_object_lsize( ui->groupmenu, FL_SMALL_SIZE );
fl_set_object_lsize( ui->objectmenu, FL_SMALL_SIZE );
fl_set_object_lsize( ui->optionmenu, FL_SMALL_SIZE );
#endif
fl_set_form_atdeactivate( ui->control, deactivate_control, ui );
fl_set_form_atactivate( ui->control, activate_control, ui );
fl_set_object_dblbuffer( ui->selmsg, 1 );
fl_set_object_dblbuffer( ui->sizestatus, 1 );
fl_set_object_dblbuffer( ui->oristatus, 1 );
/* File menu */
for ( m = fmenu, me = m + NFM, i = 1; m < me; m++, i++ )
{
fl_addto_menu( ui->filemenu, m->entry );
fl_set_menu_item_shortcut( ui->filemenu, i, m->sc );
}
/* Form menu */
for ( m = fmmenu, me = m + NFMM, i = 1; m < me; m++, i++ )
{
fl_addto_menu( ui->formmenu, m->entry );
fl_set_menu_item_shortcut( ui->formmenu, i, m->sc );
}
/* Group menu */
for ( m = gmenu, me = m + NGM, i = 1; m < me; m++, i++ )
{
fl_addto_menu( ui->groupmenu, m->entry );
fl_set_menu_item_shortcut( ui->groupmenu, i, m->sc );
}
/* Object menu */
for ( m = obmenu, me = m + NOBM, i = 1; m < me; m++, i++ )
{
fl_addto_menu( ui->objectmenu, m->entry );
fl_set_menu_item_shortcut( ui->objectmenu, i, m->sc );
}
/* Option menu. all are binary items */
for ( m = opmenu, me = m + NOPM, i = 1; m < me; m++, i++ )
{
if ( strncmp( m->entry, "Emit %s", 7 ) == 0 )
{
static char tmpbuf[ 128 ];
sprintf( tmpbuf, m->entry, convertor[ fdopt.language ].lang_name );
m->entry = tmpbuf;
}
sprintf( buf, "%s%%%c", m->entry, * ( m->p ) ? 'B' : 'b' );
fl_addto_menu( ui->optionmenu, buf );
fl_set_menu_item_shortcut( ui->optionmenu, i, m->sc );
}
}
/* Misc. service routines */
/***************************************
***************************************/
void
show_geometry( FL_Coord x,
FL_Coord y,
FL_Coord w,
FL_Coord h )
{
char buf[ 128 ];
static FL_Coord lx = -1,
ly,
lw = -1,
lh;
/* Canonicalize rectangle */
if ( w < 0 )
{
x += w;
w = -w;
}
if ( h < 0 )
{
y += h;
h = -h;
}
if ( x != lx || y != ly )
{
sprintf( buf, "(%d %d)", x, y );
fl_set_object_label( fd_control->oristatus, buf );
lx = x;
ly = y;
}
if ( w != lw || h != lh )
{
sprintf( buf, "(%d %d)", w, h );
fl_set_object_label( fd_control->sizestatus, buf );
lw = w;
lh = h;
}
}
/***************************************
***************************************/
void
show_selmessage( FL_OBJECT * sel[ ],
int n )
{
char objname[ MAX_VAR_LEN ],
cbname[ MAX_VAR_LEN ],
argname[ MAX_VAR_LEN ];
char buf[ MAX_VAR_LEN ];
*buf = '\0';
if ( n == 1 )
{
get_object_name( sel[ 0 ], objname, cbname, argname );
sprintf( buf, "%s Name: %s %s%s",
find_type_name( sel[ 0 ]->objclass, sel[ 0 ]->type ),
*objname ? objname : "None",
*cbname ? "Callback: " : "",
*cbname ? cbname : "" );
}
else
{
if ( sel[ 0 ]->objclass == FL_BEGIN_GROUP )
n -= 2;
sprintf( buf, "%d objects", n );
}
fl_set_object_label( fd_control->selmsg, buf );
}
/********* Callback routines for the control panel ***************/
/*
* Form designer itself does not use resource settings, but when testing
* the newly created forms, resources are turned on. At the moment we
* only allow button label size to be changed
*/
FL_FORM *thetestform;
typedef struct {
int x,
y,
w,
h;
} GEOM;
static short *osize = NULL;
static GEOM *oldgeom = NULL;
static FL_Coord formw,
formh; /* original form size */
/***************************************
***************************************/
static void
fix_button_label_size( FL_FORM * form,
int save )
{
FL_OBJECT *ob;
int i;
if ( fd_buttonLabelSize == 0 )
return;
if ( save )
{
for ( i = 0, ob = form->first; ob; ob = ob->next )
if ( ob->objclass == FL_BUTTON )
i++;
osize = fl_realloc( osize, i * sizeof *osize );
}
for ( i = 0, ob = form->first; ob; ob = ob->next )
{
if ( ob->objclass == FL_BUTTON )
{
if ( save )
{
osize[ i++ ] = ob->lsize;
if ( ob->lsize == FL_NORMAL_FONT )
ob->lsize = fd_buttonLabelSize;
}
else
ob->lsize = osize[ i++ ];
}
}
if ( ! save )
fl_safe_free( osize );
}
/***************************************
***************************************/
static void
fix_menu_etc( FL_FORM * form,
int save )
{
FL_OBJECT *ob;
int i;
for ( ob = form->first; ob; ob = ob->next )
{
if ( ob->objclass != FL_MENU
&& ob->objclass != FL_CHOICE
&& ob->objclass != FL_BROWSER )
continue;
if ( ob->objclass == FL_MENU )
{
FLI_MENU_SPEC *sp = ob->spec;
if ( save )
{
if ( sp->numitems > 0 )
for ( i = 1; i <= sp->numitems; i++ )
fl_safe_free( sp->cb[ i ] );
else
{
fl_addto_menu( ob, "menuitem 1" );
fl_addto_menu( ob, "menuitem 2" );
fl_addto_menu( ob, "menuitem 3" );
fl_addto_menu( ob, "menuitem 4" );
}
}
else
{
SuperSPEC *ssp = get_superspec( ob );
if ( sp->numitems == ssp->nlines )
for ( i = 1; i <= sp->numitems; i++ )
if ( ssp->callback[ i ] )
sp->cb[ i ] =
( FL_PUP_CB ) fl_strdup( ssp->callback[ i ] );
else
sp->cb[ i ] = NULL;
else
fl_clear_menu( ob );
}
}
else if ( ob->objclass == FL_CHOICE )
{
FLI_CHOICE_SPEC *sp = ob->spec;
if ( save )
{
if ( sp->numitems == 0 )
{
fl_addto_choice( ob, "choice 1" );
fl_addto_choice( ob, "choice 2" );
fl_addto_choice( ob, "choice 3" );
fl_addto_choice( ob, "choice 4" );
}
}
else
{
SuperSPEC *ssp = get_superspec( ob );
if ( sp->numitems != ssp->nlines )
fl_clear_choice( ob );
}
}
else if ( ob->objclass == FL_BROWSER )
{
int nlines = fl_get_browser_maxline( ob );
if ( save )
{
if ( nlines == 0 )
{
char buf[ 100 ];
for ( i = 0; i < 20; i++ )
{
sprintf( buf, "browser line %d", i + 1 );
fl_add_browser_line( ob, buf );
}
}
}
else
{
SuperSPEC *ssp = get_superspec( ob );
if ( nlines != ssp->nlines )
fl_clear_browser( ob );
}
}
}
}
/***************************************
* Start a test of the current form
***************************************/
void
test_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
int i;
FL_OBJECT *ob;
GEOM *p;
int resizeable;
if ( cur_form == NULL )
return;
fl_deactivate_form(fd_control->control);
thetestform = cur_form;
/* During test, accumulation error might result. Save the old size */
formw = cur_form->w;
formh = cur_form->h;
for ( i = 0, ob = cur_form->first; ob; ob = ob->next, i++ )
/* empty */ ;
p = oldgeom = fl_realloc( oldgeom, i * sizeof *oldgeom );
for ( ob = cur_form->first; ob; ob = ob->next, i++, p++ )
{
p->x = ob->x;
p->y = ob->y;
p->w = ob->w;
p->h = ob->h;
}
/* Change button label size to the one requested */
fix_button_label_size( thetestform, 1 );
fix_menu_etc( thetestform, 1 );
cur_form = NULL;
redraw_the_form( 1 );
fl_clear_browser( fd_test->browser );
resizeable = strstr( get_placement( thetestform ), "FREE" ) != NULL;
if ( resizeable )
{
fl_set_form_minsize( thetestform, formw >= 10 ? formw / 2 : formw,
formh >= 10 ? formh / 2 : formh );
fl_set_form_maxsize( thetestform, fl_scrw, fl_scrh );
}
else
{
fl_set_form_minsize( thetestform, formw, formh );
fl_set_form_maxsize( thetestform, formw, formh );
}
fl_show_form( thetestform,
resizeable ? FL_PLACE_CENTERFREE : FL_PLACE_CENTER,
FL_FULLBORDER, "Test Form" );
fl_show_form( fd_test->test, FL_PLACE_POSITION | FL_PLACE_FREE,
FL_FULLBORDER, "Test" );
}
/***************************************
* Ends a testing session
***************************************/
void
stoptest_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
FL_OBJECT *ob;
GEOM *p = oldgeom;
if ( thetestform == NULL )
return;
fl_hide_form( fd_test->test );
fl_hide_form( thetestform );
fix_button_label_size( thetestform, 0 );
fix_menu_etc( thetestform, 0 );
cur_form = thetestform;
thetestform = NULL;
fl_set_form_size( cur_form, formw, formh );
if ( p )
{
for ( ob = cur_form->first; ob; ob = ob->next, p++ )
{
ob->x = p->x;
ob->y = p->y;
ob->w = p->w;
ob->h = p->h;
}
fl_safe_free( oldgeom );
}
redraw_the_form( 0 );
fl_activate_form( fd_control->control );
}
/** do alignment */
/***************************************
* Shows the align form
***************************************/
void
align_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
if ( fd_align->align->visible )
fl_hide_form( fd_align->align );
else
{
fl_show_form( fd_align->align, FL_PLACE_MOUSE, FL_FULLBORDER,
"Alignments" );
XRaiseWindow( flx->display, fd_align->align->window );
}
}
/***************************************
* Stop showing the align window
***************************************/
void
exitalign_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
fl_hide_form( fd_align->align );
}
/***************************************
* Does some alignment action
***************************************/
void
doalign_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg )
{
if ( fd_align->vdata )
free_dupped_selection( fd_align->vdata );
fd_align->vdata = dup_selection( );
align_selection( arg );
}
/***************************************
***************************************/
void
undoalign_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg FL_UNUSED_ARG )
{
if ( fd_align->vdata )
{
set_selection( fd_align->vdata );
/* only allow undo once */
free_dupped_selection( fd_align->vdata );
fd_align->vdata = 0;
}
}
/***************************************
***************************************/
void
snap_cb( FL_OBJECT * obj,
long arg FL_UNUSED_ARG )
{
set_step_size( fl_get_counter_value( obj ) );
}
/***** End of alignment stuff */
/***************************************
* The user pressed one of the function keys while in the main form
***************************************/
void
func_cb( FL_OBJECT * obj FL_UNUSED_ARG,
long arg )
{
switch ( arg )
{
case 1:
change_selection( );
redraw_the_form( 0 );
break;
case 2:
lower_selection( );
redraw_the_form( 0 );
break;
case 3:
raise_selection( );
redraw_the_form( 0 );
break;
case 4:
select_all( );
redraw_the_form( 0 );
break;
case 5:
show_selection( );
redraw_the_form( 0 );
break;
case 6:
hide_selection( );
redraw_the_form( 0 );
break;
case 7:
group_selection( );
break;
case 8:
flatten_selection( );
break;
case 9:
copy_selection( );
break;
case 10:
paste_selection( );
redraw_the_form( 0 );
break;
case 11:
next_selection( );
break;
case 12:
cut_selection( );
redraw_the_form( 0 );
break;
}
}
/***************************************
***************************************/
static void
draw_centering_symbol( FL_Coord x,
FL_Coord y,
FL_Coord w,
FL_Coord h,
int angle,
FL_COLOR col )
{
int delta = 4;
if ( angle == 0 || angle == 180 )
{
fl_draw_symbol( "@->", x, y, w / 2 + delta, h, col );
fl_draw_symbol( "@<-", x + w / 2 - delta, y, w / 2 + delta, h, col );
}
else
{
fl_draw_symbol( "@2->", x, y + 1, w, h / 2 + delta, col );
fl_draw_symbol( "@8->", x, y + h / 2 - delta - 1,
w, h / 2 + delta - 1, col );
}
}
/***************************************
***************************************/
void
init_align( void )
{
fl_add_symbol( "-><-", draw_centering_symbol, 0 );
fl_set_object_label( fd_align->hcenter, "@-><-" );
fl_set_object_label( fd_align->vcenter, "@8-><-" );
fl_set_object_helper( fd_align->left, "Flush left" );
fl_set_object_helper( fd_align->hcenter, "Center horizontally" );
fl_set_object_helper( fd_align->hequal, "Equal horizontal distance" );
fl_set_object_helper( fd_align->right, "Flush right" );
fl_set_object_helper( fd_align->top, "Flush top" );
fl_set_object_helper( fd_align->bottom, "Flush bottom" );
fl_set_object_helper( fd_align->vcenter, "Center vertically" );
fl_set_object_helper( fd_align->vequal, "Equal vertical distance" );
}
/*
* Local variables:
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
|