Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
213 tk 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.sidedit.gui.controls;
22
 
23
import java.awt.BorderLayout;
628 adamjking 24
import java.awt.Dimension;
213 tk 25
import java.awt.FlowLayout;
628 adamjking 26
import java.awt.Font;
213 tk 27
import java.awt.event.ActionEvent;
28
 
628 adamjking 29
import javax.swing.JComboBox;
30
import javax.swing.JPanel;
213 tk 31
 
628 adamjking 32
import org.midibox.sidedit.SIDSysexParameterControl;
213 tk 33
 
34
public class SIDSysexParameterControlCombo extends SIDSysexParameterControlGUI {
35
 
36
    public static float mouseWheelResolution = 10.0f;
37
    private JComboBox combo;
38
 
628 adamjking 39
    public SIDSysexParameterControlCombo(
40
            SIDSysexParameterControl midiParameter, JComboBox combo,
41
            boolean showLabel, String labelLocation, boolean valueBelow,
42
            boolean showValue) {
213 tk 43
        super(midiParameter, showLabel, labelLocation, valueBelow, showValue);
44
        this.combo = combo;
628 adamjking 45
        combo.setPreferredSize(new Dimension(110, 20));
213 tk 46
        combo.setFont(new Font("sansserif", Font.BOLD, 11));
47
        JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
48
        panel.setOpaque(false);
49
        panel.add(combo);
50
        add(panel, BorderLayout.CENTER);
51
        combo.addActionListener(this);
52
        combo.addMouseListener(this);
628 adamjking 53
        updateGraphics();
213 tk 54
    }
628 adamjking 55
 
213 tk 56
    public void actionPerformed(ActionEvent ae) {
57
 
58
        super.actionPerformed(ae);
59
 
60
        if (ae.getSource() == combo) {
61
            if (update) {
62
                update = false;
628 adamjking 63
                int newval = midiParameter.lookUpAlias((String) combo
64
                        .getSelectedItem());
213 tk 65
                midiParameter.setMidiValue(newval, true);
628 adamjking 66
 
213 tk 67
                for (int c = 0; c < midiParameters.size(); c++) {
628 adamjking 68
                    SIDSysexParameterControl mp = (SIDSysexParameterControl) midiParameters
69
                            .elementAt(c);
272 rutgerv 70
                    mp.setMidiValue(newval, false);
213 tk 71
                }
628 adamjking 72
 
213 tk 73
                update = true;
74
            }
75
        }
76
    }
628 adamjking 77
 
213 tk 78
    public void updateGraphics() {
79
        super.updateGraphics();
80
        if (update) {
81
            update = false;
628 adamjking 82
            combo.setSelectedIndex(midiParameter.lookUpValue(midiParameter
83
                    .getMidiValue()));
213 tk 84
            update = true;
85
        }
86
    }
87
}