equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
19 import java.util.Enumeration; |
19 import java.util.Enumeration; |
20 import java.util.Vector; |
20 import java.util.Vector; |
21 |
21 |
22 import javax.microedition.lcdui.EventDispatcher.LCDUIEvent; |
22 import javax.microedition.lcdui.EventDispatcher.LCDUIEvent; |
23 |
23 |
24 import org.eclipse.ercp.swt.mobile.MobileShell; |
|
25 import org.eclipse.swt.SWT; |
24 import org.eclipse.swt.SWT; |
26 import org.eclipse.swt.events.*; |
25 import org.eclipse.swt.events.*; |
27 import org.eclipse.swt.graphics.Rectangle; |
26 import org.eclipse.swt.graphics.Rectangle; |
28 import org.eclipse.swt.internal.extension.CompositeExtension; |
27 import org.eclipse.swt.internal.extension.CompositeExtension; |
|
28 import org.eclipse.swt.internal.extension.MobileShellExtension; |
29 import org.eclipse.swt.widgets.*; |
29 import org.eclipse.swt.widgets.*; |
30 import com.nokia.mj.impl.rt.support.ApplicationUtils; |
30 import com.nokia.mj.impl.rt.support.ApplicationUtils; |
31 import com.nokia.mj.impl.rt.support.ApplicationInfo; |
31 import com.nokia.mj.impl.rt.support.ApplicationInfo; |
32 |
32 |
33 /** |
33 /** |
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 } |
133 } |
134 }); |
134 }); |
164 * |
164 * |
165 * @return eSWT shell |
165 * @return eSWT shell |
166 */ |
166 */ |
167 Shell eswtConstructShell(int style) |
167 Shell eswtConstructShell(int style) |
168 { |
168 { |
169 return new MobileShell(ESWTUIThreadRunner.getInstance().getDisplay(), style); |
169 return new MobileShellExtension(ESWTUIThreadRunner.getInstance().getDisplay(), style); |
170 } |
170 } |
171 |
171 |
172 /** |
172 /** |
173 * Creates content Composite. this Composite is placed inside of |
173 * Creates content Composite. this Composite is placed inside of |
174 * shell and contains the actual displayable's content (excluding ticker). |
174 * shell and contains the actual displayable's content (excluding ticker). |
189 void eswtHandleShowCurrentEvent() |
189 void eswtHandleShowCurrentEvent() |
190 { |
190 { |
191 if(!shell.isDisposed()) |
191 if(!shell.isDisposed()) |
192 { |
192 { |
193 eswtUpdateSizes(); |
193 eswtUpdateSizes(); |
|
194 if(ticker != null) |
|
195 { |
|
196 ticker.start(); |
|
197 } |
194 shell.addShellListener(eswtShellListener); |
198 shell.addShellListener(eswtShellListener); |
195 shell.addDisposeListener(eswtDisposeListener); |
199 shell.addDisposeListener(eswtDisposeListener); |
196 shell.addControlListener(eswtControlListener); |
200 shell.addControlListener(eswtControlListener); |
197 eswtAddSelectionListenerForCommands(); |
201 eswtAddSelectionListenerForCommands(); |
198 // calling open() causes a resize event to be sent |
202 // calling open() causes a resize event to be sent |
341 { |
345 { |
342 Rectangle shellArea = shell.getClientArea(); |
346 Rectangle shellArea = shell.getClientArea(); |
343 if(tickerLabel != null) |
347 if(tickerLabel != null) |
344 { |
348 { |
345 int tickerHeight = tickerLabel.getBounds().height; |
349 int tickerHeight = tickerLabel.getBounds().height; |
|
350 |
346 contentComp.setBounds(0, tickerHeight, |
351 contentComp.setBounds(0, tickerHeight, |
347 shellArea.width, shellArea.height - tickerHeight); |
352 shellArea.width, shellArea.height - tickerHeight); |
348 } |
353 } |
349 else |
354 else |
350 { |
355 { |
618 { |
623 { |
619 return (Command) commands.elementAt(index); |
624 return (Command) commands.elementAt(index); |
620 } |
625 } |
621 |
626 |
622 /** |
627 /** |
|
628 * Gets the commands array. |
|
629 * |
|
630 * @return the commands |
|
631 */ |
|
632 Vector getCommands() |
|
633 { |
|
634 return commands; |
|
635 } |
|
636 |
|
637 /** |
|
638 * Gets the command listener. |
|
639 * |
|
640 * @return the eswt command listener. |
|
641 */ |
|
642 final EswtCommandListener getCommandListener() |
|
643 { |
|
644 return eswtCommandListener; |
|
645 } |
|
646 |
|
647 /** |
623 * Gets width. |
648 * Gets width. |
624 * |
649 * |
625 * @return Width of the Displayable in pixels. |
650 * @return Width of the Displayable in pixels. |
626 */ |
651 */ |
627 public int getWidth() |
652 public int getWidth() |
688 eswtUpdateSizes(); |
713 eswtUpdateSizes(); |
689 } |
714 } |
690 }); |
715 }); |
691 if(ticker != null) |
716 if(ticker != null) |
692 { |
717 { |
693 // Start to scroll the ticker. Ticker may be already running |
718 if(isLcduiVisible) |
694 // if it exists in some other displayable already, but |
719 { |
695 // calling this again wont do any harm: |
720 // Start to scroll the ticker. Ticker may be already running |
696 ticker.start(); |
721 // if it exists in some other displayable already, but |
|
722 // calling this again wont do any harm: |
|
723 ticker.start(); |
|
724 } |
697 } |
725 } |
698 } |
726 } |
699 |
727 |
700 /** |
728 /** |
701 * Gets current ticker. |
729 * Gets current ticker. |
744 } |
772 } |
745 |
773 |
746 /** |
774 /** |
747 * Creates singleton Label instance used by Ticker. |
775 * Creates singleton Label instance used by Ticker. |
748 */ |
776 */ |
749 private Label getTickerLabel() |
777 Label getTickerLabel() |
750 { |
778 { |
751 if(tickerLabel == null) |
779 if(tickerLabel == null) |
752 { |
780 { |
753 ESWTUIThreadRunner.syncExec(new Runnable() |
781 ESWTUIThreadRunner.syncExec(new Runnable() |
754 { |
782 { |
857 class EswtShellListener implements ShellListener |
885 class EswtShellListener implements ShellListener |
858 { |
886 { |
859 |
887 |
860 public void shellActivated(ShellEvent e) |
888 public void shellActivated(ShellEvent e) |
861 { |
889 { |
862 if(!isShellActive) |
|
863 { |
|
864 handleShellActivatedEvent(); |
|
865 } |
|
866 } |
|
867 |
|
868 public void shellDeactivated(ShellEvent e) |
|
869 { |
|
870 ESWTUIThreadRunner.getInstance().getDisplay() |
890 ESWTUIThreadRunner.getInstance().getDisplay() |
871 .asyncExec(new Runnable() |
891 .asyncExec(new Runnable() |
872 { |
892 { |
873 public void run() |
893 public void run() |
874 { |
894 { |
|
895 handleShellActivatedEvent(); |
|
896 } |
|
897 }); |
|
898 } |
|
899 |
|
900 public void shellDeactivated(ShellEvent e) |
|
901 { |
|
902 ESWTUIThreadRunner.getInstance().getDisplay() |
|
903 .asyncExec(new Runnable() |
|
904 { |
|
905 public void run() |
|
906 { |
875 handleShellDeActivatedEvent(); |
907 handleShellDeActivatedEvent(); |
876 } |
908 } |
877 }); |
909 }); |
878 |
910 |
879 } |
911 } |
905 * Displayable must listen resize-events to be able to call |
937 * Displayable must listen resize-events to be able to call |
906 * sizeChanged()-method at the right time. |
938 * sizeChanged()-method at the right time. |
907 */ |
939 */ |
908 class EswtControlListener implements ControlListener |
940 class EswtControlListener implements ControlListener |
909 { |
941 { |
|
942 |
910 public void controlResized(ControlEvent e) |
943 public void controlResized(ControlEvent e) |
911 { |
944 { |
912 eswtUpdateSizes(); |
945 eswtUpdateSizes(); |
913 } |
946 } |
914 |
947 |