File: midicheckbox.cpp

package info (click to toggle)
ams 1.8.7-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,880 kB
  • ctags: 2,171
  • sloc: cpp: 17,793; makefile: 433; sh: 101
file content (63 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <qslider.h>
#include <qhbox.h>
#include <qvbox.h>
#include <qlabel.h>
#include <stdio.h>
#include <math.h>
#include <qstrlist.h>
#include "midicheckbox.h"
#include "synthdata.h"
#include "midiwidget.h"
#include "midiguicomponent.h"

MidiCheckBox::MidiCheckBox(QObject *parentModule, float value, QWidget * parent, const char * name, SynthData
                           *p_synthdata, float *p_valueRef)
                           : MidiGUIcomponent(parentModule, p_synthdata, parent, name) {

  componentType = GUIcomponentType_checkbox;
  valueRef = p_valueRef;
//  setSpacing(5);
//  setMargin(5);
  QWidget *dummy1 = new QWidget(this);
  QHBox *checkFrame = new QHBox(this);
  QWidget *dummy2 = new QWidget(this);
  setStretchFactor(dummy1, 3);
  setStretchFactor(checkFrame, 1);
  setStretchFactor(dummy2, 3);
  checkBox = new QCheckBox(checkFrame);  
  QLabel *nameLabel = new QLabel(checkFrame);
  if (name) {
    nameLabel->setText("  "+QString(name));
  }
  checkBox->setChecked(value > 0);
  QObject::connect(checkBox, SIGNAL(toggled(bool)), this, SLOT(updateValue(bool)));
  updateValue(value > 0);
}

MidiCheckBox::~MidiCheckBox(){
}

void MidiCheckBox::setMidiValue(int value) {

  if (midiSign == 1) {
    checkBox->setChecked(value > 124);
  } else {
    checkBox->setChecked(value <= 124);
  }
}

int MidiCheckBox::getMidiValue() {

  return((checkBox->isChecked()) ? 127 : 0);
}

void MidiCheckBox::updateValue(bool on) {

  *valueRef = on ? 1 : 0;    
}

void MidiCheckBox::updateCheck(bool on) {

  checkBox->setChecked(on);
  emit guiComponentTouched();
}