UiDisplayble.java
资源名称:src.zip [点击查看]
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:3k
源码类别:
J2ME
开发平台:
Java
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.framework;
- import javax.microedition.lcdui.Graphics;
- /**
- *
- * @author Swaroop Kumar
- */
- public abstract class UiDisplayble {
- private EventManager eventManager;
- private int transitionEffect = TransitionEffect.TRANSITION_NO_EFFECT;
- public abstract void invalidate();
- public abstract ScrollableContainer getBody();
- public abstract SoftkeyBar getSoftkeybar();
- public abstract TitleBar getTitleBar();
- public EventManager getEventListener(){
- return eventManager;
- }
- protected void pointerDragged(int x, int y) {
- int titleHeight = 0;
- if(getBody() != null)
- getBody().pointerDragged(x, y);
- }
- protected void pointerReleased(int x, int y) {
- if(getSoftkeybar() == null || !getSoftkeybar().pointerReleased(x, y))
- {
- if(getBody() != null)
- getBody().pointerReleased(x, y );
- }
- }
- public void paintUI(Graphics g)
- {
- if(getBody() != null)
- getBody().paintUI(g);
- if(getTitleBar() != null)
- {
- getTitleBar().paintUi(g);
- }
- if(getSoftkeybar() != null)
- {
- getSoftkeybar().paintUi(g);
- }
- }
- public int getHeight()
- {
- int val = 0;
- if(getBody() != null)
- val += getBody().getHeight();
- if(getTitleBar() != null)
- val += getTitleBar().getHeight();
- if(getSoftkeybar() != null)
- val += getSoftkeybar().getHeight();
- return val;
- }
- public void setEventManager(EventManager manager)
- {
- eventManager = manager;
- if(getSoftkeybar() != null)
- {
- getSoftkeybar().setEventManager(manager);
- }
- if(getBody() != null)
- {
- getBody().setEventManager(manager);
- }
- }
- public final void keyPressed(int key)
- {
- if(getSoftkeybar() == null || !getSoftkeybar().keyPressed(key))
- {
- if(getBody() != null)
- getBody().keyPressed(key);
- }
- }
- public final void keyRepeated(int key)
- {
- if(!getBody().keyRepeated(key))
- {
- getBody().keyPressed(key);
- }
- }
- public final void keyReleased(int key)
- {
- if(!getBody().keyReleased(key))
- {
- getBody().keyReleased(key);
- }
- }
- public void showNotify()
- {
- if(getTitleBar() != null)
- {
- getTitleBar().showNotify();
- }
- if(getBody() != null)
- {
- getBody().showNotify();
- getBody().setSelected(true);
- }
- }
- public void hideNotify()
- {
- if(getTitleBar() != null)
- getTitleBar().hideNotify();
- if(getBody() != null)
- {
- getBody().hideNotify();
- getBody().setSelected(false);
- }
- }
- public int getTransitionEffect() {
- return transitionEffect;
- }
- public void setTransitionEffect(int transitionEffect) {
- this.transitionEffect = transitionEffect;
- }
- }