01: /*
02: * Javu WingS - Lightweight Java Component Set
03: * Copyright (c) 2005-2007 Krzysztof A. Sadlocha
04: * e-mail: ksadlocha@programics.com
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20:
21: package com.javujavu.javux.wings.item;
22:
23: import com.javujavu.javux.wings.Style;
24: import com.javujavu.javux.wings.WingConst;
25: import com.javujavu.javux.wings.WingSkin;
26:
27: /**
28: * A collection of styles used by items of list, table, combo etc.<br>
29: * <br>
30: * <b>This class is thread safe.</b>
31: **/
32: public class ItemStyles {
33: public final Style normal;
34: public final Style dark;
35: public final Style disabled;
36: public final Style selected;
37: public final Style focused;
38: public final Style focusedSelected;
39: public final Style disabledSelected;
40:
41: public ItemStyles(String styleId, Style filter) {
42: Style normal = WingSkin.getStyle(styleId, null, WingConst.ITEM
43: | WingConst.NORMAL, null);
44: dark = WingSkin.getStyle(styleId, null,
45: WingConst.ITEM | WingConst.DARK, normal).merge(filter);
46: disabled = WingSkin.getStyle(styleId, null,
47: WingConst.ITEM | WingConst.DISABLED, normal).merge(
48: filter);
49: Style selected = WingSkin.getStyle(styleId, null,
50: WingConst.ITEM | WingConst.SELECTED, normal);
51: focused = WingSkin.getStyle(styleId, null,
52: WingConst.ITEM | WingConst.FOCUSED, selected).merge(
53: filter);
54: focusedSelected = WingSkin
55: .getStyle(
56: styleId,
57: null,
58: WingConst.ITEM | WingConst.SELECTED
59: | WingConst.FOCUSED, selected).merge(
60: filter);
61: disabledSelected = WingSkin.getStyle(
62: styleId,
63: null,
64: WingConst.ITEM | WingConst.DISABLED
65: | WingConst.SELECTED, selected).merge(filter);
66: this .normal = normal.merge(filter);
67: this .selected = selected.merge(filter);
68: }
69:
70: public Style get(boolean enabled, boolean selected,
71: boolean focused, boolean dark) {
72: return (enabled) ? ((selected) ? ((focused) ? focusedSelected
73: : this.selected) : (focused) ? this.focused
74: : (dark) ? this.dark : normal)
75: : (selected) ? disabledSelected : disabled;
76: }
77: }
|