1 /*****************************************************/
2 /* This java file is a part of the */
4 /* - Plouf's Java IRC Client - */
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
8 /* All contacts : theplouf@yahoo.com */
10 /* PJIRC is free software; you can redistribute */
11 /* it and/or modify it under the terms of the GNU */
12 /* General Public License as published by the */
13 /* Free Software Foundation; version 2 or later of */
16 /* PJIRC is distributed in the hope that it will */
17 /* be useful, but WITHOUT ANY WARRANTY; without */
18 /* even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
20 /* General Public License for more details. */
22 /* You should have received a copy of the GNU */
23 /* General Public License along with PJIRC; if */
24 /* not, write to the Free Software Foundation, */
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
26 /* MA 02111-1307 USA */
28 /*****************************************************/
32 import irc.EventDispatcher;
33 import irc.ListenerGroup;
34 import irc.StyleContext;
36 import java.awt.BorderLayout;
37 import java.awt.Button;
39 import java.awt.Panel;
40 import java.awt.event.ActionEvent;
41 import java.awt.event.ActionListener;
44 * Extension for the style selector.
46 public class AWTStyleSelectorEx extends Panel implements ActionListener, FontSelectorListener {
47 private ListenerGroup _lis;
48 private AWTStyleSelector _selector;
49 private FontSelector _fs;
53 * Create a new AWTStyleSelectorEx.
56 * global irc configuration.
58 public AWTStyleSelectorEx(PixxConfiguration config) {
59 _fs = new FontSelector(config);
60 _selector = new AWTStyleSelector(config);
61 setLayout(new BorderLayout());
62 add(_selector, BorderLayout.CENTER);
63 _b = new NonFocusableButton(config.getText(PixxTextProvider.GUI_FONT));
64 _b.setForeground(config.getColor(PixxColorModel.COLOR_WHITE));
65 _b.setBackground(config.getColor(PixxColorModel.COLOR_FRONT));
66 _b.addActionListener(this);
67 if (config.getB("setfontonstyle"))
68 add(_b, BorderLayout.EAST);
69 _lis = new ListenerGroup();
73 * Release this object.
75 public void release() {
77 _b.removeActionListener(this);
85 * Set the style context.
90 public void setStyleContext(StyleContext ct) {
91 _selector.setStyleContext(ct);
97 * @return style prefix.
99 public String getPrefix() {
100 return _selector.getPrefix();
104 * Get the style selector.
106 * @return the style selector.
108 public AWTStyleSelector getStyleSelector() {
118 public void addAWTStyleSelectorExListener(AWTStyleSelectorExListener lis) {
119 _lis.addListener(lis);
126 * listener to remove.
128 public void removeAWTStyleSelectorExListener(AWTStyleSelectorExListener lis) {
129 _lis.removeListener(lis);
133 public void actionPerformed(ActionEvent e) {
134 EventDispatcher.dispatchEventAsync(_fs, "selectFont", new Object[] { this });
138 public void fontSelected(Font f) {
140 _lis.sendEvent("fontSelected", f);