javauis/lcdui_qt/src/javax/microedition/lcdui/Displayable.java
changeset 87 1627c337e51e
parent 72 1f0034e370aa
equal deleted inserted replaced
80:d6dafc5d983f 87:1627c337e51e
   197     {
   197     {
   198         if(!shell.isDisposed())
   198         if(!shell.isDisposed())
   199         {
   199         {
   200             eswtUpdateSizes();
   200             eswtUpdateSizes();
   201 
   201 
   202             // If it is popup textbox ticker should not be visible
   202             // If it is popup textbox or alert ticker should not be visible
   203             if (ticker != null && !isPopup())
   203             if (ticker != null && !isPopup())
   204             {
   204             {
       
   205                 if (tickerLabel != null && !tickerLabel.getVisible())
       
   206                 {
       
   207                     // Show ticker:
       
   208                     tickerLabel.setVisible(true);
       
   209                 }
   205                 ticker.start();
   210                 ticker.start();
       
   211             }
       
   212             else if (ticker != null && isPopup())
       
   213             {
       
   214                 if (tickerLabel != null && tickerLabel.getVisible())
       
   215                 {
       
   216                     // Hide ticker:
       
   217                     tickerLabel.setVisible(false);
       
   218                 }
       
   219 
   206             }
   220             }
   207             shell.addShellListener(eswtShellListener);
   221             shell.addShellListener(eswtShellListener);
   208             shell.addDisposeListener(eswtDisposeListener);
   222             shell.addDisposeListener(eswtDisposeListener);
   209             shell.addControlListener(eswtControlListener);
   223             shell.addControlListener(eswtControlListener);
   210             eswtAddSelectionListenerForCommands();
   224             eswtAddSelectionListenerForCommands();
   336 
   350 
   337             Rectangle contentBounds = contentComp.getBounds();
   351             Rectangle contentBounds = contentComp.getBounds();
   338             int newWidth = (aWidth > 0 ? aWidth : contentBounds.width);
   352             int newWidth = (aWidth > 0 ? aWidth : contentBounds.width);
   339             int newHeight = (aHeight > 0 ? aHeight : contentBounds.height);
   353             int newHeight = (aHeight > 0 ? aHeight : contentBounds.height);
   340 
   354 
   341             if(tickerLabel != null)
   355             if(tickerLabel != null && !isPopup())
   342             {
   356             {
   343                 newHeight += tickerLabel.getBounds().height;
   357                 newHeight += tickerLabel.getBounds().height;
   344             }
   358             }
   345 
   359 
   346             Rectangle shellBounds = shell.getBounds();
   360             Rectangle shellBounds = shell.getBounds();
   367 
   381 
   368     Rectangle eswtLayoutShellContent()
   382     Rectangle eswtLayoutShellContent()
   369     {
   383     {
   370         Rectangle shellArea = shell.getClientArea();
   384         Rectangle shellArea = shell.getClientArea();
   371 
   385 
   372         if(tickerLabel != null)
   386         if(tickerLabel != null && !isPopup())
   373         {
   387         {
   374             int tickerHeight = tickerLabel.getBounds().height;
   388             int tickerHeight = tickerLabel.getBounds().height;
   375 
   389 
   376             contentComp.setBounds(0, tickerHeight,
   390             contentComp.setBounds(0, tickerHeight,
   377                                   shellArea.width, shellArea.height - tickerHeight);
   391                                   shellArea.width, shellArea.height - tickerHeight);
   394                 || newArea.width != contentArea.width
   408                 || newArea.width != contentArea.width
   395                 || newArea.height != contentArea.height)
   409                 || newArea.height != contentArea.height)
   396         {
   410         {
   397             contentArea = newArea;
   411             contentArea = newArea;
   398             initialized = true;
   412             initialized = true;
   399             if(ticker != null)
   413             if(ticker != null && !isPopup())
   400             {
   414             {
   401                 ticker.updateSpeed();
   415                 ticker.updateSpeed();
   402             }
   416             }
   403             eswtHandleResizeEvent(contentArea.width, contentArea.height);
   417             eswtHandleResizeEvent(contentArea.width, contentArea.height);
   404         }
   418         }
   723                 if(finalTicker != null)
   737                 if(finalTicker != null)
   724                 {
   738                 {
   725                     // Setting ticker:
   739                     // Setting ticker:
   726                     tickerLabel.setText(finalTicker.getFormattedString());
   740                     tickerLabel.setText(finalTicker.getFormattedString());
   727 
   741 
   728                     // If it is popup textbox ticker should not be visible
   742                     // If it is popup textbox or alert ticker should not be visible
   729                     if (!currentDisplayable.isPopup())
   743                     if (!currentDisplayable.isPopup())
   730                     {
   744                     {
   731 
   745 
   732                         // Setting ticker:
   746                         // Setting ticker:
   733                         tickerLabel.pack();
   747                         tickerLabel.pack();
   741                 else
   755                 else
   742                 {
   756                 {
   743                     // Removing ticker:
   757                     // Removing ticker:
   744                     tickerLabel.setText("");
   758                     tickerLabel.setText("");
   745 
   759 
   746                     // If it is popup textbox ticker should not be visible
   760                     // If it is popup textbox or alert ticker should not be visible
   747                     if (!currentDisplayable.isPopup())
   761                     if (!currentDisplayable.isPopup())
   748                     {
   762                     {
   749                         // Removing ticker:
   763                         // Removing ticker:
   750                         tickerLabel.setBounds(Integer.MIN_VALUE, 0, 0, 0);
   764                         tickerLabel.setBounds(Integer.MIN_VALUE, 0, 0, 0);
   751                     }
   765                     }
   755         });
   769         });
   756         if(ticker != null)
   770         if(ticker != null)
   757         {
   771         {
   758             if(isLcduiVisible)
   772             if(isLcduiVisible)
   759             {
   773             {
   760                 // If it is popup textbox ticker should not be visible
   774                 // If it is popup textbox or alert ticker should not be visible
   761                 if (!isPopup())
   775                 if (!isPopup())
   762                 {
   776                 {
   763                     // Start to scroll the ticker. Ticker may be already running
   777                     // Start to scroll the ticker. Ticker may be already running
   764                     // if it exists in some other displayable already, but
   778                     // if it exists in some other displayable already, but
   765                     // calling this again wont do any harm:
   779                     // calling this again wont do any harm:
   825             final Displayable currentDisplayable = this;
   839             final Displayable currentDisplayable = this;
   826             ESWTUIThreadRunner.syncExec(new Runnable()
   840             ESWTUIThreadRunner.syncExec(new Runnable()
   827             {
   841             {
   828                 public void run()
   842                 public void run()
   829                 {
   843                 {
   830                     // Alert's ticker should be added to top part of the screen
   844                     tickerLabel = new Label(shell,
   831                     Composite parent = shell;
       
   832                     if (currentDisplayable instanceof Alert)
       
   833                     {
       
   834                         parent = shell.getParent();
       
   835                         if(parent == null)
       
   836                         {
       
   837                             parent = shell;
       
   838                         }
       
   839                     }
       
   840                     tickerLabel = new Label(parent,
       
   841                         SWT.SHADOW_NONE | SWT.HORIZONTAL | SWT.CENTER);
   845                         SWT.SHADOW_NONE | SWT.HORIZONTAL | SWT.CENTER);
   842                 }
   846                 }
   843             });
   847             });
   844         }
   848         }
   845         return tickerLabel;
   849         return tickerLabel;
   904      */
   908      */
   905     protected boolean isPopup()
   909     protected boolean isPopup()
   906     {
   910     {
   907         boolean isPopup = false;
   911         boolean isPopup = false;
   908 
   912 
   909         if(this instanceof TextBox && 
   913         if(this instanceof Alert || (this instanceof TextBox && 
   910                     !JadAttributeUtil.isValue(
   914                     !JadAttributeUtil.isValue(
   911                         JadAttributeUtil.ATTRIB_NOKIA_UI_ENHANCEMENT, 
   915                         JadAttributeUtil.ATTRIB_NOKIA_UI_ENHANCEMENT, 
   912                         JadAttributeUtil.VALUE_FULLSCREEN_TEXTBOX))
   916                         JadAttributeUtil.VALUE_FULLSCREEN_TEXTBOX)))
   913         {
   917         {
   914             isPopup = true;
   918             isPopup = true;
   915         }
   919         }
   916         return isPopup;
   920         return isPopup;
   917     }
   921     }