1 /*---------------------------------------------------------------------------- 2 -- 3 -- Module: xitParSet 4 -- 5 -- Project: xit - X Internal Toolkit 6 -- System: <> 7 -- Subsystem: <> 8 -- Function block: <> 9 -- 10 -- Description: 11 -- The parameter set window allows you to control the settings of 12 -- one or more parameters. The typical use is in a customize 13 -- window. 14 -- 15 -- Filename: xitParSet.c 16 -- 17 -- Authors: Roger Larsson, Ulrika Bornetun 18 -- Creation date: 1992-05-31 19 -- 20 -- 21 -- (C) Copyright Ulrika Bornetun, Roger Larsson (1995) 22 -- All rights reserved 23 -- 24 -- Permission to use, copy, modify, and distribute this software and its 25 -- documentation for any purpose and without fee is hereby granted, 26 -- provided that the above copyright notice appear in all copies. Ulrika 27 -- Bornetun and Roger Larsson make no representations about the usability 28 -- of this software for any purpose. It is provided "as is" without express 29 -- or implied warranty. 30 ----------------------------------------------------------------------------*/ 31 32 /* SCCS module identifier. */ 33 static char SCCSID[] = "@(#) Module: xitParSet.c, Version: 1.1, Date: 95/02/18 15:10:43"; 34 35 36 /*---------------------------------------------------------------------------- 37 -- Include files 38 ----------------------------------------------------------------------------*/ 39 40 #include <X11/Intrinsic.h> 41 42 #include <Xm/Xm.h> 43 #include <Xm/Form.h> 44 #include <Xm/List.h> 45 #include <Xm/RowColumn.h> 46 #include <Xm/Scale.h> 47 #include <Xm/ToggleBG.h> 48 #include <Xm/ToggleB.h> 49 #include <Xm/Text.h> 50 51 #include <stdio.h> 52 #include <stdlib.h> 53 #include <ctype.h> 54 55 #include "System.h" 56 #include "TimDate.h" 57 58 #include "xitError.h" 59 #include "xitTools.h" 60 #include "xitColorSel.h" 61 #include "xitFieldSel.h" 62 #include "xitParSet.h" 63 64 65 /*---------------------------------------------------------------------------- 66 -- Macro definitions 67 ----------------------------------------------------------------------------*/ 68 69 /* Local widgets in the entry edit window. */ 70 #define colorFs dataLocalW[ 0 ] 71 #define descLa dataLocalW[ 1 ] 72 #define descTx dataLocalW[ 2 ] 73 #define indexFs dataLocalW[ 3 ] 74 #define intFo dataLocalW[ 4 ] 75 #define intSc dataLocalW[ 5 ] 76 #define intTx dataLocalW[ 6 ] 77 #define noTb dataLocalW[ 7 ] 78 #define offTb dataLocalW[ 8 ] 79 #define onOffRb dataLocalW[ 9 ] 80 #define onTb dataLocalW[ 10 ] 81 #define parListLa dataLocalW[ 11 ] 82 #define parListLi dataLocalW[ 12 ] 83 #define selectFs dataLocalW[ 13 ] 84 #define textTx dataLocalW[ 14 ] 85 #define valueLa dataLocalW[ 15 ] 86 #define yesNoRb dataLocalW[ 16 ] 87 #define yesTb dataLocalW[ 17 ] 88 #define centuryTb dataLocalW[ 18 ] 89 #define dateOrderRb dataLocalW[ 19 ] 90 #define dateSepRc dataLocalW[ 20 ] 91 #define dayZeroTb dataLocalW[ 21 ] 92 #define dmyTb dataLocalW[ 22 ] 93 #define mdyTb dataLocalW[ 23 ] 94 #define monthZeroTb dataLocalW[ 24 ] 95 #define ymdTb dataLocalW[ 25 ] 96 #define dateSepLa dataLocalW[ 26 ] 97 #define dateFormatFo dataLocalW[ 27 ] 98 #define dateSepTx dataLocalW[ 28 ] 99 #define dateParRc dataLocalW[ 29 ] 100 #define hour12Tb dataLocalW[ 30 ] 101 #define hour12Tx dataLocalW[ 31 ] 102 #define hour24Tb dataLocalW[ 32 ] 103 #define hour24Tx dataLocalW[ 33 ] 104 #define hourZeroTb dataLocalW[ 34 ] 105 #define timeFormatFo dataLocalW[ 35 ] 106 #define timeParRc dataLocalW[ 36 ] 107 #define timeSepLa dataLocalW[ 37 ] 108 #define timeSepRc dataLocalW[ 38 ] 109 #define timeSepTx dataLocalW[ 39 ] 110 #define timeTypeRb dataLocalW[ 40 ] 111 #define week1stDayFs dataLocalW[ 41 ] 112 #define week1stDayLa dataLocalW[ 42 ] 113 #define week1stDayRc dataLocalW[ 43 ] 114 #define hiddenLa dataLocalW[ 44 ] 115 #define hiddenPb dataLocalW[ 45 ] 116 #define hiddenRc dataLocalW[ 46 ] 117 #define chidWhatLa dataLocalW[ 47 ] 118 #define chidTx dataLocalW[ 48 ] 119 #define workdaysRc dataLocalW[ 49 ] 120 121 122 /* The number of parameter we can do. */ 123 #define MAX_PARAMETERS 100 124 125 /* Pre-defined entry tags in a menu, how many? */ 126 #define MAX_MENU_TAGS 50 127 128 129 /*---------------------------------------------------------------------------- 130 -- Type declarations 131 ----------------------------------------------------------------------------*/ 132 133 /* Are we doing a reset or default action? */ 134 typedef enum { 135 DO_RESET, 136 DO_DEFAULT 137 } ACTION; 138 139 140 /* Temporary placeholder for values while working. */ 141 typedef struct { 142 void *value; 143 } WORK_VALUE_REC; 144 145 146 /* Internal data to use. */ 147 typedef struct { 148 149 /* Do update of field. */ 150 Boolean do_update; 151 152 /* General flags to use. */ 153 UINT32 flags; 154 155 /* Value for hidden field. */ 156 int change_hidden_max_columns; 157 int change_hidden_max_length; 158 char hidden_buf[ 128 ]; 159 Widget changeHiddenW; 160 161 /* The main widget. */ 162 Widget parSetW; 163 164 /* The last widget value and parameter type used. */ 165 int last_value_no; 166 Widget last_valueW; 167 168 /* The complete parameter set. */ 169 int rec_no; 170 XIT_PAR_REC *par_rec_ref; 171 172 /* Values while working. */ 173 WORK_VALUE_REC work[ MAX_PARAMETERS ]; 174 175 /* Action to do. */ 176 ACTION do_action; 177 178 /* Messages. */ 179 char *msg_confirm_default; 180 char *msg_confirm_reset; 181 char *msg_invalid_value; 182 183 /* User callback and user data. */ 184 XIT_PS_ACTION_CB actionCB; 185 XtPointer user_data; 186 187 } PAR_SET_REC, *PAR_SET_REC_REF; 188 189 190 /*---------------------------------------------------------------------------- 191 -- Global definitions 192 ----------------------------------------------------------------------------*/ 193 194 195 /*---------------------------------------------------------------------------- 196 -- Function prototypes 197 ----------------------------------------------------------------------------*/ 198 199 static void 200 cancelCB( Widget widget, 201 PAR_SET_REC_REF par_set_ref, 202 XtPointer call_data ); 203 204 static void 205 changeHiddenCB( Widget widget, 206 PAR_SET_REC_REF par_set_ref, 207 XtPointer call_data ); 208 209 static void 210 changeHiddenCancelCB( Widget widget, 211 PAR_SET_REC_REF par_set_ref, 212 XtPointer call_data ); 213 214 static void 215 changeHiddenOkCB( Widget widget, 216 PAR_SET_REC_REF par_set_ref, 217 XtPointer call_data ); 218 219 static void 220 createFieldMenu( char *menu_string, 221 String *tags, 222 int max_tags, 223 int *num_tags ); 224 225 static void 226 defaultsCB( Widget widget, 227 PAR_SET_REC_REF par_set_ref, 228 XtPointer call_data ); 229 230 static void 231 destroyCB( Widget widget, 232 PAR_SET_REC_REF par_set_ref, 233 XtPointer call_data ); 234 235 static void 236 doDefaultResetCB( Widget widget, 237 PAR_SET_REC_REF par_set_ref, 238 XtPointer call_data ); 239 240 static void 241 intScChangedCB( Widget widget, 242 PAR_SET_REC_REF par_set_ref, 243 XmScaleCallbackStruct *call_data ); 244 245 static void 246 intTxChangedCB( Widget widget, 247 PAR_SET_REC_REF par_set_ref, 248 XtPointer call_data ); 249 250 static void 251 okCB( Widget widget, 252 PAR_SET_REC_REF par_set_ref, 253 XtPointer call_data ); 254 255 static void 256 parListCB( Widget widget, 257 PAR_SET_REC_REF par_set_ref, 258 XmListCallbackStruct *call_data ); 259 static void 260 resetCB( Widget widget, 261 PAR_SET_REC_REF par_set_ref, 262 XtPointer call_data ); 263 264 static Boolean 265 saveParameter( PAR_SET_REC_REF par_set_ref ); 266 267 static void 268 setParameter( PAR_SET_REC_REF par_set_ref, 269 XIT_PAR_REC *par_rec_ref, 270 WORK_VALUE_REC *work_ref ); 271 272 273 274 /*---------------------------------------------------------------------------- 275 -- Functions 276 ----------------------------------------------------------------------------*/ 277 278 Widget xitCreateParameterSet(Widget parent,UINT32 flags,XIT_PS_LABELS * labels,XIT_PS_ACTION_CB actionCB,XtPointer user_data)279 xitCreateParameterSet( Widget parent, 280 UINT32 flags, 281 XIT_PS_LABELS *labels, 282 XIT_PS_ACTION_CB actionCB, 283 XtPointer user_data ) 284 { 285 286 /* Variables. */ 287 int index; 288 int tag_count; 289 Arg args[ 10 ]; 290 Cardinal n; 291 String tag_array[ MAX_MENU_TAGS ]; 292 Widget chidFd; 293 Widget dataLocalW[ 50 ]; 294 Widget parSetFd; 295 Widget workFo; 296 Widget workdaysBu[ 10 ]; 297 Widget tempW; 298 PAR_SET_REC_REF par_set_ref; 299 300 static XIT_TEXT_STRUCT text_buffer_def[] = { 301 { "DescTx", NULL, 2, False }, 302 { "TextTx", NULL, 1, True }, 303 { "IntTx", NULL, 1, True }, 304 { "SepTx", NULL, 1, True }, 305 { "Hour12Tx", NULL, 1, True }, 306 { "Hour24Tx", NULL, 1, True }, 307 }; 308 309 static XIT_PUSH_STRUCT button_def[] = { 310 { "HiddenPb", "", "", True, NULL }, 311 }; 312 313 static XIT_ACTION_AREA_ITEM action_buttons[] = { 314 { "", okCB, NULL }, 315 { "", resetCB, NULL }, 316 { "", defaultsCB, NULL }, 317 { "", cancelCB, NULL }, 318 }; 319 320 321 /* Code. */ 322 323 /* Create and initialize our private data. */ 324 par_set_ref = SysNew( PAR_SET_REC ); 325 if( par_set_ref == NULL ) 326 return( NULL ); 327 328 par_set_ref -> do_update = True; 329 par_set_ref -> par_rec_ref = NULL; 330 par_set_ref -> flags = flags; 331 par_set_ref -> last_valueW = NULL; 332 par_set_ref -> msg_confirm_default = labels -> msg_confirm_default; 333 par_set_ref -> msg_confirm_reset = labels -> msg_confirm_reset; 334 par_set_ref -> msg_invalid_value = labels -> msg_invalid_value; 335 par_set_ref -> actionCB = actionCB; 336 par_set_ref -> user_data = user_data; 337 338 for( index = 0; index < MAX_PARAMETERS; index++ ) 339 par_set_ref -> work[ index ].value = NULL; 340 341 342 /* The window buttons. */ 343 button_def[ 0 ].title = labels -> change_button; 344 345 action_buttons[ 0 ].label = labels -> ok_button; 346 action_buttons[ 0 ].data = par_set_ref; 347 action_buttons[ 1 ].label = labels -> reset_button; 348 action_buttons[ 1 ].data = par_set_ref; 349 action_buttons[ 2 ].label = labels -> defaults_button; 350 action_buttons[ 2 ].data = par_set_ref; 351 action_buttons[ 3 ].label = labels -> cancel_button; 352 action_buttons[ 3 ].data = par_set_ref; 353 354 355 /* Create a form dialog with buttons. */ 356 parSetFd = xitCreateFormDialog( parent, "ParSetFd", 357 1, 0, 358 action_buttons, 359 XtNumber( action_buttons ) ); 360 361 par_set_ref -> parSetW = parSetFd; 362 363 XtAddCallback( parSetFd, XmNdestroyCallback, 364 (XtCallbackProc) destroyCB, (XtPointer) par_set_ref ); 365 366 n = 0; 367 XtSetArg( args[ n ], XmNtitle, labels -> window_title ); n++; 368 XtSetValues( XtParent( parSetFd ), args, n ); 369 370 n = 0; 371 XtSetArg( args[ n ], XmNuserData, (void *) par_set_ref ); n++; 372 XtSetArg( args[ n ], XmNdeleteResponse, XmDESTROY ); n++; 373 XtSetArg( args[ n ], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); n++; 374 XtSetValues( parSetFd, args, n ); 375 376 377 /* Container for the contents of the window. */ 378 workFo = XtNameToWidget( parSetFd, "ParSetFdFo" ); 379 380 381 /* The labels we need. */ 382 parListLa = xitCreateLabel( workFo, "ParListLa", 383 labels -> parameter_list, -1 ); 384 385 descLa = xitCreateLabel( workFo, "DescLa", 386 labels -> description, -1 ); 387 388 valueLa = xitCreateLabel( workFo, "ValueLa", 389 labels -> parameter_value, -1 ); 390 391 392 /* The parameter list. */ 393 n = 0; 394 XtSetArg( args[ n ], XmNlistSizePolicy, XmCONSTANT ); n++; 395 XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++; 396 XtSetArg( args[ n ], XmNselectionPolicy, XmSINGLE_SELECT ); n++; 397 XtSetArg( args[ n ], XmNlistMarginHeight, 5 ); n++; 398 XtSetArg( args[ n ], XmNlistMarginWidth, 5 ); n++; 399 parListLi = XmCreateScrolledList( workFo, "ParListLi", args, n ); 400 401 XtAddCallback( parListLi, XmNsingleSelectionCallback, 402 (XtCallbackProc) parListCB, (XtPointer) par_set_ref ); 403 XtAddCallback( parListLi, XmNdefaultActionCallback, 404 (XtCallbackProc) parListCB, (XtPointer) par_set_ref ); 405 406 407 /* The description text. */ 408 descTx = xitCreateTextScrolled( workFo, &text_buffer_def[ 0 ] ); 409 410 n = 0; 411 XtSetArg( args[ n ], XmNeditable, False ); n++; 412 XtSetArg( args[ n ], XmNcursorPositionVisible, False ); n++; 413 XtSetValues( descTx, args, n ); 414 415 416 /* Yes/No radio box. */ 417 n = 0; 418 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 419 XtSetArg( args[ n ], XmNpacking, XmPACK_COLUMN ); n++; 420 XtSetArg( args[ n ], XmNradioBehavior, True ); n++; 421 yesNoRb = XmCreateRowColumn( workFo, "YesNoRb", args, n ); 422 423 yesTb = xitCreateToggleButton( yesNoRb, "YesTb", 424 labels -> yes_label, False ); 425 426 noTb = xitCreateToggleButton( yesNoRb, "NoTb", 427 labels -> no_label, False ); 428 429 430 /* On/Off radio box. */ 431 n = 0; 432 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 433 XtSetArg( args[ n ], XmNpacking, XmPACK_COLUMN ); n++; 434 XtSetArg( args[ n ], XmNradioBehavior, True ); n++; 435 onOffRb = XmCreateRowColumn( workFo, "OnOffRb", args, n ); 436 437 onTb = xitCreateToggleButton( onOffRb, "OnTb", 438 labels -> on_label, False ); 439 440 offTb = xitCreateToggleButton( onOffRb, "OffTb", 441 labels -> off_label, False ); 442 443 444 /* A slider bar and text field for integer values. */ 445 intFo = XmCreateForm( workFo, "IntFo", args, 0 ); 446 447 n = 0; 448 XtSetArg( args[ n ], XmNvalue, 1 ); n++; 449 XtSetArg( args[ n ], XmNminimum, 1 ); n++; 450 XtSetArg( args[ n ], XmNmaximum, 100 ); n++; 451 XtSetArg( args[ n ], XmNprocessingDirection, XmMAX_ON_RIGHT ); n++; 452 XtSetArg( args[ n ], XmNshowValue, True ); n++; 453 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 454 intSc = XmCreateScale( intFo, "IntSc", args, n ); 455 456 XtAddCallback( intSc, XmNvalueChangedCallback, 457 (XtCallbackProc) intScChangedCB, (XtPointer) par_set_ref ); 458 XtAddCallback( intSc, XmNdragCallback, 459 (XtCallbackProc) intScChangedCB, (XtPointer) par_set_ref ); 460 461 intTx = xitCreateText( intFo, &text_buffer_def[ 2 ] ); 462 463 XtAddCallback( intTx, XmNvalueChangedCallback, 464 (XtCallbackProc) intTxChangedCB, (XtPointer) par_set_ref ); 465 466 467 /* Text field. */ 468 textTx = xitCreateText( workFo, &text_buffer_def[ 1 ] ); 469 470 471 /* Color field. */ 472 n = 0; 473 XtSetArg( args[ n ], XmNitems, NULL ); n++; 474 XtSetArg( args[ n ], XmNitemCount, 0 ); n++; 475 XtSetArg( args[ n ], XmNcolumns, 5 ); n++; 476 colorFs = xitCreateColorSelect( workFo, "ColorFs", args, n, NULL, NULL ); 477 478 479 /* Index select field. */ 480 n = 0; 481 XtSetArg( args[ n ], XmNitems, NULL ); n++; 482 XtSetArg( args[ n ], XmNitemCount, 0 ); n++; 483 XtSetArg( args[ n ], XmNcolumns, 10 ); n++; 484 XtSetArg( args[ n ], XmNcursorPositionVisible, False ); n++; 485 indexFs = xitCreateFieldSelect( workFo, "IndexFs", args, n, NULL, NULL ); 486 487 488 /* Select field. */ 489 n = 0; 490 XtSetArg( args[ n ], XmNitems, NULL ); n++; 491 XtSetArg( args[ n ], XmNitemCount, 0 ); n++; 492 XtSetArg( args[ n ], XmNcolumns, 10 ); n++; 493 selectFs = xitCreateFieldSelect( workFo, "SelectFs", args, n, NULL, NULL ); 494 495 496 tempW = xitFieldSelectGetChild( indexFs, xitFIELD_SELECT_TEXT_FIELD ); 497 n = 0; 498 XtSetArg( args[ n ], XmNshadowThickness, 1 ); n++; 499 XtSetValues( tempW, args, n ); 500 501 502 /* Hidden field. */ 503 { 504 Pixel bg; 505 Widget tmpWorkFo; 506 507 static XIT_TEXT_STRUCT text_buffer[] = { 508 { "ChidTx", NULL, 1, True }, 509 }; 510 511 static XIT_ACTION_AREA_ITEM action_buttons[] = { 512 { "", changeHiddenOkCB, NULL }, 513 { NULL, NULL, NULL }, 514 { "", changeHiddenCancelCB, NULL }, 515 }; 516 517 n = 0; 518 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 519 hiddenRc = XmCreateRowColumn( workFo, "HiddenRc", args, n ); 520 521 hiddenLa = xitCreateLabel( hiddenRc, "HiddenLa", " ", -1 ); 522 hiddenPb = xitCreatePushButton( hiddenRc, &button_def[ 0 ] ); 523 524 XtAddCallback( hiddenPb, XmNactivateCallback, 525 (XtCallbackProc) changeHiddenCB, (XtPointer) par_set_ref ); 526 527 /* Change hidden popup. */ 528 action_buttons[ 0 ].label = labels -> ok_button; 529 action_buttons[ 0 ].data = par_set_ref; 530 action_buttons[ 2 ].label = labels -> cancel_button; 531 action_buttons[ 2 ].data = par_set_ref; 532 533 /* Create a form dialog with buttons. */ 534 chidFd = xitCreateFormDialog( par_set_ref -> parSetW, "ChidFd", 535 1, 0, 536 action_buttons, 537 XtNumber( action_buttons ) ); 538 539 n = 0; 540 XtSetArg( args[ n ], XmNtitle, " " ); n++; 541 XtSetValues( XtParent( chidFd ), args, n ); 542 543 n = 0; 544 XtSetArg( args[ n ], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); n++; 545 XtSetValues( chidFd, args, n ); 546 547 tmpWorkFo = XtNameToWidget( chidFd, "ChidFdFo" ); 548 549 chidWhatLa = xitCreateLabel( tmpWorkFo, "PwdWhatLa", 550 labels -> change_hidden_label, 551 -1 ); 552 553 chidTx = xitCreateTextCols( tmpWorkFo, &text_buffer[ 0 ], 20 ); 554 555 n = 0; 556 XtSetArg( args[ n ], XmNbackground, &bg ); n++; 557 XtGetValues( chidTx, args, n ); 558 559 n = 0; 560 XtSetArg( args[ n ], XmNforeground, bg ); n++; 561 XtSetValues( chidTx, args, n ); 562 563 xitAttachWidget( chidWhatLa, 564 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 565 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 566 xitAttachWidget( chidTx, 567 XmATTACH_WIDGET, chidWhatLa, XmATTACH_FORM, NULL, 568 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 569 570 n = 0; 571 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 572 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 573 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 574 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 575 XtSetValues( chidWhatLa, args, n ); 576 XtSetValues( chidTx, args, n ); 577 578 par_set_ref -> changeHiddenW = chidFd; 579 } 580 581 582 /* Workdays. */ 583 { 584 int char_read; 585 char buffer[ 256 ]; 586 char label[ 256 ]; 587 char *char_ref; 588 589 n = 0; 590 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 591 XtSetArg( args[ n ], XmNpacking, XmPACK_COLUMN ); n++; 592 XtSetArg( args[ n ], XmNnumColumns, 2 ); n++; 593 workdaysRc = XmCreateRowColumn( workFo, "WorkdaysRc", args, n ); 594 595 char_ref = labels -> weekdays_short; 596 597 for( index = 0; index < XtNumber( workdaysBu ); index++ ) { 598 if( index < 7 ) { 599 char_read = strlen( char_ref ); 600 sscanf( char_ref, "%s%n", label, &char_read ); 601 char_ref = char_ref + char_read; 602 } else { 603 strcpy( label, " " ); 604 } 605 606 sprintf( buffer, "Workdays%dBu", index + 1 ); 607 608 workdaysBu[ index ] = xitCreateToggleButton( workdaysRc, buffer, 609 label, False ); 610 611 if( index >= 7 ) { 612 n = 0; 613 XtSetArg( args[ n ], XmNmappedWhenManaged, False ); n++; 614 XtSetValues( workdaysBu[ index ], args, n ); 615 } 616 } /* loop */ 617 618 } /* block */ 619 620 621 /* Date format. */ 622 dateFormatFo = XmCreateForm( workFo, "DateFormatFo", args, 0 ); 623 624 n = 0; 625 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 626 dateOrderRb = XmCreateRadioBox( dateFormatFo, "DateOrderRb", args, n ); 627 628 ymdTb = xitCreateToggleButton( dateOrderRb, "YmdTb", 629 labels -> ymd_label, False ); 630 dmyTb = xitCreateToggleButton( dateOrderRb, "DmyTb", 631 labels -> dmy_label, False ); 632 mdyTb = xitCreateToggleButton( dateOrderRb, "MdyTb", 633 labels -> mdy_label, False ); 634 635 n = 0; 636 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 637 dateSepRc = XmCreateRowColumn( dateFormatFo, "DateSepRc", args, n ); 638 639 dateSepLa = xitCreateLabel( dateSepRc, "DateSepLa", 640 labels -> date_sep_label, -1 ); 641 dateSepTx = xitCreateText( dateSepRc, &text_buffer_def[ 3 ] ); 642 643 n = 0; 644 XtSetArg( args[ n ], XmNorientation, XmVERTICAL ); n++; 645 dateParRc = XmCreateRowColumn( dateFormatFo, "DateParRc", args, n ); 646 647 dayZeroTb = xitCreateToggleButton( dateParRc, "DayZeroTb", 648 labels -> day_zero_label, False ); 649 monthZeroTb = xitCreateToggleButton( dateParRc, "MonthZeroTb", 650 labels -> month_zero_label, False ); 651 centuryTb = xitCreateToggleButton( dateParRc, "CenturyTb", 652 labels -> century_label, False ); 653 654 n = 0; 655 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 656 week1stDayRc = XmCreateRowColumn( dateFormatFo, "Week1stDayRc", args, n ); 657 658 week1stDayLa = xitCreateLabel( week1stDayRc, "Week1stDayLa", 659 labels -> week_1st_day_label, -1 ); 660 661 n = 0; 662 XtSetArg( args[ n ], XmNitems, NULL ); n++; 663 XtSetArg( args[ n ], XmNitemCount, 0 ); n++; 664 XtSetArg( args[ n ], XmNcolumns, 15 ); n++; 665 XtSetArg( args[ n ], XmNcursorPositionVisible, False ); n++; 666 week1stDayFs = xitCreateFieldSelect( week1stDayRc, "Week1stDayFs", 667 args, n, NULL, NULL ); 668 xitFieldSelectEditable( week1stDayFs, False ); 669 670 tempW = xitFieldSelectGetChild( week1stDayFs, xitFIELD_SELECT_TEXT_FIELD ); 671 n = 0; 672 XtSetArg( args[ n ], XmNshadowThickness, 1 ); n++; 673 XtSetValues( tempW, args, n ); 674 675 createFieldMenu( labels -> week_1st_days, tag_array, MAX_MENU_TAGS, 676 &tag_count ); 677 xitFieldSelectSetMenu( week1stDayFs, tag_array, tag_count ); 678 679 for( index = 0; index < tag_count; index++ ) 680 SysFree( tag_array[ index ] ); 681 682 683 xitAttachWidget( dateOrderRb, 684 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 685 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 686 xitAttachWidget( dateSepRc, 687 XmATTACH_WIDGET, dateOrderRb, XmATTACH_FORM, NULL, 688 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 689 xitAttachWidget( dateParRc, 690 XmATTACH_WIDGET, dateSepRc, XmATTACH_FORM, NULL, 691 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 692 xitAttachWidget( week1stDayRc, 693 XmATTACH_WIDGET, dateParRc, XmATTACH_FORM, NULL, 694 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 695 696 n = 0; 697 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 698 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 699 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 700 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 701 XtSetValues( dateOrderRb, args, n ); 702 XtSetValues( dateSepRc, args, n ); 703 XtSetValues( dateParRc, args, n ); 704 XtSetValues( week1stDayRc, args, n ); 705 706 707 /* Time format. */ 708 timeFormatFo = XmCreateForm( workFo, "TimeFormatFo", args, 0 ); 709 710 n = 0; 711 XtSetArg( args[ n ], XmNorientation, XmVERTICAL ); n++; 712 XtSetArg( args[ n ], XmNradioBehavior, True ); n++; 713 XtSetArg( args[ n ], XmNspacing, 15 ); n++; 714 timeTypeRb = XmCreateRowColumn( timeFormatFo, "TimeTypeRb", args, n ); 715 716 hour12Tb = xitCreateToggleButton( timeTypeRb, "Hour12Tb", 717 labels -> hour12_label, False ); 718 hour24Tb = xitCreateToggleButton( timeTypeRb, "Hour24Tb", 719 labels -> hour24_label, False ); 720 721 hour12Tx = xitCreateText( timeFormatFo, &text_buffer_def[ 4 ] ); 722 hour24Tx = xitCreateText( timeFormatFo, &text_buffer_def[ 5 ] ); 723 724 n = 0; 725 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 726 timeSepRc = XmCreateRowColumn( timeFormatFo, "TimeSepRc", args, n ); 727 728 timeSepLa = xitCreateLabel( timeSepRc, "TimeSepLa", 729 labels -> time_sep_label, -1 ); 730 731 timeSepTx = xitCreateText( timeSepRc, &text_buffer_def[ 3 ] ); 732 733 n = 0; 734 XtSetArg( args[ n ], XmNorientation, XmVERTICAL ); n++; 735 timeParRc = XmCreateRowColumn( timeFormatFo, "TimeParRc", args, n ); 736 737 hourZeroTb = xitCreateToggleButton( timeParRc, "HourZeroTb", 738 labels -> hour_zero_label, False ); 739 740 xitAttachWidget( timeTypeRb, 741 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 742 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 743 xitAttachWidget( hour12Tx, 744 XmATTACH_FORM, NULL, XmATTACH_WIDGET, timeTypeRb, 745 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 746 xitAttachWidget( hour24Tx, 747 XmATTACH_WIDGET, hour12Tx, XmATTACH_WIDGET, timeTypeRb, 748 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 749 xitAttachWidget( timeSepRc, 750 XmATTACH_WIDGET, hour24Tx, XmATTACH_FORM, NULL, 751 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 752 xitAttachWidget( timeParRc, 753 XmATTACH_WIDGET, timeSepRc, XmATTACH_FORM, NULL, 754 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 755 756 n = 0; 757 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 758 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 759 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 760 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 761 XtSetValues( timeTypeRb, args, n ); 762 XtSetValues( timeSepRc, args, n ); 763 XtSetValues( timeParRc, args, n ); 764 XtSetValues( hour12Tx, args, n ); 765 XtSetValues( hour24Tx, args, n ); 766 767 768 /* Place the various elements together. */ 769 xitAttachWidget( parListLa, 770 XmATTACH_FORM, NULL, 771 XmATTACH_FORM, NULL, 772 XmATTACH_NONE, NULL, 773 XmATTACH_NONE, NULL ); 774 xitAttachWidget( XtParent( parListLi ), 775 XmATTACH_WIDGET, parListLa, 776 XmATTACH_FORM, NULL, 777 XmATTACH_NONE, NULL, 778 XmATTACH_NONE, NULL ); 779 xitAttachWidget( descLa, 780 XmATTACH_FORM, NULL, 781 XmATTACH_WIDGET, XtParent( parListLi ), 782 XmATTACH_NONE, NULL, 783 XmATTACH_NONE, NULL ); 784 xitAttachWidget( XtParent( descTx ), 785 XmATTACH_WIDGET, descLa, 786 XmATTACH_WIDGET, XtParent( parListLi ), 787 XmATTACH_NONE, NULL, 788 XmATTACH_NONE, NULL ); 789 xitAttachWidget( valueLa, 790 XmATTACH_WIDGET, XtParent( descTx ), 791 XmATTACH_WIDGET, XtParent( parListLi ), 792 XmATTACH_NONE, NULL, 793 XmATTACH_NONE, NULL ); 794 795 xitAttachWidget( colorFs, 796 XmATTACH_WIDGET, valueLa, 797 XmATTACH_WIDGET, XtParent( parListLi ), 798 XmATTACH_NONE, NULL, 799 XmATTACH_NONE, NULL ); 800 xitAttachWidget( indexFs, 801 XmATTACH_WIDGET, valueLa, 802 XmATTACH_WIDGET, XtParent( parListLi ), 803 XmATTACH_NONE, NULL, 804 XmATTACH_NONE, NULL ); 805 xitAttachWidget( onOffRb, 806 XmATTACH_WIDGET, valueLa, 807 XmATTACH_WIDGET, XtParent( parListLi ), 808 XmATTACH_NONE, NULL, 809 XmATTACH_NONE, NULL ); 810 xitAttachWidget( selectFs, 811 XmATTACH_WIDGET, valueLa, 812 XmATTACH_WIDGET, XtParent( parListLi ), 813 XmATTACH_NONE, NULL, 814 XmATTACH_NONE, NULL ); 815 xitAttachWidget( textTx, 816 XmATTACH_WIDGET, valueLa, 817 XmATTACH_WIDGET, XtParent( parListLi ), 818 XmATTACH_NONE, NULL, 819 XmATTACH_NONE, NULL ); 820 xitAttachWidget( intFo, 821 XmATTACH_WIDGET, valueLa, 822 XmATTACH_WIDGET, XtParent( parListLi ), 823 XmATTACH_FORM, NULL, 824 XmATTACH_NONE, NULL ); 825 xitAttachWidget( dateFormatFo, 826 XmATTACH_WIDGET, valueLa, 827 XmATTACH_WIDGET, XtParent( parListLi ), 828 XmATTACH_FORM, NULL, 829 XmATTACH_NONE, NULL ); 830 xitAttachWidget( hiddenRc, 831 XmATTACH_WIDGET, valueLa, 832 XmATTACH_WIDGET, XtParent( parListLi ), 833 XmATTACH_FORM, NULL, 834 XmATTACH_NONE, NULL ); 835 xitAttachWidget( workdaysRc, 836 XmATTACH_WIDGET, valueLa, 837 XmATTACH_WIDGET, XtParent( parListLi ), 838 XmATTACH_FORM, NULL, 839 XmATTACH_NONE, NULL ); 840 xitAttachWidget( timeFormatFo, 841 XmATTACH_WIDGET, valueLa, 842 XmATTACH_WIDGET, XtParent( parListLi ), 843 XmATTACH_FORM, NULL, 844 XmATTACH_NONE, NULL ); 845 xitAttachWidget( intSc, 846 XmATTACH_FORM, NULL, 847 XmATTACH_FORM, NULL, 848 XmATTACH_WIDGET, intTx, 849 XmATTACH_NONE, NULL ); 850 xitAttachWidget( intTx, 851 XmATTACH_NONE, NULL, 852 XmATTACH_NONE, NULL, 853 XmATTACH_FORM, NULL, 854 XmATTACH_FORM, NULL ); 855 xitAttachWidget( yesNoRb, 856 XmATTACH_WIDGET, valueLa, 857 XmATTACH_WIDGET, XtParent( parListLi ), 858 XmATTACH_NONE, NULL, 859 XmATTACH_NONE, NULL ); 860 861 862 /* Make sure there is enough space between the children. */ 863 n = 0; 864 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 865 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 866 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 867 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 868 XtSetValues( parListLa, args, n ); 869 XtSetValues( descLa, args, n ); 870 XtSetValues( XtParent( parListLi ), args, n ); 871 XtSetValues( XtParent( descTx ), args, n ); 872 873 n = 0; 874 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 875 XtSetArg( args[ n ], XmNleftOffset, 15 ); n++; 876 XtSetArg( args[ n ], XmNrightOffset, 15 ); n++; 877 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 878 XtSetValues( colorFs, args, n ); 879 XtSetValues( indexFs, args, n ); 880 XtSetValues( onOffRb, args, n ); 881 XtSetValues( selectFs, args, n ); 882 XtSetValues( textTx, args, n ); 883 XtSetValues( valueLa, args, n ); 884 XtSetValues( intSc, args, n ); 885 XtSetValues( yesNoRb, args, n ); 886 XtSetValues( dateFormatFo, args, n ); 887 XtSetValues( timeFormatFo, args, n ); 888 XtSetValues( hiddenRc, args, n ); 889 XtSetValues( workdaysRc, args, n ); 890 891 n = 0; 892 XtSetArg( args[ n ], XmNleftOffset, 15 ); n++; 893 XtSetArg( args[ n ], XmNrightOffset, 15 ); n++; 894 XtSetArg( args[ n ], XmNbottomOffset, 0 ); n++; 895 XtSetValues( intTx, args, n ); 896 897 n = 0; 898 XtSetArg( args[ n ], XmNleftOffset, 15 ); n++; 899 XtSetValues( descLa, args, n ); 900 XtSetValues( XtParent( descTx ), args, n ); 901 902 903 /* Manage all the children. */ 904 xitManageChildren( workdaysBu, XtNumber( workdaysBu ) ); 905 xitManageChildren( dataLocalW, XtNumber( dataLocalW ) ); 906 907 908 /* Set the size of the window. */ 909 xitSetSizeFormDialog( parSetFd, True ); 910 xitSetSizeFormDialog( chidFd, True ); 911 912 913 /* Make sure our children don't spoil our size. */ 914 n = 0; 915 XtSetArg( args[ n ], XmNallowShellResize, False ); n++; 916 XtSetValues( XtParent( parSetFd ), args, n ); 917 918 919 /* Don't display any parameter widgets. */ 920 XtUnmanageChild( colorFs ); 921 XtUnmanageChild( indexFs ); 922 XtUnmanageChild( onOffRb ); 923 XtUnmanageChild( selectFs ); 924 XtUnmanageChild( textTx ); 925 XtUnmanageChild( intFo ); 926 XtUnmanageChild( yesNoRb ); 927 XtUnmanageChild( dateFormatFo ); 928 XtUnmanageChild( timeFormatFo ); 929 XtUnmanageChild( hiddenRc ); 930 XtUnmanageChild( workdaysRc ); 931 932 933 /* Make the final attachments. */ 934 n = 0; 935 XtSetArg( args[ n ], XmNbottomAttachment, XmATTACH_FORM ); n++; 936 XtSetValues( XtParent( parListLi ), args, n ); 937 938 n = 0; 939 XtSetArg( args[ n ], XmNrightAttachment, XmATTACH_FORM ); n++; 940 XtSetValues( XtParent( descTx ), args, n ); 941 942 943 return( parSetFd ); 944 945 } /* xitCreateParameterSet */ 946 947 948 /*----------------------------------------------------------------------*/ 949 950 void xitParameterSetDisplay(Widget parSetW,XIT_PAR_REC par_rec_ref[],int rec_no)951 xitParameterSetDisplay( Widget parSetW, 952 XIT_PAR_REC par_rec_ref[], 953 int rec_no ) 954 { 955 956 /* Variables. */ 957 int index; 958 size_t size; 959 Arg args[ 5 ]; 960 Cardinal n; 961 XmString list_items[ 100 ]; 962 Widget mainW; 963 Widget tempW; 964 PAR_SET_REC_REF par_set_ref; 965 966 967 /* Code. */ 968 969 /* Get our private data. */ 970 n = 0; 971 XtSetArg( args[ n ], XmNuserData, (void *) &par_set_ref ); n++; 972 XtGetValues( parSetW, args, n ); 973 974 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 975 976 977 /* Save the parameter data (needed later ). */ 978 if( par_set_ref -> par_rec_ref != NULL ) 979 SysFree( par_set_ref -> par_rec_ref ); 980 981 par_set_ref -> par_rec_ref = 982 (XIT_PAR_REC *) SysMalloc( sizeof( XIT_PAR_REC ) * rec_no ); 983 984 memcpy( par_set_ref -> par_rec_ref, par_rec_ref, 985 rec_no * sizeof( XIT_PAR_REC ) ); 986 987 par_set_ref -> rec_no = rec_no; 988 989 990 /* Free any data allocated for working parameters. */ 991 for( index = 0; index < MAX_PARAMETERS; index++ ) { 992 if( par_set_ref -> work[ index ].value != NULL ) 993 SysFree( par_set_ref -> work[ index ].value ); 994 } 995 996 997 /* Copy the parameters to be used when working. */ 998 for( index = 0; index < rec_no; index++ ) { 999 size = par_rec_ref[ index ].size; 1000 1001 par_set_ref -> work[ index ].value = (void *) SysMalloc( size ); 1002 1003 switch( par_rec_ref[ index ].parameter_type ) { 1004 case XIT_PS_TYPE_SEPARATOR: 1005 break; 1006 1007 default: 1008 memcpy( par_set_ref -> work[ index ].value, 1009 par_rec_ref[ index ].value, 1010 size ); 1011 } 1012 } 1013 1014 if( par_set_ref -> last_valueW != NULL ) { 1015 XtUnmanageChild( par_set_ref -> last_valueW ); 1016 par_set_ref -> last_valueW = NULL; 1017 } 1018 1019 par_set_ref -> last_value_no = 0; 1020 1021 1022 /* Fill the parameter list. */ 1023 for( index = 0; index < rec_no; index++ ) { 1024 if( par_rec_ref[ index ].parameter_type == XIT_PS_TYPE_SEPARATOR ) 1025 list_items[ index ] = XmStringCreate( "---", CS ); 1026 else 1027 list_items[ index ] = 1028 XmStringCreate( par_rec_ref[ index ].parameter_label, CS ); 1029 } 1030 1031 1032 /* Assign the parameters to the parameter list. */ 1033 tempW = XtNameToWidget( mainW, "ParListLiSW.ParListLi" ); 1034 1035 n = 0; 1036 XtSetArg( args[ n ], XmNitems, list_items ); n++; 1037 XtSetArg( args[ n ], XmNitemCount, rec_no ); n++; 1038 XtSetArg( args[ n ], XmNselectedItemCount, 0 ); n++; 1039 XtSetValues( tempW, args, n ); 1040 1041 /* Free allocated memory. */ 1042 for( index = 0; index < rec_no; index++ ) 1043 XmStringFree( list_items[ index ] ); 1044 1045 XmListSelectPos( tempW, 1, True ); 1046 1047 1048 return; 1049 1050 } /* xitParameterSetDisplay */ 1051 1052 1053 /*----------------------------------------------------------------------*/ 1054 1055 static void createFieldMenu(char * menu_string,String * tags,int max_tags,int * num_tags)1056 createFieldMenu( char *menu_string, 1057 String *tags, 1058 int max_tags, 1059 int *num_tags ) 1060 { 1061 1062 /* Variables. */ 1063 int char_read; 1064 int items; 1065 int tag_count; 1066 char buffer[ 150 ]; 1067 char *char_ref; 1068 1069 1070 /* Code. */ 1071 1072 tag_count = 0; 1073 char_ref = menu_string; 1074 1075 do { 1076 while( isspace( *char_ref ) ) 1077 char_ref++; 1078 1079 if( *char_ref == '\0' ) 1080 break; 1081 1082 char_read = strlen( char_ref ); 1083 items = sscanf( char_ref, "%s%n", buffer, &char_read ); 1084 if( items != 1 ) 1085 break; 1086 1087 *(tags + tag_count ) = SysNewString( buffer ); 1088 tag_count++; 1089 1090 char_ref = char_ref + char_read; 1091 1092 } while( tag_count < max_tags ); 1093 1094 *num_tags = tag_count; 1095 1096 1097 return; 1098 1099 } /* createFieldMenu */ 1100 1101 1102 /*----------------------------------------------------------------------*/ 1103 1104 static Boolean saveParameter(PAR_SET_REC_REF par_set_ref)1105 saveParameter( PAR_SET_REC_REF par_set_ref ) 1106 { 1107 1108 /* Variables. */ 1109 int hour; 1110 int index_color; 1111 int int_value; 1112 int items; 1113 int minute; 1114 UINT32 flag_value; 1115 char buffer1[ 50 ]; 1116 char buffer2[ 50 ]; 1117 char *char_string; 1118 Pixel pixel; 1119 Widget mainW; 1120 Widget tempW; 1121 XColor color; 1122 TIM_STATUS_TYPE tstatus; 1123 TIM_TIME_REF time_value; 1124 XIT_PAR_REC *par_rec_ref; 1125 WORK_VALUE_REC *work_ref; 1126 1127 1128 /* Code. */ 1129 1130 if( par_set_ref -> last_valueW == NULL ) 1131 return( True ); 1132 1133 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 1134 par_rec_ref = &par_set_ref -> par_rec_ref[ par_set_ref -> last_value_no ]; 1135 work_ref = &par_set_ref -> work[ par_set_ref -> last_value_no ]; 1136 1137 1138 /* Save the previous value. */ 1139 switch( par_rec_ref -> parameter_type ) { 1140 1141 case XIT_PS_TYPE_SEPARATOR: 1142 break; 1143 1144 case XIT_PS_TYPE_INTEGER: 1145 tempW = XtNameToWidget( mainW, "IntFo.IntTx" ); 1146 1147 char_string = xitStringGetText( tempW ); 1148 items = sscanf( char_string, "%d", &int_value ); 1149 SysFree( char_string ); 1150 1151 if( items != 1 || 1152 int_value < par_rec_ref -> min || 1153 int_value > par_rec_ref -> max ) 1154 return( False ); 1155 1156 *((int *) work_ref -> value) = int_value; 1157 break; 1158 1159 1160 case XIT_PS_TYPE_YES_NO: 1161 case XIT_PS_TYPE_ON_OFF: 1162 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO ) 1163 tempW = XtNameToWidget( mainW, "YesNoRb.YesTb" ); 1164 else 1165 tempW = XtNameToWidget( mainW, "OnOffRb.OnTb" ); 1166 1167 if( XmToggleButtonGetState( tempW ) ) 1168 *((Boolean *) work_ref -> value) = True; 1169 else 1170 *((Boolean *) work_ref -> value) = False; 1171 break; 1172 1173 1174 case XIT_PS_TYPE_YES_NO_FLAG: 1175 case XIT_PS_TYPE_ON_OFF_FLAG: 1176 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO_FLAG ) 1177 tempW = XtNameToWidget( mainW, "YesNoRb.YesTb" ); 1178 else 1179 tempW = XtNameToWidget( mainW, "OnOffRb.OnTb" ); 1180 1181 flag_value = *((UINT32 *) work_ref -> value); 1182 1183 if( XmToggleButtonGetState( tempW ) ) 1184 flagSet( flag_value, par_rec_ref -> flag_offset ); 1185 else 1186 flagClear( flag_value, par_rec_ref -> flag_offset ); 1187 1188 *((UINT32 *) work_ref -> value) = flag_value; 1189 break; 1190 1191 1192 case XIT_PS_TYPE_TEXT_FIELD: 1193 tempW = XtNameToWidget( mainW, "TextTx" ); 1194 1195 char_string = xitStringGetText( tempW ); 1196 strcpy( ((char *) work_ref -> value), char_string ); 1197 SysFree( char_string ); 1198 break; 1199 1200 1201 case XIT_PS_TYPE_INTEGER_FIELD: 1202 tempW = XtNameToWidget( mainW, "TextTx" ); 1203 1204 char_string = xitStringGetText( tempW ); 1205 1206 items = sscanf( char_string, "%d", &int_value ); 1207 SysFree( char_string ); 1208 1209 if( items != 1 || 1210 int_value < par_rec_ref -> min || 1211 int_value > par_rec_ref -> max ) 1212 return( False ); 1213 1214 *((int *) work_ref -> value) = int_value; 1215 break; 1216 1217 1218 case XIT_PS_TYPE_DATE_FIELD: 1219 tempW = XtNameToWidget( mainW, "TextTx" ); 1220 1221 char_string = xitStringGetText( tempW ); 1222 1223 items = sscanf( char_string, "%s", buffer1 ); 1224 SysFree( char_string ); 1225 1226 if( items != 1 ) 1227 return( False ); 1228 1229 tstatus = TimMakeDateFromString( &time_value, buffer2 ); 1230 if( tstatus != TIM_OK ) 1231 return( False ); 1232 1233 *((TIM_TIME_REF *) work_ref -> value) = time_value; 1234 break; 1235 1236 1237 case XIT_PS_TYPE_TIME_FIELD: 1238 tempW = XtNameToWidget( mainW, "TextTx" ); 1239 1240 char_string = xitStringGetText( tempW ); 1241 1242 items = sscanf( char_string, "%s", buffer1 ); 1243 SysFree( char_string ); 1244 1245 if( items != 1 ) 1246 return( False ); 1247 1248 tstatus = TimMakeTimeFromString( &time_value, buffer2 ); 1249 if( tstatus != TIM_OK ) 1250 return( False ); 1251 1252 *((TIM_TIME_REF *) work_ref -> value) = time_value; 1253 break; 1254 1255 1256 case XIT_PS_TYPE_DURATION_FIELD: 1257 tempW = XtNameToWidget( mainW, "TextTx" ); 1258 1259 char_string = xitStringGetText( tempW ); 1260 1261 items = sscanf( char_string, "%d:%d", &hour, &minute ); 1262 SysFree( char_string ); 1263 1264 if( items == 1 && hour >= 0 ) 1265 int_value = hour; 1266 else if( items == 2 && hour >= 0 && minute >= 0 && minute < 60 ) 1267 int_value = hour * 60 + minute; 1268 else 1269 return( False ); 1270 1271 if( int_value < par_rec_ref -> min || 1272 int_value > par_rec_ref -> max ) 1273 return( False ); 1274 1275 *((int *) work_ref -> value) = int_value; 1276 break; 1277 1278 1279 case XIT_PS_TYPE_COLOR_FIELD: 1280 tempW = XtNameToWidget( mainW, "ColorFs" ); 1281 1282 (void) xitColorSelectGetColor( tempW, 1283 &pixel, &color, 1284 buffer1 ); 1285 1286 *((Pixel *) work_ref -> value) = (Pixel) color.pixel; 1287 break; 1288 1289 1290 case XIT_PS_TYPE_COLOR_INDEX_FIELD: 1291 tempW = XtNameToWidget( mainW, "ColorFs" ); 1292 1293 (void) xitColorSelectGetIndex( tempW, 1294 &index_color ); 1295 1296 *((int *) work_ref -> value) = index_color; 1297 break; 1298 1299 1300 case XIT_PS_TYPE_SELECT_FIELD: 1301 tempW = XtNameToWidget( mainW, "SelectFs" ); 1302 1303 xitFieldSelectGetCurrent( tempW, &char_string ); 1304 strcpy( ((char *) work_ref -> value), char_string ); 1305 1306 SysFree( char_string ); 1307 break; 1308 1309 1310 case XIT_PS_TYPE_SELECT_INDEX_FIELD: 1311 tempW = XtNameToWidget( mainW, "IndexFs" ); 1312 1313 xitFieldSelectGetIndex( tempW, &int_value ); 1314 1315 *((int *) work_ref -> value) = int_value; 1316 break; 1317 1318 1319 case XIT_PS_TYPE_HIDDEN_TEXT_FIELD: 1320 strcpy( ((char *) work_ref -> value), par_set_ref -> hidden_buf ); 1321 break; 1322 1323 1324 case XIT_PS_TYPE_WORKDAYS_FIELD: 1325 { 1326 Boolean valid = False; 1327 int index; 1328 char buffer[ 256 ]; 1329 1330 for( index = 0; index < 7; index++ ) { 1331 sprintf( buffer, "WorkdaysRc.Workdays%dBu", index + 1 ); 1332 tempW = XtNameToWidget( mainW, buffer ); 1333 1334 if( XmToggleButtonGetState( tempW ) ) 1335 valid = True; 1336 } 1337 1338 if( ! valid ) 1339 return( False); 1340 1341 for( index = 0; index < 7; index++ ) { 1342 sprintf( buffer, "WorkdaysRc.Workdays%dBu", index + 1 ); 1343 tempW = XtNameToWidget( mainW, buffer ); 1344 1345 if( XmToggleButtonGetState( tempW ) ) 1346 *(((Boolean *) work_ref -> value) + index) = True; 1347 else 1348 *(((Boolean *) work_ref -> value) + index) = False; 1349 } 1350 } 1351 break; 1352 1353 1354 case XIT_PS_TYPE_DATE_FORMAT_FIELD: 1355 { 1356 char buffer[ 50 ]; 1357 char date_format[ 50 ]; 1358 1359 tempW = XtNameToWidget( mainW, "DateFormatFo.DateOrderRb.YmdTb" ); 1360 if( XmToggleButtonGetState( tempW ) ) 1361 strncpy( date_format, "YMD", 3 ); 1362 1363 tempW = XtNameToWidget( mainW, "DateFormatFo.DateOrderRb.MdyTb" ); 1364 if( XmToggleButtonGetState( tempW ) ) 1365 strncpy( date_format, "MDY", 3 ); 1366 1367 tempW = XtNameToWidget( mainW, "DateFormatFo.DateOrderRb.DmyTb" ); 1368 if( XmToggleButtonGetState( tempW ) ) 1369 strncpy( date_format, "DMY", 3 ); 1370 1371 tempW = XtNameToWidget( mainW, "DateFormatFo.DateSepRc.SepTx" ); 1372 char_string = xitStringGetText( tempW ); 1373 1374 if( isdigit( *char_string ) ) { 1375 SysFree( char_string ); 1376 return( False ); 1377 } 1378 1379 if( *char_string == '\0' ) 1380 date_format[ 3 ] = '0'; 1381 else 1382 date_format[ 3 ] = *char_string; 1383 SysFree( char_string ); 1384 1385 tempW = XtNameToWidget( mainW, "DateFormatFo.DateParRc.DayZeroTb" ); 1386 if( XmToggleButtonGetState( tempW ) ) 1387 date_format[ 4 ] = '1'; 1388 else 1389 date_format[ 4 ] = '0'; 1390 1391 tempW = XtNameToWidget( mainW, "DateFormatFo.DateParRc.MonthZeroTb" ); 1392 if( XmToggleButtonGetState( tempW ) ) 1393 date_format[ 5 ] = '1'; 1394 else 1395 date_format[ 5 ] = '0'; 1396 1397 tempW = XtNameToWidget( mainW, "DateFormatFo.DateParRc.CenturyTb" ); 1398 if( XmToggleButtonGetState( tempW ) ) 1399 date_format[ 6 ] = '1'; 1400 else 1401 date_format[ 6 ] = '0'; 1402 1403 tempW = XtNameToWidget( mainW, 1404 "DateFormatFo.Week1stDayRc.Week1stDayFs" ); 1405 (void) xitFieldSelectGetIndex( tempW, &int_value ); 1406 sprintf( buffer, "%d", int_value ); 1407 date_format[ 7 ] = buffer[ 0 ]; 1408 1409 date_format[ 8 ] = '\0'; 1410 1411 strcpy( ((char *) work_ref -> value), date_format ); 1412 } 1413 break; 1414 1415 1416 case XIT_PS_TYPE_TIME_FORMAT_FIELD: 1417 { 1418 Boolean hour12_format = False; 1419 char time_format[ 50 ]; 1420 1421 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeTypeRb.Hour12Tb" ); 1422 if( XmToggleButtonGetState( tempW ) ) { 1423 strncpy( time_format, "12", 2 ); 1424 hour12_format = True; 1425 } 1426 1427 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeTypeRb.Hour24Tb" ); 1428 if( XmToggleButtonGetState( tempW ) ) 1429 strncpy( time_format, "24", 2 ); 1430 1431 strncpy( &time_format[ 2 ], " ", 2 ); 1432 1433 if( hour12_format ) { 1434 tempW = XtNameToWidget( mainW, "TimeFormatFo.Hour12Tx" ); 1435 char_string = xitStringGetText( tempW ); 1436 1437 if( *char_string != '\0' ) { 1438 time_format[ 2 ] = *char_string; 1439 if( *(char_string + 1) != '\0' ) 1440 time_format[ 3 ] = *(char_string + 1); 1441 } 1442 1443 SysFree( char_string ); 1444 } 1445 1446 if( hour12_format && strncmp( &time_format[ 2 ], " ", 2 ) == 0 ) 1447 strncpy( &time_format[ 2 ], "am", 2 ); 1448 1449 strncpy( &time_format[ 4 ], " ", 2 ); 1450 1451 tempW = XtNameToWidget( mainW, "TimeFormatFo.Hour24Tx" ); 1452 char_string = xitStringGetText( tempW ); 1453 1454 if( *char_string != '\0' ) { 1455 time_format[ 4 ] = *char_string; 1456 if( *(char_string + 1) != '\0' ) 1457 time_format[ 5 ] = *(char_string + 1); 1458 } 1459 1460 SysFree( char_string ); 1461 1462 if( hour12_format && strncmp( &time_format[ 4 ], " ", 2 ) == 0 ) 1463 strncpy( &time_format[ 4 ], "pm", 2 ); 1464 1465 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeSepRc.SepTx" ); 1466 char_string = xitStringGetText( tempW ); 1467 1468 if( isdigit( *char_string ) ) { 1469 SysFree( char_string ); 1470 return( False ); 1471 } 1472 1473 if( *char_string == '\0' ) 1474 time_format[ 6 ] = '0'; 1475 else 1476 time_format[ 6 ] = *char_string; 1477 SysFree( char_string ); 1478 1479 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeParRc.HourZeroTb" ); 1480 if( XmToggleButtonGetState( tempW ) ) 1481 time_format[ 7 ] = '1'; 1482 else 1483 time_format[ 7 ] = '0'; 1484 1485 time_format[ 8 ] = '\0'; 1486 1487 strcpy( ((char *) work_ref -> value), time_format ); 1488 } 1489 break; 1490 1491 } /* switch */ 1492 1493 1494 return( True ); 1495 1496 } /* saveParameter */ 1497 1498 1499 /*----------------------------------------------------------------------*/ 1500 1501 static void setParameter(PAR_SET_REC_REF par_set_ref,XIT_PAR_REC * par_rec_ref,WORK_VALUE_REC * work_ref)1502 setParameter( PAR_SET_REC_REF par_set_ref, 1503 XIT_PAR_REC *par_rec_ref, 1504 WORK_VALUE_REC *work_ref ) 1505 { 1506 1507 /* Variables. */ 1508 int index; 1509 int index_color; 1510 int int_value; 1511 int tag_count; 1512 UINT32 flag_value; 1513 char *char_ref; 1514 char buffer[ 201 ]; 1515 Arg args[ 5 ]; 1516 Cardinal n; 1517 Pixel pixel_value; 1518 String tag_array[ MAX_MENU_TAGS ]; 1519 Widget mainW; 1520 Widget tempW; 1521 TIM_TIME_REF time_value; 1522 1523 1524 /* Code. */ 1525 1526 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 1527 1528 /* Set the value. */ 1529 switch( par_rec_ref -> parameter_type ) { 1530 1531 case XIT_PS_TYPE_SEPARATOR: 1532 break; 1533 1534 case XIT_PS_TYPE_INTEGER: 1535 tempW = XtNameToWidget( mainW, "IntFo" ); 1536 par_set_ref -> last_valueW = tempW; 1537 1538 XtManageChild( tempW ); 1539 1540 int_value = *((int *) work_ref -> value); 1541 1542 tempW = XtNameToWidget( mainW, "IntFo.IntSc" ); 1543 n = 0; 1544 XtSetArg( args[ n ], XmNvalue, int_value ); n++; 1545 XtSetArg( args[ n ], XmNminimum, par_rec_ref -> min ); n++; 1546 XtSetArg( args[ n ], XmNmaximum, par_rec_ref -> max ); n++; 1547 XtSetValues( tempW, args, n ); 1548 1549 tempW = XtNameToWidget( mainW, "IntFo.IntTx" ); 1550 n = 0; 1551 XtSetArg( args[ n ], XmNmaxLength, par_rec_ref -> max_length ); n++; 1552 XtSetArg( args[ n ], XmNcolumns, par_rec_ref -> max_columns ); n++; 1553 XtSetValues( tempW, args, n ); 1554 1555 sprintf( buffer, "%d", int_value ); 1556 if( strlen( buffer ) < 2 ) 1557 strcat( buffer, " " ); 1558 1559 XmTextSetString( tempW, buffer ); 1560 break; 1561 1562 1563 case XIT_PS_TYPE_YES_NO: 1564 case XIT_PS_TYPE_ON_OFF: 1565 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO ) 1566 tempW = XtNameToWidget( mainW, "YesNoRb" ); 1567 else 1568 tempW = XtNameToWidget( mainW, "OnOffRb" ); 1569 1570 par_set_ref -> last_valueW = tempW; 1571 1572 XtManageChild( tempW ); 1573 1574 if( *((Boolean *) work_ref -> value) ) { 1575 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO ) 1576 tempW = XtNameToWidget( mainW, "YesNoRb.YesTb" ); 1577 else 1578 tempW = XtNameToWidget( mainW, "OnOffRb.OnTb" ); 1579 XmToggleButtonSetState( tempW, True, True ); 1580 1581 } else { 1582 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO ) 1583 tempW = XtNameToWidget( mainW, "YesNoRb.NoTb" ); 1584 else 1585 tempW = XtNameToWidget( mainW, "OnOffRb.OffTb" ); 1586 XmToggleButtonSetState( tempW, True, True ); 1587 } 1588 break; 1589 1590 1591 case XIT_PS_TYPE_YES_NO_FLAG: 1592 case XIT_PS_TYPE_ON_OFF_FLAG: 1593 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO_FLAG ) 1594 tempW = XtNameToWidget( mainW, "YesNoRb" ); 1595 else 1596 tempW = XtNameToWidget( mainW, "OnOffRb" ); 1597 1598 par_set_ref -> last_valueW = tempW; 1599 1600 XtManageChild( tempW ); 1601 1602 flag_value = *((UINT32 *) work_ref -> value); 1603 1604 if( flagIsSet( flag_value, par_rec_ref -> flag_offset ) ) { 1605 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO_FLAG ) 1606 tempW = XtNameToWidget( mainW, "YesNoRb.YesTb" ); 1607 else 1608 tempW = XtNameToWidget( mainW, "OnOffRb.OnTb" ); 1609 XmToggleButtonSetState( tempW, True, True ); 1610 1611 } else { 1612 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_YES_NO_FLAG ) 1613 tempW = XtNameToWidget( mainW, "YesNoRb.NoTb" ); 1614 else 1615 tempW = XtNameToWidget( mainW, "OnOffRb.OffTb" ); 1616 XmToggleButtonSetState( tempW, True, True ); 1617 } 1618 break; 1619 1620 1621 case XIT_PS_TYPE_TEXT_FIELD: 1622 tempW = XtNameToWidget( mainW, "TextTx" ); 1623 par_set_ref -> last_valueW = tempW; 1624 1625 XtManageChild( tempW ); 1626 1627 n = 0; 1628 XtSetArg( args[ n ], XmNmaxLength, par_rec_ref -> max_length ); n++; 1629 XtSetArg( args[ n ], XmNcolumns, par_rec_ref -> max_columns ); n++; 1630 XtSetValues( tempW, args, n ); 1631 1632 strncpy( buffer, ((char *) work_ref -> value), 200 ); 1633 buffer[ 200 ] = '\0'; 1634 if( strlen( buffer ) < 2 ) 1635 strcat( buffer, " " ); 1636 1637 XmTextSetString( tempW, buffer ); 1638 break; 1639 1640 1641 case XIT_PS_TYPE_INTEGER_FIELD: 1642 tempW = XtNameToWidget( mainW, "TextTx" ); 1643 par_set_ref -> last_valueW = tempW; 1644 1645 XtManageChild( tempW ); 1646 1647 n = 0; 1648 XtSetArg( args[ n ], XmNmaxLength, par_rec_ref -> max_length ); n++; 1649 XtSetArg( args[ n ], XmNcolumns, par_rec_ref -> max_columns ); n++; 1650 XtSetValues( tempW, args, n ); 1651 1652 sprintf( buffer, "%d", *((int *) work_ref -> value) ); 1653 if( strlen( buffer ) < 2 ) 1654 strcat( buffer, " " ); 1655 1656 XmTextSetString( tempW, buffer ); 1657 break; 1658 1659 1660 case XIT_PS_TYPE_DATE_FIELD: 1661 tempW = XtNameToWidget( mainW, "TextTx" ); 1662 par_set_ref -> last_valueW = tempW; 1663 1664 XtManageChild( tempW ); 1665 1666 time_value = *((TIM_TIME_REF *) work_ref -> value); 1667 TimFormatDate( time_value, buffer, sizeof( buffer ) ); 1668 1669 n = 0; 1670 XtSetArg( args[ n ], XmNmaxLength, par_rec_ref -> max_length ); n++; 1671 XtSetArg( args[ n ], XmNcolumns, par_rec_ref -> max_columns ); n++; 1672 XtSetValues( tempW, args, n ); 1673 1674 XmTextSetString( tempW, buffer ); 1675 break; 1676 1677 1678 case XIT_PS_TYPE_TIME_FIELD: 1679 tempW = XtNameToWidget( mainW, "TextTx" ); 1680 par_set_ref -> last_valueW = tempW; 1681 1682 XtManageChild( tempW ); 1683 1684 time_value = *((TIM_TIME_REF *) work_ref -> value); 1685 TimFormatTime( time_value, buffer, sizeof( buffer ) ); 1686 1687 n = 0; 1688 XtSetArg( args[ n ], XmNmaxLength, par_rec_ref -> max_length ); n++; 1689 XtSetArg( args[ n ], XmNcolumns, par_rec_ref -> max_columns ); n++; 1690 XtSetValues( tempW, args, n ); 1691 1692 XmTextSetString( tempW, buffer ); 1693 break; 1694 1695 1696 case XIT_PS_TYPE_DURATION_FIELD: 1697 tempW = XtNameToWidget( mainW, "TextTx" ); 1698 par_set_ref -> last_valueW = tempW; 1699 1700 XtManageChild( tempW ); 1701 1702 n = 0; 1703 XtSetArg( args[ n ], XmNmaxLength, par_rec_ref -> max_length ); n++; 1704 XtSetArg( args[ n ], XmNcolumns, par_rec_ref -> max_columns ); n++; 1705 XtSetValues( tempW, args, n ); 1706 1707 int_value = *((int *) work_ref -> value); 1708 sprintf( buffer, "%d:%02d", int_value / 60, int_value % 60 ); 1709 1710 XmTextSetString( tempW, buffer ); 1711 break; 1712 1713 1714 case XIT_PS_TYPE_COLOR_FIELD: 1715 case XIT_PS_TYPE_COLOR_INDEX_FIELD: 1716 case XIT_PS_TYPE_SELECT_FIELD: 1717 case XIT_PS_TYPE_SELECT_INDEX_FIELD: 1718 createFieldMenu( par_rec_ref -> select_values, tag_array, MAX_MENU_TAGS, 1719 &tag_count ); 1720 1721 switch( par_rec_ref -> parameter_type ) { 1722 1723 case XIT_PS_TYPE_COLOR_FIELD: 1724 tempW = XtNameToWidget( mainW, "ColorFs" ); 1725 par_set_ref -> last_valueW = tempW; 1726 1727 pixel_value = *((Pixel *) work_ref -> value); 1728 1729 xitColorSelectSetMenu( tempW, tag_array, tag_count ); 1730 xitColorSelectSetPixel( tempW, pixel_value, False ); 1731 1732 XtManageChild( tempW ); 1733 break; 1734 1735 case XIT_PS_TYPE_COLOR_INDEX_FIELD: 1736 tempW = XtNameToWidget( mainW, "ColorFs" ); 1737 par_set_ref -> last_valueW = tempW; 1738 1739 index_color = *((int *) work_ref -> value); 1740 1741 xitColorSelectSetMenu( tempW, tag_array, tag_count ); 1742 xitColorSelectSetIndex( tempW, index_color, False ); 1743 1744 XtManageChild( tempW ); 1745 break; 1746 1747 case XIT_PS_TYPE_SELECT_FIELD: 1748 tempW = XtNameToWidget( mainW, "SelectFs" ); 1749 par_set_ref -> last_valueW = tempW; 1750 1751 char_ref = ((char *) work_ref -> value); 1752 1753 xitFieldSelectSetMenu( tempW, tag_array, tag_count ); 1754 xitFieldSelectSetCurrent( tempW, char_ref, False ); 1755 1756 xitFieldSelectEditable( tempW, True ); 1757 1758 XtManageChild( tempW ); 1759 break; 1760 1761 case XIT_PS_TYPE_SELECT_INDEX_FIELD: 1762 tempW = XtNameToWidget( mainW, "IndexFs" ); 1763 par_set_ref -> last_valueW = tempW; 1764 1765 int_value = *((int *) work_ref -> value); 1766 1767 xitFieldSelectSetMenu( tempW, tag_array, tag_count ); 1768 xitFieldSelectSetIndex( tempW, int_value, False ); 1769 1770 xitFieldSelectEditable( tempW, False ); 1771 1772 XtManageChild( tempW ); 1773 break; 1774 default: /* clause added RXTN 040597 without having a clue about correctness */ 1775 break; 1776 } 1777 1778 for( index = 0; index < tag_count; index++ ) 1779 SysFree( tag_array[ index ] ); 1780 break; 1781 1782 1783 case XIT_PS_TYPE_HIDDEN_TEXT_FIELD: 1784 tempW = XtNameToWidget( mainW, "HiddenRc" ); 1785 par_set_ref -> last_valueW = tempW; 1786 1787 XtManageChild( tempW ); 1788 1789 /* Length if we want to change. */ 1790 par_set_ref -> change_hidden_max_length = par_rec_ref -> max_length; 1791 par_set_ref -> change_hidden_max_columns = par_rec_ref -> max_columns; 1792 1793 /* Save the hidden string. */ 1794 strcpy( par_set_ref -> hidden_buf, ((char *) work_ref -> value) ); 1795 1796 /* Display the field as a number of --. */ 1797 strcpy( buffer, par_set_ref -> hidden_buf ); 1798 1799 for( index = 0; index < strlen( buffer ); index++ ) 1800 buffer[ index ] = '-'; 1801 1802 tempW = XtNameToWidget( mainW, "HiddenRc.HiddenLa" ); 1803 xitStringSetLabel( tempW, buffer ); 1804 break; 1805 1806 1807 case XIT_PS_TYPE_WORKDAYS_FIELD: 1808 { 1809 int index; 1810 char buffer[ 256 ]; 1811 1812 tempW = XtNameToWidget( mainW, "WorkdaysRc" ); 1813 par_set_ref -> last_valueW = tempW; 1814 1815 XtManageChild( tempW ); 1816 1817 for( index = 0; index < 7; index++ ) { 1818 sprintf( buffer, "WorkdaysRc.Workdays%dBu", index + 1 ); 1819 tempW = XtNameToWidget( mainW, buffer ); 1820 1821 if( *(((Boolean *) work_ref -> value) + index) ) 1822 XmToggleButtonSetState( tempW, True, False ); 1823 else 1824 XmToggleButtonSetState( tempW, False, False ); 1825 } 1826 } 1827 break; 1828 1829 1830 case XIT_PS_TYPE_DATE_FORMAT_FIELD: 1831 { 1832 char date_format[ 50 ]; 1833 1834 tempW = XtNameToWidget( mainW, "DateFormatFo" ); 1835 par_set_ref -> last_valueW = tempW; 1836 1837 XtManageChild( tempW ); 1838 1839 strcpy( date_format, ((char *) work_ref -> value) ); 1840 1841 if( strncmp( date_format, "YMD", 3 ) == 0 ) 1842 tempW = XtNameToWidget( mainW, "DateFormatFo.DateOrderRb.YmdTb" ); 1843 else if( strncmp( date_format, "MDY", 3 ) == 0 ) 1844 tempW = XtNameToWidget( mainW, "DateFormatFo.DateOrderRb.MdyTb" ); 1845 else 1846 tempW = XtNameToWidget( mainW, "DateFormatFo.DateOrderRb.DmyTb" ); 1847 1848 XmToggleButtonSetState( tempW, True, True ); 1849 1850 if( date_format[ 3 ] == '0' ) 1851 strcpy( buffer, "" ); 1852 else { 1853 buffer[ 0 ] = date_format[ 3 ]; 1854 buffer[ 1 ] = '\0'; 1855 } 1856 1857 if( strlen( buffer ) < 2 ) 1858 strcat( buffer, " " ); 1859 1860 tempW = XtNameToWidget( mainW, "DateFormatFo.DateSepRc.SepTx" ); 1861 XmTextSetString( tempW, buffer ); 1862 1863 n = 0; 1864 XtSetArg( args[ n ], XmNmaxLength, 1 ); n++; 1865 XtSetArg( args[ n ], XmNcolumns, 2 ); n++; 1866 XtSetValues( tempW, args, n ); 1867 1868 tempW = XtNameToWidget( mainW, "DateFormatFo.DateParRc.DayZeroTb" ); 1869 if( date_format[ 4 ] == '1' ) 1870 XmToggleButtonSetState( tempW, True, True ); 1871 else 1872 XmToggleButtonSetState( tempW, False, True ); 1873 1874 tempW = XtNameToWidget( mainW, "DateFormatFo.DateParRc.MonthZeroTb" ); 1875 if( date_format[ 5 ] == '1' ) 1876 XmToggleButtonSetState( tempW, True, True ); 1877 else 1878 XmToggleButtonSetState( tempW, False, True ); 1879 1880 tempW = XtNameToWidget( mainW, "DateFormatFo.DateParRc.CenturyTb" ); 1881 if( date_format[ 6 ] == '1' ) 1882 XmToggleButtonSetState( tempW, True, True ); 1883 else 1884 XmToggleButtonSetState( tempW, False, True ); 1885 1886 buffer[ 0 ] = date_format[ 7 ]; 1887 buffer[ 1 ] = '\0'; 1888 1889 int_value = atoi( buffer ); 1890 if( int_value < 0 || int_value > 1 ) 1891 int_value = 1; 1892 1893 tempW = XtNameToWidget( mainW, 1894 "DateFormatFo.Week1stDayRc.Week1stDayFs" ); 1895 xitFieldSelectSetIndex( tempW, int_value, False ); 1896 } 1897 break; 1898 1899 1900 case XIT_PS_TYPE_TIME_FORMAT_FIELD: 1901 { 1902 char time_format[ 50 ]; 1903 1904 tempW = XtNameToWidget( mainW, "TimeFormatFo" ); 1905 par_set_ref -> last_valueW = tempW; 1906 1907 XtManageChild( tempW ); 1908 1909 strcpy( time_format, ((char *) work_ref -> value) ); 1910 1911 if( strncmp( time_format, "12", 2 ) == 0 ) 1912 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeTypeRb.Hour12Tb" ); 1913 else 1914 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeTypeRb.Hour24Tb" ); 1915 1916 XmToggleButtonSetState( tempW, True, True ); 1917 1918 strncpy( buffer, &time_format[ 2 ], 2 ); 1919 buffer[ 2 ] = '\0'; 1920 1921 if( strcmp( buffer, " " ) == 0 ) { 1922 if( strncmp( time_format, "12", 2 ) == 0 ) 1923 strcpy( buffer, "am" ); 1924 else 1925 strcpy( buffer, "" ); 1926 } 1927 1928 tempW = XtNameToWidget( mainW, "TimeFormatFo.Hour12Tx" ); 1929 XmTextSetString( tempW, buffer ); 1930 1931 n = 0; 1932 XtSetArg( args[ n ], XmNmaxLength, 2 ); n++; 1933 XtSetArg( args[ n ], XmNcolumns, 3 ); n++; 1934 XtSetValues( tempW, args, n ); 1935 1936 strncpy( buffer, &time_format[ 4 ], 2 ); 1937 buffer[ 2 ] = '\0'; 1938 1939 if( strcmp( buffer, " " ) == 0 ) { 1940 if( strncmp( time_format, "12", 2 ) == 0 ) 1941 strcpy( buffer, "pm" ); 1942 else 1943 strcpy( buffer, "" ); 1944 } 1945 1946 tempW = XtNameToWidget( mainW, "TimeFormatFo.Hour24Tx" ); 1947 XmTextSetString( tempW, buffer ); 1948 1949 n = 0; 1950 XtSetArg( args[ n ], XmNmaxLength, 2 ); n++; 1951 XtSetArg( args[ n ], XmNcolumns, 3 ); n++; 1952 XtSetValues( tempW, args, n ); 1953 1954 if( time_format[ 6 ] == '0' ) 1955 strcpy( buffer, "" ); 1956 else { 1957 buffer[ 0 ] = time_format[ 6 ]; 1958 buffer[ 1 ] = '\0'; 1959 } 1960 1961 if( strlen( buffer ) < 2 ) 1962 strcat( buffer, " " ); 1963 1964 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeSepRc.SepTx" ); 1965 XmTextSetString( tempW, buffer ); 1966 1967 n = 0; 1968 XtSetArg( args[ n ], XmNmaxLength, 1 ); n++; 1969 XtSetArg( args[ n ], XmNcolumns, 2 ); n++; 1970 XtSetValues( tempW, args, n ); 1971 1972 tempW = XtNameToWidget( mainW, "TimeFormatFo.TimeParRc.HourZeroTb" ); 1973 if( time_format[ 7 ] == '1' ) 1974 XmToggleButtonSetState( tempW, True, True ); 1975 else 1976 XmToggleButtonSetState( tempW, False, True ); 1977 } 1978 break; 1979 1980 } /* switch */ 1981 1982 1983 return; 1984 1985 } /* setParameter */ 1986 1987 1988 /*----------------------------------------------------------------------*/ 1989 1990 static void cancelCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)1991 cancelCB( Widget widget, 1992 PAR_SET_REC_REF par_set_ref, 1993 XtPointer call_data ) 1994 { 1995 1996 /* Code. */ 1997 1998 /* Do we have a user action callback registered? */ 1999 if( par_set_ref -> actionCB != NULL ) 2000 (* par_set_ref -> actionCB)( XIT_PS_REASON_CANCEL, 2001 par_set_ref -> user_data ); 2002 2003 /* Pop-down the window. */ 2004 XtUnmanageChild( par_set_ref -> parSetW ); 2005 2006 2007 return; 2008 2009 } /* cancelCB */ 2010 2011 2012 /*----------------------------------------------------------------------*/ 2013 2014 static void changeHiddenCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2015 changeHiddenCB( Widget widget, 2016 PAR_SET_REC_REF par_set_ref, 2017 XtPointer call_data ) 2018 { 2019 2020 /* Variables. */ 2021 Arg args[ 10 ]; 2022 Cardinal n; 2023 Widget tempW; 2024 2025 2026 /* Code. */ 2027 2028 /* Display the text (not wisible). */ 2029 tempW = XtNameToWidget( par_set_ref -> changeHiddenW, "ChidFdFo.ChidTx" ); 2030 2031 n = 0; 2032 XtSetArg( args[ n ], XmNmaxLength, 2033 par_set_ref -> change_hidden_max_length ); n++; 2034 XtSetArg( args[ n ], XmNcolumns, 2035 par_set_ref -> change_hidden_max_columns ); n++; 2036 XtSetValues( tempW, args, n ); 2037 2038 XmTextSetString( tempW, "" ); 2039 2040 /* Make sure the window is visible. */ 2041 XtManageChild( par_set_ref -> changeHiddenW ); 2042 2043 /* Set focus. */ 2044 tempW = XtNameToWidget( par_set_ref -> changeHiddenW, "ChidFdFo.ChidTx" ); 2045 xitSetFocus( par_set_ref -> changeHiddenW, tempW ); 2046 2047 2048 return; 2049 2050 } /* changeHiddenCB */ 2051 2052 2053 /*----------------------------------------------------------------------*/ 2054 2055 static void changeHiddenCancelCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2056 changeHiddenCancelCB( Widget widget, 2057 PAR_SET_REC_REF par_set_ref, 2058 XtPointer call_data ) 2059 { 2060 2061 /* Code. */ 2062 2063 /* Remove window. */ 2064 XtUnmanageChild( par_set_ref -> changeHiddenW ); 2065 2066 2067 return; 2068 2069 } /* changeHiddenCancelCB */ 2070 2071 2072 /*----------------------------------------------------------------------*/ 2073 2074 static void changeHiddenOkCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2075 changeHiddenOkCB( Widget widget, 2076 PAR_SET_REC_REF par_set_ref, 2077 XtPointer call_data ) 2078 { 2079 2080 /* Variables. */ 2081 int index; 2082 char buffer[ 201 ]; 2083 char *char_ref; 2084 char *end_ref; 2085 char *start_ref; 2086 Widget tempW; 2087 2088 2089 /* Code. */ 2090 2091 /* Fetch hidden text. */ 2092 tempW = XtNameToWidget( par_set_ref -> changeHiddenW, "ChidFdFo.ChidTx" ); 2093 char_ref = xitStringGetText( tempW ); 2094 2095 2096 /* Trim spaces. */ 2097 start_ref = char_ref; 2098 while( isspace( *start_ref ) ) 2099 start_ref++; 2100 2101 end_ref = start_ref + strlen( start_ref ) - 1; 2102 while( end_ref > start_ref && isspace( *end_ref ) ) { 2103 *end_ref = '\0'; 2104 end_ref--; 2105 } 2106 2107 strcpy( par_set_ref -> hidden_buf, start_ref ); 2108 SysFree( char_ref ); 2109 2110 2111 /* Remove window. */ 2112 XtUnmanageChild( par_set_ref -> changeHiddenW ); 2113 2114 2115 /* Set field. */ 2116 tempW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo.HiddenRc" ); 2117 tempW = XtNameToWidget( tempW, "HiddenLa" ); 2118 2119 strcpy( buffer, par_set_ref -> hidden_buf ); 2120 for( index = 0; index < strlen( buffer ); index++ ) 2121 buffer[ index ] = '-'; 2122 2123 xitStringSetLabel( tempW, buffer ); 2124 2125 2126 return; 2127 2128 } /* changeHiddenOkCB */ 2129 2130 2131 /*----------------------------------------------------------------------*/ 2132 2133 static void doDefaultResetCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2134 doDefaultResetCB( Widget widget, 2135 PAR_SET_REC_REF par_set_ref, 2136 XtPointer call_data ) 2137 { 2138 2139 /* Variables. */ 2140 int index; 2141 size_t size; 2142 Widget mainW; 2143 Widget tempW; 2144 2145 2146 /* Code. */ 2147 2148 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 2149 2150 2151 /* New work values. */ 2152 for( index = 0; index < par_set_ref -> rec_no; index++ ) { 2153 2154 size = par_set_ref -> par_rec_ref[ index ].size; 2155 2156 switch( par_set_ref -> do_action ) { 2157 case DO_RESET: 2158 memcpy( par_set_ref -> work[ index ].value, 2159 par_set_ref -> par_rec_ref[ index ].value, 2160 size ); 2161 break; 2162 2163 case DO_DEFAULT: 2164 memcpy( par_set_ref -> work[ index ].value, 2165 par_set_ref -> par_rec_ref[ index ].default_value, 2166 size ); 2167 break; 2168 2169 } /* switch */ 2170 2171 } /* loop */ 2172 2173 2174 /* Select the curerent parameter. */ 2175 tempW = XtNameToWidget( mainW, "ParListLiSW.ParListLi" ); 2176 2177 /* No previous 'history'. */ 2178 if( par_set_ref -> last_valueW != NULL ) { 2179 XtUnmanageChild( par_set_ref -> last_valueW ); 2180 par_set_ref -> last_valueW = NULL; 2181 } 2182 2183 XmListSelectPos( tempW, 1, True ); 2184 2185 2186 return; 2187 2188 } /* doDefaultResetCB */ 2189 2190 2191 /*----------------------------------------------------------------------*/ 2192 2193 static void defaultsCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2194 defaultsCB( Widget widget, 2195 PAR_SET_REC_REF par_set_ref, 2196 XtPointer call_data ) 2197 { 2198 2199 /* Code. */ 2200 2201 par_set_ref -> do_action = DO_DEFAULT; 2202 2203 /* Ask for confirmation. */ 2204 (void ) xitCreateQuestionDialog( 2205 par_set_ref -> parSetW, "QuestionDialog", 2206 " ", 2207 par_set_ref -> msg_confirm_default, 2208 doDefaultResetCB, par_set_ref, 2209 NULL, NULL ); 2210 2211 2212 return; 2213 2214 } /* defaultsCB */ 2215 2216 2217 /*----------------------------------------------------------------------*/ 2218 2219 static void destroyCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2220 destroyCB( Widget widget, 2221 PAR_SET_REC_REF par_set_ref, 2222 XtPointer call_data ) 2223 { 2224 2225 /* Variables. */ 2226 int index; 2227 2228 2229 /* Code. */ 2230 2231 /* Do we have a user action callback registered? */ 2232 if( par_set_ref -> actionCB != NULL ) 2233 (* par_set_ref -> actionCB)( XIT_PS_REASON_DESTROY, 2234 par_set_ref -> user_data ); 2235 2236 2237 /* Working values. */ 2238 for( index = 0; index < MAX_PARAMETERS; index++ ) { 2239 if( par_set_ref -> work[ index ].value != NULL ) 2240 SysFree( par_set_ref -> work[ index ].value ); 2241 } 2242 2243 /* Internal data. */ 2244 if( par_set_ref != NULL ) 2245 SysFree( par_set_ref ); 2246 2247 2248 return; 2249 2250 } /* destroyCB */ 2251 2252 2253 /*----------------------------------------------------------------------*/ 2254 2255 static void intScChangedCB(Widget widget,PAR_SET_REC_REF par_set_ref,XmScaleCallbackStruct * call_data)2256 intScChangedCB( Widget widget, 2257 PAR_SET_REC_REF par_set_ref, 2258 XmScaleCallbackStruct *call_data ) 2259 { 2260 2261 /* Variables. */ 2262 char buffer[ 50 ]; 2263 Widget mainW; 2264 Widget tempW; 2265 2266 2267 /* Code. */ 2268 2269 if( ! par_set_ref -> do_update ) 2270 return; 2271 2272 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 2273 2274 /* Set the value to the text field. */ 2275 tempW = XtNameToWidget( mainW, "IntFo.IntTx" ); 2276 2277 sprintf( buffer, "%d", call_data -> value ); 2278 if( strlen( buffer ) < 2 ) 2279 strcat( buffer, " " ); 2280 2281 par_set_ref -> do_update = False; 2282 XmTextSetString( tempW, buffer ); 2283 par_set_ref -> do_update = True; 2284 2285 2286 return; 2287 2288 } /* intScChangedCB */ 2289 2290 2291 /*----------------------------------------------------------------------*/ 2292 2293 static void intTxChangedCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2294 intTxChangedCB( Widget widget, 2295 PAR_SET_REC_REF par_set_ref, 2296 XtPointer call_data ) 2297 { 2298 2299 /* Variables. */ 2300 int items; 2301 int int_value; 2302 char *char_string; 2303 Widget mainW; 2304 Widget tempW; 2305 XIT_PAR_REC *par_rec_ref; 2306 2307 2308 /* Code. */ 2309 2310 if( ! par_set_ref -> do_update ) 2311 return; 2312 2313 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 2314 par_rec_ref = &par_set_ref -> par_rec_ref[ par_set_ref -> last_value_no ]; 2315 2316 /* Fetch the new value. */ 2317 tempW = XtNameToWidget( mainW, "IntFo.IntTx" ); 2318 2319 char_string = xitStringGetText( tempW ); 2320 items = sscanf( char_string, "%d", &int_value ); 2321 SysFree( char_string ); 2322 2323 if( items != 1 || 2324 int_value < par_rec_ref -> min || 2325 int_value > par_rec_ref -> max ) 2326 return; 2327 2328 2329 /* Set the new value. */ 2330 tempW = XtNameToWidget( mainW, "IntFo.IntSc" ); 2331 2332 par_set_ref -> do_update = False; 2333 XmScaleSetValue( tempW, int_value ); 2334 par_set_ref -> do_update = True; 2335 2336 2337 return; 2338 2339 } /* intTxChangedCB */ 2340 2341 2342 /*----------------------------------------------------------------------*/ 2343 2344 static void okCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2345 okCB( Widget widget, 2346 PAR_SET_REC_REF par_set_ref, 2347 XtPointer call_data ) 2348 { 2349 2350 /* Variables. */ 2351 int index; 2352 UINT32 flag_value; 2353 UINT32 work_flag_value; 2354 size_t size; 2355 Boolean ok; 2356 XIT_PAR_REC *par_rec_ref; 2357 WORK_VALUE_REC *work_ref; 2358 2359 2360 /* Code. */ 2361 2362 /* Save the current value. */ 2363 ok = saveParameter( par_set_ref ); 2364 if( ! ok ) { 2365 xitErMessage( par_set_ref -> parSetW, XIT_ER_ERROR, 2366 "", "", par_set_ref -> msg_invalid_value ); 2367 return; 2368 } 2369 2370 2371 /* Make the work values 'real'. */ 2372 for( index = 0; index < par_set_ref -> rec_no; index++ ) { 2373 2374 par_rec_ref = &par_set_ref -> par_rec_ref[ index ]; 2375 work_ref = &par_set_ref -> work[ index ]; 2376 size = par_rec_ref -> size; 2377 2378 switch( par_rec_ref -> parameter_type ) { 2379 2380 case XIT_PS_TYPE_YES_NO_FLAG: 2381 case XIT_PS_TYPE_ON_OFF_FLAG: 2382 flag_value = *((UINT32 *) par_rec_ref -> value); 2383 work_flag_value = *((UINT32 *) work_ref -> value); 2384 2385 if( flagIsSet( work_flag_value, par_rec_ref -> flag_offset ) ) 2386 flagSet( flag_value, par_rec_ref -> flag_offset ); 2387 else 2388 flagClear( flag_value, par_rec_ref -> flag_offset ); 2389 2390 *((UINT32 *) par_rec_ref -> value) = flag_value; 2391 break; 2392 2393 case XIT_PS_TYPE_SEPARATOR: 2394 break; 2395 2396 default: 2397 memcpy( par_rec_ref -> value, work_ref -> value, size ); 2398 break; 2399 2400 } /* switch */ 2401 2402 } /* loop */ 2403 2404 2405 /* Do we have a user action callback registered? */ 2406 if( par_set_ref -> actionCB != NULL ) 2407 (* par_set_ref -> actionCB)( XIT_PS_REASON_OK, 2408 par_set_ref -> user_data ); 2409 2410 2411 /* Pop-down the window. */ 2412 XtUnmanageChild( par_set_ref -> parSetW ); 2413 2414 2415 return; 2416 2417 } /* okCB */ 2418 2419 2420 /*----------------------------------------------------------------------*/ 2421 2422 static void parListCB(Widget widget,PAR_SET_REC_REF par_set_ref,XmListCallbackStruct * call_data)2423 parListCB( Widget widget, 2424 PAR_SET_REC_REF par_set_ref, 2425 XmListCallbackStruct *call_data ) 2426 { 2427 2428 /* Variables. */ 2429 Boolean ok; 2430 Widget mainW; 2431 Widget tempW; 2432 XIT_PAR_REC *par_rec_ref; 2433 WORK_VALUE_REC *work_ref; 2434 2435 2436 /* Code. */ 2437 2438 mainW = XtNameToWidget( par_set_ref -> parSetW, "ParSetFdFo" ); 2439 par_rec_ref = &par_set_ref -> par_rec_ref[ call_data -> item_position - 1 ]; 2440 work_ref = &par_set_ref -> work[ call_data -> item_position - 1 ]; 2441 2442 /* Separators cannot be selected. */ 2443 if( par_rec_ref -> parameter_type == XIT_PS_TYPE_SEPARATOR ) { 2444 XmListSelectPos( widget, par_set_ref -> last_value_no + 1, False ); 2445 2446 return; 2447 } 2448 2449 /* Save the previous value. */ 2450 ok = saveParameter( par_set_ref ); 2451 if( ! ok ) { 2452 XmListSelectPos( widget, par_set_ref -> last_value_no + 1, False ); 2453 2454 xitErMessage( par_set_ref -> parSetW, XIT_ER_ERROR, 2455 "", "", par_set_ref -> msg_invalid_value ); 2456 return; 2457 } 2458 2459 2460 /* Set the parameter help text. */ 2461 tempW = XtNameToWidget( mainW, "DescTxSW.DescTx" ); 2462 XmTextSetString( tempW, par_rec_ref -> parameter_help ); 2463 2464 2465 /* Hid the current value widget (if any). */ 2466 if( par_set_ref -> last_valueW != NULL ) { 2467 XtUnmanageChild( par_set_ref -> last_valueW ); 2468 par_set_ref -> last_valueW = NULL; 2469 } 2470 2471 2472 /* Set the correct parameter value. */ 2473 setParameter( par_set_ref, par_rec_ref, work_ref ); 2474 2475 2476 /* We need these later. */ 2477 par_set_ref -> last_value_no = call_data -> item_position - 1; 2478 2479 2480 return; 2481 2482 } /* parListCB */ 2483 2484 2485 /*----------------------------------------------------------------------*/ 2486 2487 static void resetCB(Widget widget,PAR_SET_REC_REF par_set_ref,XtPointer call_data)2488 resetCB( Widget widget, 2489 PAR_SET_REC_REF par_set_ref, 2490 XtPointer call_data ) 2491 { 2492 2493 /* Code. */ 2494 2495 par_set_ref -> do_action = DO_RESET; 2496 2497 /* Ask for confirmation. */ 2498 (void ) xitCreateQuestionDialog( 2499 par_set_ref -> parSetW, "QuestionDialog", 2500 " ", 2501 par_set_ref -> msg_confirm_reset, 2502 doDefaultResetCB, par_set_ref, 2503 NULL, NULL ); 2504 2505 2506 return; 2507 2508 } /* resetCB */ 2509