javauis/lcdui_qt/src/javax/microedition/lcdui/Displayable.java
changeset 47 f40128debb5d
parent 23 98ccebc37403
child 48 e0d6e9bd3ca7
equal deleted inserted replaced
35:85266cc22c7f 47:f40128debb5d
   124     {
   124     {
   125         ESWTUIThreadRunner.safeSyncExec(new Runnable()
   125         ESWTUIThreadRunner.safeSyncExec(new Runnable()
   126         {
   126         {
   127             public void run()
   127             public void run()
   128             {
   128             {
   129                 shell = eswtConstructShell(SWT.SYSTEM_MODAL);
   129                 shell = eswtConstructShell(SWT.SHELL_TRIM | SWT.PRIMARY_MODAL);
   130                 eswtSetTitle();
   130                 eswtSetTitle();
   131                 contentComp = eswtConstructContent(SWT.NONE);
   131                 contentComp = eswtConstructContent(SWT.NONE);
   132                 contentArea = eswtLayoutShellContent();
   132                 contentArea = eswtLayoutShellContent();
       
   133                 eswtInitGraphics();
   133             }
   134             }
   134         });
   135         });
   135     }
   136     }
   136 
   137 
   137     /**
   138     /**
   182         Composite comp = new CompositeExtension(shell, style);
   183         Composite comp = new CompositeExtension(shell, style);
   183         return comp;
   184         return comp;
   184     }
   185     }
   185 
   186 
   186     /**
   187     /**
       
   188      * Initializes the Displayable for Graphics drawing. 
       
   189      */
       
   190     void eswtInitGraphics() {
       
   191     
       
   192     }
       
   193     
       
   194     /**
   187      * Called by Display when Displayable should become visible.
   195      * Called by Display when Displayable should become visible.
   188      */
   196      */
   189     void eswtHandleShowCurrentEvent()
   197     void eswtHandleShowCurrentEvent()
   190     {
   198     {
   191         if(!shell.isDisposed())
   199         if(!shell.isDisposed())
   192         {
   200         {
   193             eswtUpdateSizes();
   201             eswtUpdateSizes();
       
   202             if(ticker != null)
       
   203             {
       
   204                 ticker.start();
       
   205             }
   194             shell.addShellListener(eswtShellListener);
   206             shell.addShellListener(eswtShellListener);
   195             shell.addDisposeListener(eswtDisposeListener);
   207             shell.addDisposeListener(eswtDisposeListener);
   196             shell.addControlListener(eswtControlListener);
   208             shell.addControlListener(eswtControlListener);
   197             eswtAddSelectionListenerForCommands();
   209             eswtAddSelectionListenerForCommands();
   198             // calling open() causes a resize event to be sent
   210             // calling open() causes a resize event to be sent
   341     {
   353     {
   342         Rectangle shellArea = shell.getClientArea();
   354         Rectangle shellArea = shell.getClientArea();
   343         if(tickerLabel != null)
   355         if(tickerLabel != null)
   344         {
   356         {
   345             int tickerHeight = tickerLabel.getBounds().height;
   357             int tickerHeight = tickerLabel.getBounds().height;
       
   358 
   346             contentComp.setBounds(0, tickerHeight,
   359             contentComp.setBounds(0, tickerHeight,
   347                                   shellArea.width, shellArea.height - tickerHeight);
   360                                   shellArea.width, shellArea.height - tickerHeight);
   348         }
   361         }
   349         else
   362         else
   350         {
   363         {
   618     {
   631     {
   619         return (Command) commands.elementAt(index);
   632         return (Command) commands.elementAt(index);
   620     }
   633     }
   621 
   634 
   622     /**
   635     /**
       
   636      * Gets the commands array.
       
   637      *
       
   638      * @return the commands
       
   639      */
       
   640     Vector getCommands()
       
   641     {
       
   642         return commands;
       
   643     }
       
   644 
       
   645     /**
       
   646      * Gets the command listener.
       
   647      *
       
   648      * @return the eswt command listener.
       
   649      */
       
   650     final EswtCommandListener getCommandListener()
       
   651     {
       
   652         return eswtCommandListener;
       
   653     }
       
   654 
       
   655     /**
   623      * Gets width.
   656      * Gets width.
   624      *
   657      *
   625      * @return Width of the Displayable in pixels.
   658      * @return Width of the Displayable in pixels.
   626      */
   659      */
   627     public int getWidth()
   660     public int getWidth()
   688                 eswtUpdateSizes();
   721                 eswtUpdateSizes();
   689             }
   722             }
   690         });
   723         });
   691         if(ticker != null)
   724         if(ticker != null)
   692         {
   725         {
   693             // Start to scroll the ticker. Ticker may be already running
   726             if(isLcduiVisible)
   694             // if it exists in some other displayable already, but
   727             {
   695             // calling this again wont do any harm:
   728                 // Start to scroll the ticker. Ticker may be already running
   696             ticker.start();
   729                 // if it exists in some other displayable already, but
       
   730                 // calling this again wont do any harm:
       
   731                 ticker.start();
       
   732             }
   697         }
   733         }
   698     }
   734     }
   699 
   735 
   700     /**
   736     /**
   701      * Gets current ticker.
   737      * Gets current ticker.
   744     }
   780     }
   745 
   781 
   746     /**
   782     /**
   747      * Creates singleton Label instance used by Ticker.
   783      * Creates singleton Label instance used by Ticker.
   748      */
   784      */
   749     private Label getTickerLabel()
   785     Label getTickerLabel()
   750     {
   786     {
   751         if(tickerLabel == null)
   787         if(tickerLabel == null)
   752         {
   788         {
   753             ESWTUIThreadRunner.syncExec(new Runnable()
   789             ESWTUIThreadRunner.syncExec(new Runnable()
   754             {
   790             {
   854      * Every Displayable must listen shell events to be able to tell is the
   890      * Every Displayable must listen shell events to be able to tell is the
   855      * MIDlet sent to background.
   891      * MIDlet sent to background.
   856      */
   892      */
   857     class EswtShellListener implements ShellListener
   893     class EswtShellListener implements ShellListener
   858     {
   894     {
   859 
   895     
   860         public void shellActivated(ShellEvent e)
   896         public void shellActivated(ShellEvent e)
   861         {
       
   862             if(!isShellActive)
       
   863             {
       
   864                 handleShellActivatedEvent();
       
   865             }
       
   866         }
       
   867 
       
   868         public void shellDeactivated(ShellEvent e)
       
   869         {
   897         {
   870             ESWTUIThreadRunner.getInstance().getDisplay()
   898             ESWTUIThreadRunner.getInstance().getDisplay()
   871             .asyncExec(new Runnable()
   899             .asyncExec(new Runnable()
   872             {
   900             {
   873                 public void run()
   901                 public void run()
   874                 {
   902                 {
       
   903                     handleShellActivatedEvent();
       
   904                 }
       
   905             });
       
   906         }
       
   907 
       
   908         public void shellDeactivated(ShellEvent e)
       
   909         {
       
   910             ESWTUIThreadRunner.getInstance().getDisplay()
       
   911             .asyncExec(new Runnable()
       
   912             {
       
   913                 public void run()
       
   914                 {
   875                     handleShellDeActivatedEvent();
   915                     handleShellDeActivatedEvent();
   876                 }
   916                 }
   877             });
   917             });
   878 
   918 
   879         }
   919         }
   905      * Displayable must listen resize-events to be able to call
   945      * Displayable must listen resize-events to be able to call
   906      * sizeChanged()-method at the right time.
   946      * sizeChanged()-method at the right time.
   907      */
   947      */
   908     class EswtControlListener implements ControlListener
   948     class EswtControlListener implements ControlListener
   909     {
   949     {
       
   950     
   910         public void controlResized(ControlEvent e)
   951         public void controlResized(ControlEvent e)
   911         {
   952         {
   912             eswtUpdateSizes();
   953             eswtUpdateSizes();
   913         }
   954         }
   914 
   955