public synchronized javax.swing.plaf.synth.SynthStyle | getStyle(javax.swing.JComponent c, javax.swing.plaf.synth.Region id)Returns the GTKStyle to use based on the
Region id
WidgetType wt = GTKNativeEngine.getWidgetType(c, id);
Object key = null;
if (id == Region.SCROLL_BAR) {
// The style/insets of a scrollbar can depend on a number of
// factors (see GTKStyle.getScrollBarInsets()) so use a
// complex key here.
if (c != null) {
JScrollBar sb = (JScrollBar)c;
boolean sp = (sb.getParent() instanceof JScrollPane);
boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
boolean ltr = sb.getComponentOrientation().isLeftToRight();
boolean focusable = sb.isFocusable();
key = new ComplexKey(wt, sp, horiz, ltr, focusable);
}
}
else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) {
// The style/insets of a checkbox or radiobutton can depend
// on the component orientation, so use a complex key here.
if (c != null) {
boolean ltr = c.getComponentOrientation().isLeftToRight();
key = new ComplexKey(wt, ltr);
}
}
else if (id == Region.BUTTON) {
// The style/insets of a button can depend on whether it is
// default capable or in a toolbar, so use a complex key here.
if (c != null) {
JButton btn = (JButton)c;
boolean toolButton = (btn.getParent() instanceof JToolBar);
boolean defaultCapable = btn.isDefaultCapable();
key = new ComplexKey(wt, toolButton, defaultCapable);
}
}
if (key == null) {
// Otherwise, just use the WidgetType as the key.
key = wt;
}
GTKStyle result = stylesCache.get(key);
if (result == null) {
result = isNativeGtk ?
new GTKNativeStyle(defaultFont, wt) :
new GTKDefaultStyle(defaultFont);
stylesCache.put(key, result);
}
return result;
|