]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/gui/pixx/PixxPanel.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 / PixxPanel.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.Color;\r
33 import java.awt.Graphics;\r
34 import java.awt.Panel;\r
35 \r
36 /**\r
37  * Root panel for all PixxComponents.\r
38  */\r
39 public class PixxPanel extends Panel {\r
40         /**\r
41          * Black.\r
42          */\r
43         public static final int COLOR_BLACK = PixxColorModel.COLOR_BLACK;\r
44         /**\r
45          * White.\r
46          */\r
47         public static final int COLOR_WHITE = PixxColorModel.COLOR_WHITE;\r
48         /**\r
49          * Dark gray.\r
50          */\r
51         public static final int COLOR_DARK_GRAY = PixxColorModel.COLOR_DARK_GRAY;\r
52         /**\r
53          * Gray.\r
54          */\r
55         public static final int COLOR_GRAY = PixxColorModel.COLOR_GRAY;\r
56         /**\r
57          * Light gray.\r
58          */\r
59         public static final int COLOR_LIGHT_GRAY = PixxColorModel.COLOR_LIGHT_GRAY;\r
60         /**\r
61          * Front.\r
62          */\r
63         public static final int COLOR_FRONT = PixxColorModel.COLOR_FRONT;\r
64         /**\r
65          * Back.\r
66          */\r
67         public static final int COLOR_BACK = PixxColorModel.COLOR_BACK;\r
68         /**\r
69          * Selected.\r
70          */\r
71         public static final int COLOR_SELECTED = PixxColorModel.COLOR_SELECTED;\r
72         /**\r
73          * Event.\r
74          */\r
75         public static final int COLOR_EVENT = PixxColorModel.COLOR_EVENT;\r
76         /**\r
77          * Close.\r
78          */\r
79         public static final int COLOR_CLOSE = PixxColorModel.COLOR_CLOSE;\r
80         /**\r
81          * Voice.\r
82          */\r
83         public static final int COLOR_VOICE = PixxColorModel.COLOR_VOICE;\r
84         /**\r
85          * Op.\r
86          */\r
87         public static final int COLOR_OP = PixxColorModel.COLOR_OP;\r
88         /**\r
89          * Semiop.\r
90          */\r
91         public static final int COLOR_SEMIOP = PixxColorModel.COLOR_SEMIOP;\r
92         /**\r
93          * ASL male.\r
94          */\r
95         public static final int COLOR_MALE = PixxColorModel.COLOR_MALE;\r
96         /**\r
97          * ASL femeale.\r
98          */\r
99         public static final int COLOR_FEMEALE = PixxColorModel.COLOR_FEMEALE;\r
100         /**\r
101          * ASL undefined.\r
102          */\r
103         public static final int COLOR_UNDEF = PixxColorModel.COLOR_UNDEF;\r
104 \r
105         /**\r
106          * Pixx Configuration.\r
107          */\r
108         protected PixxConfiguration _pixxConfiguration;\r
109 \r
110         /**\r
111          * Create a new PixxPanel.\r
112          * \r
113          * @param config\r
114          *          global pixx configuration.\r
115          */\r
116         public PixxPanel(PixxConfiguration config) {\r
117                 _pixxConfiguration = config;\r
118         }\r
119 \r
120         /**\r
121          * Release this object. No further method call may be performed.\r
122          */\r
123         public void release() {\r
124                 _pixxConfiguration = null;\r
125         }\r
126 \r
127         /**\r
128          * Get the formatted text from the formatted text code.\r
129          * \r
130          * @param code\r
131          *          text code.\r
132          * @return formatted string.\r
133          */\r
134         public String getText(int code) {\r
135                 return _pixxConfiguration.getText(code);\r
136         }\r
137 \r
138         /**\r
139          * Draw a 3d box at given position.\r
140          * \r
141          * @param g\r
142          *          where to draw.\r
143          * @param x\r
144          *          x position.\r
145          * @param y\r
146          *          y position.\r
147          * @param w\r
148          *          width.\r
149          * @param h\r
150          *          height.\r
151          */\r
152         protected void drawSeparator(Graphics g, int x, int y, int w, int h) {\r
153                 g.setColor(new Color(0x868686));\r
154                 g.drawLine(x + 0, y + 0, x + w - 1, y + 0);\r
155                 g.drawLine(x + 0, y + 0, x + 0, y + 1);\r
156                 g.drawLine(x + w - 1, y + 0, x + w - 1, y + 1);\r
157                 g.setColor(Color.black);\r
158                 g.drawLine(x + 1, y + 1, x + w - 2, y + 1);\r
159 \r
160                 g.setColor(new Color(0x868686));\r
161                 g.drawLine(x + 0, y + 0, x + 0, y + h - 1);\r
162                 g.setColor(Color.black);\r
163                 g.drawLine(x + 1, y + 1, x + 1, y + h - 1);\r
164 \r
165                 g.setColor(new Color(0xD7D3CB));\r
166                 g.drawLine(x + 0, y + h - 1, x + w - 1, y + h - 1);\r
167 \r
168                 g.setColor(new Color(0xD7D3CB));\r
169                 g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);\r
170         }\r
171 \r
172         /**\r
173          * Return the i'th color from the color model.\r
174          * \r
175          * @param col\r
176          *          color index.\r
177          * @return i'th color from color model.\r
178          */\r
179         public Color getColor(int col) {\r
180                 return _pixxConfiguration.getColor(col);\r
181         }\r
182 \r
183         /**\r
184          * Get the current IRC color model.\r
185          * \r
186          * @return the irc color model.\r
187          */\r
188         public PixxColorModel getPixxColorModel() {\r
189                 return _pixxConfiguration.getColorModel();\r
190         }\r
191 }\r