View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 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-core Project
18  //
19  // WindowTitleBar.java
20  // Since: 2007/11/28
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.ui;
26  
27  import org.utgenome.gwt.widget.client.Style;
28  
29  import com.google.gwt.core.client.GWT;
30  import com.google.gwt.user.client.ui.Composite;
31  import com.google.gwt.user.client.ui.FlexTable;
32  import com.google.gwt.user.client.ui.Label;
33  import com.google.gwt.user.client.ui.VerticalPanel;
34  
35  public class WindowTitleBar extends Composite {
36  
37  	public final FlexTable layoutFrame = new FlexTable();
38  	public final Label leftCorner = new Label();
39  	public final FlexTable titleBar = new FlexTable();
40  	public final Label title = new Label("Title");
41  	public final Label rightCorner = new Label();
42  
43  	public WindowTitleBar() {
44  
45  		setupWidget();
46  		initWidget(layoutFrame);
47  	}
48  
49  	protected void setupWidget() {
50  		// layout widgets
51  		layoutFrame.clear();
52  		layoutFrame.setWidget(0, 0, leftCorner);
53  		layoutFrame.setWidget(0, 1, titleBar);
54  		layoutFrame.setWidget(0, 2, rightCorner);
55  
56  		// layout frame design
57  		layoutFrame.setCellPadding(0);
58  		layoutFrame.setCellSpacing(0);
59  		layoutFrame.getCellFormatter().setWidth(0, 1, "100%");
60  		layoutFrame.setHeight("100%");
61  
62  		// title bar
63  		titleBar.setCellPadding(0);
64  		titleBar.setCellSpacing(0);
65  		titleBar.setWidth("100%");
66  		titleBar.setHeight("23px");
67  		titleBar.setWidget(0, 0, title);
68  		titleBar.getRowFormatter().setVerticalAlign(0, VerticalPanel.ALIGN_MIDDLE);
69  		titleBar.getCellFormatter().setWidth(0, 0, "100%");
70  		Style.cursor(title, Style.CURSOR_MOVE);
71  
72  		// CSS 
73  		leftCorner.setPixelSize(9, 23);
74  		rightCorner.setPixelSize(9, 23);
75  		Style.fontSize(leftCorner, 0);
76  		Style.fontSize(rightCorner, 0);
77  		Style.fontSize(title, 12);
78  		Style.nowrap(title);
79  		Style.backgroundImage(leftCorner, GWT.getModuleBaseURL() + "theme/mac/tl.gif");
80  		Style.backgroundImage(titleBar, GWT.getModuleBaseURL() + "theme/mac/t.gif");
81  		Style.backgroundImage(rightCorner, GWT.getModuleBaseURL() + "theme/mac/tr.gif");
82  		Style.backgroundNoRepeat(leftCorner);
83  		Style.backgroundNoRepeat(rightCorner);
84  	}
85  
86  }