- Timestamp:
- 08/24/07 22:05:08 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
bbtracker/trunk/src/org/bbtracker/mobile/gui/OptionsForm.java
r88 r93 42 42 43 43 public class OptionsForm extends Form implements CommandListener, ItemCommandListener { 44 private static final String[] FONT_SIZE_NAMES = new String[] { "Small", "Medium", "Large" }; 45 44 46 private final TrackManager trackManager; 45 47 … … 61 63 62 64 private final ChoiceGroup statusFontSizeGroup; 65 66 private final ChoiceGroup detailsFontSizeGroup; 63 67 64 68 public OptionsForm(final TrackManager trackManager) { … … 75 79 unitsGroup.setSelectedIndex(pref.getUnits(), true); 76 80 77 statusFontSizeGroup = new ChoiceGroup("Status text size: ", Choice.POPUP, new String[] { "Small", "Medium", 78 "Large" }, null); 79 int selectedFontSizeItem; 80 switch (pref.getStatusFontSize()) { 81 case Font.SIZE_SMALL: 82 selectedFontSizeItem = 0; 83 break; 84 case Font.SIZE_MEDIUM: 85 selectedFontSizeItem = 1; 86 break; 87 case Font.SIZE_LARGE: 88 selectedFontSizeItem = 2; 89 break; 90 default: 91 selectedFontSizeItem = 1; 92 } 93 statusFontSizeGroup.setSelectedIndex(selectedFontSizeItem, true); 81 statusFontSizeGroup = new ChoiceGroup("Status text size: ", Choice.POPUP, FONT_SIZE_NAMES, null); 82 final int statusFontSizeIndex = getSelectedFontIndex(pref.getStatusFontSize()); 83 statusFontSizeGroup.setSelectedIndex(statusFontSizeIndex, true); 84 85 detailsFontSizeGroup = new ChoiceGroup("Details text size: ", Choice.POPUP, FONT_SIZE_NAMES, null); 86 final int detailsFontSizeIndex = getSelectedFontIndex(pref.getDetailsFontSize()); 87 detailsFontSizeGroup.setSelectedIndex(detailsFontSizeIndex, true); 94 88 95 89 startTypeGroup = new ChoiceGroup("Startup action: ", Choice.POPUP, Preferences.START_ACTIONS, null); … … 113 107 append(unitsGroup); 114 108 append(statusFontSizeGroup); 109 append(detailsFontSizeGroup); 115 110 append(startTypeGroup); 116 111 append(directoryField); … … 123 118 addCommand(cancelCommand); 124 119 setCommandListener(this); 120 } 121 122 private int getSelectedFontIndex(final int fontSize) { 123 int selectedIndex; 124 switch (fontSize) { 125 case Font.SIZE_SMALL: 126 selectedIndex = 0; 127 break; 128 case Font.SIZE_MEDIUM: 129 selectedIndex = 1; 130 break; 131 case Font.SIZE_LARGE: 132 selectedIndex = 2; 133 break; 134 default: 135 selectedIndex = 1; 136 } 137 return selectedIndex; 138 } 139 140 private int getFontSize(final int selectedIndex) { 141 int fontSize; 142 switch (selectedIndex) { 143 case 0: 144 fontSize = Font.SIZE_SMALL; 145 break; 146 case 1: 147 fontSize = Font.SIZE_MEDIUM; 148 break; 149 case 2: 150 fontSize = Font.SIZE_LARGE; 151 break; 152 default: 153 throw new IllegalStateException(); 154 } 155 return fontSize; 125 156 } 126 157 … … 206 237 pref.setUnits(unitsGroup.getSelectedIndex()); 207 238 208 final int newFontSize; 209 switch (statusFontSizeGroup.getSelectedIndex()) { 210 case 0: 211 newFontSize = Font.SIZE_SMALL; 212 break; 213 case 1: 214 newFontSize = Font.SIZE_MEDIUM; 215 break; 216 case 2: 217 newFontSize = Font.SIZE_LARGE; 218 break; 219 default: 220 throw new IllegalStateException(); 221 } 222 pref.setStatusFontSize(newFontSize); 239 final int statusFontSize = getFontSize(statusFontSizeGroup.getSelectedIndex()); 240 pref.setStatusFontSize(statusFontSize); 241 242 final int detailsFontSize = getFontSize(detailsFontSizeGroup.getSelectedIndex()); 243 pref.setDetailsFontSize(detailsFontSize); 223 244 224 245 pref.store();
Note: See TracChangeset
for help on using the changeset viewer.