Search in sources :

Example 1 with DefaultLookAndFeel

use of com.codename1.ui.plaf.DefaultLookAndFeel in project CodenameOne by codenameone.

the class BlackBerryImplementation method installNativeTheme.

/**
 * Installs the native theme, this is only applicable if hasNativeTheme() returned true. Notice that this method
 * might replace the DefaultLookAndFeel instance and the default transitions.
 */
public void installNativeTheme() {
    if (nativeThemeAvailable) {
        try {
            InputStream is = getResourceAsStream(getClass(), "/blackberry_theme.res");
            Resources r = Resources.open(is);
            UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
            is.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
Also used : BufferedInputStream(com.codename1.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) InputStream(java.io.InputStream) Resources(com.codename1.ui.util.Resources) IOException(java.io.IOException)

Example 2 with DefaultLookAndFeel

use of com.codename1.ui.plaf.DefaultLookAndFeel in project CodenameOne by codenameone.

the class IOSImplementation method installNativeTheme.

/**
 * Installs the native theme, this is only applicable if hasNativeTheme() returned true. Notice that this method
 * might replace the DefaultLookAndFeel instance and the default transitions.
 */
public void installNativeTheme() {
    try {
        Resources r;
        if (iosMode.equals("modern")) {
            r = Resources.open("/iOS7Theme.res");
            Hashtable tp = r.getTheme(r.getThemeResourceNames()[0]);
            if (!nativeInstance.isIOS7()) {
                tp.put("TitleArea.padding", "0,0,0,0");
            }
            UIManager.getInstance().setThemeProps(tp);
            return;
        }
        if (iosMode.equals("auto")) {
            if (nativeInstance.isIOS7()) {
                r = Resources.open("/iOS7Theme.res");
            } else {
                r = Resources.open("/iPhoneTheme.res");
            }
            UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
            return;
        }
        r = Resources.open("/iPhoneTheme.res");
        UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
Also used : Hashtable(java.util.Hashtable) Resources(com.codename1.ui.util.Resources) IOException(java.io.IOException)

Example 3 with DefaultLookAndFeel

use of com.codename1.ui.plaf.DefaultLookAndFeel in project CodenameOne by codenameone.

the class Label method initComponentImpl.

/**
 * {@inheritDoc}
 */
void initComponentImpl() {
    super.initComponentImpl();
    UIManager manager = getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    if (hasFocus()) {
        if (lf instanceof DefaultLookAndFeel) {
            ((DefaultLookAndFeel) lf).focusGained(this);
        }
    }
    // into the container
    if (isTickerEnabled() && isTickerRunning() && !isCellRenderer()) {
        getComponentForm().registerAnimatedInternal(this);
    }
    checkAnimation();
    if (maskName != null && mask == null) {
        setMask(UIManager.getInstance().getThemeMaskConstant(maskName));
    }
    if (getIcon() != null) {
        getIcon().lock();
    }
}
Also used : DefaultLookAndFeel(com.codename1.ui.plaf.DefaultLookAndFeel) UIManager(com.codename1.ui.plaf.UIManager) LookAndFeel(com.codename1.ui.plaf.LookAndFeel) DefaultLookAndFeel(com.codename1.ui.plaf.DefaultLookAndFeel)

Example 4 with DefaultLookAndFeel

use of com.codename1.ui.plaf.DefaultLookAndFeel in project CodenameOne by codenameone.

the class AndroidImplementation method installNativeTheme.

/**
 * Installs the native theme, this is only applicable if hasNativeTheme()
 * returned true. Notice that this method might replace the
 * DefaultLookAndFeel instance and the default transitions.
 */
public void installNativeTheme() {
    hasNativeTheme();
    if (nativeThemeAvailable) {
        try {
            InputStream is;
            if (android.os.Build.VERSION.SDK_INT < 14 && !isTablet() || Display.getInstance().getProperty("and.hololight", "false").equals("true")) {
                is = getResourceAsStream(getClass(), "/androidTheme.res");
            } else {
                is = getResourceAsStream(getClass(), "/android_holo_light.res");
            }
            Resources r = Resources.open(is);
            Hashtable h = r.getTheme(r.getThemeResourceNames()[0]);
            h.put("@commandBehavior", "Native");
            UIManager.getInstance().setThemeProps(h);
            is.close();
            Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
Also used : BufferedInputStream(com.codename1.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Hashtable(java.util.Hashtable) Resources(com.codename1.ui.util.Resources) IOException(java.io.IOException)

Aggregations

Resources (com.codename1.ui.util.Resources)3 IOException (java.io.IOException)3 BufferedInputStream (com.codename1.io.BufferedInputStream)2 InputStream (java.io.InputStream)2 Hashtable (java.util.Hashtable)2 DefaultLookAndFeel (com.codename1.ui.plaf.DefaultLookAndFeel)1 LookAndFeel (com.codename1.ui.plaf.LookAndFeel)1 UIManager (com.codename1.ui.plaf.UIManager)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 FileInputStream (java.io.FileInputStream)1