1 /******************************************************************************
2 * DESCRIPTION: Dinotrace source: window scrolling, etc
3 *
4 * This file is part of Dinotrace.
5 *
6 * Author: Wilson Snyder <wsnyder@wsnyder.org>
7 *
8 * Code available from: http://www.veripool.org/dinotrace
9 *
10 ******************************************************************************
11 *
12 * Some of the code in this file was originally developed for Digital
13 * Semiconductor, a division of Digital Equipment Corporation. They
14 * gratefuly have agreed to share it, and thus the base version has been
15 * released to the public with the following provisions:
16 *
17 *
18 * This software is provided 'AS IS'.
19 *
20 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THE INFORMATION
21 * (INCLUDING ANY SOFTWARE) PROVIDED, INCLUDING ALL IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE, AND
23 * NON-INFRINGEMENT. DIGITAL NEITHER WARRANTS NOR REPRESENTS THAT THE USE
24 * OF ANY SOURCE, OR ANY DERIVATIVE WORK THEREOF, WILL BE UNINTERRUPTED OR
25 * ERROR FREE. In no event shall DIGITAL be liable for any damages
26 * whatsoever, and in particular DIGITAL shall not be liable for special,
27 * indirect, consequential, or incidental damages, or damages for lost
28 * profits, loss of revenue, or loss of use, arising out of or related to
29 * any use of this software or the information contained in it, whether
30 * such damages arise in contract, tort, negligence, under statute, in
31 * equity, at law or otherwise. This Software is made available solely for
32 * use by end users for information and non-commercial or personal use
33 * only. Any reproduction for sale of this Software is expressly
34 * prohibited. Any rights not expressly granted herein are reserved.
35 *
36 ******************************************************************************
37 *
38 * Changes made over the basic version are covered by the GNU public licence.
39 *
40 * Dinotrace is free software; you can redistribute it and/or modify
41 * it under the terms of the GNU General Public License as published by
42 * the Free Software Foundation; either version 3, or (at your option)
43 * any later version.
44 *
45 * Dinotrace is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU General Public License for more details.
49 *
50 * You should have received a copy of the GNU General Public License
51 * along with Dinotrace; see the file COPYING. If not, write to
52 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
53 * Boston, MA 02111-1307, USA.
54 *
55 *****************************************************************************/
56
57 #include "dinotrace.h"
58
59 #include <Xm/RowColumnP.h>
60 #include <Xm/LabelP.h>
61 #include <Xm/CascadeBP.h>
62 #include <Xm/BulletinB.h>
63 #include <Xm/PushB.h>
64 #include <Xm/PushBG.h>
65 #include <Xm/ToggleB.h>
66 #include <Xm/Text.h>
67 #include <Xm/Form.h>
68 #include <Xm/Separator.h>
69
70 #include "functions.h"
71
72
73 static void win_note_ok_cb (Widget w, Trace_t* trace, XmSelectionBoxCallbackStruct* cb);
74 static void win_note_cancel_cb (Widget w, Trace_t* trace, XmAnyCallbackStruct* cb);
75
76 /****************************** CALLBACKS ******************************/
77
win_expose_cb(Widget w,Trace_t * trace)78 void win_expose_cb (
79 Widget w,
80 Trace_t *trace)
81 {
82 if (DTPRINT_ENTRY) printf ("In win_expose_cb - trace=%p\n",trace);
83 /* special, call draw directly so screen doesn't flicker */
84 draw_expose_needed (trace);
85 }
86
win_resize_cb(Widget w,Trace_t * trace)87 void win_resize_cb (
88 Widget w,
89 Trace_t *trace)
90 {
91 if (DTPRINT_ENTRY) printf ("In win_resize_cb - trace=%p\n",trace);
92 draw_needupd_sig_start ();
93 draw_all_needed (); /* All, as xstart might have changed */
94 }
95
win_refresh_cb(Widget w,Trace_t * trace)96 void win_refresh_cb (
97 Widget w,
98 Trace_t *trace)
99 {
100 if (DTPRINT_ENTRY) printf ("In win_refresh_cb - trace=%p\n",trace);
101 draw_all_needed ();
102 /* Main loop won't refresh if in manual refresh mode */
103 if (global->redraw_manually) draw_perform();
104 }
105
hscroll_unitinc_cb(Widget w)106 void hscroll_unitinc_cb (
107 Widget w)
108 {
109 Trace_t *trace = widget_to_trace(w);
110 if (DTPRINT_ENTRY) printf ("In hscroll_unitinc - trace=%p old_time=%d",trace,global->time);
111 global->time += grid_primary_period (trace);
112 if (DTPRINT_ENTRY) printf (" new time=%d\n",global->time);
113
114 new_time (trace);
115 }
116
hscroll_unitdec_cb(Widget w)117 void hscroll_unitdec_cb (
118 Widget w)
119 {
120 Trace_t *trace = widget_to_trace(w);
121 if (DTPRINT_ENTRY) printf ("In hscroll_unitdec - trace=%p old_time=%d",trace,global->time);
122 global->time -= grid_primary_period (trace);
123 new_time (trace);
124 }
125
hscroll_pageinc_cb(Widget w)126 void hscroll_pageinc_cb (
127 Widget w)
128 {
129 Trace_t *trace = widget_to_trace(w);
130 if (DTPRINT_ENTRY) printf ("In hscroll_pageinc - trace=%p old_time=%d",trace,global->time);
131
132 switch ( global->pageinc ) {
133 case PAGEINC_QUARTER:
134 global->time += (int) ( TIME_WIDTH (trace) /4);
135 break;
136 case PAGEINC_HALF:
137 global->time += (int) ( TIME_WIDTH (trace) /2);
138 break;
139 case PAGEINC_FULL:
140 global->time += (int) ( TIME_WIDTH (trace) );
141 break;
142 }
143
144 if (DTPRINT_ENTRY) printf (" new time=%d\n",global->time);
145
146 new_time (trace);
147 }
148
hscroll_pagedec_cb(Widget w)149 void hscroll_pagedec_cb (
150 Widget w)
151 {
152 Trace_t *trace = widget_to_trace(w);
153 if (DTPRINT_ENTRY) printf ("In hscroll_pagedec - trace=%p old_time=%d pageinc=%d",trace,global->time,global->pageinc);
154
155 switch ( global->pageinc ) {
156 case PAGEINC_QUARTER:
157 global->time -= (int) ( TIME_WIDTH (trace) /4);
158 break;
159 case PAGEINC_HALF:
160 global->time -= (int) ( TIME_WIDTH (trace) /2);
161 break;
162 case PAGEINC_FULL:
163 global->time -= (int) ( TIME_WIDTH (trace) );
164 break;
165 }
166
167 if (DTPRINT_ENTRY) printf (" new time=%d\n",global->time);
168
169 new_time (trace);
170 }
171
hscroll_drag_cb(Widget w)172 void hscroll_drag_cb (
173 Widget w)
174 {
175 Trace_t *trace = widget_to_trace(w);
176 int inc;
177
178 XtSetArg (arglist[0], XmNvalue, &inc);
179 XtGetValues (trace->hscroll,arglist,1);
180
181 global->time = inc;
182
183 new_time (trace);
184 }
185
win_begin_cb(Widget w)186 void win_begin_cb (
187 Widget w)
188 {
189 Trace_t *trace = widget_to_trace(w);
190 if (DTPRINT_ENTRY) printf ("In win_begin_cb trace=%p\n",trace);
191 global->time = trace->start_time;
192 new_time (trace);
193 }
194
win_end_cb(Widget w)195 void win_end_cb (
196 Widget w)
197 {
198 Trace_t *trace = widget_to_trace(w);
199 if (DTPRINT_ENTRY) printf ("In win_end_cb trace=%p\n",trace);
200 global->time = trace->end_time - TIME_WIDTH (trace);
201 new_time (trace);
202 }
203
win_namescroll_change_cb(Widget w)204 void win_namescroll_change_cb (
205 Widget w)
206 {
207 Trace_t *trace = widget_to_trace(w);
208 int inc;
209
210 if (DTPRINT_ENTRY) printf ("In win_namescroll_change trace=%p\n",trace);
211
212 XtSetArg (arglist[0], XmNvalue, &inc);
213 XtGetValues (trace->command.namescroll,arglist,1);
214
215 global->namepos = inc;
216 draw_all_needed();
217 }
218
219 /* Vertically scroll + or - inc lines */
220
vscroll_new(Trace_t * trace,int inc)221 void vscroll_new (
222 Trace_t *trace,
223 int inc) /* Lines to move, signed, +1, -1, or +- n */
224 {
225 uint_t signum;
226 Signal_t *sig_ptr;
227
228 if (DTPRINT_ENTRY) printf ("in vscroll_new inc=%d start=%d\n",inc,trace->numsigstart);
229
230 /* Move to requested position */
231 while ( (inc > 0) && trace->dispsig && trace->dispsig->forward ) {
232 trace->dispsig = trace->dispsig->forward;
233 inc--;
234 }
235 while ( (inc < 0) && trace->dispsig && trace->dispsig->backward ) {
236 trace->dispsig = trace->dispsig->backward;
237 inc++;
238 }
239
240 /* Calculate numsigstart */
241 trace->numsigstart = 0;
242 for (sig_ptr = trace->firstsig; sig_ptr && (sig_ptr != trace->dispsig); sig_ptr = sig_ptr->forward) {
243 trace->numsigstart++;
244 }
245
246 /* If blank space on bottom of screen, scroll to fill it */
247 for (signum=0; (signum < trace->numsigvis) && sig_ptr; sig_ptr = sig_ptr->forward) signum++;
248 while ( (signum < trace->numsigvis) && trace->dispsig && trace->dispsig->backward ) {
249 trace->dispsig = trace->dispsig->backward;
250 signum++;
251 trace->numsigstart--;
252 }
253
254 draw_needed (trace);
255 }
256
vscroll_unitinc_cb(Widget w)257 void vscroll_unitinc_cb (
258 Widget w)
259 {
260 Trace_t *trace = widget_to_trace(w);
261 vscroll_new (trace, 1);
262 }
263
vscroll_unitdec_cb(Widget w)264 void vscroll_unitdec_cb (
265 Widget w)
266 {
267 Trace_t *trace = widget_to_trace(w);
268 vscroll_new (trace, -1);
269 }
270
vscroll_pageinc_cb(Widget w)271 void vscroll_pageinc_cb (
272 Widget w)
273 {
274 Trace_t *trace = widget_to_trace(w);
275 vscroll_new (trace, trace->numsigvis);
276 }
277
vscroll_pagedec_cb(Widget w)278 void vscroll_pagedec_cb (
279 Widget w)
280 {
281 Trace_t *trace = widget_to_trace(w);
282 vscroll_new (trace, -(trace->numsigvis));
283 }
284
vscroll_drag_cb(Widget w)285 void vscroll_drag_cb (
286 Widget w)
287 {
288 Trace_t *trace = widget_to_trace(w);
289 int inc;
290
291 if (DTPRINT_ENTRY) printf ("In vscroll_drag trace=%p\n",trace);
292
293 XtSetArg (arglist[0], XmNvalue, &inc);
294 XtGetValues (trace->vscroll, arglist, 1);
295
296 /*
297 ** The sig pointer is reset to the start and the loop will set
298 ** it to the signal that inc represents
299 */
300 trace->dispsig = trace->firstsig;
301 vscroll_new (trace, inc);
302 }
303
win_chg_res_cb(Widget w)304 void win_chg_res_cb (
305 Widget w)
306 {
307 Trace_t *trace = widget_to_trace(w);
308 if (DTPRINT_ENTRY) printf ("In win_chg_res_cb - trace=%p\n",trace);
309 get_data_popup (trace,"Resolution",IO_RES);
310 }
311
312
new_res(Trace_t * trace,float res_new)313 void new_res (
314 Trace_t *trace,
315 float res_new) /* Desired res, pass global->res to not change */
316 {
317 char string[MAXTIMELEN+30], timestrg[MAXTIMELEN];
318
319 if (DTPRINT_ENTRY) printf ("In new_res - res = %f\n",res_new);
320
321 if (res_new != global->res) {
322 global->res_default = FALSE; /* Has changed */
323 global->res = res_new;
324 }
325
326 if (global->res==0.0) global->res=0.1; /* prevent div zero error */
327
328 for (trace = global->trace_head; trace; trace = trace->next_trace) {
329 if (trace->toplevel) {
330 /* change res button's value */
331 time_to_string (trace, timestrg, (int)(RES_SCALE/global->res), TRUE);
332 sprintf (string,"Res=%s %s", timestrg,
333 time_units_to_string (global->timerep, FALSE));
334 XtSetArg (arglist[0],XmNlabelString,XmStringCreateSimple (string));
335 XtSetValues (trace->command.reschg_but,arglist,1);
336 }
337 }
338
339 draw_all_needed ();
340 }
341
win_inc_res_cb(Widget w)342 void win_inc_res_cb (
343 Widget w)
344 {
345 Trace_t *trace = widget_to_trace(w);
346 if (DTPRINT_ENTRY) printf ("In win_inc_res_cb - trace=%p\n",trace);
347
348 /* increase the resolution by 10% */
349 new_res (trace, global->res * 1.1);
350 }
351
win_dec_res_cb(Widget w)352 void win_dec_res_cb (
353 Widget w)
354 {
355 Trace_t *trace = widget_to_trace(w);
356 if (DTPRINT_ENTRY) printf ("In win_dec_res_cb - trace=%p\n",trace);
357
358 /* decrease the resolution by 10% */
359 new_res (trace, global->res * 0.9);
360 }
361
win_full_res_cb(Widget w)362 void win_full_res_cb (
363 Widget w)
364 {
365 Trace_t *trace = widget_to_trace(w);
366 win_full_res (trace);
367 }
368
win_full_res(Trace_t * trace)369 void win_full_res (
370 Trace_t *trace)
371 {
372 if (DTPRINT_ENTRY) printf ("In win_full_res_cb - trace=%p\n",trace);
373
374 /* printf ("%d %d %d %d %d\n",
375 global->xstart, trace->width,XMARGIN, trace->end_time, trace->start_time); */
376
377 /* xstart matters, so recalc if needed */
378 draw_update();
379
380 /* set resolution */
381 if (trace->end_time != trace->start_time) {
382 global->time = trace->start_time;
383 new_res (trace,
384 ( ((float)(trace->width - global->xstart - XMARGIN)) /
385 ((float)(trace->end_time - trace->start_time)) )
386 );
387 new_time (trace);
388 }
389 }
390
win_zoom_res_cb(Widget w)391 void win_zoom_res_cb (
392 Widget w)
393 {
394 Trace_t *trace = widget_to_trace(w);
395 if (DTPRINT_ENTRY) printf ("In win_zoom_res_cb - trace=%p\n",trace);
396
397 /* process all subsequent button presses as res_zoom clicks */
398 global->click_time = -1; /* time must be signed */
399 remove_all_events (trace);
400 set_cursor (DC_ZOOM_1);
401 add_event (ButtonPressMask, res_zoom_click_ev);
402 }
403
res_zoom_click_ev(Widget w,Trace_t * trace,XButtonPressedEvent * ev)404 void res_zoom_click_ev (
405 Widget w,
406 Trace_t *trace,
407 XButtonPressedEvent *ev)
408 {
409 DTime_t time;
410
411 if (DTPRINT_ENTRY) printf ("In res_zoom_click1_ev - trace=%p x=%d y=%d b=%d\n",trace,ev->x,ev->y,ev->button);
412 if (ev->type != ButtonPress || (ev->button!=1 && ev->button!=3)) return;
413
414 /* convert x value to a time value */
415 time = posx_to_time (trace, ev->x);
416 if (time<0) return;
417
418 /* If no click time defined, define one and wait for second click */
419 if ( global->click_time < 0) {
420 global->click_time = time;
421 set_cursor (DC_ZOOM_2);
422 return;
423 }
424
425 if (DTPRINT_ENTRY) printf ("click1 = %d, click2 = %d\n",global->click_time, time);
426
427 /* Got 2 clicks, set res */
428 if (time != global->click_time) {
429 /* Swap so time is the max */
430 if (time < global->click_time) {
431 DTime_t tmp;
432 tmp = time;
433 time = global->click_time;
434 global->click_time = tmp;
435 }
436
437 /* Set new res & time */
438 global->time = global->click_time;
439 new_res (trace,
440 ( ((float)(trace->width - global->xstart)) /
441 ((float)(time - global->click_time)) )
442 );
443 new_time (trace);
444 }
445
446 /* remove handlers */
447 remove_all_events (trace);
448 }
449
450 /****************************** NOTES ******************************/
451
win_note(Trace_t * trace,const char * text1,const char * text2,const char * notetext,Boolean_t forcursor)452 void win_note (
453 Trace_t* trace,
454 const char* text1,
455 const char* text2,
456 const char* notetext,
457 Boolean_t forcursor)
458 {
459 char* notestr;
460
461 if (DTPRINT_ENTRY) printf ("in win_note\n");
462
463 trace->note.forcursor = forcursor;
464
465 if (!trace->note.dialog) {
466 XtSetArg (arglist[0], XmNdefaultPosition, TRUE);
467 XtSetArg (arglist[1], XmNdialogTitle, XmStringCreateSimple ("Note Change") );
468 XtSetArg (arglist[2], XmNverticalSpacing, 10);
469 XtSetArg (arglist[3], XmNhorizontalSpacing, 10);
470 trace->note.dialog = XmCreateFormDialog (trace->work,"note",arglist,4);
471
472 /* Create label widget for notetext widget */
473 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("Note") );
474 XtSetArg (arglist[1], XmNleftAttachment, XmATTACH_FORM );
475 XtSetArg (arglist[2], XmNleftOffset, 5);
476 XtSetArg (arglist[3], XmNtopAttachment, XmATTACH_FORM );
477 XtSetArg (arglist[4], XmNtopOffset, 5);
478 trace->note.notelabel = XmCreateLabel (trace->note.dialog,"",arglist,5);
479 DManageChild (trace->note.notelabel, trace, MC_NOKEYS);
480
481 /* Create the print note text widget */
482 XtSetArg (arglist[0], XmNrows, 1);
483 XtSetArg (arglist[1], XmNleftAttachment, XmATTACH_FORM );
484 XtSetArg (arglist[2], XmNleftOffset, 5);
485 XtSetArg (arglist[3], XmNcolumns, 30);
486 XtSetArg (arglist[4], XmNtopAttachment, XmATTACH_WIDGET );
487 XtSetArg (arglist[5], XmNtopOffset, 0);
488 XtSetArg (arglist[6], XmNtopWidget, trace->note.notelabel);
489 XtSetArg (arglist[7], XmNresizeHeight, FALSE);
490 XtSetArg (arglist[8], XmNeditMode, XmSINGLE_LINE_EDIT);
491 trace->note.notetext = XmCreateText (trace->note.dialog,"notetext",arglist,9);
492 DAddCallback (trace->note.notetext, XmNactivateCallback, win_note_ok_cb, trace);
493 DManageChild (trace->note.notetext, trace, MC_NOKEYS);
494
495 /* Ok/apply/cancel */
496 ok_apply_cancel (&trace->note.okapply, trace->note.dialog,
497 dmanage_last,
498 (XtCallbackProc)win_note_ok_cb, trace,
499 NULL, NULL,
500 NULL, NULL,
501 (XtCallbackProc)win_note_cancel_cb, trace);
502 }
503
504
505 /* right units */
506 if (!text1) text1="";
507 if (!text2) text2="";
508 if (!notetext) notetext="";
509 notestr = (char*)XtMalloc(100+strlen(text1)+strlen(text2));
510 strcpy(notestr,text1);
511 strcat(notestr,text2);
512 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ((char*)notestr));
513 XtSetValues (trace->note.notelabel, arglist, 1);
514
515 /* Update with current search values */
516 XmTextSetString (trace->note.notetext, (char*)notetext);
517 XtSetValues (trace->note.notetext, arglist, 1);
518
519 /* manage the dialog on the screen */
520 DManageChild (trace->note.dialog, trace, MC_NOKEYS);
521 XSync (global->display,0);
522 }
523
win_note_ok_cb(Widget w,Trace_t * trace,XmSelectionBoxCallbackStruct * cb)524 void win_note_ok_cb (
525 Widget w,
526 Trace_t *trace,
527 XmSelectionBoxCallbackStruct *cb)
528 {
529 char *note = NULL;
530
531 if (DTPRINT_ENTRY) printf ("In win_note_ok_cb - trace=%p\n",trace);
532
533 /* Get value */
534 note = XmTextGetString (trace->note.notetext);
535 DFree (global->select_note);
536 if (!note[0]) note = NULL;
537
538 if (trace->note.forcursor) {
539 cur_note (global->selected_cursor, note);
540 } else {
541 sig_note (global->selected_sig, note);
542 }
543
544 /* unmanage the popup window */
545 XtUnmanageChild (trace->note.dialog);
546 }
547
win_note_cancel_cb(Widget w,Trace_t * trace,XmAnyCallbackStruct * cb)548 void win_note_cancel_cb (
549 Widget w,
550 Trace_t *trace,
551 XmAnyCallbackStruct *cb)
552 {
553 if (DTPRINT_ENTRY) printf ("In win_note_cancel_cb - trace=%p\n",trace);
554
555 /* unmanage the popup on the screen */
556 XtUnmanageChild (trace->note.dialog);
557 }
558
559 /****************************** GOTO ******************************/
560
win_goto_cb(Widget w)561 void win_goto_cb (
562 Widget w)
563 {
564 int i;
565 Trace_t *trace = widget_to_trace(w);
566
567 if (DTPRINT_ENTRY) printf ("In win_goto_cb - trace=%p\n",trace);
568
569 if (!trace->gotos.dialog) {
570 XtSetArg (arglist[0], XmNdefaultPosition, TRUE);
571 XtSetArg (arglist[1], XmNdialogTitle, XmStringCreateSimple ("Goto Time") );
572 XtSetArg (arglist[2], XmNverticalSpacing, 10);
573 XtSetArg (arglist[3], XmNhorizontalSpacing, 10);
574 trace->gotos.dialog = XmCreateFormDialog (trace->work,"goto",arglist,4);
575 DAddCallback (trace->gotos.dialog, XmNmapCallback, win_goto_option_cb, trace);
576
577 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("Time"));
578 XtSetArg (arglist[1], XmNtopAttachment, XmATTACH_FORM );
579 XtSetArg (arglist[2], XmNtopOffset, 5);
580 XtSetArg (arglist[3], XmNleftAttachment, XmATTACH_FORM );
581 XtSetArg (arglist[4], XmNleftOffset, 5);
582 trace->gotos.label1 = XmCreateLabel (trace->gotos.dialog,"label1",arglist,5);
583 DManageChild (trace->gotos.label1, trace, MC_NOKEYS);
584
585 /* create the goto text widget */
586 XtSetArg (arglist[0], XmNrows, 1);
587 XtSetArg (arglist[1], XmNcolumns, 12);
588 XtSetArg (arglist[2], XmNtopAttachment, XmATTACH_FORM );
589 XtSetArg (arglist[3], XmNtopOffset, 5);
590 XtSetArg (arglist[4], XmNleftAttachment, XmATTACH_WIDGET );
591 XtSetArg (arglist[5], XmNleftWidget, trace->gotos.label1 );
592 XtSetArg (arglist[6], XmNresizeHeight, FALSE);
593 XtSetArg (arglist[7], XmNeditMode, XmSINGLE_LINE_EDIT);
594 trace->gotos.text = XmCreateText (trace->gotos.dialog,"textn",arglist,8);
595 DAddCallback (trace->gotos.text, XmNactivateCallback, win_goto_ok_cb, trace);
596 DManageChild (trace->gotos.text, trace, MC_NOKEYS);
597
598 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("ns"));
599 XtSetArg (arglist[1], XmNtopAttachment, XmATTACH_FORM );
600 XtSetArg (arglist[2], XmNtopOffset, 5);
601 XtSetArg (arglist[3], XmNleftAttachment, XmATTACH_WIDGET );
602 XtSetArg (arglist[4], XmNleftWidget, trace->gotos.text );
603 trace->gotos.label2 = XmCreateLabel (trace->gotos.dialog,"label2",arglist,5);
604 DManageChild (trace->gotos.label2, trace, MC_NOKEYS);
605
606 /* Make option menu */
607 trace->gotos.pulldown = XmCreatePulldownMenu (trace->gotos.dialog,"pulldown",arglist,0);
608
609 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("None") );
610 trace->gotos.pulldownbutton[0] =
611 XmCreatePushButtonGadget (trace->gotos.pulldown,"pdbutton0",arglist,1);
612 DAddCallback (trace->gotos.pulldownbutton[0], XmNactivateCallback, win_goto_option_cb, trace);
613 DManageChild (trace->gotos.pulldownbutton[0], trace, MC_NOKEYS);
614
615 for (i=0; i<MAX_SRCH; i++) {
616 XtSetArg (arglist[0], XmNbackground, trace->xcolornums[i] );
617 XtSetArg (arglist[1], XmNmarginRight, 20);
618 XtSetArg (arglist[2], XmNmarginBottom, 4);
619 trace->gotos.pulldownbutton[i+1] =
620 XmCreatePushButton (trace->gotos.pulldown,"",arglist,3);
621 DAddCallback (trace->gotos.pulldownbutton[i+1], XmNactivateCallback, win_goto_option_cb, trace);
622 DManageChild (trace->gotos.pulldownbutton[i+1], trace, MC_NOKEYS);
623 }
624
625 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("Place Cursor:"));
626 XtSetArg (arglist[1], XmNleftAttachment, XmATTACH_FORM );
627 XtSetArg (arglist[2], XmNleftOffset, 5);
628 XtSetArg (arglist[3], XmNtopAttachment, XmATTACH_WIDGET );
629 XtSetArg (arglist[4], XmNtopWidget, trace->gotos.text );
630 XtSetArg (arglist[5], XmNsubMenuId, trace->gotos.pulldown);
631 trace->gotos.options = XmCreateOptionMenu (trace->gotos.dialog,"options",arglist,6);
632 DManageChild (trace->gotos.options, trace, MC_NOKEYS);
633
634
635 /* Create label widget for notetext widget */
636 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("Cursor Note") );
637 XtSetArg (arglist[1], XmNleftAttachment, XmATTACH_FORM );
638 XtSetArg (arglist[2], XmNleftOffset, 5);
639 XtSetArg (arglist[3], XmNtopAttachment, XmATTACH_WIDGET );
640 XtSetArg (arglist[4], XmNtopOffset, 5);
641 XtSetArg (arglist[5], XmNtopWidget, trace->gotos.options);
642 trace->gotos.notelabel = XmCreateLabel (trace->gotos.dialog,"",arglist,6);
643 DManageChild (trace->gotos.notelabel, trace, MC_NOKEYS);
644
645 /* Create the print note text widget */
646 XtSetArg (arglist[0], XmNrows, 1);
647 XtSetArg (arglist[1], XmNleftAttachment, XmATTACH_FORM );
648 XtSetArg (arglist[2], XmNleftOffset, 5);
649 XtSetArg (arglist[3], XmNcolumns, 30);
650 XtSetArg (arglist[4], XmNtopAttachment, XmATTACH_WIDGET );
651 XtSetArg (arglist[5], XmNtopOffset, 0);
652 XtSetArg (arglist[6], XmNtopWidget, trace->gotos.notelabel);
653 XtSetArg (arglist[7], XmNresizeHeight, FALSE);
654 XtSetArg (arglist[8], XmNeditMode, XmSINGLE_LINE_EDIT);
655 trace->gotos.notetext = XmCreateText (trace->gotos.dialog,"notetext",arglist,9);
656 DAddCallback (trace->gotos.notetext, XmNactivateCallback, win_goto_ok_cb, trace);
657 DManageChild (trace->gotos.notetext, trace, MC_NOKEYS);
658
659 /* Ok/apply/cancel */
660 ok_apply_cancel (&trace->gotos.okapply, trace->gotos.dialog,
661 dmanage_last,
662 (XtCallbackProc)win_goto_ok_cb, trace,
663 NULL, NULL,
664 NULL, NULL,
665 (XtCallbackProc)win_goto_cancel_cb, trace);
666 }
667
668 /* right units */
669 XtSetArg (arglist[0], XmNlabelString,
670 XmStringCreateSimple (time_units_to_string (global->timerep, FALSE)));
671 XtSetValues (trace->gotos.label2, arglist, 1);
672
673 /* make right one active */
674 XtSetArg (arglist[0], XmNmenuHistory, trace->gotos.pulldownbutton[global->goto_color + 1]);
675 XtSetValues (trace->gotos.options, arglist, 1);
676 XmTextSetString (trace->gotos.text, "");
677
678 /* Must redraw color box on any exposures */
679 XtAddEventHandler (trace->gotos.dialog, ExposureMask, TRUE,
680 (XtEventHandler)win_goto_option_cb, trace);
681
682 /* manage the dialog on the screen */
683 DManageChild (trace->gotos.dialog, trace, MC_NOKEYS);
684 XSync (global->display,0);
685
686 /* Update button - must be after manage*/
687 win_goto_option_cb (w, trace, NULL);
688 }
689
win_goto_option_cb(Widget w,Trace_t * trace,XmSelectionBoxCallbackStruct * cb)690 void win_goto_option_cb (
691 Widget w,
692 Trace_t *trace,
693 XmSelectionBoxCallbackStruct *cb) /* OR XButtonPressedEvent *ev; */
694 /* Puts the color in the option menu, since Xm does not copy colors on selection */
695 /* Also used as an event callback for exposures */
696 {
697 int i;
698 Widget button;
699 Position x,y,height,width;
700
701 if (DTPRINT_ENTRY) printf ("In win_goto_option_cb - trace=%p\n",trace);
702
703 i = option_to_number(trace->gotos.options, trace->gotos.pulldownbutton, MAX_SRCH);
704
705 if (i <= 0) {
706 /* Put "None" in the button */
707 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("None"));
708 XtSetValues ( XmOptionButtonGadget (trace->gotos.options), arglist, 1);
709 }
710 else {
711 /* Put "Place" in the button */
712 XSetForeground (global->display, trace->gc, trace->xcolornums[i-1]);
713 XtSetArg (arglist[0], XmNlabelString, XmStringCreateSimple ("Place"));
714 XtSetValues ( XmOptionButtonGadget (trace->gotos.options), arglist, 1);
715
716 /* Find the coords of the button */
717 button = XmOptionButtonGadget (trace->gotos.options);
718 x = (((XmCascadeButtonWidget) button)->core.x);
719 y = (((XmCascadeButtonWidget) button)->core.y);
720 width = (((XmCascadeButtonWidget) button)->core.width);
721 height = (((XmCascadeButtonWidget) button)->core.height);
722
723 /* Fill the button with the color */
724 XSetForeground (global->display, trace->gc, trace->xcolornums[i-1]);
725 XFillRectangle (global->display, XtWindow (button), trace->gc,
726 x, y, width, height);
727 }
728 }
729
730
win_goto_ok_cb(Widget w,Trace_t * trace,XmSelectionBoxCallbackStruct * cb)731 void win_goto_ok_cb (
732 Widget w,
733 Trace_t *trace,
734 XmSelectionBoxCallbackStruct *cb)
735 {
736 char *strg;
737 DTime_t time;
738 char *note = NULL;
739
740 if (DTPRINT_ENTRY) printf ("In win_goto_ok_cb - trace=%p\n",trace);
741
742 /* Get menu */
743 global->goto_color = -1 + option_to_number(trace->gotos.options, trace->gotos.pulldownbutton, MAX_SRCH);
744
745 if (DTPRINT_ENTRY) printf ("\tnew goto_color=%d\n",global->goto_color);
746
747 /* Get value */
748 strg = XmTextGetString (trace->gotos.text);
749 time = string_to_time (trace, strg);
750 note = XmTextGetString (trace->gotos.notetext);
751 if (!note[0]) note=NULL;
752
753 /* unmanage the popup window */
754 XtRemoveEventHandler (trace->gotos.dialog, ExposureMask, TRUE,
755 (XtEventHandler)win_goto_option_cb, trace);
756 XtUnmanageChild (trace->gotos.dialog);
757
758 if (time > 0) {
759 /* Center it on the screen */
760 global->time = time - ( TIME_WIDTH (trace) / 2);
761
762 /* Limit time extent */
763 /* V6.3 bug - Don't subtract the window length */
764 if ( time > trace->end_time ) {
765 time = trace->end_time;
766 }
767 if ( time < trace->start_time ) {
768 time = trace->start_time;
769 }
770
771 /* Add cursor if wanted */
772 if (global->goto_color > 0) {
773 /* make the cursor */
774 cur_new (time, global->goto_color, USER, note);
775 }
776
777 new_time (trace);
778 }
779 }
780
win_goto_cancel_cb(Widget w,Trace_t * trace,XmAnyCallbackStruct * cb)781 void win_goto_cancel_cb (
782 Widget w,
783 Trace_t *trace,
784 XmAnyCallbackStruct *cb)
785 {
786 if (DTPRINT_ENTRY) printf ("In win_goto_cancel_cb - trace=%p\n",trace);
787
788 /* unmanage the popup on the screen */
789 XtRemoveEventHandler (trace->gotos.dialog, ExposureMask, TRUE,
790 (XtEventHandler)win_goto_option_cb, trace);
791 XtUnmanageChild (trace->gotos.dialog);
792 }
793
794 /**********************************************************************/
795
debug_toggle_print_cb(Widget w)796 void debug_toggle_print_cb (
797 Widget w)
798 {
799 if (DTPRINT) DTPRINT = 0;
800 else DTPRINT = ~0;
801 printf ("Printing now %d\n",DTPRINT);
802 }
803
804