1 /*
2 * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
197 private Method resolveMethod(String name) {
198 try {
199 return GTKPainter.class.getMethod(name, getMethodParamTypes());
200 } catch (NoSuchMethodException e) {
201 assert false;
202 }
203 return null;
204 }
205
206 int getIconDimension(SynthContext context) {
207 if (iconDimension >= 0) {
208 return iconDimension;
209 }
210
211 if (context == null) {
212 return DEFAULT_ICON_SIZE;
213 }
214
215 Region region = context.getRegion();
216 GTKStyle style = (GTKStyle) context.getStyle();
217 iconDimension = style.getClassSpecificIntValue(context,
218 "indicator-size",
219 (region == Region.CHECK_BOX_MENU_ITEM ||
220 region == Region.RADIO_BUTTON_MENU_ITEM) ?
221 DEFAULT_TOGGLE_MENU_ITEM_SIZE : DEFAULT_ICON_SIZE);
222
223 if (region == Region.CHECK_BOX || region == Region.RADIO_BUTTON) {
224 iconDimension += 2 * style.getClassSpecificIntValue(context,
225 "indicator-spacing", DEFAULT_ICON_SPACING);
226 } else if (region == Region.CHECK_BOX_MENU_ITEM ||
227 region == Region.RADIO_BUTTON_MENU_ITEM) {
228 iconDimension += 2 * CHECK_ICON_EXTRA_INSET;
229 }
230 return iconDimension;
231 }
232 }
233
234 private static class SynthExpanderIcon extends DelegatingIcon {
235 SynthExpanderIcon(String method) {
236 super(method);
|
1 /*
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
197 private Method resolveMethod(String name) {
198 try {
199 return GTKPainter.class.getMethod(name, getMethodParamTypes());
200 } catch (NoSuchMethodException e) {
201 assert false;
202 }
203 return null;
204 }
205
206 int getIconDimension(SynthContext context) {
207 if (iconDimension >= 0) {
208 return iconDimension;
209 }
210
211 if (context == null) {
212 return DEFAULT_ICON_SIZE;
213 }
214
215 Region region = context.getRegion();
216 GTKStyle style = (GTKStyle) context.getStyle();
217 if (GTKLookAndFeel.is3() && region == Region.MENU) {
218 Object value = style.getClassSpecificValue("arrow-scaling");
219 if (value instanceof Number) {
220 iconDimension = (int)(((Number) value).floatValue() *
221 (style.getFont(context).getSize2D() +
222 2 * style.getClassSpecificIntValue(context,
223 "indicator-spacing", DEFAULT_ICON_SPACING)));
224 if (iconDimension > 0) {
225 return iconDimension;
226 }
227 }
228 }
229 iconDimension = style.getClassSpecificIntValue(context,
230 "indicator-size",
231 (region == Region.CHECK_BOX_MENU_ITEM ||
232 region == Region.RADIO_BUTTON_MENU_ITEM) ?
233 DEFAULT_TOGGLE_MENU_ITEM_SIZE : DEFAULT_ICON_SIZE);
234
235 if (region == Region.CHECK_BOX || region == Region.RADIO_BUTTON) {
236 iconDimension += 2 * style.getClassSpecificIntValue(context,
237 "indicator-spacing", DEFAULT_ICON_SPACING);
238 } else if (region == Region.CHECK_BOX_MENU_ITEM ||
239 region == Region.RADIO_BUTTON_MENU_ITEM) {
240 iconDimension += 2 * CHECK_ICON_EXTRA_INSET;
241 }
242 return iconDimension;
243 }
244 }
245
246 private static class SynthExpanderIcon extends DelegatingIcon {
247 SynthExpanderIcon(String method) {
248 super(method);
|