src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java

Print this page




  99 
 100     /**
 101      * If mouse button is clicked on item showing submenu
 102      * we have to hide its submenu.
 103      * And if mouse button is pressed on such item and
 104      * dragged to another, getShowingSubmenu() is changed.
 105      * So this member saves the item that the user
 106      * presses mouse button on _only_ if it's showing submenu.
 107      */
 108     private XMenuPeer showingMousePressedSubmenu = null;
 109 
 110     /**
 111      * If the PopupMenu is invoked as a result of right button click
 112      * first mouse event after grabInput would be MouseReleased.
 113      * We need to check if the user has moved mouse after input grab.
 114      * If yes - hide the PopupMenu. If no - do nothing
 115      */
 116     protected Point grabInputPoint = null;
 117     protected boolean hasPointerMoved = false;
 118 


 119     /************************************************
 120      *
 121      * Mapping data
 122      *
 123      ************************************************/
 124 
 125     /**
 126      * Mapping data that is filled in getMappedItems function
 127      * and reset in resetSize function. It contains array of
 128      * items in order that they appear on screen and may contain
 129      * additional data defined by descendants.
 130      */
 131     private MappingData mappingData;
 132 
 133     static class MappingData implements Cloneable {
 134 
 135         /**
 136          * Array of item in order that they appear on screen
 137          */
 138         private XMenuItemPeer[] items;


 157             try {
 158                 return super.clone();
 159             } catch (CloneNotSupportedException ex) {
 160                 throw new InternalError(ex);
 161             }
 162         }
 163 
 164         public XMenuItemPeer[] getItems() {
 165             return this.items;
 166         }
 167     }
 168 
 169     /************************************************
 170      *
 171      * Construction
 172      *
 173      ************************************************/
 174     XBaseMenuWindow() {
 175         super(new XCreateWindowParams(new Object[] {
 176             DELAYED, Boolean.TRUE}));


 177     }
 178 
 179     /************************************************
 180      *
 181      * Abstract methods
 182      *
 183      ************************************************/
 184 
 185     /**
 186      * Returns parent menu window (not the X-heirarchy parent window)
 187      */
 188     protected abstract XBaseMenuWindow getParentMenuWindow();
 189 
 190     /**
 191      * Performs mapping of items in window.
 192      * This function creates and fills specific
 193      * descendant of MappingData
 194      * and sets mapping coordinates of items
 195      * This function should return default menu data
 196      * if errors occur


 887         switch (e.get_type()) {
 888           case XConstants.Expose :
 889           case XConstants.GraphicsExpose :
 890           case XConstants.ButtonPress:
 891           case XConstants.ButtonRelease:
 892           case XConstants.MotionNotify:
 893           case XConstants.KeyPress:
 894           case XConstants.KeyRelease:
 895           case XConstants.DestroyNotify:
 896               return super.isEventDisabled(e);
 897           default:
 898               return true;
 899         }
 900     }
 901 
 902     /**
 903      * Invokes disposal procedure on eventHandlerThread
 904      */
 905     public void dispose() {
 906         setDisposed(true);
 907         InvocationEvent ev = new InvocationEvent(target, new Runnable() {

 908             public void run() {
 909                 doDispose();
 910             }
 911         });
 912         super.postEvent(ev);
 913     }
 914 
 915     /**
 916      * Performs disposal of menu window.
 917      * Should be called only on eventHandlerThread
 918      */
 919     protected void doDispose() {
 920         xSetVisible(false);
 921         SurfaceData oldData = surfaceData;
 922         surfaceData = null;
 923         if (oldData != null) {
 924             oldData.invalidate();
 925         }
 926         XToolkit.targetDisposedPeer(target, this);
 927         destroy();
 928     }
 929 
 930     /**
 931      * Invokes event processing on eventHandlerThread
 932      * This function needs to be overriden since




  99 
 100     /**
 101      * If mouse button is clicked on item showing submenu
 102      * we have to hide its submenu.
 103      * And if mouse button is pressed on such item and
 104      * dragged to another, getShowingSubmenu() is changed.
 105      * So this member saves the item that the user
 106      * presses mouse button on _only_ if it's showing submenu.
 107      */
 108     private XMenuPeer showingMousePressedSubmenu = null;
 109 
 110     /**
 111      * If the PopupMenu is invoked as a result of right button click
 112      * first mouse event after grabInput would be MouseReleased.
 113      * We need to check if the user has moved mouse after input grab.
 114      * If yes - hide the PopupMenu. If no - do nothing
 115      */
 116     protected Point grabInputPoint = null;
 117     protected boolean hasPointerMoved = false;
 118 
 119     private AppContext disposeAppContext;
 120 
 121     /************************************************
 122      *
 123      * Mapping data
 124      *
 125      ************************************************/
 126 
 127     /**
 128      * Mapping data that is filled in getMappedItems function
 129      * and reset in resetSize function. It contains array of
 130      * items in order that they appear on screen and may contain
 131      * additional data defined by descendants.
 132      */
 133     private MappingData mappingData;
 134 
 135     static class MappingData implements Cloneable {
 136 
 137         /**
 138          * Array of item in order that they appear on screen
 139          */
 140         private XMenuItemPeer[] items;


 159             try {
 160                 return super.clone();
 161             } catch (CloneNotSupportedException ex) {
 162                 throw new InternalError(ex);
 163             }
 164         }
 165 
 166         public XMenuItemPeer[] getItems() {
 167             return this.items;
 168         }
 169     }
 170 
 171     /************************************************
 172      *
 173      * Construction
 174      *
 175      ************************************************/
 176     XBaseMenuWindow() {
 177         super(new XCreateWindowParams(new Object[] {
 178             DELAYED, Boolean.TRUE}));
 179 
 180         disposeAppContext = AppContext.getAppContext();
 181     }
 182 
 183     /************************************************
 184      *
 185      * Abstract methods
 186      *
 187      ************************************************/
 188 
 189     /**
 190      * Returns parent menu window (not the X-heirarchy parent window)
 191      */
 192     protected abstract XBaseMenuWindow getParentMenuWindow();
 193 
 194     /**
 195      * Performs mapping of items in window.
 196      * This function creates and fills specific
 197      * descendant of MappingData
 198      * and sets mapping coordinates of items
 199      * This function should return default menu data
 200      * if errors occur


 891         switch (e.get_type()) {
 892           case XConstants.Expose :
 893           case XConstants.GraphicsExpose :
 894           case XConstants.ButtonPress:
 895           case XConstants.ButtonRelease:
 896           case XConstants.MotionNotify:
 897           case XConstants.KeyPress:
 898           case XConstants.KeyRelease:
 899           case XConstants.DestroyNotify:
 900               return super.isEventDisabled(e);
 901           default:
 902               return true;
 903         }
 904     }
 905 
 906     /**
 907      * Invokes disposal procedure on eventHandlerThread
 908      */
 909     public void dispose() {
 910         setDisposed(true);
 911 
 912         SunToolkit.invokeLaterOnAppContext(disposeAppContext, new Runnable()  {
 913             public void run() {
 914                 doDispose();
 915             }
 916         });

 917     }
 918 
 919     /**
 920      * Performs disposal of menu window.
 921      * Should be called only on eventHandlerThread
 922      */
 923     protected void doDispose() {
 924         xSetVisible(false);
 925         SurfaceData oldData = surfaceData;
 926         surfaceData = null;
 927         if (oldData != null) {
 928             oldData.invalidate();
 929         }
 930         XToolkit.targetDisposedPeer(target, this);
 931         destroy();
 932     }
 933 
 934     /**
 935      * Invokes event processing on eventHandlerThread
 936      * This function needs to be overriden since