Example #1
0
 public void plus_font_size(Manager parent) {
   if (parent == null) {
     return;
   }
   for (int index = 0; index < parent.getFieldCount(); index++) {
     parent.getField(index);
     if (parent.getField(index) instanceof TextField) {
       TextField tf = (TextField) parent.getField(index);
       int ts = tf.getFont().getHeight();
       int ns = ts;
       if (ts <= 14) {
         ns = 16;
       }
       if (ts <= 16 && ts > 14) {
         ns = 18;
       }
       if (ts <= 18 && ts > 16) {
         ns = 20;
       }
       if (ts <= 20 && ts > 18) {
         ns = 22;
       }
       if (ts <= 22 && ts > 20) {
         ns = 14;
       }
       tf.setFont(tf.getFont().derive(tf.getFont().getStyle(), ns));
     }
   }
 }
  private void createProgressMsg() {

    progressMsg = new LabelField();
    progressMsgFieldmanager = new HorizontalFieldManager(FIELD_HCENTER);
    progressMsgFieldmanager.setPadding(PADDING);
    progressMsg.setPadding(PADDING);
    progressMsgFieldmanager.add(progressMsg);
  }
Example #3
0
 public BitmapField WriteSimpleImage(
     Manager parent, String resource, long style, int size, String listener) {
   EncodedImage ei = EncodedImage.getEncodedImageResource(resource);
   EncodedImage ei2 = getScaledImage(ei, size);
   BitmapField fImg = new BitmapField(ei2.getBitmap(), style);
   parent.add(fImg);
   return fImg;
 }
Example #4
0
  protected void paint(Graphics g) {
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, userField.getWidth() + 8, userImage.getHeight());

    g.setColor(Color.GRAY);
    g.drawRect(0, 0, userField.getWidth() + 8, userImage.getHeight());

    super.paint(g);
  }
  private void addButtons() {
    loginButton = new Button("Login");
    loginButton.setChangeListener(this);

    cancelButton = new Button("Cancel");
    cancelButton.setChangeListener(this);
    buttonManager = new HorizontalFieldManager(FIELD_HCENTER);
    buttonManager.setPadding(PADDING);
    add(buttonManager);
  }
Example #6
0
  public ProfileScreen(ProfileInfoScreenManager _profileInfo) {
    super(Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR);
    profileInfo = _profileInfo;
    Manager mainManager = getMainManager();
    mainManager.setBackground(BackgroundFactory.createBitmapBackground(Images.screen_background));
    backButton = new TabbedButton("Back", 6, 100, 36);
    backButton.setRVAlue(10);
    backButton.setChangeListener(AirCrewApp.backButtonListener);
    homeButton = new TabbedButton("Home", 6, 100, 36);
    homeButton.setRVAlue(10);

    setTitle(new ScreenBannar("My Profile", 40, backButton, homeButton));

    mvrm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    nameField = new CompositeTextBox("Username", "", true);
    emailIdField = new CompositeTextBox("email", "", true);
    passwordField = new CompositePasswordBox("Password", "", true);
    confirmPasswordField = new CompositePasswordBox("Confirm Password", "", true);
    airlineField = new CompositeObjectChoiceField("Airlines", airlines, 0);
    designationField = new CompositeTextBox("Designation", "", true);
    genderField = new CompositeObjectChoiceField("Gender", gender, 0);
    locationField = new CompositeTextBox("Location", "", true);

    CompositeFieldManager manager =
        new CompositeFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);

    manager.add(nameField);
    manager.add(emailIdField);
    manager.add(passwordField);
    manager.add(confirmPasswordField);
    manager.add(airlineField);
    manager.add(designationField);
    manager.add(genderField);
    manager.add(locationField);

    mvrm.add(manager);
    saveButton = new TabbedButton("Save", 7, 470, 40);
    saveButton.setRVAlue(12);
    mvrm.add(saveButton);
    mvrm.add(new SpaceField(10));
    add(mvrm);
  }
Example #7
0
 public TextField WriteParragraph(
     Manager parent, String text, net.rim.device.api.ui.Font font, long style) {
   String alignedtxt = text;
   TextField tf = new TextField(style);
   tf.setEditable(false);
   tf.setFont(font);
   alignedtxt = alignedtxt.trim();
   tf.setText(alignedtxt);
   tf.setMargin(10, 5, 5, 5);
   parent.add(tf);
   return tf;
 }
  /**
   * Applies a visual style to a Manager to make it appear like a distinct group.
   *
   * @param manager The Manager to transform.
   * @param title The title of the group. If null or empty, no label will be added.
   * @return Reference to the same Manager object that was passed as the manager parameter.
   */
  public static Manager makeGroup(Manager manager, String title) {
    if ((title != null) && (title != "")) {
      manager.add(createGroupLabel(title));
    }

    manager.setMargin(new XYEdges(3, 3, 0, 3));
    manager.setPadding(new XYEdges(5, 5, 5, 5));
    manager.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    manager.setBorder(
        BorderFactory.createBevelBorder(
            new XYEdges(2, 2, 2, 2),
            new XYEdges(
                COLOR_GROUP_BEZEL_OUTER,
                COLOR_GROUP_BEZEL_OUTER,
                COLOR_GROUP_BEZEL_OUTER,
                COLOR_GROUP_BEZEL_OUTER),
            new XYEdges(
                COLOR_GROUP_BEZEL_INNER,
                COLOR_GROUP_BEZEL_INNER,
                COLOR_GROUP_BEZEL_INNER,
                COLOR_GROUP_BEZEL_INNER)));

    return manager;
  }
Example #9
0
  public LabelField FocusableFormatLabel(
      Manager parent, net.rim.device.api.ui.Font font, final int color, String content) {
    content = content.trim();

    LabelField l_Label =
        new LabelField(content, Field.FOCUSABLE) {
          public void paint(Graphics g) {
            g.setColor(color);
            super.paint(g);
          }
        };
    l_Label.setMargin(1, 1, 1, 1);
    l_Label.setPadding(0, 0, 0, 0);
    l_Label.setFont(font);
    parent.add(l_Label);
    return l_Label;
  }
Example #10
0
 public static final XYRect getFieldExtent(Field fld) {
   int cy = fld.getContentTop();
   int cx = fld.getContentLeft();
   Manager m = fld.getManager();
   while (m != null) {
     cy += m.getContentTop() - m.getVerticalScroll();
     cx += m.getContentLeft() - m.getHorizontalScroll();
     if (m instanceof Screen) break;
     m = m.getManager();
   }
   return new XYRect(cx, cy, fld.getContentWidth(), fld.getContentHeight());
 }
Example #11
0
 public BitmapField WriteWebImage(final Manager parent, final String url, final int size) {
   final BitmapField fImg =
       new BitmapField(Bitmap.getBitmapResource("img/cargandosm.png"), BitmapField.FOCUSABLE) {
         protected void layout(int width, int height) {
           setExtent(getBitmapWidth() + 3, getBitmapHeight() + 3);
         }
       };
   parent.add(fImg);
   try {
     UiApplication.getUiApplication()
         .invokeLater(
             new Runnable() {
               public void run() {
                 new AsyncDownloadImage(url, fImg, size).run();
               }
             });
   } catch (Exception e) {
     e.printStackTrace();
   }
   return fImg;
 }
Example #12
0
  public Manager splashScreen(Manager parent) {
    VerticalFieldManager fm_MainHolder =
        new VerticalFieldManager(
            Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL) {
          public int getPreferredWidth() {
            return Display.getWidth();
          }

          public int getPreferredHeight() {
            return Display.getHeight();
          }

          protected void sublayout(int width, int height) {
            width = getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };
    Background back = bkg_splash;
    fm_MainHolder.setBackground(back);
    parent.add(fm_MainHolder);
    return fm_MainHolder;
  }
Example #13
0
  public Manager mainScreen(Manager parent) {
    CInterface ci = new CInterface();
    final int columnHeight0 = (int) ((Display.getHeight() / 2));
    final int columnHeight1 = (int) (Display.getHeight() / 2);
    final int btnw = (int) ((float) Display.getWidth() * .75);
    final EncodedImage buttonoff =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(button), btnw);
    final EncodedImage buttonon =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(button_on), btnw);
    final EncodedImage friendsoff =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(friends), btnw);
    final EncodedImage friendson =
        ci.getScaledImage(EncodedImage.getEncodedImageResource(friends_on), btnw);
    int imagew = (int) ((float) Display.getWidth() * .75);
    Bitmap blankbmp = Bitmap.getBitmapResource(blank);

    VerticalFieldManager fm_MainHolder =
        new VerticalFieldManager(
            Manager.USE_ALL_WIDTH
                | Manager.USE_ALL_HEIGHT
                | Manager.NO_HORIZONTAL_SCROLL
                | Manager.NO_VERTICAL_SCROLL) {
          public int getPreferredWidth() {
            return Display.getWidth();
          }

          public int getPreferredHeight() {
            return Display.getHeight();
          }

          protected void sublayout(int width, int height) {
            width = getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };
    Background back = bkg_main;
    fm_MainHolder.setBackground(back);

    // MAIN LOGO
    HorizontalFieldManager lgo =
        new HorizontalFieldManager(
            Manager.NO_VERTICAL_SCROLL
                | Manager.NO_HORIZONTAL_SCROLL
                | Manager.FIELD_HCENTER
                | Manager.FIELD_VCENTER
                | Manager.USE_ALL_WIDTH) {
          public int getPreferredHeight() {
            return columnHeight0;
          }

          protected void sublayout(int width, int height) {
            width = super.getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };
    BitmapField img =
        ci.WriteSimpleImage(
            lgo, logo, BitmapField.FIELD_VCENTER | BitmapField.FIELD_HCENTER, imagew, "");
    fm_MainHolder.add(lgo);

    // BUTTON HOLDER
    VerticalFieldManager vfmButton =
        new VerticalFieldManager(
            Manager.FIELD_HCENTER | Manager.FIELD_VCENTER | Manager.USE_ALL_WIDTH) {
          public int getPreferredHeight() {
            return columnHeight1;
          }

          public int getPreferredWidth() {
            return Display.getWidth();
          }

          protected void sublayout(int width, int height) {
            width = getPreferredWidth();
            height = getPreferredHeight();
            super.sublayout(width, height);
            super.setExtent(width, height);
          }
        };

    final BitmapField bmFieldSpan = new BitmapField(blankbmp, BitmapField.NON_FOCUSABLE);

    CustomButtonField cbfFriends =
        new CustomButtonField(
            btnw,
            strings.getString("invite_friends"),
            friendsoff.getBitmap(),
            friendson.getBitmap(),
            Field.FOCUSABLE | Field.FIELD_HCENTER | Field.FIELD_VCENTER) {
          protected boolean navigationClick(int status, int time) {
            c.action_callback("web_friends", "", "");
            return true;
          }
        };

    CustomButtonField cbfButton =
        new CustomButtonField(
            btnw,
            strings.getString("read_qr"),
            buttonoff.getBitmap(),
            buttonon.getBitmap(),
            Field.FOCUSABLE | Field.FIELD_HCENTER | Field.FIELD_VCENTER) {
          protected boolean navigationClick(int status, int time) {
            c.action_callback("qr_start", "", "");
            return true;
          }
        };

    vfmButton.add(cbfButton);
    vfmButton.add(bmFieldSpan);
    vfmButton.add(cbfFriends);
    fm_MainHolder.add(vfmButton);

    parent.add(fm_MainHolder);
    return fm_MainHolder;
  }
Example #14
0
 public void construct_makescrollable_attache(Manager parent) {
   parent.add(new NullField(NullField.FOCUSABLE));
 }
 private void setLoginButton() {
   buttonManager.deleteAll();
   buttonManager.add(loginButton);
 }
 private void setCacelButton() {
   buttonManager.deleteAll();
   buttonManager.add(cancelButton);
 }
Example #17
0
  public SearchView(HomeScreen homeScreen) {
    this.homeScreen = homeScreen;
    manager =
        new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL) {
          public boolean keyChar(char c, int status, int time) {
            if (!searchField.isFocus()) {
              String oldText = searchField.getText();
              searchField.setFocus();
              String newText = c == Keypad.KEY_DELETE ? oldText : oldText + c;
              searchField.setText(newText.trim());
              return true;
            } else if (c == Keypad.KEY_ESCAPE) {
              if (searchField.getText().length() > 0) {
                searchField.setText("");
                return true;
              }
            }
            return super.keyChar(c, status, time);
          }
        };
    searchField =
        new BasicEditField(Field.USE_ALL_WIDTH) {
          public boolean navigationClick(int status, int time) {
            if (getText().trim().length() > 0) {
              SearchView.this.homeScreen.fireActionSearch();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public boolean keyChar(char c, int status, int time) {
            if (c == Keypad.KEY_ENTER) {
              if (getText().trim().length() > 0) {
                SearchView.this.homeScreen.fireActionSearch();
                return true;
              }
            } else if (getText().length() == 0 && c == Keypad.KEY_SPACE) {
              return true;
            }
            return super.keyChar(c, status, time);
          }

          public void paint(Graphics g) {
            if (getText().length() == 0) {
              g.setColor(0xbbbbbb);
              g.drawText(" Search", 0, 0);
            } else {
              g.setColor(0);
              super.paint(g);
            }
          }
        };

    // int defaultFontHeight = Font.getDefault().getHeight();
    // searchField.setFont(Font.getDefault().derive(Font.PLAIN, defaultFontHeight+8));
    Border border = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4));
    searchField.setBorder(border);
    searchField.setBackground(BackgroundFactory.createSolidBackground(0xffffff));
    manager.add(searchField);
    manager.add(new SeparatorField());

    // manager.setBackground(HomeScreen.mainBackground);
    listField =
        new ListField(0, Manager.USE_ALL_HEIGHT) {
          public boolean navigationClick(int status, int time) {
            if (SearchView.this.listData.size() > 0) {
              int index = getSelectedIndex();
              if (isMoreButton(index)) {
                increaseListFieldSize();
                invalidate();
                return true;
              }
              ProgramData data = (ProgramData) SearchView.this.listData.elementAt(index);
              data.isFavorite = !data.isFavorite;
              if (data.isFavorite) {
                FavoritePersistent.addFavorite(data.id);
                PIMEvent.addEvent(data);
              } else {
                FavoritePersistent.removeFavorite(data.id);
                PIMEvent.removeEvent(data);
              }
              invalidate();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public void paint(Graphics g) {
            int ty = getContentTop() + getContentHeight() / 2 - g.getFont().getHeight() / 2;
            if (ThaiTVSchedule.isFetching()) {
              ThaiTVSchedule.paintFetching(g, ty);
            } else if (this.getSize() < 1) {
              g.setColor(0);
              int x = (getWidth() - g.getFont().getAdvance("No data")) / 2;
              g.drawText("No data", x, ty);
            } else {
              super.paint(g);
            }
          }

          public boolean isFocusable() {
            return !ThaiTVSchedule.isFetching();
          }
        };
    // listField.setBackground(HomeScreen.mainBackground);
    listField.setRowHeight(ScheduleScreen.LIST_HEIGHT);
    listField.setCallback(this);
    listData = new Vector();
    listField.setSize(0);
    listField.setFont(Font.getDefault().derive(Font.PLAIN, 20));
    VerticalFieldManager _vfm =
        new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    _vfm.add(listField);
    manager.add(_vfm);

    // autoFocus();
  }