List of usage examples for com.google.gwt.dom.client Style setPadding
public void setPadding(double value, Unit unit)
From source file:com.alkacon.geranium.client.util.DebugLog.java
License:Open Source License
/** * Constructor.<p>//from w w w . j a v a 2 s . com */ @SuppressWarnings("unused") private DebugLog() { if (!DEBUG) { return; } m_html = new HTML(); initWidget(m_html); Style style = getElement().getStyle(); style.setWidth(200, Unit.PX); style.setHeight(500, Unit.PX); style.setPadding(10, Unit.PX); style.setOverflow(Overflow.AUTO); style.setBorderStyle(BorderStyle.SOLID); style.setBorderColor(I_LayoutBundle.INSTANCE.constants().css().borderColor()); style.setBorderWidth(1, Unit.PX); style.setPosition(Position.FIXED); style.setTop(50, Unit.PX); style.setRight(50, Unit.PX); style.setBackgroundColor(I_LayoutBundle.INSTANCE.constants().css().backgroundColorDialog()); style.setZIndex(10); }
From source file:com.bearsoft.gwt.ui.widgets.DecoratorBox.java
public void setWidget(HasValue<T> w) { if (decorated != w) { if (changeValueHandler != null) { changeValueHandler.removeHandler(); }/*from ww w .j a v a2 s. c o m*/ if (keyDownHandler != null) keyDownHandler.removeHandler(); if (keyUpHandler != null) keyUpHandler.removeHandler(); if (keyPressHandler != null) keyPressHandler.removeHandler(); if (focusHandler != null) focusHandler.removeHandler(); if (blurHandler != null) blurHandler.removeHandler(); if (decorated instanceof Widget) { ((Widget) decorated).removeFromParent(); } decorated = w; if (decorated != null) { changeValueHandler = decorated.addValueChangeHandler(new ValueChangeHandler<T>() { @Override public void onValueChange(ValueChangeEvent<T> event) { fireValueChangeEvent(); } }); if (decorated instanceof Widget) { CommonResources.INSTANCE.commons().ensureInjected(); ((Widget) decorated).getElement() .addClassName(CommonResources.INSTANCE.commons().borderSized()); Style style = ((Widget) decorated).getElement().getStyle(); style.setBorderWidth(0, Style.Unit.PX); style.setPadding(0, Style.Unit.PX); style.setMargin(0, Style.Unit.PX); style.setPosition(Style.Position.ABSOLUTE); style.setDisplay(Style.Display.INLINE_BLOCK); style.setLeft(0, Style.Unit.PX); style.setTop(0, Style.Unit.PX); style.setHeight(100, Style.Unit.PCT); style.setWidth(100, Style.Unit.PCT); style.setOutlineStyle(Style.OutlineStyle.NONE); style.setBackgroundColor("inherit"); style.setColor("inherit"); contentWrapper.setWidget((Widget) decorated); } if (decorated instanceof HasKeyDownHandlers) { keyDownHandler = ((HasKeyDownHandlers) decorated).addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { KeyDownEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasKeyUpHandlers) { keyUpHandler = ((HasKeyUpHandlers) decorated).addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { KeyUpEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasKeyPressHandlers) { keyPressHandler = ((HasKeyPressHandlers) decorated).addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { KeyPressEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasFocusHandlers) { focusHandler = ((HasFocusHandlers) decorated).addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { DecoratorBox.this.getElement().addClassName(DECORATOR_FOCUSED_CLASS_NAME); FocusEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasBlurHandlers) { blurHandler = ((HasBlurHandlers) decorated).addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { DecoratorBox.this.getElement().removeClassName(DECORATOR_FOCUSED_CLASS_NAME); BlurEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } } } }
From source file:com.googlecode.gwtquake.client.GwtQuake.java
License:Open Source License
public void onModuleLoad() { // Initialize drivers. Document doc = Document.get(); doc.setTitle("GWT Quake II"); BodyElement body = doc.getBody();/*from ww w . ja v a 2s . c om*/ Style style = body.getStyle(); style.setPadding(0, Unit.PX); style.setMargin(0, Unit.PX); style.setBorderWidth(0, Unit.PX); style.setProperty("height", "100%"); style.setBackgroundColor("#000"); style.setColor("#888"); // Window.alert("UA: " + userAgent+ " type: " + browserType); boolean wireframe = ("" + Window.Location.getHash()).indexOf("wireframe") != -1; canvas = (CanvasElement) doc.createElement("canvas"); video = doc.createElement("video"); w = Window.getClientWidth(); h = Window.getClientHeight(); canvas.setWidth(w); canvas.setHeight(h); style = canvas.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style = video.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style.setProperty("display", "none"); body.appendChild(canvas); body.appendChild(video); try { Globals.autojoin.value = Window.Location.getHash().indexOf("autojoin") != -1 ? 1.0f : 0.0f; final Renderer renderer = wireframe ? new GwtWireframeGLRenderer(canvas) : new GwtWebGLRenderer(canvas, video); Globals.re = renderer; ResourceLoader.impl = new GwtResourceLoaderImpl(); Compatibility.impl = new CompatibilityImpl(); Sound.impl = new GwtSound(); NET.socketFactory = new WebSocketFactoryImpl(); // Sys.impl = new Sys.SysImpl() { // public void exit(int status) { // Window.alert("Something's rotten in Denmark"); // Window.Location.assign("gameover.html"); // } // }; // Flags. QuakeCommon.Init(new String[] { "GQuake" }); // Enable stdout. Globals.nostdout = ConsoleVariables.Get("nostdout", "0", 0); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (Window.getClientWidth() == w && Window.getClientHeight() == h) { return; } w = Window.getClientWidth(); h = Window.getClientHeight(); renderer.GLimp_SetMode(new Dimension(w, h), 0, false); } }); // QuakeServer.main(new String[0], new DummySNetImpl(), false); timer = new Timer() { double startTime = Duration.currentTimeMillis(); @Override public void run() { try { double curTime = Duration.currentTimeMillis(); boolean pumping = ResourceLoader.Pump(); if (pumping) { Screen.UpdateScreen2(); } else { int dt = (int) (curTime - startTime); GwtKBD.Frame(dt); QuakeCommon.Frame(dt); } startTime = curTime; timer.schedule(ResourceLoader.Pump() ? LOADING_DELAY : INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); } } }; timer.schedule(INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); DivElement div = doc.createDivElement(); div.setInnerHTML(NO_WEBGL_MESSAGE); body.appendChild(div); } }
From source file:com.ksyzt.gwt.client.ui.richeditor.RichTextToolbar.java
License:Open Source License
/** * Inits the popup panel./*from ww w.java 2s . com*/ */ private void initPopupPanel() { m_ap_shadow = new HTMLPanel("div", ""); m_ap_content = new HTMLPanel("div", ""); m_ap_line = new HTMLPanel("div", ""); Style style = m_ap_content.getElement().getStyle(); style.setProperty("border", "solid 1px skyblue"); style.setBackgroundColor("white"); style.setPadding(5, Unit.PX); style.setPosition(Position.ABSOLUTE); style.setZIndex(1000000); style = m_ap_shadow.getElement().getStyle(); style.setBackgroundColor("#f0f0f0"); style.setPosition(Position.ABSOLUTE); style.setZIndex(999999); m_ap_line.setHeight("1px"); style = m_ap_line.getElement().getStyle(); style.setBackgroundColor("white"); style.setPosition(Position.ABSOLUTE); style.setZIndex(1000001); RootPanel.get().add(m_ap_shadow); RootPanel.get().add(m_ap_content); RootPanel.get().add(m_ap_line); m_ap_content.setVisible(false); m_ap_shadow.setVisible(false); m_ap_line.setVisible(false); }
From source file:com.sciencegadgets.client.algebra.edit.LinkPrompt_Equation.java
License:Open Source License
public LinkPrompt_Equation(final AlgebraActivity algebraActivity, EquationTree initialEquation) { super();//from w ww .ja va 2s .c o m this.initialEquation = initialEquation; this.algebraActivity = algebraActivity; // params.add(easyToggle); if (initialEquation == null) { LinkedList<EquationNode> variables = algebraActivity.getEquationTree() .getNodesByType(TypeSGET.Variable); int varCount = variables.size(); if (varCount == 0) { Window.alert("You should consider adding a variable in the equation"); } else { // final Button solveGoalButton = new Button("Solve Goal", // new ClickHandler() { // @Override // public void onClick(ClickEvent arg0) { // LinkPrompt_Equation.this.disappear(); // Moderator.switchToAlgebra( // algebraActivity.getEquationTree(), // ActivityType.editsolvegoal, true); // } // }); // solveGoalButton // .setTitle("Faster and more accurate but can't use with random numbers"); // solveGoalButton.addStyleName(CSS.CREATE_GOAL_BUTTON); // solveGoalButton.addStyleName(CSS.BORDER_RADIUS_SMALL); // upperArea.add(solveGoalButton); // // final Button createGoalButton = new Button("Edit Goal", // new ClickHandler() { // @Override // public void onClick(ClickEvent arg0) { // LinkPrompt_Equation.this.disappear(); // Moderator.switchToAlgebra( // algebraActivity.getEquationTree(), // ActivityType.editcreategoal, true); // } // }); // createGoalButton // .setTitle("Can use with random numbers but prone to error!"); // createGoalButton.addStyleName(CSS.CREATE_GOAL_BUTTON); // createGoalButton.addStyleName(CSS.BORDER_RADIUS_SMALL); // upperArea.add(createGoalButton); } Unit[] units = Unit.values(); ArrayList<String> unitStrings = new ArrayList<String>(); for (Unit u : units) { unitStrings.add(u.toString()); } widthUnits.setAcceptableValues(unitStrings); heightUnits.setAcceptableValues(unitStrings); SpecChangeHandler specChange = new SpecChangeHandler(); KeyUpToSpecChange keyUp = new KeyUpToSpecChange(); widthTextBox.addValueChangeHandler(specChange); widthUnits.addValueChangeHandler(specChange); heightTextBox.addValueChangeHandler(specChange); heightUnits.addValueChangeHandler(specChange); widthTextBox.addKeyUpHandler(keyUp); heightTextBox.addKeyUpHandler(keyUp); colorTextBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { setColor(colorTextBox.getValue()); } }); colorTextBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { setColor(colorTextBox.getValue()); } }); colorTextBox.getElement().setId("colorTextBox"); Element colorInput = DOM.createElement("input"); colorInput.setAttribute("type", "color"); colorInput.setAttribute("value", initialColor); colorInput.setAttribute("id", "colorInputElement"); colorInput.setAttribute("onchange", "colorTextBox.value=colorInputElement.value.replace('#', ''); colorTextBox.focus()"); Style colorInputStyle = colorInput.getStyle(); colorInputStyle.setProperty("border", "none"); colorInputStyle.setPadding(0, Unit.PX); colorInputStyle.setWidth(100, Unit.PCT); colorInputArea.getElement().appendChild(colorInput); } else { setModal(true); setAutoHideEnabled(false); upperArea.add(new Label("Goal: ")); upperArea.add(algebraActivity.getEquationTree().getDisplayClone()); addOkHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { Moderator.switchToAlgebra(algebraActivity.getEquationTree(), ActivityType.editequation, true); } }); } }
From source file:com.vaadin.client.SimpleTree.java
License:Apache License
public SimpleTree() { setElement(Document.get().createDivElement()); Style style = getElement().getStyle(); style.setProperty("whiteSpace", "nowrap"); style.setPadding(3, Unit.PX); style.setPaddingLeft(12, Unit.PX);//from ww w .j av a 2 s . c o m // handle styling style = handle.getStyle(); style.setDisplay(Display.NONE); style.setTextAlign(TextAlign.CENTER); style.setWidth(0.5, Unit.EM); style.setHeight(0.5, Unit.EM); style.setCursor(Cursor.POINTER); style.setBackgroundColor("gray"); style.setColor("white"); style.setPadding(4, Unit.PX); style.setMarginRight(3, Unit.PX); style.setLineHeight(0.5, Unit.EM); handle.setInnerHTML("+"); getElement().appendChild(handle); getElement().appendChild(text); // children styling style = children.getStyle(); style.setPaddingLeft(1.5, Unit.EM); style.setDisplay(Display.NONE); getElement().appendChild(children); addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (event.getNativeEvent().getEventTarget().cast() == handle) { if (children.getStyle().getDisplay().intern() == Display.NONE.getCssName()) { open(event.getNativeEvent().getAltKey()); } else { close(); } } else if (event.getNativeEvent().getEventTarget().cast() == text) { select(event); } } }, ClickEvent.getType()); }
From source file:com.vaadin.client.ui.VCustomLayout.java
License:Apache License
public VCustomLayout() { setElement(DOM.createDiv());//from w ww.j a v a 2s . co m // Clear any unwanted styling Style style = getElement().getStyle(); style.setBorderStyle(BorderStyle.NONE); style.setMargin(0, Unit.PX); style.setPadding(0, Unit.PX); if (BrowserInfo.get().isIE()) { style.setPosition(Position.RELATIVE); } setStyleName(CLASSNAME); }
From source file:com.vaadin.terminal.gwt.client.SimpleTree.java
License:Open Source License
public SimpleTree() { setElement(Document.get().createDivElement()); Style style = getElement().getStyle(); style.setProperty("whiteSpace", "nowrap"); style.setPadding(3, Unit.PX); style = handle.getStyle();//from w w w .j ava2s . com style.setDisplay(Display.NONE); style.setProperty("textAlign", "center"); style.setWidth(10, Unit.PX); style.setCursor(Cursor.POINTER); style.setBorderStyle(BorderStyle.SOLID); style.setBorderColor("#666"); style.setBorderWidth(1, Unit.PX); style.setMarginRight(3, Unit.PX); style.setProperty("borderRadius", "4px"); handle.setInnerHTML("+"); getElement().appendChild(handle); getElement().appendChild(text); style = children.getStyle(); style.setPaddingLeft(20, Unit.PX); style.setDisplay(Display.NONE); getElement().appendChild(children); addDomHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (event.getNativeEvent().getEventTarget().cast() == handle) { if (children.getStyle().getDisplay().intern() == Display.NONE.getCssName()) { open(event.getNativeEvent().getShiftKey()); } else { close(); } } else if (event.getNativeEvent().getEventTarget().cast() == text) { select(event); } } }, ClickEvent.getType()); }
From source file:de.bonprix.gridstacklayout.client.GridStackLayoutWidget.java
License:Open Source License
public GridStackLayoutWidget() { this.gridstackId = DOM.createUniqueId(); this.gridstackDiv = DOM.createDiv(); this.gridstackDiv.addClassName("grid-stack"); this.gridstackDiv.setId(this.gridstackId); setElement(this.gridstackDiv); // Clear any unwanted styling final Style style = getElement().getStyle(); style.setBorderStyle(BorderStyle.NONE); style.setMargin(0, Unit.PX);/*from w ww.j a v a 2 s.co m*/ style.setPadding(0, Unit.PX); if (BrowserInfo.get().isIE()) { style.setPosition(Position.RELATIVE); } setStyleName(CLASSNAME); addAttachHandler(new Handler() { @Override public void onAttachOrDetach(final AttachEvent event) { checkInit(); } }); setStackedModeWidth(60 * DEFAULT_COLUMNS); }
From source file:fr.mncc.gwttoolbox.ui.client.Indicator.java
License:Open Source License
public void setMessage(String msg, String bkgColor, String txtColor) { label_.setText(msg);//w w w .ja va 2 s. co m Style labelStyle = label_.getElement().getStyle(); labelStyle.setFontSize(1.6, Style.Unit.EM); labelStyle.setBackgroundColor(bkgColor); labelStyle.setColor(txtColor); labelStyle.setPadding(5, Style.Unit.PX); }