Java Code Examples for com.codename1.ui.plaf.UIManager#getLookAndFeel()

The following examples show how to use com.codename1.ui.plaf.UIManager#getLookAndFeel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Form.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void initLaf(UIManager uim) {
    super.initLaf(uim);
    LookAndFeel laf = uim.getLookAndFeel();
    transitionOutAnimator = laf.getDefaultFormTransitionOut();
    transitionInAnimator = laf.getDefaultFormTransitionIn();
    focusScrolling = laf.isFocusScrolling();
    if (menuBar == null || !menuBar.getClass().equals(laf.getMenuBarClass())) {
        try {
            menuBar = (MenuBar) laf.getMenuBarClass().newInstance();
        } catch (Exception ex) {
            Log.e(ex);
            menuBar = new MenuBar();
        }
        menuBar.initMenuBar(this);
    }

    tintColor = laf.getDefaultFormTintColor();
    tactileTouchDuration = laf.getTactileTouchDuration();
}
 
Example 2
Source File: Container.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 
 * {@inheritDoc}
 */
protected void initLaf(UIManager uim) {
    if(uim == getUIManager() && isInitialized()){
        return;
    }
    super.initLaf(uim);
    LookAndFeel laf = uim.getLookAndFeel();
    setSmoothScrolling(laf.isDefaultSmoothScrolling());
    if(components != null){
        int count = getComponentCount();
        for (int i = 0; i < count; i++) {
            Component c = getComponentAt(i);
            c.initLaf(uim);
        }
    }

}
 
Example 3
Source File: Label.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
void initComponentImpl() {
    super.initComponentImpl();
    UIManager manager = getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    if(hasFocus()) {
        if(lf instanceof DefaultLookAndFeel) {
            ((DefaultLookAndFeel)lf).focusGained(this);
        }
    }
    // solves the case of a user starting a ticker before adding the component
    // 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();
    }
}
 
Example 4
Source File: TextArea.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void initLaf(UIManager uim) {
    super.initLaf(uim);
    setSelectCommandText(uim.localize("edit", "Edit"));
    LookAndFeel laf = uim.getLookAndFeel();
    setSmoothScrolling(laf.isDefaultSmoothScrolling());
}
 
Example 5
Source File: Toolbar.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
protected Command showOverflowMenu(Dialog menu) {
    Form parent = sideMenu.getParentForm();
    int height;
    int marginLeft;
    int marginRight = 0;
    Container dialogContentPane = menu.getDialogComponent();
    marginLeft = parent.getWidth() - (dialogContentPane.getPreferredW()
            + menu.getStyle().getHorizontalPadding());
    marginLeft = Math.max(0, marginLeft);
    if (parent.getSoftButtonCount() > 1) {
        height = parent.getHeight() - parent.getSoftButton(0).getParent().getPreferredH() - dialogContentPane.getPreferredH();
    } else {
        height = parent.getHeight() - dialogContentPane.getPreferredH();
    }
    height = Math.max(0, height);
    int th = getHeight();
    Transition transitionIn;
    Transition transitionOut;
    UIManager manager = parent.getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    if (lf.getDefaultMenuTransitionIn() != null || lf.getDefaultMenuTransitionOut() != null) {
        transitionIn = lf.getDefaultMenuTransitionIn();
        if (transitionIn instanceof BubbleTransition) {
            ((BubbleTransition) transitionIn).setComponentName("OverflowButton");
        }
        transitionOut = lf.getDefaultMenuTransitionOut();
    } else {
        transitionIn = CommonTransitions.createEmpty();
        transitionOut = CommonTransitions.createEmpty();
    }
    menu.setTransitionInAnimator(transitionIn);
    menu.setTransitionOutAnimator(transitionOut);

    if (isRTL()) {
        marginRight = marginLeft;
        marginLeft = 0;
    }
    int tint = parent.getTintColor();
    parent.setTintColor(0x00FFFFFF);
    parent.tint = false;
    boolean showBelowTitle = manager.isThemeConstant("showMenuBelowTitleBool", true);
    int topPadding = 0;
    Component statusBar = ((BorderLayout) getLayout()).getNorth();
    if (statusBar != null) {
        topPadding = statusBar.getAbsoluteY() + statusBar.getHeight();
    }
    if (showBelowTitle) {
        topPadding = th;
    }

    Command r = menu.show(topPadding, Math.max(topPadding, height - topPadding), marginLeft, marginRight, true);
    parent.setTintColor(tint);
    return r;
}
 
Example 6
Source File: MenuBar.java    From CodenameOne with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Factory method that returns the Form Menu select Command.
 * This method can be overridden to customize the Command on the Form.
 * 
 * @return Command
 */
protected Command createMenuSelectCommand() {
    UIManager manager = parent.getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    return new Command(manager.localize("select", "Select"), lf.getMenuIcons()[0]);
}
 
Example 7
Source File: MenuBar.java    From CodenameOne with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Factory method that returns the Form Menu cancel Command.
 * This method can be overridden to customize the Command on the Form.
 * 
 * @return Command
 */
protected Command createMenuCancelCommand() {
    UIManager manager = parent.getUIManager();
    LookAndFeel lf = manager.getLookAndFeel();
    return new Command(manager.localize("cancel", "Cancel"), lf.getMenuIcons()[1]);
}