gtkiconfactory.java

来自「java jdk 1.4的源码」· Java 代码 · 共 447 行 · 第 1/2 页

JAVA
447
字号
    }    public static void paintRadioButtonMenuItemArrowIcon(SynthContext context,                            Graphics g, int x, int y, int w, int h) {        // Don't paint anything.  We are just reserving space so we align the        // menu items correctly.    }    public static SynthIcon getRadioButtonMenuItemCheckIcon() {        if (radioButtonMenuItemCheckIcon == null) {            radioButtonMenuItemCheckIcon = new DelegatingIcon(                "paintRadioButtonMenuItemCheckIcon", 13, 13);        }        return radioButtonMenuItemCheckIcon;    }    public static void paintRadioButtonMenuItemCheckIcon(             SynthContext context, Graphics g, int x, int y, int w, int h) {        GTKStyle style = (GTKStyle)context.getStyle();        int state = context.getComponentState();        int gtkState = GTKLookAndFeel.synthStateToGTKState(                                      context.getRegion(), state);        int shadowType = GTKConstants.SHADOW_OUT;        if ((state & SynthConstants.SELECTED) != 0) {            gtkState = SynthConstants.SELECTED;        }        if (gtkState == SynthConstants.SELECTED) {            shadowType = GTKConstants.SHADOW_IN;        }        ((GTKStyle)context.getStyle()).getEngine(                context).paintOption(context, g, gtkState, shadowType,                    "option", x, y, w, h);    }    //    // ToolBar Handle    //     public static SynthIcon getToolBarHandleIcon() {        if (toolBarHandleIcon == null) {            toolBarHandleIcon =                new ToolBarHandleIcon("paintToolBarHandleIcon");        }        return toolBarHandleIcon;    }    public static void paintToolBarHandleIcon(SynthContext context,            Graphics g, int x, int y, int w, int h) {        int orientation =            ((JToolBar)context.getComponent()).getOrientation() ==                JToolBar.HORIZONTAL ?                    GTKConstants.HORIZONTAL : GTKConstants.VERTICAL;        GTKStyle style = (GTKStyle)context.getStyle();        int gtkState = GTKLookAndFeel.synthStateToGTKState(                context.getRegion(), context.getComponentState());        style.getEngine(context).paintHandle(context, g, gtkState,                    GTKConstants.SHADOW_OUT, "handlebox", x, y, w, h,                    orientation);    }    private static class DelegatingIcon extends SynthIcon implements                                   UIResource {        private static final Class[] PARAM_TYPES = new Class[] {            SynthContext.class, Graphics.class, int.class, int.class,            int.class, int.class };        private int width;        private int height;        private Object method;        DelegatingIcon(String methodName, int width, int height) {            this.method = methodName;            this.width = width;            this.height = height;        }        public void paintIcon(SynthContext context, Graphics g, int x, int y,                              int w, int h) {            if (context != null) {                try {                    getMethod().invoke(GTKIconFactory.class, new Object[] {                                context, g, new Integer(x), new Integer(y),                                new Integer(w), new Integer(h) });                } catch (IllegalAccessException iae) {                } catch (InvocationTargetException ite) {                }            }        }        public int getIconWidth(SynthContext context) {            return width;        }        public int getIconHeight(SynthContext context) {            return height;        }        private Method getMethod() {            if (method instanceof String) {                Method[] methods = GTKIconFactory.class.getMethods();                try {                    method = GTKIconFactory.class.getMethod((String)method,                                                            PARAM_TYPES);                } catch (NoSuchMethodException nsme) {                    System.out.println("NSME: " + nsme);                }            }            return (Method)method;        }    }    private static class SynthExpanderIcon extends SynthIcon {        private static final Class[] PARAM_TYPES = new Class[] {            SynthContext.class, Graphics.class, int.class, int.class,            int.class, int.class };            private int width = -1;            private int height = -1;            private Object method;        SynthExpanderIcon(String method) {            this.method = method;        }        public void paintIcon(SynthContext context, Graphics g, int x, int y,                              int w, int h) {            if (context != null) {                try {                    getMethod().invoke(GTKIconFactory.class, new Object[] {                                context, g, new Integer(x), new Integer(y),                                new Integer(w), new Integer(h) });                } catch (IllegalAccessException iae) {                } catch (InvocationTargetException ite) {                }            }        }        public int getIconWidth(SynthContext context) {            if (width == -1) {                width = context.getStyle().getInt(context,                        "Tree.expanderSize", 10);            }            return width;        }        public int getIconHeight(SynthContext context) {            if (height == -1) {                height = context.getStyle().getInt(context,                        "Tree.expanderSize", 10);            }            return height;        }        private Method getMethod() {            if (method instanceof String) {                Method[] methods = GTKIconFactory.class.getMethods();                try {                    method = GTKIconFactory.class.getMethod((String)method,                                                            PARAM_TYPES);                } catch (NoSuchMethodException nsme) {                    System.out.println("NSME: " + nsme);                }            }            return (Method)method;        }    }    private static class ToolBarHandleIcon extends SynthIcon {        private static final Class[] PARAM_TYPES = new Class[] {            SynthContext.class, Graphics.class, int.class, int.class,            int.class, int.class };            private Object method;        ToolBarHandleIcon(String method) {            this.method = method;        }        public void paintIcon(SynthContext context, Graphics g, int x, int y,                              int w, int h) {            if (context != null) {                try {                    getMethod().invoke(GTKIconFactory.class, new Object[] {                                context, g, new Integer(x), new Integer(y),                                new Integer(w), new Integer(h) });                } catch (IllegalAccessException iae) {                } catch (InvocationTargetException ite) {                }            }        }        public int getIconWidth(SynthContext context) {            if (((JToolBar)context.getComponent()).getOrientation() ==                    JToolBar.HORIZONTAL) {                return 10;            } else {                return context.getComponent().getWidth();            }        }        public int getIconHeight(SynthContext context) {            if (((JToolBar)context.getComponent()).getOrientation() ==                    JToolBar.HORIZONTAL) {                return context.getComponent().getHeight();            } else {                return 10;            }        }        private Method getMethod() {            if (method instanceof String) {                Method[] methods = GTKIconFactory.class.getMethods();                try {                    method = GTKIconFactory.class.getMethod((String)method,                                                            PARAM_TYPES);                } catch (NoSuchMethodException nsme) {                    System.out.println("NSME: " + nsme);                }            }            return (Method)method;        }    }}

⌨️ 快捷键说明

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