mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-02 22:32:45 +00:00
created more listeners
This commit is contained in:
parent
ae1188ae27
commit
beb0830c25
@ -2,6 +2,8 @@ package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
@ -12,17 +14,16 @@ import javax.swing.KeyStroke;
|
||||
public class ColourQuirksAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DataPanel owner;
|
||||
List<ColourQuirksListener> listeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public ColourQuirksAction (DataPanel owner)
|
||||
public ColourQuirksAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Smear HGR");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Display pixels like a TV screen");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt Q"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_Q);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -30,6 +31,22 @@ public class ColourQuirksAction extends AbstractAction
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
owner.setColourQuirks (((JMenuItem) e.getSource ()).isSelected ());
|
||||
for (ColourQuirksListener listener : listeners)
|
||||
listener.setColourQuirks (((JMenuItem) e.getSource ()).isSelected ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addColourQuirksListener (ColourQuirksListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!listeners.contains (listener))
|
||||
listeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public interface ColourQuirksListener
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
public void setColourQuirks (boolean value);
|
||||
}
|
||||
}
|
@ -37,15 +37,17 @@ import com.bytezone.diskbrowser.applefile.QuickDrawFont;
|
||||
import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorList;
|
||||
import com.bytezone.diskbrowser.gui.ColourQuirksAction.ColourQuirksListener;
|
||||
import com.bytezone.diskbrowser.gui.DebuggingAction.DebugListener;
|
||||
import com.bytezone.diskbrowser.gui.FontAction.FontChangeEvent;
|
||||
import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
|
||||
import com.bytezone.diskbrowser.gui.MonochromeAction.MonochromeListener;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class DataPanel extends JTabbedPane
|
||||
implements DiskSelectionListener, FileSelectionListener, SectorSelectionListener,
|
||||
FileNodeSelectionListener, FontChangeListener, BasicPreferencesListener,
|
||||
AssemblerPreferencesListener, TextPreferencesListener, DebugListener
|
||||
public class DataPanel extends JTabbedPane implements DiskSelectionListener,
|
||||
FileSelectionListener, SectorSelectionListener, FileNodeSelectionListener,
|
||||
FontChangeListener, BasicPreferencesListener, AssemblerPreferencesListener,
|
||||
TextPreferencesListener, DebugListener, ColourQuirksListener, MonochromeListener
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int TEXT_WIDTH = 65;
|
||||
@ -157,8 +159,13 @@ public class DataPanel extends JTabbedPane
|
||||
menuHandler.lineWrapItem.setAction (lineWrapAction);
|
||||
lineWrapAction.addListener (formattedText);
|
||||
|
||||
menuHandler.colourQuirksItem.setAction (new ColourQuirksAction (this));
|
||||
menuHandler.monochromeItem.setAction (new MonochromeAction (this));
|
||||
ColourQuirksAction colourQuirksAction = new ColourQuirksAction ();
|
||||
colourQuirksAction.addColourQuirksListener (this);
|
||||
menuHandler.colourQuirksItem.setAction (colourQuirksAction);
|
||||
|
||||
MonochromeAction monochromeAction = new MonochromeAction ();
|
||||
monochromeAction.addMonochromeListener (this);
|
||||
menuHandler.monochromeItem.setAction (monochromeAction);
|
||||
|
||||
DebuggingAction debuggingAction = new DebuggingAction ();
|
||||
debuggingAction.addDebugListener (this);
|
||||
@ -213,6 +220,7 @@ public class DataPanel extends JTabbedPane
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public void setColourQuirks (boolean value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
|
@ -2,6 +2,8 @@ package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
@ -12,17 +14,16 @@ import javax.swing.KeyStroke;
|
||||
class MonochromeAction extends AbstractAction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DataPanel owner;
|
||||
List<MonochromeListener> listeners = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
MonochromeAction (DataPanel owner)
|
||||
MonochromeAction ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Monochrome");
|
||||
putValue (Action.SHORT_DESCRIPTION, "Display image in monochrome or color");
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt M"));
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_M);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -30,6 +31,22 @@ class MonochromeAction extends AbstractAction
|
||||
public void actionPerformed (ActionEvent e)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
owner.setMonochrome (((JMenuItem) e.getSource ()).isSelected ());
|
||||
for (MonochromeListener listener : listeners)
|
||||
listener.setMonochrome (((JMenuItem) e.getSource ()).isSelected ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addMonochromeListener (MonochromeListener listener)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!listeners.contains (listener))
|
||||
listeners.add (listener);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public interface MonochromeListener
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
public void setMonochrome (boolean value);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user