00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import javax.swing.*;
00036 import java.awt.*;
00037 import java.awt.event.*;
00038
00039
00040 public class OptionMenu extends ExtendedMenu
00041 {
00042 class subMenu extends ExtendedMenu
00043 {
00044 public OptionMenu parent;
00045 public ExtendedCheckBox four;
00046 public ExtendedCheckBox two;
00047 public ExtendedCheckBox one;
00048 public ExtendedCheckBox half;
00049 public ExtendedCheckBox quarter;
00050
00051
00052 public subMenu(String name, OptionMenu m) {
00053 super(name);
00054 parent = m;
00055
00056 four = new ExtendedCheckBox("400%", this);
00057 two = new ExtendedCheckBox("200%", this);
00058 one = new ExtendedCheckBox("100%", this, true);
00059 half = new ExtendedCheckBox("50%", this);
00060 quarter = new ExtendedCheckBox("25%", this);
00061
00062 four.addActionListener(m.gui);
00063 two.addActionListener(m.gui);
00064 one.addActionListener(m.gui);
00065 half.addActionListener(m.gui);
00066 quarter.addActionListener(m.gui);
00067
00068 add(four);
00069 add(two);
00070 add(one);
00071 add(half);
00072 add(quarter);
00073 }
00074
00075
00076 public void handleAction(String s) {
00077 if (s.equalsIgnoreCase("400%")) {
00078 two.setState(false);
00079 one.setState(false);
00080 half.setState(false);
00081 quarter.setState(false);
00082 parent.zoom_state = 2;
00083 } else if (s.equalsIgnoreCase("200%")) {
00084 four.setState(false);
00085 one.setState(false);
00086 half.setState(false);
00087 quarter.setState(false);
00088 parent.zoom_state = 1;
00089 } else if (s.startsWith("100%")) {
00090 four.setState(false);
00091 two.setState(false);
00092 half.setState(false);
00093 quarter.setState(false);
00094 parent.zoom_state = 0;
00095 } else if (s.equalsIgnoreCase("50%")) {
00096 four.setState(false);
00097 two.setState(false);
00098 one.setState(false);
00099 quarter.setState(false);
00100 parent.zoom_state = -1;
00101 } else if (s.equalsIgnoreCase("25%")) {
00102 four.setState(false);
00103 two.setState(false);
00104 one.setState(false);
00105 half.setState(false);
00106 parent.zoom_state = -2;
00107 }
00108 gui.zoom(parent.zoom_state);
00109 }
00110 }
00111
00112
00113 public int zoom_state;
00114 public int actual_zoom;
00115 public SenseGui gui;
00116
00117 private subMenu zoom;
00118
00119
00120 public OptionMenu(String name, SenseGui g) {
00121 super(name);
00122 gui = g;
00123 zoom_state = 0;
00124 actual_zoom = 100;
00125
00126 ExtendedMenuItem zin = new ExtendedMenuItem("Zoom In", this);
00127 ExtendedMenuItem zout = new ExtendedMenuItem("Zoom Out", this);
00128 zin.addActionListener(gui);
00129 zout.addActionListener(gui);
00130 add(zin);
00131 add(zout);
00132
00133 zoom = new subMenu("Zoom", this);
00134 add(zoom);
00135
00136 if (gui.in_browser == false) {
00137 addSeparator();
00138 ExtendedMenuItem ex = new ExtendedMenuItem("Exit", this);
00139 ex.addActionListener(gui);
00140 add(ex);
00141 }
00142 }
00143
00144
00145 public int zup() {
00146 zoom.four.setState(false);
00147 zoom.two.setState(false);
00148 zoom.one.setState(false);
00149 zoom.half.setState(false);
00150 zoom.quarter.setState(false);
00151 if (zoom_state < 2)
00152 zoom_state++;
00153
00154 switch (zoom_state) {
00155 case -2:
00156 zoom.quarter.setState(true);
00157 break;
00158 case -1:
00159 zoom.half.setState(true);
00160 break;
00161 case 0:
00162 zoom.one.setState(true);
00163 break;
00164 case 1:
00165 zoom.two.setState(true);
00166 break;
00167 case 2:
00168 zoom.four.setState(true);
00169 break;
00170 default:
00171 break;
00172 }
00173 return zoom_state;
00174 }
00175
00176
00177 public int zdn() {
00178 zoom.four.setState(false);
00179 zoom.two.setState(false);
00180 zoom.one.setState(false);
00181 zoom.half.setState(false);
00182 zoom.quarter.setState(false);
00183 if (zoom_state > -2)
00184 zoom_state--;
00185
00186 switch (zoom_state) {
00187 case -2:
00188 zoom.quarter.setState(true);
00189 break;
00190 case -1:
00191 zoom.half.setState(true);
00192 break;
00193 case 0:
00194 zoom.one.setState(true);
00195 break;
00196 case 1:
00197 zoom.two.setState(true);
00198 break;
00199 case 2:
00200 zoom.four.setState(true);
00201 break;
00202 default:
00203 break;
00204 }
00205 return zoom_state;
00206 }
00207
00208
00209 public void handleAction(String s) {
00210 if (s.equalsIgnoreCase("Zoom In"))
00211 zup();
00212 else if (s.equalsIgnoreCase("Zoom Out"))
00213 zdn();
00214 else if (s.equalsIgnoreCase("Exit"))
00215 gui.quit();
00216
00217 gui.zoom(zoom_state);
00218 }
00219 }