litesoft
@ HEAD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
package com.googlecode.mgwt.ui.client; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.LinkElement; import com.google.gwt.dom.client.NodeList; import com.googlecode.mgwt.ui.client.theme.MGWTTheme; import com.googlecode.mgwt.ui.client.theme.MGWTThemeBaseThemeStandardImpl; /** * The {@link MGWTStyle} class provides an easy access to the default theme of every gwt app. * * If widgets are created without a specific theme they ask MGWTStyle for the default theme. * * The default theme can be changed at start up time of an mgwt app <b>once</b>. * * After startup the bundle can not be changed. If no bundle is set, MGWTStyle creates the MGWT * Default theme. * * If you like to create your own theme consult the docs at: <a * href="http://code.google.com/p/mgwt/wiki/Styling" >http://code.google.com/p/mgwt/wiki/Styling</a> * * * @author Daniel Kurka */ public class MGWTStyle { private static MGWTTheme theme; /** * get the default bundle of this mgwt app * * @return the default bundle */ public static final MGWTTheme getTheme() { if (theme == null) { theme = new MGWTThemeBaseThemeStandardImpl(); theme.getMGWTClientBundle().getMainCss().ensureInjected(); } return theme; } /** * Set the default bundle of this mgwt app * * <p> * can only be called once at startup * <p> * * * @param newTheme the default bundle to use */ public static final void setTheme(MGWTTheme newTheme) { if (theme != null) { throw new IllegalStateException("can not change default theme if theres already an instance..."); } theme = newTheme; theme.getMGWTClientBundle().getMainCss().ensureInjected(); } /** * Inject a given css file at the end of the head * * @param url the url of the css file */ public static void injectStyleSheet(String url) { NodeList<Element> nodeList = Document.get().getElementsByTagName("head"); if (nodeList.getLength() != 1) { throw new RuntimeException("can not find head element, does your html include a head section?"); } final Element head = nodeList.getItem(0); final LinkElement linkElement = Document.get().createLinkElement(); linkElement.setRel("stylesheet"); linkElement.setType("text/css"); linkElement.setHref(url); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { head.appendChild(linkElement); } }); } /** * this routine provides access to match media from java * * @param mediaQuery the query to perform * @return true if the query matches otherwise false */ public native boolean matchMedia(String mediaQuery)/*-{ return $wnd.matchMedia(mediaQuery); }-*/; } |
Commits for litesoft/trunk/mobileGWT/mgwt/src/main/java/com/googlecode/mgwt/ui/client/MGWTStyle.java
Revision | Author | Commited | Message |
---|---|---|---|
906 Diff | GeorgeS | Fri 07 Jun, 2013 22:50:38 +0000 | Update to latest gwt-phonegap & MGWT. |
887 Diff | GeorgeS | Tue 11 Dec, 2012 02:05:08 +0000 | |
876 Diff | GeorgeS | Mon 10 Dec, 2012 03:38:59 +0000 | Updated to current Version |
740 Diff | GeorgeS | Tue 26 Jun, 2012 00:47:02 +0000 | |
681 | GeorgeS | Sun 20 May, 2012 23:24:07 +0000 |