Blame hdspmixer/src/HDSPMixerPeak.cxx

Packit 427e91
/*
Packit 427e91
 *   HDSPMixer
Packit 427e91
 *    
Packit 427e91
 *   Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org)
Packit 427e91
 *    
Packit 427e91
 *   This program is free software; you can redistribute it and/or modify
Packit 427e91
 *   it under the terms of the GNU General Public License as published by
Packit 427e91
 *   the Free Software Foundation; either version 2 of the License, or
Packit 427e91
 *   (at your option) any later version.
Packit 427e91
 *
Packit 427e91
 *   This program is distributed in the hope that it will be useful,
Packit 427e91
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 427e91
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 427e91
 *   GNU General Public License for more details.
Packit 427e91
 *
Packit 427e91
 *   You should have received a copy of the GNU General Public License
Packit 427e91
 *   along with this program; if not, write to the Free Software
Packit 427e91
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit 427e91
 */
Packit 427e91
Packit 427e91
#pragma implementation
Packit 427e91
#include "HDSPMixerPeak.h"
Packit 427e91
Packit 427e91
HDSPMixerPeak::HDSPMixerPeak(int x, int y, int parenttype):Fl_Widget(x, y, 30, 13)
Packit 427e91
{
Packit 427e91
    parent_iomixer = parenttype;
Packit 427e91
    over = 0;
Packit 427e91
    snprintf(text, 10, "-oo");
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerPeak::draw()
Packit 427e91
{
Packit 427e91
    if (over) {
Packit 427e91
        fl_draw_pixmap(over_xpm, x(), y());
Packit 427e91
    }
Packit 427e91
    fl_color(FL_GREEN);
Packit 427e91
    fl_font(FL_HELVETICA, 8);
Packit 427e91
    fl_draw(text, x(), y(), w(), h(), FL_ALIGN_CENTER);
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerPeak::update(double maxlevel, int ovr) {
Packit 427e91
    if (ovr) {
Packit 427e91
	snprintf(text, 10, "Ovr");
Packit 427e91
	over = 1;
Packit 427e91
    } else {
Packit 427e91
	over = 0;
Packit 427e91
	if (maxlevel <= 0.001) {
Packit 427e91
	    snprintf(text, 10, "0.00");
Packit 427e91
	} else if (maxlevel == 1000.0) {
Packit 427e91
	    snprintf(text, 10, "-oo");
Packit 427e91
	} else if (maxlevel >= 100.0) {
Packit 427e91
	    snprintf(text, 10, "-%.1f", maxlevel);
Packit 427e91
	} else {
Packit 427e91
	    snprintf(text, 10, "-%.2f", maxlevel);
Packit 427e91
	}
Packit 427e91
    }
Packit 427e91
    redraw();    
Packit 427e91
}
Packit 427e91