gtkpainter.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,333 行 · 第 1/4 页
JAVA
1,333 行
insets.left = insets.right = focusSize + pad + xThickness; insets.top = insets.bottom = focusSize + pad + yThickness; return insets; } private void paintTextBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { // Text is odd, the background is filled in with // TEXT_BACKGROUND JComponent c = context.getComponent(); // Text is odd in that it uses the TEXT_BACKGROUND vs BACKGROUND. if (c.isOpaque() && c.getBackground() instanceof ColorUIResource) { g.setColor(((GTKStyle)context.getStyle()).getGTKColor( context.getComponent(), context.getRegion(), SynthConstants.ENABLED, GTKColorType.TEXT_BACKGROUND)); g.fillRect(x, y, w, h); } } // // OPTION_Pane // private Insets getOptionPaneInsets(SynthContext context, Insets insets) { insets.left = insets.right = insets.top = insets.bottom = 6; return insets; } // // TOGGLE_BUTTON // public void paintToggleButtonBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int state = context.getComponentState(); int gtkState = GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state); GTKStyle style = (GTKStyle)context.getStyle(); boolean interiorFocus = style.getClassSpecificBoolValue(context, "interior-focus", true); int focusSize = style.getClassSpecificIntValue(context, "focus-line-width",1); int focusPad = style.getClassSpecificIntValue(context, "focus-padding", 1); int totalFocusSize = focusSize + focusPad; int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); JToggleButton toggleButton = (JToggleButton)context.getComponent(); if (!interiorFocus && (state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { x += totalFocusSize; y += totalFocusSize; w -= 2 * totalFocusSize; h -= 2 * totalFocusSize; } int shadow = GTKConstants.SHADOW_OUT; if (toggleButton.isSelected() || ((state & SynthConstants.PRESSED) != 0)) { shadow = GTKConstants.SHADOW_IN; } engine.paintBox(context, g, gtkState, shadow, "button", x, y, w, h); // focus if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { 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, "button", x, y, w, h); } } // // ROOT_PANE // public void paintRootPaneBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); engine.paintFlatBoxNormal(context, g, gtkState, "base", x, y, w, h); } // // SCROLL_BAR // private void paintScrollBarBackground(SynthContext context, GTKEngine engine, 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 focusSize = style.getClassSpecificIntValue(context, "focus-line-width",1); int focusPad = style.getClassSpecificIntValue(context, "focus-padding", 1); int totalFocus = focusSize + focusPad; engine.paintBox(context, g, SynthConstants.PRESSED, GTKConstants.SHADOW_IN, "trough", x + totalFocus, y + totalFocus, w - 2 * totalFocus, h - 2 * totalFocus); if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { engine.paintFocus(context, g, SynthConstants.ENABLED, "trough", x, y, w, h); } } private Insets getScrollBarInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); if (context.getComponent().isFocusable()) { int focusSize = style.getClassSpecificIntValue(context, "focus-line-width",1); int focusPad = style.getClassSpecificIntValue(context, "focus-padding", 1); int w = focusSize + focusPad; int h = focusSize + focusPad; insets.left = insets.right = w; insets.top = insets.bottom = h; } int troughBorder = style.getClassSpecificIntValue(context, "trough-border", 1); insets.left += troughBorder; insets.right += troughBorder; insets.top += troughBorder; insets.bottom += troughBorder; return insets; } // // SCROLL_BAR_THUMB // private void paintScrollBarThumbBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int orientation; if (((JScrollBar)context.getComponent()).getOrientation() == JScrollBar.VERTICAL) { orientation = GTKConstants.VERTICAL; } else { orientation = GTKConstants.HORIZONTAL; } engine.paintSlider(context, g, GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()), GTKConstants.SHADOW_OUT, "slider", x, y, w, h, orientation); } // // TOOL_BAR // private void paintToolBarBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int state = context.getComponentState(); int gtkState = GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state); GTKStyle style = (GTKStyle)context.getStyle(); g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, GTKColorType.BACKGROUND)); engine.paintFlatBox(context, g, gtkState, "handlebox_bin", x, y, w, h); } private Insets getToolBarInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); insets.top = insets.bottom = yThickness; insets.right = insets.left = xThickness; return insets; } private void paintToolBarContentBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int state = context.getComponentState(); int gtkState = GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state); engine.paintShadow(context, g, SynthConstants.ENABLED, GTKConstants.SHADOW_OUT, "handlebox_bin", x, y, w, h); } // // TOOL_TIP // private void paintToolTipBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { engine.paintFlatBoxNormal(context, g, SynthConstants.ENABLED,"tooltip", x, y, w, h); } private Insets getToolTipInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); insets.left = insets.right = style.getXThickness(); insets.top = insets.bottom = style.getYThickness(); return insets; } // // TREE_CELL // private void paintTreeCellBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); // the string arg should alternate based on row being painted, but // we currently don't pass that in. engine.paintFlatBoxText(context, g, gtkState, "cell_odd", x, y, w, h); } private void paintTreeCellFocus(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); engine.paintFocus(context, g, gtkState, "treeview", x, y, w, h); } // // TREE_CELL_RENDERER // private Insets getTreeCellRendererInsets(SynthContext context, Insets insets) { insets.left = insets.right = insets.top = insets.bottom = 1; return insets; } // // TREE_CELL_EDITOR // private Insets getTreeCellEditorInsets(SynthContext context, Insets insets) { insets.left = insets.right = insets.top = insets.bottom = 1; return insets; } private void paintTreeCellEditorBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); engine.paintFlatBoxText(context, g, gtkState, "entry_bg", x, y, w, h); } // // TREE // private void paintTreeBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { // As far as I can tell, these don't call into the engine. int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); g.setColor(((GTKStyle)context.getStyle()).getGTKColor( context.getComponent(), context.getRegion(), gtkState, GTKColorType.TEXT_BACKGROUND)); g.fillRect(x, y, w, h); } // // VIEWPORT // private void paintViewportBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w,int h) { // As far as I can tell, these don't call into the engine. // Also note that you don't want this to call into the engine // as if it where to paint a background JViewport wouldn't scroll // correctly. int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()); g.setColor(((GTKStyle)context.getStyle()).getGTKColor( context.getComponent(), context.getRegion(), gtkState, GTKColorType.TEXT_BACKGROUND)); g.fillRect(x, y, w, h); } // Refer to GTKLookAndFeel for details on this. static class ListTableFocusBorder extends AbstractBorder implements UIResource { public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.setColor(Color.BLACK); GTKEngine.INSTANCE._paintFocus(g, x, y, w, h, GTKEngine.DEFAULT_FOCUS_PATTERN, 1); } public Insets getBorderInsets(Component c) { return new Insets(1, 1, 1, 1); } public Insets getBorderInsets(Component c, Insets i) { if (i == null) { return getBorderInsets(c); } i.left = i.right = i.top = i.bottom = 1; return i; } public boolean isBorderOpaque() { return true; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?