01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.sample.showcase2.client.dd;
09:
10: import com.google.gwt.user.client.DOM;
11: import com.google.gwt.user.client.ui.HorizontalPanel;
12: import com.gwtext.client.core.EventObject;
13: import com.gwtext.client.dd.DD;
14: import com.gwtext.client.widgets.Component;
15: import com.gwtext.client.widgets.Panel;
16: import com.gwtext.client.widgets.layout.HorizontalLayout;
17: import com.gwtext.client.widgets.layout.FitLayout;
18: import com.gwtext.client.widgets.layout.TableLayout;
19: import com.gwtext.client.widgets.layout.ColumnLayout;
20: import com.gwtext.sample.showcase2.client.SampleData;
21: import com.gwtext.sample.showcase2.client.ShowcasePanel;
22:
23: public class BasicOnTopSample extends ShowcasePanel {
24:
25: public String getSourceUrl() {
26: return "source/dd/BasicOnTopSample.java.html";
27: }
28:
29: public Panel getViewPanel() {
30: if (panel == null) {
31: panel = new Panel();
32: HorizontalPanel horizontalPanel = new HorizontalPanel();
33: horizontalPanel.setSpacing(15);
34:
35: Panel panel1 = new Panel();
36: panel1.setTitle("Panel1");
37: panel1.setBorder(true);
38: panel1.setBodyStyle("background-color:#6D739A");
39: panel1.setWidth(200);
40: panel1.setHtml(SampleData.getShortBogusMarkup());
41:
42: Panel panel2 = new Panel();
43: panel2.setTitle("Panel2");
44: panel2.setBodyStyle("background-color:#566F4E");
45: panel2.setBorder(true);
46: panel2.setWidth(200);
47: panel2.setHtml(SampleData.getShortBogusMarkup());
48:
49: Panel panel3 = new Panel();
50: panel3.setTitle("Panel3");
51: panel3.setBodyStyle("background-color:#7E5B60");
52: panel3.setBorder(true);
53: panel3.setWidth(200);
54: panel3.setHtml(SampleData.getShortBogusMarkup());
55:
56: DD dd1 = new DDOnTop(panel1);
57: DD dd2 = new DDOnTop(panel2);
58: DD dd3 = new DDOnTop(panel3);
59:
60: horizontalPanel.add(panel1);
61: horizontalPanel.add(panel2);
62: horizontalPanel.add(panel3);
63:
64: panel.add(horizontalPanel);
65: }
66:
67: return panel;
68: }
69:
70: class DDOnTop extends DD {
71: private int origZ = 0;
72:
73: DDOnTop(Component component) {
74: super (component);
75: }
76:
77: public void startDrag(int x, int y) {
78: origZ = DOM.getIntStyleAttribute(this .getEl(), "zIndex");
79: DOM.setIntStyleAttribute(this .getEl(), "zIndex", 999);
80: }
81:
82: public void endDrag(EventObject e) {
83: DOM.setIntStyleAttribute(DDOnTop.this .getEl(), "zIndex",
84: origZ);
85: }
86: }
87:
88: protected boolean showEvents() {
89: return true;
90: }
91:
92: public String getIntro() {
93: return "<p>This example builds on the basic drag and drop, keeping the dragged element on top of the others by changing its z-index property during the drag.</p>";
94: }
95: }
|