javauis/lcdui_qt/src/javax/microedition/lcdui/Displayable.java
changeset 79 2f468c1958d0
parent 76 4ad59aaee882
equal deleted inserted replaced
76:4ad59aaee882 79:2f468c1958d0
   123     {
   123     {
   124         ESWTUIThreadRunner.safeSyncExec(new Runnable()
   124         ESWTUIThreadRunner.safeSyncExec(new Runnable()
   125         {
   125         {
   126             public void run()
   126             public void run()
   127             {
   127             {
   128                 shell = eswtConstructShell(SWT.SHELL_TRIM | SWT.PRIMARY_MODAL);
   128                 shell = eswtConstructShell(SWT.SHELL_TRIM);
   129                 eswtSetTitle();
   129                 eswtSetTitle();
   130                 contentComp = eswtConstructContent(SWT.NONE);
   130                 contentComp = eswtConstructContent(SWT.NONE);
   131                 contentArea = eswtLayoutShellContent();
   131                 contentArea = eswtLayoutShellContent();
   132                 eswtInitGraphics();
   132                 eswtInitGraphics();
   133             }
   133             }
   196     void eswtHandleShowCurrentEvent()
   196     void eswtHandleShowCurrentEvent()
   197     {
   197     {
   198         if(!shell.isDisposed())
   198         if(!shell.isDisposed())
   199         {
   199         {
   200             eswtUpdateSizes();
   200             eswtUpdateSizes();
   201             if(ticker != null)
   201 
       
   202             // If it is popup textbox ticker should not be visible
       
   203             if (ticker != null && !isPopup())
   202             {
   204             {
   203                 ticker.start();
   205                 ticker.start();
   204             }
   206             }
   205             shell.addShellListener(eswtShellListener);
   207             shell.addShellListener(eswtShellListener);
   206             shell.addDisposeListener(eswtDisposeListener);
   208             shell.addDisposeListener(eswtDisposeListener);
   325      */
   327      */
   326     void eswtSetPreferredContentSize(int aWidth, int aHeight)
   328     void eswtSetPreferredContentSize(int aWidth, int aHeight)
   327     {
   329     {
   328         if(isDialogShell())
   330         if(isDialogShell())
   329         {
   331         {
   330             // aHeight += Config.DISPLAYABLE_DIALOGSHELL_HEIGHT_DISPLACEMENT;
   332             //aHeight += Config.DISPLAYABLE_DIALOGSHELL_HEIGHT_DISPLACEMENT;
   331 
   333 
   332             Logger.method(this, "eswtSetPreferredContentSize",
   334             Logger.method(this, "eswtSetPreferredContentSize",
   333                           String.valueOf(aWidth), String.valueOf(aHeight));
   335                           String.valueOf(aWidth), String.valueOf(aHeight));
   334 
   336 
   335             Rectangle contentBounds = contentComp.getBounds();
   337             Rectangle contentBounds = contentComp.getBounds();
   342             }
   344             }
   343 
   345 
   344             Rectangle shellBounds = shell.getBounds();
   346             Rectangle shellBounds = shell.getBounds();
   345             // compute the trimmed shell size
   347             // compute the trimmed shell size
   346             Rectangle newSize = shell.computeTrim(0, 0, newWidth, newHeight);
   348             Rectangle newSize = shell.computeTrim(0, 0, newWidth, newHeight);
       
   349 
   347             // set the new size
   350             // set the new size
   348             shell.setSize(newSize.width, newSize.height);
   351             shell.setSize(newSize.width, newSize.height);
   349             // set the location - attached to the bottom growing upwards
   352 
   350             shell.setLocation(shellBounds.x, (shellBounds.y + shellBounds.height) - newSize.height);
   353             if(!(this instanceof Alert))
       
   354             {
       
   355                 // set the location - attached to the bottom growing upwards
       
   356                 shell.setLocation(shellBounds.x, 
       
   357                     (shellBounds.y + shellBounds.height) - newSize.height);
       
   358             }
       
   359             else
       
   360             {
       
   361                 // Temporary solution, it should be changed after qt integration
       
   362                 shell.setLocation(shellBounds.x, ESWTUIThreadRunner.
       
   363                     getInstance().getDisplay().getBounds().height/2);
       
   364             }
   351         }
   365         }
   352     }
   366     }
   353 
   367 
   354     Rectangle eswtLayoutShellContent()
   368     Rectangle eswtLayoutShellContent()
   355     {
   369     {
   356         Rectangle shellArea = shell.getClientArea();
   370         Rectangle shellArea = shell.getClientArea();
       
   371 
   357         if(tickerLabel != null)
   372         if(tickerLabel != null)
   358         {
   373         {
   359             int tickerHeight = tickerLabel.getBounds().height;
   374             int tickerHeight = tickerLabel.getBounds().height;
   360 
   375 
   361             contentComp.setBounds(0, tickerHeight,
   376             contentComp.setBounds(0, tickerHeight,
   697         {
   712         {
   698             ticker.addLabel(getTickerLabel());
   713             ticker.addLabel(getTickerLabel());
   699         }
   714         }
   700 
   715 
   701         final Ticker finalTicker = ticker;
   716         final Ticker finalTicker = ticker;
       
   717         final Displayable currentDisplayable = this;
       
   718 
   702         ESWTUIThreadRunner.syncExec(new Runnable()
   719         ESWTUIThreadRunner.syncExec(new Runnable()
   703         {
   720         {
   704             public void run()
   721             public void run()
   705             {
   722             {
   706                 if(finalTicker != null)
   723                 if(finalTicker != null)
   707                 {
   724                 {
   708                     // Setting ticker:
   725                     // Setting ticker:
   709                     tickerLabel.setText(finalTicker.getFormattedString());
   726                     tickerLabel.setText(finalTicker.getFormattedString());
   710                     tickerLabel.pack();
   727 
   711                     // Avoid ticker flashing by setting it out of the
   728                     // If it is popup textbox ticker should not be visible
   712                     // screen first:
   729                     if (!currentDisplayable.isPopup())
   713                     tickerLabel.setBounds(Integer.MIN_VALUE, 0,
   730                     {
       
   731 
       
   732                         // Setting ticker:
       
   733                         tickerLabel.pack();
       
   734                         // Avoid ticker flashing by setting it out of the
       
   735                         // screen first:
       
   736                         tickerLabel.setBounds(Integer.MIN_VALUE, 0,
   714                                           tickerLabel.getBounds().width,
   737                                           tickerLabel.getBounds().width,
   715                                           tickerLabel.getBounds().height);
   738                                           tickerLabel.getBounds().height);
       
   739                     }
   716                 }
   740                 }
   717                 else
   741                 else
   718                 {
   742                 {
   719                     // Removing ticker:
   743                     // Removing ticker:
   720                     tickerLabel.setText("");
   744                     tickerLabel.setText("");
   721                     tickerLabel.setBounds(Integer.MIN_VALUE, 0, 0, 0);
   745 
       
   746                     // If it is popup textbox ticker should not be visible
       
   747                     if (!currentDisplayable.isPopup())
       
   748                     {
       
   749                         // Removing ticker:
       
   750                         tickerLabel.setBounds(Integer.MIN_VALUE, 0, 0, 0);
       
   751                     }
   722                 }
   752                 }
   723                 eswtUpdateSizes();
   753                 eswtUpdateSizes();
   724             }
   754             }
   725         });
   755         });
   726         if(ticker != null)
   756         if(ticker != null)
   727         {
   757         {
   728             if(isLcduiVisible)
   758             if(isLcduiVisible)
   729             {
   759             {
   730                 // Start to scroll the ticker. Ticker may be already running
   760                 // If it is popup textbox ticker should not be visible
   731                 // if it exists in some other displayable already, but
   761                 if (!isPopup())
   732                 // calling this again wont do any harm:
   762                 {
   733                 ticker.start();
   763                     // Start to scroll the ticker. Ticker may be already running
       
   764                     // if it exists in some other displayable already, but
       
   765                     // calling this again wont do any harm:
       
   766                     ticker.start();
       
   767                 }
   734             }
   768             }
   735         }
   769         }
   736     }
   770     }
   737 
   771 
   738     /**
   772     /**
   786      */
   820      */
   787     Label getTickerLabel()
   821     Label getTickerLabel()
   788     {
   822     {
   789         if(tickerLabel == null)
   823         if(tickerLabel == null)
   790         {
   824         {
       
   825             final Displayable currentDisplayable = this;
   791             ESWTUIThreadRunner.syncExec(new Runnable()
   826             ESWTUIThreadRunner.syncExec(new Runnable()
   792             {
   827             {
   793                 public void run()
   828                 public void run()
   794                 {
   829                 {
   795                     tickerLabel = new Label(shell,
   830                     // Alert's ticker should be added to top part of the screen
   796                                             SWT.SHADOW_NONE | SWT.HORIZONTAL | SWT.CENTER);
   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);
   797                 }
   842                 }
   798             });
   843             });
   799         }
   844         }
   800         return tickerLabel;
   845         return tickerLabel;
   801     }
   846     }
   852             event.commandListener.commandAction(event.command, this);
   897             event.commandListener.commandAction(event.command, this);
   853             break;
   898             break;
   854         }
   899         }
   855     }
   900     }
   856 
   901 
       
   902     /* (non-Javadoc)
       
   903      * Checks if instance of Displayable is popup component
       
   904      */
       
   905     protected boolean isPopup()
       
   906     {
       
   907         boolean isPopup = false;
       
   908 
       
   909         if(this instanceof TextBox && 
       
   910                     !JadAttributeUtil.isValue(
       
   911                         JadAttributeUtil.ATTRIB_NOKIA_UI_ENHANCEMENT, 
       
   912                         JadAttributeUtil.VALUE_FULLSCREEN_TEXTBOX))
       
   913         {
       
   914             isPopup = true;
       
   915         }
       
   916         return isPopup;
       
   917     }
       
   918 
   857     /**
   919     /**
   858      * Inner class which receives SelectionEvents from eSWT and convert and
   920      * Inner class which receives SelectionEvents from eSWT and convert and
   859      * forwards those events to LCDUI's CommandListener.
   921      * forwards those events to LCDUI's CommandListener.
   860      */
   922      */
   861     class EswtCommandListener implements SelectionListener
   923     class EswtCommandListener implements SelectionListener