display the measurement value in the measurebutton tooltip,
[gwave-svn.git] / src / wavepanel.c
blobe2769b29bf0d0f5c12bc06b0d418f4a68c23b55a
1 /*
2 * wavepanel.c, part of the gwave waveform viewer tool
4 * Functions in this file handle wave panels.
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 <wavewin.h>
42 #include <measurebtn.h>
43 #include <dnd.h>
44 #include <GtkTable_indel.h>
46 #define WAVEPANEL_MIN_WIDTH 300
47 #define WAVEPANEL_MIN_HEIGHT 20
48 #define WAVEPANEL_MAX_REQHEIGHT 600
50 XSCM_HOOK(new_wavepanel_hook,"new-wavepanel-hook", 1, (SCM wp),
51 "This hook is invoked with one WavePanel argument, WP, when the"
52 "WavePanel is first created and added to the waveform window."
53 "The main purpose of this hook is to allow creation of "
54 "popup menus and other event bindings for the wavepanel.");
56 SCM wavepanel_mouse_binding[N_MOUSE_BUTTONS];
58 void wavepanel_lmtable_size_handler(GtkWidget *w,
59 GtkRequisition *req, gpointer d);
61 /* generate VisibleWave button label string,
62 * for both initial setup and updating.
64 void
65 vw_get_label_string(char *buf, int buflen, VisibleWave *vw)
67 GWDataFile *gdf;
68 int n, l;
70 gdf = vw->gdf;
71 g_assert(gdf != NULL);
73 if(wv_is_multisweep(vw->var)) {
74 l = buflen - strlen(gdf->ftag) - 10;
75 n = MIN(l, 15);
76 snprintf(buf, buflen, "%s: %.*s @ %.10s=%g",
77 gdf->ftag,
78 n, vw->varname,
79 vw->var->wtable->name, vw->var->wtable->swval);
80 } else {
81 l = buflen - strlen(gdf->ftag) - 10;
82 n = MIN(l, 15);
83 snprintf(buf, buflen, "%s: %.*s", gdf->ftag, n, vw->varname);
88 * vw_wp_create_button -- create button, label, and measurement
89 * widgets for a new VisibleWave just added to a WavePanel
91 void
92 vw_wp_create_button(VisibleWave *vw, WavePanel *wp)
94 char lbuf[64];
95 int newrow;
97 vw_get_label_string(lbuf, 64, vw);
98 vw->label = gtk_label_new(lbuf);
99 vw->button = gtk_toggle_button_new();
100 gtk_container_add(GTK_CONTAINER(vw->button), vw->label);
102 /* create new row #1 of the label/measurement table,
103 and add this stuff there. row 0 reserved for Y-axis label. */
104 newrow = 1;
105 gtk_table_insert_row(wp->lmtable, newrow);
107 gtk_table_attach(GTK_TABLE(wp->lmtable), vw->button,
108 0, 1, newrow, newrow+1,
109 GTK_EXPAND|GTK_FILL,
111 0, 0 );
113 sprintf(lbuf, "wavecolor%d", vw->colorn);
114 gtk_widget_set_name(vw->label, lbuf);
115 gtk_widget_show(vw->label);
116 gtk_widget_set_name(vw->button, "wavebutton");
117 gtk_widget_show(vw->button);
119 /* create measurement buttons */
120 vw->mbtn[0] = measure_button_new(vw->var, MBF_VARC0);
121 vw->mbtn[1] = measure_button_new(vw->var, MBF_VARC1);
123 gtk_widget_set_usize(vw->mbtn[0]->button, 60, -1);
124 gtk_widget_set_usize(vw->mbtn[1]->button, 60, -1);
126 gtk_table_attach(GTK_TABLE(wp->lmtable), vw->mbtn[0]->button,
127 1, 2, newrow, newrow+1,
128 GTK_FILL,
130 0, 0 );
132 gtk_table_attach(GTK_TABLE(wp->lmtable), vw->mbtn[1]->button,
133 2, 3, newrow, newrow+1,
134 GTK_FILL,
136 0, 0 );
138 mbtn_update(vw->mbtn[0], NULL);
139 mbtn_update(vw->mbtn[1], NULL);
142 void
143 draw_wavepanel_labels(WavePanel *wp)
145 if(wp->lab_min) {
146 gtk_label_set(GTK_LABEL(wp->lab_min), val2txt(wp->start_yval,0));
148 if(wp->lab_max) {
149 gtk_label_set(GTK_LABEL(wp->lab_max), val2txt(wp->end_yval,0));
153 /* Allocate a new WavePanel and do basic setup */
154 WavePanel *
155 new_wave_panel()
157 WavePanel *wp;
158 wp = g_new0(WavePanel, 1);
159 wp->valid = 1;
161 SGT_NEWCELL_SMOB(wp->smob, WavePanel, wp);
162 scm_gc_protect_object(wp->smob);
163 wp->outstanding_smob = 1;
164 call1_hooks(new_wavepanel_hook, wp->smob);
166 return wp;
170 * Construct label/measurement area on the left side of a WavePanel.
171 * This area consist of a table containing 3 columns.
173 * The top row (row 0) has a single hbox spanning 3 colums.
174 * It may be invisible, and conatains the LogY indicator and maximum Y value
175 * label.
176 * The bottom row (row N-1) has a single hbox spanning 3 columns,
177 * with the minimum Y value label.
178 * rows 1 through N-2 contain three columns, for the label and up to two
179 * measurements.
182 void setup_wavepanel_lmtable(WavePanel *wp, int showlabels)
184 char lbuf[128];
185 GtkWidget *vbox;
186 GtkWidget *scrolled_window;
188 // outer label/measurement vbox, will have 3 entries
189 wp->lmvbox = gtk_vbox_new(FALSE, 0);
190 gtk_widget_show(wp->lmvbox);
192 // hbox with logY and maxY labels
193 wp->lab_max_hbox = gtk_hbox_new(FALSE, 0);
194 gtk_box_pack_start(GTK_BOX(wp->lmvbox), wp->lab_max_hbox,
195 FALSE, FALSE, 0);
197 strcpy(lbuf, val2txt(wp->end_yval, 0));
198 wp->lab_max = gtk_label_new(lbuf);
199 gtk_box_pack_end(GTK_BOX(wp->lab_max_hbox), wp->lab_max,
200 FALSE, FALSE, 0);
201 gtk_widget_show(wp->lab_max);
203 wp->lab_logscale = gtk_label_new("LogY");
204 gtk_box_pack_start(GTK_BOX(wp->lab_max_hbox), wp->lab_logscale,
205 FALSE, FALSE, 0);
208 // table for buttons and masurements. row 0 is space-filling dummy.
210 vbox = gtk_vbox_new(FALSE, 0);
211 gtk_widget_show(vbox);
213 wp->lmtable = gtk_table_new(1, 3, FALSE);
214 gtk_widget_set_usize(wp->lmtable, 190, -1);
215 gtk_widget_show(wp->lmtable);
217 gtk_table_attach(GTK_TABLE(wp->lmtable), vbox,
218 0, 3, 0, 1,
220 GTK_EXPAND|GTK_FILL,
221 0, 0 );
223 // wrap scrolled window with vertical scrollbar around table
224 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
225 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window),
226 GTK_POLICY_NEVER,
227 GTK_POLICY_ALWAYS);
228 gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW (scrolled_window),
229 GTK_CORNER_TOP_RIGHT);
230 GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_window)->vscrollbar, GTK_CAN_FOCUS);
231 gtk_widget_show (scrolled_window);
233 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
234 wp->lmtable);
235 gtk_container_set_focus_vadjustment(
236 GTK_CONTAINER (wp->lmtable),
237 gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window)));
240 gtk_box_pack_start(GTK_BOX(wp->lmvbox), scrolled_window,
241 TRUE, TRUE, 0);
244 // last item in the outer vbox: hbox for minY label
245 strcpy(lbuf, val2txt(wp->start_yval, 0));
246 wp->lab_min = gtk_label_new(lbuf);
247 gtk_widget_show(wp->lab_min);
248 wp->lab_min_hbox = gtk_hbox_new(FALSE, 0);
249 gtk_box_pack_end(GTK_BOX(wp->lab_min_hbox), wp->lab_min,
250 FALSE, FALSE, 0);
251 gtk_box_pack_end(GTK_BOX(wp->lmvbox), wp->lab_min_hbox,
252 FALSE, FALSE, 0);
254 if(showlabels) {
255 gtk_widget_show(wp->lab_min_hbox);
256 gtk_widget_show(wp->lab_max_hbox);
259 // take action when the label/measure table wants to change size
260 gtk_signal_connect(GTK_OBJECT(wp->lmtable), "size-request",
261 GTK_SIGNAL_FUNC(wavepanel_lmtable_size_handler), (gpointer)wp);
265 * Set up widgets for a newly-created WavePanel -
266 * construct label and drawing areas
268 void setup_wave_panel(WavePanel *wp, int minheight, int showlabels)
270 if(v_flag) {
271 fprintf(stderr, "setup_wave_panel minheight%d showlabels=%d\n",
272 minheight, showlabels);
274 wp->start_xval = wtable->start_xval;
275 wp->end_xval = wtable->end_xval;
277 setup_wavepanel_lmtable(wp, showlabels);
279 /* drawing area for waveform */
280 wp->drawing = gtk_drawing_area_new();
281 gtk_signal_connect(
282 GTK_OBJECT(wp->drawing), "expose_event",
283 (GtkSignalFunc)expose_handler, (gpointer)wp);
284 gtk_signal_connect(
285 GTK_OBJECT(wp->drawing), "button_press_event",
286 (GtkSignalFunc)button_press_handler, (gpointer)wp);
287 gtk_signal_connect(
288 GTK_OBJECT(wp->drawing), "button_release_event",
289 (GtkSignalFunc)button_release_handler, (gpointer)wp);
290 gtk_signal_connect(
291 GTK_OBJECT(wp->drawing), "motion_notify_event",
292 (GtkSignalFunc)motion_handler, (gpointer)wp);
294 if(minheight < WAVEPANEL_MIN_HEIGHT)
295 wp->req_height = WAVEPANEL_MIN_HEIGHT;
296 else if(minheight > WAVEPANEL_MAX_REQHEIGHT)
297 wp->req_height = WAVEPANEL_MAX_REQHEIGHT;
298 else
299 wp->req_height = minheight;
301 gtk_drawing_area_size(GTK_DRAWING_AREA(wp->drawing),
302 wp->width ? wp->width : WAVEPANEL_MIN_WIDTH,
303 wp->req_height);
304 gtk_widget_show(wp->drawing);
306 dnd_setup_target(wp->drawing, (gpointer)wp);
308 gtk_widget_set_events(wp->drawing,
309 GDK_EXPOSURE_MASK|GDK_BUTTON_RELEASE_MASK|
310 GDK_BUTTON_PRESS_MASK|
311 GDK_BUTTON1_MOTION_MASK|GDK_BUTTON2_MOTION_MASK);
315 * Delete a wavepanel structure and all data structures referenced from it.
317 void destroy_wave_panel(WavePanel *wp)
319 VisibleWave *vw;
321 while((vw = g_list_nth_data(wp->vwlist, 0)) != NULL) {
322 remove_wave_from_panel(wp, vw);
324 gtk_widget_destroy(wp->lmvbox);
325 gtk_widget_destroy(wp->drawing);
326 gdk_pixmap_unref(wp->pixmap);
327 wp->valid = 0;
328 scm_gc_unprotect_object(wp->smob);
329 if(wp->outstanding_smob == 0)
330 g_free(wp);
334 * Gtk+ signal handler called a panel's lmtable changes size.
335 * If there isn't room to show the whole width, force it larger, but
336 * don't let it get too big.
337 * Seems to restore the behavior from before the ScrolledWindow was added,
338 * when the label/button area always fit.
340 void
341 wavepanel_lmtable_size_handler(GtkWidget *w,
342 GtkRequisition *req, gpointer d)
344 WavePanel *wp = (WavePanel *)d;
346 /* printf("wavepanel_lmtable_size_handler: reqw=%d alloc=%d\n",
347 req->width, wp->lmtable->allocation.width); */
349 if(req->width > 100
350 && wp->lmtable->allocation.width > 100
351 && req->width > wp->lmtable->allocation.width) {
352 gtk_widget_set_usize(wp->lmtable,
353 (req->width > 350 ? 350 : req->width), -1);
359 SCM_DEFINE(wavepanel_selected_p, "wavepanel-selected?", 1, 0, 0,
360 (SCM wavepanel),
361 "Return true if the WAVEPANEL is selected")
362 #define FUNC_NAME s_wavepanel_selected_p
364 WavePanel *wp;
365 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
366 if(wp->selected)
367 return SCM_BOOL_T;
368 else
369 return SCM_BOOL_F;
371 #undef FUNC_NAME
373 SCM_DEFINE(set_wavepanel_selected_x, "set-wavepanel-selected!", 2, 0, 0,
374 (SCM wavepanel, SCM tf),
375 "Set the selected state of WAVEPANEL to TF, either true or false")
376 #define FUNC_NAME s_set_wavepanel_selected_x
378 WavePanel *wp;
379 int itf;
380 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
381 VALIDATE_ARG_BOOL_COPY(2, tf, itf);
383 if(wp->selected != itf) {
384 wp->selected = itf;
385 draw_wavepanel(wp->drawing, NULL, wp);
387 return SCM_UNSPECIFIED;
389 #undef FUNC_NAME
391 SCM_DEFINE(wavepanel_y_zoom_x, "wavepanel-y-zoom!", 3, 0, 0,
392 (SCM wavepanel, SCM miny, SCM maxy),
393 "zoom/rescale WAVEPANEL so that the y axis displays from MINY to MAXY")
394 #define FUNC_NAME s_wavepanel_y_zoom_x
396 WavePanel *wp;
397 double dmin, dmax;
398 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
399 if(miny == SCM_BOOL_F) {
400 wp->man_yzoom = 0;
401 wp->start_yval = wp->min_yval;
402 wp->end_yval = wp->max_yval;
403 } else {
404 VALIDATE_ARG_DBL_COPY(1, miny, dmin);
405 VALIDATE_ARG_DBL_COPY(2, maxy, dmax);
406 wp->man_yzoom = 1;
407 if(dmin < dmax) {
408 wp->start_yval = dmin;
409 wp->end_yval = dmax;
410 } else {
411 wp->start_yval = dmax;
412 wp->end_yval = dmin;
415 draw_wavepanel(wp->drawing, NULL, wp);
416 draw_wavepanel_labels(wp);
417 return SCM_UNSPECIFIED;
419 #undef FUNC_NAME
421 SCM_DEFINE(wavepanel_y_manual_p, "wavepanel-y-manual?", 1, 0, 0,
422 (SCM wavepanel),
423 "If WAVEPANEL's y extents have been zoomed manually, return #t."
424 "Otherwise, return #f to indicate automatic y-zoom to show the minimum"
425 "and maximum values of all dependent variables")
426 #define FUNC_NAME s_wavepanel_y_manual_p
428 WavePanel *wp;
429 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
431 if(wp->man_yzoom)
432 return SCM_BOOL_T;
433 else
434 return SCM_BOOL_F;
436 #undef FUNC_NAME
439 SCM_DEFINE(set_wavepanel_ylabels_visible_x, "set-wavepanel-ylabels-visible!", 2, 0, 0,
440 (SCM wavepanel, SCM show),
441 "If SHOW is #t, make the Y-axis labels on the left side of WAVEPANEL"
442 "visible. If show is #f, hide the labels. Hiding the labels allows"
443 "shrinking WAVEPANEL's height a little further. This is useful when you have"
444 "a lot of panels, for example with digital circuits.")
445 #define FUNC_NAME s_set_wavepanel_ylabels_visible_x
447 WavePanel *wp;
448 int ishow;
449 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
450 VALIDATE_ARG_BOOL_COPY(2, show, ishow);
452 if(ishow) {
453 gtk_widget_show(wp->lab_min_hbox);
454 gtk_widget_show(wp->lab_max_hbox);
455 } else {
456 gtk_widget_hide(wp->lab_min_hbox);
457 gtk_widget_hide(wp->lab_max_hbox);
459 return SCM_UNSPECIFIED;
461 #undef FUNC_NAME
463 SCM_DEFINE(set_wavepanel_ylogscale_x, "set-wavepanel-ylogscale!", 2, 0, 0,
464 (SCM wavepanel, SCM logscale),
465 "If LOGSCALE is #t, The Y-axis of WAVEPANEL is set to have"
466 "Logarithmic scaling. Otherwise, scaling is linear.")
467 #define FUNC_NAME s_set_wavepanel_ylogscale_x
469 WavePanel *wp;
470 int logy;
471 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
472 VALIDATE_ARG_BOOL_COPY(2, logscale, logy);
474 if(wp->logy != logy) {
475 wp->logy = logy;
476 if(logy)
477 gtk_widget_show(wp->lab_logscale);
478 else
479 gtk_widget_hide(wp->lab_logscale);
480 draw_wavepanel(wp->drawing, NULL, wp);
482 return SCM_UNSPECIFIED;
484 #undef FUNC_NAME
486 SCM_DEFINE(wavepanel_ylogscale_p, "wavepanel-ylogscale?", 1, 0, 0,
487 (SCM wavepanel),
488 "If WAVEPANEL is set to Logarithmic scaling, return #t.")
489 #define FUNC_NAME s_wavepanel_ylogscale_p
491 WavePanel *wp;
492 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
494 if(wp->logy)
495 return SCM_BOOL_T;
496 else
497 return SCM_BOOL_F;
499 #undef FUNC_NAME
502 SCM /* Helper for wavepanel_visiblewaves */
503 wavepanel_to_scm(void *vwp)
505 WavePanel *wp = (WavePanel *)vwp;
506 return wp->smob;
509 SCM_DEFINE(wavepanel_visiblewaves, "wavepanel-visiblewaves", 1, 0, 0,
510 (SCM wavepanel),
511 "Return a list of the VisibleWaves contained in WAVEPANEL.")
512 #define FUNC_NAME s_wavepanel_visiblewaves
514 WavePanel *wp;
516 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
518 return glist2scm(wp->vwlist, wavepanel_to_scm);
520 #undef FUNC_NAME
524 * this binding stuff is really quite a hack; we should build a common
525 * mechanism for mouse and keyboard bindings, together with modifiers.
526 * But the scheme interface here isn't too far from what that would implement,
527 * and this simple thing lets us get the rest of the old menus into guile.
529 SCM_DEFINE(wavepanel_bind_mouse, "wavepanel-bind-mouse", 2, 0, 0,
530 (SCM button, SCM proc),
531 "binds a mouse BUTTON to the procedure PROC in all wavepanels. "
532 "PROC is called with 1 argument, the wavepanel that the mouse was in.")
533 #define FUNC_NAME s_wavepanel_bind_mouse
535 int bnum;
536 VALIDATE_ARG_INT_RANGE_COPY(1, button, 1, N_MOUSE_BUTTONS-1, bnum);
537 VALIDATE_ARG_PROC(2, proc);
539 /* TODO: find right way to initialize and test to remove old binding.
540 if(SCM_NFALSEP(scm_procedure_p(wavepanel_mouse_binding[bnum])) {
541 scm_unprotect_object(wavepanel_mouse_binding[bnum]);
544 if (!UNSET_SCM(proc)) {
545 scm_gc_protect_object(proc);
546 wavepanel_mouse_binding[bnum] = proc;
549 return SCM_UNSPECIFIED;
551 #undef FUNC_NAME
553 SCM_DEFINE(wavepanel_x2val, "wavepanel-x2val", 2, 0, 0,
554 (SCM wavepanel, SCM xpixel),
555 "Given an XPIXEL coordinate in WAVEPANEL, "
556 "return the value of the independent variable at that position"
557 "in the waveform.")
558 #define FUNC_NAME s_wavepanel_x2val
560 WavePanel *wp;
561 int x;
562 double val;
563 VALIDATE_ARG_WavePanel_COPY_USE_NULL(1,wavepanel,wp);
564 VALIDATE_ARG_INT_COPY(2,xpixel,x);
565 val = x2val(wp, x, wtable->logx);
566 return scm_make_real(val);
568 #undef FUNC_NAME
570 SCM_DEFINE(wavepanel_y2val, "wavepanel-y2val", 2, 0, 0,
571 (SCM wavepanel, SCM ypixel),
572 "Given a YPIXEL screen-space coordinate in WAVEPANEL, "
573 "return the value that the dependent variable would have"
574 "at that position.")
575 #define FUNC_NAME s_wavepanel_y2val
577 WavePanel *wp;
578 int y;
579 double val;
580 VALIDATE_ARG_WavePanel_COPY_USE_NULL(1,wavepanel,wp);
581 VALIDATE_ARG_INT_COPY(2,ypixel,y);
582 val = y2val(wp, y);
583 return scm_make_real(val);
585 #undef FUNC_NAME
587 SCM_DEFINE(wavepanel_disp_rect, "wavepanel-disp-rect", 1, 0, 0,
588 (SCM wavepanel),
589 "Return a list containing coordinates of the space "
590 "currently displayed by the current zoom setting of WAVEPANEL. "
591 "The list contains four elements, startX, startY, endX, endY")
592 #define FUNC_NAME s_wavepanel_disp_rect
594 WavePanel *wp;
595 SCM answer = SCM_EOL;
596 VALIDATE_ARG_WavePanel_COPY_USE_NULL(1,wavepanel,wp);
597 answer = scm_cons( scm_make_real(wp->end_yval), answer);
598 answer = scm_cons( scm_make_real(wp->end_xval), answer);
599 answer = scm_cons( scm_make_real(wp->start_yval), answer);
600 answer = scm_cons( scm_make_real(wp->start_xval), answer);
601 return answer;
603 #undef FUNC_NAME
605 SCM_DEFINE(wavepanel_max_rect, "wavepanel-max-rect", 1, 0, 0,
606 (SCM wavepanel),
607 "Return a list containing coordinates of the bounding box of all waveforms"
608 "displayed in WAVEPANEL."
609 "The list contains four elements, minX, minY, maxX, maxY")
610 #define FUNC_NAME s_wavepanel_max_rect
612 WavePanel *wp;
613 SCM answer = SCM_EOL;
614 VALIDATE_ARG_WavePanel_COPY_USE_NULL(1,wavepanel,wp);
615 answer = scm_cons( scm_make_real(wp->max_yval), answer);
616 answer = scm_cons( scm_make_real(wp->max_xval), answer);
617 answer = scm_cons( scm_make_real(wp->min_yval), answer);
618 answer = scm_cons( scm_make_real(wp->min_xval), answer);
619 return answer;
621 #undef FUNC_NAME
623 SCM_DEFINE(set_wavepanel_minheight_x, "set-wavepanel-minheight!", 2, 0, 0,
624 (SCM wavepanel, SCM height),
625 "Set the minimum height of WAVEPANEL to HEIGHT pixels. Adding multiple"
626 "VisibleWaves to the wavepanel can cause the actual height to increase"
627 "beyond this minimum, but it will never be smaller.")
628 #define FUNC_NAME s_set_wavepanel_minheight_x
630 WavePanel *wp;
631 int min_height;
632 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
633 VALIDATE_ARG_INT_RANGE_COPY(2,height,WAVEPANEL_MIN_HEIGHT,WAVEPANEL_MAX_REQHEIGHT,min_height);
634 wp->req_height = min_height;
635 gtk_drawing_area_size(GTK_DRAWING_AREA(wp->drawing),
636 wp->width ? wp->width : WAVEPANEL_MIN_WIDTH,
637 wp->req_height);
639 return SCM_UNSPECIFIED;
641 #undef FUNC_NAME
644 SCM_DEFINE(wavepanel_debug_x, "wavepanel-debug!", 1, 0, 0,
645 (SCM wavepanel),
646 "Causes debug info about WAVEPANEL to be printed to stdout")
647 #define FUNC_NAME s_wavepanel_debug_x
649 WavePanel *wp;
650 VALIDATE_ARG_WavePanel_COPY(1,wavepanel,wp);
652 printf("wavepanel lmtable req=%d,%d alloc=%d,%d\n",
653 wp->lmtable->requisition.width,
654 wp->lmtable->requisition.height,
655 wp->lmtable->allocation.width,
656 wp->lmtable->allocation.height);
657 printf(" vbox req=%d,%d alloc=%d,%d\n",
658 wp->lmvbox->requisition.width,
659 wp->lmvbox->requisition.height,
660 wp->lmvbox->allocation.width,
661 wp->lmvbox->allocation.height );
663 return SCM_UNSPECIFIED;
665 #undef FUNC_NAME
668 SCM_DEFINE(VisibleWave_selected_p, "VisibleWave-selected?", 1, 0, 0,
669 (SCM visiblewave),
670 "Returns true if VISIBLEWAVE has been selected by having its buttons pressed.")
671 #define FUNC_NAME s_wavepanel_visiblewaves
673 VisibleWave *vw;
675 VALIDATE_ARG_VisibleWave_COPY(1, visiblewave, vw);
676 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vw->button)))
677 return SCM_BOOL_T;
678 else
679 return SCM_BOOL_F;
681 #undef FUNC_NAME
686 /*****************************************************************************
687 * Standard stuff for the WavePanel SMOB */
689 scm_sizet
690 free_WavePanel(SCM obj)
692 WavePanel *wp = WavePanel(obj);
693 wp->outstanding_smob = 0;
695 if(wp->valid == 0) { /* if C has already invalidated, free it up */
696 if(v_flag)
697 fprintf(stderr, "free WavePanel 0x%x in gc\n", wp);
698 g_free(wp);
699 return sizeof(WavePanel);
701 else
702 return 0;
706 mark_WavePanel(SCM obj)
708 return SCM_BOOL_F;
711 int
712 print_WavePanel(SCM obj, SCM port, scm_print_state *ARG_IGNORE(pstate))
714 WavePanel *wp = WavePanel(obj);
715 scm_puts("#<WavePanel ", port);
716 scm_force_output(port);
717 scm_uintprint((long)wp, 16, port);
718 scm_force_output(port);
719 if(!wp->valid)
720 scm_puts("invalid", port);
721 scm_putc('>', port);
722 scm_force_output(port);
723 return 1;
726 SCM_DEFINE(WavePanel_p, "WavePanel?", 1, 0, 0,
727 (SCM obj),
728 "Returns #t if OBJ is a gwave data file object, otherwise #f.")
729 #define FUNC_NAME s_WavePanel_p
731 return SCM_BOOL_FromBool(WavePanel_P(obj));
733 #undef FUNC_NAME
735 /*****************************************************************************
736 * Standard stuff for the VisibleWave SMOB */
738 scm_sizet
739 free_VisibleWave(SCM obj)
741 VisibleWave *wp = VisibleWave(obj);
742 wp->outstanding_smob = 0;
744 if(wp->valid == 0) { /* if C has already invalidated, free it up */
745 if(v_flag)
746 fprintf(stderr, "free VisibleWave 0x%x in gc\n", wp);
747 g_free(wp);
748 return sizeof(VisibleWave);
750 else
751 return 0;
755 mark_VisibleWave(SCM obj)
757 return SCM_BOOL_F;
760 int
761 print_VisibleWave(SCM obj, SCM port, scm_print_state *ARG_IGNORE(pstate))
763 VisibleWave *wp = VisibleWave(obj);
764 scm_puts("#<VisibleWave ", port);
765 scm_intprint((long)wp, 16, port);
766 if(!VisibleWave(obj)->valid)
767 scm_puts("invalid", port);
768 scm_putc('>', port);
769 return 1;
772 SCM_DEFINE(VisibleWave_p, "VisibleWave?", 1, 0, 0,
773 (SCM obj),
774 "Returns #t if OBJ is a gwave data file object, otherwise #f.")
775 #define FUNC_NAME s_VisibleWave_p
777 return SCM_BOOL_FromBool(VisibleWave_P(obj));
779 #undef FUNC_NAME
781 /***********************************************************************
782 * guile initialization
785 MAKE_SMOBFUNS(WavePanel);
786 MAKE_SMOBFUNS(VisibleWave);
788 void init_wavepanel()
790 REGISTER_SCWMSMOBFUNS(WavePanel);
791 REGISTER_SCWMSMOBFUNS(VisibleWave);
793 #ifndef SCM_MAGIC_SNARF_INITS
794 #include "wavepanel.x"
795 #endif