Clean up tooltips-related warnings by rejiggering how the GtkTooltips instance
[gwave-svn.git] / src / wavewin.c
blobe4f9acdc50163cddce53042b1fac823d19d881c9
1 /*
2 * wavewin.c, part of the gwave waveform viewer tool
4 * Functions in this file set up the main waveform window GUI.
6 * Copyright (C) 1998, 1999, 2000 Stephen G. Tell.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <ctype.h>
25 #include <math.h>
26 #include <setjmp.h>
27 #include <stdarg.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <unistd.h>
32 #include <errno.h>
33 #include <sys/time.h>
34 #include <gtk/gtk.h>
35 #include <guile-gnome-gobject/gobject.h>
37 #include <config.h>
38 #include <scwm_guile.h>
39 #include <gwave.h>
40 #include <wavelist.h>
41 #include <measurebtn.h>
43 #define WAVEWIN_IMPLEMENTATION
44 #include <wavewin.h>
46 #define WAVEPANEL_MIN_WIDTH 400
47 #define WAVEPANEL_MIN_HEIGHT 20
48 #define WAVEPANEL_MAX_REQHEIGHT 400
50 XSCM_HOOK(new_wavewin_hook,"new-wavewin-hook", 0, (),
51 "This hook is invoked with no arguments when the main waveform"
52 "window is first created."
53 "The main purpose of this hook is to allow creation of the"
54 "contents of the menubar and toolbar.");
56 /* create horizontal button box for top of main window */
57 GtkWidget *create_toolbar()
59 GtkWidget *bbox, *btn;
61 bbox = gtk_hbutton_box_new();
62 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START);
63 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
64 gtk_widget_show(bbox);
65 return bbox;
68 /* horizontal box for X-axis labels */
69 GtkWidget *create_xlabel_hbox(WaveTable *wt)
71 GtkWidget *hbox;
72 hbox = gtk_hbox_new(FALSE, 0);
73 wt->xlabel_left = gtk_label_new("0");
74 gtk_box_pack_start(GTK_BOX(hbox), wt->xlabel_left, FALSE, FALSE, 0);
75 gtk_widget_show(wt->xlabel_left);
77 wt->xlabel_right = gtk_label_new("0");
78 gtk_box_pack_end(GTK_BOX(hbox), wt->xlabel_right, FALSE, FALSE, 0);
79 gtk_widget_show(wt->xlabel_right);
81 wt->lab_xlogscale = gtk_label_new("LogX");
82 gtk_box_pack_end(GTK_BOX(hbox), wt->lab_xlogscale, TRUE, FALSE, 0);
84 gtk_widget_show(hbox);
85 return hbox;
88 /* global wtable: GtkTable widget for the main window. */
90 SCM_DEFINE(wtable_start_xval, "wtable-start-xval", 0, 0, 0, (),
91 "Return the X coordinate represented by the left edge of the"
92 "displayed portion of the waveforms")
93 #define FUNC_NAME s_wtable_start_xval
95 return scm_make_real(wtable->start_xval);
97 #undef FUNC_NAME
99 SCM_DEFINE(wtable_end_xval, "wtable-end-xval", 0, 0, 0, (),
100 "Return the X coordinate represented by the right edge of the"
101 "displayed portion of the waveforms")
102 #define FUNC_NAME s_wtable_end_xval
104 return scm_make_real(wtable->end_xval);
106 #undef FUNC_NAME
108 SCM_DEFINE(wtable_min_xval, "wtable-min-xval", 0, 0, 0, (),
109 "return the minimum X coordinate of any displayed waveform")
110 #define FUNC_NAME s_wtable_min_xval
112 return scm_make_real(wtable->min_xval);
114 #undef FUNC_NAME
116 SCM_DEFINE(wtable_max_xval, "wtable-max-xval", 0, 0, 0, (),
117 "return the maximum X coordinate of any displayed waveform")
118 #define FUNC_NAME s_wtable_max_xval
120 return scm_make_real(wtable->max_xval);
122 #undef FUNC_NAME
124 SCM_DEFINE(wtable_vcursor, "wtable-vcursor", 1, 0, 0, (SCM cur),
125 "return the x coordinate where vertical bar cursor CUR is located")
126 #define FUNC_NAME s_wtable_vcursor
128 int icno;
129 VALIDATE_ARG_INT_RANGE_COPY(1, cur, 0, 2, icno);
130 if(!wtable->cursor[icno]->shown)
131 return SCM_BOOL_F;
132 return scm_make_real(wtable->cursor[icno]->xval);
134 #undef FUNC_NAME
136 SCM_DEFINE(set_wtable_vcursor_x, "set-wtable-vcursor!", 2, 0, 0,
137 (SCM cur, SCM x),
138 "Position vertical bar cursor number CUR at X")
139 #define FUNC_NAME s_set_wtable_vcursor_x
141 int icno;
142 double xval;
143 VBCursor *csp;
145 VALIDATE_ARG_INT_RANGE_COPY(1, cur, 0, 2, icno);
146 csp = wtable->cursor[icno];
147 VALIDATE_ARG_DBL_COPY(2, x, xval);
148 if(xval < wtable->min_xval)
149 xval = wtable->min_xval;
150 if(xval > wtable->max_xval)
151 xval = wtable->max_xval;
153 update_cursor(csp, xval);
155 return SCM_UNSPECIFIED;
157 #undef FUNC_NAME
160 * Gtk+ signal handler called when main window scrolled panel table chanes size
161 * try to make the horizontal scrollbar the same width as the drawing
162 * area parts of the panel
164 void
165 wavewin_ptable_size_handler(GtkWidget *w,
166 GtkRequisition *req, gpointer d)
168 WaveTable *wt = (WaveTable *)d;
169 int pwidth, boxwidth;
171 pwidth = wt->panels[0]->drawing->allocation.width;
172 boxwidth = wt->bot_vbox->requisition.width;
174 if(gwave_debug)
175 printf("wavewin_ptable_size_handler: pwidth=%d boxwidth=%d\n",
176 pwidth, boxwidth);
178 if(pwidth > 20 && pwidth != boxwidth)
179 gtk_widget_set_usize(wt->bot_vbox, pwidth, -1);
183 * Gtk+ signal handler called when main window's scrollbar changes size.
184 * try to make the empty glue window the same size, to make everything line up.
187 void
188 wavewin_ptablevsbar_sh_handler(GtkWidget *w,
189 gpointer d)
191 WaveTable *wt = (WaveTable *)d;
192 int pwidth, boxwidth;
193 int vis;
196 pwidth = w->allocation.width + 3;
197 vis = GTK_WIDGET_VISIBLE(w);
198 boxwidth = wt->bot_hbox3->allocation.width;
200 if(gwave_debug)
201 printf("wavewin_ptablevsbar_sh_handler: pwidth=%d vis=%d boxwidth=%d\n",
202 pwidth, vis, boxwidth);
204 if(vis) {
205 if(!GTK_WIDGET_VISIBLE(wt->bot_hbox3))
206 gtk_widget_show(wt->bot_hbox3);
207 if(pwidth > 8 && pwidth != boxwidth)
208 gtk_widget_set_usize(wt->bot_hbox3, pwidth, -1);
209 } else {
210 if(GTK_WIDGET_VISIBLE(wt->bot_hbox3))
211 gtk_widget_hide(wt->bot_hbox3);
215 /* this is a hack and should go away: try to rejigger the bottom of
216 * the window so things line up right.
217 * I don't fully understand the gtk size-management stuff, but experimentaly
218 * this seems to work.
220 void
221 wavewin_bot_fixup()
223 WaveTable *wt = wtable;
225 if(gwave_debug) printf("wavewin_bot_fixup()\n");
227 if(wt) {
228 wavewin_ptable_size_handler(NULL, NULL, (gpointer)wt);
229 wavewin_ptablevsbar_sh_handler(GTK_SCROLLED_WINDOW(wt->vswindow)->vscrollbar, (gpointer)wt);
231 /* I don't know why this works, but without the next three
232 lines, things are still wrong after a window resize */
233 gtk_main_iteration_do(0);
234 wavewin_ptable_size_handler(NULL, NULL, (gpointer)wt);
235 wavewin_ptablevsbar_sh_handler(GTK_SCROLLED_WINDOW(wt->vswindow)->vscrollbar, (gpointer)wt);
240 /* build the GtkTable widget for the main window.
241 * side effect:
242 * creates wtable->table widget and adds the other widgets
243 * to it.
245 void
246 wavewin_build_table(WaveTable *wt)
248 int i;
250 wt->table = gtk_table_new(wtable->npanels,2,FALSE);
251 /* gtk_table_set_row_spacings(GTK_TABLE(wtable->table), 2); */
252 gtk_table_set_col_spacings(GTK_TABLE(wt->table), 4);
253 gtk_widget_show(wt->table);
254 for(i = 0; i < wt->npanels; i++) {
255 WavePanel *wp = wt->panels[i];
257 gtk_table_attach(GTK_TABLE(wt->table), wp->lmvbox,
258 0, 1, i, i+1,
259 GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 1);
261 gtk_table_attach(GTK_TABLE(wt->table), wp->drawing,
262 1, 2, i, i+1,
263 GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 1);
267 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(wt->vswindow),
268 wt->table);
269 gtk_container_set_focus_vadjustment(
270 GTK_CONTAINER (wt->table),
271 gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(wt->vswindow)));
276 * delete waveform window's GtkTable Widget.
277 * arranges so that the child widgets stay around so a new table
278 * can be built with more or fewer panels.
280 void
281 wavewin_destroy_table()
283 int i;
284 /* bump refcount on table's children so they don't get cleaned up */
285 for(i = 0; i < wtable->npanels; i++) {
286 WavePanel *wp = wtable->panels[i];
287 gtk_widget_ref(wp->lmvbox);
288 gtk_container_remove(GTK_CONTAINER(wtable->table), wp->lmvbox);
289 gtk_widget_ref(wp->drawing);
290 gtk_container_remove(GTK_CONTAINER(wtable->table),wp->drawing);
292 gtk_widget_destroy(wtable->table);
293 wtable->table = NULL;
296 /* remove the extra references to wtable's child widgets
297 * that we had to make while rebuilding the table
299 void
300 wavewin_finish_table_rebuild()
302 int i;
303 for(i = 0; i < wtable->npanels; i++) {
304 WavePanel *wp = wtable->panels[i];
306 gtk_widget_unref(wp->lmvbox);
307 gtk_widget_unref(wp->drawing);
311 SCM_DEFINE(get_wavewin, "get-wavewin", 0, 0, 0, (),
312 "Return the GtkWindow object for the main waveform window.")
313 #define FUNC_NAME s_get_wavewin
315 return scm_c_gtype_instance_to_scm(GTK_OBJECT(wtable->window));
317 #undef FUNC_NAME
319 SCM_DEFINE(get_wavewin_toolbar, "get-wavewin-toolbar", 0, 0, 0, (),
320 "Return the GtkHBox object for horizontal box to contain"
321 "function buttons or icons in the main waveform window")
322 #define FUNC_NAME s_get_wavewin_toolbar
324 return scm_c_gtype_instance_to_scm(GTK_OBJECT(wtable->toolbar));
326 #undef FUNC_NAME
328 SCM_DEFINE(get_wavewin_menubar, "get-wavewin-menubar", 0, 0, 0, (),
329 "return the GtkMenuBar object for menubar in the main waveform window")
330 #define FUNC_NAME s_get_wavewin_menubar
332 return scm_c_gtype_instance_to_scm(GTK_OBJECT(wtable->menubar));
334 #undef FUNC_NAME
337 /* construct row of x-axis measurement boxes
339 static GtkWidget *build_xmeasure_hbox(WaveTable *wt)
341 GtkWidget *xmhbox = gtk_hbox_new(FALSE, 0);
343 wt->cursor_mbtn[3] = measure_button_new(NULL, MBF_RECIPCURDIFF);
344 gtk_box_pack_end(GTK_BOX(xmhbox),
345 wt->cursor_mbtn[3]->button, FALSE, FALSE, 0);
347 wt->cursor_mbtn[2] = measure_button_new(NULL, MBF_CURSORDIFF);
348 gtk_box_pack_end(GTK_BOX(xmhbox),
349 wt->cursor_mbtn[2]->button, FALSE, FALSE, 0);
351 wt->cursor_mbtn[1] = measure_button_new(NULL, MBF_CURSOR1);
352 gtk_box_pack_end(GTK_BOX(xmhbox),
353 wt->cursor_mbtn[1]->button, FALSE, FALSE, 0);
355 wt->cursor_mbtn[0] = measure_button_new(NULL, MBF_CURSOR0);
356 gtk_box_pack_end(GTK_BOX(xmhbox),
357 wt->cursor_mbtn[0]->button, FALSE, FALSE, 0);
359 return xmhbox;
363 * Construct main window and its widgets
365 void setup_waveform_window(void)
367 int i;
368 GtkWidget *box0;
369 GtkWidget *hbox1, *hbox2;
370 GtkWidget *w;
372 /* some size information. */
373 const int min_w=450, min_h=220;
375 /* Create a top-level window. Set the title and establish delete and
376 destroy event handlers. */
377 wtable->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
378 gtk_widget_set_name(wtable->window, prog_name);
379 gtk_signal_connect(
380 GTK_OBJECT(wtable->window), "destroy",
381 GTK_SIGNAL_FUNC(destroy_handler), NULL);
382 gtk_signal_connect(
383 GTK_OBJECT(wtable->window), "delete_event",
384 GTK_SIGNAL_FUNC(destroy_handler), NULL);
386 /* create the vertical box, and add it to the window */
387 box0 = gtk_vbox_new(FALSE, 0);
388 gtk_container_add(GTK_CONTAINER(wtable->window), box0);
389 gtk_widget_show(box0);
391 wtable->menubar = gtk_menu_bar_new();
392 gtk_widget_show(wtable->menubar);
393 gtk_box_pack_start(GTK_BOX(box0), wtable->menubar, FALSE, TRUE, 0);
395 /* table that structures the rest of the window */
396 wtable->ftable = gtk_table_new(4, 1, FALSE);
397 gtk_container_border_width (GTK_CONTAINER (wtable->ftable), 5);
398 gtk_container_add (GTK_CONTAINER (box0), wtable->ftable);
400 wtable->toolbar = create_toolbar();
401 gtk_table_attach(GTK_TABLE(wtable->ftable), wtable->toolbar,
402 0, 1, WTABLE_FTR_TOOLBAR, WTABLE_FTR_TOOLBAR+1,
403 GTK_EXPAND|GTK_FILL, 0, 0, 0);
405 /* x measurement bar: the X-cursor-related measurebuttons */
406 wtable->xmeasure_hbox = build_xmeasure_hbox(wtable);
407 gtk_widget_show(wtable->xmeasure_hbox);
408 gtk_table_attach(GTK_TABLE(wtable->ftable), wtable->xmeasure_hbox,
409 0, 1, WTABLE_FTR_XMHBOX, WTABLE_FTR_XMHBOX+1,
410 GTK_EXPAND|GTK_FILL, 0, 0, 1);
413 // scrolled window with vertical scrollbar for panel-table
414 wtable->vswindow = gtk_scrolled_window_new (NULL, NULL);
415 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(wtable->vswindow),
416 GTK_POLICY_NEVER,
417 GTK_POLICY_AUTOMATIC);
418 gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(wtable->vswindow), GTK_CORNER_TOP_LEFT);
419 GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW(wtable->vswindow)->vscrollbar, GTK_CAN_FOCUS);
420 gtk_widget_show(wtable->vswindow);
421 // gtk_widget_set_usize(wtable->ftable, -1, min_h);
423 gtk_signal_connect(GTK_OBJECT(wtable->vswindow), "size-allocate",
424 GTK_SIGNAL_FUNC(wavewin_ptable_size_handler),
425 (gpointer)wtable);
427 gtk_table_attach(GTK_TABLE(wtable->ftable), wtable->vswindow,
428 0, 1, WTABLE_FTR_PTABLE, WTABLE_FTR_PTABLE+1,
429 GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0, 0);
431 /* set up initial WavePanels - remnant to be removed someday */
432 for(i = 0; i < wtable->npanels; i++) {
433 WavePanel *wp = wtable->panels[i];
434 setup_wave_panel(wp, 0, 0);
437 /* all the stuff at the bottom */
438 hbox1 = gtk_hbox_new(FALSE, 0);
439 gtk_widget_show(hbox1);
440 gtk_table_attach(GTK_TABLE(wtable->ftable), hbox1, 0, 1,
441 WTABLE_FTR_BHBOX, WTABLE_FTR_BHBOX+1,
442 GTK_EXPAND|GTK_FILL, 0, 0, 0);
444 hbox2 = gtk_hbox_new(FALSE, 0);
445 gtk_widget_show(hbox2);
446 gtk_box_pack_start(GTK_BOX(hbox1), hbox2, TRUE, TRUE, 0);
448 wtable->bot_vbox = gtk_vbox_new(FALSE, 0);
449 gtk_widget_show(wtable->bot_vbox);
450 gtk_box_pack_start(GTK_BOX(hbox1), wtable->bot_vbox, FALSE, FALSE, 0);
452 wtable->bot_hbox3 = gtk_hbox_new(FALSE, 0);
453 if(gwave_debug) {
454 w = gtk_label_new("@");
455 gtk_widget_show(w);
456 gtk_box_pack_start(GTK_BOX(wtable->bot_hbox3), w, FALSE, FALSE, 0);
458 gtk_widget_show(wtable->bot_hbox3);
459 gtk_box_pack_start(GTK_BOX(hbox1), wtable->bot_hbox3, FALSE, FALSE, 0);
461 gtk_signal_connect(GTK_OBJECT(GTK_SCROLLED_WINDOW(wtable->vswindow)->vscrollbar),
462 "show",
463 GTK_SIGNAL_FUNC(wavewin_ptablevsbar_sh_handler), (gpointer)wtable);
464 gtk_signal_connect(GTK_OBJECT(GTK_SCROLLED_WINDOW(wtable->vswindow)->vscrollbar),
465 "hide",
466 GTK_SIGNAL_FUNC(wavewin_ptablevsbar_sh_handler), (gpointer)wtable);
468 /* horizontal box for X-axis labels */
469 wtable->xlhbox = create_xlabel_hbox(wtable);
470 gtk_box_pack_start(GTK_BOX(wtable->bot_vbox), wtable->xlhbox,
471 FALSE, FALSE, 0);
473 /* horizontal scrollbar */
474 wtable->hsadj = (GtkAdjustment *)
475 gtk_adjustment_new(0.0, /* value */
476 0.0, /* lower */
477 1.0, /* upper */
478 1.0/100., /* step increment = 1% */
479 1.0/2., /* page increment = 50% */
480 1.0 /* page_size */
482 wtable->hsbar = gtk_hscrollbar_new(GTK_ADJUSTMENT(wtable->hsadj));
483 gtk_range_set_update_policy (GTK_RANGE (wtable->hsbar),
484 GTK_UPDATE_CONTINUOUS);
485 gtk_signal_connect(
486 GTK_OBJECT(wtable->hsadj), "value_changed",
487 (GtkSignalFunc)scroll_handler, (gpointer)wtable);
488 gtk_widget_show(wtable->hsbar);
489 gtk_box_pack_start(GTK_BOX(wtable->bot_vbox), wtable->hsbar,
490 FALSE, FALSE, 0);
492 /* assemble wavepanels into the table */
493 wavewin_build_table(wtable);
495 /* have to call hooks to build menu before doing
496 gtk-widget-show on main window */
497 call0_hooks(new_wavewin_hook);
499 /* Show the top-level window, set its minimum size */
500 gtk_widget_show(wtable->ftable);
501 gtk_widget_show(wtable->window);
502 gtk_window_set_default_size(GTK_WINDOW(wtable->window),
503 min_w, min_h*3/2);
504 gdk_window_set_hints(wtable->window->window, 0,0, min_w, min_h, 0,0,
505 GDK_HINT_MIN_SIZE);
506 wtable->button_down = -1;
508 gtk_signal_connect(
509 GTK_OBJECT(wtable->window),
510 // "configure-event",
511 "size-allocate",
512 (GtkSignalFunc)wavewin_bot_fixup, (gpointer)wtable);
516 * Create new WavePanel before the specified panel,
517 * or at the end if no panel specified.
519 void
520 wavewin_insert_panel(WavePanel *ppos, int minheight, int showlabels)
522 int p, n;
523 WavePanel **owp;
524 int found = 0;
526 wavewin_destroy_table();
528 owp = wtable->panels;
529 wtable->npanels++;
530 wtable->panels = g_new0(WavePanel*, wtable->npanels);
532 for(p = 0, n = 0; p < wtable->npanels - 1 ; p++) {
533 if(ppos == owp[p]) {
534 wtable->panels[n] = new_wave_panel();
535 setup_wave_panel(wtable->panels[n], minheight, showlabels);
537 /* protect new widgets from unref needed on old widgets
538 * in finish_table_rebuild */
539 gtk_widget_ref(wtable->panels[n]->lmvbox);
540 gtk_widget_ref(wtable->panels[n]->drawing);
541 found = 1;
542 n++;
544 wtable->panels[n++] = owp[p];
546 if(!found) { /* add at end */
547 wtable->panels[n] = new_wave_panel();
548 setup_wave_panel(wtable->panels[n], minheight, showlabels);
550 gtk_widget_ref(wtable->panels[n]->lmvbox);
551 gtk_widget_ref(wtable->panels[n]->drawing);
553 g_free(owp);
554 wavewin_build_table(wtable);
555 wavewin_finish_table_rebuild();
559 * Delete the specified WavePanel.
561 void
562 wavewin_delete_panel(WavePanel *dwp)
564 int i, p;
565 WavePanel **nwp;
566 if(wtable->npanels == 1) {
567 fprintf(stderr, "cmd_delete_panel: can't delete last panel\n");
568 return;
571 wavewin_destroy_table();
573 nwp = g_new0(WavePanel*, wtable->npanels - 1);
574 for(p = 0, i = 0; i < wtable->npanels; i++) {
575 if(wtable->panels[i] == dwp) {
576 destroy_wave_panel(wtable->panels[i]);
577 dwp = NULL;
578 wtable->panels[i] = NULL;
579 } else {
580 nwp[p++] = wtable->panels[i];
583 if(dwp) {
584 fprintf(stderr, "cmd_delete_panel: specified panel not found\n");
585 /* some memory may have leaked */
587 g_free(wtable->panels);
588 wtable->npanels--;
589 wtable->panels = nwp;
591 wavewin_build_table(wtable);
592 wavewin_finish_table_rebuild();
595 WavePanel *
596 first_selected_wavepanel()
598 WavePanel *wp;
599 int i;
600 for(i = wtable->npanels-1; i >= 0; i--) {
601 WavePanel *wp = wtable->panels[i];
602 if(wp->selected)
603 return wp;
605 return NULL;
608 SCM_DEFINE(wtable_insert_panel_x, "wtable-insert-panel!", 2, 1, 0,
609 (SCM wp, SCM minheight, SCM showlabels),
610 "Add a new panel after the existing panel WP, or"
611 "at the end if WP is #f."
612 "The new panel has minimum height MINHEIGHT and has visible y-labels"
613 "unless SHOWLABELS is #f")
614 #define FUNC_NAME s_wtable_insert_panel_x
616 WavePanel *cwp;
617 int iheight, ishow;
618 VALIDATE_ARG_WavePanel_COPY_USE_NULL(1,wp,cwp);
619 VALIDATE_ARG_INT_RANGE_COPY(2,minheight,
620 WAVEPANEL_MIN_HEIGHT,
621 WAVEPANEL_MAX_REQHEIGHT, iheight);
622 VALIDATE_ARG_BOOL_COPY_USE_T(3,showlabels,ishow);
623 if(v_flag)
624 fprintf(stderr, "wtable_insert_panel(0x%x)\n", cwp);
625 wavewin_insert_panel(cwp, iheight, ishow);
626 return SCM_UNSPECIFIED;
628 #undef FUNC_NAME
630 SCM_DEFINE(wtable_delete_panel_x, "wtable-delete-panel!", 1, 0, 0, (SCM wp),
631 "Delete panel WP from the waveform display")
632 #define FUNC_NAME s_wtable_delete_panel_x
634 WavePanel *cwp;
635 VALIDATE_ARG_WavePanel_COPY(1,wp,cwp);
636 if(v_flag)
637 fprintf(stderr, "wtable_delete_panel(0x%x)\n", cwp);
638 wavewin_delete_panel(cwp);
639 return SCM_UNSPECIFIED;
641 #undef FUNC_NAME
643 SCM_DEFINE(wtable_set_xlogscale_x, "wtable-set-xlogscale!", 1, 0, 0,
644 (SCM xlogscale),
645 "Set scaling for all X axes; logarithmic if XLOGSCALE is #t, else linear")
646 #define FUNC_NAME s_wtable_set_xlogscale_x
648 int logx;
649 VALIDATE_ARG_BOOL_COPY(1,xlogscale,logx);
651 if(wtable->logx != logx) {
652 wtable->logx = logx;
653 if(logx) {
654 gtk_widget_show(wtable->lab_xlogscale);
655 } else {
656 gtk_widget_hide(wtable->lab_xlogscale);
658 wtable_redraw_x();
661 return SCM_UNSPECIFIED;
663 #undef FUNC_NAME
665 SCM_DEFINE(wtable_xlogscale_p, "wtable-xlogscale?", 0, 0, 0, (),
666 "If the X axis is set to Logarithmic scaling, return #t.")
667 #define FUNC_NAME s_wtable_xlogscale_p
669 if(wtable->logx)
670 return SCM_BOOL_T;
671 else
672 return SCM_BOOL_F;
674 #undef FUNC_NAME
677 SCM_DEFINE(wtable_wavepanels, "wtable-wavepanels", 0, 0, 0,
679 "Return list of WavePanels that are currently displayed")
680 #define FUNC_NAME s_wtable_wavepanels
682 int i;
683 SCM answer;
684 answer = SCM_EOL;
685 for(i = wtable->npanels-1; i >= 0; i--) {
686 WavePanel *wp = wtable->panels[i];
687 answer = scm_cons(wp->smob, answer);
689 return answer;
691 #undef FUNC_NAME
693 SCM_DEFINE(set_wtable_measure_x, "set-wtable-measure!", 2, 0, 0,
694 (SCM n, SCM func),
695 "Change the global measurement box numbered N (0 through 3)"
696 "to display the result of the measurement function FUNC")
697 #define FUNC_NAME s_set_wtable_measure_x
699 int mno;
700 int mfunc;
701 VALIDATE_ARG_INT_RANGE_COPY(1, n, 0, N_WTABLE_MBTNS-1, mno);
702 VALIDATE_ARG_INT_RANGE_COPY(2, func, 0, MBF_MAX_FUNC, mfunc);
704 mbtn_set_func(wtable->cursor_mbtn[mno], mfunc);
705 mbtn_update(wtable->cursor_mbtn[mno], NULL);
706 return SCM_UNSPECIFIED;
708 #undef FUNC_NAME
711 SCM_DEFINE(wtable_bottom_fixup, "wtable-bottom-fixup", 0, 0, 0,
713 "Attempt to fix up sizing/positioning of bottom of window")
714 #define FUNC_NAME s_wtable_bottom_fixup
716 wavewin_bot_fixup(wtable);
718 return SCM_UNSPECIFIED;
720 #undef FUNC_NAME
724 SCM_DEFINE(set_wtable_tooltips_x, "set-wtable-tooltips!", 1, 0, 0,
725 (SCM tt),
726 "Use tooltips group TT when adding pop-up tool tips to"
727 "widgets within the wave table")
728 #define FUNC_NAME s_set_wtable_tooltips_x
730 GtkTooltips *gtt;
732 SCM_VALIDATE_GOBJECT_COPY(1, tt, gtt);
734 if(!GTK_IS_TOOLTIPS(gtt)) {
735 printf("set_wtable_tooltips!: not a tooltips %lx\n", gtt);
737 wtable->ttips = gtt;
738 return SCM_UNSPECIFIED;
740 #undef FUNC_NAME
743 /***********************************************************************
744 * guile initialization
747 void init_wavewin()
749 #ifndef SCM_MAGIC_SNARF_INITS
750 #include "wavewin.x"
751 #endif