View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-widget Project
18  //
19  // WindowTrackPanel.java
20  // Since: May 1, 2008
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.widget.client;
26  
27  import org.utgenome.gwt.widget.client.impl.TrackPanelBase;
28  
29  import com.google.gwt.user.client.ui.FocusPanel;
30  import com.google.gwt.user.client.ui.HorizontalPanel;
31  import com.google.gwt.user.client.ui.Label;
32  import com.google.gwt.user.client.ui.ScrollPanel;
33  import com.google.gwt.user.client.ui.VerticalPanel;
34  import com.google.gwt.user.client.ui.Widget;
35  
36  /**
37   * Track panel of the window shape
38   * 
39   * 
40   * @author leo
41   * 
42   */
43  public class TrackWindowPanel extends TrackPanelBase {
44  
45  	private FrameBorder border;
46  	private ScrollPanel scrollPanel = new ScrollPanel();
47  	private FocusPanel labelFrame = new FocusPanel();
48  	private HorizontalPanel titleFrame = new HorizontalPanel();
49  	private VerticalPanel layoutPanel = new VerticalPanel();
50  	private String title;
51  	private Label titleLabel = new Label();
52  
53  	public TrackWindowPanel() {
54  		drawWidget();
55  
56  		initWidget(layoutPanel);
57  	}
58  
59  	protected void drawWidget() {
60  
61  		// track label
62  		setTrackTitle("Track");
63  		Style.fontSize(titleLabel, 11);
64  		Style.fontFamily(titleLabel, "Tahoma, Arial, Verdana");
65  		Style.set(titleLabel, "color", "white");
66  		Style.overflowHidden(titleLabel);
67  		Style.fullBlock(titleLabel);
68  		labelFrame.add(titleLabel);
69  
70  		// label frame
71  		Style.fullWidth(labelFrame);
72  		Style.cursor(labelFrame, Style.CURSOR_MOVE);
73  
74  		// title bar
75  		titleFrame.setHeight("23px");
76  		
77  		Style.fullWidth(titleFrame);
78  		Label windowLeftCorner = new Label();
79  		windowLeftCorner.setSize("9px", "23px");
80  		Style.fontSize(windowLeftCorner, 0);
81  		Style.backgroundImage(windowLeftCorner, "theme/default/tdl.gif");
82  		Style.backgroundNoRepeat(windowLeftCorner);
83  		Label windowRightCorner = new Label(); 
84  		windowRightCorner.setSize("9px", "23px");
85  		Style.fontSize(windowRightCorner, 0);
86  		Style.backgroundImage(windowRightCorner, "theme/default/tdr.gif");
87  		Style.backgroundNoRepeat(windowRightCorner);
88  		
89  
90  		HorizontalPanel titleBarFrame = new HorizontalPanel();
91  		titleBarFrame.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
92  		titleBarFrame.setHeight("23px");
93  		titleBarFrame.add(labelFrame);
94  		titleBarFrame.setCellWidth(labelFrame, "100%");
95  		titleBarFrame.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
96  		titleBarFrame.add(getIconSetPanel());
97  		Style.fullWidth(titleBarFrame);
98  		Style.backgroundImage(titleBarFrame, "theme/default/td.gif");
99  		Style.backgroundRepeatX(titleBarFrame);
100 		Style.backgroundColor(titleBarFrame, "EEEEEE");
101 
102 
103 		titleFrame.add(windowLeftCorner);
104 		titleFrame.add(titleBarFrame);
105 		titleFrame.setCellWidth(titleBarFrame, "100%");
106 		titleFrame.add(windowRightCorner);
107 
108 		
109 		VerticalPanel borderContent = new VerticalPanel();
110 		//Style.fullSize(borderContent);
111 		
112 		// whole window
113 		Style.fullSize(layoutPanel);
114 		layoutPanel.setVerticalAlignment(VerticalPanel.ALIGN_TOP);
115 		layoutPanel.add(titleFrame);
116 
117 		// scroll panel
118 		borderContent.add(scrollPanel);
119 		//borderContent.setCellHeight(scrollPanel, "100%");
120 		//borderContent.setCellWidth(scrollPanel, "100%");
121 
122 		// resize bar
123 		HorizontalPanel hp = new HorizontalPanel();
124 		Style.fullWidth(hp);
125 		//Style.backgroundColor(hp, "D0F0F0");
126 		Style.backgroundColor(hp, "E0E0E0");
127 		hp.setHeight("16px");
128 		hp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
129 		hp.add(getResizeButton());
130 		borderContent.add(hp);
131 
132 		// window border
133 		border = new FrameBorder(2, FrameBorder.EAST | FrameBorder.SOUTH | FrameBorder.WEST);
134 		Style.fullWidth(border);
135 		border.setWidget(borderContent);
136 		layoutPanel.add(border);
137 		
138 		// set default widget height
139 		setWidth(200);
140 		setHeight(100);
141 	}
142 
143 	public void setWidth(int pixelWidth) {
144 		if (pixelWidth >= 0) {
145 			layoutPanel.setWidth(pixelWidth + "px");
146 			scrollPanel.setWidth(pixelWidth - 4 + "px");
147 		}
148 	}
149 
150 	public void setHeight(int pixelHeight) {
151 		if (pixelHeight >= 41) {
152 			layoutPanel.setWidth(pixelHeight + "px");
153 			border.setHeight(pixelHeight - 23 + "px");
154 			scrollPanel.setHeight(pixelHeight - 41 + "px");
155 		}
156 	}
157 
158 	public void addTrackButtonListener(TrackButtonListener listener) {
159 		iconSet.addTrackButtonListener(listener);
160 	}
161 
162 	public Widget getDraggableWidget() {
163 		return labelFrame;
164 	}
165 
166 	public String getTrackTitle() {
167 		return title;
168 	}
169 
170 	public void setTrackTitle(String title) {
171 		this.title = title;
172 		titleLabel.setText(title);
173 		titleLabel.setTitle(title);
174 	}
175 
176 	public void setTrackContent(Widget w) {
177 		scrollPanel.setWidget(w);
178 	}
179 
180 }