Blame hdspmixer/src/HDSPMixerIOMixer.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 "HDSPMixerIOMixer.h"
Packit 427e91
Packit 427e91
HDSPMixerIOMixer::HDSPMixerIOMixer(int x, int y, int w, int h, int ch, int type):Fl_Group(x, y, w, h)
Packit 427e91
{
Packit 427e91
    mixer_type = type;
Packit 427e91
    if (type) {
Packit 427e91
	channel_name << "Out " << ch;
Packit 427e91
    } else {
Packit 427e91
	channel_name << "In " << ch;
Packit 427e91
    }
Packit 427e91
    channel_num = ch;
Packit 427e91
    if (channel_num%2) {
Packit 427e91
	relative_num = channel_num+1;
Packit 427e91
	p_iomixer_xpm = iomixer_xpm;
Packit 427e91
    } else {
Packit 427e91
	relative_num = channel_num-1;
Packit 427e91
	p_iomixer_xpm = iomixer_r_xpm;
Packit 427e91
    }
Packit 427e91
    for (int j = 0; j < MAX_CARDS; ++j) {
Packit 427e91
	for (int i = 0; i < NUM_PRESETS; ++i) {
Packit 427e91
	    data[j][0][i] = new HDSPMixerStripData();
Packit 427e91
	    data[j][1][i] = new HDSPMixerStripData();
Packit 427e91
	    data[j][2][i] = new HDSPMixerStripData();
Packit 427e91
	}
Packit 427e91
    }
Packit 427e91
    mutesolo = new HDSPMixerMuteSolo(x+3, y+3, 0, 0, channel_num, type);
Packit 427e91
    gain = new HDSPMixerGain(x+3, y+207, 1);
Packit 427e91
    peak = new HDSPMixerPeak(x+3, y+36, 1);
Packit 427e91
    fader = new HDSPMixerFader(x+4, y+51, 32768.0, channel_num, type);
Packit 427e91
    pan = new HDSPMixerPan(x+3, y+19, channel_num, type) ;
Packit 427e91
    targets = new HDSPMixerSelector(x+3, y+240, 29, 10);
Packit 427e91
    meter = new HDSPMixerMeter(x+20, y+59, true, peak);
Packit 427e91
    end();
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerIOMixer::draw_background() 
Packit 427e91
{
Packit 427e91
    draw_background(x(), y(), w(), h());
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerIOMixer::draw_background(int xpos, int ypos, int w, int h)
Packit 427e91
{
Packit 427e91
    fl_push_clip(xpos, ypos, w, h);
Packit 427e91
    fl_draw_pixmap(p_iomixer_xpm, x(), y());
Packit 427e91
    fl_pop_clip();
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerIOMixer::draw()
Packit 427e91
{
Packit 427e91
    Fl_Widget *const* a = array();
Packit 427e91
    if (damage() & ~FL_DAMAGE_CHILD) {
Packit 427e91
	draw_background();
Packit 427e91
	fl_color(FL_FOREGROUND_COLOR);
Packit 427e91
	fl_font(FL_HELVETICA, 8);
Packit 427e91
	fl_draw(channel_name.str().c_str(), x()+4, y()+225, 27, 9, FL_ALIGN_CENTER);
Packit 427e91
	for (int i=children(); i--;) {
Packit 427e91
	    Fl_Widget& o = **a++;
Packit 427e91
	    draw_child(o);
Packit 427e91
	}
Packit 427e91
    } else {
Packit 427e91
	for (int i=children(); i--;) update_child(**a++);
Packit 427e91
    }
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerIOMixer::update_child(Fl_Widget& widget) 
Packit 427e91
{
Packit 427e91
    if (widget.damage() && widget.visible() && widget.type() < FL_WINDOW && fl_not_clipped(widget.x(), widget.y(), widget.w(), widget.h())) {
Packit 427e91
	if ((HDSPMixerMeter*)&widget == meter) {
Packit 427e91
	    ((HDSPMixerMeter *)&widget)->fine_draw = 1;
Packit 427e91
	} else {
Packit 427e91
	    draw_background(widget.x(), widget.y(), widget.w(), widget.h());
Packit 427e91
	}
Packit 427e91
	widget.draw();
Packit 427e91
	widget.clear_damage();
Packit 427e91
    }
Packit 427e91
}
Packit 427e91