FileDocCategorySizeDatePackage
Dispatcher.javaAPI DocAndroid 1.5 API25386Wed May 06 22:41:54 BST 2009java.awt

Dispatcher

public class Dispatcher extends Object
Helper package-private class for managing lightweight components & dispatching events from heavyweight source

Fields Summary
final MouseGrabManager
mouseGrabManager
final MouseDispatcher
mouseDispatcher
private final ComponentDispatcher
componentDispatcher
private final KeyDispatcher
keyDispatcher
private final Toolkit
toolkit
int
clickInterval
Constructors Summary
Dispatcher(Toolkit toolkit)

param
toolkit - AWT toolkit


              
      
        this.toolkit = toolkit;

        //???AWT: focusDispatcher = new FocusDispatcher(toolkit);
        mouseDispatcher = new MouseDispatcher(mouseGrabManager, toolkit);
    
Methods Summary
public booleanonEvent(org.apache.harmony.awt.wtk.NativeEvent event)
Dispatch native event: produce appropriate AWT events, update component's fields when needed

param
event - native event to dispatch
return
- true means default processing by OS is not needed

        int eventId = event.getEventId();

        if (eventId == NativeEvent.ID_CREATED) {
            return toolkit.onWindowCreated(event.getWindowId());
        } else if (eventId == NativeEvent.ID_MOUSE_GRAB_CANCELED) {
            return mouseGrabManager.onGrabCanceled();
        //???AWT
//        } else if (popupDispatcher.onEvent(event)) {
//            return false;
        } else {
            Component src = toolkit.getComponentById(event.getWindowId());

            if (src != null) {
                if (((eventId >= ComponentEvent.COMPONENT_FIRST) && (eventId <= ComponentEvent.COMPONENT_LAST))
                        || ((eventId >= WindowEvent.WINDOW_FIRST) && (eventId <= WindowEvent.WINDOW_LAST))
                        || (eventId == NativeEvent.ID_INSETS_CHANGED)
                        || (eventId == NativeEvent.ID_BOUNDS_CHANGED)
                        || (eventId == NativeEvent.ID_THEME_CHANGED)) {
                    return componentDispatcher.dispatch(src, event);
                } else if ((eventId >= MouseEvent.MOUSE_FIRST)
                        && (eventId <= MouseEvent.MOUSE_LAST)) {
                    return mouseDispatcher.dispatch(src, event);
                } else if (eventId == PaintEvent.PAINT) {
                    //???AWT: src.redrawManager.addPaintRegion(src, event.getClipRects());
                    return true;
                }
            }
            if ((eventId >= FocusEvent.FOCUS_FIRST)
                    && (eventId <= FocusEvent.FOCUS_LAST)) {

                //???AWT: return focusDispatcher.dispatch(src, event);
                return false;
            } else if ((eventId >= KeyEvent.KEY_FIRST)
                    && (eventId <= KeyEvent.KEY_LAST)) {
                return keyDispatcher.dispatch(src, event);
            }
        }

        return false;