Blame hdspmixer/src/HDSPMixerCardSelector.cxx

Packit Service b98cfc
/*
Packit Service b98cfc
 *   HDSPMixer
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 "HDSPMixerCardSelector.h"
Packit Service b98cfc
Packit Service b98cfc
HDSPMixerCardSelector::HDSPMixerCardSelector(int x, int y, int w, int h, int cardnum):Fl_Widget(x, y, 61, 13)
Packit Service b98cfc
{
Packit Service b98cfc
    basew = (HDSPMixerWindow *)window();
Packit Service b98cfc
    card = cardnum;
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
Packit Service b98cfc
void HDSPMixerCardSelector::draw() 
Packit Service b98cfc
{
Packit Service b98cfc
    switch (card) {
Packit Service b98cfc
	case 1:
Packit Service b98cfc
	    fl_draw_pixmap(b_card1_xpm, x(), y());
Packit Service b98cfc
	    return;
Packit Service b98cfc
	case 2:
Packit Service b98cfc
	    fl_draw_pixmap(b_card2_xpm, x()+24, y());
Packit Service b98cfc
	    return;
Packit Service b98cfc
	case 3:
Packit Service b98cfc
	    fl_draw_pixmap(b_card3_xpm, x()+48, y());
Packit Service b98cfc
	    return;
Packit Service b98cfc
	default:
Packit Service b98cfc
	    return;
Packit Service b98cfc
    }    
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
void HDSPMixerCardSelector::ActivateCard (int i)
Packit Service b98cfc
{
Packit Service b98cfc
  card = i + 1;
Packit Service b98cfc
  basew->stashPreset(); /* save current mixer state */
Packit Service b98cfc
  basew->current_card = i;
Packit Service b98cfc
  basew->cards[i]->setMode (basew->cards[i]->getSpeed ());
Packit Service b98cfc
  basew->setTitleWithFilename();
Packit Service b98cfc
  basew->unstashPreset(); /* restore previous mixer state */
Packit Service b98cfc
  redraw ();
Packit Service b98cfc
}
Packit Service b98cfc
Packit Service b98cfc
int HDSPMixerCardSelector::handle(int e)
Packit Service b98cfc
{
Packit Service b98cfc
    int xpos = Fl::event_x()-x();
Packit Service b98cfc
    switch (e) {
Packit Service b98cfc
	case FL_PUSH:
Packit Service b98cfc
	    if (xpos < 13 && card != 1)
Packit Service b98cfc
	      ActivateCard (0);
Packit Service b98cfc
	    else if (xpos >= 24 && xpos < 37 && card != 2 && basew->cards[1] != NULL)
Packit Service b98cfc
	      ActivateCard (1);
Packit Service b98cfc
	    else if (xpos >= 48 && card != 3 && basew->cards[2] != NULL)
Packit Service b98cfc
	      ActivateCard (2);
Packit Service b98cfc
	    return 1;
Packit Service b98cfc
	default:
Packit Service b98cfc
	    return Fl_Widget::handle(e);
Packit Service b98cfc
    }    
Packit Service b98cfc
}