-IWindow themed, changes to size calculations and HTML structure.
-New Util function, isIE6.
-Small style fixes to common.css, select.css and progressindicator.css
-IFilterSelect styles changed a bit, now works more reliably with wider widths.
-ISplitPanel styles redone.
-Windowing test now only for inline window testing, new test for native windowing test -> TestForNativeWindowing.java
svn changeset:2515/svn branch:trunk
}
return false;
}-*/;
+
+ /**
+ * Detects if current browser is IE6.
+ *
+ * @return true if IE6
+ */
+ public static native boolean isIE6() /*-{
+ var browser=$wnd.navigator.appName;
+ if (browser=="Microsoft Internet Explorer") {
+ var ua = navigator.userAgent;
+ var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
+ if (re.exec(ua) != null)
+ rv = parseFloat(RegExp.$1);
+ if(rv == 6) return true;
+ }
+ return false;
+ }-*/;
/**
* Nulls oncontextmenu function on given element. We need to manually clear
public static final String CLASSNAME = "i-splitpanel";
public static final int ORIENTATION_HORIZONTAL = 0;
+
public static final int ORIENTATION_VERTICAL = 1;
private static final int MIN_SIZE = 30;
private int orientation = ORIENTATION_HORIZONTAL;
+
private Widget firstChild;
+
private Widget secondChild;
private Element wrapper = DOM.createDiv();
+
private Element firstContainer = DOM.createDiv();
+
private Element secondContainer = DOM.createDiv();
+
private Element splitter = DOM.createDiv();
private boolean resizing;
DOM.setStyleAttribute(splitter, "position", "absolute");
DOM.setStyleAttribute(secondContainer, "position", "absolute");
- DOM.setElementProperty(splitter, "className", "splitter");
DOM.setStyleAttribute(firstContainer, "overflow", "hidden");
DOM.setStyleAttribute(secondContainer, "overflow", "hidden");
DOM.setStyleAttribute(splitter, "height", "100%");
DOM.setStyleAttribute(firstContainer, "height", "100%");
DOM.setStyleAttribute(secondContainer, "height", "100%");
+ DOM.setElementProperty(splitter, "className", CLASSNAME
+ + "-hsplitter");
} else {
DOM.setStyleAttribute(splitter, "width", "100%");
DOM.setStyleAttribute(firstContainer, "width", "100%");
DOM.setStyleAttribute(secondContainer, "width", "100%");
+ DOM.setElementProperty(splitter, "className", CLASSNAME
+ + "-vsplitter");
}
}
}
public void onMouseDown(Event event) {
- if (DOM.compare(DOM.eventGetTarget(event), splitter)) {
+ Element trg = DOM.eventGetTarget(event);
+ if (DOM.compare(trg, splitter)
+ || DOM.compare(trg, DOM.getChild(splitter, 0))) {
resizing = true;
DOM.setCapture(getElement());
origX = DOM.getElementPropertyInt(splitter, "offsetLeft");
*/
public class IWindow extends PopupPanel implements Paintable, ScrollListener {
+ private static final int DEFAULT_HEIGHT = 300;
+
+ private static final int DEFAULT_WIDTH = 400;
+
private static Vector windowOrder = new Vector();
public static final String CLASSNAME = "i-window";
/** pixels used by inner borders and paddings horizontally */
- protected static final int BORDER_WIDTH_HORIZONTAL = 0;
+ protected static final int BORDER_WIDTH_HORIZONTAL = 41;
/** pixels used by headers, footers, inner borders and paddings vertically */
- protected static final int BORDER_WIDTH_VERTICAL = 22;
+ protected static final int BORDER_WIDTH_VERTICAL = 58;
private static final int STACKING_OFFSET_PIXELS = 15;
DOM.sinkEvents(closeBox, Event.ONCLICK);
DOM.sinkEvents(contents, Event.ONCLICK);
- Element wrapper = getElement();
+ Element wrapper = DOM.createDiv();
+ DOM.setElementProperty(wrapper, "className", CLASSNAME + "-wrap");
+ Element wrapper2 = DOM.createDiv();
+ DOM.setElementProperty(wrapper2, "className", CLASSNAME + "-wrap2");
DOM.sinkEvents(wrapper, Event.ONKEYDOWN);
- DOM.appendChild(wrapper, closeBox);
- DOM.appendChild(wrapper, header);
- DOM.appendChild(wrapper, contents);
- DOM.appendChild(wrapper, footer);
+ DOM.appendChild(wrapper2, closeBox);
+ DOM.appendChild(wrapper2, header);
+ DOM.appendChild(wrapper2, contents);
+ DOM.appendChild(wrapper2, footer);
+ DOM.appendChild(wrapper, wrapper2);
+ DOM.appendChild(getElement(), wrapper);
setWidget(contentPanel);
// set default size
- setWidth(400 + "px");
- setHeight(300 + "px");
+ setWidth(DEFAULT_WIDTH + "px");
+ setHeight(DEFAULT_HEIGHT + "px");
}
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
if (uidl.hasAttribute("invisible")) {
this.hide();
return;
- } else {
+ }
- // Initialize the width from UIDL
- if (uidl.hasVariable("width")) {
- String width = uidl.getStringVariable("width");
- setWidth(width);
- }
- if (uidl.hasVariable("height")) {
- String height = uidl.getStringVariable("height");
- setHeight(height);
- }
+ // Initialize the width from UIDL
+ if (uidl.hasVariable("width")) {
+ String width = uidl.getStringVariable("width");
+ setWidth(width);
+ }
+ if (uidl.hasVariable("height")) {
+ String height = uidl.getStringVariable("height");
+ setHeight(height);
+ }
- contentPanel.setScrollPosition(uidl.getIntVariable("scrolltop"));
- contentPanel.setHorizontalScrollPosition(uidl
- .getIntVariable("scrollleft"));
-
- // Initialize the position form UIDL
- try {
- int positionx = uidl.getIntVariable("positionx");
- int positiony = uidl.getIntVariable("positiony");
- if (positionx >= 0 && positiony >= 0) {
- setPopupPosition(positionx, positiony);
- }
- } catch (IllegalArgumentException e) {
- // Silently ignored as positionx and positiony are not required
- // parameters
- }
+ contentPanel.setScrollPosition(uidl.getIntVariable("scrolltop"));
+ contentPanel.setHorizontalScrollPosition(uidl
+ .getIntVariable("scrollleft"));
- if (!isAttached()) {
- show();
+ // Initialize the position form UIDL
+ try {
+ int positionx = uidl.getIntVariable("positionx");
+ int positiony = uidl.getIntVariable("positiony");
+ if (positionx >= 0 && positiony >= 0) {
+ setPopupPosition(positionx, positiony);
}
+ } catch (IllegalArgumentException e) {
+ // Silently ignored as positionx and positiony are not required
+ // parameters
}
+
+ if (!isAttached()) {
+ show();
+ }
+
UIDL childUidl = uidl.getChildUIDL(0);
Paintable lo = (Paintable) client.getWidget(childUidl);
if (layout != null) {
resizing = true;
startX = DOM.eventGetScreenX(event);
startY = DOM.eventGetScreenY(event);
- origW = getOffsetWidth();
- origH = getOffsetHeight();
+ origW = DOM.getIntStyleAttribute(getElement(), "width")
+ - BORDER_WIDTH_HORIZONTAL;
+ origH = getWidget().getOffsetHeight();
DOM.addEventPreview(this);
break;
case Event.ONMOUSEUP:
}
public void setWidth(String width) {
- super.setWidth(width);
- DOM.setStyleAttribute(header, "width", width);
+ DOM.setStyleAttribute(getElement(), "width", (Integer.parseInt(width
+ .substring(0, width.length() - 2)) + BORDER_WIDTH_HORIZONTAL)
+ + "px");
}
private void onHeaderEvent(Event event) {
*/
.i-orderedlayout {
- margin: 15px 18px;
+ padding: 15px 18px;
}
/**
background: #dfe2e4 url(img/base.gif);
height: 9px;
border: 1px solid #b6bbbc;
+ overflow: hidden; /* for IE6 */
}
.i-progressindicator div {
background: #f7f9f9 url(img/progress.png);
height: 9px;
+ overflow: hidden; /* for IE6 */
}
\ No newline at end of file
}
.i-filterselect-input {
+ width: 99%;
border: none;
background: transparent;
- width: 97%;
height: 20px;
- margin: 3px 0 0 4px;
- padding: 0;
+ margin: 0;
+ padding: 3px 0 0 4px;
font-size: 13px;
}
}
* html .i-filterselect-input {
- margin-top: 2px;
+ margin-top: -1px;
}
*+html .i-filterselect-input {
- margin-top: 1px;
+ margin-top: -1px;
}
* html .i-filterselect-button {
position: static;
- display: inline;
margin-top: -24px;
}
*+html .i-filterselect-button {
position: static;
+ margin-top: -24px;
}
\r
.i-select-optiongroup .i-select-option {\r
display: block;\r
+ white-space: nowrap;\r
}\r
\r
.i-select-select {\r
-.i-splitpanel-horizontal .splitter,
-.i-splitpanel-vertical .i-splitpanel-horizontal .splitter {
- width: 8px;
+.i-splitpanel-horizontal .i-splitpanel-hsplitter {
+ width: 6px;
+ font-size: 1px; /* for IE6 */
+}
+
+.i-splitpanel-horizontal .i-splitpanel-hsplitter div {
+ width: 6px;
+ font-size: 1px; /* for IE6 */
+ position: absolute;
+ top: 0;
+ bottom: 0;
background: #ccd2d0 url(img/bg_hor.png);
border: 1px solid #b6bbbc;
- border-top:0;
- border-bottom:0;
cursor: e-resize;
+ margin: 0 -1px;
}
-.i-splitpanel-vertical .splitter {
- height: 8px;
+.i-splitpanel-vertical .i-splitpanel-vsplitter {
+ height: 6px;
+ font-size: 1px; /* for IE6 */
+}
+
+.i-splitpanel-vertical .i-splitpanel-vsplitter div {
+ height: 6px;
+ font-size: 1px; /* for IE6 */
background: #ccd2d0 url(img/bg_ver.png);
border: 1px solid #b6bbbc;
- border-left:0;
- border-right:0;
cursor: n-resize;
+ margin: -1px 0;
+}
+
+
+
+
+
+/* IE specific styles */
+
+* html .i-splitpanel-horizontal .i-splitpanel-hsplitter div {
+ height: 99%;
+}
+
+* html .i-splitpanel-vertical .i-splitpanel-vsplitter {
+ height: 8px;
+}
+
+* html .i-splitpanel-vertical .i-splitpanel-vsplitter div {
+ margin: 0;
}
.i-window {
- border: 1px solid #999;
/* mac FF fix for scrollbar see thru */
position: absolute;
+ font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
+ color: #464f52;
+ font-size: 13px;
+ line-height: 18px;
}
+
+.i-window:before {
+ display: block;
+ content: "";
+ background: transparent url(img/top-right.png) repeat-x right top;
+ height: 21px;
+ margin-left: 21px;
+}
+
+.i-window-wrap {
+ padding-left: 20px;
+ background: transparent url(img/left-bg.png) repeat-y;
+}
+
+.i-window-wrap2 {
+ padding-right: 20px;
+ background: transparent url(img/right-bg.png) repeat-y top right;
+}
+
.i-window-header {
- background: yellow;
- height:20px;
- overflow: hidden;
+ font-size: 18px;
+ line-height: 18px;
+ font-weight: normal;
+ letter-spacing: -0.03em;
+ color: #f14c1a;
white-space: nowrap;
+ height: 18px;
+ padding: 6px 18px 14px 18px;
+ background: #fff;
+ cursor: move;
}
-.i-window-footer {
- background: #0f0;
- height:2px;
+.i-window-header:before {
+ display: block;
+ content: "";
+ width: 21px;
+ height: 21px;
+ margin: -27px 0 6px -38px;
+ background: transparent url(img/top-left.png);
}
.i-window-contents {
background: #fff;
+ border: 1px solid #babfc0;
+}
+
+.i-window-footer {
+ height: 0;
+ font-size: 0px;
+}
+
+.i-window-footer:before {
+ display: block;
+ content: "";
+ width: 21px;
+ height: 46px;
+ background: transparent url(img/bottom-left.png);
+ margin-left: -20px;
+}
+
+.i-window-footer:after {
+ display: block;
+ content: "";
+ height: 46px;
+ background: transparent url(img/bottom-right.png) no-repeat top right;
+ margin: -46px -20px 0 1px;
}
.i-window-resizebox {
position:absolute;
- bottom:0;
- right:0;
- background: black;
- width: 5px;
- height: 5px;
- float:right;
- /* IE 6 hack */
- overflow: auto;
+ bottom: -21px;
+ right: 0;
+ width: 25px;
+ height: 21px;
+ cursor: se-resize;
+ background: transparent url(img/resize.png);
}
.i-window-closebox {
position:absolute;
- top:0;
- right:0;
- background: red;
- width: 15px;
- height: 15px;
- float:right;
+ top: 33px;
+ right: 36px;
+ width: 12px;
+ height: 11px;
+ background: transparent url(img/close.png);
+ cursor: pointer;
+ overflow: hidden;
+}
+.i-window-closebox:hover {
+ background-position: 0 -11px;
+}
+
+
+
+/* IE specific styles */
+
+* html .i-window-wrap {
+ padding: 12px;
+ border: 1px solid #e8e9e9;
+ background: transparent;
+ filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../ITMILL/widgetsets/com.itmill.toolkit.terminal.gwt.DefaultWidgetSet/default/window/img/bg-color.png", sizingMethod="scale");
+ zoom: 1; /* to gain hasLayout, IE won't apply filter otherwise */
+}
+*+html .i-window-wrap {
+ padding: 12px;
+ border: 1px solid #e8e9e9;
+ background: transparent url(img/bg-color.png) repeat;
+}
+
+* html .i-window-wrap2 {
+ padding: 6px;
+ border: 1px solid #babfc0;
+ background: #fff;
+}
+*+html .i-window-wrap2 {
+ padding: 6px;
+ border: 1px solid #babfc0;
+ background: #fff;
+}
+
+* html .i-window-resizebox {
+ bottom: 0;
+ background-position: 3px 3px;
}
+*+html .i-window-resizebox {
+ bottom: 0;
+ background-position: 3px 3px;
+}
\ No newline at end of file
--- /dev/null
+package com.itmill.toolkit.tests;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+
+public class TestForNativeWindowing extends Application {
+
+ Window main = new Window("Windowing test");
+
+ public void init() {
+
+ setMainWindow(main);
+
+ main.addComponent(new Button("Add new subwindow",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window w = new Window("sw "
+ + System.currentTimeMillis());
+ main.addWindow(w);
+ w.setPositionX(100);
+ w.setPositionY(100);
+ w.setWidth(200);
+ w.setHeight(200);
+
+ w.setWidth(100);
+ w.setHeight(400);
+
+ Button closebutton = new Button("Close "
+ + w.getCaption(), new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ main.removeWindow(w);
+ }
+
+ });
+ w.addComponent(closebutton);
+
+ w.addComponent(new Label(
+ "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>"
+ + "<p>Lorem ipsum dolor sit amet.</p>",
+ Label.CONTENT_XHTML));
+
+ }
+ }));
+
+ main.addComponent(new Button(
+ "Open a currently uncreated application level window",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ try {
+ main
+ .open(
+ new com.itmill.toolkit.terminal.ExternalResource(
+ new URL(
+ getURL(),
+ "mainwin-"
+ + System
+ .currentTimeMillis()
+ + "/")),
+ null);
+ } catch (MalformedURLException e) {
+ }
+ }
+ }));
+
+ main.addComponent(new Button(
+ "Commit (saves window state: size, place, scrollpos)"));
+ }
+
+ public Window getWindow(String name) {
+
+ Window w = super.getWindow(name);
+ if (w != null)
+ return w;
+
+ if (name != null && name.startsWith("mainwin-")) {
+ String postfix = name.substring("mainwin-".length());
+ final Window ww = new Window("Window: " + postfix);
+ ww.setName(name);
+ ww.addComponent(new Label(
+ "This is a application-level window opened with name: "
+ + name));
+ ww.addComponent(new Button("Click me", new Button.ClickListener() {
+ int state = 0;
+
+ public void buttonClick(ClickEvent event) {
+ ww.addComponent(new Label("Button clicked " + (++state)
+ + " times"));
+ }
+ }));
+ addWindow(ww);
+ return ww;
+ }
+
+ return null;
+ }
+
+}
main.addComponent(c);
uploadBufferSelector = new Select("Receiver type");
+ uploadBufferSelector.setColumns(6);
uploadBufferSelector.setImmediate(true);
uploadBufferSelector.addItem("memory");
uploadBufferSelector.setValue("memory");
package com.itmill.toolkit.tests;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import com.itmill.toolkit.Application;
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.data.Property.ValueChangeListener;
import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomComponent;
import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.OptionGroup;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Select;
import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Button.ClickEvent;
-
-public class TestForWindowing extends Application {
-
- Window main = new Window("Windowing test");
-
- public void init() {
-
- setMainWindow(main);
-
- main.addComponent(new Button("Add new subwindow",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("sw "
- + System.currentTimeMillis());
- main.addWindow(w);
- w.setPositionX(100);
- w.setPositionY(100);
- w.setWidth(200);
- w.setHeight(200);
-
- w.setWidth(100);
- w.setHeight(400);
-
- Button closebutton = new Button("Close "
- + w.getCaption(), new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- main.removeWindow(w);
- }
-
- });
- w.addComponent(closebutton);
-
- w.addComponent(new Label(
- "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>"
- + "<p>Lorem ipsum dolor sit amet.</p>",
- Label.CONTENT_XHTML));
-
- }
- }));
-
- main.addComponent(new Button(
- "Open a currently uncreated application level window",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- try {
- main
- .open(
- new com.itmill.toolkit.terminal.ExternalResource(
- new URL(
- getURL(),
- "mainwin-"
- + System
- .currentTimeMillis()
- + "/")),
- null);
- } catch (MalformedURLException e) {
- }
+import com.itmill.toolkit.ui.Button.ClickListener;
+
+public class TestForWindowing extends CustomComponent {
+
+ private Select s2;
+
+ public TestForWindowing() {
+
+ OrderedLayout main = new OrderedLayout();
+
+ main.addComponent(new Label("Click the button to create a new inline window."));
+
+ Button create = new Button("Create a new window", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Window w = new Window("Testing Window");
+
+ Select s1 = new OptionGroup();
+ s1.setCaption("1. Select output format");
+ s1.addItem("Excel sheet");
+ s1.addItem("CSV plain text");
+ s1.setValue("Excel sheet");
+
+ s2 = new Select();
+ s2.addItem("Separate by comma (,)");
+ s2.addItem("Separate by colon (:)");
+ s2.addItem("Separate by semicolon (;)");
+ s2.setColumns(14);
+ s2.setEnabled(false);
+
+ s1.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ String v = (String) event.getProperty().getValue();
+ if(v.equals("CSV plain text"))
+ s2.setEnabled(true);
+ else
+ s2.setEnabled(false);
}
- }));
-
- main.addComponent(new Button(
- "Commit (saves window state: size, place, scrollpos)"));
+
+ });
+
+ w.addComponent(s1);
+ w.addComponent(s2);
+
+ getApplication().getMainWindow().addWindow(w);
+
+ }
+
+ });
+
+ main.addComponent(create);
+
+ setCompositionRoot(main);
+
}
- public Window getWindow(String name) {
-
- Window w = super.getWindow(name);
- if (w != null)
- return w;
-
- if (name != null && name.startsWith("mainwin-")) {
- String postfix = name.substring("mainwin-".length());
- final Window ww = new Window("Window: " + postfix);
- ww.setName(name);
- ww.addComponent(new Label(
- "This is a application-level window opened with name: "
- + name));
- ww.addComponent(new Button("Click me", new Button.ClickListener() {
- int state = 0;
-
- public void buttonClick(ClickEvent event) {
- ww.addComponent(new Label("Button clicked " + (++state)
- + " times"));
- }
- }));
- addWindow(ww);
- return ww;
- }
-
- return null;
- }
}