Blame hdspconf/src/HC_AutoSyncRef.cxx

Packit 427e91
/*
Packit 427e91
 *   HDSPConf
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 "HC_AutoSyncRef.h"
Packit 427e91
#include "labels.h"
Packit 427e91
Packit 427e91
HC_AutoSyncRef::HC_AutoSyncRef(int x, int y, int w, int h):Fl_Widget(x, y, w, h, "AutoSync Ref.")
Packit 427e91
{
Packit 427e91
	external_freq = 2;
Packit 427e91
	external_ref = 3;
Packit 427e91
	draw_box = Fl::get_boxtype(FL_ENGRAVED_FRAME);
Packit 427e91
	label("AutoSync Ref.");
Packit 427e91
	labelsize(10);
Packit 427e91
	align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
Packit 427e91
}
Packit 427e91
Packit 427e91
void HC_AutoSyncRef::draw()
Packit 427e91
{
Packit 427e91
	fl_color(FL_BACKGROUND_COLOR);
Packit 427e91
	fl_rectf(x(), y(), w(), h());
Packit 427e91
	draw_box(x(), y(), w(), h(), FL_WHITE);
Packit 427e91
	fl_color(FL_FOREGROUND_COLOR);
Packit 427e91
	fl_font(FL_HELVETICA, 10);
Packit 427e91
	fl_draw("Input", x()+4, y(), w()/2, h()/2, FL_ALIGN_LEFT);
Packit 427e91
	fl_draw(ref[external_ref], x()+w()/2-4, y(), w()/2, h()/2, FL_ALIGN_CENTER);
Packit 427e91
	fl_draw("Freq.", x()+4, y()+h()/2, w()/2, h()/2, FL_ALIGN_LEFT);
Packit 427e91
	fl_draw(freqs[external_freq], x()+w()/2-4, y()+h()/2, w()/2, h()/2, FL_ALIGN_CENTER);
Packit 427e91
}
Packit 427e91
Packit 427e91
void HC_AutoSyncRef::setFreq(int f)
Packit 427e91
{
Packit 427e91
	int freq;
Packit 427e91
	switch (f) {
Packit 427e91
	case 32000:
Packit 427e91
	    freq = 0;
Packit 427e91
	    break;
Packit 427e91
	case 44100:
Packit 427e91
	    freq = 1;
Packit 427e91
	    break;
Packit 427e91
	case 48000:
Packit 427e91
	    freq = 2;
Packit 427e91
	    break;
Packit 427e91
	case 64000:
Packit 427e91
	    freq = 3;
Packit 427e91
	    break;
Packit 427e91
	case 88200:
Packit 427e91
	    freq = 4;
Packit 427e91
	    break;
Packit 427e91
	case 96000:
Packit 427e91
	    freq = 5;
Packit 427e91
	    break;
Packit 427e91
	case 128000:
Packit 427e91
	    freq = 7;
Packit 427e91
	    break;
Packit 427e91
	case 176400:
Packit 427e91
	    freq = 8;
Packit 427e91
	    break;
Packit 427e91
	case 192000:
Packit 427e91
	    freq = 9;
Packit 427e91
	    break;
Packit 427e91
	default:
Packit 427e91
	    freq = 6;
Packit 427e91
	}	    
Packit 427e91
	if (freq != external_freq) {
Packit 427e91
	    external_freq = freq;
Packit 427e91
	    redraw();
Packit 427e91
	}
Packit 427e91
}
Packit 427e91
Packit 427e91
void HC_AutoSyncRef::setRef(unsigned char r)
Packit 427e91
{
Packit 427e91
	if (r == external_ref) return;
Packit 427e91
	if (r > 6) external_ref = 3;
Packit 427e91
	else external_ref = r;
Packit 427e91
	redraw();
Packit 427e91
}
Packit 427e91