javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java
changeset 76 4ad59aaee882
parent 61 bf7ee68962da
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
    36 {
    36 {
    37 
    37 
    38     /**
    38     /**
    39      * Key name for paint listener.
    39      * Key name for paint listener.
    40      */
    40      */
    41     private static final String PAINT_LISTENER = "paint";
    41     private static final String PAINT_LISTENER = "PaintListener";
    42 
    42 
    43     /**
    43     /**
    44      * Key name for mouse listener.
    44      * Key name for mouse listener.
    45      */
    45      */
    46     private static final String MOUSE_LISTENER = "mouse";
    46     private static final String MOUSE_LISTENER = "MouseListener";
    47 
    47 
    48     boolean noBackground;
    48     boolean noBackground;
    49 
    49 
    50     private Timer timer = new Timer();
    50     private Timer timer = new Timer();
    51     private CustomItemTimerTask timerTask;
    51     private CustomItemTimerTask timerTask;
    91                 try
    91                 try
    92                 {
    92                 {
    93                     twips = Integer.parseInt(twipString);
    93                     twips = Integer.parseInt(twipString);
    94                     timeout = Integer.parseInt(timeoutString);
    94                     timeout = Integer.parseInt(timeoutString);
    95 
    95 
    96                     // Check for Negative Values
    96 					// If any one of the value is zero or Negative, set defaults.
    97                     if((twips < 0) && (timeout < 0))
    97 					// If both are zero disable the tapdetection.
    98                     {
       
    99                         setDefaultTapValues();
       
   100                     }
       
   101 
       
   102                     if((twips == 0)  && (timeout == 0))
    98                     if((twips == 0)  && (timeout == 0))
   103                     {
    99                     {
   104                         disableTapDetection = true;
   100                         disableTapDetection = true;
   105                     }
   101                     }
   106 
   102                     else if((twips <= 0) || (timeout <= 0))
   107                     // if any one of the value is zero, set defaults
       
   108                     if(!((twips != 0) && (timeout != 0)))
       
   109                     {
   103                     {
   110                         setDefaultTapValues();
   104                         setDefaultTapValues();
   111                     }
   105                     }
   112                 }
   106                 }
   113                 catch(NumberFormatException e)
   107                 catch(NumberFormatException e)
   114                 {
   108                 {
   115                     // Alpha Numeric Values of Timeouts and Timeout
   109                     // Alpha Numeric Values of Twips and Timeout
   116                     setDefaultTapValues();
   110                     setDefaultTapValues();
   117                 }
   111                 }
   118             }
   112             }
   119         }
   113         }
   120         else
   114         else
   147      * Set the size of the layouted Control.
   141      * Set the size of the layouted Control.
   148      */
   142      */
   149     void eswtResizeControl(Item item, Control control, int width, int height)
   143     void eswtResizeControl(Item item, Control control, int width, int height)
   150     {
   144     {
   151         super.eswtResizeControl(item, control, width, height);
   145         super.eswtResizeControl(item, control, width, height);
   152         CustomItem customitem = (CustomItem) item;
   146         ((CustomItem)item).internalHandleSizeChanged(width, height);
   153         customitem.internalHandleSizeChanged(width, height);
       
   154     }
   147     }
   155 
   148 
   156     /**
   149     /**
   157      * Add listeners to Layouter specific control.
   150      * Add listeners to Layouter specific control.
   158      */
   151      */
   556 
   549 
   557             int LeftX = pointerDownX - (int) xPxielwidth;
   550             int LeftX = pointerDownX - (int) xPxielwidth;
   558 
   551 
   559             // If the rectange width falls outside the custom area
   552             // If the rectange width falls outside the custom area
   560             if(LeftX < 0)
   553             if(LeftX < 0)
       
   554             {
   561                 LeftX = 0;
   555                 LeftX = 0;
       
   556             }
   562 
   557 
   563             int TopY = pointerDownY - (int) yPixelHeight;
   558             int TopY = pointerDownY - (int) yPixelHeight;
   564 
   559 
   565             // If the rectange height falls outside the custom area
   560             // If the rectange height falls outside the custom area
   566             if(TopY < 0)
   561             if(TopY < 0)
       
   562         	{
   567                 TopY = 0;
   563                 TopY = 0;
       
   564             }
   568 
   565 
   569             int DownY = pointerDownY + (int) yPixelHeight;
   566             int DownY = pointerDownY + (int) yPixelHeight;
   570 
   567 
   571             // If the rectange heightfalls outside the custom area.
   568             // If the rectange heightfalls outside the custom area.
   572             if(DownY > customItem.getContentHeight())
   569             if(DownY > customItem.getContentHeight())
       
   570             {
   573                 DownY = customItem.getContentHeight();
   571                 DownY = customItem.getContentHeight();
       
   572             }
   574 
   573 
   575             // Find the PointerUp is withing rectange
   574             // Find the PointerUp is withing rectange
   576             if((x >= LeftX) && (x <= RightX))
   575             if((x >= LeftX) && (x <= RightX))
   577             {
   576             {
   578                 if((y >= TopY) && (y <= DownY))
   577                 if((y >= TopY) && (y <= DownY))