1 16 package com.google.gwt.sample.mail.client; 17 18 import com.google.gwt.core.client.EntryPoint; 19 import com.google.gwt.core.client.GWT; 20 import com.google.gwt.user.client.Command; 21 import com.google.gwt.user.client.DeferredCommand; 22 import com.google.gwt.user.client.Window; 23 import com.google.gwt.user.client.WindowResizeListener; 24 import com.google.gwt.user.client.ui.DockPanel; 25 import com.google.gwt.user.client.ui.RootPanel; 26 import com.google.gwt.user.client.ui.VerticalPanel; 27 28 33 public class Mail implements EntryPoint, WindowResizeListener { 34 35 private static Mail singleton; 36 37 41 private static final Images images = (Images) GWT.create(Images.class); 42 43 47 public interface Images extends Shortcuts.Images, TopPanel.Images { 48 } 49 50 53 public static Mail get() { 54 return singleton; 55 } 56 57 private TopPanel topPanel = new TopPanel(images); 58 private VerticalPanel rightPanel = new VerticalPanel(); 59 private MailList mailList; 60 private MailDetail mailDetail = new MailDetail(); 61 private Shortcuts shortcuts = new Shortcuts(images); 62 63 68 public void displayItem(MailItem item) { 69 mailDetail.setItem(item); 70 } 71 72 76 public void onModuleLoad() { 77 singleton = this; 78 79 topPanel.setWidth("100%"); 80 81 mailList = new MailList(); 84 mailList.setWidth("100%"); 85 86 rightPanel.add(mailList); 88 rightPanel.add(mailDetail); 89 mailList.setWidth("100%"); 90 mailDetail.setWidth("100%"); 91 92 DockPanel outer = new DockPanel(); 95 outer.add(topPanel, DockPanel.NORTH); 96 outer.add(shortcuts, DockPanel.WEST); 97 outer.add(rightPanel, DockPanel.CENTER); 98 outer.setWidth("100%"); 99 100 outer.setSpacing(4); 101 outer.setCellWidth(rightPanel, "100%"); 102 103 Window.addWindowResizeListener(this); 105 106 Window.enableScrolling(false); 109 Window.setMargin("0px"); 110 111 RootPanel.get().add(outer); 114 115 DeferredCommand.addCommand(new Command() { 119 public void execute() { 120 onWindowResized(Window.getClientWidth(), Window.getClientHeight()); 121 } 122 }); 123 124 onWindowResized(Window.getClientWidth(), Window.getClientHeight()); 125 } 126 127 public void onWindowResized(int width, int height) { 128 int shortcutHeight = height - shortcuts.getAbsoluteTop() - 8; 131 if (shortcutHeight < 1) { 132 shortcutHeight = 1; 133 } 134 shortcuts.setHeight("" + shortcutHeight); 135 136 mailDetail.adjustSize(width, height); 138 } 139 } 140 | Popular Tags |