/** 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();
 }
  /**
   * Create GotoPanel
   *
   * @param Preferences global preferences
   * @param MainTab reference to MainTable
   * @param DetailsPanel reference to DetailsPanel
   * @param Vector cacheDB
   */
  public GotoPanel(Navigate nav) {
    myNavigation = nav;
    pref = Global.getPref();
    profile = Global.getProfile();
    mainT = Global.mainTab;
    detP = mainT.detP;
    cacheDB = profile.cacheDB;

    // Button
    ButtonP.addNext(
        btnGPS = new mButton(MyLocale.getMsg(1504, "Start")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    ButtonP.addNext(
        btnCenter = new mButton(MyLocale.getMsg(309, "Centre")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    ButtonP.addLast(
        btnSave = new mButton(MyLocale.getMsg(311, "Create Waypoint")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // ButtonP.addLast(btnMap = new mButton(MyLocale.getMsg(1506,"Map")),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));

    // Format selection for coords
    // context menu
    mnuContextFormt = new Menu();
    currFormatSel = 1; // default to d° m.m
    mnuContextFormt.addItem(miCooformat[0] = new MenuItem("d.d°"));
    miCooformat[0].modifiers &= ~MenuItem.Checked;
    mnuContextFormt.addItem(miCooformat[1] = new MenuItem("d°m.m\'"));
    miCooformat[1].modifiers |= MenuItem.Checked; // default
    mnuContextFormt.addItem(miCooformat[2] = new MenuItem("d°m\'s\""));
    miCooformat[2].modifiers &= ~MenuItem.Checked;
    mnuContextFormt.addItems(TransformCoordinates.getProjectedSystemNames());

    // Create context menu for compass rose: select luminary for orientation
    mnuContextRose = new Menu();
    for (int i = 0; i < SkyOrientation.LUMINARY_NAMES.length; i++) {
      mnuContextRose.addItem(miLuminary[i] = new MenuItem(SkyOrientation.getLuminaryName(i)));
      if (i == myNavigation.luminary) miLuminary[i].modifiers |= MenuItem.Checked;
      else miLuminary[i].modifiers &= MenuItem.Checked;
    }

    // Coords
    CoordsP.addNext(
        lblGPS = new mLabel("GPS: "),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    lblGPS.backGround = RED;
    lblGPS.setMenu(mnuContextFormt);
    lblGPS.modifyAll(ControlConstants.WantHoldDown, 0);

    lblPosition =
        new mLabel(myNavigation.gpsPos.toString(CoordsScreen.getLocalSystem(currFormatSel)));
    lblPosition.anchor = CellConstants.CENTER;
    lblPosition.setMenu(mnuContextFormt);
    lblPosition.modifyAll(ControlConstants.WantHoldDown, 0);
    CoordsP.addLast(
        lblPosition, CellConstants.HSTRETCH, (CellConstants.HFILL | CellConstants.WEST));

    CoordsP.addNext(
        lblDST = new mLabel(MyLocale.getMsg(1500, "DST:")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    lblDST.backGround = new Color(0, 0, 255);
    lblDST.setMenu(mnuContextFormt);
    lblDST.modifyAll(ControlConstants.WantHoldDown, 0);

    CoordsP.addLast(
        btnGoto = new mButton(getGotoBtnText()),
        CellConstants.HSTRETCH,
        (CellConstants.HFILL | CellConstants.WEST));

    // Rose for bearing
    // compassRose = new GotoRose("rose.png");
    compassRose = new GotoRose();
    icRose = new ImageControl(compassRose);
    icRose.setMenu(mnuContextRose);
    icRose.modifyAll(
        ControlConstants.WantHoldDown,
        0); // this is necessary in order to make PenHold on a PDA work as right click
    roseP.addLast(
        icRose, CellConstants.DONTSTRETCH, (CellConstants.DONTFILL | CellConstants.NORTH));

    mnuContextRose.addItem(new MenuItem("", MenuItem.Separator, null));
    mnuContextRose.addItem(miNorthCentered = new MenuItem(MyLocale.getMsg(1503, "North Centered")));
    if (compassRose.isNorthCentered()) miNorthCentered.modifiers |= MenuItem.Checked;
    else miNorthCentered.modifiers &= MenuItem.Checked;

    // add Panels
    HeadP.addLast(ButtonP, CellConstants.HSTRETCH, CellConstants.DONTFILL | CellConstants.WEST)
        .setTag(SPAN, new Dimension(2, 1));
    HeadP.addLast(CoordsP, CellConstants.HSTRETCH, CellConstants.HFILL | CellConstants.NORTH)
        .setTag(SPAN, new Dimension(2, 1));
    this.addNext(HeadP, CellConstants.HSTRETCH, CellConstants.WEST)
        .setTag(SPAN, new Dimension(2, 1));
    this.addLast(
            btnMap = new mButton(MyLocale.getMsg(1506, "Map") + " "),
            CellConstants.HSTRETCH,
            CellConstants.VFILL | CellConstants.RIGHT)
        .setTag(SPAN, new Dimension(2, 1));
    this.addLast(roseP, CellConstants.DONTSTRETCH, CellConstants.DONTFILL | CellConstants.WEST)
        .setTag(SPAN, new Dimension(2, 1));
    btnMap.backGround = GREEN;
  }
  // Set the colors of the filter buttons according to which filters are active
  private void setColors() {
    // Panel 1 - Bearing & Distance
    if (inpDist.getText().length() > 0
        || !(chkNW.state
            && chkNNW.state
            && chkN.state
            && chkNNE.state
            && chkNE.state
            && chkENE.state
            && chkE.state
            && chkESE.state
            && chkSE.state
            && chkSSE.state
            && chkS.state
            && chkSSW.state
            && chkSW.state
            && chkWSW.state
            && chkW.state
            && chkWNW.state)) btnBearing.backGround = COLOR_FILTERACTIVE;
    else btnBearing.backGround = COLOR_FILTERINACTIVE;
    if (!(chkNW.state
        || chkNNW.state
        || chkN.state
        || chkNNE.state
        || chkNE.state
        || chkENE.state
        || chkE.state
        || chkESE.state
        || chkSE.state
        || chkSSE.state
        || chkS.state
        || chkSSW.state
        || chkSW.state
        || chkWSW.state
        || chkW.state
        || chkWNW.state)) btnBearing.backGround = COLOR_FILTERALL;
    btnBearing.repaint();

    // Panel 2 - Cache attributes
    if (!(chkArchived.state
        && chkAvailable.state
        && chkFound.state
        && chkOwned.state
        && chkNotArchived.state
        && chkNotAvailable.state
        && chkNotFound.state
        && chkNotOwned.state
        && chcStatus.getText().equals(""))) btnAttributes.backGround = COLOR_FILTERACTIVE;
    else btnAttributes.backGround = COLOR_FILTERINACTIVE;
    if ((chkArchived.state == false && chkNotArchived.state == false)
        || (chkAvailable.state == false && chkNotAvailable.state == false)
        || (chkFound.state == false && chkNotFound.state == false)
        || (chkOwned.state == false && chkNotOwned.state == false))
      btnAttributes.backGround = COLOR_FILTERALL;
    btnAttributes.repaint();

    // Panel 3 - Cache ratings
    if (inpDiff.getText().length() > 0 || inpTerr.getText().length() > 0)
      btnRatings.backGround = COLOR_FILTERACTIVE;
    else btnRatings.backGround = COLOR_FILTERINACTIVE;
    btnRatings.repaint();

    // Panel 5 - Addi Waypoints
    if (chkParking.state
        || chkStage.state
        || chkQuestion.state
        || chkFinal.state
        || chkTrailhead.state
        || chkReference.state) { // At least one tick
      btnAddi.backGround = COLOR_FILTERACTIVE;
      addiWptChk.state = true;
      if (chkParking.state
          && chkStage.state
          && chkQuestion.state
          && chkFinal.state
          && chkTrailhead.state
          && chkReference.state) { // All ticked?
        addiWptChk.bgColor = Color.White;
        btnAddi.backGround = COLOR_FILTERINACTIVE;
      } else {
        addiWptChk.bgColor = Color.LightGray;
      }
    } else { // All not ticked
      btnAddi.backGround = COLOR_FILTERACTIVE;
      addiWptChk.bgColor = Color.White;
      addiWptChk.state = false;
    }
    btnAddi.repaint();

    // Panel 4 - Cache types
    boolean allAddis =
        (chkParking.state
            && chkStage.state
            && chkQuestion.state
            && chkFinal.state
            && chkTrailhead.state
            && chkReference.state);
    if (!(chkTrad.state
        && chkMulti.state
        && chkVirtual.state
        && chkLetter.state
        && chkEvent.state
        && chkWebcam.state
        && chkMystery.state
        && chkEarth.state
        && chkLocless.state
        && chkMega.state
        && chkCito.state
        && chkWherigo.state
        && chkCustom.state
        && allAddis)) btnTypes.backGround = COLOR_FILTERACTIVE;
    else btnTypes.backGround = COLOR_FILTERINACTIVE;
    if (!(chkTrad.state
        || chkMulti.state
        || chkVirtual.state
        || chkLetter.state
        || chkEvent.state
        || chkWebcam.state
        || chkMystery.state
        || chkEarth.state
        || chkLocless.state
        || chkMega.state
        || chkCustom.state
        || chkParking.state
        || chkStage.state
        || chkQuestion.state
        || chkFinal.state
        || chkTrailhead.state
        || chkCito.state
        || chkWherigo.state
        || chkReference.state)) btnTypes.backGround = COLOR_FILTERALL;
    btnTypes.repaint();

    // Panel 6 - Cache container
    if (!(chkMicro.state
        && chkSmall.state
        && chkRegular.state
        && chkLarge.state
        && chkVeryLarge.state
        && chkOther.state)) btnContainer.backGround = COLOR_FILTERACTIVE;
    else btnContainer.backGround = COLOR_FILTERINACTIVE;
    if (!(chkMicro.state
        || chkSmall.state
        || chkRegular.state
        || chkLarge.state
        || chkVeryLarge.state
        || chkOther.state)) btnContainer.backGround = COLOR_FILTERALL;
    btnContainer.repaint();

    // Panel 7 - Search

    // Panel 8 - Cache attributes
    if (attV.selectionMaskYes == 0l && attV.selectionMaskNo == 0l)
      btnCacheAttributes.backGround = COLOR_FILTERINACTIVE;
    else btnCacheAttributes.backGround = COLOR_FILTERACTIVE;
    btnCacheAttributes.repaint();
  }
  public FilterScreen() {
    this.title = MyLocale.getMsg(700, "Set Filter");

    //////////////////////////
    // Panel 1 - Bearing & Distance
    //////////////////////////
    addTitle(pnlBearDist, MyLocale.getMsg(714, "Bearings & Distance"));
    pnlBearDist.addNext(
        new mLabel(MyLocale.getMsg(701, "Distance: ")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlBearDist.addNext(
        chcDist = new mChoice(new String[] {"<=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    pnlBearDist.addLast(inpDist = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlBearDist.addLast(new mLabel(""));
    pnlRose.addNext(chkNW = new mCheckBox("NW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkNNW = new mCheckBox("NNW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkN = new mCheckBox("N"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkNNE = new mCheckBox("NNE"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkNE = new mCheckBox("NE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkENE = new mCheckBox("ENE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkE = new mCheckBox("E "), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkESE = new mCheckBox("ESE"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkSE = new mCheckBox("SE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkSSE = new mCheckBox("SSE"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkS = new mCheckBox("S"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkSSW = new mCheckBox("SSW"), CellConstants.HSTRETCH, CellConstants.FILL);

    pnlRose.addNext(chkSW = new mCheckBox("SW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkWSW = new mCheckBox("WSW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(chkW = new mCheckBox("W "), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addLast(chkWNW = new mCheckBox("WNW"), CellConstants.HSTRETCH, CellConstants.FILL);
    pnlRose.addNext(
        btnDeselect = new mButton(MyLocale.getMsg(716, "Deselect all")),
        CellConstants.HSTRETCH,
        CellConstants.FILL);
    btnDeselect.setTag(SPAN, new Dimension(2, 1));
    pnlRose.addLast(
        btnSelect = new mButton(MyLocale.getMsg(717, "Select all")),
        CellConstants.HSTRETCH,
        CellConstants.FILL);
    pnlBearDist.addLast(pnlRose, CellConstants.STRETCH, CellConstants.FILL);

    //////////////////////////
    // Panel 2 - Cache attributes
    //////////////////////////
    addTitle(pnlAttributes, MyLocale.getMsg(720, "Status"));
    mLabel lblTitleAtt;
    pnlAttributes.addLast(
        lblTitleAtt = new mLabel(MyLocale.getMsg(715, "Show all caches with status:")),
        HSTRETCH,
        FILL);
    lblTitleAtt.setTag(SPAN, new Dimension(2, 1));
    pnlAttributes.addNext(
        chkArchived = new mCheckBox(MyLocale.getMsg(710, "Archived")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotArchived = new mCheckBox(MyLocale.getMsg(729, "Nicht archiviert")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkAvailable = new mCheckBox(MyLocale.getMsg(730, "Suchbar")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotAvailable = new mCheckBox(MyLocale.getMsg(711, "Not available")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkFound = new mCheckBox(MyLocale.getMsg(703, "Found")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotFound = new mCheckBox(MyLocale.getMsg(731, "Noch nicht gefunden")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        chkOwned = new mCheckBox(MyLocale.getMsg(707, "Owned")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlAttributes.addLast(
        chkNotOwned = new mCheckBox(MyLocale.getMsg(732, "Anderer Besitzer")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);

    pnlAttributes.addNext(
        new mLabel(MyLocale.getMsg(307, "Status:")),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    pnlAttributes.addLast(
        chcStatus =
            new mComboBox(
                new String[] {
                  "",
                  MyLocale.getMsg(313, "Flag 1"),
                  MyLocale.getMsg(314, "Flag 2"),
                  MyLocale.getMsg(315, "Flag 3"),
                  MyLocale.getMsg(316, "Flag 4"),
                  MyLocale.getMsg(317, "Search"),
                  MyLocale.getMsg(318, "Found"),
                  MyLocale.getMsg(319, "Not Found"),
                  MyLocale.getMsg(320, "Owner")
                },
                0),
        CellConstants.HSTRETCH,
        (CellConstants.HFILL | CellConstants.WEST));
    pnlAttributes.addLast(chkUseRegexp = new mCheckBox(MyLocale.getMsg(299, "Regular expression")));

    //////////////////////////
    // Panel 3 - Cache ratings
    //////////////////////////
    addTitle(pnlRatings, MyLocale.getMsg(718, "Cache ratings"));
    pnlRatings.addNext(
        new mLabel(MyLocale.getMsg(702, "Difficulty: ")),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlRatings.addNext(
        chcDiff = new mChoice(new String[] {"<=", "=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // pnlRatings.addLast(difIn = new mChoice(new String[]{"1.0", "1.5", "2.0", "2.5", "3.0", "3.5",
    // "4.0", "4.5", "5.0"},0),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));
    pnlRatings.addLast(inpDiff = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlRatings.addNext(new mLabel("Terrain: "), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlRatings.addNext(
        chcTerr = new mChoice(new String[] {"<=", "=", ">="}, 0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));
    // pnlRatings.addLast(terrIn = new mChoice(new String[]{"1.0", "1.5", "2.0", "2.5", "3.0",
    // "3.5", "4.0", "4.5", "5.0"},0),CellConstants.DONTSTRETCH,
    // (CellConstants.DONTFILL|CellConstants.WEST));
    pnlRatings.addLast(inpTerr = new mInput(), CellConstants.DONTSTRETCH, CellConstants.FILL);

    //////////////////////////
    // Panel 4 - Cache types
    //////////////////////////

    addTitle(pnlCacheTypes, MyLocale.getMsg(719, "Cache types"));
    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_TRADITIONAL)));
    pnlCacheTypes.addNext(
        chkTrad = new mCheckBox("Traditonal"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_MULTI)));
    pnlCacheTypes.addLast(
        chkMulti = new mCheckBox("Multi"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_VIRTUAL)));
    pnlCacheTypes.addNext(
        chkVirtual = new mCheckBox("Virtual"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_LETTERBOX)));
    pnlCacheTypes.addLast(
        chkLetter = new mCheckBox("Letterbox"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_EVENT)));
    pnlCacheTypes.addNext(
        chkEvent = new mCheckBox("Event"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_WEBCAM)));
    pnlCacheTypes.addLast(
        chkWebcam = new mCheckBox("Webcam"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_UNKNOWN)));
    pnlCacheTypes.addNext(
        chkMystery = new mCheckBox("Mystery"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_EARTH)));
    pnlCacheTypes.addLast(
        chkEarth = new mCheckBox("Earth"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_LOCATIONLESS)));
    pnlCacheTypes.addNext(
        chkLocless = new mCheckBox("Locationless"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_MEGA_EVENT)));
    pnlCacheTypes.addLast(
        chkMega = new mCheckBox("Mega-Ev."), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_CITO)));
    pnlCacheTypes.addNext(
        chkCito = new mCheckBox("Cito-Ev."), CellConstants.DONTSTRETCH, CellConstants.FILL);

    // pnlCacheTypes.addLast(addiWptChk = new mCheckBox("Add. Wpt"), CellConstants.DONTSTRETCH,
    // CellConstants.FILL);
    // pnlCacheTypes.addLast(new mLabel(""));
    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_CUSTOM)));
    pnlCacheTypes.addLast(
        chkCustom = new mCheckBox("Custom"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_WHEREIGO)));
    pnlCacheTypes.addNext(
        chkWherigo = new myChkBox("WherIGo"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    pnlCacheTypes.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_DRIVE_IN)));
    pnlCacheTypes.addNext(
        addiWptChk = new myChkBox("Add. Wpt"), CellConstants.DONTSTRETCH, CellConstants.FILL);

    // addiWptChk.modify(0,NotAnEditor);
    //////////////////////////
    // Panel 5 - Addi waypoints
    //////////////////////////
    addTitle(pnlAddi, MyLocale.getMsg(726, "Additional waypoints"));
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_PARKING)));
    pnlAddi.addNext(
        chkParking = new mCheckBox("Parking"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_STAGE)));
    pnlAddi.addLast(
        chkStage = new mCheckBox("Stage"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_QUESTION)));
    pnlAddi.addNext(
        chkQuestion = new mCheckBox("Question"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_FINAL)));
    pnlAddi.addLast(
        chkFinal = new mCheckBox("Final"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_TRAILHEAD)));
    pnlAddi.addNext(
        chkTrailhead = new mCheckBox("Trailhead"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addNext(addImg(GuiImageBroker.getTypeImage(CacheType.CW_TYPE_REFERENCE)));
    pnlAddi.addLast(
        chkReference = new mCheckBox("Reference"), CellConstants.DONTSTRETCH, CellConstants.FILL);
    pnlAddi.addLast(new mLabel(""), VSTRETCH, FILL);

    //////////////////////////
    // Panel 6 - Cache container
    //////////////////////////
    addTitle(pnlContainer, MyLocale.getMsg(727, "Cache container"));
    pnlContainer.addLast(chkMicro = new mCheckBox("Micro"));
    pnlContainer.addLast(chkSmall = new mCheckBox("Small"));
    pnlContainer.addLast(chkRegular = new mCheckBox("Regular"));
    pnlContainer.addLast(chkLarge = new mCheckBox("Large"));
    pnlContainer.addLast(chkVeryLarge = new mCheckBox("Very Large"));
    pnlContainer.addLast(chkOther = new mCheckBox("Other"));

    //////////////////////////
    // Panel 7 - Search
    //////////////////////////
    addTitle(pnlSearch, "Search");
    pnlSearch.addLast(new mLabel("To be implemented"));

    //////////////////////////
    // Panel 8 - Cache attributes
    //////////////////////////

    if (MyLocale.getScreenHeight() > 240)
      addTitle(pnlCacheAttributes, MyLocale.getMsg(737, "Attributes"));
    pnlCacheAttributes.addNext(
        new mLabel(MyLocale.getMsg(739, "Filter on") + ":"),
        CellConstants.DONTSTRETCH,
        CellConstants.FILL);
    pnlCacheAttributes.addLast(
        chcAttrib =
            new mChoice(
                new String[] {
                  MyLocale.getMsg(740, "all"),
                  MyLocale.getMsg(741, "one"),
                  MyLocale.getMsg(742, "none")
                },
                0),
        CellConstants.DONTSTRETCH,
        (CellConstants.DONTFILL | CellConstants.WEST));

    attV = new AttributesSelector();
    pnlCacheAttributes.addLast(
        attV,
        CellConstants.STRETCH | CellConstants.LEFT /*|CellConstants.BORDER*/,
        CellConstants.STRETCH);
    attV.setSelectionMasks(0l, 0l);

    Frame frmScreen = new Frame();
    mLabel lblInfo;
    frmScreen
        .addLast(
            lblInfo =
                new mLabel(MyLocale.getMsg(725, "Note: Filters are additive, active filter=green")))
        .setTag(SPAN, new Dimension(2, 1));
    lblInfo.setTag(INSETS, new Insets(0, 0, 2, 0));
    frmScreen.borderStyle =
        UIConstants.BDR_RAISEDOUTER | UIConstants.BDR_SUNKENINNER | UIConstants.BF_BOTTOM;
    this.addLast(frmScreen, HSTRETCH, HFILL);

    CellPanel pnlButtons = new CellPanel();
    pnlButtons.addLast(new mLabel("Filter"));
    pnlButtons.addLast(btnBearing = new mButton(MyLocale.getMsg(721, "Bearing")));
    pnlButtons.addLast(btnAttributes = new mButton(MyLocale.getMsg(720, "Attributes")));
    pnlButtons.addLast(btnRatings = new mButton(MyLocale.getMsg(722, "Ratings")));
    pnlButtons.addLast(btnTypes = new mButton(MyLocale.getMsg(723, "Types")));
    pnlButtons.addLast(btnAddi = new mButton(MyLocale.getMsg(733, "Add. Wpt")));
    pnlButtons.addLast(btnContainer = new mButton(MyLocale.getMsg(724, "Container")));
    pnlButtons.addLast(btnCacheAttributes = new mButton(MyLocale.getMsg(738, "Attributes")));
    // Search ist für 0.9n noch deaktiviert
    // pnlButtons.addLast(btnSearch=new mButton("Search")); btnSearch.modify(Disabled,0);
    addNext(pnlButtons, HSTRETCH, FILL);

    cp.addItem(pnlBearDist, "Bear", null);
    cp.addItem(pnlAttributes, "Att", null);
    cp.addItem(pnlRatings, "DT", null);
    cp.addItem(pnlCacheTypes, "Type", null);
    cp.addItem(pnlAddi, "Addi", null);
    cp.addItem(pnlContainer, "Size", null);
    cp.addItem(pnlSearch, "Search", null);
    cp.addItem(pnlCacheAttributes, "Attr", null);
    addLast(cp, VSTRETCH, FILL);

    CellPanel savDelPanel = new CellPanel(); // Panel for "save" and "delete" button
    savDelPanel.equalWidths = true;
    mImage savImg = new mImage("clsave.png");
    savImg.transparentColor = new Color(255, 0, 0);
    savDelPanel.addNext(btnSaveFlt = new mButton(savImg), STRETCH, FILL);
    savDelPanel.addLast(btnDelFlt = new mButton(new mImage("trash.png")), STRETCH, FILL);
    Panel fltListPanel = new Panel();
    fltListPanel.addLast(fltList = new mChoice());
    fltListPanel.addLast(savDelPanel);
    CellPanel btPanel = new CellPanel();
    btPanel.equalWidths = true;
    btPanel.addNext(fltListPanel, CellConstants.STRETCH, CellConstants.FILL);
    btPanel.addNext(
        btnCancel = new mButton(MyLocale.getMsg(708, "Cancel")),
        CellConstants.STRETCH,
        CellConstants.FILL);
    btPanel.addLast(
        btnApply = new mButton(MyLocale.getMsg(709, "Apply")),
        CellConstants.STRETCH,
        CellConstants.FILL);
    //		btPanel.addLast(btnRoute = new mButton("Route"),CellConstants.STRETCH, CellConstants.FILL);
    addLast(
        btPanel.setTag(CellConstants.SPAN, new Dimension(3, 1)),
        CellConstants.STRETCH,
        CellConstants.FILL);

    int sw = MyLocale.getScreenWidth();
    int sh = MyLocale.getScreenHeight();
    Preferences pref = Global.getPref();
    int fs = pref.fontSize;
    int psx;
    int psy;
    if ((sw > 300) && (sh > 300)) {
      // larger screens: size according to fontsize
      psx = 240;
      psy = 260;
      if (fs > 12) {
        psx = 300;
        psy = 330;
      }
      if (fs > 17) {
        psx = 400;
        psy = 340;
      }
      if (fs > 23) {
        psx = 500;
        psy = 350;
      }
      setPreferredSize(psx, psy);
    } else {
      // small screens: fixed size
      if (sh > 240) setPreferredSize(240, 260);
      else setPreferredSize(240, 240);
    }
    cp.select(3);

    // Populating the comboBox of saved filters
    buildFilterList();
  }
 private mButton addImg(Image pImage) {
   mButton mb = new mButton(pImage);
   mb.borderWidth = 0;
   mb.modify(NotEditable | PreferredSizeOnly, 0);
   return mb;
 }