gtkpainter.java
来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,426 行 · 第 1/4 页
JAVA
1,426 行
SynthConstants.DEFAULT) { engine.paintBox(context, g, SynthConstants.ENABLED, GTKConstants.SHADOW_IN, "buttondefault", x, y, w, h); } x += defaultInsets.left; y += defaultInsets.top; w -= (defaultInsets.left + defaultInsets.right); h -= (defaultInsets.top + defaultInsets.bottom); } // Render the box. if (!interiorFocus && (state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { x += totalFocusSize; y += totalFocusSize; w -= 2 * totalFocusSize; h -= 2 * totalFocusSize; } if (paintBG && (!(component.getParent() instanceof JToolBar) || gtkState != SynthConstants.ENABLED)) { int shadowType; if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) { shadowType = GTKConstants.SHADOW_IN; } else { shadowType = GTKConstants.SHADOW_OUT; } engine.paintBox(context, g, gtkState, shadowType, detail, x, y, w, h); } // focus if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED && (button == null || button.isFocusPainted())) { if (interiorFocus) { x += xThickness + focusPad; y += yThickness + focusPad; w -= 2 * (xThickness + focusPad); h -= 2 * (yThickness + focusPad); } else { x -= totalFocusSize; y -= totalFocusSize; w += 2 * totalFocusSize; h += 2 * totalFocusSize; } engine.paintFocus(context, g, gtkState, detail, x, y, w, h); } } // // ARROW_BUTTON // public void paintArrowButtonForeground(SynthContext context, Graphics g, int x, int y, int w, int h, int direction) { GTKEngine engine = getEngine(context); int state = GTKLookAndFeel.synthStateToGTKState( Region.ARROW_BUTTON, context.getComponentState()); int shadowType; if (state == SynthConstants.PRESSED) { shadowType = GTKConstants.SHADOW_IN; } else { shadowType = GTKConstants.SHADOW_OUT; } switch (direction) { case SwingConstants.NORTH: direction = GTKConstants.ARROW_UP; break; case SwingConstants.SOUTH: direction = GTKConstants.ARROW_DOWN; break; case SwingConstants.EAST: direction = GTKConstants.ARROW_RIGHT; break; case SwingConstants.WEST: direction = GTKConstants.ARROW_LEFT; break; } Component c = context.getComponent(); String name = c.getName(); String detail = "arrow"; if (name == "ScrollBar.button") { if (c.getParent() instanceof JScrollBar) { if (((JScrollBar)c.getParent()).getOrientation() == SwingConstants.HORIZONTAL) { detail = "hscrollbar"; } else { detail = "vscrollbar"; } } } else if (name == "Spinner.nextButton") { detail = "spinbutton"; } else if (name == "Spinner.previousButton") { detail = "spinbutton"; } engine.paintArrow(context, g, state, shadowType, direction, detail, x, y, w, h); } public void paintArrowButtonBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); Component c = context.getComponent(); String name = c.getName(); String detail = "button"; if (name == "ScrollBar.button") { if (c.getParent() instanceof JScrollBar) { if (((JScrollBar)c.getParent()).getOrientation() == SwingConstants.HORIZONTAL) { detail = "hscrollbar"; } else { detail = "vscrollbar"; } } } else if ("Spinner.previousButton" == name) { detail = "spinbutton_down"; } else if ("Spinner.nextButton" == name) { detail = "spinbutton_up"; } paintButtonBackground(context, engine, g, x, y, w, h, detail); } // // RADIO_BUTTON, CHECK_BUTTON // private void paintRadioButtonCheckBoxBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); if ((gtkState & SynthConstants.MOUSE_OVER) != 0) { engine.paintFlatBoxNormal(context, g, SynthConstants.MOUSE_OVER, "checkbutton", x, y, w, h); } } // // CHECK_BUTTON_MENU_ITEM // private void paintRadioButtonCheckBoxMenuItemBackground( SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) { if (GTKLookAndFeel.is2_2()) { engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_NONE, "menuitem", x, y, w, h); } else { engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_OUT, "menuitem", x, y, w, h); } } } // // LIST // public void paintListBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); int state = GTKLookAndFeel.synthStateToGTKState( Region.LIST, context.getComponentState()); if (context.getComponent().getName() == "ComboBox.list") { // Paint it's shadow. } engine.paintFlatBoxText(context, g, state, "base", x, y, w, h); } // // MENU_BAR // private Insets getMenuBarInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int internalPadding = style.getClassSpecificIntValue(context, "internal-padding", 0); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); insets.top = insets.bottom = internalPadding + yThickness; insets.left = insets.right = internalPadding + xThickness; return insets; } public void paintMenuBarBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); GTKStyle style = (GTKStyle)context.getStyle(); int shadowType = style.getClassSpecificIntValue(context, "shadow-type", GTKConstants.SHADOW_OUT); int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); engine.paintBox(context, g, gtkState, shadowType, "menubar", x, y, w, h); } // // MENU // public void paintMenuBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); if (gtkState == SynthConstants.MOUSE_OVER) { if (GTKLookAndFeel.is2_2()) { engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_NONE, "menuitem", x, y, w, h); } else { engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_OUT, "menuitem", x, y, w, h); } } } // // MENU_ITEM // private Insets getMenuItemInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int internalPadding = style.getClassSpecificIntValue(context, "internal-padding", 0); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); insets.top = insets.bottom = internalPadding + yThickness; insets.left = insets.right = internalPadding + xThickness; return insets; } public void paintMenuItemBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) { if (GTKLookAndFeel.is2_2()) { engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_NONE, "menuitem", x, y, w, h); } else { engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_OUT, "menuitem", x, y, w, h); } } } private Insets getPopupMenuInsets(SynthContext context, Insets insets) { insets.left = insets.right = insets.top = insets.bottom = 2; return insets; } public void paintPopupMenuBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_OUT, "menu", x, y, w, h); GTKStyle style = (GTKStyle)context.getStyle(); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); engine.paintBackground(context, g, gtkState, style.getGTKColor( context.getComponent(), context.getRegion(), gtkState, GTKColorType.BACKGROUND), x + xThickness, y + yThickness, w - xThickness - xThickness, h - yThickness - yThickness); } // // PROGRESS_BAR // private Insets getProgressBarInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); insets.left = insets.right = style.getXThickness(); insets.top = insets.bottom = style.getYThickness(); return insets; } public void paintProgressBarBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); GTKStyle style = (GTKStyle)context.getStyle(); // Draw the trough. engine.paintBox(context, g, SynthConstants.ENABLED, GTKConstants.SHADOW_IN, "trough", x, y, w, h); } public void paintProgressBarForeground(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) { // Draw the actual progress of the progress bar. if (w != 0 || h != 0) { getEngine(context).paintBox(context, g, SynthConstants.MOUSE_OVER, GTKConstants.SHADOW_OUT, "bar", x, y, w, h); } } public void paintViewportBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { getEngine(context).paintShadow(context, g, SynthConstants.ENABLED, GTKConstants.SHADOW_IN, "scrolled_window", x, y, w, h); } public void paintScrollPaneBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { getEngine(context).paintShadow(context, g, SynthConstants.ENABLED, GTKConstants.SHADOW_IN, "scrolled_window", x, y, w, h); } Insets getScrollPaneInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); insets.right = insets.left = style.getXThickness(); insets.top = insets.bottom = style.getYThickness(); return insets; } // // SEPARATOR // private Insets getSeparatorInsets(SynthContext context, Insets insets) { return insets; } public void paintSeparatorBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { GTKEngine engine = getEngine(context); if (((JSeparator)context.getComponent()).getOrientation() ==
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?