Re: Adding CSS style dynamically
try com.google.gwt.dom.client.Style class. ... Style style = yourElement.getStyle(); style.setPosition(Position.ABSOLUTE); ... -- Professor Vagner O PLANETA É O MEU PAÍS, E A CIÊNCIA É A MINHA RELIGIÃO ! INDO AO INFINITO E ALÉM... !! -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Adding CSS style dynamically
Hi, this code does not look totally wrong. However, it depend where your widgets/dom are placed in. In a LayoutPanel it would not work. In an AbsolutePanel it probably works. Stefan Bachert http://gwtworld.de On 18 Mai, 15:37, Lex tose...@gmail.com wrote: Hello. I have some odd situation where I need to add the style attributes dynamically/programmatically depending on what the saved data is. In short, instead of defining the css style definitions in the file and reference them, I need to create those per Widget, depending on the data. I tried to use DOM.setElementProperty, but it doesn't seem to work properly. It doesn't set the background or the foreground, and the absolute positioning also gets screwed up. Can anyone share your tips/insights on how I can achieve this? private void setStyle(Element dom, ScreenElement e) { DOM.setElementProperty(dom, position, absolute); DOM.setElementProperty(dom, top, e.getYpos() + px); DOM.setElementProperty(dom, left, e.getXpos() + px); DOM.setElementProperty(dom, height, e.getHeight() + px); DOM.setElementProperty(dom, width, e.getWidth() + px); DOM.setElementProperty(dom, fontSize, e.getFontSize() + pt); DOM.setElementProperty(dom, fontFamily, e.getFontFamily()); DOM.setElementProperty(dom, backgroundColor, e.getBackColor()); DOM.setElementProperty(dom, color, e.getForeColor()); if (e.isFontStyleUnderline()) { DOM.setElementProperty(dom, textDecoration, underlined); } else { DOM.setElementProperty(dom, textDecoration, normal); } if (e.isFontStyleItalic()) { DOM.setElementProperty(dom, fontStyle, italic); } else { DOM.setElementProperty(dom, fontStyle, normal); } if (e.isFontStyleBold()) { DOM.setElementProperty(dom, fontWeight, bold); } else { DOM.setElementProperty(dom, fontWeight, normal); } } -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Adding CSS style dynamically
Hello. I have some odd situation where I need to add the style attributes dynamically/programmatically depending on what the saved data is. In short, instead of defining the css style definitions in the file and reference them, I need to create those per Widget, depending on the data. I tried to use DOM.setElementProperty, but it doesn't seem to work properly. It doesn't set the background or the foreground, and the absolute positioning also gets screwed up. Can anyone share your tips/insights on how I can achieve this? private void setStyle(Element dom, ScreenElement e) { DOM.setElementProperty(dom, position, absolute); DOM.setElementProperty(dom, top, e.getYpos() + px); DOM.setElementProperty(dom, left, e.getXpos() + px); DOM.setElementProperty(dom, height, e.getHeight() + px); DOM.setElementProperty(dom, width, e.getWidth() + px); DOM.setElementProperty(dom, fontSize, e.getFontSize() + pt); DOM.setElementProperty(dom, fontFamily, e.getFontFamily()); DOM.setElementProperty(dom, backgroundColor, e.getBackColor()); DOM.setElementProperty(dom, color, e.getForeColor()); if (e.isFontStyleUnderline()) { DOM.setElementProperty(dom, textDecoration, underlined); } else { DOM.setElementProperty(dom, textDecoration, normal); } if (e.isFontStyleItalic()) { DOM.setElementProperty(dom, fontStyle, italic); } else { DOM.setElementProperty(dom, fontStyle, normal); } if (e.isFontStyleBold()) { DOM.setElementProperty(dom, fontWeight, bold); } else { DOM.setElementProperty(dom, fontWeight, normal); } } -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.