gtkpainter.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,333 行 · 第 1/4 页
JAVA
1,333 行
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; } private void paintSeparatorBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { if (((JSeparator)context.getComponent()).getOrientation() == JSeparator.HORIZONTAL) { engine.paintHline(context, g, SynthConstants.ENABLED, "hseparator", x, y, w, h); } else { engine.paintVline(context, g, SynthConstants.ENABLED, "vseparator", x, y, w, h); } } // // SLIDER // private Insets getSliderInsets(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 Insets getSliderTrackInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int focusSize = style.getClassSpecificIntValue(context, "focus-line-width", 1); int focusPad = style.getClassSpecificIntValue(context, "focus-padding", 1); insets.top = insets.bottom = insets.left = insets.right = focusSize + focusPad; return insets; } private void paintSliderTrackBackground(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); engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_IN, "trough", x, y, w, h); if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { int focusSize = style.getClassSpecificIntValue(context, "focus-line-width", 1); focusSize += style.getClassSpecificIntValue(context, "focus-padding", 1); x -= focusSize; y -= focusSize; w += 2 * focusSize; h += 2 * focusSize; engine.paintFocus(context, g, SynthConstants.ENABLED, "trough", x, y, w, h); } } private void paintSliderThumbBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int orientation; if (((JSlider)context.getComponent()).getOrientation() == JSlider.HORIZONTAL) { orientation = GTKConstants.HORIZONTAL; } else { orientation = GTKConstants.VERTICAL; } engine.paintSlider(context, g, GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()), GTKConstants.SHADOW_OUT, "slider", x, y, w, h, orientation); } // // SPINNER // private void paintSpinnerBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int gtkState = GTKLookAndFeel.synthStateToGTKState(context.getRegion(), context.getComponentState()); engine.paintBox(context, g, gtkState, GTKConstants.SHADOW_IN, "spinbutton", x, y, w, h); } private Insets getSpinnerInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); insets.top = insets.bottom = yThickness; insets.right = 1; insets.left = xThickness; return insets; } private Insets getSpinnerButtonInsets(SynthContext context, Insets insets) { insets.top = insets.bottom = 1; insets.right = insets.left = 1; return insets; } // // SPLIT_PANE_DIVIDER // private void paintSplitPaneDividerBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { int orientation; if (((JSplitPane)context.getComponent()).getOrientation() == JSplitPane.VERTICAL_SPLIT) { orientation = GTKConstants.HORIZONTAL; } else { orientation = GTKConstants.VERTICAL; } engine.paintHandle(context, g, GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()), GTKConstants.UNDEFINED, "paned", x, y, w, h, orientation); } private void paintSplitPaneDividerDragBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { g.setColor(context.getStyle().getColor(context, GTKColorType.BACKGROUND)); g.fillRect(x, y, w, h); paintSplitPaneDividerBackground(context, engine, g, x, y, w, h); } // // TABBED_PANE // private Insets getTabbedPaneInsets(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; } // // TABBED_PANE_CONTENT // private Insets getTabbedPaneContentInsets(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 paintTabbedPaneContentBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { JTabbedPane tabPane = (JTabbedPane)context.getComponent(); GTKStyle style = (GTKStyle)context.getStyle(); Region region = context.getRegion(); int placement = GTKLookAndFeel.SwingOrientationConstantToGTK( tabPane.getTabPlacement()); int start = 0; int size = 0; int selectedIndex = tabPane.getSelectedIndex(); if (selectedIndex != -1) { Rectangle tabBounds = tabPane.getBoundsAt(selectedIndex); if (placement == GTKConstants.TOP || placement == GTKConstants.BOTTOM) { start = tabBounds.x - 1; size = tabBounds.width; } else { start = tabBounds.y - 1; size = tabBounds.height; } } engine.paintBoxGap(context, g, GTKLookAndFeel.synthStateToGTKState( context.getRegion(), context.getComponentState()), GTKConstants.SHADOW_OUT, "notebook", x, y, w, h, placement, start, size); } // // TABBED_PANE_TAB // private Insets getTabbedPaneTabInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); int focusSize = 0; int pad = 2; focusSize = style.getClassSpecificIntValue(context, "focus-line-width",1); insets.left = insets.right = focusSize + pad + xThickness; insets.top = insets.bottom = focusSize + pad + yThickness; return insets; } private void paintTabbedPaneTabBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { GTKStyle style = (GTKStyle)context.getStyle(); int state = context.getComponentState(); int tabIndex = ((TabContext)context).getTabIndex(); int selectedIndex = ((JTabbedPane)context.getComponent()). getSelectedIndex(); int offset = (selectedIndex == tabIndex) ? 0 : 2; int side; state = GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state); switch (((JTabbedPane)context.getComponent()).getTabPlacement()) { case SwingConstants.TOP: side = GTKConstants.BOTTOM; y += offset; h -= offset; break; case SwingConstants.BOTTOM: h -= offset; side = GTKConstants.TOP; break; case SwingConstants.LEFT: x += offset; w -= offset; side = GTKConstants.RIGHT; break; default: w -= offset; side = GTKConstants.LEFT; break; } engine.paintExtension(context, g, state, GTKConstants.SHADOW_OUT, "tab", x, y, w, h, side); } // // TEXT_AREA // private void paintTextAreaBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { GTKStyle style = (GTKStyle)context.getStyle(); int state = context.getComponentState(); engine.paintFlatBoxText(context, g, state, "base", x, y, w, h); } // // TEXT_FIELD // // NOTE: comobobox and FormattedTextField calls this too. private void paintTextFieldBackground(SynthContext context, GTKEngine engine, Graphics g, int x, int y, int w, int h) { GTKStyle style = (GTKStyle)context.getStyle(); boolean interiorFocus = style.getClassSpecificBoolValue(context, "interior-focus", true); int state = context.getComponentState(); int gtkState = GTKLookAndFeel.synthStateToGTKState( context.getRegion(), state); int focusSize; int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); paintTextBackground(context, engine, g, x, y, w, h); state = GTKLookAndFeel.synthStateToGTKState(context.getRegion(),state); if (!interiorFocus && (state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) { focusSize = style.getClassSpecificIntValue(context, "focus-line-width",1); x += focusSize; y += focusSize; w -= 2 * focusSize; h -= 2 * focusSize; } else { focusSize = 0; } engine.paintFlatBoxText(context, g, SynthConstants.ENABLED, "entry_bg", x + xThickness, y + yThickness, w - (2 * xThickness), h - (2 * yThickness)); if (context.getComponent().getName() != "Spinner.formattedTextField") { engine.paintShadow(context, g, SynthConstants.ENABLED, GTKConstants.SHADOW_IN, "entry", x, y, w, h); } if (focusSize > 0) { x -= focusSize; y -= focusSize; w += 2 * focusSize; h += 2 * focusSize; engine.paintFocus(context, g, gtkState, "entry", x, y, w, h); } } // NOTE: this is called for ComboBox, and FormattedTextField. too. private Insets getTextFieldInsets(SynthContext context, Insets insets) { GTKStyle style = (GTKStyle)context.getStyle(); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); boolean interiorFocus = style.getClassSpecificBoolValue(context, "interior-focus", true); int focusSize = 0; int pad = 2; if (!interiorFocus) { focusSize = style.getClassSpecificIntValue(context, "focus-line-width",1); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?