]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/gui/pixx/ScrollablePixxNickList.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / gui / pixx / ScrollablePixxNickList.java
1 /*****************************************************/\r
2 /*          This java file is a part of the          */\r
3 /*                                                   */\r
4 /*           -  Plouf's Java IRC Client  -           */\r
5 /*                                                   */\r
6 /*   Copyright (C)  2002 - 2004 Philippe Detournay   */\r
7 /*                                                   */\r
8 /*         All contacts : theplouf@yahoo.com         */\r
9 /*                                                   */\r
10 /*  PJIRC is free software; you can redistribute     */\r
11 /*  it and/or modify it under the terms of the GNU   */\r
12 /*  General Public License as published by the       */\r
13 /*  Free Software Foundation; version 2 or later of  */\r
14 /*  the License.                                     */\r
15 /*                                                   */\r
16 /*  PJIRC is distributed in the hope that it will    */\r
17 /*  be useful, but WITHOUT ANY WARRANTY; without     */\r
18 /*  even the implied warranty of MERCHANTABILITY or  */\r
19 /*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   */\r
20 /*  General Public License for more details.         */\r
21 /*                                                   */\r
22 /*  You should have received a copy of the GNU       */\r
23 /*  General Public License along with PJIRC; if      */\r
24 /*  not, write to the Free Software Foundation,      */\r
25 /*  Inc., 59 Temple Place, Suite 330, Boston,        */\r
26 /*  MA  02111-1307  USA                              */\r
27 /*                                                   */\r
28 /*****************************************************/\r
29 \r
30 package irc.gui.pixx;\r
31 \r
32 import java.awt.BorderLayout;\r
33 import java.awt.Panel;\r
34 \r
35 /**\r
36  * A scrollable nick list.\r
37  */\r
38 public class ScrollablePixxNickList extends PixxPanel implements PixxScrollBarListener {\r
39         private PixxNickList _list;\r
40         private PixxVerticalScrollBar _scroll;\r
41 \r
42         /**\r
43          * Create a new ScrollablePixxNickList.\r
44          * \r
45          * @param config\r
46          *          the global irc configuration.\r
47          * @param prefixes\r
48          *          known nick prefixes.\r
49          */\r
50         public ScrollablePixxNickList(PixxConfiguration config, char[] prefixes) {\r
51                 super(config);\r
52                 setLayout(new BorderLayout());\r
53                 Panel p = new Panel();\r
54                 p.setLayout(new BorderLayout());\r
55 \r
56                 _list = new PixxNickList(config, prefixes);\r
57                 _scroll = new PixxVerticalScrollBar(config, 0, 0, 0.1);\r
58                 _scroll.addPixxScrollBarListener(this);\r
59                 p.add(_list, BorderLayout.CENTER);\r
60                 p.add(_scroll, BorderLayout.EAST);\r
61 \r
62                 add(p, BorderLayout.CENTER);\r
63                 add(new PixxSeparator(PixxSeparator.BORDER_LEFT), BorderLayout.WEST);\r
64                 add(new PixxSeparator(PixxSeparator.BORDER_RIGHT), BorderLayout.EAST);\r
65                 add(new PixxSeparator(PixxSeparator.BORDER_UP), BorderLayout.NORTH);\r
66                 add(new PixxSeparator(PixxSeparator.BORDER_DOWN), BorderLayout.SOUTH);\r
67         }\r
68 \r
69         @Override\r
70         public void release() {\r
71                 _scroll.removePixxScrollBarListener(this);\r
72                 _list.release();\r
73                 _scroll.release();\r
74                 _list = null;\r
75                 _scroll = null;\r
76                 super.release();\r
77         }\r
78 \r
79         /**\r
80          * Add a listener.\r
81          * \r
82          * @param lis\r
83          *          the listener to add.\r
84          */\r
85         public void addPixxNickListListener(PixxNickListListener lis) {\r
86                 _list.addPixxNickListListener(lis);\r
87         }\r
88 \r
89         /**\r
90          * Remove a listener.\r
91          * \r
92          * @param lis\r
93          *          the listener to remove.\r
94          */\r
95         public void removePixxNickListListener(PixxNickListListener lis) {\r
96                 _list.removePixxNickListListener(lis);\r
97         }\r
98 \r
99         /**\r
100          * Set all the nicks.\r
101          * \r
102          * @param nicks\r
103          *          new nick list.\r
104          */\r
105         public void set(String[] nicks) {\r
106                 _list.set(nicks);\r
107                 _scroll.setMaximum(_list.getNickCount() - 1);\r
108         }\r
109 \r
110         /**\r
111          * Add a nick.\r
112          * \r
113          * @param nick\r
114          *          nick to add.\r
115          */\r
116         public void add(String nick) {\r
117                 _list.add(nick);\r
118                 _scroll.setMaximum(_list.getNickCount() - 1);\r
119         }\r
120 \r
121         /**\r
122          * Remove all nicks.\r
123          */\r
124         @Override\r
125         public void removeAll() {\r
126                 _list.removeAll();\r
127                 _scroll.setMaximum(_list.getNickCount() - 1);\r
128         }\r
129 \r
130         @Override\r
131         public void valueChanged(PixxScrollBar pixScrollBar) {\r
132                 _list.setBase(pixScrollBar.getValue());\r
133         }\r
134 \r
135         /**\r
136          * Clear any off-screen ressources. The next display might be slower.\r
137          */\r
138         public void dispose() {\r
139                 _list.dispose();\r
140         }\r
141 \r
142 }\r