Subversion Repositories svn.mios

Rev

Rev 293 | Rev 639 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 293 Rev 628
Line 19... Line 19...
19
 */
19
 */
20
20
21
package org.midibox.sidedit.gui;
21
package org.midibox.sidedit.gui;
22
22
23
import java.awt.BorderLayout;
23
import java.awt.BorderLayout;
24
import java.awt.Color;
-
 
25
import java.awt.Dimension;
24
import java.awt.Dimension;
26
import java.awt.GradientPaint;
-
 
27
import java.awt.Graphics;
25
import java.awt.Frame;
28
import java.awt.Graphics2D;
-
 
29
import java.awt.GridBagConstraints;
-
 
30
import java.awt.GridBagLayout;
-
 
31
import java.awt.GridLayout;
-
 
32
import java.awt.Insets;
-
 
33
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionEvent;
34
import java.awt.event.ActionListener;
27
import java.awt.event.ActionListener;
-
 
28
import java.awt.event.WindowAdapter;
-
 
29
import java.awt.event.WindowEvent;
35
import java.util.Observable;
30
import java.util.Observable;
36
import java.util.Observer;
31
import java.util.Observer;
37
import javax.sound.midi.Receiver;
-
 
38
32
39
import javax.swing.BorderFactory;
33
import javax.swing.BorderFactory;
40
import javax.swing.BoxLayout;
34
import javax.swing.BoxLayout;
41
import javax.swing.Icon;
35
import javax.swing.JDialog;
42
import javax.swing.ImageIcon;
-
 
43
import javax.swing.JLabel;
36
import javax.swing.JLabel;
44
import javax.swing.JOptionPane;
37
import javax.swing.JOptionPane;
45
import javax.swing.JPanel;
38
import javax.swing.JPanel;
46
import javax.swing.JSlider;
-
 
47
import javax.swing.JTabbedPane;
-
 
48
import javax.swing.JComponent;
-
 
49
import javax.swing.JTextField;
-
 
50
-
 
51
import javax.swing.JToggleButton;
39
import javax.swing.JToggleButton;
52
import javax.swing.SpinnerNumberModel;
40
import javax.swing.border.BevelBorder;
53
import javax.swing.SwingConstants;
-
 
54
import javax.swing.event.ChangeEvent;
-
 
55
import javax.swing.event.ChangeListener;
-
 
56
import javax.swing.event.MouseInputAdapter;
-
 
57
41
-
 
42
import org.midibox.sidedit.SIDEditController;
-
 
43
import org.midibox.sidedit.gui.bassline.BasslineGUI;
-
 
44
import org.midibox.sidedit.gui.drum.DrumGUI;
-
 
45
import org.midibox.sidedit.gui.lead.LeadGUI;
-
 
46
import org.midibox.sidedit.gui.multi.MultiGUI;
58
import org.midibox.sidlibr.Patch;
47
import org.midibox.sidlibr.Patch;
59
import org.midibox.sidedit.gui.lead.*;
-
 
60
import org.midibox.sidedit.gui.bassline.*;
-
 
61
import org.midibox.sidedit.gui.drum.*;
-
 
62
import org.midibox.sidedit.gui.multi.*;
-
 
63
import org.midibox.midi.*;
-
 
64
import org.midibox.sidedit.*;
-
 
65
import org.midibox.utils.gui.FontLoader;
-
 
66
import org.midibox.utils.gui.ImageLoader;
48
import org.midibox.utils.gui.ImageLoader;
67
import org.midibox.utils.gui.Knob;
-
 
68
import org.midibox.utils.gui.MyButtonUI;
49
import org.midibox.utils.gui.MyButtonUI;
69
import java.util.Vector;
-
 
70
import javax.swing.event.*;
-
 
71
import java.io.*;
-
 
72
import java.awt.event.*;
-
 
73
import javax.swing.JInternalFrame;
-
 
74
import javax.swing.JDialog;
-
 
75
import java.awt.Frame;
-
 
76
import javax.swing.border.BevelBorder;
-
 
77
import javax.swing.border.EtchedBorder;
-
 
-
 
50
78
public class MBSIDV2EditorGUI extends JDialog implements Observer, ActionListener {
51
public class MBSIDV2EditorGUI extends JDialog implements Observer,
-
 
52
        ActionListener {
79
53
80
    private SIDEditController sidEditController;
54
    private SIDEditController sidEditController;
81
55
82
    private JPanel editPanel;
56
    private JPanel editPanel;
83
   
57
84
    private JLabel tooltipLabel;
58
    private JLabel tooltipLabel;
85
   
59
86
    private JToggleButton stereoLink, oscillatorLink, core1Button, core2Button, core3Button, core4Button;
60
    private JToggleButton stereoLink, oscillatorLink, core1Button, core2Button,
-
 
61
            core3Button, core4Button;
87
   
62
88
    public MBSIDV2EditorGUI(Frame owner, boolean modal) {
63
    public MBSIDV2EditorGUI(Frame owner, boolean modal) {
89
        super(owner, modal);   
64
        super(owner, modal);
90
       
65
91
        setTitle("MidiBox SID V2 Editor - no patch selected");     
66
        setTitle("MidiBox SID V2 Editor - no patch selected");
Line 104... Line 79...
104
        add(editPanel, BorderLayout.NORTH);
79
        add(editPanel, BorderLayout.NORTH);
105
        pack();
80
        pack();
106
    }
81
    }
107
   
82
108
    public void editThis(SIDEditController sidEditController, int cores) {     
83
    public void editThis(SIDEditController sidEditController, int cores) {
-
 
84
        if (isVisible()) {
-
 
85
-
 
86
            int result = JOptionPane
-
 
87
                    .showConfirmDialog(
-
 
88
                            null,
-
 
89
                            "The current patch has been changed. Would you like to save?",
-
 
90
                            "Save patch?", JOptionPane.YES_NO_CANCEL_OPTION,
-
 
91
                            JOptionPane.QUESTION_MESSAGE);
-
 
92
            switch (result) {
-
 
93
            case JOptionPane.YES_OPTION:
-
 
94
                sidEditController.Save();
-
 
95
                break;
-
 
96
            case JOptionPane.NO_OPTION:
-
 
97
                break;
-
 
98
            case JOptionPane.CANCEL_OPTION:
-
 
99
                return;
-
 
100
            default:
-
 
101
                break;
-
 
102
            }
-
 
103
-
 
104
        }
-
 
105
109
        this.sidEditController = sidEditController;
106
        this.sidEditController = sidEditController;
110
        sidEditController.setTooltipListener(this);
107
        sidEditController.setTooltipListener(this);
111
        Patch p = sidEditController.getPatch();
108
        Patch p = sidEditController.getPatch();
112
        stereoLink.setSelected(true);
109
        stereoLink.setSelected(true);
113
        oscillatorLink.setSelected(false);
110
        oscillatorLink.setSelected(false);
114
        setTooltip("");
111
        setTooltip("");
115
        core1Button.setSelected(((cores&0x01)>0));
112
        core1Button.setSelected(((cores & 0x01) > 0));
116
        core2Button.setSelected(((cores&0x02)>0));
113
        core2Button.setSelected(((cores & 0x02) > 0));
117
        core3Button.setSelected(((cores&0x04)>0));
114
        core3Button.setSelected(((cores & 0x04) > 0));
118
        core4Button.setSelected(((cores&0x08)>0));     
115
        core4Button.setSelected(((cores & 0x08) > 0));
119
        this.setTitle("MidiBox SID V2 Editor - " + p.getEngineStr() + " engine: " + p.getPatchName());
116
        this.setTitle("MidiBox SID V2 Editor - " + p.getEngineStr()
-
 
117
                + " engine: " + p.getPatchName());
120
        sidEditController.addObserver(this);
118
        sidEditController.addObserver(this);
121
        remove(editPanel); 
119
        remove(editPanel);
122
       
120
123
        if (p.getEngine()==p.LEAD) {
121
        if (p.getEngine() == p.LEAD) {
124
            editPanel = new LeadGUI(sidEditController);
122
            editPanel = new LeadGUI(sidEditController);
Line 152... Line 150...
152
        JPanel statusBar = new JPanel();
150
        JPanel statusBar = new JPanel();
153
        statusBar.setLayout(new BorderLayout());       
151
        statusBar.setLayout(new BorderLayout());
154
        statusBar.setBorder(BorderFactory.createRaisedBevelBorder());
152
        statusBar.setBorder(BorderFactory.createRaisedBevelBorder());
155
               
153
156
        stereoLink = new JToggleButton("Stereo link");
154
        stereoLink = new JToggleButton("Stereo link");
157
        stereoLink.setPreferredSize(new Dimension(stereoLink.getPreferredSize().width,20));
155
        stereoLink.setPreferredSize(new Dimension(
-
 
156
                stereoLink.getPreferredSize().width, 20));
158
        stereoLink.addActionListener(this);
157
        stereoLink.addActionListener(this);
159
       
158
160
        oscillatorLink = new JToggleButton("Oscillator link");
159
        oscillatorLink = new JToggleButton("Oscillator link");
161
        oscillatorLink.setPreferredSize(new Dimension(oscillatorLink.getPreferredSize().width,20));
160
        oscillatorLink.setPreferredSize(new Dimension(oscillatorLink
-
 
161
                .getPreferredSize().width, 20));
162
        oscillatorLink.addActionListener(this);
162
        oscillatorLink.addActionListener(this);
163
       
163
164
        JPanel buttonPanel = new JPanel();
164
        JPanel buttonPanel = new JPanel();
165
        buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));   
165
        buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
-
 
166
        buttonPanel.setBorder(BorderFactory
166
        buttonPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
167
                .createBevelBorder(BevelBorder.LOWERED));
167
        JLabel coreLabel = new JLabel("Cores: ");
168
        JLabel coreLabel = new JLabel("Cores: ");
168
        core1Button = new JToggleButton();     
169
        core1Button = new JToggleButton();
169
        core1Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"), ImageLoader.getImageIcon("txOff.png")));    
170
        core1Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"),
-
 
171
                ImageLoader.getImageIcon("txOff.png")));
170
        core1Button.setEnabled(false);
172
        core1Button.setEnabled(false);
171
        core2Button = new JToggleButton();     
173
        core2Button = new JToggleButton();
172
        core2Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"), ImageLoader.getImageIcon("txOff.png")));    
174
        core2Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"),
-
 
175
                ImageLoader.getImageIcon("txOff.png")));
173
        core2Button.setEnabled(false);
176
        core2Button.setEnabled(false);
174
        core3Button = new JToggleButton();     
177
        core3Button = new JToggleButton();
175
        core3Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"), ImageLoader.getImageIcon("txOff.png")));    
178
        core3Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"),
-
 
179
                ImageLoader.getImageIcon("txOff.png")));
176
        core3Button.setEnabled(false);
180
        core3Button.setEnabled(false);
177
        core4Button = new JToggleButton();     
181
        core4Button = new JToggleButton();
178
        core4Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"), ImageLoader.getImageIcon("txOff.png")));    
182
        core4Button.setUI(new MyButtonUI(ImageLoader.getImageIcon("txOn.png"),
-
 
183
                ImageLoader.getImageIcon("txOff.png")));
179
        core4Button.setEnabled(false);
184
        core4Button.setEnabled(false);
180
        buttonPanel.add(coreLabel);
185
        buttonPanel.add(coreLabel);
181
        buttonPanel.add(core1Button);
186
        buttonPanel.add(core1Button);
182
        buttonPanel.add(core2Button);
187
        buttonPanel.add(core2Button);
183
        buttonPanel.add(core3Button);
188
        buttonPanel.add(core3Button);
184
        buttonPanel.add(core4Button);
189
        buttonPanel.add(core4Button);
185
       
190
186
        JLabel empty1Label = new JLabel();     
191
        JLabel empty1Label = new JLabel();
-
 
192
        empty1Label.setBorder(BorderFactory
187
        empty1Label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
193
                .createBevelBorder(BevelBorder.LOWERED));
188
               
194
189
        tooltipLabel = new JLabel("");     
195
        tooltipLabel = new JLabel("");
-
 
196
        tooltipLabel.setBorder(BorderFactory
190
        tooltipLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
197
                .createBevelBorder(BevelBorder.LOWERED));
191
       
198
192
        JPanel linkPanel = new JPanel();
199
        JPanel linkPanel = new JPanel();
193
        linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS));
200
        linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS));
194
        linkPanel.add(stereoLink);
201
        linkPanel.add(stereoLink);
195
        linkPanel.add(oscillatorLink);
202
        linkPanel.add(oscillatorLink);
Line 200... Line 207...
200
       
207
201
        return statusBar;
208
        return statusBar;
202
    }
209
    }
203
       
210
204
    private void saveAndClose() {
211
    private void saveAndClose() {
-
 
212
        int result = JOptionPane.showConfirmDialog(null,
205
        int result = JOptionPane.showConfirmDialog(null, "The current patch has been changed. Would you like to save?", "Save patch?", JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE );
213
                "The current patch has been changed. Would you like to save?",
-
 
214
                "Save patch?", JOptionPane.YES_NO_CANCEL_OPTION,
-
 
215
                JOptionPane.QUESTION_MESSAGE);
206
        switch(result) {
216
        switch (result) {
207
            case JOptionPane.YES_OPTION:
217
        case JOptionPane.YES_OPTION:
208
                sidEditController.Save();
218
            sidEditController.Save();
209
                this.setVisible(false);            
219
            this.setVisible(false);
210
                break;
220
            break;