/** Eventhandler */ public void onEvent(Event ev) { if (ev instanceof MenuEvent) { if (ev.type == MenuEvent.SELECTED) { if (((MenuEvent) ev).menu == mnuContextFormt) { mnuContextFormt.close(); mnuContextFormt.getItemAt(currFormatSel).modifiers &= ~MenuItem.Checked; currFormatSel = mnuContextFormt.getInt(); mnuContextFormt.getItemAt(currFormatSel).modifiers |= MenuItem.Checked; lblPosition.setText( myNavigation.gpsPos.toString(CoordsScreen.getLocalSystem(currFormatSel))); btnGoto.setText(getGotoBtnText()); } // end lat-lon-format context menu if (((MenuEvent) ev).menu == mnuContextRose) { MenuItem action = (MenuItem) mnuContextRose.getSelectedItem(); if (action != null) { for (int i = 0; i < miLuminary.length; i++) { if (action == miLuminary[i]) { myNavigation.setLuminary(i); miLuminary[i].modifiers |= MenuItem.Checked; compassRose.setLuminaryName(SkyOrientation.getLuminaryName(myNavigation.luminary)); } else miLuminary[i].modifiers &= ~MenuItem.Checked; } if (action == miNorthCentered) { if (compassRose.isNorthCentered()) { compassRose.setNorthCentered(false); miNorthCentered.modifiers &= ~MenuItem.Checked; } else { compassRose.setNorthCentered(true); miNorthCentered.modifiers |= MenuItem.Checked; } } } } } } if (ev instanceof ControlEvent && ev.type == ControlEvent.PRESSED) { // start/stop GPS connection if (ev.target == btnGPS) { if (btnGPS.getText().equals(MyLocale.getMsg(1504, "Start"))) startGps(); else myNavigation.stopGps(); } // set current position as centre and recalculate distance of caches in MainTab if (ev.target == btnCenter) { if (myNavigation.gpsPos.isValid()) { pref.setCurCentrePt(myNavigation.gpsPos); } else (new MessageBox( MyLocale.getMsg(312, "Error"), MyLocale.getMsg( 1514, "Cannot recalculate distances, because the GPS position is not set"), FormBase.OKB)) .execute(); } // Start moving map if (ev.target == btnMap) { switchToMovingMap(); } // create new waypoint with current GPS-position if (ev.target == btnSave) { CacheHolder ch = new CacheHolder(); ch.setPos(myNavigation.gpsPos); ch.setType(CacheType.CW_TYPE_STAGE); // see CacheType.GC_AW_STAGE_OF_MULTI // TODO unfertig mainT.newWaypoint(ch); } // change destination waypoint if (ev.target == btnGoto) { if (Vm.isMobile()) { InputScreen InScr = new InputScreen(CoordsScreen.getLocalSystem(currFormatSel)); if (myNavigation.destination.isValid()) InScr.setCoords(myNavigation.destination); else InScr.setCoords(new CWPoint(0, 0)); if (InScr.execute(null, CellConstants.TOP) == FormBase.IDOK) setDestination(InScr.getCoords()); } else { CoordsScreen cs = new CoordsScreen(); if (myNavigation.destination.isValid()) cs.setFields(myNavigation.destination, CoordsScreen.getLocalSystem(currFormatSel)); else cs.setFields(new CWPoint(0, 0), CoordsScreen.getLocalSystem(currFormatSel)); if (cs.execute(null, CellConstants.TOP) == FormBase.IDOK) setDestination(cs.getCoords()); } } } super.onEvent(ev); }
public void gpsStarted() { btnGPS.setText(MyLocale.getMsg(1505, "Stop")); }
public void gpsStoped() { btnGPS.setText(MyLocale.getMsg(1504, "Start")); gpsStatus = this.backGround; this.repaintNow(); // without this the change in the background color will not be displayed }
public void destChanged(CWPoint d) { // called from myNavigate btnGoto.setText(getGotoBtnText()); updateDistance(); }