mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 06:57:13 -06:00
JIDE: support JideButton and JideToggleButton
This commit is contained in:
@@ -23,7 +23,9 @@ import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIDefaults;
|
||||
import com.formdev.flatlaf.FlatDefaultsAddon;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.jideoss.ui.FlatJidePainter;
|
||||
import com.jidesoft.plaf.LookAndFeelFactory;
|
||||
import com.jidesoft.plaf.UIDefaultsLookup;
|
||||
import com.jidesoft.plaf.LookAndFeelFactory.UIDefaultsCustomizer;
|
||||
import com.jidesoft.plaf.LookAndFeelFactory.UIDefaultsInitializer;
|
||||
|
||||
@@ -66,6 +68,8 @@ public class FlatJideOssDefaultsAddon
|
||||
* Because JIDE overwrites our UI defaults (from properties files) with its
|
||||
* own UI defaults, we have to first remember our UI defaults in the initializer
|
||||
* (invoked before JIDE overwrites UI defaults) and then restore them in the customizer.
|
||||
* <p>
|
||||
* Invoked from {@link LookAndFeelFactory#installJideExtension()}.
|
||||
*/
|
||||
public static class FlatJideUIDefaultsCustomizer
|
||||
implements UIDefaultsInitializer, UIDefaultsCustomizer
|
||||
@@ -96,6 +100,9 @@ public class FlatJideOssDefaultsAddon
|
||||
jideDefaults = null;
|
||||
}
|
||||
|
||||
// painter
|
||||
UIDefaultsLookup.put( defaults, "Theme.painter", FlatJidePainter.getInstance() );
|
||||
|
||||
// TristateCheckBox
|
||||
defaults.put( "TristateCheckBox.icon", null );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2021 FormDev Software GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.formdev.flatlaf.jideoss.ui;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import com.jidesoft.plaf.LookAndFeelFactory;
|
||||
import com.jidesoft.plaf.basic.BasicJideButtonUI;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link com.jidesoft.swing.JideButton}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatJideButtonUI
|
||||
extends BasicJideButtonUI
|
||||
{
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
// usually JIDE would invoke this in JideButton.updateUI(),
|
||||
// but it does not because FlatLaf already has added the UI class to the UI defaults
|
||||
LookAndFeelFactory.installJideExtension();
|
||||
|
||||
return new FlatJideButtonUI();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2021 FormDev Software GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.formdev.flatlaf.jideoss.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import com.jidesoft.plaf.basic.BasicPainter;
|
||||
import com.jidesoft.plaf.basic.ThemePainter;
|
||||
import com.jidesoft.swing.JideButton;
|
||||
|
||||
/**
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatJidePainter
|
||||
extends BasicPainter
|
||||
{
|
||||
protected final int arc = UIManager.getInt( "Button.arc" );
|
||||
|
||||
public static ThemePainter getInstance() {
|
||||
// always create a new instance of Laf switching
|
||||
return new FlatJidePainter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground( JComponent c, Graphics g, Rectangle rect,
|
||||
Color borderColor, Color background, int orientation )
|
||||
{
|
||||
if( c instanceof JideButton && ((JideButton)c).getButtonStyle() == JideButton.TOOLBAR_STYLE ) {
|
||||
Color oldColor = g.getColor();
|
||||
g.setColor( FlatUIUtils.deriveColor( background, c.getBackground() ) );
|
||||
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
|
||||
|
||||
FlatUIUtils.paintComponentBackground( (Graphics2D) g, rect.x, rect.y,
|
||||
rect.width, rect.height, 0, UIScale.scale( (float) arc ) );
|
||||
|
||||
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
|
||||
g.setColor( oldColor );
|
||||
} else
|
||||
super.paintBackground( c, g, rect, borderColor, background, orientation );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user