Search in sources :

Example 6 with LookAndFeel

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

the class Toolbar method showOverflowMenu.

/*
     * A Overflow Menu is implemented as a dialog, this method allows you to 
     * override the dialog display in order to customize the dialog menu in 
     * various ways
     * 
     * @param menu a dialog containing Overflow Menu options that can be 
     * customized
     * @return the command selected by the user in the dialog
     */
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;
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Transition(com.codename1.ui.animations.Transition) BubbleTransition(com.codename1.ui.animations.BubbleTransition) UIManager(com.codename1.ui.plaf.UIManager) LookAndFeel(com.codename1.ui.plaf.LookAndFeel) BubbleTransition(com.codename1.ui.animations.BubbleTransition)

Example 7 with LookAndFeel

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

the class Form method initLaf.

/**
 * {@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();
}
Also used : LookAndFeel(com.codename1.ui.plaf.LookAndFeel)

Example 8 with LookAndFeel

use of com.codename1.ui.plaf.LookAndFeel 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 9 with LookAndFeel

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

the class Component method initLaf.

/**
 * This method initializes the Component defaults constants
 */
protected void initLaf(UIManager uim) {
    if (uim == getUIManager() && isInitialized()) {
        return;
    }
    selectText = uim.localize("select", "Select");
    LookAndFeel laf = uim.getLookAndFeel();
    animationSpeed = laf.getDefaultSmoothScrollingSpeed();
    rtl = laf.isRTL();
    tactileTouch = isFocusable();
    tensileDragEnabled = laf.isDefaultTensileDrag();
    snapToGrid = laf.isDefaultSnapToGrid();
    alwaysTensile = laf.isDefaultAlwaysTensile();
    tensileHighlightEnabled = laf.isDefaultTensileHighlight();
    scrollOpacityChangeSpeed = laf.getFadeScrollBarSpeed();
    isScrollVisible = laf.isScrollVisible();
    if (tensileHighlightEnabled) {
        tensileLength = 3;
    } else {
        tensileLength = -1;
    }
}
Also used : LookAndFeel(com.codename1.ui.plaf.LookAndFeel)

Aggregations

LookAndFeel (com.codename1.ui.plaf.LookAndFeel)9 UIManager (com.codename1.ui.plaf.UIManager)5 BubbleTransition (com.codename1.ui.animations.BubbleTransition)1 Transition (com.codename1.ui.animations.Transition)1 BorderLayout (com.codename1.ui.layouts.BorderLayout)1 GridLayout (com.codename1.ui.layouts.GridLayout)1 DefaultLookAndFeel (com.codename1.ui.plaf.DefaultLookAndFeel)1