1 /*---------------------------------------------------------------------------- 2 -- 3 -- Module: xtmSchedMain 4 -- 5 -- Project: XDiary 6 -- System: xtm - X Desktop Calendar 7 -- Subsystem: <> 8 -- Function block: <> 9 -- 10 -- Description: 11 -- Schedule tool for an overview of diary appointments and notes. 12 -- 13 -- Filename: xtmSchedMain.c 14 -- 15 -- Authors: Roger Larsson, Ulrika Bornetun 16 -- Creation date: 1992-04-01 17 -- 18 -- 19 -- (C) Copyright Ulrika Bornetun, Roger Larsson (1995) 20 -- All rights reserved 21 -- 22 -- Permission to use, copy, modify, and distribute this software and its 23 -- documentation for any purpose and without fee is hereby granted, 24 -- provided that the above copyright notice appear in all copies. Ulrika 25 -- Bornetun and Roger Larsson make no representations about the usability 26 -- of this software for any purpose. It is provided "as is" without express 27 -- or implied warranty. 28 ----------------------------------------------------------------------------*/ 29 30 /* SCCS module identifier. */ 31 static char SCCSID[] = "@(#) Module: xtmSchedMain.c, Version: 1.1, Date: 95/02/18 15:52:44"; 32 33 34 /*---------------------------------------------------------------------------- 35 -- Include files 36 ----------------------------------------------------------------------------*/ 37 38 #include <pwd.h> 39 #include <stdio.h> 40 #include <stdlib.h> 41 #include <string.h> 42 #include <time.h> 43 44 #include <X11/Intrinsic.h> 45 #include <X11/StringDefs.h> 46 #include <X11/Shell.h> 47 48 #include <Xm/Protocols.h> 49 50 #include <Xm/Xm.h> 51 #include <Xm/ArrowB.h> 52 #include <Xm/BulletinB.h> 53 #include <Xm/CascadeB.h> 54 #include <Xm/Form.h> 55 #include <Xm/LabelP.h> 56 #include <Xm/PanedW.h> 57 #include <Xm/RowColumn.h> 58 #include <Xm/Separator.h> 59 #include <Xm/ScrolledW.h> 60 #include <Xm/Text.h> 61 #include <Xm/ToggleB.h> 62 63 #include "xitRwPixB.h" 64 65 #include "LstLinked.h" 66 #include "Message.h" 67 #include "System.h" 68 #include "TimDate.h" 69 70 #include "msgXdiary.h" 71 #include "xtmGlobal.h" 72 #include "xtmAccBase.h" 73 #include "xtmArchive.h" 74 #include "xtmCpMvEntry.h" 75 #include "xtmCustBase.h" 76 #include "xtmDbFilter.h" 77 #include "xtmDbInclude.h" 78 #include "xtmDbTools.h" 79 #include "xtmDbMisc.h" 80 #include "xtmDelEntry.h" 81 #include "xtmDuplEntry.h" 82 #include "xtmEditEntry.h" 83 #include "xtmFields.h" 84 #include "xtmFormat.h" 85 #include "xtmFreeze.h" 86 #include "xtmHelp.h" 87 #include "xtmIcons.h" 88 #include "xtmMsgSend.h" 89 #include "xtmOpenView.h" 90 #include "xtmPlan.h" 91 #include "xtmRemote.h" 92 #include "xtmSchedAct.h" 93 #include "xtmSchedTool.h" 94 #include "xtmSchedWin.h" 95 #include "xtmSelHidden.h" 96 #include "xtmShowToDo.h" 97 #include "xtmTools.h" 98 #include "xtmUpdate.h" 99 #include "xitError.h" 100 #include "xitFieldSel.h" 101 #include "xitTools.h" 102 #include "XmUbArrLab.h" 103 #include "xtmSchedMain.h" 104 105 #include "xtmSchedPriv.h" 106 107 108 /*---------------------------------------------------------------------------- 109 -- Macro definitions 110 ----------------------------------------------------------------------------*/ 111 112 /* Day views in the cache? */ 113 #define MAX_CACHE_ENTRIES 3 114 115 /* Local widgets in the database select window. */ 116 #define appLa dataLocalW[ 0 ] 117 #define dateInfoLa dataLocalW[ 1 ] 118 #define dateLa dataLocalW[ 2 ] 119 #define dateRc dataLocalW[ 3 ] 120 #define dayDispBb dataLocalW[ 4 ] 121 #define dayDispSw dataLocalW[ 5 ] 122 #define entryBb dataLocalW[ 6 ] 123 #define entryBottomSp dataLocalW[ 7 ] 124 #define entrySw dataLocalW[ 8 ] 125 #define fromTb dataLocalW[ 9 ] 126 #define makeAppPb dataLocalW[ 10 ] 127 #define makeNotePb dataLocalW[ 11 ] 128 #define menuBr dataLocalW[ 12 ] 129 #define navDayAl dataLocalW[ 13 ] 130 #define navMonthAl dataLocalW[ 14 ] 131 #define navFo dataLocalW[ 15 ] 132 #define navWeekAl dataLocalW[ 16 ] 133 #define navYearAl dataLocalW[ 17 ] 134 #define noteBb dataLocalW[ 18 ] 135 #define noteBottomSp dataLocalW[ 19 ] 136 #define noteSw dataLocalW[ 20 ] 137 #define pane1Fo dataLocalW[ 21 ] 138 #define pane2Fo dataLocalW[ 22 ] 139 #define schedPa dataLocalW[ 23 ] 140 #define timeDispBb dataLocalW[ 24 ] 141 #define timeDispLa dataLocalW[ 25 ] 142 #define timeDispSw dataLocalW[ 26 ] 143 #define trackLa dataLocalW[ 27 ] 144 #define trackPx dataLocalW[ 28 ] 145 #define zoomFs dataLocalW[ 29 ] 146 147 148 /*---------------------------------------------------------------------------- 149 -- Type declarations 150 ----------------------------------------------------------------------------*/ 151 152 153 /*---------------------------------------------------------------------------- 154 -- Global definitions 155 ----------------------------------------------------------------------------*/ 156 157 /* Name of module. */ 158 static char *module_name = "xtmSchedMain"; 159 160 /* IDs for the help windows. */ 161 static char *day_view_window_id = "DayView"; 162 163 /* Trace double clicks on entries. */ 164 static Time time_last = 0; 165 166 /* Cache entries. */ 167 static Boolean init_cache = True; 168 static SCHED_REC_REF cache_entries[ MAX_CACHE_ENTRIES ]; 169 170 /* Last active day view window. */ 171 static SCHED_REC_REF last_active_sched_ref = NULL; 172 173 /* Tick pixmaps to use. */ 174 static Boolean init_tick_pixmap = True; 175 static Pixmap tick_pixmap[ 7 ]; 176 177 178 /*---------------------------------------------------------------------------- 179 -- Function prototypes 180 ----------------------------------------------------------------------------*/ 181 182 static void 183 applyCB( Widget widget, 184 SCHED_REC_REF sched_ref, 185 XtPointer call_data ); 186 187 static void 188 closeCB( Widget widget, 189 SCHED_REC_REF sched_ref, 190 XtPointer call_data ); 191 192 static void 193 closeReallyCB( Widget widget, 194 SCHED_REC_REF sched_ref, 195 XtPointer call_data ); 196 197 static Widget 198 createScheduleWindow( Widget parent, 199 SCHED_REC_REF sched_ref ); 200 201 static void 202 ctrlMenuCB( Widget widget, 203 SCHED_REC_REF sched_ref, 204 XmRowColumnCallbackStruct *call_data ); 205 206 static void 207 destroyCB( Widget widget, 208 SCHED_REC_REF sched_ref, 209 XtPointer call_data ); 210 211 static void 212 displayEntryInfo( SCHED_REC_REF sched_ref ); 213 214 static void 215 editMenuCB( Widget widget, 216 SCHED_REC_REF sched_ref, 217 XmRowColumnCallbackStruct *call_data ); 218 219 static void 220 fileMenuCB( Widget widget, 221 SCHED_REC_REF sched_ref, 222 XmRowColumnCallbackStruct *call_data ); 223 224 static void 225 filterApplyCB( XTM_FI_REASON reason, 226 XTM_DM_FILTER_REC *filter_ref, 227 void *user_data ); 228 229 static void 230 gotFocusCB( Widget widget, 231 SCHED_REC_REF sched_ref, 232 XmAnyCallbackStruct *call_data ); 233 234 static void 235 includeDbApplyCB( XTM_DI_REASON reason, 236 XTM_CD_INCL_CALS_REF new_db_incl_ref, 237 void *user_data ); 238 239 static void 240 infoCB( Widget widget, 241 SCHED_REC_REF sched_ref, 242 XmRowColumnCallbackStruct *call_data ); 243 244 static void 245 leaveHookCB( Widget widget, 246 XEvent *event, 247 char *leave_args[], 248 Cardinal *num_args ); 249 250 static void 251 makeAppointmentCB( Widget widget, 252 SCHED_REC_REF sched_ref, 253 XmAnyCallbackStruct *call_data ); 254 255 static void 256 makeNoteCB( Widget widget, 257 SCHED_REC_REF sched_ref, 258 XmAnyCallbackStruct *call_data ); 259 260 static void 261 navigateCB( Widget widget, 262 SCHED_REC_REF sched_ref, 263 XmUbArrowLabelCallbackStruct *call_data ); 264 265 static void 266 newViewApplyCB( XTM_OV_REASON reason, 267 XTM_CD_CAL_INFO *db_info_ref, 268 void *user_data ); 269 270 static void 271 optionsMenuCB( Widget widget, 272 SCHED_REC_REF sched_ref, 273 XmRowColumnCallbackStruct *call_data ); 274 275 static void 276 printerActionCB( XTM_PR_REASON reason, 277 void *user_data ); 278 279 static void 280 selHideApplyCB( XTM_SH_REASON reason, 281 UINT32 entry_id, 282 char *calendar, 283 TIM_TIME_REF as_date, 284 TIM_TIME_REF as_time, 285 void *user_data ); 286 287 static void 288 summaryActionCB( XTM_SD_REASON reason, 289 void *user_data ); 290 291 static void 292 timeActionHookCB( Widget widget, 293 SCHED_REC_REF sched_ref, 294 XEvent *event ); 295 296 static void 297 updateCB( UINT32 flags, 298 void *user_data, 299 void *update_user_data ); 300 301 static void 302 zoomCB( Widget widget, 303 SCHED_REC_REF sched_ref, 304 XtPointer call_data ); 305 306 307 308 /*---------------------------------------------------------------------------- 309 -- Functions 310 ----------------------------------------------------------------------------*/ 311 312 XTM_SM_HANDLE xtmSmInitialize(XTM_GL_BASE_DATA_REF appl_data_ref,Widget toplevel,char * db_name,XTM_SM_INIT_REF init_ref,XTM_SM_ACTION_CB actionCB,void * user_data)313 xtmSmInitialize( XTM_GL_BASE_DATA_REF appl_data_ref, 314 Widget toplevel, 315 char *db_name, 316 XTM_SM_INIT_REF init_ref, 317 XTM_SM_ACTION_CB actionCB, 318 void *user_data ) 319 { 320 321 /* Variables. */ 322 Boolean ok; 323 int index; 324 int length; 325 SCHED_REC_REF sched_ref; 326 TIM_TIME_REF now; 327 XTM_CD_CAL_INFO db_info; 328 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 329 330 static XtActionsRec leaveActions[] = { 331 { "LeaveHook", leaveHookCB } 332 }; 333 334 335 /* Code. */ 336 337 custom_data_ref = appl_data_ref -> custom_data; 338 339 now = TimLocalTime( TimMakeTimeNow() ); 340 now = TimMakeTime( TimIndexOfYear( now ), 341 TimIndexOfMonth( now ), 342 TimIndexOfDay( now ), 343 0, 0, 0 ); 344 345 346 /* Fetch database information. */ 347 ok = xtmCdFetchNamedDb( custom_data_ref -> cal_db_handle, 348 db_name, &db_info, NULL ); 349 if( ! ok ) 350 return( False ); 351 352 353 /* Minium permissions are read. */ 354 if( flagIsClear( db_info.operations, XTM_DB_FLAG_MODE_READ ) ) 355 return( NULL ); 356 357 358 /* Initialize the cache? */ 359 if( init_cache ) { 360 for( index = 0; index < MAX_CACHE_ENTRIES; index++ ) 361 cache_entries[ index ] = NULL; 362 363 init_cache = False; 364 } 365 366 367 /* Anything in the cache? */ 368 sched_ref = NULL; 369 370 for( index = 0; index < MAX_CACHE_ENTRIES; index++ ) { 371 if( cache_entries[ index ] != NULL ) { 372 sched_ref = cache_entries[ index ]; 373 cache_entries[ index ] = NULL; 374 375 break; 376 } 377 } 378 379 /* Create the schedule record? */ 380 if( sched_ref == NULL ) { 381 382 sched_ref = SysNew( SCHED_REC ); 383 if( sched_ref == NULL ) 384 return( NULL ); 385 386 sched_ref -> scheduleW = NULL; 387 sched_ref -> update_id = 0; 388 sched_ref -> counter = 1; 389 sched_ref -> selected_widget = NULL; 390 sched_ref -> animate_ref = NULL; 391 392 } /* if */ 393 394 sched_ref -> appl_data_ref = appl_data_ref; 395 sched_ref -> editor_handle = NULL; 396 sched_ref -> filter_handle = NULL; 397 sched_ref -> include_handle = NULL; 398 sched_ref -> nav_cal_handle = NULL; 399 sched_ref -> open_handle = NULL; 400 sched_ref -> planner_handle = NULL; 401 sched_ref -> pr_handle = NULL; 402 sched_ref -> remote_handle = NULL; 403 sched_ref -> sel_hide_handle = NULL; 404 sched_ref -> show_handle = NULL; 405 sched_ref -> force_update = False; 406 sched_ref -> schedule_start = now; 407 sched_ref -> day_width = (Dimension) custom_data_ref -> def_day_width; 408 sched_ref -> actionCB = actionCB; 409 sched_ref -> user_data = user_data; 410 411 sched_ref -> old_entry_delta = 0; 412 sched_ref -> old_schedule_start = 0; 413 sched_ref -> old_schedule_stop = 0; 414 sched_ref -> old_entry_start = 0; 415 sched_ref -> old_entry_stop = 0; 416 417 sched_ref -> filter_rec.flags = XTM_DM_FLAG_ALL; 418 sched_ref -> filter_rec.text_string[ 0 ] = '\0'; 419 sched_ref -> filter_rec.tag_string[ 0 ] = '\0'; 420 421 length = strlen( custom_data_ref -> entry_tags_filter ); 422 423 if( length > 0 && length < XTM_DM_MAX_TAG_SEARCH ) { 424 strcpy( sched_ref -> filter_rec.tag_string, 425 custom_data_ref -> entry_tags_filter ); 426 flagSet( sched_ref -> filter_rec.flags, XTM_DM_FLAG_SEARCH_TAG ); 427 } 428 429 sched_ref -> show_no_days = custom_data_ref -> day_view_days; 430 if( sched_ref -> show_no_days < 1 || sched_ref -> show_no_days > 31 ) 431 sched_ref -> show_no_days = 2; 432 433 /* We have no default day width :-(. */ 434 if( sched_ref -> day_width == 0 ) 435 sched_ref -> day_width = 130; 436 437 438 /* Default values? */ 439 if( init_ref == NULL ) { 440 sched_ref -> entry_start = TimMakeTime( 1970, 1, 1, 441 custom_data_ref -> start_hour, 442 0, 0 ); 443 sched_ref -> entry_stop = TimMakeTime( 1970, 1, 1, 444 custom_data_ref -> stop_hour, 445 0, 0 ); 446 447 sched_ref -> entry_delta = custom_data_ref -> default_entry_delta; 448 sched_ref -> flags = (XTM_SM_USE_GRID | XTM_SM_ENTRY_HANDLES); 449 450 if( custom_data_ref -> confirm_actions ) 451 flagSet( sched_ref -> flags, XTM_SM_CONFIRM ); 452 if( custom_data_ref -> list_layout ) 453 flagSet( sched_ref -> flags, XTM_SM_LIST_LAYOUT ); 454 if( custom_data_ref -> display_nav_cal ) 455 flagSet( sched_ref -> flags, XTM_SM_AUTO_NAV_CAL ); 456 if( custom_data_ref -> display_entry_flags ) 457 flagSet( sched_ref -> flags, XTM_SM_ENTRY_FLAGS ); 458 if( custom_data_ref -> read_only_mode ) 459 flagSet( sched_ref -> flags, XTM_SM_READ_ONLY ); 460 if( custom_data_ref -> true_color_included ) 461 flagSet( sched_ref -> flags, XTM_SM_TRUE_COLOR_INC ); 462 463 } else { 464 sched_ref -> entry_start = init_ref -> entry_start; 465 sched_ref -> entry_stop = init_ref -> entry_stop; 466 sched_ref -> entry_delta = init_ref -> entry_delta; 467 sched_ref -> flags = init_ref -> default_flags; 468 469 } /* if */ 470 471 472 /* Create a shadow calendar database. */ 473 ok = xtmCdCreateShadowEntry( custom_data_ref -> cal_db_handle, 474 db_name, sched_ref -> db_name ); 475 if( ! ok ) { 476 SysFree( sched_ref ); 477 478 return( NULL ); 479 } 480 481 482 /* Data for our animation. */ 483 if( sched_ref -> animate_ref == NULL ) { 484 sched_ref -> animate_ref = SysNew( ANIMATE_REC ); 485 486 if( sched_ref -> animate_ref == NULL ) { 487 SysFree( sched_ref ); 488 return( NULL ); 489 } 490 491 sched_ref -> animate_ref -> aniEntryW = NULL; 492 sched_ref -> animate_ref -> aniNoteW = NULL; 493 sched_ref -> animate_ref -> aniTimeW = NULL; 494 } 495 496 sched_ref -> animate_ref -> animate_on = False; 497 498 499 /* Create the schedule window and entry cache? */ 500 if( sched_ref -> scheduleW == NULL ) { 501 502 /* Entry cache. */ 503 sched_ref -> entry_cache_ref = SysNew( ENTRY_CACHE ); 504 505 sched_ref -> entry_cache_ref -> max_used = 500; 506 sched_ref -> entry_cache_ref -> used = 507 (ENTRY_INFO_REF *) SysMalloc( sizeof( ENTRY_INFO_REF ) * 500 ); 508 509 for( index = 0; index < 500; index++ ) 510 sched_ref -> entry_cache_ref -> used[ index ] = NULL; 511 512 /* Schedule window. */ 513 sched_ref -> scheduleW = createScheduleWindow( toplevel, sched_ref ); 514 515 if( sched_ref -> scheduleW == NULL ) { 516 xtmCdFreeShadowEntry( custom_data_ref -> cal_db_handle, 517 sched_ref -> db_name ); 518 519 SysFree( sched_ref -> animate_ref ); 520 SysFree( sched_ref ); 521 522 return( NULL ); 523 } 524 525 /* Initialize the tick pixmaps? */ 526 if( init_tick_pixmap ) { 527 Widget tempW; 528 529 tempW = XtNameToWidget( sched_ref -> scheduleW, 530 "SchedTlBase.SchedTlFo" ); 531 532 tick_pixmap[ 0 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE, 533 False ); 534 tick_pixmap[ 1 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE1, 535 False ); 536 tick_pixmap[ 2 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE2, 537 False ); 538 tick_pixmap[ 3 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE3, 539 False ); 540 tick_pixmap[ 4 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE4, 541 False ); 542 tick_pixmap[ 5 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE5, 543 False ); 544 tick_pixmap[ 6 ] = xtmIcFetchSimplePixmap( tempW, XTM_IC_ICON_ANI_MOVE6, 545 False ); 546 init_tick_pixmap = False; 547 } 548 549 /* Animation pixmaps. */ 550 for( index = 0; index < 7; index++ ) 551 sched_ref -> tick_pixmap[ index ] = tick_pixmap[ index ]; 552 553 sched_ref -> tick_pixmap_index = 0; 554 xtmStClearEntryTime( sched_ref ); 555 556 /* We will need this for the animation stuff. */ 557 XtAppAddActions( XtWidgetToApplicationContext( toplevel ), 558 leaveActions, XtNumber( leaveActions ) ); 559 560 } /* if */ 561 562 563 return( sched_ref ); 564 565 } /* xtmSmInitialize */ 566 567 568 /*----------------------------------------------------------------------*/ 569 570 void xtmSmEmptyCache()571 xtmSmEmptyCache() 572 { 573 574 /* Variables. */ 575 int index; 576 577 578 /* Code. */ 579 580 if( ! init_cache ) 581 return; 582 583 for( index = 0; index < MAX_CACHE_ENTRIES; index++ ) { 584 if( cache_entries[ index ] != NULL ) 585 XtDestroyWidget( cache_entries[ index ] -> scheduleW ); 586 587 cache_entries[ index ] = NULL; 588 } 589 590 591 return; 592 593 } /* xtmSmEmptyCache */ 594 595 596 /*----------------------------------------------------------------------*/ 597 598 void xtmSmDestroy(XTM_SM_HANDLE sched_handle)599 xtmSmDestroy( XTM_SM_HANDLE sched_handle ) 600 { 601 602 /* Variables. */ 603 SCHED_REC_REF sched_ref; 604 605 606 /* Code. */ 607 608 if( sched_handle == NULL ) 609 return; 610 611 612 /* Our private data. */ 613 sched_ref = (SCHED_REC_REF) sched_handle; 614 615 /* Destroy the schedule widget. */ 616 if( sched_ref -> scheduleW != NULL ) 617 closeReallyCB( NULL, sched_ref, NULL ); 618 619 620 return; 621 622 } /* xtmSmDestroy */ 623 624 625 /*----------------------------------------------------------------------*/ 626 627 void xtmSmSetFlags(XTM_SM_HANDLE sched_handle,UINT32 flags)628 xtmSmSetFlags( XTM_SM_HANDLE sched_handle, 629 UINT32 flags ) 630 { 631 632 /* Variables. */ 633 SCHED_REC_REF sched_ref; 634 635 636 /* Code. */ 637 638 if( sched_handle == NULL ) 639 return; 640 641 642 /* Our private data. */ 643 sched_ref = (SCHED_REC_REF) sched_handle; 644 645 flagSet( sched_ref -> flags, flags ); 646 647 648 return; 649 650 } /* xtmSmSetFlags */ 651 652 653 /*----------------------------------------------------------------------*/ 654 655 void xtmSmViewSchedule(XTM_SM_HANDLE sched_handle,TIM_TIME_REF start_date,Boolean iconic)656 xtmSmViewSchedule( XTM_SM_HANDLE sched_handle, 657 TIM_TIME_REF start_date, 658 Boolean iconic ) 659 { 660 661 /* Variables. */ 662 Arg args[ 10 ]; 663 Cardinal n; 664 Widget tempW; 665 SCHED_REC_REF sched_ref; 666 667 668 /* Code. */ 669 670 if( sched_handle == NULL ) 671 return; 672 673 674 /* Our private data. */ 675 sched_ref = (SCHED_REC_REF) sched_handle; 676 677 if( start_date != 0 ) 678 sched_ref -> schedule_start = start_date; 679 680 681 /* Start the day view on a specific day? */ 682 xtmStStartOnDay( sched_ref, &sched_ref -> schedule_start ); 683 684 685 /* Set the start and stop dates and display the schedule. */ 686 xtmSwSetScheduleDates( sched_ref, sched_ref -> scheduleW, False ); 687 688 xtmSwSetSchedule( sched_ref, sched_ref -> scheduleW ); 689 690 691 /* Start as icon? */ 692 n = 0; 693 if( iconic ) { 694 XtSetArg( args[ n ], XmNinitialState, IconicState ); n++; 695 } else { 696 XtSetArg( args[ n ], XmNinitialState, NormalState ); n++; 697 } 698 XtSetValues( sched_ref -> scheduleW, args, n ); 699 700 701 /* Make sure the schedule window is visable. */ 702 XtPopup( sched_ref -> scheduleW, XtGrabNone ); 703 704 705 if( ! iconic ) { 706 XRaiseWindow( XtDisplay( sched_ref -> scheduleW ), 707 XtWindow( sched_ref -> scheduleW ) ); 708 709 XtMapWidget( sched_ref -> scheduleW ); 710 } 711 712 /* Don't let our children spoil our size. */ 713 n = 0; 714 XtSetArg( args[ n ], XmNallowShellResize, False ); n++; 715 XtSetValues( sched_ref -> scheduleW, args, n ); 716 717 718 /* Register for updates? */ 719 if( sched_ref -> update_id == 0 ) 720 sched_ref -> update_id = xtmUpRegister( 721 (XTM_UP_MINUTE_TICK | XTM_UP_SCHEDULE), 722 updateCB, (void *) sched_ref ); 723 724 725 /* Keep track of when we are active. */ 726 #ifndef XD_HAS_FOCUS_BUG 727 tempW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase" ); 728 XtAddCallback( tempW, XmNfocusCallback, 729 (XtCallbackProc) gotFocusCB, (XtPointer) sched_ref ); 730 #endif 731 732 gotFocusCB( NULL, sched_ref, NULL ); 733 734 735 return; 736 737 } /* xtmSmViewSchedule */ 738 739 740 /*----------------------------------------------------------------------*/ 741 742 Boolean xtmSmViewLastUsed(TIM_TIME_REF start_date)743 xtmSmViewLastUsed( TIM_TIME_REF start_date ) 744 { 745 746 /* Variables. */ 747 SCHED_REC_REF sched_ref; 748 749 750 /* Code. */ 751 752 /* Any 'last used day' view? */ 753 if( last_active_sched_ref == NULL ) 754 return( False ); 755 756 sched_ref = last_active_sched_ref; 757 758 if( start_date != 0 ) 759 sched_ref -> schedule_start = start_date; 760 761 762 /* Start the day view on a specific day? */ 763 xtmStStartOnDay( sched_ref, &sched_ref -> schedule_start ); 764 765 /* Set the start and stop dates and display the schedule. */ 766 xtmSwSetScheduleDates( sched_ref, sched_ref -> scheduleW, False ); 767 768 xtmSwSetSchedule( sched_ref, sched_ref -> scheduleW ); 769 770 771 /* The window should be 'on top'. */ 772 XRaiseWindow( XtDisplay( sched_ref -> scheduleW ), 773 XtWindow( sched_ref -> scheduleW ) ); 774 775 XtMapWidget( sched_ref -> scheduleW ); 776 777 778 return( True ); 779 780 } /* xtmSmViewLastUsed */ 781 782 783 /*----------------------------------------------------------------------*/ 784 785 static Widget createScheduleWindow(Widget parent,SCHED_REC_REF sched_ref)786 createScheduleWindow( Widget parent, 787 SCHED_REC_REF sched_ref ) 788 { 789 790 /* Variables. */ 791 int index; 792 char buffer[ 100 ]; 793 Arg args[ 10 ]; 794 Cardinal n; 795 Dimension height; 796 Dimension width; 797 Dimension sb_height; 798 Dimension time_width; 799 Widget dataLocalW[ 30 ]; 800 Widget menuCasc[ 5 ]; 801 Widget menuCtrlBu[ 12 ]; 802 Widget menuEditBu[ 12 ]; 803 Widget menuFileBu[ 8 ]; 804 Widget menuHelpBu[ 7 ]; 805 Widget menuOptionsBu[ 6 ]; 806 Widget pulldownMenu[ 5 ]; 807 Widget schedTl; 808 Widget timeIndicatorAr; 809 Widget tempW; 810 Widget toplevel; 811 Widget workFo; 812 XmString xstr; 813 814 static char *zoom_times = "0:10 0:15 0:30 0:45 1:00 1:30 2:00 4:00 6:00"; 815 816 static char *pull_downs[] = { 817 "pdown1", "pdown2", "pdown3", "pdown4", "pdown5" }; 818 819 static XIT_PUSH_STRUCT button_def[] = { 820 { "MakeAppPb", "", "", True, NULL }, 821 { "MakeNotePb", "", "", True, NULL } 822 }; 823 824 static XIT_CASCADE_STRUCT menupane[] = { 825 { "", "", "FilePane" }, 826 { "", "", "EditPane" }, 827 { "", "", "ControlPane" }, 828 { "", "", "OptionsPane" }, 829 { "", "", "HelpPane" }, 830 }; 831 832 static XIT_MENU_BUTTON_STRUCT file_casc[] = { 833 { "", "", NULL, "NewViewBu", True, False, False }, 834 { "", "", NULL, "OpenSameBu", True, False, False }, 835 { "", "", NULL, "PrintBu", True, False, False }, 836 { XIT_SEP, " ", NULL, "", False, False, False }, 837 { "", "", NULL, "UploadBu", True, False, False }, 838 { "", "", NULL, "DownloadBu", True, False, False }, 839 { XIT_SEP, " ", NULL, "", False, False, False }, 840 { "", "", NULL, "CloseBu", True, False, False }, 841 }; 842 843 static XIT_MENU_BUTTON_STRUCT edit_casc[] = { 844 { "", "", NULL, "EditBu", True, False, False }, 845 { "", "", NULL, "DeleteBu", True, False, False }, 846 { "", "", NULL, "MoveBu", True, False, False }, 847 { "", "", NULL, "CopyBu", True, False, False }, 848 { "", "", NULL, "DuplBu", True, False, False }, 849 { "", "", NULL, "ArchBu", True, False, False }, 850 { "", "", NULL, "FreezeBu", True, False, False }, 851 { "", "", NULL, "InfoBu", True, False, False }, 852 { XIT_SEP, " ", NULL, "", False, False, False }, 853 { "", "", NULL, "CopyBufBu", True, False, False }, 854 { "", "", NULL, "CutBufBu", True, False, False }, 855 { "", "", NULL, "PasteBufBu", True, False, False }, 856 }; 857 858 static XIT_MENU_BUTTON_STRUCT ctrl_casc[] = { 859 { "", "", NULL, "ConfirmBu", True, True, False }, 860 { "", "", NULL, "HandleBu", True, True, False }, 861 { "", "", NULL, "ListLayBu", True, True, False }, 862 { "", "", NULL, "UseGridBu", True, True, False }, 863 { "", "", NULL, "EntryFlagsBu", True, True, False }, 864 { "", "", NULL, "TrueColorIncBu", True, True, False }, 865 { XIT_SEP, " ", NULL, "", False, False, False }, 866 { "", "", NULL, "DispDaysBu", True, False, False }, 867 { "", "", NULL, "DayWidthBu", True, False, False }, 868 { "", "", NULL, "FilterBu", True, False, False }, 869 { "", "", NULL, "IncludeBu", True, False, False }, 870 { "", "", NULL, "SelHideBu", True, False, False }, 871 }; 872 873 static XIT_MENU_BUTTON_STRUCT opt_casc[] = { 874 { "", "", NULL, "ApEditBu", True, False, False }, 875 { "", "", NULL, "SummaryBu", True, False, False }, 876 { "", "", NULL, "SendMsgBu", True, False, False }, 877 { "", "", NULL, "PlannerBu", True, False, False }, 878 { XIT_SEP, " ", NULL, "", False, False, False }, 879 { "", "", NULL, "RedisplayBu", True, False, False }, 880 }; 881 882 static XIT_MENU_BUTTON_STRUCT help_casc[] = { 883 { "", "", NULL, "ContextBu", True, False, False }, 884 { "", "", NULL, "WindowsBu", True, False, False }, 885 { "", "", NULL, "KeysBu", True, False, False }, 886 { "", "", NULL, "IndexBu", True, False, False }, 887 { "", "", NULL, "HelpBu", True, False, False }, 888 { "", "", NULL, "VersionBu", True, False, False }, 889 { "", "", NULL, "AboutBu", True, False, False }, 890 }; 891 892 static XIT_ACTION_AREA_ITEM action_buttons[] = { 893 { "", applyCB, NULL }, 894 { NULL, NULL, NULL }, 895 { NULL, NULL, NULL }, 896 { NULL, NULL, NULL }, 897 { "", closeCB, NULL }, 898 }; 899 900 static XIT_ARROW_STRUCT time_ind_def[] = { 901 { "TimeIndicatorAr", False, XmARROW_RIGHT, NULL }, 902 }; 903 904 905 /* Code. */ 906 907 /* Initialize the menu and label items. */ 908 action_buttons[ 0 ].label = msgGetText( MXDI_APPLY_BUTTON ); 909 action_buttons[ 0 ].data = sched_ref; 910 action_buttons[ 4 ].label = msgGetText( MXDI_CLOSE_BUTTON ); 911 action_buttons[ 4 ].data = sched_ref; 912 913 menupane[ 0 ].title = msgGetText( MXDI_FILE_MENU ); 914 menupane[ 0 ].mnemonic = msgGetText( MXDI_FILE_MENU_ACC ); 915 menupane[ 1 ].title = msgGetText( MXDI_EDIT_MENU ); 916 menupane[ 1 ].mnemonic = msgGetText( MXDI_EDIT_MENU_ACC ); 917 menupane[ 2 ].title = msgGetText( MXDI_CTRL_MENU ); 918 menupane[ 2 ].mnemonic = msgGetText( MXDI_CTRL_MENU_ACC ); 919 menupane[ 3 ].title = msgGetText( MXDI_OPT_MENU ); 920 menupane[ 3 ].mnemonic = msgGetText( MXDI_OPT_MENU_ACC ); 921 menupane[ 4 ].title = msgGetText( MXDI_HELP_MENU ); 922 menupane[ 4 ].mnemonic = msgGetText( MXDI_HELP_MENU_ACC ); 923 924 file_casc[ 0 ].title = msgGetText( MXDI_OPEN_SAME_MENU ); 925 file_casc[ 0 ].mnemonic = msgGetText( MXDI_OPEN_SAME_MENU_ACC ); 926 file_casc[ 1 ].title = msgGetText( MXDI_NEW_VIEW_MENU ); 927 file_casc[ 1 ].mnemonic = msgGetText( MXDI_NEW_VIEW_MENU_ACC ); 928 file_casc[ 2 ].title = msgGetText( MXDI_PRINT_MENU ); 929 file_casc[ 2 ].mnemonic = msgGetText( MXDI_PRINT_MENU_ACC ); 930 file_casc[ 4 ].title = msgGetText( MXDI_UPLOAD_MENU ); 931 file_casc[ 4 ].mnemonic = msgGetText( MXDI_UPLOAD_MENU_ACC ); 932 file_casc[ 5 ].title = msgGetText( MXDI_DOWNLOAD_MENU ); 933 file_casc[ 5 ].mnemonic = msgGetText( MXDI_DOWNLOAD_MENU_ACC ); 934 file_casc[ 7 ].title = msgGetText( MXDI_CLOSE_MENU ); 935 file_casc[ 7 ].mnemonic = msgGetText( MXDI_CLOSE_MENU_ACC ); 936 937 if( flagIsSet( sched_ref -> flags, XTM_SM_READ_ONLY ) ) { 938 edit_casc[ 0 ].title = msgGetText( MXDI_SHOW_MENU ); 939 edit_casc[ 0 ].mnemonic = msgGetText( MXDI_SHOW_MENU_ACC ); 940 } else { 941 edit_casc[ 0 ].title = msgGetText( MXDI_EDIT_MENU ); 942 edit_casc[ 0 ].mnemonic = msgGetText( MXDI_EDIT_MENU_ACC ); 943 } 944 945 edit_casc[ 1 ].title = msgGetText( MXDI_DELETE_MENU ); 946 edit_casc[ 1 ].mnemonic = msgGetText( MXDI_DELETE_MENU_ACC ); 947 edit_casc[ 2 ].title = msgGetText( MXDI_MOVE_MENU ); 948 edit_casc[ 2 ].mnemonic = msgGetText( MXDI_MOVE_MENU_ACC ); 949 edit_casc[ 3 ].title = msgGetText( MXDI_COPY_MENU ); 950 edit_casc[ 3 ].mnemonic = msgGetText( MXDI_COPY_MENU_ACC ); 951 edit_casc[ 4 ].title = msgGetText( MXDI_DUPL_MENU ); 952 edit_casc[ 4 ].mnemonic = msgGetText( MXDI_DUPL_MENU_ACC ); 953 edit_casc[ 5 ].title = msgGetText( MXDI_ARCH_MENU ); 954 edit_casc[ 5 ].mnemonic = msgGetText( MXDI_ARCH_MENU_ACC ); 955 edit_casc[ 6 ].title = msgGetText( MXDI_FREEZE_MENU ); 956 edit_casc[ 6 ].mnemonic = msgGetText( MXDI_FREEZE_MENU_ACC ); 957 edit_casc[ 7 ].title = msgGetText( MXDI_ENTRY_INFO_MENU ); 958 edit_casc[ 7 ].mnemonic = msgGetText( MXDI_ENTRY_INFO_MENU_ACC ); 959 edit_casc[ 9 ].title = msgGetText( MXDI_COPY_BUF_MENU ); 960 edit_casc[ 9 ].mnemonic = msgGetText( MXDI_COPY_BUF_MENU_ACC ); 961 edit_casc[ 10 ].title = msgGetText( MXDI_CUT_BUF_MENU ); 962 edit_casc[ 10 ].mnemonic = msgGetText( MXDI_CUT_BUF_MENU_ACC ); 963 edit_casc[ 11 ].title = msgGetText( MXDI_PASTE_BUF_MENU ); 964 edit_casc[ 11 ].mnemonic = msgGetText( MXDI_PASTE_BUF_MENU_ACC ); 965 966 ctrl_casc[ 0 ].title = msgGetText( MXDI_CONF_MENU ); 967 ctrl_casc[ 0 ].mnemonic = msgGetText( MXDI_CONF_MENU_ACC ); 968 ctrl_casc[ 1 ].title = msgGetText( MXDI_HANDLE_MENU ); 969 ctrl_casc[ 1 ].mnemonic = msgGetText( MXDI_HANDLE_MENU_ACC ); 970 ctrl_casc[ 2 ].title = msgGetText( MXDI_TIME_LAY_MENU ); 971 ctrl_casc[ 2 ].mnemonic = msgGetText( MXDI_TIME_LAY_MENU_ACC ); 972 ctrl_casc[ 3 ].title = msgGetText( MXDI_GRID_MENU ); 973 ctrl_casc[ 3 ].mnemonic = msgGetText( MXDI_GRID_MENU_ACC ); 974 ctrl_casc[ 4 ].title = msgGetText( MXDI_FLAGS_DISPLAY_MENU ); 975 ctrl_casc[ 4 ].mnemonic = msgGetText( MXDI_FLAGS_DISPLAY_MENU_ACC ); 976 ctrl_casc[ 5 ].title = msgGetText( MXDI_TRUE_COLOR_MENU ); 977 ctrl_casc[ 5 ].mnemonic = msgGetText( MXDI_TRUE_COLOR_MENU_ACC ); 978 ctrl_casc[ 7 ].title = msgGetText( MXDI_DISP_DAYS_MENU ); 979 ctrl_casc[ 7 ].mnemonic = msgGetText( MXDI_DISP_DAYS_MENU_ACC ); 980 ctrl_casc[ 8 ].title = msgGetText( MXDI_DAY_WIDTH_MENU ); 981 ctrl_casc[ 8 ].mnemonic = msgGetText( MXDI_DAY_WIDTH_MENU_ACC ); 982 ctrl_casc[ 9 ].title = msgGetText( MXDI_FILTER_MENU ); 983 ctrl_casc[ 9 ].mnemonic = msgGetText( MXDI_FILTER_MENU_ACC ); 984 ctrl_casc[ 10 ].title = msgGetText( MXDI_INCLUDE_MENU ); 985 ctrl_casc[ 10 ].mnemonic = msgGetText( MXDI_INCLUDE_MENU_ACC ); 986 ctrl_casc[ 11 ].title = msgGetText( MXDI_SEL_HIDDEN_MENU ); 987 ctrl_casc[ 11 ].mnemonic = msgGetText( MXDI_SEL_HIDDEN_MENU_ACC ); 988 989 if( flagIsSet( sched_ref -> flags, XTM_SM_READ_ONLY ) ) { 990 opt_casc[ 0 ].title = msgGetText( MXDI_APP_SHOW_MENU ); 991 opt_casc[ 0 ].mnemonic = msgGetText( MXDI_APP_SHOW_MENU_ACC ); 992 } else { 993 opt_casc[ 0 ].title = msgGetText( MXDI_APP_EDITOR_MENU ); 994 opt_casc[ 0 ].mnemonic = msgGetText( MXDI_APP_EDITOR_MENU_ACC ); 995 } 996 997 opt_casc[ 1 ].title = msgGetText( MXDI_SUM_MENU ); 998 opt_casc[ 1 ].mnemonic = msgGetText( MXDI_SUM_MENU_ACC ); 999 opt_casc[ 2 ].title = msgGetText( MXDI_SEND_MSG_MENU ); 1000 opt_casc[ 2 ].mnemonic = msgGetText( MXDI_SEND_MSG_MENU_ACC ); 1001 opt_casc[ 3 ].title = msgGetText( MXDI_PLAN_MENU ); 1002 opt_casc[ 3 ].mnemonic = msgGetText( MXDI_PLAN_MENU_ACC ); 1003 opt_casc[ 5 ].title = msgGetText( MXDI_REDISPLAY_MENU ); 1004 opt_casc[ 5 ].mnemonic = msgGetText( MXDI_REDISPLAY_MENU_ACC ); 1005 1006 help_casc[ 0 ].title = msgGetText( MXDI_HELP_CONTEXT ); 1007 help_casc[ 0 ].mnemonic = msgGetText( MXDI_HELP_CONTEXT_ACC ); 1008 help_casc[ 1 ].title = msgGetText( MXDI_HELP_WINDOWS ); 1009 help_casc[ 1 ].mnemonic = msgGetText( MXDI_HELP_WINDOWS_ACC ); 1010 help_casc[ 2 ].title = msgGetText( MXDI_HELP_KEYS ); 1011 help_casc[ 2 ].mnemonic = msgGetText( MXDI_HELP_KEYS_ACC ); 1012 help_casc[ 3 ].title = msgGetText( MXDI_HELP_INDEX ); 1013 help_casc[ 3 ].mnemonic = msgGetText( MXDI_HELP_INDEX_ACC ); 1014 help_casc[ 4 ].title = msgGetText( MXDI_HELP_HELP ); 1015 help_casc[ 4 ].mnemonic = msgGetText( MXDI_HELP_HELP_ACC ); 1016 help_casc[ 5 ].title = msgGetText( MXDI_HELP_VERSION ); 1017 help_casc[ 5 ].mnemonic = msgGetText( MXDI_HELP_VERSION_ACC ); 1018 help_casc[ 6 ].title = msgGetText( MXDI_HELP_ABOUT ); 1019 help_casc[ 6 ].mnemonic = msgGetText( MXDI_HELP_ABOUT_ACC ); 1020 1021 button_def[ 0 ].title = msgGetText( MXDI_MAKE_APPOINTMENT_LABEL ); 1022 button_def[ 1 ].title = msgGetText( MXDI_MAKE_NOTE_LABEL ); 1023 1024 1025 /* No popups are defined. */ 1026 sched_ref -> entry_popupW = NULL; 1027 sched_ref -> entry_text_popupW = NULL; 1028 1029 1030 /* Create a toplevel dialog with buttons. */ 1031 toplevel = xitGetToplevelWidget( parent ); 1032 1033 schedTl = xitCreateToplevelDialog( toplevel, "SchedTl", 1034 1, 0, 1035 action_buttons, 1036 XtNumber( action_buttons ) ); 1037 1038 XtAddCallback( schedTl, XmNdestroyCallback, 1039 (XtCallbackProc) destroyCB, (XtPointer) sched_ref ); 1040 1041 /* Exit the application if this window is deleted. */ 1042 { 1043 Atom wm_delete_window; 1044 1045 wm_delete_window = XmInternAtom( XtDisplay( schedTl ), 1046 "WM_DELETE_WINDOW", False ); 1047 1048 XmAddWMProtocols( schedTl, &wm_delete_window, 1 ); 1049 XmAddWMProtocolCallback( schedTl, wm_delete_window, 1050 (XtCallbackProc) closeCB, (XtPointer) sched_ref ); 1051 } /* block */ 1052 1053 1054 /* Container for the contents of the window. */ 1055 workFo = XtNameToWidget( schedTl, "SchedTlBase.SchedTlFo" ); 1056 1057 XtAddCallback( schedTl, XmNdestroyCallback, 1058 (XtCallbackProc) destroyCB, (XtPointer) sched_ref ); 1059 1060 /* Create the menubar and menu cascades. */ 1061 menuBr = XmCreateMenuBar( workFo, "MenuBr", args, 0 ); 1062 1063 n = 0; 1064 for( index = 0; index < XtNumber( pulldownMenu ); index++ ) 1065 pulldownMenu[ index ] = XmCreatePulldownMenu( menuBr, 1066 pull_downs[ index ], 1067 args, n ); 1068 1069 for( index = 0; index < XtNumber( menuCasc ); index++ ) 1070 menuCasc[ index ] = xitCreateCascadeButton( menuBr, 1071 pulldownMenu[ index ], 1072 &menupane[ index ] ); 1073 1074 /* The help button should be placed to the right. */ 1075 index = XtNumber( menuCasc ) - 1; 1076 n = 0; 1077 XtSetArg( args[ n ], XmNmenuHelpWidget, menuCasc[ index ] ); n++; 1078 XtSetValues( menuBr, args, n ); 1079 1080 1081 /* Create the file menu. */ 1082 XtAddCallback( pulldownMenu[ 0 ], XmNentryCallback, 1083 (XtCallbackProc) fileMenuCB, (XtPointer) sched_ref ); 1084 XtAddCallback( pulldownMenu[ 0 ], XmNmapCallback, 1085 (XtCallbackProc) xtmSaMapFileMenuCB, (XtPointer) sched_ref ); 1086 1087 for( index = 0; index < XtNumber( menuFileBu ); index++ ) { 1088 menuFileBu[ index ] = xitCreateMenuPushButton( pulldownMenu[ 0 ], 1089 &file_casc[ index ] ); 1090 1091 if( XmIsPushButton( menuFileBu[ index ] ) ) 1092 XtAddCallback( menuFileBu[ index ], XmNactivateCallback, 1093 (XtCallbackProc) fileMenuCB, (XtPointer)(intptr_t)index ); 1094 } 1095 1096 if( flagIsSet( sched_ref -> flags, XTM_SM_ONLY_ONE ) ) 1097 XtSetSensitive( menuFileBu[ 0 ], False ); 1098 1099 1100 /* Create the edit menu. */ 1101 XtAddCallback( pulldownMenu[ 1 ], XmNentryCallback, 1102 (XtCallbackProc) editMenuCB, (XtPointer) sched_ref ); 1103 XtAddCallback( pulldownMenu[ 1 ], XmNmapCallback, 1104 (XtCallbackProc) xtmSaMapEditMenuCB, (XtPointer) sched_ref ); 1105 1106 for( index = 0; index < XtNumber( menuEditBu ); index++ ) { 1107 menuEditBu[ index ] = xitCreateMenuPushButton( pulldownMenu[ 1 ], 1108 &edit_casc[ index ] ); 1109 1110 if( XmIsPushButton( menuEditBu[ index ] ) ) 1111 XtAddCallback( menuEditBu[ index ], XmNactivateCallback, 1112 (XtCallbackProc) editMenuCB, (XtPointer)(intptr_t)index ); 1113 } 1114 1115 1116 /* Create the control menu. */ 1117 XtAddCallback( pulldownMenu[ 2 ], XmNentryCallback, 1118 (XtCallbackProc) ctrlMenuCB, (XtPointer) sched_ref ); 1119 XtAddCallback( pulldownMenu[ 2 ], XmNmapCallback, 1120 (XtCallbackProc) xtmSaMapCtrlMenuCB, (XtPointer) sched_ref ); 1121 1122 for( index = 0; index < XtNumber( menuCtrlBu ); index++ ) { 1123 menuCtrlBu[ index ] = xitCreateMenuPushButton( pulldownMenu[ 2 ], 1124 &ctrl_casc[ index ] ); 1125 1126 if( XmIsPushButton( menuCtrlBu[ index ] ) ) 1127 XtAddCallback( menuCtrlBu[ index ], XmNactivateCallback, 1128 (XtCallbackProc) ctrlMenuCB, (XtPointer)(intptr_t)index ); 1129 else if( XmIsToggleButton( menuCtrlBu[ index ] ) ) 1130 XtAddCallback( menuCtrlBu[ index ], XmNvalueChangedCallback, 1131 (XtCallbackProc) ctrlMenuCB, (XtPointer)(intptr_t)index ); 1132 } 1133 1134 1135 /* Create the options menu. */ 1136 XtAddCallback( pulldownMenu[ 3 ], XmNentryCallback, 1137 (XtCallbackProc) optionsMenuCB, (XtPointer) sched_ref ); 1138 1139 for( index = 0; index < XtNumber( menuOptionsBu ); index++ ) { 1140 menuOptionsBu[ index ] = xitCreateMenuPushButton( pulldownMenu[ 3 ], 1141 &opt_casc[ index ] ); 1142 1143 if( XmIsPushButton( menuOptionsBu[ index ] ) ) 1144 XtAddCallback( menuOptionsBu[ index ], XmNactivateCallback, 1145 (XtCallbackProc) optionsMenuCB, (XtPointer)(intptr_t)index ); 1146 } 1147 1148 1149 /* Create the help menu. */ 1150 XtAddCallback( pulldownMenu[ 4 ], XmNentryCallback, 1151 (XtCallbackProc) infoCB, (XtPointer) sched_ref ); 1152 1153 for( index = 0; index < XtNumber( menuHelpBu ); index++ ) { 1154 menuHelpBu[ index ] = xitCreateMenuPushButton( pulldownMenu[ 4 ], 1155 &help_casc[ index ] ); 1156 1157 if( XmIsPushButton( menuHelpBu[ index ] ) ) 1158 XtAddCallback( menuHelpBu[ index ], XmNactivateCallback, 1159 (XtCallbackProc) infoCB, (XtPointer)(intptr_t)index ); 1160 } 1161 1162 /* We can't do context sensitive help. */ 1163 XtSetSensitive( menuHelpBu[ 0 ], False ); 1164 1165 1166 /* Create a select date form. */ 1167 n = 0; 1168 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 1169 dateRc = XmCreateRowColumn( workFo, "DateRc", args, n ); 1170 1171 dateLa = xitCreateLabel( dateRc, "DateLa", 1172 msgGetText( MXDI_SCHED_BTW_DATES ), -1 ); 1173 1174 fromTb = xtmFlCreateDateField( dateRc, "FromTb" ); 1175 XtAddCallback( fromTb, XmNactivateCallback, 1176 (XtCallbackProc) applyCB, (XtPointer) sched_ref ); 1177 1178 dateInfoLa = xitCreateLabel( dateRc, "DateInfoLa", " ", -1 ); 1179 1180 1181 /* Day display window. */ 1182 n = 0; 1183 XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++; 1184 XtSetArg( args[ n ], XmNscrollingPolicy, XmAUTOMATIC ); n++; 1185 XtSetArg( args[ n ], XmNscrollBarPlacement, XmTOP_RIGHT ); n++; 1186 XtSetArg( args[ n ], XmNshadowThickness, 1 ); n++; 1187 XtSetArg( args[ n ], XmNspacing, 0 ); n++; 1188 dayDispSw = XmCreateScrolledWindow( workFo, "DayDispSw", args, n ); 1189 1190 n = 0; 1191 XtSetArg( args[ n ], XmNhorizontalScrollBar, &tempW ); n++; 1192 XtGetValues( dayDispSw, args, n ); 1193 1194 n = 0; 1195 XtSetArg( args[ n ], XmNheight, 1 ); n++; 1196 XtSetArg( args[ n ], XmNmappedWhenManaged, False ); n++; 1197 XtSetValues( tempW, args, n ); 1198 1199 n = 0; 1200 XtSetArg( args[ n ], XmNallowOverlap, True ); n++; 1201 XtSetArg( args[ n ], XmNmarginHeight, 0 ); n++; 1202 XtSetArg( args[ n ], XmNmarginWidth, 0 ); n++; 1203 XtSetArg( args[ n ], XmNresizePolicy, XmRESIZE_NONE ); n++; 1204 dayDispBb = XmCreateBulletinBoard( dayDispSw, "DayDispBb", args, n ); 1205 1206 tempW = xitCreateLabel( dayDispBb, "", " ", -1 ); 1207 1208 n = 0; 1209 XtSetArg( args[ n ], XmNheight, &height ); n++; 1210 XtGetValues( tempW, args, n ); 1211 1212 XtDestroyWidget( tempW ); 1213 1214 n = 0; 1215 XtSetArg( args[ n ], XmNheight, height + 10 ); n++; 1216 XtSetValues( dayDispSw, args, n ); 1217 1218 1219 /* Paned window for notes and appointments. */ 1220 n = 0; 1221 XtSetArg( args[ n ], XmNmarginWidth, 0 ); n++; 1222 schedPa = XmCreatePanedWindow( workFo, "SchedPa", args, n ); 1223 1224 1225 /* Two form containers within the panes. */ 1226 height = (Dimension) sched_ref -> appl_data_ref -> custom_data -> 1227 note_pane_height; 1228 width = (Dimension) sched_ref -> appl_data_ref -> custom_data -> 1229 entry_pane_width; 1230 1231 n = 0; 1232 XtSetArg( args[ n ], XmNpaneMinimum, height ); n++; 1233 XtSetArg( args[ n ], XmNwidth, width ); n++; 1234 pane1Fo = XmCreateForm( schedPa, "Pane1Fo", args, n ); 1235 1236 height = (Dimension) sched_ref -> appl_data_ref -> custom_data -> 1237 app_pane_height; 1238 n = 0; 1239 XtSetArg( args[ n ], XmNpaneMinimum, height ); n++; 1240 XtSetArg( args[ n ], XmNwidth, width ); n++; 1241 pane2Fo = XmCreateForm( schedPa, "Pane2Fo", args, n ); 1242 1243 1244 /* Start to build the note part of the paned window. */ 1245 1246 /* Create a note. */ 1247 makeNotePb = xitCreatePushButton( pane1Fo, &button_def[ 1 ] ); 1248 1249 XtAddCallback( makeNotePb, XmNactivateCallback, 1250 (XtCallbackProc) makeNoteCB, (XtPointer) sched_ref ); 1251 1252 /* Scrolled window for the notes. */ 1253 n = 0; 1254 XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++; 1255 XtSetArg( args[ n ], XmNscrollingPolicy, XmAUTOMATIC ); n++; 1256 XtSetArg( args[ n ], XmNshadowThickness, 1 ); n++; 1257 noteSw = XmCreateScrolledWindow( pane1Fo, "NoteSw", args, n ); 1258 1259 n = 0; 1260 XtSetArg( args[ n ], XmNhorizontalScrollBar, &tempW ); n++; 1261 XtGetValues( noteSw, args, n ); 1262 1263 n = 0; 1264 XtSetArg( args[ n ], XmNheight, 1 ); n++; 1265 XtSetArg( args[ n ], XmNmappedWhenManaged, False ); n++; 1266 XtSetValues( tempW, args, n ); 1267 1268 /* Bulletin board for row columns with notes. */ 1269 n = 0; 1270 XtSetArg( args[ n ], XmNallowOverlap, True ); n++; 1271 XtSetArg( args[ n ], XmNmarginHeight, 0 ); n++; 1272 XtSetArg( args[ n ], XmNmarginWidth, 0 ); n++; 1273 XtSetArg( args[ n ], XmNresizePolicy, XmRESIZE_NONE ); n++; 1274 noteBb = XmCreateBulletinBoard( noteSw, "NoteBb", args, n ); 1275 1276 if( flagIsClear( sched_ref -> flags, XTM_SM_READ_ONLY ) ) { 1277 XtAddEventHandler( noteBb, ButtonPressMask, False, 1278 (XtEventHandler) xtmSaActionNoteHook, 1279 (XtPointer) sched_ref ); 1280 XtAddEventHandler( noteBb, ButtonMotionMask, False, 1281 (XtEventHandler) xtmSaTrackAnimation, 1282 (XtPointer) sched_ref ); 1283 XtAddEventHandler( noteBb, ButtonReleaseMask, False, 1284 (XtEventHandler) xtmSaStopAnimation, 1285 (XtPointer) sched_ref ); 1286 } 1287 1288 /* Bottom delimiter in the notes window. */ 1289 n = 0; 1290 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 1291 noteBottomSp = XmCreateSeparator( noteBb, "NoteBottomSp", args, n ); 1292 1293 1294 /* Start to build the appointments part of the paned window. */ 1295 1296 /* Create an appointment. */ 1297 makeAppPb = xitCreatePushButton( pane2Fo, &button_def[ 0 ] ); 1298 1299 XtAddCallback( makeAppPb, XmNactivateCallback, 1300 (XtCallbackProc) makeAppointmentCB, (XtPointer) sched_ref ); 1301 1302 /* Create the 'zoom' field. */ 1303 zoomFs = xtmFlCreateSelField( pane2Fo, "ZoomFs", 4, zoom_times, 1304 ' ', True, 1305 (XtCallbackProc) zoomCB, (void *) sched_ref ); 1306 1307 tempW = xitFieldSelectGetChild( zoomFs, xitFIELD_SELECT_TEXT_FIELD ); 1308 1309 n = 0; 1310 XtSetArg( args[ n ], XmNeditable, False ); n++; 1311 XtSetArg( args[ n ], XmNcursorPositionVisible, False ); n++; 1312 XtSetValues( tempW, args, n ); 1313 1314 sprintf( buffer, "%1d:%2.2d", 1315 sched_ref -> entry_delta / 60, 1316 sched_ref -> entry_delta % 60 ); 1317 1318 xitFieldSelectSetCurrent( zoomFs, buffer, False ); 1319 1320 /* Some text saying what this is all about. */ 1321 appLa = xitCreateLabel( pane2Fo, "AppLa", 1322 msgGetText( MXDI_APPOINTMENTS_PANE ), -1 ); 1323 1324 /* Label to use during animation. */ 1325 trackPx = xitCreateLabel( pane2Fo, "TrackPx", " " , -1 ); 1326 1327 n = 0; 1328 XtSetArg( args[ n ], XmNlabelType, XmPIXMAP ); n++; 1329 XtSetValues( trackPx, args, n ); 1330 1331 trackLa = xitCreateLabel( pane2Fo, "TrackLa", 1332 " ", -1 ); 1333 1334 /* Time display window. */ 1335 n = 0; 1336 XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++; 1337 XtSetArg( args[ n ], XmNscrollingPolicy, XmAUTOMATIC ); n++; 1338 XtSetArg( args[ n ], XmNscrollBarPlacement, XmBOTTOM_LEFT ); n++; 1339 XtSetArg( args[ n ], XmNshadowThickness, 1 ); n++; 1340 timeDispSw = XmCreateScrolledWindow( pane2Fo, "TimeDispSw", args, n ); 1341 1342 n = 0; 1343 XtSetArg( args[ n ], XmNverticalScrollBar, &tempW ); n++; 1344 XtGetValues( timeDispSw, args, n ); 1345 1346 n = 0; 1347 XtSetArg( args[ n ], XmNwidth, 1 ); n++; 1348 XtSetArg( args[ n ], XmNmappedWhenManaged, False ); n++; 1349 XtSetValues( tempW, args, n ); 1350 1351 n = 0; 1352 XtSetArg( args[ n ], XmNallowOverlap, True ); n++; 1353 XtSetArg( args[ n ], XmNmarginHeight, 0 ); n++; 1354 XtSetArg( args[ n ], XmNmarginWidth, 0 ); n++; 1355 timeDispBb = XmCreateBulletinBoard( timeDispSw, "TimeDispBb", args, n ); 1356 1357 /* Label with the times. */ 1358 timeDispLa = xitCreateLabelWidget( timeDispBb, "TimeDispLa", 1359 " ", -1 ); 1360 1361 /* Read only mode? */ 1362 if( flagIsClear( sched_ref -> flags, XTM_SM_READ_ONLY ) ) { 1363 XtAddEventHandler( timeDispLa, ButtonPressMask, False, 1364 (XtEventHandler) timeActionHookCB, 1365 (XtPointer) sched_ref ); 1366 XtAddEventHandler( timeDispLa, ButtonMotionMask, False, 1367 (XtEventHandler) xtmSaTrackAnimation, 1368 (XtPointer) sched_ref ); 1369 XtAddEventHandler( timeDispLa, ButtonReleaseMask, False, 1370 (XtEventHandler) xtmSaStopAnimation, 1371 (XtPointer) sched_ref ); 1372 } 1373 1374 n = 0; 1375 XtSetArg( args[ n ], XmNx, 10 ); n++; 1376 XtSetArg( args[ n ], XmNy, 0 ); n++; 1377 XtSetValues( timeDispLa, args, n ); 1378 1379 /* Current time indicator (do not manage yet). */ 1380 timeIndicatorAr = xitCreateArrowPushButton( timeDispBb, 1381 &time_ind_def[ 0 ] ); 1382 n = 0; 1383 XtSetArg( args[ n ], XmNshadowThickness, 0 ); n++; 1384 XtSetArg( args[ n ], XmNtraversalOn, False ); n++; 1385 XtSetArg( args[ n ], XmNhighlightThickness, 0 ); n++; 1386 XtSetValues( timeIndicatorAr, args, n ); 1387 1388 1389 /* Size of the time window. */ 1390 n = 0; 1391 XtSetArg( args[ n ], XmNwidth, &width ); n++; 1392 XtGetValues( timeDispLa, args, n ); 1393 1394 n = 0; 1395 XtSetArg( args[ n ], XmNwidth, width + 20 ); n++; 1396 XtSetValues( timeDispSw, args, n ); 1397 1398 /* Window for the appointments. */ 1399 n = 0; 1400 XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++; 1401 XtSetArg( args[ n ], XmNscrollingPolicy, XmAUTOMATIC ); n++; 1402 XtSetArg( args[ n ], XmNshadowThickness, 1 ); n++; 1403 entrySw = XmCreateScrolledWindow( pane2Fo, "EntrySw", args, n ); 1404 1405 n = 0; 1406 XtSetArg( args[ n ], XmNhorizontalScrollBar, &tempW ); n++; 1407 XtGetValues( entrySw, args, n ); 1408 1409 XtAddCallback( tempW, XmNincrementCallback, 1410 (XtCallbackProc) xtmSwEntryScrolledHorizCB, 1411 (XtPointer) sched_ref ); 1412 XtAddCallback( tempW, XmNdecrementCallback, 1413 (XtCallbackProc) xtmSwEntryScrolledHorizCB, 1414 (XtPointer) sched_ref ); 1415 XtAddCallback( tempW, XmNpageIncrementCallback, 1416 (XtCallbackProc) xtmSwEntryScrolledHorizCB, 1417 (XtPointer) sched_ref ); 1418 XtAddCallback( tempW, XmNpageDecrementCallback, 1419 (XtCallbackProc) xtmSwEntryScrolledHorizCB, 1420 (XtPointer) sched_ref ); 1421 XtAddCallback( tempW, XmNvalueChangedCallback, 1422 (XtCallbackProc) xtmSwEntryScrolledHorizCB, 1423 (XtPointer) sched_ref ); 1424 XtAddCallback( tempW, XmNdragCallback, 1425 (XtCallbackProc) xtmSwEntryScrolledHorizCB, 1426 (XtPointer) sched_ref ); 1427 1428 n = 0; 1429 XtSetArg( args[ n ], XmNverticalScrollBar, &tempW ); n++; 1430 XtGetValues( entrySw, args, n ); 1431 1432 XtAddCallback( tempW, XmNincrementCallback, 1433 (XtCallbackProc) xtmSwEntryScrolledVertCB, 1434 (XtPointer) sched_ref ); 1435 XtAddCallback( tempW, XmNdecrementCallback, 1436 (XtCallbackProc) xtmSwEntryScrolledVertCB, 1437 (XtPointer) sched_ref ); 1438 XtAddCallback( tempW, XmNpageIncrementCallback, 1439 (XtCallbackProc) xtmSwEntryScrolledVertCB, 1440 (XtPointer) sched_ref ); 1441 XtAddCallback( tempW, XmNpageDecrementCallback, 1442 (XtCallbackProc) xtmSwEntryScrolledVertCB, 1443 (XtPointer) sched_ref ); 1444 XtAddCallback( tempW, XmNvalueChangedCallback, 1445 (XtCallbackProc) xtmSwEntryScrolledVertCB, 1446 (XtPointer) sched_ref ); 1447 XtAddCallback( tempW, XmNdragCallback, 1448 (XtCallbackProc) xtmSwEntryScrolledVertCB, 1449 (XtPointer) sched_ref ); 1450 1451 n = 0; 1452 XtSetArg( args[ n ], XmNallowOverlap, True ); n++; 1453 XtSetArg( args[ n ], XmNmarginHeight, 0 ); n++; 1454 XtSetArg( args[ n ], XmNmarginWidth, 0 ); n++; 1455 XtSetArg( args[ n ], XmNresizePolicy, XmRESIZE_NONE ); n++; 1456 entryBb = XmCreateBulletinBoard( entrySw, "EntryBb", args, n ); 1457 1458 if( flagIsClear( sched_ref -> flags, XTM_SM_READ_ONLY ) ) { 1459 XtAddEventHandler( entryBb, ButtonPressMask, False, 1460 (XtEventHandler) xtmSaActionAppHook, 1461 (XtPointer) sched_ref ); 1462 XtAddEventHandler( entryBb, ButtonMotionMask, False, 1463 (XtEventHandler) xtmSaTrackAnimation, 1464 (XtPointer) sched_ref ); 1465 XtAddEventHandler( entryBb, ButtonReleaseMask, False, 1466 (XtEventHandler) xtmSaStopAnimation, 1467 (XtPointer) sched_ref ); 1468 } 1469 1470 /* Bottom delimiter in the entry window. */ 1471 n = 0; 1472 XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++; 1473 entryBottomSp = XmCreateSeparator( entryBb, "EntryBottomSp", args, n ); 1474 1475 1476 /* Create the navigate buttons. */ 1477 n = 0; 1478 navFo = XmCreateForm( workFo, "NavFo", args, n ); 1479 1480 1481 /* Create next day action. */ 1482 xstr = XmStringCreateLtoR( msgGetText( MXDI_DAY_LABEL ), CS ); 1483 1484 n = 0; 1485 XtSetArg( args[ n ], XmNlabelString, xstr ); n++; 1486 navDayAl = XmUbCreateArrowLabel( navFo, "NavDayAl", args, n ); 1487 1488 XmStringFree( xstr ); 1489 1490 XtAddCallback( navDayAl, XmNactivateCallback, 1491 (XtCallbackProc) navigateCB, (XtPointer) sched_ref ); 1492 1493 1494 /* Create next week action. */ 1495 xstr = XmStringCreateLtoR( msgGetText( MXDI_WEEK_LABEL ), CS ); 1496 1497 n = 0; 1498 XtSetArg( args[ n ], XmNlabelString, xstr ); n++; 1499 navWeekAl = XmUbCreateArrowLabel( navFo, "NavWeekAl", args, n ); 1500 1501 XmStringFree( xstr ); 1502 1503 XtAddCallback( navWeekAl, XmNactivateCallback, 1504 (XtCallbackProc) navigateCB, (XtPointer) sched_ref ); 1505 1506 1507 /* Create next month action. */ 1508 xstr = XmStringCreateLtoR( msgGetText( MXDI_MONTH_LABEL ), CS ); 1509 1510 n = 0; 1511 XtSetArg( args[ n ], XmNlabelString, xstr ); n++; 1512 navMonthAl = XmUbCreateArrowLabel( navFo, "NavMonthAl", args, n ); 1513 1514 XmStringFree( xstr ); 1515 1516 XtAddCallback( navMonthAl, XmNactivateCallback, 1517 (XtCallbackProc) navigateCB, (XtPointer) sched_ref ); 1518 1519 1520 /* Create next year action. */ 1521 xstr = XmStringCreateLtoR( msgGetText( MXDI_YEAR_LABEL ), CS ); 1522 1523 n = 0; 1524 XtSetArg( args[ n ], XmNlabelString, xstr ); n++; 1525 navYearAl = XmUbCreateArrowLabel( navFo, "NavYearAl", args, n ); 1526 1527 XmStringFree( xstr ); 1528 1529 XtAddCallback( navYearAl, XmNactivateCallback, 1530 (XtCallbackProc) navigateCB, (XtPointer) sched_ref ); 1531 1532 1533 /* Fetch dimensions to use for offset values. */ 1534 n = 0; 1535 XtSetArg( args[ n ], XmNhorizontalScrollBar, &tempW ); n++; 1536 XtGetValues( entrySw, args, n ); 1537 1538 n = 0; 1539 XtSetArg( args[ n ], XmNheight, &sb_height ); n++; 1540 XtGetValues( tempW, args, n ); 1541 1542 n = 0; 1543 XtSetArg( args[ n ], XmNwidth, &time_width ); n++; 1544 XtGetValues( timeDispSw, args, n ); 1545 1546 1547 /* Set offsets for the components. */ 1548 n = 0; 1549 XtSetArg( args[ n ], XmNtopOffset, 10 ); n++; 1550 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 1551 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 1552 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 1553 XtSetValues( dateRc, args, n ); 1554 1555 /* Day names window. */ 1556 n = 0; 1557 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 1558 XtSetArg( args[ n ], XmNleftOffset, time_width + 6 ); n++; 1559 XtSetArg( args[ n ], XmNrightOffset, sb_height + 18 ); n++; 1560 XtSetValues( dayDispSw, args, n ); 1561 1562 /* Pane window. */ 1563 n = 0; 1564 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 1565 XtSetArg( args[ n ], XmNrightOffset, 5 ); n++; 1566 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 1567 XtSetValues( schedPa, args, n ); 1568 1569 /* Navigate form. */ 1570 n = 0; 1571 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 1572 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 1573 XtSetArg( args[ n ], XmNleftOffset, 5 ); n++; 1574 XtSetValues( navFo, args, n ); 1575 1576 /* Navigate buttons. */ 1577 n = 0; 1578 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 1579 XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++; 1580 XtSetArg( args[ n ], XmNleftOffset, 10 ); n++; 1581 XtSetArg( args[ n ], XmNrightOffset, 10 ); n++; 1582 XtSetValues( navDayAl, args, n ); 1583 XtSetValues( navWeekAl, args, n ); 1584 XtSetValues( navMonthAl, args, n ); 1585 XtSetValues( navYearAl, args, n ); 1586 1587 /* Notes window. */ 1588 n = 0; 1589 XtSetArg( args[ n ], XmNtopOffset, 0 ); n++; 1590 XtSetArg( args[ n ], XmNleftOffset, time_width ); n++; 1591 XtSetArg( args[ n ], XmNrightOffset, 0 ); n++; 1592 XtSetArg( args[ n ], XmNbottomOffset, 0 ); n++; 1593 XtSetValues( noteSw, args, n ); 1594 1595 /* Zoom button. */ 1596 n = 0; 1597 XtSetArg( args[ n ], XmNleftOffset, 2 ); n++; 1598 XtSetValues( zoomFs, args, n ); 1599 1600 /* New entry button. */ 1601 n = 0; 1602 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 1603 XtSetArg( args[ n ], XmNleftOffset, 2 ); n++; 1604 XtSetValues( makeAppPb, args, n ); 1605 1606 /* Time display window. */ 1607 n = 0; 1608 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 1609 XtSetArg( args[ n ], XmNleftOffset, 0 ); n++; 1610 XtSetArg( args[ n ], XmNrightOffset, 0 ); n++; 1611 XtSetArg( args[ n ], XmNbottomOffset, sb_height ); n++; 1612 XtSetValues( timeDispSw, args, n ); 1613 1614 /* Entry display window. */ 1615 n = 0; 1616 XtSetArg( args[ n ], XmNtopOffset, 5 ); n++; 1617 XtSetArg( args[ n ], XmNleftOffset, 0 ); n++; 1618 XtSetArg( args[ n ], XmNrightOffset, 0 ); n++; 1619 XtSetArg( args[ n ], XmNbottomOffset, 0 ); n++; 1620 XtSetValues( entrySw, args, n ); 1621 1622 1623 /* Parts in the notes pane. */ 1624 xitAttachWidget( noteSw, 1625 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 1626 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL ); 1627 1628 /* Parts in the appointments pane. */ 1629 xitAttachWidget( zoomFs, 1630 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 1631 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1632 xitAttachWidget( appLa, 1633 XmATTACH_OPPOSITE_WIDGET, zoomFs, 1634 XmATTACH_WIDGET, timeDispSw, 1635 XmATTACH_NONE, NULL, XmATTACH_OPPOSITE_WIDGET, zoomFs ); 1636 xitAttachWidget( trackPx, 1637 XmATTACH_OPPOSITE_WIDGET, zoomFs, 1638 XmATTACH_WIDGET, appLa, 1639 XmATTACH_NONE, NULL, XmATTACH_OPPOSITE_WIDGET, zoomFs ); 1640 xitAttachWidget( trackLa, 1641 XmATTACH_OPPOSITE_WIDGET, zoomFs, 1642 XmATTACH_WIDGET, trackPx, 1643 XmATTACH_NONE, NULL, XmATTACH_OPPOSITE_WIDGET, zoomFs ); 1644 xitAttachWidget( makeAppPb, 1645 XmATTACH_WIDGET, zoomFs, XmATTACH_FORM, NULL, 1646 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1647 xitAttachWidget( timeDispSw, 1648 XmATTACH_WIDGET, zoomFs, XmATTACH_FORM, NULL, 1649 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL ); 1650 xitAttachWidget( entrySw, 1651 XmATTACH_WIDGET, zoomFs, XmATTACH_WIDGET, timeDispSw, 1652 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL ); 1653 1654 /* Parts in the navigate window. */ 1655 xitAttachWidget( navDayAl, 1656 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 1657 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1658 xitAttachWidget( navWeekAl, 1659 XmATTACH_FORM, NULL, XmATTACH_WIDGET, navDayAl, 1660 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1661 xitAttachWidget( navMonthAl, 1662 XmATTACH_FORM, NULL, XmATTACH_WIDGET, navWeekAl, 1663 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1664 xitAttachWidget( navYearAl, 1665 XmATTACH_FORM, NULL, XmATTACH_WIDGET, navMonthAl, 1666 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1667 1668 /* Parts in the main window. */ 1669 xitAttachWidget( menuBr, 1670 XmATTACH_FORM, NULL, XmATTACH_FORM, NULL, 1671 XmATTACH_FORM, NULL, XmATTACH_NONE, NULL ); 1672 xitAttachWidget( dateRc, 1673 XmATTACH_WIDGET, menuBr, XmATTACH_FORM, NULL, 1674 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1675 xitAttachWidget( dayDispSw, 1676 XmATTACH_WIDGET, dateRc, XmATTACH_FORM, NULL, 1677 XmATTACH_FORM, NULL, XmATTACH_NONE, NULL ); 1678 xitAttachWidget( schedPa, 1679 XmATTACH_WIDGET, dayDispSw, XmATTACH_FORM, NULL, 1680 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1681 xitAttachWidget( navFo, 1682 XmATTACH_WIDGET, schedPa, XmATTACH_FORM, NULL, 1683 XmATTACH_NONE, NULL, XmATTACH_NONE, NULL ); 1684 1685 1686 /* Manage all the children. */ 1687 XtManageChildren( menuCasc, XtNumber( menuCasc ) ); 1688 XtManageChildren( menuCtrlBu, XtNumber( menuCtrlBu ) ); 1689 XtManageChildren( menuEditBu, XtNumber( menuEditBu ) ); 1690 XtManageChildren( menuFileBu, XtNumber( menuFileBu ) ); 1691 XtManageChildren( menuHelpBu, XtNumber( menuHelpBu ) ); 1692 XtManageChildren( menuOptionsBu, XtNumber( menuOptionsBu ) ); 1693 1694 xitManageChildren( dataLocalW, XtNumber( dataLocalW ) ); 1695 1696 1697 /* We don't display all scroll bars. */ 1698 n = 0; 1699 XtSetArg( args[ n ], XmNhorizontalScrollBar, &tempW ); n++; 1700 XtGetValues( timeDispSw, args, n ); 1701 XtUnmanageChild( tempW ); 1702 1703 n = 0; 1704 XtSetArg( args[ n ], XmNverticalScrollBar, &tempW ); n++; 1705 XtGetValues( dayDispSw, args, n ); 1706 XtUnmanageChild( tempW ); 1707 1708 1709 /* Set icon for this window. */ 1710 xtmIcSetSimpleIcon( schedTl, workFo, XTM_IC_ICON_SCHEDULE ); 1711 1712 /* Set the size of the window. */ 1713 xitSetSizeToplevelDialog( schedTl, True ); 1714 1715 1716 /* Make the final attachments. */ 1717 xitAttachWidget( navFo, 1718 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL, 1719 XmATTACH_NONE, NULL, XmATTACH_FORM, NULL ); 1720 xitAttachWidget( schedPa, 1721 XmATTACH_WIDGET, dayDispSw, XmATTACH_FORM, NULL, 1722 XmATTACH_FORM, NULL, XmATTACH_WIDGET, navFo ); 1723 1724 n = 0; 1725 XtSetArg( args[ n ], XmNpaneMinimum, 1 ); n++; 1726 XtSetValues( pane1Fo, args, n ); 1727 XtSetValues( pane2Fo, args, n ); 1728 1729 1730 return( schedTl ); 1731 1732 } /* createScheduleWindow */ 1733 1734 1735 /*----------------------------------------------------------------------*/ 1736 1737 static void displayEntryInfo(SCHED_REC_REF sched_ref)1738 displayEntryInfo( SCHED_REC_REF sched_ref ) 1739 { 1740 1741 /* Variables. */ 1742 Boolean ok; 1743 char buffer[ 50 ]; 1744 char entry_type[ 50 ]; 1745 char last_changed[ 50 ]; 1746 char last_changed_by[ 100 ]; 1747 char message[ 500 ]; 1748 ENTRY_INFO *entry_info_ref; 1749 TIM_TIME_REF last_update; 1750 XTM_DB_ALL_ENTRY_DEF entry_record; 1751 XTM_DB_ENTRY_DATABASES database; 1752 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 1753 struct passwd *password_ref; 1754 1755 1756 /* Code. */ 1757 1758 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 1759 1760 /* Selected entry. */ 1761 entry_info_ref = xtmStFetchSelectedInfo( sched_ref ); 1762 if( entry_info_ref == NULL ) 1763 return; 1764 1765 /* Open the database and fetch the entry. */ 1766 ok = xtmDmOpenDatabase( sched_ref -> appl_data_ref, 1767 entry_info_ref -> db_name, XTM_DB_FLAG_MODE_READ, 1768 &database ); 1769 if( ! ok ) 1770 return; 1771 1772 ok = xtmDmFetchEntry( sched_ref -> scheduleW, 1773 &database, entry_info_ref -> id, 1774 &entry_record, NULL ); 1775 1776 xtmDbCloseEntryDb( &database ); 1777 if( ! ok ) 1778 return; 1779 1780 1781 /* Type of entry? */ 1782 entry_type[ 0 ] = '\0'; 1783 1784 if( entry_record.entry.entry_type == XTM_DB_DAY_ENTRY ) { 1785 if( entry_record.entry.entry_category == XTM_DB_REP_ENTRY_LIST ) 1786 strcpy( entry_type, msgGetText( MXDI_TYPE_STAND_APPOINT ) ); 1787 else 1788 strcpy( entry_type, msgGetText( MXDI_TYPE_APPOINT ) ); 1789 } 1790 1791 if( entry_record.entry.entry_type == XTM_DB_DAY_NOTE ) { 1792 if( entry_record.entry.entry_category == XTM_DB_REP_ENTRY_LIST ) 1793 strcpy( entry_type, msgGetText( MXDI_TYPE_STAND_NOTE ) ); 1794 else if( entry_record.entry.entry_category == XTM_DB_STICKY_LIST ) 1795 strcpy( entry_type, msgGetText( MXDI_TYPE_STICKY_NOTE ) ); 1796 else 1797 strcpy( entry_type, msgGetText( MXDI_TYPE_NOTE ) ); 1798 } 1799 1800 1801 /* Last changed. */ 1802 last_update = TimLocalTime( (TIM_TIME_REF) entry_record.entry.last_update ); 1803 1804 xtmFoFormatDate( last_update, buffer, sizeof( buffer ) ); 1805 sprintf( last_changed, "%s ", buffer ); 1806 1807 xtmFoFormatTime( last_update, buffer, sizeof( buffer ) ); 1808 strcat( last_changed, buffer ); 1809 1810 1811 /* Last changed by. */ 1812 password_ref = getpwuid( entry_record.entry.owner ); 1813 if( password_ref != NULL ) 1814 strcpy( last_changed_by, password_ref -> pw_name ); 1815 else 1816 strcpy( last_changed_by, "-" ); 1817 1818 1819 /* Display the information. */ 1820 sprintf( message, msgGetText( MXDI_ENTRY_INFO_TEMPLATE ), 1821 entry_type, entry_record.db_name, 1822 last_changed, last_changed_by ); 1823 1824 (void) xitCreateInformationDialog( 1825 sched_ref -> scheduleW, "InformationDialog", 1826 msgGetText( MXDI_INFORMATION_LABEL ), 1827 message, 1828 NULL, NULL ); 1829 1830 1831 return; 1832 1833 } /* displayEntryInfo */ 1834 1835 1836 /*----------------------------------------------------------------------*/ 1837 1838 static void applyCB(Widget widget,SCHED_REC_REF sched_ref,XtPointer call_data)1839 applyCB( Widget widget, 1840 SCHED_REC_REF sched_ref, 1841 XtPointer call_data ) 1842 { 1843 1844 /* Code. */ 1845 1846 /* Update the start and stop dates. */ 1847 xtmSwSetScheduleDates( sched_ref, widget, True ); 1848 1849 /* Display the new schedule. */ 1850 xtmSwSetSchedule( sched_ref, widget ); 1851 1852 1853 return; 1854 1855 } /* applyCB */ 1856 1857 1858 /*----------------------------------------------------------------------*/ 1859 1860 static void closeCB(Widget widget,SCHED_REC_REF sched_ref,XtPointer call_data)1861 closeCB( Widget widget, 1862 SCHED_REC_REF sched_ref, 1863 XtPointer call_data ) 1864 { 1865 1866 /* Variables. */ 1867 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 1868 1869 1870 /* Code. */ 1871 1872 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 1873 1874 /* Do we really want this? */ 1875 if( flagIsSet( sched_ref -> flags, XTM_SM_ONLY_ONE ) && 1876 custom_data_ref -> confirm_actions ) { 1877 1878 XRaiseWindow( XtDisplay( sched_ref -> scheduleW ), 1879 XtWindow( sched_ref -> scheduleW ) ); 1880 1881 XtMapWidget( sched_ref -> scheduleW ); 1882 1883 (void) xitCreateQuestionDialog( 1884 sched_ref -> scheduleW, "QuestionDialog", 1885 msgGetText( MXDI_QUESTION_MESSAGE_LABEL ), 1886 msgGetText( MXDI_SCHED_CONFIRM_CLOSE ), 1887 closeReallyCB, sched_ref, 1888 NULL, NULL ); 1889 1890 } else { 1891 closeReallyCB( widget, sched_ref, NULL ); 1892 } 1893 1894 1895 return; 1896 1897 } /* closeCB */ 1898 1899 1900 /*----------------------------------------------------------------------*/ 1901 1902 static void closeReallyCB(Widget widget,SCHED_REC_REF sched_ref,XtPointer call_data)1903 closeReallyCB( Widget widget, 1904 SCHED_REC_REF sched_ref, 1905 XtPointer call_data ) 1906 { 1907 1908 /* Variables. */ 1909 int index; 1910 Widget tempW; 1911 1912 1913 /* Code. */ 1914 1915 /* Do we have a user action callback registered? */ 1916 if( sched_ref -> actionCB != NULL ) 1917 (* sched_ref -> actionCB)( XTM_SM_REASON_EXIT, 1918 sched_ref -> user_data ); 1919 1920 /* Not last active window. */ 1921 if( last_active_sched_ref == sched_ref ) 1922 last_active_sched_ref = NULL; 1923 1924 /* No focus callback. */ 1925 #ifndef XD_HAS_FOCUS_BUG 1926 tempW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase" ); 1927 XtRemoveCallback( tempW, XmNfocusCallback, 1928 (XtCallbackProc) gotFocusCB, (XtPointer) sched_ref ); 1929 #endif 1930 1931 1932 /* Keep the window in cache? */ 1933 for( index = 0; index < MAX_CACHE_ENTRIES; index++ ) { 1934 if( cache_entries[ index ] == NULL ) { 1935 cache_entries[ index ] = sched_ref; 1936 1937 destroyCB( NULL, sched_ref, NULL ); 1938 XtPopdown( sched_ref -> scheduleW ); 1939 1940 return; 1941 } 1942 } 1943 1944 1945 /* Window not kept in cache, really remove it. */ 1946 XtDestroyWidget( sched_ref -> scheduleW ); 1947 1948 1949 return; 1950 1951 } /* closeReallyCB */ 1952 1953 1954 /*----------------------------------------------------------------------*/ 1955 1956 static void ctrlMenuCB(Widget widget,SCHED_REC_REF sched_ref,XmRowColumnCallbackStruct * call_data)1957 ctrlMenuCB( Widget widget, 1958 SCHED_REC_REF sched_ref, 1959 XmRowColumnCallbackStruct *call_data ) 1960 { 1961 1962 /* Variables. */ 1963 Widget mainW; 1964 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 1965 1966 1967 /* Code. */ 1968 1969 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 1970 1971 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 1972 1973 /* Select what to do. */ 1974 switch( (intptr_t) call_data -> data ) { 1975 1976 /* Confirm actions? */ 1977 case 0: 1978 if( XmToggleButtonGetState( call_data -> widget ) ) { 1979 flagSet( sched_ref -> flags, XTM_SM_CONFIRM ); 1980 custom_data_ref -> confirm_actions = True; 1981 } else { 1982 flagClear( sched_ref -> flags, XTM_SM_CONFIRM ); 1983 custom_data_ref -> confirm_actions = False; 1984 } 1985 break; 1986 1987 1988 /* Entry handles? */ 1989 case 1: 1990 if( XmToggleButtonGetState( call_data -> widget ) ) 1991 flagSet( sched_ref -> flags, XTM_SM_ENTRY_HANDLES ); 1992 else 1993 flagClear( sched_ref -> flags, XTM_SM_ENTRY_HANDLES ); 1994 1995 if( flagIsClear( sched_ref -> flags, XTM_SM_LIST_LAYOUT ) ) 1996 xtmUpDoUpdate( XTM_UP_SCHEDULE, NULL ); 1997 break; 1998 1999 2000 /* List layout? */ 2001 case 2: 2002 if( XmToggleButtonGetState( call_data -> widget ) ) 2003 flagSet( sched_ref -> flags, XTM_SM_LIST_LAYOUT ); 2004 else 2005 flagClear( sched_ref -> flags, XTM_SM_LIST_LAYOUT ); 2006 2007 sched_ref -> force_update = True; 2008 xtmUpDoUpdate( XTM_UP_SCHEDULE, NULL ); 2009 break; 2010 2011 2012 /* Use grid? */ 2013 case 3: 2014 if( XmToggleButtonGetState( call_data -> widget ) ) 2015 flagSet( sched_ref -> flags, XTM_SM_USE_GRID ); 2016 else 2017 flagClear( sched_ref -> flags, XTM_SM_USE_GRID ); 2018 break; 2019 2020 2021 /* Display entry flags? */ 2022 case 4: 2023 if( XmToggleButtonGetState( call_data -> widget ) ) 2024 flagSet( sched_ref -> flags, XTM_SM_ENTRY_FLAGS ); 2025 else 2026 flagClear( sched_ref -> flags, XTM_SM_ENTRY_FLAGS ); 2027 2028 sched_ref -> force_update = True; 2029 xtmUpDoUpdate( XTM_UP_SCHEDULE, NULL ); 2030 break; 2031 2032 2033 /* True color for included entries? */ 2034 case 5: 2035 if( XmToggleButtonGetState( call_data -> widget ) ) 2036 flagSet( sched_ref -> flags, XTM_SM_TRUE_COLOR_INC ); 2037 else 2038 flagClear( sched_ref -> flags, XTM_SM_TRUE_COLOR_INC ); 2039 2040 xtmUpDoUpdate( XTM_UP_SCHEDULE, NULL ); 2041 break; 2042 2043 2044 /* Days to display? */ 2045 case 7: 2046 xtmSwSelectScaleValue( sched_ref, SCHED_DISP_DAYS ); 2047 break; 2048 2049 2050 /* Width of displayed days? */ 2051 case 8: 2052 xtmSwSelectScaleValue( sched_ref, SCHED_DAY_WIDTH ); 2053 break; 2054 2055 2056 /* Filter database. */ 2057 case 9: 2058 /* Initialize the filter? */ 2059 if( sched_ref -> filter_handle == NULL ) 2060 sched_ref -> filter_handle = xtmFiInitialize( 2061 sched_ref -> appl_data_ref, 2062 sched_ref -> scheduleW, 2063 custom_data_ref -> entry_tags_menu, 2064 False, 2065 filterApplyCB, (void *) sched_ref ); 2066 2067 /* Display the filter window. */ 2068 xtmFiDisplayFilterWindow( sched_ref -> filter_handle, 2069 &sched_ref -> filter_rec ); 2070 break; 2071 2072 2073 /* Include database. */ 2074 case 10: 2075 /* Initialize include. */ 2076 if( sched_ref -> include_handle == NULL ) 2077 sched_ref -> include_handle = xtmDiInitialize( 2078 sched_ref -> appl_data_ref, 2079 sched_ref -> scheduleW, 2080 False, 2081 includeDbApplyCB, 2082 (void *) sched_ref ); 2083 2084 /* Display the include window. */ 2085 xtmDiDisplayIncludeWindow( sched_ref -> include_handle, 2086 sched_ref -> db_name ); 2087 break; 2088 2089 2090 /* All standing entries? */ 2091 case 11: 2092 /* Initialize the window? */ 2093 if( sched_ref -> sel_hide_handle == NULL ) 2094 sched_ref -> sel_hide_handle = xtmShInitialize( 2095 sched_ref -> appl_data_ref, 2096 sched_ref -> scheduleW, 2097 False, 2098 selHideApplyCB, 2099 (void *) sched_ref ); 2100 2101 /* Display the window. */ 2102 xtmShDisplaySelectWindow( sched_ref -> sel_hide_handle, 2103 sched_ref -> db_name, 2104 sched_ref -> schedule_start ); 2105 break; 2106 2107 } /* switch */ 2108 2109 2110 return; 2111 2112 } /* ctrlMenuCB */ 2113 2114 2115 /*----------------------------------------------------------------------*/ 2116 2117 static void destroyCB(Widget widget,SCHED_REC_REF sched_ref,XtPointer call_data)2118 destroyCB( Widget widget, 2119 SCHED_REC_REF sched_ref, 2120 XtPointer call_data ) 2121 { 2122 2123 /* Variables. */ 2124 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 2125 2126 2127 /* Code. */ 2128 2129 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 2130 2131 2132 /* Do we have a user action callback registered? */ 2133 if( sched_ref -> actionCB != NULL ) 2134 (* sched_ref -> actionCB)( XTM_SM_REASON_DESTROY, 2135 sched_ref -> user_data ); 2136 2137 2138 /* De-register updates. */ 2139 if( sched_ref -> update_id != 0 ) 2140 xtmUpRemove( sched_ref -> update_id ); 2141 2142 sched_ref -> update_id = 0; 2143 2144 2145 /* Destroy child windows. */ 2146 if( sched_ref -> editor_handle != NULL ) { 2147 xtmEdDestroy( sched_ref -> editor_handle ); 2148 sched_ref -> editor_handle = NULL; 2149 } 2150 2151 if( sched_ref -> filter_handle != NULL ) { 2152 xtmFiDestroy( sched_ref -> filter_handle ); 2153 sched_ref -> filter_handle = NULL; 2154 } 2155 2156 if( sched_ref -> include_handle != NULL ) { 2157 xtmDiDestroy( sched_ref -> include_handle ); 2158 sched_ref -> include_handle = NULL; 2159 } 2160 2161 if( sched_ref -> pr_handle != NULL ) { 2162 xtmPrDestroy( sched_ref -> pr_handle ); 2163 sched_ref -> pr_handle = NULL; 2164 } 2165 2166 if( sched_ref -> nav_cal_handle != NULL ) { 2167 xtmNcDestroy( sched_ref -> nav_cal_handle ); 2168 sched_ref -> nav_cal_handle = NULL; 2169 } 2170 2171 if( sched_ref -> open_handle != NULL ) { 2172 xtmOvDestroy( sched_ref -> open_handle ); 2173 sched_ref -> open_handle = NULL; 2174 } 2175 2176 if( sched_ref -> planner_handle != NULL ) { 2177 xtmPlDestroy( sched_ref -> planner_handle ); 2178 sched_ref -> planner_handle = NULL; 2179 } 2180 2181 if( sched_ref -> show_handle != NULL ) { 2182 xtmSdDestroy( sched_ref -> show_handle ); 2183 sched_ref -> show_handle = NULL; 2184 } 2185 2186 if( sched_ref -> sel_hide_handle != NULL ) { 2187 xtmShDestroy( sched_ref -> sel_hide_handle ); 2188 sched_ref -> sel_hide_handle = NULL; 2189 } 2190 2191 2192 /* Free the shadow calendar. */ 2193 xtmCdFreeShadowEntry( custom_data_ref -> cal_db_handle, 2194 sched_ref -> db_name ); 2195 2196 2197 /* Release the user data (only if not cached). */ 2198 if( widget != NULL ) { 2199 2200 int index; 2201 ENTRY_CACHE_REF cache_ref; 2202 2203 /* Entry cache. */ 2204 cache_ref = sched_ref -> entry_cache_ref; 2205 2206 for( index = 0; index < cache_ref -> max_used; index++ ) { 2207 if( cache_ref -> used[ index ] == NULL ) 2208 continue; 2209 2210 if( cache_ref -> used[ index ] -> entry_text != NULL ) 2211 SysFree( cache_ref -> used[ index ] -> entry_text ); 2212 2213 SysFree( cache_ref -> used[ index ] ); 2214 } 2215 2216 SysFree( sched_ref -> entry_cache_ref -> used ); 2217 SysFree( sched_ref -> entry_cache_ref ); 2218 2219 2220 /* Animation record. */ 2221 if( sched_ref -> animate_ref != NULL ) 2222 SysFree( sched_ref -> animate_ref ); 2223 2224 2225 /* Main record. */ 2226 SysFree( sched_ref ); 2227 2228 } /* if */ 2229 2230 2231 return; 2232 2233 } /* destroyCB */ 2234 2235 2236 /*----------------------------------------------------------------------*/ 2237 2238 static void gotFocusCB(Widget widget,SCHED_REC_REF sched_ref,XmAnyCallbackStruct * call_data)2239 gotFocusCB( Widget widget, 2240 SCHED_REC_REF sched_ref, 2241 XmAnyCallbackStruct *call_data ) 2242 { 2243 2244 /* Code. */ 2245 2246 last_active_sched_ref = sched_ref; 2247 2248 2249 return; 2250 2251 } /* gotFocusCB */ 2252 2253 2254 /*----------------------------------------------------------------------*/ 2255 2256 static void editMenuCB(Widget widget,SCHED_REC_REF sched_ref,XmRowColumnCallbackStruct * call_data)2257 editMenuCB( Widget widget, 2258 SCHED_REC_REF sched_ref, 2259 XmRowColumnCallbackStruct *call_data ) 2260 { 2261 2262 /* Variables. */ 2263 Widget mainW; 2264 ENTRY_INFO *entry_info_ref; 2265 XTM_GL_BASE_DATA_REF appl_data_ref; 2266 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 2267 2268 2269 /* Code. */ 2270 2271 appl_data_ref = sched_ref -> appl_data_ref; 2272 custom_data_ref = appl_data_ref -> custom_data; 2273 2274 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 2275 2276 entry_info_ref = xtmStFetchSelectedInfo( sched_ref ); 2277 2278 2279 /* Select what to do. */ 2280 switch( (intptr_t) call_data -> data ) { 2281 2282 /* Edit the entry. */ 2283 case 0: 2284 xtmSaAppointmentEditorShow( sched_ref ); 2285 break; 2286 2287 2288 /* Delete the entry. */ 2289 case 1: 2290 xtmDlDeleteEntry( appl_data_ref, sched_ref -> scheduleW, 2291 entry_info_ref -> db_name, 2292 entry_info_ref -> id ); 2293 break; 2294 2295 2296 /* Move the entry. */ 2297 case 2: 2298 xtmCmCopyMoveEntry( appl_data_ref, sched_ref -> scheduleW, 2299 XTM_CM_MOVE, 2300 entry_info_ref -> db_name, 2301 entry_info_ref -> id ); 2302 break; 2303 2304 2305 /* Copy the entry. */ 2306 case 3: 2307 xtmCmCopyMoveEntry( appl_data_ref, sched_ref -> scheduleW, 2308 XTM_CM_COPY, 2309 entry_info_ref -> db_name, 2310 entry_info_ref -> id ); 2311 break; 2312 2313 2314 /* Duplicate the entry. */ 2315 case 4: 2316 xtmDpDuplicateEntry( appl_data_ref, sched_ref -> scheduleW, 2317 entry_info_ref -> db_name, 2318 entry_info_ref -> id ); 2319 break; 2320 2321 2322 /* Archive the entry. */ 2323 case 5: 2324 xtmArArchiveEntry( appl_data_ref, sched_ref -> scheduleW, 2325 entry_info_ref -> db_name, 2326 entry_info_ref -> id ); 2327 break; 2328 2329 2330 /* Freeze a repeated entry. */ 2331 case 6: 2332 xtmFzFreezeEntry( appl_data_ref, sched_ref -> scheduleW, 2333 entry_info_ref -> db_name, 2334 entry_info_ref -> id, 2335 entry_info_ref -> date_stamp ); 2336 break; 2337 2338 2339 /* Selected entry information. */ 2340 case 7: 2341 displayEntryInfo( sched_ref ); 2342 break; 2343 2344 2345 /* Copy entry to buffer. */ 2346 case 9: 2347 xtmSaDoCutBuffer( sched_ref, XTM_SA_DO_COPY, 2348 entry_info_ref -> db_name, 2349 entry_info_ref -> id ); 2350 break; 2351 2352 2353 /* Cut entry to buffer. */ 2354 case 10: 2355 xtmSaDoCutBuffer( sched_ref, XTM_SA_DO_CUT, 2356 entry_info_ref -> db_name, 2357 entry_info_ref -> id ); 2358 break; 2359 2360 2361 /* Paste entry from buffer. */ 2362 case 11: 2363 xtmSaDoCutBuffer( sched_ref, XTM_SA_DO_PASTE, 2364 sched_ref -> db_name, 2365 0 ); 2366 break; 2367 2368 } /* switch */ 2369 2370 /* The entry is not selected. */ 2371 xtmSwUnselectEntry( sched_ref ); 2372 2373 2374 return; 2375 2376 } /* editMenuCB */ 2377 2378 2379 /*----------------------------------------------------------------------*/ 2380 2381 static void fileMenuCB(Widget widget,SCHED_REC_REF sched_ref,XmRowColumnCallbackStruct * call_data)2382 fileMenuCB( Widget widget, 2383 SCHED_REC_REF sched_ref, 2384 XmRowColumnCallbackStruct *call_data ) 2385 { 2386 2387 /* Variables. */ 2388 Widget mainW; 2389 XTM_GL_BASE_DATA_REF appl_data_ref; 2390 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 2391 XTM_SM_HANDLE sched_handle; 2392 XTM_SM_INIT_REC sched_init; 2393 2394 2395 /* Code. */ 2396 2397 appl_data_ref = sched_ref -> appl_data_ref; 2398 custom_data_ref = appl_data_ref -> custom_data; 2399 2400 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 2401 2402 2403 /* Select what to do. */ 2404 switch( (intptr_t) call_data -> data ) { 2405 2406 /* Open schedule with the same database. */ 2407 case 0: 2408 sched_init.entry_start = sched_ref -> entry_start; 2409 sched_init.entry_stop = sched_ref -> entry_stop; 2410 sched_init.entry_delta = sched_ref -> entry_delta; 2411 sched_init.default_flags = sched_ref -> flags; 2412 2413 sched_handle = xtmSmInitialize( appl_data_ref, 2414 appl_data_ref -> toplevel, 2415 sched_ref -> db_name, &sched_init, 2416 NULL, NULL ); 2417 if( sched_handle == NULL ) 2418 return; 2419 2420 /* Diaplay the schedule window. */ 2421 xtmSmViewSchedule( sched_handle, sched_ref -> schedule_start, False ); 2422 break; 2423 2424 2425 /* Select a new database view. */ 2426 case 1: 2427 if( sched_ref -> open_handle == NULL ) 2428 sched_ref -> open_handle = xtmOvInitialize( 2429 appl_data_ref, 2430 sched_ref -> scheduleW, 2431 False, 2432 newViewApplyCB, 2433 (void *) sched_ref ); 2434 2435 if( sched_ref -> open_handle == NULL ) 2436 return; 2437 2438 /* Display the window. */ 2439 xtmOvOpenView( sched_ref -> open_handle ); 2440 break; 2441 2442 2443 /* Print window. */ 2444 case 2: 2445 if( sched_ref -> pr_handle == NULL ) 2446 sched_ref -> pr_handle = xtmPrInitialize( 2447 appl_data_ref, 2448 appl_data_ref -> toplevel, 2449 sched_ref -> db_name, 2450 printerActionCB, (void *) sched_ref ); 2451 2452 if( sched_ref -> pr_handle == NULL ) 2453 return; 2454 2455 /* Display the printer window. */ 2456 xtmPrDisplayPrinter( sched_ref -> pr_handle, 2457 sched_ref -> schedule_start, 2458 sched_ref -> schedule_stop, 2459 0, 2460 &sched_ref -> filter_rec ); 2461 2462 /* Inherit the calendar settings. */ 2463 xtmPrSetCalendar( sched_ref -> pr_handle, sched_ref -> db_name ); 2464 break; 2465 2466 2467 /* Upload and download calendar. */ 2468 case 4: 2469 case 5: 2470 { 2471 Boolean can_download = False; 2472 Boolean ok; 2473 XTM_CD_CAL_INFO db_info; 2474 2475 if( sched_ref -> remote_handle == NULL ) 2476 sched_ref -> remote_handle = xtmRtInitialize( 2477 appl_data_ref, 2478 sched_ref -> scheduleW, 2479 False, 2480 NULL, (void *) sched_ref ); 2481 2482 if( sched_ref -> remote_handle == NULL ) 2483 return; 2484 2485 /* Display the window. */ 2486 ok = xtmCdFetchNamedDb( custom_data_ref -> cal_db_handle, 2487 sched_ref -> db_name, 2488 &db_info, NULL ); 2489 if( ! ok ) 2490 return; 2491 2492 if( flagIsClear( sched_ref -> flags, XTM_SM_READ_ONLY ) && 2493 flagIsSet( db_info.operations, XTM_DB_FLAG_MODE_WRITE ) ) 2494 can_download = True; 2495 2496 if( (intptr_t) call_data -> data == 4 ) 2497 xtmRtDoRemote( sched_ref -> remote_handle, XTM_RT_UPLOAD, 2498 db_info.short_name, True, can_download ); 2499 else 2500 xtmRtDoRemote( sched_ref -> remote_handle, XTM_RT_DOWNLOAD, 2501 db_info.short_name, True, can_download ); 2502 } 2503 break; 2504 2505 2506 /* Exit the window. */ 2507 case 7: 2508 closeCB( widget, sched_ref, NULL ); 2509 break; 2510 2511 } /* switch */ 2512 2513 2514 return; 2515 2516 } /* fileMenuCB */ 2517 2518 2519 /*----------------------------------------------------------------------*/ 2520 2521 static void filterApplyCB(XTM_FI_REASON reason,XTM_DM_FILTER_REC * filter_ref,void * user_data)2522 filterApplyCB( XTM_FI_REASON reason, 2523 XTM_DM_FILTER_REC *filter_ref, 2524 void *user_data ) 2525 { 2526 2527 /* Variables. */ 2528 SCHED_REC_REF sched_ref; 2529 2530 2531 /* Code. */ 2532 2533 if( reason != XTM_FI_REASON_APPLY && reason != XTM_FI_REASON_OK ) 2534 return; 2535 2536 sched_ref = (SCHED_REC_REF) user_data; 2537 2538 2539 /* Save the filter. */ 2540 memcpy( (void *) &sched_ref -> filter_rec, 2541 (void *) filter_ref, 2542 sizeof( XTM_DM_FILTER_REC ) ); 2543 2544 2545 /* Display the schedule again ... */ 2546 applyCB( sched_ref -> scheduleW, sched_ref, NULL ); 2547 2548 2549 return; 2550 2551 } /* filterApplyCB */ 2552 2553 2554 /*----------------------------------------------------------------------*/ 2555 2556 static void includeDbApplyCB(XTM_DI_REASON reason,XTM_CD_INCL_CALS_REF new_db_incl_ref,void * user_data)2557 includeDbApplyCB( XTM_DI_REASON reason, 2558 XTM_CD_INCL_CALS_REF new_db_incl_ref, 2559 void *user_data ) 2560 { 2561 2562 /* Variables. */ 2563 SCHED_REC_REF sched_ref; 2564 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 2565 XTM_CD_CAL_INFO db_info; 2566 XTM_CD_INCL_CALS db_incl; 2567 2568 2569 /* Code. */ 2570 2571 if( reason != XTM_DI_REASON_APPLY && reason != XTM_DI_REASON_OK ) 2572 return; 2573 2574 sched_ref = (SCHED_REC_REF) user_data; 2575 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 2576 2577 2578 /* Fetch the current database. */ 2579 (void) xtmCdFetchNamedDb( custom_data_ref -> cal_db_handle, 2580 sched_ref -> db_name, 2581 &db_info, &db_incl ); 2582 2583 /* Save the new include data. */ 2584 (void) xtmCdChangeEntry( custom_data_ref -> cal_db_handle, 2585 sched_ref -> db_name, 2586 &db_info, new_db_incl_ref ); 2587 2588 /* Redisplay. */ 2589 applyCB( sched_ref -> scheduleW, sched_ref, NULL ); 2590 2591 2592 return; 2593 2594 } /* includeDbApplyCB */ 2595 2596 2597 /*----------------------------------------------------------------------*/ 2598 2599 static void infoCB(Widget widget,SCHED_REC_REF sched_ref,XmRowColumnCallbackStruct * call_data)2600 infoCB( Widget widget, 2601 SCHED_REC_REF sched_ref, 2602 XmRowColumnCallbackStruct *call_data ) 2603 { 2604 2605 /* Code. */ 2606 2607 /* About window? */ 2608 if( (intptr_t) call_data -> data == 6 ) { 2609 xtmHlDisplayAboutWindow( sched_ref -> scheduleW ); 2610 2611 return; 2612 } 2613 2614 /* Use the standard help. */ 2615 xtmHlDisplayHelp( sched_ref -> appl_data_ref -> info_handle, 2616 (intptr_t) call_data -> data, 2617 day_view_window_id, "" ); 2618 2619 return; 2620 2621 } /* infoCB */ 2622 2623 2624 /*----------------------------------------------------------------------*/ 2625 2626 static void leaveHookCB(Widget widget,XEvent * event,char * leave_args[],Cardinal * num_args)2627 leaveHookCB( Widget widget, 2628 XEvent *event, 2629 char *leave_args[], 2630 Cardinal *num_args ) 2631 { 2632 2633 /* Variables. */ 2634 UINT32 flags = 0; 2635 Arg args[ 10 ]; 2636 Cardinal n; 2637 Dimension animate_height; 2638 Dimension animate_width; 2639 Position start_x = 0; 2640 Position start_y = 0; 2641 Time time_now; 2642 Widget animateBaseW; 2643 Widget mainW; 2644 ENTRY_INFO *entry_info_ref; 2645 SCHED_REC_REF sched_ref; 2646 XTM_GL_BASE_DATA_REF appl_data_ref; 2647 2648 2649 /* Code. */ 2650 2651 /* Only for push buttons. */ 2652 if( ! xitRwIsPixButton( widget ) ) 2653 return; 2654 2655 /* Only if armed. */ 2656 if( ! xitRwPixButIsArmed( widget ) ) 2657 return; 2658 2659 /* Get reference to our user data. */ 2660 #ifdef XD_HAS_NO_PRINTF_PTR 2661 sscanf( leave_args[ 1 ], "%d", &sched_ref ); 2662 #else 2663 sscanf( leave_args[ 1 ], "%p", &sched_ref ); 2664 #endif 2665 2666 appl_data_ref = sched_ref -> appl_data_ref; 2667 2668 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 2669 2670 2671 /* Only activate move if leaving the window with Btn(1|2) pressed. */ 2672 if( event -> xany.type != LeaveNotify ) 2673 return; 2674 2675 if( flagIsClear( event -> xcrossing.state, (Button1Mask | Button2Mask) ) ) 2676 return; 2677 2678 /* Don't get double events. */ 2679 time_now = event -> xcrossing.time; 2680 2681 if( abs( time_now - time_last ) < 2000 && time_last != 0 ) { 2682 time_last = time_now; 2683 return; 2684 } 2685 2686 time_last = time_now; 2687 2688 2689 /* Force the button to let go of the pointer events. */ 2690 XUngrabPointer( XtDisplay( widget ), CurrentTime ); 2691 2692 2693 /* Get the bounds of the animation cursor. */ 2694 n = 0; 2695 XtSetArg( args[ n ], XmNwidth, &animate_width ); n++; 2696 XtSetArg( args[ n ], XmNheight, &animate_height ); n++; 2697 XtGetValues( widget, args, n ); 2698 2699 2700 /* Valid action? */ 2701 if( flagIsSet( event -> xcrossing.state, Button1Mask ) ) { 2702 if( strcmp( leave_args[ 0 ], "Note" ) == 0 ) 2703 return; 2704 2705 if( flagIsSet( sched_ref -> flags, XTM_SM_LIST_LAYOUT ) ) 2706 return; 2707 } 2708 2709 2710 /* Make sure the entry is selected. */ 2711 if( sched_ref -> selected_widget != widget ) { 2712 xtmSwUnselectEntry( sched_ref ); 2713 2714 n = 0; 2715 XtSetArg( args[ n ], XmNbackground, &sched_ref -> entry_saved_bg ); n++; 2716 XtGetValues( widget, args, n ); 2717 2718 n = 0; 2719 XtSetArg( args[ n ], XmNbackground, 2720 appl_data_ref -> custom_data -> entry_select_bg ); n++; 2721 XtSetValues( widget, args, n ); 2722 2723 sched_ref -> selected_widget = widget; 2724 } 2725 2726 2727 /* Fetch information for the entry. */ 2728 entry_info_ref = xtmStFetchSelectedInfo( sched_ref ); 2729 if( entry_info_ref == NULL ) 2730 return; 2731 2732 2733 /* New duration? */ 2734 if( flagIsSet( event -> xcrossing.state, Button1Mask ) ) { 2735 2736 TIM_DELTA_TYPE delta_time; 2737 2738 (void) TimDelta( sched_ref -> schedule_start, 2739 entry_info_ref -> date_stamp, &delta_time ); 2740 2741 start_x = xtmStPositionEntryX( sched_ref, delta_time.days ); 2742 start_y = xtmStPositionEntryY( sched_ref, entry_info_ref -> time_stamp ); 2743 2744 animate_width = (Dimension) sched_ref -> day_width - 14; 2745 2746 flagSet( flags, ANI_NEW_DURATION ); 2747 } 2748 2749 /* Move/copy entry. */ 2750 if( flagIsSet( event -> xcrossing.state, Button2Mask ) ) { 2751 flagSet( flags, ANI_MOVE_COPY ); 2752 } 2753 2754 2755 /* Animation for notes/entries? */ 2756 if( strcmp( leave_args[ 0 ], "Note" ) == 0 ) { 2757 flagSet( flags, ANI_NOTE ); 2758 2759 animateBaseW = XtNameToWidget( mainW, 2760 "SchedPa.Pane1Fo.NoteSw.ClipWindow.NoteBb" ); 2761 2762 } else { 2763 flagSet( flags, ANI_ENTRY ); 2764 2765 animateBaseW = XtNameToWidget( mainW, 2766 "SchedPa.Pane2Fo.EntrySw.ClipWindow.EntryBb" ); 2767 } 2768 2769 /* Start the animation. */ 2770 xtmSaStartAnimation( sched_ref, event, 2771 flags, animateBaseW, 2772 start_x, start_y, 2773 animate_width, animate_height ); 2774 2775 2776 return; 2777 2778 } /* leaveHookCB */ 2779 2780 2781 /*----------------------------------------------------------------------*/ 2782 2783 static void makeAppointmentCB(Widget widget,SCHED_REC_REF sched_ref,XmAnyCallbackStruct * call_data)2784 makeAppointmentCB( Widget widget, 2785 SCHED_REC_REF sched_ref, 2786 XmAnyCallbackStruct *call_data ) 2787 { 2788 2789 /* Variables. */ 2790 Boolean ok; 2791 TIM_TIME_REF pick_date; 2792 2793 2794 /* Code. */ 2795 2796 if( flagIsSet( call_data -> event -> xbutton.state, ShiftMask ) ) { 2797 pick_date = sched_ref -> schedule_start; 2798 2799 } else { 2800 ok = xtmStPickDate( sched_ref, XTM_ST_PICK_APP, &pick_date ); 2801 if( ! ok ) 2802 return; 2803 } 2804 2805 2806 /* Create an appointment. */ 2807 xtmSwUnselectEntry( sched_ref ); 2808 2809 xtmSaAppointmentEditorShow( sched_ref ); 2810 2811 /* Set the correct date. */ 2812 xtmEdSetValues( sched_ref -> editor_handle, 2813 XTM_ED_SET_DATE, pick_date, 0, 0, "" ); 2814 2815 2816 return; 2817 2818 } /* makeAppointmentCB */ 2819 2820 2821 /*----------------------------------------------------------------------*/ 2822 2823 static void makeNoteCB(Widget widget,SCHED_REC_REF sched_ref,XmAnyCallbackStruct * call_data)2824 makeNoteCB( Widget widget, 2825 SCHED_REC_REF sched_ref, 2826 XmAnyCallbackStruct *call_data ) 2827 { 2828 2829 /* Variables. */ 2830 Boolean ok; 2831 TIM_TIME_REF pick_date; 2832 2833 2834 /* Code. */ 2835 2836 if( flagIsSet( call_data -> event -> xbutton.state, ShiftMask ) ) { 2837 pick_date = sched_ref -> schedule_start; 2838 2839 } else { 2840 ok = xtmStPickDate( sched_ref, XTM_ST_PICK_NOTE, &pick_date ); 2841 if( ! ok ) 2842 return; 2843 } 2844 2845 2846 /* Create a note. */ 2847 xtmSwUnselectEntry( sched_ref ); 2848 2849 xtmSaAppointmentEditorShow( sched_ref ); 2850 2851 /* Make sure we are editing a note. */ 2852 xtmEdSetValues( sched_ref -> editor_handle, 2853 (XTM_ED_SET_IS_NOTE | XTM_ED_SET_DATE), pick_date, 2854 0, 0, "" ); 2855 2856 2857 return; 2858 2859 } /* makeNoteCB */ 2860 2861 2862 /*----------------------------------------------------------------------*/ 2863 2864 static void navigateCB(Widget widget,SCHED_REC_REF sched_ref,XmUbArrowLabelCallbackStruct * call_data)2865 navigateCB( Widget widget, 2866 SCHED_REC_REF sched_ref, 2867 XmUbArrowLabelCallbackStruct *call_data ) 2868 { 2869 2870 /* Variables. */ 2871 Widget baseW; 2872 Widget mainW; 2873 Widget tempW; 2874 TIM_TIME_REF schedule_start; 2875 2876 2877 /* Code. */ 2878 2879 baseW = xitGetParentWidget( widget, "SchedTl" ); 2880 if( baseW == NULL ) 2881 return; 2882 2883 mainW = XtNameToWidget( baseW, "SchedTlBase.SchedTlFo" ); 2884 2885 schedule_start = sched_ref -> schedule_start; 2886 2887 /* Previous/next day? */ 2888 tempW = XtNameToWidget( mainW, "NavFo.NavDayAl" ); 2889 if( tempW == widget ) { 2890 if( call_data -> reason == XmUbCR_BACK_ARROW_ACTIVATED ) 2891 TimAddDays( &schedule_start, -1 ); 2892 else 2893 TimAddDays( &schedule_start, 1 ); 2894 } 2895 2896 /* Previous/next week? */ 2897 tempW = XtNameToWidget( mainW, "NavFo.NavWeekAl" ); 2898 if( tempW == widget ) { 2899 if( call_data -> reason == XmUbCR_BACK_ARROW_ACTIVATED ) 2900 TimAddDays( &schedule_start, -7 ); 2901 else 2902 TimAddDays( &schedule_start, 7 ); 2903 } 2904 2905 /* Previous/next month? */ 2906 tempW = XtNameToWidget( mainW, "NavFo.NavMonthAl" ); 2907 if( tempW == widget ) { 2908 if( call_data -> reason == XmUbCR_BACK_ARROW_ACTIVATED ) 2909 TimAddMonths( &schedule_start, -1 ); 2910 else 2911 TimAddMonths( &schedule_start, 1 ); 2912 } 2913 2914 /* Previous/next year? */ 2915 tempW = XtNameToWidget( mainW, "NavFo.NavYearAl" ); 2916 if( tempW == widget ) { 2917 if( call_data -> reason == XmUbCR_BACK_ARROW_ACTIVATED ) 2918 TimAddYears( &schedule_start, -1 ); 2919 else 2920 TimAddYears( &schedule_start, 1 ); 2921 } 2922 2923 2924 /* Within limits? */ 2925 if( TimIndexOfYear( schedule_start ) < 1971 ) { 2926 XBell( XtDisplay( widget ), 100 ); 2927 2928 return; 2929 } 2930 2931 /* Update the day view. */ 2932 sched_ref -> schedule_start = schedule_start; 2933 2934 xtmSwSetScheduleDates( sched_ref, widget, False ); 2935 xtmSwSetSchedule( sched_ref, widget ); 2936 2937 2938 return; 2939 2940 } /* navigateCB */ 2941 2942 2943 /*----------------------------------------------------------------------*/ 2944 2945 static void newViewApplyCB(XTM_OV_REASON reason,XTM_CD_CAL_INFO * db_info_ref,void * user_data)2946 newViewApplyCB( XTM_OV_REASON reason, 2947 XTM_CD_CAL_INFO *db_info_ref, 2948 void *user_data ) 2949 { 2950 2951 /* Variables. */ 2952 SCHED_REC_REF sched_ref; 2953 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 2954 2955 2956 /* Code. */ 2957 2958 if( reason != XTM_OV_REASON_APPLY && reason != XTM_OV_REASON_OK ) 2959 return; 2960 2961 sched_ref = (SCHED_REC_REF) user_data; 2962 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 2963 2964 2965 /* Remove navigation calendar? */ 2966 if( sched_ref -> nav_cal_handle != NULL ) 2967 xtmNcDestroy( sched_ref -> nav_cal_handle ); 2968 2969 2970 /* Free the shadow calendar. */ 2971 xtmCdFreeShadowEntry( custom_data_ref -> cal_db_handle, 2972 sched_ref -> db_name ); 2973 2974 2975 /* Create a shadow calendar database. */ 2976 (void) xtmCdCreateShadowEntry( custom_data_ref -> cal_db_handle, 2977 db_info_ref -> short_name, 2978 sched_ref -> db_name ); 2979 2980 /* Redisplay. */ 2981 applyCB( sched_ref -> scheduleW, sched_ref, NULL ); 2982 2983 2984 return; 2985 2986 } /* newViewApplyCB */ 2987 2988 2989 /*----------------------------------------------------------------------*/ 2990 2991 static void optionsMenuCB(Widget widget,SCHED_REC_REF sched_ref,XmRowColumnCallbackStruct * call_data)2992 optionsMenuCB( Widget widget, 2993 SCHED_REC_REF sched_ref, 2994 XmRowColumnCallbackStruct *call_data ) 2995 { 2996 2997 /* Variables. */ 2998 Widget mainW; 2999 ENTRY_INFO *entry_info_ref; 3000 TIM_TIME_REF start_date; 3001 XTM_GL_BASE_DATA_REF appl_data_ref; 3002 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 3003 XTM_CD_CAL_INFO db_info; 3004 3005 3006 /* Code. */ 3007 3008 appl_data_ref = sched_ref -> appl_data_ref; 3009 custom_data_ref = appl_data_ref -> custom_data; 3010 3011 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 3012 3013 entry_info_ref = xtmStFetchSelectedInfo( sched_ref ); 3014 3015 3016 /* Fetch the current database. */ 3017 (void) xtmCdFetchNamedDb( custom_data_ref -> cal_db_handle, 3018 sched_ref -> db_name, 3019 &db_info, NULL ); 3020 3021 3022 /* Select what to do. */ 3023 switch( (intptr_t) call_data -> data ) { 3024 3025 /* Appointment editor. */ 3026 case 0: 3027 xtmSaAppointmentEditorShow( sched_ref ); 3028 break; 3029 3030 3031 /* Summary window. */ 3032 case 1: 3033 if( sched_ref -> show_handle == NULL ) 3034 sched_ref -> show_handle = xtmSdInitialize( 3035 appl_data_ref, 3036 appl_data_ref -> toplevel, 3037 sched_ref -> db_name, 3038 summaryActionCB, (void *) sched_ref ); 3039 3040 if( sched_ref -> show_handle == NULL ) 3041 return; 3042 3043 /* Display the summary. */ 3044 xtmSdDisplaySummary( sched_ref -> show_handle, 3045 sched_ref -> schedule_start, 3046 sched_ref -> schedule_stop, 3047 db_info.view_tags ); 3048 break; 3049 3050 3051 /* Send message. */ 3052 case 2: 3053 if( appl_data_ref -> msg_send_handle == NULL ) 3054 appl_data_ref -> msg_send_handle = 3055 xtmMsInitialize( appl_data_ref, appl_data_ref -> toplevel ); 3056 3057 /* The message window. */ 3058 if( entry_info_ref == NULL ) 3059 xtmMsSendMessage( appl_data_ref -> msg_send_handle, 3060 "", 0 ); 3061 else 3062 xtmMsSendMessage( appl_data_ref -> msg_send_handle, 3063 entry_info_ref -> db_name, 3064 entry_info_ref -> id ); 3065 break; 3066 3067 3068 /* Planner window. */ 3069 case 3: 3070 if( sched_ref -> planner_handle == NULL ) 3071 sched_ref -> planner_handle = xtmPlInitialize( 3072 appl_data_ref, 3073 appl_data_ref -> toplevel, 3074 NULL, NULL ); 3075 if( sched_ref -> planner_handle == NULL ) 3076 return; 3077 3078 /* Planner for the current month. */ 3079 start_date = TimMakeTime( TimIndexOfYear( sched_ref -> schedule_start ), 3080 TimIndexOfMonth( sched_ref -> schedule_start ), 3081 TimIndexOfDay( sched_ref -> schedule_start ), 3082 0, 0, 0 ); 3083 3084 /* Display the planner window. */ 3085 xtmPlViewPlanner( sched_ref -> planner_handle, start_date, False ); 3086 break; 3087 3088 3089 /* Redisplay schedule. */ 3090 case 5: 3091 if( sched_ref -> animate_ref != NULL ) 3092 sched_ref -> animate_ref -> animate_on = False; 3093 3094 sched_ref -> force_update = True; 3095 xtmUpDoUpdate( (XTM_UP_CALENDAR | XTM_UP_SCHEDULE), NULL ); 3096 break; 3097 3098 } /* switch */ 3099 3100 3101 return; 3102 3103 } /* optionsMenuCB */ 3104 3105 3106 /*----------------------------------------------------------------------*/ 3107 3108 static void printerActionCB(XTM_PR_REASON reason,void * user_data)3109 printerActionCB( XTM_PR_REASON reason, 3110 void *user_data ) 3111 { 3112 3113 /* Variables. */ 3114 SCHED_REC_REF sched_ref; 3115 3116 3117 /* Code. */ 3118 3119 sched_ref = (SCHED_REC_REF) user_data; 3120 3121 if( reason == XTM_PR_REASON_DESTROY ) 3122 sched_ref -> pr_handle = NULL; 3123 3124 3125 return; 3126 3127 } /* printerActionCB */ 3128 3129 3130 /*----------------------------------------------------------------------*/ 3131 3132 static void selHideApplyCB(XTM_SH_REASON reason,UINT32 entry_id,char * calendar,TIM_TIME_REF as_date,TIM_TIME_REF as_time,void * user_data)3133 selHideApplyCB( XTM_SH_REASON reason, 3134 UINT32 entry_id, 3135 char *calendar, 3136 TIM_TIME_REF as_date, 3137 TIM_TIME_REF as_time, 3138 void *user_data ) 3139 { 3140 3141 /* Variables. */ 3142 SCHED_REC_REF sched_ref; 3143 3144 3145 /* Code. */ 3146 3147 sched_ref = (SCHED_REC_REF) user_data; 3148 3149 /* Window destroyed? */ 3150 if( reason == XTM_SH_REASON_DESTROY ) { 3151 sched_ref -> sel_hide_handle = NULL; 3152 return; 3153 } 3154 3155 /* Edit entry? */ 3156 if( reason == XTM_SH_REASON_EDIT ) 3157 xtmSaAppointmentEditorShowFor( sched_ref, 3158 entry_id, calendar, as_date, as_time ); 3159 3160 3161 return; 3162 3163 } /* selHideApplyCB */ 3164 3165 3166 /*----------------------------------------------------------------------*/ 3167 3168 static void summaryActionCB(XTM_SD_REASON reason,void * user_data)3169 summaryActionCB( XTM_SD_REASON reason, 3170 void *user_data ) 3171 { 3172 3173 /* Variables. */ 3174 SCHED_REC_REF sched_ref; 3175 3176 3177 /* Code. */ 3178 3179 sched_ref = (SCHED_REC_REF) user_data; 3180 3181 if( reason == XTM_SD_REASON_DESTROY ) 3182 sched_ref -> show_handle = NULL; 3183 3184 3185 return; 3186 3187 } /* summaryActionCB */ 3188 3189 3190 /*----------------------------------------------------------------------*/ 3191 3192 static void timeActionHookCB(Widget widget,SCHED_REC_REF sched_ref,XEvent * event)3193 timeActionHookCB( Widget widget, 3194 SCHED_REC_REF sched_ref, 3195 XEvent *event ) 3196 { 3197 3198 /* Variables. */ 3199 Widget mainW; 3200 Widget timeDispBbW; 3201 Widget timeDispLaW; 3202 Widget timeDispSwW; 3203 3204 3205 /* Code. */ 3206 3207 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 3208 3209 /* No animation in list mode. */ 3210 if( flagIsSet( sched_ref -> flags, XTM_SM_LIST_LAYOUT ) ) 3211 return; 3212 3213 /* Only activate when Btn1 pressed. */ 3214 if( event -> xany.type != ButtonPress || event -> xbutton.button != 1 ) 3215 return; 3216 3217 3218 /* Information to use in the animation. */ 3219 timeDispSwW = XtNameToWidget( mainW, "SchedPa.Pane2Fo.TimeDispSw" ); 3220 3221 timeDispLaW = XtNameToWidget( timeDispSwW, "ClipWindow" ); 3222 timeDispBbW = XtNameToWidget( timeDispLaW, "TimeDispBb" ); 3223 timeDispLaW = XtNameToWidget( timeDispLaW, "TimeDispLa" ); 3224 3225 /* Start animation as if new entry. */ 3226 xtmSaStartAnimation( sched_ref, event, 3227 (ANI_TIME | ANI_NEW_ENTRY | ANI_PICK_DAY), 3228 timeDispBbW, 3229 1, 0, 6, 0 ); 3230 3231 3232 return; 3233 3234 } /* timeActionHookCB */ 3235 3236 3237 /*----------------------------------------------------------------------*/ 3238 3239 static void updateCB(UINT32 flags,void * user_data,void * update_user_data)3240 updateCB( UINT32 flags, 3241 void *user_data, 3242 void *update_user_data ) 3243 { 3244 3245 /* Variables. */ 3246 int day_no; 3247 Widget mainW; 3248 ANIMATE_REC_REF animate_ref; 3249 SCHED_REC_REF sched_ref; 3250 XTM_GL_CUSTOM_DATA_REF custom_data_ref; 3251 TIM_TIME_REF use_time; 3252 3253 /* Code. */ 3254 3255 /* Our private data. */ 3256 sched_ref = (SCHED_REC_REF) user_data; 3257 3258 animate_ref = sched_ref -> animate_ref; 3259 custom_data_ref = sched_ref -> appl_data_ref -> custom_data; 3260 3261 mainW = XtNameToWidget( sched_ref -> scheduleW, "SchedTlBase.SchedTlFo" ); 3262 3263 3264 /* If we are already doing animation, don't do updates. */ 3265 if( animate_ref != NULL && animate_ref -> animate_on ) 3266 return; 3267 3268 3269 /* Update schedule? */ 3270 if( flagIsSet( flags, XTM_UP_SCHEDULE ) ) 3271 xtmSwSetSchedule( sched_ref, sched_ref -> scheduleW ); 3272 3273 3274 /* New day? */ 3275 if( flagIsSet( flags, XTM_UP_NEW_DAY ) ) { 3276 3277 use_time = TimLocalTime( TimMakeTimeNow() ); 3278 day_no = TimIndexOfDayInIsoWeek( use_time ); 3279 3280 if( custom_data_ref -> day_view_day_switch == 0 || 3281 custom_data_ref -> day_view_day_switch - 1 == day_no ) { 3282 3283 sched_ref -> schedule_start = TimMakeTime( TimIndexOfYear( use_time ), 3284 TimIndexOfMonth( use_time ), 3285 TimIndexOfDay( use_time ), 3286 0, 0, 0 ); 3287 3288 xtmSwSetScheduleDates( sched_ref, sched_ref -> scheduleW, False ); 3289 xtmSwSetSchedule( sched_ref, sched_ref -> scheduleW ); 3290 3291 } 3292 3293 } /* if */ 3294 3295 3296 /* A simple minute tick? */ 3297 if( flagIsSet( flags, (XTM_UP_MINUTE_TICK | XTM_UP_SCHEDULE) ) ) 3298 xtmStUpdateMinuteMarker( sched_ref ); 3299 3300 3301 return; 3302 3303 } /* updateCB */ 3304 3305 3306 /*----------------------------------------------------------------------*/ 3307 3308 static void zoomCB(Widget widget,SCHED_REC_REF sched_ref,XtPointer call_data)3309 zoomCB( Widget widget, 3310 SCHED_REC_REF sched_ref, 3311 XtPointer call_data ) 3312 { 3313 3314 /* Variables. */ 3315 int hours; 3316 int minutes; 3317 char *char_ref; 3318 Widget baseW; 3319 Widget mainW; 3320 Widget tempW; 3321 3322 3323 /* Code. */ 3324 3325 baseW = xitGetParentWidget( widget, "SchedTl" ); 3326 if( baseW == NULL ) 3327 return; 3328 3329 mainW = XtNameToWidget( baseW, "SchedTlBase.SchedTlFo" ); 3330 3331 3332 /* Fetch the zoom string. */ 3333 tempW = XtNameToWidget( mainW, "SchedPa.Pane2Fo.ZoomFs" ); 3334 3335 xitFieldSelectGetCurrent( tempW, &char_ref ); 3336 if( char_ref == NULL ) 3337 return; 3338 3339 sscanf( char_ref, "%d:%d", &hours, &minutes ); 3340 3341 sched_ref -> entry_delta = (hours * 60) + minutes; 3342 3343 /* Redisplay the schedule. */ 3344 xtmSwSetSchedule( sched_ref, sched_ref -> scheduleW ); 3345 3346 SysFree( char_ref ); 3347 3348 3349 return; 3350 3351 } /* zoomCB */ 3352