Blame hdspconf/src/HC_AutoSyncRef.cxx

Packit Service b98cfc
/*
Packit Service b98cfc
 *   HDSPConf
Packit Service b98cfc
 *    
Packit Service b98cfc
 *   Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org)
Packit Service b98cfc
 *    
Packit Service b98cfc
 *   This program is free software; you can redistribute it and/or modify
Packit Service b98cfc
 *   it under the terms of the GNU General Public License as published by
Packit Service b98cfc
 *   the Free Software Foundation; either version 2 of the License, or
Packit Service b98cfc
 *   (at your option) any later version.
Packit Service b98cfc
 *
Packit Service b98cfc
 *   This program is distributed in the hope that it will be useful,
Packit Service b98cfc
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service b98cfc
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service b98cfc
 *   GNU General Public License for more details.
Packit Service b98cfc
 *
Packit Service b98cfc
 *   You should have received a copy of the GNU General Public License
Packit Service b98cfc
 *   along with this program; if not, write to the Free Software
Packit Service b98cfc
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit Service b98cfc
 */
Packit Service b98cfc
Packit Service b98cfc
#pragma implementation
Packit Service b98cfc
#include "HC_AutoSyncRef.h"
Packit Service b98cfc
#include "labels.h"
Packit Service b98cfc
Packit Service b98cfc
HC_AutoSyncRef::HC_AutoSyncRef(int x, int y, int w, int h):Fl_Widget(x, y, w, h, "AutoSync Ref.")
Packit Service b98cfc
{
Packit Service b98cfc
	external_freq = 2;
Packit Service b98cfc
	external_ref = 3;
Packit Service b98cfc
	draw_box = Fl::get_boxtype(FL_ENGRAVED_FRAME);
Packit Service b98cfc
	label("AutoSync Ref.");
Packit Service b98cfc
	labelsize(10);
Packit Service b98cfc
	align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
void HC_AutoSyncRef::draw()
Packit Service b98cfc
{
Packit Service b98cfc
	fl_color(FL_BACKGROUND_COLOR);
Packit Service b98cfc
	fl_rectf(x(), y(), w(), h());
Packit Service b98cfc
	draw_box(x(), y(), w(), h(), FL_WHITE);
Packit Service b98cfc
	fl_color(FL_FOREGROUND_COLOR);
Packit Service b98cfc
	fl_font(FL_HELVETICA, 10);
Packit Service b98cfc
	fl_draw("Input", x()+4, y(), w()/2, h()/2, FL_ALIGN_LEFT);
Packit Service b98cfc
	fl_draw(ref[external_ref], x()+w()/2-4, y(), w()/2, h()/2, FL_ALIGN_CENTER);
Packit Service b98cfc
	fl_draw("Freq.", x()+4, y()+h()/2, w()/2, h()/2, FL_ALIGN_LEFT);
Packit Service b98cfc
	fl_draw(freqs[external_freq], x()+w()/2-4, y()+h()/2, w()/2, h()/2, FL_ALIGN_CENTER);
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
void HC_AutoSyncRef::setFreq(int f)
Packit Service b98cfc
{
Packit Service b98cfc
	int freq;
Packit Service b98cfc
	switch (f) {
Packit Service b98cfc
	case 32000:
Packit Service b98cfc
	    freq = 0;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 44100:
Packit Service b98cfc
	    freq = 1;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 48000:
Packit Service b98cfc
	    freq = 2;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 64000:
Packit Service b98cfc
	    freq = 3;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 88200:
Packit Service b98cfc
	    freq = 4;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 96000:
Packit Service b98cfc
	    freq = 5;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 128000:
Packit Service b98cfc
	    freq = 7;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 176400:
Packit Service b98cfc
	    freq = 8;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	case 192000:
Packit Service b98cfc
	    freq = 9;
Packit Service b98cfc
	    break;
Packit Service b98cfc
	default:
Packit Service b98cfc
	    freq = 6;
Packit Service b98cfc
	}	    
Packit Service b98cfc
	if (freq != external_freq) {
Packit Service b98cfc
	    external_freq = freq;
Packit Service b98cfc
	    redraw();
Packit Service b98cfc
	}
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
void HC_AutoSyncRef::setRef(unsigned char r)
Packit Service b98cfc
{
Packit Service b98cfc
	if (r == external_ref) return;
Packit Service b98cfc
	if (r > 6) external_ref = 3;
Packit Service b98cfc
	else external_ref = r;
Packit Service b98cfc
	redraw();
Packit Service b98cfc
}
Packit Service b98cfc