Subversion Repositories svn.mios32

Rev

Rev 1503 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
932 tk 1
/* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
2
// $Id: ConfigTableComponents.cpp 1724 2013-03-28 20:23:40Z tk $
3
/*
4
 * MIDIO128 Tool Window
5
 *
6
 * ==========================================================================
7
 *
8
 *  Copyright (C) 2010 Thorsten Klose (tk@midibox.org)
9
 *  Licensed for personal non-commercial use only.
10
 *  All other rights reserved.
11
 *
12
 * ==========================================================================
13
 */
14
 
15
#include "ConfigTableComponents.h"
16
 
17
 
18
ConfigTableComboBox::ConfigTableComboBox(ConfigTableController& _owner)
19
    : owner(_owner)
20
{
21
    addAndMakeVisible(comboBox = new ComboBox(String::empty));
22
    comboBox->addListener(this);
23
    comboBox->setWantsKeyboardFocus(true);
24
}
25
 
26
ConfigTableComboBox::~ConfigTableComboBox()
27
{
1194 tk 28
    deleteAllChildren();
932 tk 29
}
30
 
31
void ConfigTableComboBox::resized()
32
{
1724 tk 33
    comboBox->setBoundsInset(BorderSize<int>(2));
932 tk 34
}
35
 
36
void ConfigTableComboBox::setRowAndColumn(const int newRow, const int newColumn)
37
{
38
    row = newRow;
39
    columnId = newColumn;
40
    comboBox->setSelectedId(owner.getTableValue(row, columnId), true);
41
}
42
 
43
void ConfigTableComboBox::comboBoxChanged(ComboBox* comboBoxThatHasChanged)
44
{
45
    owner.setTableValue(row, columnId, comboBox->getSelectedId());
46
}
47
 
48
void ConfigTableComboBox::addItem(const String &newItemText, const int newItemId)
49
{
50
    comboBox->addItem(newItemText, newItemId);
51
}
52
 
53
 
54
//==============================================================================
55
//==============================================================================
56
//==============================================================================
57
ConfigTableSlider::ConfigTableSlider(ConfigTableController& _owner)
58
    : owner(_owner)
59
{
60
    addAndMakeVisible(slider = new Slider(String::empty));
61
    slider->addListener(this);
62
    slider->setRange(0, 127, 1);
63
    slider->setSliderStyle(Slider::IncDecButtons);
64
    slider->setTextBoxStyle(Slider::TextBoxLeft, false, 80, 20);
65
    slider->setDoubleClickReturnValue(true, 0);
66
}
67
 
68
ConfigTableSlider::~ConfigTableSlider()
69
{
1194 tk 70
    deleteAllChildren();
932 tk 71
}
72
 
73
void ConfigTableSlider::resized()
74
{
1724 tk 75
    slider->setBoundsInset(BorderSize<int>(2));
932 tk 76
}
77
 
78
void ConfigTableSlider::setRowAndColumn(const int newRow, const int newColumn)
79
{
80
    row = newRow;
81
    columnId = newColumn;
1724 tk 82
    slider->setValue(owner.getTableValue(row, columnId), dontSendNotification);
932 tk 83
}
84
 
85
void ConfigTableSlider::sliderValueChanged(Slider *slider)
86
{
87
    owner.setTableValue(row, columnId, slider->getValue());
88
}
89
 
90
void ConfigTableSlider::setRange(const double newMinimum, const double newMaximum)
91
{
92
    slider->setRange(newMinimum, newMaximum, 1);
93
}
935 tk 94
 
95
 
96
//==============================================================================
97
//==============================================================================
98
//==============================================================================
99
ConfigTableToggleButton::ConfigTableToggleButton(ConfigTableController& _owner)
100
    : owner(_owner)
101
{
102
    addAndMakeVisible(toggleButton = new ToggleButton(String::empty));
1502 tk 103
    toggleButton->addListener(this);
935 tk 104
}
105
 
106
ConfigTableToggleButton::~ConfigTableToggleButton()
107
{
1194 tk 108
    deleteAllChildren();
935 tk 109
}
110
 
111
void ConfigTableToggleButton::resized()
112
{
1724 tk 113
    toggleButton->setBoundsInset(BorderSize<int>(2));
935 tk 114
}
115
 
116
void ConfigTableToggleButton::setRowAndColumn(const int newRow, const int newColumn)
117
{
118
    row = newRow;
119
    columnId = newColumn;
120
    toggleButton->setToggleState(owner.getTableValue(row, columnId), true);
121
}
122
 
123
void ConfigTableToggleButton::buttonClicked(Button *button)
124
{
125
    owner.setTableValue(row, columnId, button->getToggleState());
126
}
1502 tk 127
 
128
 
129
//==============================================================================
130
//==============================================================================
131
//==============================================================================
132
ConfigTableLabel::ConfigTableLabel(ConfigTableController& _owner)
133
    : owner(_owner)
134
{
135
    addAndMakeVisible(label = new Label(String::empty));
136
    label->setEditable(true);
137
    label->addListener(this);
138
}
139
 
140
ConfigTableLabel::~ConfigTableLabel()
141
{
142
    deleteAllChildren();
143
}
144
 
145
void ConfigTableLabel::resized()
146
{
1724 tk 147
    label->setBoundsInset(BorderSize<int>(2));
1502 tk 148
}
149
 
150
void ConfigTableLabel::setRowAndColumn(const int newRow, const int newColumn)
151
{
152
    row = newRow;
153
    columnId = newColumn;
1503 tk 154
 
155
    String content(owner.getTableString(row, columnId));
156
 
157
    label->setText(content, false);
158
    if( !content.compare(T("no name available")) ) {
159
        label->setEnabled(false);
160
        label->setEditable(false);
161
    } else {
162
        label->setEnabled(true);
163
        label->setEditable(true);
164
    }
1502 tk 165
}
166
 
167
void ConfigTableLabel::labelTextChanged(Label *labelThatHasBeenChanged)
168
{
169
    owner.setTableString(row, columnId, label->getText());
170
}