MOMUiFactory.java
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:4k
源码类别:

J2ME

开发平台:

Java

  1. /*
  2.  * MOMUiFactory.java
  3.  *
  4.  * Created on April 21, 2010, 1:32 PM
  5.  *
  6.  * To change this template, choose Tools | Template Manager
  7.  * and open the template in the editor.
  8.  */
  9. package com.MOM.ui;
  10. import com.MOM.Constants;
  11. import com.MOM.controller.Controller;
  12. import com.MOM.resources.Resources;
  13. import com.MOM.ui.control.MOMTitleBar;
  14. import com.framework.DisplayManager;
  15. import com.framework.EditControl;
  16. import com.framework.GTantra;
  17. import com.framework.ImageControl;
  18. import com.framework.RadioControl;
  19. import com.framework.TextControl;
  20. import com.framework.TickerTextControl;
  21. import com.framework.TitleBar;
  22. import com.framework.UiScreen;
  23. import javax.microedition.lcdui.Graphics;
  24. import javax.microedition.lcdui.Image;
  25. /**
  26.  *
  27.  * @author Tejaswi
  28.  */
  29. public class MOMUiFactory {
  30.     
  31.     public static UiScreen getMOMScreen(String leftSoftKey,String rightsoftKey)
  32.     {
  33.         UiScreen screen = new UiScreen(){
  34.             public TitleBar getTitleBar() {
  35.                 if(titleBar == null)
  36.                     titleBar =  new MOMTitleBar(this);
  37.                 return titleBar;
  38.             }
  39.         };
  40.         screen.getSoftkeybar().setFont(Resources.getInstance().getSoftKeyFont());
  41.         screen.getSoftkeybar().setSetSoftkey(Graphics.LEFT, leftSoftKey);
  42.         screen.getSoftkeybar().setSetSoftkey(Graphics.RIGHT, rightsoftKey);
  43.         screen.getSoftkeybar().setBgColor(0xFFFFFF);
  44.         screen.invalidate();
  45.         screen.setEventManager(Controller.getInstance());
  46.         return screen;
  47.     }  
  48.     public static TextControl getCommanTabButton(String text)
  49.     {
  50.         Image bgImage = Resources.getInstance().getImage(Resources.TAB_BUTTON_OFF_IMAGE);
  51.         TextControl textControl = new TextControl(text, bgImage.getWidth(),Resources.getInstance().getTabButtonTitleFont(), GTantra.TEXT_VCENTER_HCENTER , false);
  52.         textControl.setBgImage(bgImage);
  53.         textControl.setHeight(bgImage.getHeight());
  54.         textControl.setSelectionBgImage(Resources.getInstance().getImage(Resources.TAB_BUTTON_ON_IMAGE));
  55.         textControl.setVerticalPadding(0);
  56.         return textControl;
  57.     }
  58.     public static TickerTextControl getDarckLabel(String text)
  59.     {
  60.         TickerTextControl control = new TickerTextControl(text,Resources.getInstance().getLableTitleFont());
  61.         control.setSelectable(false);
  62.         control.setBgColor(0x94a5b5);
  63.         control.setWidth(DisplayManager.getInst().getWidth());
  64.         return control;
  65.     }
  66.     public static TickerTextControl getSearchButton(String text)
  67.     {
  68.         TickerTextControl control = new TickerTextControl(text,Resources.getInstance().getButtonTextFont());
  69.         control.setBgImage(Resources.getInstance().getImage(Resources.SEARCH_BUTTON_IMAGE));
  70.         control.setAllignment(Graphics.HCENTER);
  71.         control.setSelectionBorderColor(Constants.CONTROLS_SELECTION_BORDER_COLOR);
  72.         return control;
  73.     }
  74.     public static EditControl getEditControl(int width,int height)
  75.     {
  76.         EditControl control = new EditControl(Resources.getInstance().getEditControlFont() , width, height , 1024 , false);
  77.         control.setSelectionBorderColor(Constants.CONTROLS_SELECTION_BORDER_COLOR);
  78.         control.setBorderColor(0);
  79.         control.setCursorColor(0);
  80.         return control;
  81.     }
  82.     public static ImageControl getUnselectbleImageControl(Image image)
  83.     {
  84.         ImageControl control = new ImageControl(image);
  85.         control.setSelectable(false);
  86.         return control;
  87.     }
  88.     public static RadioControl getRadioControl(String text)
  89.     {
  90.         RadioControl radioControl = new RadioControl(text,Resources.getInstance().getFontBlackMediumBold(),Resources.getInstance().getImage(Resources.RADIO_BUTTON_IMAGE),Resources.getInstance().getImage(Resources.RADIO_BUTTON_ON_IMAGE));
  91.         radioControl.setRadioCircleBorderColor(Constants.RADIO_CONTROL_CIRCLE_BORDER_COLOR);
  92.         radioControl.setSelectionBorderColor(Constants.CONTROLS_SELECTION_BORDER_COLOR);
  93.         return radioControl;
  94.     }
  95.     public static TickerTextControl getBlueLabel(String text)
  96.     {
  97.         TickerTextControl label = new TickerTextControl(text, Resources.getInstance().getFontWhiteMediumBold());
  98.         label.setBgColor(Constants.BLUE_LABLE_BG_COLOR);
  99.         label.setBorderColor(Constants.BLUE_LABLE_BORDER_COLOR);
  100.         label.setSelectable(false);
  101.         label.setWidth(DisplayManager.getInst().getWidth());
  102.         
  103.         return label;
  104.     }
  105. }