lookandfeel.java.svn-base

来自「j2me设计的界面包」· SVN-BASE 代码 · 共 613 行 · 第 1/2 页

SVN-BASE
613
字号
        
        Style s = UIManager.getInstance().getComponentStyle("Scroll");

        g.setColor(s.getFgColor());
        
        int height = getHorizontalScrollHeight();
                  
        Painter p = s.getBgPainter();
        if(p != null) {
            p.paint(g, new Rectangle(x, y, width, height));
        } else {
            g.fillRect(x, y, width, height, s.getBgTransparency());
        }
        
        g.setColor(s.getBgColor());
            
        g.fillRoundRect(x + 1, y, width - 2, height, 10, 10);

        g.setColor(s.getFgColor());

        int offset = (int)(width * offsetRatio);
        int blockSize = (int)(width * blockSizeRatio);
        g.fillRoundRect(x + offset , y, blockSize , height, 10, 10);
    }
        
    
    /**
     * Sets the foreground color and font for a generic component, reuse-able by most component
     * drawing code
     */
    public void  setFG(Graphics g, Component c) {
        Style s = c.getStyle();
        g.setFont(s.getFont());
        if(c.isEnabled()) {
            if(c.hasFocus() && c.isFocusPainted()){
                g.setColor(s.getFgSelectionColor());
            }else{
                g.setColor(s.getFgColor());
            }
        } else {
            g.setColor(disableColor);
        }
    }
    
    /**
     * Returns the default width of a vertical scroll bar
     * 
     * @return default width of a vertical scroll bar
     */
    public int getVerticalScrollWidth() {
        Style s = UIManager.getInstance().getComponentStyle("Scroll");
        return s.getMargin(Component.LEFT) + s.getMargin(Component.RIGHT) + 
            s.getPadding(Component.LEFT) + s.getPadding(Component.RIGHT);
    }

    /**
     * Returns the default height of a horizontal scroll bar
     * 
     * @return default height of a horizontal scroll bar
     */
    public int getHorizontalScrollHeight() {
        Style s = UIManager.getInstance().getComponentStyle("Scroll");
        return s.getMargin(Component.TOP) + s.getMargin(Component.BOTTOM) + 
            s.getPadding(Component.TOP) + s.getPadding(Component.BOTTOM);
    }

    /**
     * Draws generic component border
     * 
     * @deprecated replaced by the Border class
     */
    public void drawBorder(Graphics g, Component c, int color, int borderWidth) {
        drawBorder(g, c, color, color, borderWidth);
    }
    
    /**
     * Draws generic component border
     * 
     * @deprecated replaced by the Border class
     */
    public void drawBorder(Graphics g, Component c, int topAndRightColor, int bottomAndLeftColor, int borderWidth) {
        g.setColor(topAndRightColor);     //Text Component upper border color
        g.fillRect(c.getX(), c.getY(), c.getWidth(),borderWidth);
        g.fillRect(c.getX(), c.getY(), borderWidth, c.getHeight());
        g.setColor(bottomAndLeftColor);     //Text Component lower border color
        g.fillRect(c.getX(), c.getY() + c.getHeight()-borderWidth, c.getWidth(), borderWidth);
        g.fillRect(c.getX() + c.getWidth()-borderWidth, c.getY() , borderWidth, c.getHeight());
    }
    
    /**
     * Draws and return the TabbedPane cell component (renderer)
     * according to each tab orientation, the borders are getting draws
     * 
     * @param tp the TabbedPane
     * @param text the cell text
     * @param icon the cell icon image
     * @param isSelected is the cell is the selected one
     * @param cellHasFocus is the cell has focus
     * @param cellStyle the cell Style object
     * @param tabbedPaneStyle the TabbedPane Style object
     * @param cellOffsetX the offset when the cell is on TOP or BOTTOM orientation
     * @param cellOffsetY the offset when the cell is on LEFT or RIGHT orientation
     * @param cellsPreferredSize the total cells PreferredSize
     * @param contentPaneSize the contentPaneSize
     * @return A TabbedPane cell component
     */
    public abstract Component getTabbedPaneCell(final TabbedPane tp,
            final String text, final Image icon, final boolean isSelected,
            final boolean cellHasFocus, final Style cellStyle,
            final Style tabbedPaneStyle, final int cellOffsetX ,
            final int cellOffsetY, final Dimension cellsPreferredSize, 
            final Dimension contentPaneSize);
    
    /**
     * Draws and return the TabbedPane contentpane painter
     * 
     * @param tp the TabbedPane
     * @param g the content pane graphics
     * @param rect the content pane painting rectangle area
     * @param cellsPreferredSize the total cells PreferredSize
     * @param numOfTabs number of tabs
     * @param selectedTabIndex the selected tab index
     * @param tabsSize the tabs size
     * @param cellOffsetX the offset when the cell is on TOP or BOTTOM orientation
     * @param cellOffsetY the offset when the cell is on LEFT or RIGHT orientation
     */
    public abstract void drawTabbedPaneContentPane(final TabbedPane tp,
                    final Graphics g, final Rectangle rect, 
                    final Dimension cellsPreferredSize, final int numOfTabs,
                    final int selectedTabIndex, final Dimension tabsSize,
                    final int cellOffsetX , final int cellOffsetY);

    /**
     * Allows us to define a default animation that will draw the transition for
     * entering a form
     */
    public Transition getDefaultFormTransitionIn() {
        return defaultFormTransitionIn;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * entering a form
     */
    public void setDefaultFormTransitionIn(Transition defaultFormTransitionIn) {
        this.defaultFormTransitionIn = defaultFormTransitionIn;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * exiting a form
     */
    public Transition getDefaultFormTransitionOut() {
        return defaultFormTransitionOut;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * exiting a form
     */
    public void setDefaultFormTransitionOut(Transition defaultFormTransitionOut) {
        this.defaultFormTransitionOut = defaultFormTransitionOut;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * entering a Menu
     */
    public Transition getDefaultMenuTransitionIn() {
        return defaultMenuTransitionIn;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * entering a Menu
     */
    public void setDefaultMenuTransitionIn(Transition defaultMenuTransitionIn) {
        this.defaultMenuTransitionIn = defaultMenuTransitionIn;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * exiting a Menu
     */
    public Transition getDefaultMenuTransitionOut() {
        return defaultMenuTransitionOut;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * exiting a Menu
     */
    public void setDefaultMenuTransitionOut(Transition defaultMenuTransitionOut) {
        this.defaultMenuTransitionOut = defaultMenuTransitionOut;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * entering a dialog
     */
    public Transition getDefaultDialogTransitionIn() {
        return defaultDialogTransitionIn;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * entering a dialog
     */
    public void setDefaultDialogTransitionIn(Transition defaultDialogTransitionIn) {
        this.defaultDialogTransitionIn = defaultDialogTransitionIn;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * exiting a dialog
     */
    public Transition getDefaultDialogTransitionOut() {
        return defaultDialogTransitionOut;
    }

    /**
     * Allows us to define a default animation that will draw the transition for
     * exiting a dialog
     */
    public void setDefaultDialogTransitionOut(Transition defaultDialogTransitionOut) {
        this.defaultDialogTransitionOut = defaultDialogTransitionOut;
    }

    /**
     * Tint color is set when a form is partially covered be it by a menu or by a 
     * dialog. A look and feel can override this default value.
     */
    public int getDefaultFormTintColor() {
        return defaultFormTintColor;
    }

    /**
     * Tint color is set when a form is partially covered be it by a menu or by a 
     * dialog. A look and feel can override this default value.
     */
    public void setDefaultFormTintColor(int defaultFormTintColor) {
        this.defaultFormTintColor = defaultFormTintColor;
    }

    /**
     * This color is used to paint disable mode text color.
     
     * @return the color value
     */
    public int getDisableColor() {
        return disableColor;
    }

    /**
     * Simple setter to diable color
     * 
     * @param disableColor the diable color value
     */
    public void setDisableColor(int disableColor) {
        this.disableColor = disableColor;
    }

    
    /**
     * Indicates whether lists and containers should have smooth scrolling by default
     */
    public boolean isDefaultSmoothScrolling() {
        return defaultSmoothScrolling;
    }

    /**
     * Indicates whether lists and containers should have smooth scrolling by default
     */
    public void setDefaultSmoothScrolling(boolean defaultSmoothScrolling) {
        this.defaultSmoothScrolling = defaultSmoothScrolling;
    }

    /**
     * Indicates the default speed for smooth scrolling
     */
    public int getDefaultSmoothScrollingSpeed() {
        return defaultSmoothScrollingSpeed;
    }

    /**
     * Indicates the default speed for smooth scrolling
     */
    public void setDefaultSmoothScrollingSpeed(int defaultSmoothScrollingSpeed) {
        this.defaultSmoothScrollingSpeed = defaultSmoothScrollingSpeed;
    }

    /**
     * Indicates whether softbuttons should be reversed from their default orientation
     */
    public boolean isReverseSoftButtons() {
        return reverseSoftButtons;
    }

    /**
     * Indicates whether softbuttons should be reversed from their default orientation
     */
    public void setReverseSoftButtons(boolean reverseSoftButtons) {
        this.reverseSoftButtons = reverseSoftButtons;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?