/[classpath]/classpath/java/awt/event/InputEvent.java
ViewVC logotype

Diff of /classpath/java/awt/event/InputEvent.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by ericb, Sat Mar 30 12:02:30 2002 UTC revision 1.6 by ericb, Wed May 8 07:53:54 2002 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package java.awt.event;  package java.awt.event;
40    
41  import java.awt.Component;  import java.awt.Component;
42    import gnu.java.awt.EventModifier;
43    
44  /**  /**
45   * This is the common superclass for all component input classes. These are   * This is the common superclass for all component input classes. These are
# Line 182  public abstract class InputEvent extends Line 183  public abstract class InputEvent extends
183     */     */
184    public static final int ALT_GRAPH_DOWN_MASK = 0x2000;    public static final int ALT_GRAPH_DOWN_MASK = 0x2000;
185    
   /** The mask for old events, package visible for use in subclasses. */  
   static final int OLD_MASK = 0x3f;  
   
   /** The mask for new events, package visible for use in subclasses. */  
   static final int NEW_MASK = 0x3fc0;  
   
186    /** The mask to convert new to old, package visible for use in subclasses. */    /** The mask to convert new to old, package visible for use in subclasses. */
187    static final int CONVERT_MASK    static final int CONVERT_MASK
188      = NEW_MASK & ~(BUTTON2_DOWN_MASK | BUTTON3_DOWN_MASK);      = EventModifier.NEW_MASK & ~(BUTTON2_DOWN_MASK | BUTTON3_DOWN_MASK);
189    
190    /**    /**
191     * The timestamp when this event occurred.     * The timestamp when this event occurred.
# Line 226  public abstract class InputEvent extends Line 221  public abstract class InputEvent extends
221    {    {
222      super(source, id);      super(source, id);
223      this.when = when;      this.when = when;
224      this.modifiers = extend(modifiers);      this.modifiers = EventModifier.extend(modifiers);
225    }    }
226    
227    /**    /**
# Line 304  public abstract class InputEvent extends Line 299  public abstract class InputEvent extends
299     */     */
300    public int getModifiers()    public int getModifiers()
301    {    {
302      int mod = modifiers;      return EventModifier.revert(modifiers);
     if ((mod & SHIFT_DOWN_MASK) != 0)  
       mod |= SHIFT_MASK;  
     if ((mod & CTRL_DOWN_MASK) != 0)  
       mod |= CTRL_MASK;  
     if ((mod & META_DOWN_MASK) != 0)  
       mod |= META_MASK;  
     if ((mod & ALT_DOWN_MASK) != 0)  
       mod |= ALT_MASK;  
     if ((mod & ALT_GRAPH_DOWN_MASK) != 0)  
       mod |= ALT_GRAPH_MASK;  
     if ((mod & BUTTON1_DOWN_MASK) != 0)  
       mod |= BUTTON1_MASK;  
     return mod & OLD_MASK;  
303    }    }
304    
305    /**    /**
# Line 372  public abstract class InputEvent extends Line 354  public abstract class InputEvent extends
354     */     */
355    public static String getModifiersExText(int modifiers)    public static String getModifiersExText(int modifiers)
356    {    {
357      modifiers &= NEW_MASK;      modifiers &= EventModifier.NEW_MASK;
358      if (modifiers == 0)      if (modifiers == 0)
359        return "";        return "";
360      StringBuffer s = new StringBuffer();      StringBuffer s = new StringBuffer();
# Line 394  public abstract class InputEvent extends Line 376  public abstract class InputEvent extends
376        s.append("Button3+");        s.append("Button3+");
377      return s.substring(0, s.length() - 1);      return s.substring(0, s.length() - 1);
378    }    }
   
   /**  
    * Converts the old style modifiers (0x3f) to the new style (0xffffffc0).  
    * Package visible for use by subclasses.  
    *  
    * @param mod the modifiers to convert  
    * @return the adjusted modifiers  
    */  
   static int extend(int mod)  
   {  
     // Favor what we hope will be the common case.  
     if ((mod & OLD_MASK) == 0)  
       return mod;  
     if ((mod & SHIFT_MASK) != 0)  
       mod |= SHIFT_DOWN_MASK;  
     if ((mod & CTRL_MASK) != 0)  
       mod |= CTRL_DOWN_MASK;  
     if ((mod & META_MASK) != 0)  
       mod |= META_DOWN_MASK;  
     if ((mod & ALT_MASK) != 0)  
       mod |= ALT_DOWN_MASK;  
     if ((mod & BUTTON1_MASK) != 0)  
       mod |= BUTTON1_DOWN_MASK;  
     if ((mod & ALT_GRAPH_MASK) != 0)  
       mod |= ALT_GRAPH_DOWN_MASK;  
     return mod & ~OLD_MASK;  
   }  
379  } // class InputEvent  } // class InputEvent

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26